Skip to content
Snippets Groups Projects
Commit ba924dae authored by Simon Barner's avatar Simon Barner
Browse files

- Add fixMissingIDs(EObject object, EObject existingModel), a method that...

- Add fixMissingIDs(EObject object, EObject existingModel), a method that generates all missing IDs of the given sub-model.
refs 3067
parent 740e4600
No related branches found
No related tags found
No related merge requests found
......@@ -12,4 +12,4 @@ MigrationUtils.java e54370b19148ff656d7563e8188baccd947c24d5 GREEN
PrototypesUtils.java 538b5edbab06e95bc32e81309482e36a4bc64d1e GREEN
ResourceUtils.java 8ab06ad3b72fdb2b1925e2ccbedcfea35e36cf24 GREEN
TransformationUtils.java f159b17ac1ce2ce0d94c1a873d74e052ac2dc74b GREEN
UniqueIDUtils.java 9586f7f13b69b89d2b443312373e7f15aac92bd8 GREEN
UniqueIDUtils.java f8b053bf64835d8a441192f7681fda0655a98469 YELLOW
......@@ -261,11 +261,32 @@ public class UniqueIDUtils {
public static void fixMissingIDs(final ITopLevelElement modelElement) {
final int maxID = getLargestID(modelElement.getRootModelElement());
if(maxID > 0) {
modelElement.runAsCommand(new Runnable() {
@Override
public void run() {
generateMissingIDs(modelElement.getRootModelElement(), maxID);
}
modelElement.runAsCommand(() -> {
generateMissingIDs(modelElement.getRootModelElement(), maxID);
});
}
}
/**
* Generates all missing IDs of the given sub-model.
*
* @param object
* The sub-model element for which missing IDs should be prepared
* @param existingModel
* the existing model to be considered for used IDs if object
* already contains IDs > 0
*/
public static void fixMissingIDs(EObject object, EObject existingModel) {
EObject root = existingModel;
while(root.eContainer() != null) {
root = root.eContainer();
}
ITopLevelElement topLevelElement =
IPersistencyService.getInstance().getTopLevelElementFor(existingModel);
final int maxID = getLargestID(root);
if(maxID > 0) {
topLevelElement.runAsCommand(() -> {
generateMissingIDs(object, maxID);
});
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment