Skip to content

Commit

Permalink
Fix odesign validation.
Browse files Browse the repository at this point in the history
Signed-off-by: Mélanie Bats <[email protected]>
  • Loading branch information
fbats authored and mbats committed May 19, 2017
1 parent d9bc097 commit 1e8b74d
Show file tree
Hide file tree
Showing 285 changed files with 2,833 additions and 75,400 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -256,13 +256,6 @@ litigation.
version="0.0.0"
unpack="false"/>

<plugin
id="org.obeonetwork.dsl.uml2.properties"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>

<plugin
id="org.obeonetwork.dsl.uml2.navigator"
download-size="0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,13 +264,6 @@ litigation.
version="0.0.0"
unpack="false"/>

<plugin
id="org.obeonetwork.dsl.uml2.properties"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>

<plugin
id="org.obeonetwork.dsl.uml2.navigator"
download-size="0"
Expand Down Expand Up @@ -389,10 +382,12 @@ litigation.
install-size="0"
version="0.0.0"
unpack="false"/>

<plugin
id="org.obeonetwork.dsl.uml2.dashboard"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>

</feature>
494 changes: 472 additions & 22 deletions plugins/org.obeonetwork.dsl.uml2.design/description/uml2.odesign

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,9 @@ public String computeAssociationNAryBeginLabel(Association association, DDiagram
*/
private Association createAssociation(Element source, Element target) {
final Association association = UMLFactory.eINSTANCE.createAssociation();
final Property end1 = createAssociationEnd((Type)source);
final Property end1 = AssociationServices.INSTANCE.createAssociationEnd((Type)source);
association.getMemberEnds().add(end1);
final Property end2 = createAssociationEnd((Type)target);
final Property end2 = AssociationServices.INSTANCE.createAssociationEnd((Type)target);
association.getMemberEnds().add(end2);

association.getOwnedEnds().add(end1);
Expand Down Expand Up @@ -194,21 +194,14 @@ private Association createAssociationAddEnd(Element source, Element target) {
if (isBroken(association)) { // Look for broken association
fixAssociation(association, type);
} else { // create new end
final Property end = createAssociationEnd(type);
final Property end = AssociationServices.INSTANCE.createAssociationEnd(type);
association.getNavigableOwnedEnds().add(end);
association.getOwnedEnds().add(end);
}
return association;
}

private Property createAssociationEnd(Type type) {
final Property property = UMLFactory.eINSTANCE.createProperty();
property.setName(getAssociationEndsName(type));
property.setType(type);
property.setLower(0);
property.setUpper(-1);
return property;
}


/**
* Precondition for n-ary association creation.
Expand All @@ -218,18 +211,7 @@ private Property createAssociationEnd(Type type) {
* @return true if association is binary and no end have no qualifiers
*/
public boolean createNaryAssociationPrecondition(EObject object) {
// aql:self.oclIsKindOf(uml::Association) and
// self.oclAsType(uml::Association).getEndTypes()->size()<=2
if (object instanceof Association) {
if (((Association)object).getMemberEnds().size() == 2) {
for (final Property end : ((Association)object).getMemberEnds()) {
if (end.getQualifiers().isEmpty()) {
return true;
}
}
}
}
return false;
return AssociationServices.INSTANCE.createNaryAssociationPrecondition(object);
}

/**
Expand Down Expand Up @@ -389,13 +371,13 @@ public String getText(Object element) {
if (types != null && types.length == 1) {
final Property endToFix = (Property)types[0];
endToFix.setType(type);
endToFix.setName(getAssociationEndsName(type));
endToFix.setName(AssociationServices.INSTANCE.getAssociationEndsName(type));
}
}
} else {
final Property endToFix = brokenEnds.get(0);
endToFix.setType(type);
endToFix.setName(getAssociationEndsName(type));
endToFix.setName(AssociationServices.INSTANCE.getAssociationEndsName(type));
}
}

Expand Down Expand Up @@ -483,15 +465,6 @@ public List<Association> getAssociation(Package container, DDiagram diagram) {
return result;
}

private String getAssociationEndsName(Type type) {
String name = ((NamedElement)type).getName();
if (!com.google.common.base.Strings.isNullOrEmpty(name)) {
final char c[] = name.toCharArray();
c[0] = Character.toLowerCase(c[0]);
name = new String(c) + 's';
}
return name;
}

/**
* Retrieve the cross references of the association of all the UML elements displayed as node in a
Expand Down Expand Up @@ -1095,7 +1068,7 @@ public boolean apply(EObject input) {
final Association association = createAssociation((Element)source, (Element)target);
for (final Object element : elementsToAdd) {
if (element instanceof Type) {
final Property end = createAssociationEnd((Type)element);
final Property end = AssociationServices.INSTANCE.createAssociationEnd((Type)element);
association.getOwnedEnds().add(end);
association.getMemberEnds().add(end);
association.getNavigableOwnedEnds().add(end);
Expand Down
Loading

0 comments on commit 1e8b74d

Please sign in to comment.