Search in sources :

Example 1 with UMLClass

use of org.hl7.fhir.definitions.uml.UMLClass in project kindling by HL7.

the class ProfileGenerator method genUml.

private void genUml(TypeDefn t) {
    if (!uml.hasClass(t.getName())) {
        UMLClass c = new UMLClass(t.getName(), UMLClassType.Class);
        uml.getTypes().put(t.getName(), c);
    }
    UMLClass c = uml.getClassByName(t.getName());
    c.setDocumentation(t.getDefinition());
    if (!t.getTypes().isEmpty()) {
        c.setSpecialises(uml.getClassByName(t.typeCodeNoParams()));
    }
    if (!c.hasAttributes()) {
        for (ElementDefn e : t.getElements()) {
            UMLAttribute a = null;
            if (t.getTypes().isEmpty()) {
                a = new UMLAttribute(e.getName(), Integer.toString(e.getMinCardinality()), Integer.toString(e.getMaxCardinality()), uml.getClassByNameCreate("Base"));
            } else if (t.getTypes().size() == 1 && !isReference(t.getTypes().get(0).getName())) {
                a = new UMLAttribute(e.getName(), Integer.toString(e.getMinCardinality()), Integer.toString(e.getMaxCardinality()), uml.getClassByNameCreate(e.typeCode()));
            } else {
                String tn = t.getTypes().get(0).getName();
                boolean allSame = true;
                for (int i = 1; i < t.getTypes().size(); i++) {
                    allSame = tn.equals(t.getTypes().get(i).getName());
                }
                if (allSame && isReference(tn)) {
                    a = new UMLAttribute(e.getName(), Integer.toString(e.getMinCardinality()), Integer.toString(e.getMaxCardinality()), uml.getClassByNameCreate(tn));
                    for (TypeRef tr : t.getTypes()) {
                        for (String p : tr.getParams()) {
                            a.getTargets().add(p);
                        }
                    }
                } else {
                    boolean allPrimitive = true;
                    for (TypeRef tr : t.getTypes()) {
                        if (!definitions.hasPrimitiveType(tr.getName())) {
                            allPrimitive = false;
                        }
                    }
                    if (allPrimitive) {
                        a = new UMLAttribute(e.getName(), Integer.toString(e.getMinCardinality()), Integer.toString(e.getMaxCardinality()), uml.getClassByNameCreate("PrimitiveType"));
                    } else {
                        a = new UMLAttribute(e.getName(), Integer.toString(e.getMinCardinality()), Integer.toString(e.getMaxCardinality()), uml.getClassByNameCreate("DataType"));
                    }
                    for (TypeRef tr : t.getTypes()) {
                        a.getTypes().add(tr.getName());
                        for (String p : tr.getParams()) {
                            a.getTargets().add(p);
                        }
                    }
                }
            }
            c.getAttributes().add(a);
        }
    }
}
Also used : UMLClass(org.hl7.fhir.definitions.uml.UMLClass) UMLAttribute(org.hl7.fhir.definitions.uml.UMLAttribute) TypeRef(org.hl7.fhir.definitions.model.TypeRef) ElementDefn(org.hl7.fhir.definitions.model.ElementDefn)

Example 2 with UMLClass

use of org.hl7.fhir.definitions.uml.UMLClass in project kindling by HL7.

the class ProfileGenerator method genUml.

public void genUml(DefinedStringPattern type) {
    UMLClass c = uml.getClassByNameCreate(type.getCode());
    c.setDocumentation(type.getDefinition());
    c.setSpecialises(uml.getClassByNameCreate(type.getBase()));
}
Also used : UMLClass(org.hl7.fhir.definitions.uml.UMLClass)

Example 3 with UMLClass

use of org.hl7.fhir.definitions.uml.UMLClass in project kindling by HL7.

the class ProfileGenerator method genUml.

public void genUml(PrimitiveType type) {
    UMLClass c = uml.getClassByNameCreate(type.getCode());
    c.setDocumentation(type.getDefinition());
    c.setSpecialises(uml.getClassByName("PrimitiveType"));
    String t = type.getSchemaType();
    if (!t.startsWith("xs:"))
        t = "xs:" + t;
    if (!uml.hasPrimitive(t)) {
        UMLPrimitive p = new UMLPrimitive(t);
        uml.getTypes().put(t, p);
    }
    c.getAttributes().add(new UMLAttribute("value", "0", "1", uml.getTypes().get(t)));
}
Also used : UMLClass(org.hl7.fhir.definitions.uml.UMLClass) UMLAttribute(org.hl7.fhir.definitions.uml.UMLAttribute) UMLPrimitive(org.hl7.fhir.definitions.uml.UMLPrimitive)

Aggregations

UMLClass (org.hl7.fhir.definitions.uml.UMLClass)3 UMLAttribute (org.hl7.fhir.definitions.uml.UMLAttribute)2 ElementDefn (org.hl7.fhir.definitions.model.ElementDefn)1 TypeRef (org.hl7.fhir.definitions.model.TypeRef)1 UMLPrimitive (org.hl7.fhir.definitions.uml.UMLPrimitive)1