[Minor] code cleanup in AddOrUpdateStrolchRootElementService
This commit is contained in:
parent
dd7c925735
commit
f22ec993ee
|
@ -46,27 +46,10 @@ public class AddOrUpdateStrolchRootElementService extends AbstractService<Strolc
|
|||
try (StrolchTransaction tx = openArgOrUserTx(arg)) {
|
||||
|
||||
switch (arg.rootElement.getObjectType()) {
|
||||
case Tags.RESOURCE -> {
|
||||
if (tx.hasResource(arg.rootElement.getType(), arg.rootElement.getId())) {
|
||||
tx.update((Resource) arg.rootElement);
|
||||
} else {
|
||||
tx.add((Resource) arg.rootElement);
|
||||
}
|
||||
}
|
||||
case Tags.ORDER -> {
|
||||
if (tx.hasOrder(arg.rootElement.getType(), arg.rootElement.getId())) {
|
||||
tx.update((Order) arg.rootElement);
|
||||
} else {
|
||||
tx.add((Order) arg.rootElement);
|
||||
}
|
||||
}
|
||||
case Tags.ACTIVITY -> {
|
||||
if (tx.hasActivity(arg.rootElement.getType(), arg.rootElement.getId())) {
|
||||
tx.update((Activity) arg.rootElement);
|
||||
} else {
|
||||
tx.add((Activity) arg.rootElement);
|
||||
}
|
||||
}
|
||||
case Tags.RESOURCE -> tx.addOrUpdate((Resource) arg.rootElement);
|
||||
case Tags.ORDER -> tx.addOrUpdate((Order) arg.rootElement);
|
||||
case Tags.ACTIVITY -> tx.addOrUpdate((Activity) arg.rootElement);
|
||||
default -> throw new IllegalStateException("Unexpected value: " + arg.rootElement.getObjectType());
|
||||
}
|
||||
|
||||
tx.commitOnClose();
|
||||
|
|
Loading…
Reference in New Issue