コード例 #1
0
ファイル: UmlManager.java プロジェクト: gmcfall/semantictools
  private void defineEnd(UmlAssociationEnd end, Field field, Encapsulation encapsulation) {

    end.setEncapsulation(encapsulation);
    if (field == null) return;
    end.setField(field);
    end.setLocalName(field.getLocalName());
    end.setMultiplicity(field.getMultiplicity());
  }
コード例 #2
0
ファイル: UmlManager.java プロジェクト: gmcfall/semantictools
  private void addChildren(UmlClass umlClass, Frame frame) {

    List<UmlAssociation> parentList = new ArrayList<UmlAssociation>();

    for (Field field : frame.getDeclaredFields()) {
      RdfType fieldType = field.getRdfType();

      Field inverseField = field.getInverseField();

      UmlClass otherClass = null;
      if (fieldType.canAsFrame()) {
        otherClass = getUmlClassByURI(fieldType.getUri());
      } else if (fieldType.canAsListType()) {
        otherClass = getUmlClassByURI(fieldType.asListType().getElementType().getUri());
      }

      if (otherClass != null) {

        InverseProperty inverse = field.getInverseProperty();

        Encapsulation inverseEncapsulation =
            inverseField == null ? inverse.getEncapsulation() : inverseField.getEncapsulation();

        Encapsulation encapsulation = field.getEncapsulation();

        if (encapsulation == Encapsulation.NONE && inverseEncapsulation != Encapsulation.NONE) {
          //
          // The other class is the parent

          UmlAssociationEnd end0 = new UmlAssociationEnd(umlClass);
          end0.setMultiplicity(inverse.getMultiplicity());
          defineEnd(end0, inverseField, encapsulation);

          UmlAssociationEnd end1 = new UmlAssociationEnd(otherClass);
          defineEnd(end1, field, inverseEncapsulation);

          UmlAssociation assoc = new UmlAssociation(end0, end1);

          otherClass.addChild(assoc);
          parentList.add(assoc);

        } else {

          UmlAssociationEnd end0 = new UmlAssociationEnd(umlClass);
          UmlAssociationEnd end1 = new UmlAssociationEnd(otherClass);
          defineEnd(end0, inverseField, encapsulation);
          defineEnd(end1, field, inverseEncapsulation);

          UmlAssociation assoc = new UmlAssociation(end0, end1);

          umlClass.addChild(assoc);
          parentList.add(assoc);
        }

      } else {
        // TODO: handle other conditions

      }
    }

    addParentList(umlClass, parentList);
  }