Skip to content
Snippets Groups Projects
Commit ffb0055b authored by Vincent Aravantinos's avatar Vincent Aravantinos
Browse files

adapts the utils to the new metamodel

refs 2726
parent e5bf38b5
No related branches found
No related tags found
No related merge requests found
......@@ -43,7 +43,7 @@ import org.fortiss.tooling.kernel.service.IConstraintService.IFix;
* @author aravantinos
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: 115825B5DDF0458D48AC3BEA8D4CBF97
* @ConQAT.Rating YELLOW Hash: 87FB5925C1CB74007DE36581134FBC6D
*/
public class ConstraintsUtils {
......@@ -59,22 +59,17 @@ public class ConstraintsUtils {
/**
* Defines <code>constrained</code> as the <code>i</code>-th constrained model element of
* <code>ci</code>. Leaves the other elements as they are if they exist, fill them with
* <code>null</code> till <code>i</code> otherwise.
* <code>constrained</code> till <code>i</code> otherwise (we cannot set to <code>null</code>).
*/
public static void
setConstrainedElement(ConstraintInstance ci, IConstrained constrained, int i) {
EList<ConstrainedWithChecksum> cwcs = ci.getConstrainedsWithChecksum();
if(cwcs.size() <= i) {
for(int j = cwcs.size(); j <= i; j++) {
cwcs.add(j, ConstraintsFactory.eINSTANCE.createConstrainedWithChecksum());
}
EList<IConstrained> constraineds = ci.getConstraineds();
for(int j = constraineds.size(); j <= i; j++) {
constraineds.add(j, constrained);
}
if(!constrained.getConstraintInstances().contains(ci)) {
constrained.getConstraintInstances().add(ci);
}
ConstrainedWithChecksum cwc = cwcs.get(i);
cwc.setConstrained(constrained);
cwc.setChecksum(null);
}
/** @return the first constraint instance of type <code>cstr</code> in <code>c</code>. */
......@@ -144,7 +139,7 @@ public class ConstraintsUtils {
try {
// get(0) because the constraint instance shall contain at least one constrained element
// (responsibility of the caller!) and because we want the first element.
return ci.getConstrainedsWithChecksum().get(0).getConstrained();
return ci.getConstraineds().get(0);
} catch(IndexOutOfBoundsException e) {
return null;
}
......@@ -160,7 +155,7 @@ public class ConstraintsUtils {
try {
// get(1) because the constraint instance shall contain at least one constrained element
// (responsibility of the caller!) and because we want the first element.
return ci.getConstrainedsWithChecksum().get(1).getConstrained();
return ci.getConstraineds().get(1);
} catch(IndexOutOfBoundsException e) {
return null;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment