Search in sources :

Example 1 with Type

use of org.eclipse.vorto.core.api.model.datatype.Type in project vorto by eclipse.

the class CodeGenTools method getReferencedTypes.

public static EList<Type> getReferencedTypes(Entity entity) {
    EList<Type> types = new BasicEList<Type>();
    for (Property property : entity.getProperties()) {
        types.addAll(getReferencedTypes(property));
    }
    types.add(entity.getSuperType());
    return types;
}
Also used : ObjectPropertyType(org.eclipse.vorto.core.api.model.datatype.ObjectPropertyType) Type(org.eclipse.vorto.core.api.model.datatype.Type) BasicEList(org.eclipse.emf.common.util.BasicEList) Property(org.eclipse.vorto.core.api.model.datatype.Property)

Example 2 with Type

use of org.eclipse.vorto.core.api.model.datatype.Type in project vorto by eclipse.

the class DatatypeGeneratorTask method getTypesOfType.

private static Set<Type> getTypesOfType(Type type, Set<Type> container) {
    TreeIterator<EObject> iterator = type.eAllContents();
    while (iterator.hasNext()) {
        EObject current = iterator.next();
        if (current instanceof ObjectPropertyType) {
            if (!container.contains(current)) {
                container.add(((ObjectPropertyType) current).getType());
                Set<Type> moreTypes = getTypesOfType(((ObjectPropertyType) current).getType(), container);
                container.addAll(moreTypes);
            }
        }
    }
    return container;
}
Also used : ReturnObjectType(org.eclipse.vorto.core.api.model.functionblock.ReturnObjectType) ObjectPropertyType(org.eclipse.vorto.core.api.model.datatype.ObjectPropertyType) Type(org.eclipse.vorto.core.api.model.datatype.Type) ObjectPropertyType(org.eclipse.vorto.core.api.model.datatype.ObjectPropertyType) EObject(org.eclipse.emf.ecore.EObject)

Example 3 with Type

use of org.eclipse.vorto.core.api.model.datatype.Type in project vorto by eclipse.

the class DatatypeGeneratorTask method getTypes.

private static Set<Type> getTypes(FunctionblockModel model) {
    Set<Type> allTypes = new LinkedHashSet<>();
    TreeIterator<EObject> iterator = model.eAllContents();
    while (iterator.hasNext()) {
        EObject current = iterator.next();
        if (current instanceof RefParam) {
            addTypeAndReferences(((RefParam) current).getType(), allTypes);
        } else if (current instanceof ReturnObjectType) {
            addTypeAndReferences(((ReturnObjectType) current).getReturnType(), allTypes);
        } else if (current instanceof ObjectPropertyType) {
            addTypeAndReferences(((ObjectPropertyType) current).getType(), allTypes);
        }
    }
    return allTypes;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) ReturnObjectType(org.eclipse.vorto.core.api.model.functionblock.ReturnObjectType) ObjectPropertyType(org.eclipse.vorto.core.api.model.datatype.ObjectPropertyType) Type(org.eclipse.vorto.core.api.model.datatype.Type) RefParam(org.eclipse.vorto.core.api.model.functionblock.RefParam) ObjectPropertyType(org.eclipse.vorto.core.api.model.datatype.ObjectPropertyType) EObject(org.eclipse.emf.ecore.EObject) ReturnObjectType(org.eclipse.vorto.core.api.model.functionblock.ReturnObjectType)

Example 4 with Type

use of org.eclipse.vorto.core.api.model.datatype.Type in project vorto by eclipse.

the class CodeGenTools method getReferencedTypes.

public static EList<Type> getReferencedTypes(Property property) {
    EList<Type> types = new BasicEList<Type>();
    if (property.getType() instanceof ObjectPropertyType) {
        ObjectPropertyType objectType = (ObjectPropertyType) property.getType();
        types.add(objectType.getType());
        if (objectType.getType() instanceof Entity) {
            types.addAll(getReferencedTypes((Entity) objectType.getType()));
        }
    }
    return types;
}
Also used : Entity(org.eclipse.vorto.core.api.model.datatype.Entity) ObjectPropertyType(org.eclipse.vorto.core.api.model.datatype.ObjectPropertyType) Type(org.eclipse.vorto.core.api.model.datatype.Type) ObjectPropertyType(org.eclipse.vorto.core.api.model.datatype.ObjectPropertyType) BasicEList(org.eclipse.emf.common.util.BasicEList)

Aggregations

ObjectPropertyType (org.eclipse.vorto.core.api.model.datatype.ObjectPropertyType)4 Type (org.eclipse.vorto.core.api.model.datatype.Type)4 BasicEList (org.eclipse.emf.common.util.BasicEList)2 EObject (org.eclipse.emf.ecore.EObject)2 ReturnObjectType (org.eclipse.vorto.core.api.model.functionblock.ReturnObjectType)2 LinkedHashSet (java.util.LinkedHashSet)1 Entity (org.eclipse.vorto.core.api.model.datatype.Entity)1 Property (org.eclipse.vorto.core.api.model.datatype.Property)1 RefParam (org.eclipse.vorto.core.api.model.functionblock.RefParam)1