Search in sources :

Example 1 with DataType

use of org.obeonetwork.dsl.environment.DataType in project InformationSystem by ObeoNetwork.

the class PropertiesServices method getAttrTypeFromString.

public DataType getAttrTypeFromString(Attribute attribute, String inputString) {
    int delimiter = inputString.indexOf(":");
    if (delimiter != -1 && delimiter < inputString.length()) {
        int startMulti = inputString.indexOf("[");
        String typeName;
        if (startMulti != -1) {
            typeName = inputString.substring(delimiter + 1, startMulti);
        } else {
            typeName = inputString.substring(delimiter + 1);
        }
        DataType dataType = getDataType(attribute, typeName);
        if (dataType != null) {
            return dataType;
        }
    }
    return attribute.getType();
}
Also used : DataType(org.obeonetwork.dsl.environment.DataType)

Example 2 with DataType

use of org.obeonetwork.dsl.environment.DataType in project InformationSystem by ObeoNetwork.

the class PropertiesServices method getDataType.

private DataType getDataType(EObject context, String name) {
    String searchedName = name.trim();
    Collection<Resource> semanticResources = ModelServices.getAllResources(context);
    for (Resource semanticResource : semanticResources) {
        TreeIterator<?> iterator = semanticResource.getAllContents();
        while (iterator.hasNext()) {
            Object o = iterator.next();
            if (o instanceof DataType) {
                DataType type = (DataType) o;
                if (searchedName.equalsIgnoreCase(type.getName())) {
                    return type;
                }
            }
        }
    }
    return null;
}
Also used : Resource(org.eclipse.emf.ecore.resource.Resource) DataType(org.obeonetwork.dsl.environment.DataType) EObject(org.eclipse.emf.ecore.EObject)

Example 3 with DataType

use of org.obeonetwork.dsl.environment.DataType in project InformationSystem by ObeoNetwork.

the class DesignServices method isExistingDependency.

/**
 * Checks whether a dependency should be displayed between 2 namespaces
 * @param source
 * @param target
 * @return
 */
public static boolean isExistingDependency(Namespace source, Namespace target) {
    for (Type type : source.getTypes()) {
        if (type instanceof StructuredType) {
            StructuredType structuredType = (StructuredType) type;
            // Check inheritance
            StructuredType supertype = structuredType.getSupertype();
            if (supertype != null && target.equals(supertype.eContainer())) {
                return true;
            }
            // Check references
            for (Reference reference : structuredType.getOwnedReferences()) {
                StructuredType referencedType = reference.getReferencedType();
                if (referencedType != null && target.equals(referencedType.eContainer())) {
                    return true;
                }
            }
            // Check attributes
            for (Attribute attribute : structuredType.getOwnedAttributes()) {
                DataType datatype = attribute.getType();
                if (datatype instanceof Enumeration && target.equals(datatype.eContainer())) {
                    return true;
                }
            }
        }
    }
    return false;
}
Also used : StructuredType(org.obeonetwork.dsl.environment.StructuredType) DataType(org.obeonetwork.dsl.environment.DataType) Type(org.obeonetwork.dsl.environment.Type) Enumeration(org.obeonetwork.dsl.environment.Enumeration) Attribute(org.obeonetwork.dsl.environment.Attribute) Reference(org.obeonetwork.dsl.environment.Reference) DataType(org.obeonetwork.dsl.environment.DataType) StructuredType(org.obeonetwork.dsl.environment.StructuredType)

Example 4 with DataType

use of org.obeonetwork.dsl.environment.DataType in project InformationSystem by ObeoNetwork.

the class DesignServices method getNbDependencies.

/**
 * Returns the number of dependencies between 2 namespaces
 * @param source
 * @param target
 * @return
 */
public static int getNbDependencies(Namespace source, Namespace target) {
    int count = 0;
    for (Type type : source.getTypes()) {
        if (type instanceof StructuredType) {
            StructuredType structuredType = (StructuredType) type;
            // Check inheritance
            StructuredType supertype = structuredType.getSupertype();
            if (supertype != null && target.equals(supertype.eContainer())) {
                count += 1;
            }
            // Check references
            for (Reference reference : structuredType.getOwnedReferences()) {
                StructuredType referencedType = reference.getReferencedType();
                if (referencedType != null && target.equals(referencedType.eContainer())) {
                    count += 1;
                }
            }
            // Check attributes
            for (Attribute attribute : structuredType.getOwnedAttributes()) {
                DataType datatype = attribute.getType();
                if (datatype instanceof Enumeration && target.equals(datatype.eContainer())) {
                    count += 1;
                }
            }
        }
    }
    return count;
}
Also used : StructuredType(org.obeonetwork.dsl.environment.StructuredType) DataType(org.obeonetwork.dsl.environment.DataType) Type(org.obeonetwork.dsl.environment.Type) Enumeration(org.obeonetwork.dsl.environment.Enumeration) Attribute(org.obeonetwork.dsl.environment.Attribute) Reference(org.obeonetwork.dsl.environment.Reference) DataType(org.obeonetwork.dsl.environment.DataType) StructuredType(org.obeonetwork.dsl.environment.StructuredType)

Aggregations

DataType (org.obeonetwork.dsl.environment.DataType)4 Attribute (org.obeonetwork.dsl.environment.Attribute)2 Enumeration (org.obeonetwork.dsl.environment.Enumeration)2 Reference (org.obeonetwork.dsl.environment.Reference)2 StructuredType (org.obeonetwork.dsl.environment.StructuredType)2 Type (org.obeonetwork.dsl.environment.Type)2 EObject (org.eclipse.emf.ecore.EObject)1 Resource (org.eclipse.emf.ecore.resource.Resource)1