Home » Modeling » Epsilon » Getting all objects with EGL
| |
Re: Getting all objects with EGL [message #1752711 is a reply to message #1752690] |
Thu, 26 January 2017 12:22 |
C. Santos Messages: 32 Registered: September 2015 |
Member |
|
|
Hi,
My Epsilon version is:
My last version of .emf file is:
@namespace(uri="crystal", prefix="crystal")
package crystal;
@gmf.diagram(foo="bar", rcp="false", onefile="true", diagram.extension="crystal")
class Crystal {
val Links[*] links;
val Subprograms[*] subprograms;
}
@gmf.node(figure="rectangle", border.width="1", label.readOnly="true")
abstract class Subprograms {
@gmf.compartment
val DataAbstractions[*] declarativePart;
@gmf.compartment
val Statements[*] executablePart;
}
@gmf.node(figure="rectangle", border.width="1", label.readOnly="true")
abstract class NamedBlocks extends Subprograms {
attr String name;
@gmf.compartment
val DataAbstractions[*] parameters;
}
@gmf.node(label="name", label.text="Procedure", border.color="255,13,13")
class Procedure extends NamedBlocks {
}
@gmf.node(label="name", label.text="Function", border.color="25,191,108")
class Function extends NamedBlocks {
@gmf.compartment
val DataAbstractions[1] returnPart;
}
@gmf.node(label="description", label.text="Anonymous Block", border.color="43,106,215", border.style="dash")
class AnonymousBlock extends Subprograms {
attr String description;
}
@gmf.node(label="name", figure="rectangle", border.width="1", label.icon="true", label.readOnly="true", label.placement="internal")
abstract class DataAbstractions {
attr String name;
attr ParameterType type;
}
@gmf.node(label.text="Data Type")
class DataType extends DataAbstractions {
attr String className = "DataType";
attr DataTypeOptions options;
attr int precision;
attr int scale;
}
@gmf.node(label.text="Collection")
class Collections extends DataAbstractions {
attr String className = "Collections";
attr String code;
attr String typeName;
}
@gmf.node(label.text="Record")
class Records extends DataAbstractions {
attr String className = "Records";
attr String code;
attr String typeName;
}
@gmf.node(label.text="Cursor")
class Cursor extends DataAbstractions {
attr String className = "Cursor";
attr String cursorQuery;
}
@gmf.node(label="description", label.icon="true", label.placement="internal")
abstract class Statements {
attr String description;
attr boolean isStart;
}
@gmf.node(figure="rectangle")
abstract class CallBlocks extends Statements {
attr String nameSubroutine;
}
@gmf.node(figure="rectangle")
abstract class CursorOperations extends Statements {
attr String cursorName;
}
@gmf.node(figure="rectangle")
abstract class SQLOperations extends Statements {
attr String code;
}
@gmf.node(figure="rectangle")
abstract class IterationStructures extends Statements {
@gmf.compartment
val Statements[*] interations_statements;
}
@gmf.node(figure="rectangle")
abstract class ConditionalStructures extends Statements {
}
@gmf.node(figure="rectangle")
abstract class AdditionalOperations extends Statements {
}
@gmf.node(figure="rectangle")
class Expression extends AdditionalOperations {
attr String className = "Expression";
attr String value;
}
@gmf.node(figure="rectangle")
class Exception extends AdditionalOperations {
attr String className = "Exception";
attr String code;
}
@gmf.node(figure="rectangle")
class If extends ConditionalStructures {
attr String className = "If";
attr String condition;
@gmf.compartment
val Statements[*] true_statements;
@gmf.compartment
val Statements[*] false_statements;
}
@gmf.node(figure="rectangle")
class Case extends ConditionalStructures {
attr String className = "Case";
@gmf.compartment
val Options[*] options;
@gmf.compartment
val Statements[*] default_statements;
}
@gmf.node(figure="rectangle", label="description", label.icon="true", label.placement="internal")
class Options {
attr String className = "Options";
attr String condition;
attr String description;
@gmf.compartment
val Statements[*] case_statements;
}
@gmf.node(figure="rectangle")
class Insert extends SQLOperations {
attr String className = "Insert";
}
@gmf.node(figure="rectangle")
class Update extends SQLOperations {
attr String className = "Update";
}
@gmf.node(figure="rectangle")
class Delete extends SQLOperations {
attr String className = "Delete";
}
@gmf.node(figure="rectangle")
class Select extends SQLOperations {
attr String className = "Select";
}
@gmf.node(figure="rectangle")
class While extends IterationStructures {
attr String className = "While";
attr String condition;
}
@gmf.node(figure="rectangle")
class For extends IterationStructures {
attr String className = "For";
attr String counter;
attr ForCounter typeCounter;
attr int lowestNumber;
attr int highestNumber;
}
@gmf.node(figure="rectangle")
class Loop extends IterationStructures {
attr String className = "Loop";
attr String breakCondition;
}
@gmf.node(figure="rectangle")
class Open extends CursorOperations {
attr String className = "Open";
}
@gmf.node(figure="rectangle")
class Fetch extends CursorOperations {
attr String className = "Fetch";
attr String variableName;
}
@gmf.node(figure="rectangle")
class Close extends CursorOperations {
attr String className = "Close";
}
@gmf.node(figure="rectangle")
class CallProcedure extends CallBlocks {
attr String className = "CallProcedure";
}
@gmf.node(figure="rectangle")
class CallFunction extends CallBlocks {
attr String className = "CallFunction";
}
abstract class Links {
attr String name;
}
@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 extends Links {
ref Statements source;
ref Statements target;
}
@gmf.link(source="source", target="target", incoming="true", target.decoration="arrow", style="dash", color="0,0,0", width="1", label="name", label.text="Case Connection", label.icon="true")
class OptionsTransition extends Links {
ref Options source;
ref Options 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;
NUMERIC = 8;
FLOAT = 9;
DEC = 10;
DECIMAL = 11;
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;
}
The .egl file to transform my model into text is as follow:
#auto-generated by CrystalCASE
[%
for(element in AnonymousBlock.allInstances()) {
var firstElement = getFirstElement(element.executablePart);
printStatements(firstElement);
printElementsByTransition(firstElement);
}
for(element in Procedure.allInstances()) {
var firstElement = getFirstElement(element.executablePart);
printStatements(firstElement);
printElementsByTransition(firstElement);
}
for(element in Function.allInstances()) {
var firstElement = getFirstElement(element.executablePart);
printStatements(firstElement);
printElementsByTransition(firstElement);
}
operation getFirstElement(object){
for(element in object) {
if(element.isStart == true){
return element;
}
}
}
operation Statements getNext() {
return Transition.all.
select(t|t.source = self).
collect(t|t.target).
flatten();
}
operation isEmpty (object) {
if(object.size > 0){
return false;
}
return true;
}
operation printElementsByTransition(object) {
var i = 0 ;
var element;
var x;
for(transition in Transition.all) {
if(i = 0) {
element = object.getNext();
i = 1;
} else{
element = element.first().getNext();
}
printStatements(element.first());
}
}
operation printStatements(object) {
if(not (object == null) ) {
out.println(object);
}
}
%]
When I launch the gmf editor, I use the attached example named construtoresExemplo.crystal and I tried to transform this model into text. I already know that the problem is when I add a transition inside the compartment of object called "If", but I don't know why. With this informations, Could you try to help me, please?
Cheers
|
|
|
Re: Getting all objects with EGL [message #1752713 is a reply to message #1752711] |
Thu, 26 January 2017 12:41 |
|
Hi,
Your code fails with a null pointer exception at the following statement (at that point elements is an empty sequence and as such elements.first() returns null). This is the expected behaviour.
element = element.first().getNext();
Cheers,
Dimitris
|
|
| | | |
Goto Forum:
Current Time: Thu Sep 19 05:12:43 GMT 2024
Powered by FUDForum. Page generated in 0.04330 seconds
|