Search in sources :

Example 11 with Namespace

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

the class EntityToMLD method processNamespaceAndCreateAdditionalFields.

private void processNamespaceAndCreateAdditionalFields(Namespace namespace) {
    // create tables
    for (Entity entity : EntityUtils.getEntitiesInNamespace(namespace)) {
        // Create technical fields
        Table table = getFromOutputTraceabilityMap(entity, DatabasePackage.Literals.TABLE);
        createAdditionalFields(table);
    }
    // process sub-namespaces
    for (Namespace subnamespace : namespace.getOwnedNamespaces()) {
        processNamespaceAndCreateAdditionalFields(subnamespace);
    }
}
Also used : Entity(org.obeonetwork.dsl.entity.Entity) Table(org.obeonetwork.dsl.database.Table) Namespace(org.obeonetwork.dsl.environment.Namespace)

Example 12 with Namespace

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

the class MLDToEntity method getTargetNamespace.

protected Namespace getTargetNamespace(TableContainer tableContainer) {
    if (!cacheTableContainerToNamespace.containsKey(tableContainer)) {
        Namespace targetNamespace = null;
        // First we look for a namespace with the right name
        String namespaceName = tableContainer.getName();
        // Look for a namespace with the right name
        targetNamespace = getNamespaceByName(namespaceName);
        if (targetNamespace == null) {
            if (defaultTarget instanceof Namespace) {
                if (EntityUtils.getEntitiesInNamespace((Namespace) defaultTarget).isEmpty()) {
                    // We consider the namespace is contained is a newly created model
                    // we can change its physical name
                    targetNamespace = (Namespace) defaultTarget;
                    AnnotationHelper.setPhysicalNameAnnotation(targetNamespace, namespaceName);
                }
            } else if (defaultTarget instanceof Root) {
                Root entityRoot = (Root) defaultTarget;
                if (entityRoot.getOwnedNamespaces().size() == 1 && EntityUtils.getEntitiesInNamespace(entityRoot.getOwnedNamespaces().get(0)).isEmpty()) {
                    targetNamespace = entityRoot.getOwnedNamespaces().get(0);
                    AnnotationHelper.setPhysicalNameAnnotation(targetNamespace, namespaceName);
                }
            }
            // We create a namespace if the target object is a entity root
            if (targetNamespace == null) {
                targetNamespace = createNamespace(namespaceName);
            }
            // Last solution, can occur only if the default target is a non empty namespace, we then select it
            if (targetNamespace == null) {
                if (defaultTarget instanceof Namespace) {
                    targetNamespace = (Namespace) defaultTarget;
                }
            }
        }
        cacheTableContainerToNamespace.put(tableContainer, targetNamespace);
    }
    Namespace namespace = cacheTableContainerToNamespace.get(tableContainer);
    // Ensure description is taken from tableContainer's comments
    namespace.setDescription(tableContainer.getComments());
    return namespace;
}
Also used : Root(org.obeonetwork.dsl.entity.Root) Namespace(org.obeonetwork.dsl.environment.Namespace)

Example 13 with Namespace

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

the class DesignServices method getDependencyBeginLabel.

public static String getDependencyBeginLabel(DEdge edge) {
    Namespace source = getNamespaceFromEdgeTarget(edge.getSourceNode());
    Namespace target = getNamespaceFromEdgeTarget(edge.getTargetNode());
    return "" + getNbDependencies(target, source);
}
Also used : Namespace(org.obeonetwork.dsl.environment.Namespace)

Example 14 with Namespace

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

the class DesignServices method isDependencyBeginDecorated.

public static boolean isDependencyBeginDecorated(DEdge edge) {
    Namespace source = getNamespaceFromEdgeTarget(edge.getSourceNode());
    Namespace target = getNamespaceFromEdgeTarget(edge.getTargetNode());
    return source != null && target != null && isExistingDependency(target, source);
}
Also used : Namespace(org.obeonetwork.dsl.environment.Namespace)

Example 15 with Namespace

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

the class DesignServices method isDependencyEndDecorated.

public static boolean isDependencyEndDecorated(DEdge edge) {
    Namespace source = getNamespaceFromEdgeTarget(edge.getSourceNode());
    Namespace target = getNamespaceFromEdgeTarget(edge.getTargetNode());
    return source != null && target != null && isExistingDependency(source, target);
}
Also used : Namespace(org.obeonetwork.dsl.environment.Namespace)

Aggregations

Namespace (org.obeonetwork.dsl.environment.Namespace)16 ArrayList (java.util.ArrayList)5 Root (org.obeonetwork.dsl.entity.Root)5 EObject (org.eclipse.emf.ecore.EObject)4 TableContainer (org.obeonetwork.dsl.database.TableContainer)3 XMLResource (org.eclipse.emf.ecore.xmi.XMLResource)2 Table (org.obeonetwork.dsl.database.Table)2 Entity (org.obeonetwork.dsl.entity.Entity)2 StructuredType (org.obeonetwork.dsl.environment.StructuredType)2 System (org.obeonetwork.dsl.soa.System)2 ScaffoldInfo (fr.gouv.mindef.safran.database.scaffold.ScaffoldInfo)1 Collator (java.text.Collator)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 EReference (org.eclipse.emf.ecore.EReference)1 Setting (org.eclipse.emf.ecore.EStructuralFeature.Setting)1 InternalEObject (org.eclipse.emf.ecore.InternalEObject)1 Resource (org.eclipse.emf.ecore.resource.Resource)1 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)1