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

- generateMissingIDs() bug fix: generate missing ID also for given...

- generateMissingIDs() bug fix: generate missing ID also for given 'existingModel', not only for its offspring.
refs 3067
parent ba924dae
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 f8b053bf64835d8a441192f7681fda0655a98469 YELLOW
UniqueIDUtils.java 758dd39d869297fa074926ca9298ac82c012872e YELLOW
......@@ -34,6 +34,15 @@ import org.fortiss.tooling.kernel.service.IPersistencyService;
* @author hoelzl
*/
public class UniqueIDUtils {
/** Helper to implement {@link #generateMissingIDs(EObject, int)}. */
private static int setMissingId(EObject object, int currentMaxId) {
if(object instanceof IIdLabeled) {
if(((IIdLabeled)object).getId() <= 0) {
((IIdLabeled)object).setId((++currentMaxId));
}
}
return currentMaxId;
}
/**
* Generates missing IDs of the given model starting from the given current
......@@ -47,13 +56,11 @@ public class UniqueIDUtils {
* @return The maximum ID after the generation of missing IDs.
*/
public static int generateMissingIDs(EObject existingModel, int currentMaxId) {
currentMaxId = setMissingId(existingModel, currentMaxId);
for(Iterator<EObject> i = existingModel.eAllContents(); i.hasNext();) {
EObject eo = i.next();
if(eo instanceof IIdLabeled) {
if(((IIdLabeled)eo).getId() <= 0) {
((IIdLabeled)eo).setId((++currentMaxId));
}
}
currentMaxId = setMissingId(eo, currentMaxId);
}
return currentMaxId;
}
......
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