Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » ETL models(Loading ETL models)
ETL models [message #1852643] Sun, 29 May 2022 15:08 Go to next message
Alireza Rouhi is currently offline Alireza RouhiFriend
Messages: 148
Registered: December 2015
Senior Member
Hi All,

As you know, model transformations are considered as models in MDE. I was wondering whether is there any trick to load ETL models (i.e., transformations conforming ETL metamodel) in the "run configuration" models' add dialogue?

index.php/fa/42122/0/

I would like to transform the ETL model transformations themselves by applying refactoring through model transformation patterns which apply on the ETL model transformations as their input models.

Thanks
Alireza
  • Attachment: rc-etl.png
    (Size: 72.05KB, Downloaded 502 times)
Re: ETL models [message #1852645 is a reply to message #1852643] Sun, 29 May 2022 17:26 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2165
Registered: July 2009
Location: York, UK
Senior Member

Hi Alireza,

There is no EMC driver for ETL transformations I'm afraid, however, you can update/refactor ETL transformations through Epsilon's API in Java.

Best,
Dimitris
Re: ETL models [message #1852649 is a reply to message #1852645] Mon, 30 May 2022 05:32 Go to previous messageGo to next message
Alireza Rouhi is currently offline Alireza RouhiFriend
Messages: 148
Registered: December 2015
Senior Member
Thanks a lot.
Alireza
Re: ETL models [message #1852914 is a reply to message #1852649] Fri, 10 June 2022 13:23 Go to previous messageGo to next message
Alireza Rouhi is currently offline Alireza RouhiFriend
Messages: 148
Registered: December 2015
Senior Member
Dear Dimitris,

Hi,
I would like to explore and print an example "ETL moulde file rules" through using Epsilon's API in Java. Please, provide a minimal example for me to do this task.

Thank you so much
Alireza
Re: ETL models [message #1852915 is a reply to message #1852914] Fri, 10 June 2022 13:36 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2165
Registered: July 2009
Location: York, UK
Senior Member

Hi Alireza,

Please find a minimal example below.

EtlModule m = new EtlModule();
m.parse("rule A2B transform a : In!A to b : Out!B { b.name = a.name; }");

// Get the first rule of the transformation
TransformationRule a2b = m.getTransformationRules().get(0);
// Print its name
System.out.println(a2b.getName());

// Get the body of the A2B rule
StatementBlock body = (StatementBlock) a2b.getBody().getBody();
// Print the number of statements it contains
System.out.println(body.getStatements().size());


Best,
Dimitris

[Updated on: Fri, 10 June 2022 13:36]

Report message to a moderator

Re: ETL models [message #1852916 is a reply to message #1852915] Fri, 10 June 2022 13:47 Go to previous messageGo to next message
Alireza Rouhi is currently offline Alireza RouhiFriend
Messages: 148
Registered: December 2015
Senior Member
Great. Thanks for your quick response.
Alireza
Re: ETL models [message #1852918 is a reply to message #1852916] Fri, 10 June 2022 14:08 Go to previous messageGo to next message
Alireza Rouhi is currently offline Alireza RouhiFriend
Messages: 148
Registered: December 2015
Senior Member
Dear Dimitris,

When I run the example, I found some errors like undefined methods ..., etc. What should I do to resolve these issues.
I have imported the Epsilon sample projects from the Git and updated the class path in IDE as well.

index.php/fa/42167/0/

Thanks again
Alireza
Re: ETL models [message #1852931 is a reply to message #1852918] Sat, 11 June 2022 10:46 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2165
Registered: July 2009
Location: York, UK
Senior Member

Hi Alireza,

You don't need to check out the Epsilon source code to use its API. My recommendation would be to use Epsilon's Maven artefacts like this example project does.

Best,
Dimitris
Re: ETL models [message #1852943 is a reply to message #1852931] Sun, 12 June 2022 04:31 Go to previous messageGo to next message
Alireza Rouhi is currently offline Alireza RouhiFriend
Messages: 148
Registered: December 2015
Senior Member
Hi Dimitris,

Thanks for your solutions. But I cannot run the suggested example too. Is there any missed settings which resolves these issues?
index.php/fa/42172/0/


Regards,
Alireza
Re: ETL models [message #1852944 is a reply to message #1852943] Sun, 12 June 2022 08:47 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2165
Registered: July 2009
Location: York, UK
Senior Member

Hi Alireza,

I note that several of the projects in your workspace are closed which could be related to the issue you are facing. In any case, debugging over screenshots is not ideal so could you please share with me a minimal example I can use to reproduce the issue you are encountering?

Best,
Dimitris
Re: ETL models [message #1852945 is a reply to message #1852944] Sun, 12 June 2022 08:50 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2165
Registered: July 2009
Location: York, UK
Senior Member

It may also be that Maven support is not installed in your Eclipse instance. If this is the case, please install https://www.eclipse.org/m2e/

Best,
Dimitris
Re: ETL models [message #1852946 is a reply to message #1852945] Sun, 12 June 2022 09:38 Go to previous messageGo to next message
Alireza Rouhi is currently offline Alireza RouhiFriend
Messages: 148
Registered: December 2015
Senior Member
Thanks a lot. The Maven installation resolved the raised issues.

Regards,
Alireza
Re: ETL models [message #1853005 is a reply to message #1852946] Tue, 14 June 2022 14:35 Go to previous messageGo to next message
Alireza Rouhi is currently offline Alireza RouhiFriend
Messages: 148
Registered: December 2015
Senior Member
Hi Dimitris,

I would like to parse an ETL source file. So, I used your suggested sample code:
EtlModule m = new EtlModule();
m.parse("rule A2B transform a : In!A to b : Out!B { b.name = a.name; }");

// Get the first rule of the transformation
TransformationRule a2b = m.getTransformationRules().get(0);
// Print its name
System.out.println(a2b.getName());

// Get the body of the A2B rule
StatementBlock body = (StatementBlock) a2b.getBody().getBody();
// Print the number of statements it contains
System.out.println(body.getStatements().size());

When I replace the parse method's argument with a filename or a file path,

EtlModule m = new EtlModule();

//m.parse("rule A2B transform a : In!A to b : Out!B {b.name = a.name;}");
m.parse("/org.eclipse.epsilon.examples.standalone/src/org/eclipse/epsilon/examples/standalone/etl/Sample.etl");
		
// Get the first rule of the transformation
System.out.println(m.getTransformationRules());
TransformationRule a2b = m.getTransformationRules().get(0);
// Print its name
System.out.println(a2b.getName());

// Get the body of the A2B rule
StatementBlock body = (StatementBlock) a2b.getBody().getBody();
// Print the number of statements it contains
System.out.println(body.getStatements().size());


I got the following exception, due to the emptiness of the returned rule list from calling the parse method on the ETL module m!
Is there any trick to resolve this issue. Thanks a lot.

index.php/fa/42189/0/

Regards,
Alireza
Re: ETL models [message #1853009 is a reply to message #1853005] Tue, 14 June 2022 15:27 Go to previous messageGo to next message
Horacio Hoyos is currently offline Horacio HoyosFriend
Messages: 242
Registered: October 2009
Location: Mexico
Senior Member

To parse a file you need to pass a File object to the parse method. Something in the lines of

File eltFile = new File("/some/path/to/Sample.etl");
m.parse(etlFile);


Since you are executing from java, you ned to make sure that the etl file can be found. Using paths to load files is error prone, so I would suggest finding the file as a resource.

Assuming that Sample.etl is in the same package as your EtlMParser class (from yoor screenshot), then do:

URL url = getClass().getResource("Sample.etl");
File file = new File(url.getPath());
m.parse(etlFile);


Horacio Hoyos Rodriguez
Kinori Tech
Need professional support for Epsilon, EMF?
Go to: https://kinori.tech
Re: ETL models [message #1853013 is a reply to message #1853009] Tue, 14 June 2022 16:25 Go to previous messageGo to next message
Alireza Rouhi is currently offline Alireza RouhiFriend
Messages: 148
Registered: December 2015
Senior Member
Hi Horacio,

Thank you very much.

Regards,
Alireza
Re: ETL models [message #1853120 is a reply to message #1852915] Sun, 19 June 2022 05:06 Go to previous messageGo to next message
Alireza Rouhi is currently offline Alireza RouhiFriend
Messages: 148
Registered: December 2015
Senior Member
Hi Dimitris,

I like to modify an existing ETL module in general and its constituent rules and their structures like source, target, statements, ... in particular from Java. I did not find any similar example in the provided standalone examples of Epsilon. Is there any document or a minimal example to use for these purposes?

For example, how can I modify and update the body section of an existing rule in an ETL module? Thank you very much

Regards,
Alireza
Re: ETL models [message #1853134 is a reply to message #1853120] Mon, 20 June 2022 05:48 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2165
Registered: July 2009
Location: York, UK
Senior Member

Hi Alireza,

TransformationRule, StatementBlock etc. are mutable so e.g. to add a new statement at the end of the rule you could use the following snippet:

body.getStatements().add(new ExpressionStatement(
		new OperationCallExpression(new StringLiteral("Executed rule A2B"), 
				new NameExpression("println"))));

// Optional - to see the ETL source of the modified transformation
System.out.println(new EtlUnparser().unparse(m));


Best,
Dimitris
Re: ETL models [message #1853135 is a reply to message #1853134] Mon, 20 June 2022 06:04 Go to previous messageGo to next message
Alireza Rouhi is currently offline Alireza RouhiFriend
Messages: 148
Registered: December 2015
Senior Member
Great. Thanks a lot.

Regards,
Alireza
Re: ETL models [message #1853136 is a reply to message #1853134] Mon, 20 June 2022 06:09 Go to previous messageGo to next message
Alireza Rouhi is currently offline Alireza RouhiFriend
Messages: 148
Registered: December 2015
Senior Member
Dear Dimitris,

How to apply these changes to the ETL source file (here, Sample.etl) corresponding to the module m?

Thanks,
Alireza

[Updated on: Mon, 20 June 2022 06:10]

Report message to a moderator

Re: ETL models [message #1853137 is a reply to message #1853136] Mon, 20 June 2022 06:13 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2165
Registered: July 2009
Location: York, UK
Senior Member

You could save the result of "new EtlUnparser().unparse(m)" to your ETL file. Any comments in your original transformation won't be preserved and indentation may be different, however, the generated source should be valid ETL (if not, please raise an issue in the Bugzilla).

Best,
Dimitris
Re: ETL models [message #1853138 is a reply to message #1853137] Mon, 20 June 2022 06:23 Go to previous messageGo to next message
Alireza Rouhi is currently offline Alireza RouhiFriend
Messages: 148
Registered: December 2015
Senior Member
OK. Thank you very much.

Regards,
Alireza
Re: ETL models [message #1854343 is a reply to message #1853138] Mon, 15 August 2022 11:57 Go to previous messageGo to next message
Alireza Rouhi is currently offline Alireza RouhiFriend
Messages: 148
Registered: December 2015
Senior Member
Hi All,

I would like to extract assignment expressions in rules/operations (AS Strings) of an ETL source file.
I want to count the number of tokens in the mentioned assignment expressions for refactoring purposes.
Is there any trick to do this? Thanks a million.

Alireza

[Updated on: Mon, 15 August 2022 11:58]

Report message to a moderator

Re: ETL models [message #1854365 is a reply to message #1854343] Tue, 16 August 2022 10:01 Go to previous messageGo to next message
Antonio Garcia-Dominguez is currently offline Antonio Garcia-DominguezFriend
Messages: 594
Registered: January 2010
Location: Birmingham, UK
Senior Member

Hi Alireza,

(EDITED: I did make the silly mistake of suggesting rule.visit(...) instead of rule.accept(...). Sorry!)

I would suggest these steps:

* Parse the ETL file into an EtlModule.
* Loop over the elements of module.getTransformationRules().
* For each rule, use rule.accept(visitor), where visitor should be an IEtlVisitor implementation of your
own. You will most likely want to do something in the visit(AssignmentStatement) method to
capture the assignment you are visiting.

Note that we do not store the ANTLR AST objects in the ETL DOM, so you won't have access to the
original tokens from the visitor. Still, you can just have all other visitor methods increment a counter
when you are inside an assignment, so you will have a measure of the size of the subtree of the
DOM rooted at that assignment (which would still give you a measure of complexity).

Best,
Antonio

[Updated on: Thu, 18 August 2022 15:12]

Report message to a moderator

Re: ETL models [message #1854367 is a reply to message #1854365] Tue, 16 August 2022 11:08 Go to previous messageGo to next message
Alireza Rouhi is currently offline Alireza RouhiFriend
Messages: 148
Registered: December 2015
Senior Member
Hi Antonio,
Thank you very much.
Alireza
Re: ETL models [message #1854370 is a reply to message #1854367] Tue, 16 August 2022 12:04 Go to previous messageGo to next message
Alireza Rouhi is currently offline Alireza RouhiFriend
Messages: 148
Registered: December 2015
Senior Member
Dear Antonio,

I tried to follow your suggested steps. My source code is as follows. I do not get my expected result. For example, I like to get 13 for the expression
(1 - s.risk) * (s.shares -> collect(x | x.price * x.quantity) -> sum())

while the code output is 2 instead!

		EtlModule module = new EtlModule();		
		module.parse(EpsilonStandalone.class.getResource("Sample.etl").toURI());
                module.getTransformationRules();

		for (int i = 0; i < module.getTransformationRules().size(); i++)
		{
			TransformationRule rule = module.getTransformationRules().get(i);
                         .
                         .
                         .
			StatementBlock body = (StatementBlock) rule.getBody().getBody();
			for (int c = 0; c < body.getStatements().size(); c++)
			{
				if (body.getStatements().get(c).getClass().getName().contains("Assignment")) {
					int MEL = IEtlVisitor.visit(body.getStatements().get(c));
					System.out.println(", (MEL = " + MEL + ")");
				}
			}
                 }

and my visit method is as follows:
public interface IEtlVisitor extends IErlVisitor{
	//public void visit(TransformationRule transformationRule);
	public static int visit(Statement statement) {
		return statement.getArguments().length;
	}

	public static int visit(org.eclipse.epsilon.eol.dom.Statement statement) {

		return statement.getChildren().size();
	}
}


Is there any trick to correct the above code?
Thanks a lot
Alireza

[Updated on: Thu, 18 August 2022 04:48]

Report message to a moderator

Re: ETL models [message #1854433 is a reply to message #1854370] Thu, 18 August 2022 12:55 Go to previous messageGo to next message
Antonio Garcia-Dominguez is currently offline Antonio Garcia-DominguezFriend
Messages: 594
Registered: January 2010
Location: Birmingham, UK
Senior Member

Hi Alireza,

getChildren() only gives you the direct children, not all the descendants. That's why I suggested incrementing a counter instead (e.g. ++size) whenever you visit any other DOM node from inside an assignment.

Best,
Antonio
Re: ETL models [message #1854434 is a reply to message #1854433] Thu, 18 August 2022 13:05 Go to previous messageGo to next message
Alireza Rouhi is currently offline Alireza RouhiFriend
Messages: 148
Registered: December 2015
Senior Member
Thanks for your reply and suggestion Antonio.
Alireza
Re: ETL models [message #1854438 is a reply to message #1854434] Thu, 18 August 2022 15:14 Go to previous messageGo to next message
Antonio Garcia-Dominguez is currently offline Antonio Garcia-DominguezFriend
Messages: 594
Registered: January 2010
Location: Birmingham, UK
Senior Member

By the way, I just realised that I made the silly mistake of asking you to do rule.visit(visitor), when it should have been rule.accept(visitor). I was closing down things before the holidays and it slipped my mind!

I think you mentioned it in a previous version of one of your messages :-).

IEtlVisitor implements the Visitor design pattern, as described here: https://refactoring.guru/design-patterns/visitor

Re: ETL models [message #1854439 is a reply to message #1854438] Thu, 18 August 2022 15:15 Go to previous messageGo to next message
Antonio Garcia-Dominguez is currently offline Antonio Garcia-DominguezFriend
Messages: 594
Registered: January 2010
Location: Birmingham, UK
Senior Member

The idea is that you ask the rule to "accept" the visitor (like accepting a visitor into your house), and then the rule will walk the visitor through its subtree of the DOM (repeatedly calling the various "visit" methods, like visiting the LivingRoom, the Kitchen, the Bedroom and so on).

[Updated on: Thu, 18 August 2022 15:16]

Report message to a moderator

Re: ETL models [message #1854470 is a reply to message #1854439] Sat, 20 August 2022 08:49 Go to previous message
Alireza Rouhi is currently offline Alireza RouhiFriend
Messages: 148
Registered: December 2015
Senior Member
Thanks a lot for more clarification.
Alireza
Previous Topic:Model generation starting from UML diagrams and c++ codes
Next Topic:ETL model examples' metamodels
Goto Forum:
  


Current Time: Sat Apr 27 10:54:45 GMT 2024

Powered by FUDForum. Page generated in 0.05679 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top