Skip to content

Commit

Permalink
job #12800: allow open editors to resolve model elements using UUID o…
Browse files Browse the repository at this point in the history
…r path to support textual xtUML
  • Loading branch information
leviathan747 committed May 9, 2024
1 parent 55e962c commit 4b4f35f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
9 changes: 6 additions & 3 deletions src/org.xtuml.bp.ui.text/arc/create_modeladapter_java.arc
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ public class ${modelAdapterClass}
private final static String type = "${core_package}.${classname}"; //$$NON-NLS-1$$
private String modelRootID = null;
private String componentPath;
private String modelPath;
.for each attr in id_attr_set
.invoke result = get_core_datatype(attr)
.assign cdt = result.cdt
Expand All @@ -309,6 +310,7 @@ public class ${modelAdapterClass}
{
modelRootID = inst.getModelRoot().getId();
componentPath = inst.getContent();
modelPath = inst.getPath();
.for each attr in id_attr_set
.select one rattr related by attr->O_RATTR[R106]
.if(not_empty rattr)
Expand All @@ -327,6 +329,7 @@ public class ${modelAdapterClass}
if (set.getType().equals(type))
{
modelRootID = set.getModelRootID();
modelPath = set.getModelPath();
.assign index = -1
.for each attr in id_attr_set
.assign index = index + 1
Expand All @@ -349,7 +352,7 @@ public class ${modelAdapterClass}
public ModelElementID createModelElementID()
{
.assign count = cardinality id_attr_set
ModelElementID id = new ModelElementID(modelRootID, type, componentPath);
ModelElementID id = new ModelElementID(modelRootID, type, componentPath, modelPath);
.for each attr in id_attr_set
.invoke result = get_core_datatype(attr)
.assign cdt = result.cdt
Expand All @@ -364,7 +367,7 @@ public class ${modelAdapterClass}
public boolean evaluate(Object inst)
{
${classname} candidate = (${classname}) inst;
return\
return (\
.assign sep = " "
.for each attr in id_attr_set
.invoke ibaaui = is_base_attribute_a_unique_id(attr)
Expand All @@ -375,7 +378,7 @@ public class ${modelAdapterClass}
.end if
.assign sep = "&& "
.end for
;
) || candidate.getPath().equals(modelPath);
}
}
.end for
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@ public class ModelElementID implements Serializable, Comparable<ModelElementID>
private static final String MODEL_ELEMENT_ID = "ModelElementID"; //$NON-NLS-1$
private static final String MODEL_ELEMENT_LAST_NAME = "ModelElementLastName"; //$NON-NLS-1$
private static final String MODEL_COMPONENT_PATH = "ModelComponentPath"; //$NON-NLS-1$
private static final String MODEL_PATH = "ModelPath"; //$NON-NLS-1$

private String modelRootID;
// We persist last Name so that we can obtain place holder file even if model is not loaded.
private String lastName;
private String componentPath;
private String modelPath;

private static final long serialVersionUID = 200503311547L;

Expand All @@ -53,7 +55,7 @@ public class ModelElementID implements Serializable, Comparable<ModelElementID>
transient NonRootModelElement modelElement;
transient Ooaofooa modelRoot;

protected ModelElementID(String aModelRootID, String aType, String aPath)
protected ModelElementID(String aModelRootID, String aType, String aPath, String modelPath)
{
modelRoot = Ooaofooa.getInstance(aModelRootID, false);
if(modelRoot == null){
Expand All @@ -63,6 +65,7 @@ protected ModelElementID(String aModelRootID, String aType, String aPath)
modelRootID = modelRoot.getId();
type = aType;
componentPath = aPath;
this.modelPath = modelPath;
}

protected ModelElementID(IMemento memento) throws CoreException
Expand Down Expand Up @@ -264,6 +267,7 @@ public void saveTo(IMemento memento) {
memento.putString(MODEL_ELEMENT_LAST_NAME, getLastValidName());
memento.putString(MODEL_COMPONENT_PATH, getComponentPath());
memento.putInteger(MODEL_ELEMENT_ID_COUNT, getIdCount());
memento.putString(MODEL_PATH, getModelPath());
for(int i=0; i<getIdCount(); i++){
memento.putString(MODEL_ELEMENT_ID + i, getId(i));
}
Expand Down Expand Up @@ -303,6 +307,11 @@ protected void readFrom(IMemento memento) throws CoreException{
if(componentPath == null){
throw new WorkbenchException(errorMessage + MODEL_COMPONENT_PATH);
}

modelPath = memento.getString(MODEL_PATH);
if(componentPath == null){
throw new WorkbenchException(errorMessage + MODEL_PATH);
}

Integer idCountObj = memento.getInteger(MODEL_ELEMENT_ID_COUNT);
if(idCountObj == null){
Expand Down Expand Up @@ -412,4 +421,8 @@ private static ModelElementID createInstance(InputStream inputStream) throws Cor
return meId;

}

public String getModelPath() {
return modelPath;
}
}

0 comments on commit 4b4f35f

Please sign in to comment.