예제 #1
0
  private boolean insertAssociationEnd(
      UMLAssociationEnd association, UMLClass typeInstance, UMLClass classInstance)
      throws ContractException {
    final String associationEnd = CommonElementsPackage.UMLASSOCIATIONEND;

    String id = association.getId();
    String lower = String.valueOf(association.getLower());
    String upper = String.valueOf(association.getUpper());

    boolean result = true;
    result &= insertObject(associationEnd, id, association.getName());
    result &= insertValue(associationEnd, ATTR_VISIBILITY, id, association.getVisibility());
    result &= insertValue(associationEnd, ATTR_LOWER, id, lower);
    result &= insertValue(associationEnd, ATTR_UPPER, id, upper);
    result &= insertValue(associationEnd, ATTR_COMPOSITION, id, association.isAggregation());
    result &=
        manager.insertLink(
            associationEnd,
            id,
            ROLE_TYPES,
            ROLE_CLASSIFIER,
            typeInstance.getId(),
            CommonElementsPackage.UMLCLASSIFIER);
    result &=
        manager.insertLink(
            associationEnd,
            id,
            ROLE_FEATURE,
            ROLE_CLASS,
            classInstance.getId(),
            CommonElementsPackage.UMLCLASS);
    return result;
  }
예제 #2
0
  private void insertAssociationEnd() throws ContractException {
    Set<Entry<String, UMLAssociation>> associationSet = parser.getAssociationMap().entrySet();

    for (Entry<String, UMLAssociation> associationEntry : associationSet) {

      Map<String, UMLAssociationEnd> associationEndMap =
          associationEntry.getValue().getAssociationEndMap();

      if (associationEndMap.size() != 2) {
        throw new ContractException(
            "Error in associations end size for "
                + associationEntry.getValue().getId()
                + " association");
      }

      Set<Entry<String, UMLAssociationEnd>> associationEndSet = associationEndMap.entrySet();
      ArrayList<UMLAssociationEnd> associationEndArray = new ArrayList<UMLAssociationEnd>();

      for (Entry<String, UMLAssociationEnd> associationEnd : associationEndSet) {
        associationEndArray.add(associationEnd.getValue());
      }

      UMLAssociationEnd association2 = associationEndArray.get(0);
      UMLAssociationEnd association1 = associationEndArray.get(1);
      UMLClass class1 = (UMLClass) parser.getClasses().get(association1.getParticipantClassId());
      UMLClass class2 = (UMLClass) parser.getClasses().get(association2.getParticipantClassId());

      this.insertAssociationEnd(association2, class2, class1);
      this.insertAssociationEnd(association1, class1, class2);
      this.insertLinksBetweenAssociationEnds(association2.getId(), association1.getId());
      this.insertAssociation(
          associationEntry.getValue().getId(),
          associationEntry.getValue().getName(),
          association2.getId(),
          association1.getId());
    }
  }