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;
}
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);
}
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);
}
}
}
}
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);
}
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;
}
Aggregations