[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)) {
|
try (StrolchTransaction tx = openArgOrUserTx(arg)) {
|
||||||
|
|
||||||
switch (arg.rootElement.getObjectType()) {
|
switch (arg.rootElement.getObjectType()) {
|
||||||
case Tags.RESOURCE -> {
|
case Tags.RESOURCE -> tx.addOrUpdate((Resource) arg.rootElement);
|
||||||
if (tx.hasResource(arg.rootElement.getType(), arg.rootElement.getId())) {
|
case Tags.ORDER -> tx.addOrUpdate((Order) arg.rootElement);
|
||||||
tx.update((Resource) arg.rootElement);
|
case Tags.ACTIVITY -> tx.addOrUpdate((Activity) arg.rootElement);
|
||||||
} else {
|
default -> throw new IllegalStateException("Unexpected value: " + arg.rootElement.getObjectType());
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tx.commitOnClose();
|
tx.commitOnClose();
|
||||||
|
|
Loading…
Reference in New Issue