Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » Getting links with EGL
icon7.gif  Getting links with EGL [message #1739364] Sat, 30 July 2016 18:12 Go to next message
C. Santos is currently offline C. SantosFriend
Messages: 32
Registered: September 2015
Member
Hi all Smile,

I'm creating a dsml that draws diagrams with states(nodes) and transitions(links). I need to get the objects in a EGL code to create the output of my diagram. But, I have to know the order of nodes and links. If the diagram is something like this image:

index.php/fa/26630/0/

I have to know that Object1 have a link to Object2; Object2 has a link to Object3; and all others link also.

How can I do this?

I know how get the objects but they appear in the order that was added to the diagram.. But that isn't necessary the order that I need.

Thank you all in advance Smile
Re: Getting links with EGL [message #1739365 is a reply to message #1739364] Sat, 30 July 2016 19:28 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2154
Registered: July 2009
Location: York, UK
Senior Member

Hi,

If you need to specify that Object1 is the first state in your model, you need to add a respective boolean attribute (e.g. isStart) in your metamodel and set it to true for Object1 and to false for everything else (alternatively you can introduce an InitialState class that extends your State class and make Object1 an instance of the prior). Does this answer your question?

Cheers,
Dimitris
Re: Getting links with EGL [message #1739366 is a reply to message #1739365] Sat, 30 July 2016 19:32 Go to previous messageGo to next message
C. Santos is currently offline C. SantosFriend
Messages: 32
Registered: September 2015
Member
Hi, thanks for your answer. If I know the first state, how can I get the next instance?
Re: Getting links with EGL [message #1739367 is a reply to message #1739366] Sat, 30 July 2016 19:35 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2154
Registered: July 2009
Location: York, UK
Senior Member

Hi,

This depends on your metamodel. Could you please post a copy of your metamodel - preferably a minimal fragment in Emfatic - so that I can advise?

Cheers,
Dimitris
Re: Getting links with EGL [message #1739370 is a reply to message #1739367] Sun, 31 July 2016 00:08 Go to previous messageGo to next message
C. Santos is currently offline C. SantosFriend
Messages: 32
Registered: September 2015
Member
@gmf.diagram(foo="bar", rcp="false", onefile="true", diagram.extension="ccase")
class CCase {
val Transition[*] transitions;
val Function[*] functions;
}

@gmf.node(label="name", label.text="Function", border.color="43,106,215")
class Function{
@gmf.compartment
val Parameters[*] declarativePart;
@gmf.compartment
val Statements[*] executablePart;
}

@gmf.node(label="name", figure="rectangle", border.width="1", label.icon="true",label.readOnly = "true", label.placement="internal")
class Parameters{
attr String name;
attr ParameterType type;
}

...

@gmf.node(label="description", label.icon="true", label.placement="internal")
abstract class Statements{
attr String description;
attr String code;
}

....

@gmf.link(source="source", target="target", incoming="true", target.decoration="arrow", color="0,0,0", width="1")
class Transition{
attr String name = "Connection";
ref Statements source;
ref Statements target;
}

Basically, inside of "Function" it's possible add many statements and parameters. The parameters can be linked by one Transition. I have to know where the diagram starts and the order of the statements linked.
Re: Getting links with EGL [message #1739371 is a reply to message #1739370] Sun, 31 July 2016 04:39 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2154
Registered: July 2009
Location: York, UK
Senior Member

Hi,

Since your model can contain cycles (as illustrated in your initial diagram), there's no "natural" starting point, and as such one needs to be defined explicitly. After adding an isStart attribute to the Statements class, you can find the starting Statements object as follows:

var startStatements = Statements.all.selectOne(s|s.isStart);


To find the "next" Statements of a give Statements element you can use a function like the one below:

operation Statements getNext() {
  return Transition.all.select(t|t.source = self).collect(t|t.target).flatten();
}


Cheers,
Dimitris
Re: Getting links with EGL [message #1739393 is a reply to message #1739371] Sun, 31 July 2016 15:36 Go to previous messageGo to next message
C. Santos is currently offline C. SantosFriend
Messages: 32
Registered: September 2015
Member
Hi,

Thank you for your answer! I'll try and comment later if it works.

Cheers.
Re: Getting links with EGL [message #1739396 is a reply to message #1739371] Sun, 31 July 2016 18:34 Go to previous messageGo to next message
C. Santos is currently offline C. SantosFriend
Messages: 32
Registered: September 2015
Member
Hi Dimitrius,

It works. Thank you!

Att,

[Updated on: Sun, 31 July 2016 18:43]

Report message to a moderator

Re: Getting links with EGL [message #1739398 is a reply to message #1739396] Sun, 31 July 2016 19:08 Go to previous messageGo to next message
C. Santos is currently offline C. SantosFriend
Messages: 32
Registered: September 2015
Member
The object returned by getNext() function is a "sequence" like this:

Sequence {ccase.impl.DeleteImpl@18c04885 (description: Description, isStart: true) (className: Delete, code: DELETE FROM tableA WHERE ID = 1)}

With this, I cannot call the function getNext() again. Is there a way to get the object without this "sequence" name?
Re: Getting links with EGL [message #1739400 is a reply to message #1739398] Sun, 31 July 2016 20:10 Go to previous messageGo to next message
C. Santos is currently offline C. SantosFriend
Messages: 32
Registered: September 2015
Member
sorry, I already get that.

Thank you! Smile
Re: Getting links with EGL [message #1746146 is a reply to message #1739371] Sun, 23 October 2016 20:34 Go to previous messageGo to next message
C. Santos is currently offline C. SantosFriend
Messages: 32
Registered: September 2015
Member
Is it possible set the start element as the first element added on a container?
Re: Getting links with EGL [message #1746160 is a reply to message #1746146] Mon, 24 October 2016 09:49 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2154
Registered: July 2009
Location: York, UK
Senior Member

I'm not sure I understand your question. Could you please elaborate a bit more?

Cheers,
Dimitris
Re: Getting links with EGL [message #1746466 is a reply to message #1746160] Sat, 29 October 2016 19:06 Go to previous messageGo to next message
C. Santos is currently offline C. SantosFriend
Messages: 32
Registered: September 2015
Member
Sorry about the late reply.

1. I have a compartment. When I put an Object inside this compartment, is it possible change one variable name at this time? I wanna set the variable "isStart" to true for the first object inside a compartment.
2. In my model is possible have one compartment inside of another compartment. how can I get the transitions only existing in one compartment? I was getting with "transitions.all" but this is not working anymore for me.
Re: Getting links with EGL [message #1746521 is a reply to message #1746466] Mon, 31 October 2016 14:43 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2154
Registered: July 2009
Location: York, UK
Senior Member

Hi,

#1 is feasible but you'd need to modify the generated EMF code. Let me know if that's something you'd like to do so that I can advise further.
To respond to #2, I'll need to see the latest version of your metamodel.

Cheers,
Dimitris
Re: Getting links with EGL [message #1746594 is a reply to message #1746521] Tue, 01 November 2016 14:30 Go to previous messageGo to next message
C. Santos is currently offline C. SantosFriend
Messages: 32
Registered: September 2015
Member
Hi Dimitris,

#1It's definitely something that I'l like to do.

#2 This is my .emf file updated:

@namespace(uri="crystal", prefix="crystal")
package crystal;

@gmf.diagram(foo="bar", rcp="false", onefile="true", diagram.extension="crystal")
class Crystal {
	val Transition[*] transitions;
	val SelectorTransition[*] selectorTransitions;
	val Procedure[*] procedures;
	val Function[*] functions;
	val AnonymousBlock[*] blocks;
}

//Subprograms
@gmf.node(figure="rectangle", border.width="1", label.readOnly = "true")
abstract class Subprograms{
	attr String name;
}

@gmf.node(label="name", label.text="Procedure", border.color="255,13,13") //vermelho
class Procedure extends Subprograms {
	@gmf.compartment
	val Parameters[*] declarativePart;
	@gmf.compartment
	val Parameters[*] parameters;
	@gmf.compartment
	val Statements[*] executablePart;
}

@gmf.node(label="name", label.text="Function", border.color="25,191,108") //azul	
class Function extends Subprograms {
	@gmf.compartment
	val Parameters[*] declarativePart;
	@gmf.compartment
	val Parameters[*] parameters;
	@gmf.compartment
	val Parameters[1] returnPart;
	@gmf.compartment
	val Statements[*] executablePart;
}

@gmf.node(label="name", label.text="Anonymous Block", border.color="43,106,215", border.style="dash") //verde
class AnonymousBlock extends Subprograms {
	@gmf.compartment
	val Parameters[*] declarativePart;
	@gmf.compartment
	val Statements[*] executablePart;
}

//Parameters
@gmf.node(label="name", figure="rectangle", border.width="1", label.icon="true",label.readOnly = "true", label.placement="internal")
abstract class Parameters{
	attr String name;
	attr ParameterType type;
}

@gmf.node(label.text="Data Type")
class DataType extends Parameters{
	attr String className ="DataType";
	attr DataTypeOptions options;
	attr int precision = 1;
	attr int scale = 0;
}

@gmf.node(label.text="Collection")
class Collections extends Parameters{
	attr String className ="Collection";
	attr String code = "TYPE name IS TABLE OF NUMBER INDEX BY VARCHAR2(20)";
	attr String typeName = "collectionTypeName";
}

@gmf.node(label.text="Record")
class Records extends Parameters{
	attr String className ="Record";
	attr String code = "TYPE recordType IS RECORD (id number(5), name varchar2(25), lastName tableA.last_name%type)";
	attr String typeName = "recordTypeName";
}

@gmf.node(label.text="Cursor")
class Cursor extends Parameters {
	attr String className ="Cursor";
	attr String cursorQuery = "selectStatement";
}

//Statements
@gmf.node(label="description", label.icon="true", label.placement="internal")
abstract class Statements{
	attr String description = "Description";
	attr boolean isStart;
}

@gmf.node(figure="rectangle") 
class Expression extends Statements {
	attr String className ="Expression";
	attr String value = "Type the expression here";
}

@gmf.node(figure="rectangle")
class Exception extends Statements{
	attr String className ="Exception";
	attr String code = "EXCEPTION WHEN no_data_found THEN DBMS_OUTPUT.PUT_LINE('There isnt data registered')";
}

@gmf.node(figure="rectangle")
class If extends Statements{
	attr String className ="If";
	attr String condition = "Type the IF condition";
	
	@gmf.compartment
	val Statements[*] ifs;
	@gmf.compartment
	val Statements[*] elses;
}

@gmf.node(figure="rectangle")
class Case extends Statements{
	attr String className ="Case";
	
	@gmf.compartment
	val Selector[*] cases;
}

@gmf.node(figure="rectangle", label="description", label.icon="true", label.placement="internal")
class Selector {
	attr String className = "Selector";
	attr String condition = "Type the condition for this Selector";
	attr String description = "Description";
	
	@gmf.compartment
	val Statements[*] caseStatements;
}

@gmf.node(figure="rectangle")
class Insert extends Statements{
	attr String className ="Insert";
	attr String code = "INSERT INTO tableA (id, name) VALUES (1, 'example')";
}

@gmf.node(figure="rectangle")
class Update extends Statements{
	attr String className ="Update";
	attr String code = "UPDATE tableA SET name = 'example' WHERE id = 1";
}

@gmf.node(figure="rectangle")
class Delete extends Statements{
	attr String className ="Delete";
	attr String code = "DELETE FROM tableA WHERE ID = 1";
}

@gmf.node(figure="rectangle")
class Select extends Statements{
	attr String className ="Select";
	attr String code = "SELECT * FROM tableA WHERE id = 1";
}

@gmf.node(figure="rectangle")
class While extends Statements{
	attr String className ="While";
	attr String condition = "Type the WHILE condition";
	@gmf.compartment
	val Statements[*] whileStatements;
}

@gmf.node(figure="rectangle")
class For extends Statements{
	attr String className ="For";
	attr String counter = "Type the name of the FOR counter";
	attr ForCounter typeCounter;
	attr int lowestNumber = 0;
	attr int highestNumber = 0;

	@gmf.compartment
	val Statements[*] forStatements;
}

@gmf.node(figure="rectangle")
class Loop extends Statements{
	attr String className ="Loop";
	attr String breakCondition = "Type the break condition for LOOP";
	
	@gmf.compartment
	val Statements[*] loopStatements;
}

@gmf.node(figure="rectangle")
class Open extends Statements{
	attr String className ="Open";
	attr String cursorName = "cursorName";
}

@gmf.node(figure="rectangle")
class Fetch extends Statements{
	attr String className ="Fetch";
	attr String cursorName = "cursorName";
	attr String variableName = "variableCursor";
}

@gmf.node(figure="rectangle")
class Close extends Statements{
	attr String className ="Close";
	attr String cursorName = "cursorName";
}

@gmf.node(figure="rectangle")
class CallProcedure extends Statements{
	attr String className ="CallProcedure";
	attr String nameSubroutine;
}

@gmf.node(figure="rectangle")
class CallFunction extends Statements{
	attr String className ="CallFunction";
	attr String nameSubroutine;
}

@gmf.link(source="source", target="target", incoming="true", target.decoration="arrow", color="0,0,0", width="1", label="name", label.text="Statement Connection", label.icon="true")
class Transition{
    attr String name = "Statement Connection";
    ref Statements source;
    ref Statements target;
}

@gmf.link(source="source", target="target", incoming="true", target.decoration="arrow", color="0,0,0", width="1", label="name", label.text="Case Connection", label.icon="true")
class SelectorTransition{
    attr String name = "Case Connection";
    ref Selector source;
    ref Selector target;
}

enum ParameterType {
    IN = 0;
    OUT = 1;
    IN_OUT = 2;
}

enum ForCounter {
	NORMAL = 0;
	REVERSE = 1;
}

enum DataTypeOptions {
	CHAR = 0;
	NCHAR = 1;
	NVARCHAR2 = 2;
	VARCHAR2 = 3;
	LONG = 4;
	RAW = 5;
	LONG_RAW = 6;
	NUMBER = 7; //can modify the precision and scale
	NUMERIC = 8; //can modify the precision and scale
	FLOAT = 9;
	DEC = 10; //can modify the precision and scale
	DECIMAL = 11; //can modify the precision and scale
	INTEGER = 12;
	INT = 13;
	SMALLINT = 14;
	REAL = 15;
	DOUBLE = 16;
	DATE = 17;
	TIMESTAMP_WITH_TIME_ZONE = 18;
	TIMESTAMP_WITH_LOCAL_TIME_ZONE = 19;
	INTERVAL_YEAR_TO_MONTH = 20;
	INTERVAL_DAY_TO_SECOND = 21;
	BFILE = 22;
	BLOB = 23; 
	CLOB = 24;
	NCLOB = 25;
	ROWID = 26;
	UROWID = 27;
}


Cheers.
Re: Getting links with EGL [message #1746611 is a reply to message #1746594] Tue, 01 November 2016 18:20 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2154
Registered: July 2009
Location: York, UK
Senior Member

Hi,

#1: You can add an opposite reference from the object to its container and then override the setXYZ() method in the generated EMF code to update the value of isStart accordingly if at that point the container doesn't have any additional children.

#2: In your metamodel Transitions can only be contained under a top-level Crystal element. As such, I suspect that what you want to do is to get all transitions linking "Statements" in a particular compartment. To do this, you need to get hold of the Statements of interest first and then query all transitions (Transition.all) to find out which of them have Statements of interest as their source/target.

Cheers,
Dimitris
Re: Getting links with EGL [message #1752337 is a reply to message #1739364] Sun, 22 January 2017 10:36 Go to previous messageGo to next message
C. Santos is currently offline C. SantosFriend
Messages: 32
Registered: September 2015
Member
Hi,

How can I do a Link with dashed arrow?

Cheers
Re: Getting links with EGL [message #1752338 is a reply to message #1752337] Sun, 22 January 2017 11:05 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2154
Registered: July 2009
Location: York, UK
Senior Member

Hi,

I don't think that this is supported out of the box in Eugenia. I'd suggest sending a message to the GMF forum and when you've figured out how it's done using plain GMF you can use a polishing transformation to automate the process.

Cheers,
Dimitris
Re: Getting links with EGL [message #1752340 is a reply to message #1752338] Sun, 22 January 2017 11:19 Go to previous message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2154
Registered: July 2009
Location: York, UK
Senior Member

Actually, this seems to be quite straightforward. You need to locate the Polyline Decoration that corresponds to the arrow of interest in your .gmfgraph model and turn its line kind to LINE_DASH. If you do this manually, you'll then need to right-click on your .gmfmap model and select "Create generator model ..." and then right-click on your .gmfgen and select "Generate diagram code".

Cheers,
Dimitris
Previous Topic:Invoke .emf from Ant programatically ?
Next Topic:How to export .model_diagram file into a plug-in ?
Goto Forum:
  


Current Time: Thu Mar 28 09:15:43 GMT 2024

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

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

Back to the top