Search in sources :

Example 1 with Namespace

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

the class DesignServices method getDependenciesToNamespaces.

/**
 * Returns all namespaces for which a dependency should be displayed starting from source
 * @param source
 * @param diagram
 * @return
 */
public static Collection<Namespace> getDependenciesToNamespaces(Namespace source, DSemanticDiagram diagram) {
    Collection<Namespace> targetNamespaces = new ArrayList<Namespace>();
    Set<Namespace> displayedNamespaces = getDisplayedNamespaces(diagram);
    // Check all namespaces displayed on the diagram
    for (Namespace displayedNamespace : displayedNamespaces) {
        // - an ancestor or a descendant of the source namespace
        if (displayedNamespace != source && displayedNamespace.getTechnicalid().compareTo(source.getTechnicalid()) > 0 && !EcoreUtil.isAncestor(displayedNamespace, source) && !EcoreUtil.isAncestor(source, displayedNamespace)) {
            // Now we can check if dependencies exist between the 2 namespaces
            if (isExistingDependency(source, displayedNamespace) || isExistingDependency(displayedNamespace, source)) {
                targetNamespaces.add(displayedNamespace);
            }
        }
    }
    return targetNamespaces;
}
Also used : ArrayList(java.util.ArrayList) Namespace(org.obeonetwork.dsl.environment.Namespace)

Example 2 with Namespace

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

the class DesignServices method getDependencyEndLabel.

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

Example 3 with Namespace

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

the class SoaMigrationHelper method postLoad.

@Override
public void postLoad(XMLResource resource, InputStream inputStream, Map<?, ?> options) {
    // Remove old DTO Registry level
    for (EObject rootObject : resource.getContents()) {
        if (rootObject instanceof System) {
            System system = (System) rootObject;
            if (system.getOwnedNamespaces().size() == 1) {
                Namespace oldDtoRegistry = system.getOwnedNamespaces().get(0);
                removeDtoRegistry(oldDtoRegistry);
            }
        }
    }
}
Also used : EObject(org.eclipse.emf.ecore.EObject) System(org.obeonetwork.dsl.soa.System) Namespace(org.obeonetwork.dsl.environment.Namespace)

Example 4 with Namespace

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

the class SoaMigrationHelper method removeDtoRegistry.

private void removeDtoRegistry(Namespace dtoRegistry) {
    System system = (System) dtoRegistry.eContainer();
    if (!dtoRegistry.getOwnedNamespaces().isEmpty()) {
        // Store XMI IDs
        Map<EObject, String> eObjectToIds = new HashMap<EObject, String>();
        TreeIterator<EObject> eAllContents = dtoRegistry.eAllContents();
        while (eAllContents.hasNext()) {
            EObject child = eAllContents.next();
            String xmiId = child.eResource().getURIFragment(child);
            eObjectToIds.put(child, xmiId);
        }
        // Change parent of children
        Collection<Namespace> children = new ArrayList<Namespace>(dtoRegistry.getOwnedNamespaces());
        for (Namespace child : children) {
            system.getOwnedNamespaces().add(child);
        }
        // Restore XMI IDs
        for (Entry<EObject, String> eObjectToIdEntry : eObjectToIds.entrySet()) {
            EObject object = eObjectToIdEntry.getKey();
            String id = eObjectToIdEntry.getValue();
            ((XMLResource) object.eResource()).setID(object, id);
        }
    }
    // Delete old DTO registry
    EcoreUtil.delete(dtoRegistry, false);
}
Also used : HashMap(java.util.HashMap) EObject(org.eclipse.emf.ecore.EObject) ArrayList(java.util.ArrayList) System(org.obeonetwork.dsl.soa.System) Namespace(org.obeonetwork.dsl.environment.Namespace) XMLResource(org.eclipse.emf.ecore.xmi.XMLResource)

Example 5 with Namespace

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

the class EntityToMLD method prepare.

@Override
protected boolean prepare(EObject sourceObject, EObject targetObject) {
    if (targetObject instanceof TableContainer) {
        sourceNamespaces = new ArrayList<Namespace>();
        if (sourceObject instanceof Root) {
            Root sourceRoot = (Root) sourceObject;
            sourceNamespaces.addAll(sourceRoot.getOwnedNamespaces());
        } else if (sourceObject instanceof Namespace) {
            sourceNamespaces.add((Namespace) sourceObject);
        }
        targetResource = targetObject.eResource();
        defaultTarget = targetObject;
        nativeTypesMap = loadTypesLibrary();
        return (!nativeTypesMap.isEmpty());
    }
    return false;
}
Also used : Root(org.obeonetwork.dsl.entity.Root) TableContainer(org.obeonetwork.dsl.database.TableContainer) 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