示例#1
0
  private void buildClass(Frame frame) {

    String uri = frame.getUri();

    UmlClass umlClass = new UmlClass(frame, this);
    uri2Class.put(uri, umlClass);

    for (Field field : frame.getDeclaredFields()) {

      RdfType fieldType = field.getRdfType();

      if (fieldType.canAsDatatype()) {
        umlClass.add(field);
      }
    }
  }
示例#2
0
  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);
  }