use of org.obeonetwork.dsl.entity.Root 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;
}
use of org.obeonetwork.dsl.entity.Root in project InformationSystem by ObeoNetwork.
the class AbstractTransformationTest method getRootObject.
private EObject getRootObject(URI modelURI) {
ResourceSet set = getResourceSet();
Resource resource = set.getResource(modelURI, true);
for (Iterator<EObject> it = resource.getAllContents(); it.hasNext(); ) {
EObject object = it.next();
if (object instanceof TableContainer || object instanceof Root || object instanceof Namespace || object instanceof ScaffoldInfo) {
return object;
}
}
return null;
}
Aggregations