Commit 695a37f1 authored by Simon Barner's avatar Simon Barner
Browse files

Ensure that IDs have been assigned to all new model elements before they are...

Ensure that IDs have been assigned to all new model elements before they are hooked to the project / resource
- Rationale
  - Model elements for which no ID has been assigned, have id 0 (which is the default value). 
  - When the new element is hooked to the resource, ResourceUtils.KernelResourceFactory.KernelXMIResource.getId() is called, which internally calls setId() to synchronize the XMI ID with the AF3 ID. In case the ID is still 0, this implicit call will corrupt the ID -> model object map (by override the mapping for key 0).
- Changes
  - ElementCompositorService: Assign IDs *before* hooking new element to the container (but of course using the container to determine the next free ID)
  - ModelElementCompositorBase: Assign IDs to newly instantiated annotations
parent 56e8cae3
......@@ -33,6 +33,7 @@ import org.fortiss.tooling.kernel.extension.IElementCompositor;
import org.fortiss.tooling.kernel.model.INamedElement;
import org.fortiss.tooling.kernel.service.IElementCompositorService;
import org.fortiss.tooling.kernel.service.IPersistencyService;
* Base implementation of a compositor for {@link EObject}s which is responsible for the standard
......@@ -41,7 +42,7 @@ import org.fortiss.tooling.kernel.service.IElementCompositorService;
* @author diewald
* @author $Author$
* @version $Rev$
* @ConQAT.Rating GREEN Hash: 95D78572A35141C5D47B111AD4B26AC4
* @ConQAT.Rating YELLOW Hash: 14EC7CB721E223C172B6D534820C8FC2
public abstract class ModelElementCompositorBase<C extends EObject> extends Observable implements
IElementCompositor<C> {
......@@ -58,6 +59,8 @@ public abstract class ModelElementCompositorBase<C extends EObject> extends Obse
// (see #2228 and #2208)
if(contained instanceof IModelElement) {
makeNameDistinct(container, contained);
return true;
......@@ -43,7 +43,7 @@ import org.fortiss.tooling.kernel.utils.LoggingUtils;
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: FC76754E943C5B0005F5186FD1374185
* @ConQAT.Rating YELLOW Hash: 88948AA581DBFFA76EE100BFF77829CE
public final class ElementCompositorService extends
EObjectAwareServiceBase<IElementCompositor<EObject>> implements IElementCompositorService,
......@@ -114,12 +114,12 @@ public final class ElementCompositorService extends
return false;
// Generate IDs (for sub-model to be added)
// Add element to the model (might instantiate annotations for IModelElements)
boolean rval = compositor.compose(container, element, context);
// Generate IDs (including potentially instantiated annotations)
return rval;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment