Bug 579750 https://bugs.eclipse.org/bugs/show_bug.cgi?id=579750
do not generate a setter and a getter for SE inside a dynamic SEC
Change-Id: I9da9d84174c7f5b6f2ddd2b1a54fa5ccf770b106
Signed-off-by: Asma Smaoui <asma.smaoui@cea.fr>
diff --git a/plugins/modeling/org.eclipse.papyrus.designer.languages.java.codegen/src/org/eclipse/papyrus/designer/languages/java/codegen/utils/JavaGenUtils.java b/plugins/modeling/org.eclipse.papyrus.designer.languages.java.codegen/src/org/eclipse/papyrus/designer/languages/java/codegen/utils/JavaGenUtils.java
index 3629f90..1cf74ac 100644
--- a/plugins/modeling/org.eclipse.papyrus.designer.languages.java.codegen/src/org/eclipse/papyrus/designer/languages/java/codegen/utils/JavaGenUtils.java
+++ b/plugins/modeling/org.eclipse.papyrus.designer.languages.java.codegen/src/org/eclipse/papyrus/designer/languages/java/codegen/utils/JavaGenUtils.java
@@ -169,7 +169,8 @@
return "String";
case "ENTITY":
return "String";
- // These include java primitives types: int, byte, short, long, float, double, boolean, and char
+ // These include java primitives types: int, byte, short, long, float, double,
+ // boolean, and char
case "int":
return "int";
case "boolean":
@@ -186,8 +187,7 @@
return "double";
case "char":
return "char";
-
-
+
default:
return "Object";
@@ -387,7 +387,7 @@
for (Operation o : getAllownedOperations(c)) {
// get new name concatenated with the parent name
String name = ((NamedElement) p.getOwner()).getName() + "_" + p.getName();
- if (o.getName().equals("get_"+name))
+ if (o.getName().equals("get_" + name))
return true;
}
return false;
@@ -424,9 +424,8 @@
public static Boolean isOperationExists(Classifier c, Classifier p) {
Classifier submodel = (Classifier) JavaGenUtils.getSubmodel(c);
for (Operation o : getAllownedOperations(submodel)) {
- String newname = ((Classifier) ((Classifier) p).getOwner()).getName() + "_"
- + ((Classifier) p).getName();
- if (o.getName().equals("get_"+ newname))
+ String newname = ((Classifier) p.getOwner()).getName() + "_" + p.getName();
+ if (o.getName().equals("get_" + newname))
return true;
}
return false;
@@ -469,18 +468,18 @@
public static Operation getOperation(Classifier c, Classifier sec) {
// reconstitute the name by concatinating the parent
// true only if the parent is the classifier
- String newName = "get_"+((NamedElement) sec.getOwner()).getName()+"_"+sec.getName();
+ String newName = "get_" + ((NamedElement) sec.getOwner()).getName() + "_" + sec.getName();
for (Operation o : getAllownedOperations(c)) {
if (o.getName().equals(newName))
return o;
}
return null;
}
-
+
public static Operation getOperation(Classifier c, Property p) {
// reconstitute the name by concatinating the parent
-
- String name = "get_"+((NamedElement) p.getOwner()).getName() + "_" + p.getName();
+
+ String name = "get_" + ((NamedElement) p.getOwner()).getName() + "_" + p.getName();
for (Operation o : getAllownedOperations(c)) {
if (o.getName().equals(name))
return o;
@@ -597,10 +596,15 @@
public static List<Property> getAllownedAttributes(Classifier classifier) {
List<Property> allattributes = new ArrayList();
+ // direct submodel properties
allattributes.addAll(classifier.allAttributes());
for (Element el : classifier.allOwnedElements()) {
if (el instanceof Classifier) {
- allattributes.addAll(((Classifier) el).allAttributes());
+ // check that the SEC is not dynamic other wise do not add its attributes
+ if (GenUtils.hasStereotype(classifier, org.eclipse.papyrus.aas.SubmodelElementCollection.class)
+ && !JavaGenUtils.isConnectSEC(((Classifier) el))) {
+ allattributes.addAll(((Classifier) el).allAttributes());
+ }
}
}
return allattributes;
@@ -628,14 +632,13 @@
}
return td;
}
-
+
public static String removedot(String element) {
String result = element;
String[] strings = element.split("\\.");
if (strings != null && strings.length > 1) {
result = strings[1];
-
}
return result;
@@ -666,5 +669,4 @@
}
}
-
}