From 08185b415fe9f5135694f6e9939abbac0a40a945 Mon Sep 17 00:00:00 2001 From: Robert von Burg Date: Sat, 11 Jan 2014 23:14:28 +0100 Subject: [PATCH] [New] Added Update and Remove services and commands --- .../command/AddOrderCollectionCommand.java | 8 +-- .../li/strolch/command/AddOrderCommand.java | 4 +- .../command/AddResourceCollectionCommand.java | 8 +-- .../strolch/command/AddResourceCommand.java | 4 +- .../command/RemoveOrderCollectionCommand.java | 67 +++++++++++++++++++ .../strolch/command/RemoveOrderCommand.java | 64 ++++++++++++++++++ .../RemoveResourceCollectionCommand.java | 67 +++++++++++++++++++ .../command/RemoveResourceCommand.java | 64 ++++++++++++++++++ .../command/UpdateOrderCollectionCommand.java | 67 +++++++++++++++++++ .../strolch/command/UpdateOrderCommand.java | 64 ++++++++++++++++++ .../UpdateResourceCollectionCommand.java | 67 +++++++++++++++++++ .../command/UpdateResourceCommand.java | 64 ++++++++++++++++++ .../service/RemoveOrderCollectionService.java | 56 ++++++++++++++++ .../strolch/service/RemoveOrderService.java | 53 +++++++++++++++ .../RemoveResourceCollectionService.java | 56 ++++++++++++++++ .../service/RemoveResourceService.java | 53 +++++++++++++++ .../service/UpdateOrderCollectionService.java | 56 ++++++++++++++++ .../strolch/service/UpdateOrderService.java | 53 +++++++++++++++ .../UpdateResourceCollectionService.java | 56 ++++++++++++++++ .../service/UpdateResourceService.java | 53 +++++++++++++++ 20 files changed, 972 insertions(+), 12 deletions(-) create mode 100644 src/main/java/li/strolch/command/RemoveOrderCollectionCommand.java create mode 100644 src/main/java/li/strolch/command/RemoveOrderCommand.java create mode 100644 src/main/java/li/strolch/command/RemoveResourceCollectionCommand.java create mode 100644 src/main/java/li/strolch/command/RemoveResourceCommand.java create mode 100644 src/main/java/li/strolch/command/UpdateOrderCollectionCommand.java create mode 100644 src/main/java/li/strolch/command/UpdateOrderCommand.java create mode 100644 src/main/java/li/strolch/command/UpdateResourceCollectionCommand.java create mode 100644 src/main/java/li/strolch/command/UpdateResourceCommand.java create mode 100644 src/main/java/li/strolch/service/RemoveOrderCollectionService.java create mode 100644 src/main/java/li/strolch/service/RemoveOrderService.java create mode 100644 src/main/java/li/strolch/service/RemoveResourceCollectionService.java create mode 100644 src/main/java/li/strolch/service/RemoveResourceService.java create mode 100644 src/main/java/li/strolch/service/UpdateOrderCollectionService.java create mode 100644 src/main/java/li/strolch/service/UpdateOrderService.java create mode 100644 src/main/java/li/strolch/service/UpdateResourceCollectionService.java create mode 100644 src/main/java/li/strolch/service/UpdateResourceService.java diff --git a/src/main/java/li/strolch/command/AddOrderCollectionCommand.java b/src/main/java/li/strolch/command/AddOrderCollectionCommand.java index 559560d1a..3e284a391 100644 --- a/src/main/java/li/strolch/command/AddOrderCollectionCommand.java +++ b/src/main/java/li/strolch/command/AddOrderCollectionCommand.java @@ -15,6 +15,7 @@ */ package li.strolch.command; +import java.text.MessageFormat; import java.util.List; import li.strolch.agent.api.ComponentContainer; @@ -55,14 +56,11 @@ public class AddOrderCollectionCommand extends Command { OrderMap orderMap = tx().getOrderMap(); for (Order order : orders) { if (orderMap.hasElement(tx(), order.getType(), order.getId())) { - String msg = "The Order " + order.getLocator() + " already exists!"; + String msg = MessageFormat.format("The Order {0} already exists!", order.getLocator()); throw new StrolchException(msg); } - } - for (Order order : orders) { - orderMap.add(tx(), order); - } + orderMap.addAll(tx(), orders); } } diff --git a/src/main/java/li/strolch/command/AddOrderCommand.java b/src/main/java/li/strolch/command/AddOrderCommand.java index b21d5d02a..028c0e470 100644 --- a/src/main/java/li/strolch/command/AddOrderCommand.java +++ b/src/main/java/li/strolch/command/AddOrderCommand.java @@ -15,6 +15,8 @@ */ package li.strolch.command; +import java.text.MessageFormat; + import li.strolch.agent.api.ComponentContainer; import li.strolch.agent.api.OrderMap; import li.strolch.exception.StrolchException; @@ -52,7 +54,7 @@ public class AddOrderCommand extends Command { OrderMap orderMap = tx().getOrderMap(); if (orderMap.hasElement(tx(), this.order.getType(), this.order.getId())) { - String msg = "The Order " + this.order.getLocator() + " already exists!"; + String msg = MessageFormat.format("The Order {0} already exists!", this.order.getLocator()); throw new StrolchException(msg); } diff --git a/src/main/java/li/strolch/command/AddResourceCollectionCommand.java b/src/main/java/li/strolch/command/AddResourceCollectionCommand.java index d1a71b3da..16fb3c6ce 100644 --- a/src/main/java/li/strolch/command/AddResourceCollectionCommand.java +++ b/src/main/java/li/strolch/command/AddResourceCollectionCommand.java @@ -15,6 +15,7 @@ */ package li.strolch.command; +import java.text.MessageFormat; import java.util.List; import li.strolch.agent.api.ComponentContainer; @@ -55,14 +56,11 @@ public class AddResourceCollectionCommand extends Command { ResourceMap resourceMap = tx().getResourceMap(); for (Resource resource : resources) { if (resourceMap.hasElement(tx(), resource.getType(), resource.getId())) { - String msg = "The Resource " + resource.getLocator() + " already exists!"; + String msg = MessageFormat.format("The Resource {0} already exists!", resource.getLocator()); throw new StrolchException(msg); } - } - for (Resource resource : resources) { - resourceMap.add(tx(), resource); - } + resourceMap.addAll(tx(), resources); } } diff --git a/src/main/java/li/strolch/command/AddResourceCommand.java b/src/main/java/li/strolch/command/AddResourceCommand.java index f7f5ec17f..6543c6753 100644 --- a/src/main/java/li/strolch/command/AddResourceCommand.java +++ b/src/main/java/li/strolch/command/AddResourceCommand.java @@ -15,6 +15,8 @@ */ package li.strolch.command; +import java.text.MessageFormat; + import li.strolch.agent.api.ComponentContainer; import li.strolch.agent.api.ResourceMap; import li.strolch.exception.StrolchException; @@ -52,7 +54,7 @@ public class AddResourceCommand extends Command { ResourceMap resourceMap = tx().getResourceMap(); if (resourceMap.hasElement(tx(), this.resource.getType(), this.resource.getId())) { - String msg = "The Resource " + this.resource.getLocator() + " already exists!"; + String msg = MessageFormat.format("The Resource {0} already exists!", this.resource.getLocator()); throw new StrolchException(msg); } diff --git a/src/main/java/li/strolch/command/RemoveOrderCollectionCommand.java b/src/main/java/li/strolch/command/RemoveOrderCollectionCommand.java new file mode 100644 index 000000000..6cb111893 --- /dev/null +++ b/src/main/java/li/strolch/command/RemoveOrderCollectionCommand.java @@ -0,0 +1,67 @@ +/* + * Copyright 2013 Robert von Burg + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package li.strolch.command; + +import java.text.MessageFormat; +import java.util.List; + +import li.strolch.agent.api.ComponentContainer; +import li.strolch.agent.api.OrderMap; +import li.strolch.exception.StrolchException; +import li.strolch.model.Order; +import li.strolch.persistence.api.StrolchTransaction; +import li.strolch.service.api.Command; +import ch.eitchnet.utils.dbc.DBC; + +/** + * @author Robert von Burg + */ +public class RemoveOrderCollectionCommand extends Command { + + private List orders; + + /** + * @param tx + */ + public RemoveOrderCollectionCommand(ComponentContainer container, StrolchTransaction tx) { + super(container, tx); + } + + /** + * @param orders + * the orders to set + */ + public void setOrders(List orders) { + this.orders = orders; + } + + @Override + public void doCommand() { + + DBC.PRE.assertNotNull("Order list may not be null!", this.orders); + + OrderMap orderMap = tx().getOrderMap(); + for (Order order : orders) { + if (!orderMap.hasElement(tx(), order.getType(), order.getId())) { + String msg = "The Order {0} can not be removed as it does not exist!"; + msg = MessageFormat.format(msg, order.getLocator()); + throw new StrolchException(msg); + } + } + + orderMap.removeAll(tx(), orders); + } +} diff --git a/src/main/java/li/strolch/command/RemoveOrderCommand.java b/src/main/java/li/strolch/command/RemoveOrderCommand.java new file mode 100644 index 000000000..1c115d4d2 --- /dev/null +++ b/src/main/java/li/strolch/command/RemoveOrderCommand.java @@ -0,0 +1,64 @@ +/* + * Copyright 2013 Robert von Burg + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package li.strolch.command; + +import java.text.MessageFormat; + +import li.strolch.agent.api.ComponentContainer; +import li.strolch.agent.api.OrderMap; +import li.strolch.exception.StrolchException; +import li.strolch.model.Order; +import li.strolch.persistence.api.StrolchTransaction; +import li.strolch.service.api.Command; +import ch.eitchnet.utils.dbc.DBC; + +/** + * @author Robert von Burg + */ +public class RemoveOrderCommand extends Command { + + private Order order; + + /** + * @param tx + */ + public RemoveOrderCommand(ComponentContainer container, StrolchTransaction tx) { + super(container, tx); + } + + /** + * @param order + * the order to set + */ + public void setOrder(Order order) { + this.order = order; + } + + @Override + public void doCommand() { + + DBC.PRE.assertNotNull("Order may not be null!", this.order); + + OrderMap orderMap = tx().getOrderMap(); + if (!orderMap.hasElement(tx(), this.order.getType(), this.order.getId())) { + String msg = "The Order {0} can not be removed as it does not exist!"; + msg = MessageFormat.format(msg, this.order.getLocator()); + throw new StrolchException(msg); + } + + orderMap.remove(tx(), this.order); + } +} diff --git a/src/main/java/li/strolch/command/RemoveResourceCollectionCommand.java b/src/main/java/li/strolch/command/RemoveResourceCollectionCommand.java new file mode 100644 index 000000000..7d9b972c6 --- /dev/null +++ b/src/main/java/li/strolch/command/RemoveResourceCollectionCommand.java @@ -0,0 +1,67 @@ +/* + * Copyright 2013 Robert von Burg + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package li.strolch.command; + +import java.text.MessageFormat; +import java.util.List; + +import li.strolch.agent.api.ComponentContainer; +import li.strolch.agent.api.ResourceMap; +import li.strolch.exception.StrolchException; +import li.strolch.model.Resource; +import li.strolch.persistence.api.StrolchTransaction; +import li.strolch.service.api.Command; +import ch.eitchnet.utils.dbc.DBC; + +/** + * @author Robert von Burg + */ +public class RemoveResourceCollectionCommand extends Command { + + private List resources; + + /** + * @param tx + */ + public RemoveResourceCollectionCommand(ComponentContainer container, StrolchTransaction tx) { + super(container, tx); + } + + /** + * @param resources + * the resources to set + */ + public void setResources(List resources) { + this.resources = resources; + } + + @Override + public void doCommand() { + + DBC.PRE.assertNotNull("Resource list may not be null!", this.resources); + + ResourceMap resourceMap = tx().getResourceMap(); + for (Resource resource : resources) { + if (!resourceMap.hasElement(tx(), resource.getType(), resource.getId())) { + String msg = "The Resource {0} can not be removed as it does not exist!"; + msg = MessageFormat.format(msg, resource.getLocator()); + throw new StrolchException(msg); + } + } + + resourceMap.removeAll(tx(), resources); + } +} diff --git a/src/main/java/li/strolch/command/RemoveResourceCommand.java b/src/main/java/li/strolch/command/RemoveResourceCommand.java new file mode 100644 index 000000000..d9fd28cbd --- /dev/null +++ b/src/main/java/li/strolch/command/RemoveResourceCommand.java @@ -0,0 +1,64 @@ +/* + * Copyright 2013 Robert von Burg + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package li.strolch.command; + +import java.text.MessageFormat; + +import li.strolch.agent.api.ComponentContainer; +import li.strolch.agent.api.ResourceMap; +import li.strolch.exception.StrolchException; +import li.strolch.model.Resource; +import li.strolch.persistence.api.StrolchTransaction; +import li.strolch.service.api.Command; +import ch.eitchnet.utils.dbc.DBC; + +/** + * @author Robert von Burg + */ +public class RemoveResourceCommand extends Command { + + private Resource resource; + + /** + * @param tx + */ + public RemoveResourceCommand(ComponentContainer container, StrolchTransaction tx) { + super(container, tx); + } + + /** + * @param resource + * the resource to set + */ + public void setResource(Resource resource) { + this.resource = resource; + } + + @Override + public void doCommand() { + + DBC.PRE.assertNotNull("Resource may not be null!", this.resource); + + ResourceMap resourceMap = tx().getResourceMap(); + if (!resourceMap.hasElement(tx(), this.resource.getType(), this.resource.getId())) { + String msg = "The Resource {0} can not be removed as it does not exist!!"; + msg = MessageFormat.format(msg, this.resource.getLocator()); + throw new StrolchException(msg); + } + + resourceMap.remove(tx(), this.resource); + } +} diff --git a/src/main/java/li/strolch/command/UpdateOrderCollectionCommand.java b/src/main/java/li/strolch/command/UpdateOrderCollectionCommand.java new file mode 100644 index 000000000..72e59601d --- /dev/null +++ b/src/main/java/li/strolch/command/UpdateOrderCollectionCommand.java @@ -0,0 +1,67 @@ +/* + * Copyright 2013 Robert von Burg + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package li.strolch.command; + +import java.text.MessageFormat; +import java.util.List; + +import li.strolch.agent.api.ComponentContainer; +import li.strolch.agent.api.OrderMap; +import li.strolch.exception.StrolchException; +import li.strolch.model.Order; +import li.strolch.persistence.api.StrolchTransaction; +import li.strolch.service.api.Command; +import ch.eitchnet.utils.dbc.DBC; + +/** + * @author Robert von Burg + */ +public class UpdateOrderCollectionCommand extends Command { + + private List orders; + + /** + * @param tx + */ + public UpdateOrderCollectionCommand(ComponentContainer container, StrolchTransaction tx) { + super(container, tx); + } + + /** + * @param orders + * the orders to set + */ + public void setOrders(List orders) { + this.orders = orders; + } + + @Override + public void doCommand() { + + DBC.PRE.assertNotNull("Order list may not be null!", this.orders); + + OrderMap orderMap = tx().getOrderMap(); + for (Order order : orders) { + if (!orderMap.hasElement(tx(), order.getType(), order.getId())) { + String msg = "The Order {0} can not be updated as it does not exist!"; + msg = MessageFormat.format(msg, order.getLocator()); + throw new StrolchException(msg); + } + } + + orderMap.updateAll(tx(), orders); + } +} diff --git a/src/main/java/li/strolch/command/UpdateOrderCommand.java b/src/main/java/li/strolch/command/UpdateOrderCommand.java new file mode 100644 index 000000000..69085a778 --- /dev/null +++ b/src/main/java/li/strolch/command/UpdateOrderCommand.java @@ -0,0 +1,64 @@ +/* + * Copyright 2013 Robert von Burg + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package li.strolch.command; + +import java.text.MessageFormat; + +import li.strolch.agent.api.ComponentContainer; +import li.strolch.agent.api.OrderMap; +import li.strolch.exception.StrolchException; +import li.strolch.model.Order; +import li.strolch.persistence.api.StrolchTransaction; +import li.strolch.service.api.Command; +import ch.eitchnet.utils.dbc.DBC; + +/** + * @author Robert von Burg + */ +public class UpdateOrderCommand extends Command { + + private Order order; + + /** + * @param tx + */ + public UpdateOrderCommand(ComponentContainer container, StrolchTransaction tx) { + super(container, tx); + } + + /** + * @param order + * the order to set + */ + public void setOrder(Order order) { + this.order = order; + } + + @Override + public void doCommand() { + + DBC.PRE.assertNotNull("Order may not be null!", this.order); + + OrderMap orderMap = tx().getOrderMap(); + if (!orderMap.hasElement(tx(), this.order.getType(), this.order.getId())) { + String msg = "The Order {0} can not be updated as it does not exist!"; + msg = MessageFormat.format(msg, this.order.getLocator()); + throw new StrolchException(msg); + } + + orderMap.update(tx(), this.order); + } +} diff --git a/src/main/java/li/strolch/command/UpdateResourceCollectionCommand.java b/src/main/java/li/strolch/command/UpdateResourceCollectionCommand.java new file mode 100644 index 000000000..043253d24 --- /dev/null +++ b/src/main/java/li/strolch/command/UpdateResourceCollectionCommand.java @@ -0,0 +1,67 @@ +/* + * Copyright 2013 Robert von Burg + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package li.strolch.command; + +import java.text.MessageFormat; +import java.util.List; + +import li.strolch.agent.api.ComponentContainer; +import li.strolch.agent.api.ResourceMap; +import li.strolch.exception.StrolchException; +import li.strolch.model.Resource; +import li.strolch.persistence.api.StrolchTransaction; +import li.strolch.service.api.Command; +import ch.eitchnet.utils.dbc.DBC; + +/** + * @author Robert von Burg + */ +public class UpdateResourceCollectionCommand extends Command { + + private List resources; + + /** + * @param tx + */ + public UpdateResourceCollectionCommand(ComponentContainer container, StrolchTransaction tx) { + super(container, tx); + } + + /** + * @param resources + * the resources to set + */ + public void setResources(List resources) { + this.resources = resources; + } + + @Override + public void doCommand() { + + DBC.PRE.assertNotNull("Resource list may not be null!", this.resources); + + ResourceMap resourceMap = tx().getResourceMap(); + for (Resource resource : resources) { + if (!resourceMap.hasElement(tx(), resource.getType(), resource.getId())) { + String msg = "The Resource {0} can not be updated as it does not exist!"; + msg = MessageFormat.format(msg, resource.getLocator()); + throw new StrolchException(msg); + } + } + + resourceMap.updateAll(tx(), resources); + } +} diff --git a/src/main/java/li/strolch/command/UpdateResourceCommand.java b/src/main/java/li/strolch/command/UpdateResourceCommand.java new file mode 100644 index 000000000..f6a479752 --- /dev/null +++ b/src/main/java/li/strolch/command/UpdateResourceCommand.java @@ -0,0 +1,64 @@ +/* + * Copyright 2013 Robert von Burg + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package li.strolch.command; + +import java.text.MessageFormat; + +import li.strolch.agent.api.ComponentContainer; +import li.strolch.agent.api.ResourceMap; +import li.strolch.exception.StrolchException; +import li.strolch.model.Resource; +import li.strolch.persistence.api.StrolchTransaction; +import li.strolch.service.api.Command; +import ch.eitchnet.utils.dbc.DBC; + +/** + * @author Robert von Burg + */ +public class UpdateResourceCommand extends Command { + + private Resource resource; + + /** + * @param tx + */ + public UpdateResourceCommand(ComponentContainer container, StrolchTransaction tx) { + super(container, tx); + } + + /** + * @param resource + * the resource to set + */ + public void setResource(Resource resource) { + this.resource = resource; + } + + @Override + public void doCommand() { + + DBC.PRE.assertNotNull("Resource may not be null!", this.resource); + + ResourceMap resourceMap = tx().getResourceMap(); + if (!resourceMap.hasElement(tx(), this.resource.getType(), this.resource.getId())) { + String msg = "The Resource {0} can not be updated as it does not exist!!"; + msg = MessageFormat.format(msg, this.resource.getLocator()); + throw new StrolchException(msg); + } + + resourceMap.update(tx(), this.resource); + } +} diff --git a/src/main/java/li/strolch/service/RemoveOrderCollectionService.java b/src/main/java/li/strolch/service/RemoveOrderCollectionService.java new file mode 100644 index 000000000..ac23bd144 --- /dev/null +++ b/src/main/java/li/strolch/service/RemoveOrderCollectionService.java @@ -0,0 +1,56 @@ +/* + * Copyright 2013 Robert von Burg + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package li.strolch.service; + +import java.util.List; + +import li.strolch.command.RemoveOrderCollectionCommand; +import li.strolch.model.Order; +import li.strolch.persistence.api.StrolchTransaction; +import li.strolch.service.api.AbstractService; +import li.strolch.service.api.ServiceArgument; +import li.strolch.service.api.ServiceResult; + +/** + * @author Robert von Burg + */ +public class RemoveOrderCollectionService extends + AbstractService { + + private static final long serialVersionUID = 1L; + + @Override + protected ServiceResult getResultInstance() { + return new ServiceResult(); + } + + @Override + protected ServiceResult internalDoService(AddOrderCollectionArg arg) { + + try (StrolchTransaction tx = openTx(arg.realm)) { + RemoveOrderCollectionCommand command = new RemoveOrderCollectionCommand(getContainer(), tx); + command.setOrders(arg.orders); + command.doCommand(); + } + + return ServiceResult.success(); + } + + public static class AddOrderCollectionArg extends ServiceArgument { + private static final long serialVersionUID = 1L; + public List orders; + } +} diff --git a/src/main/java/li/strolch/service/RemoveOrderService.java b/src/main/java/li/strolch/service/RemoveOrderService.java new file mode 100644 index 000000000..e7e7e7b33 --- /dev/null +++ b/src/main/java/li/strolch/service/RemoveOrderService.java @@ -0,0 +1,53 @@ +/* + * Copyright 2013 Robert von Burg + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package li.strolch.service; + +import li.strolch.command.RemoveOrderCommand; +import li.strolch.model.Order; +import li.strolch.persistence.api.StrolchTransaction; +import li.strolch.service.api.AbstractService; +import li.strolch.service.api.ServiceArgument; +import li.strolch.service.api.ServiceResult; + +/** + * @author Robert von Burg + */ +public class RemoveOrderService extends AbstractService { + + private static final long serialVersionUID = 1L; + + @Override + protected ServiceResult getResultInstance() { + return new ServiceResult(); + } + + @Override + protected ServiceResult internalDoService(AddOrderArg arg) { + + try (StrolchTransaction tx = openTx(arg.realm)) { + RemoveOrderCommand command = new RemoveOrderCommand(getContainer(), tx); + command.setOrder(arg.order); + command.doCommand(); + } + + return ServiceResult.success(); + } + + public static class AddOrderArg extends ServiceArgument { + private static final long serialVersionUID = 1L; + public Order order; + } +} diff --git a/src/main/java/li/strolch/service/RemoveResourceCollectionService.java b/src/main/java/li/strolch/service/RemoveResourceCollectionService.java new file mode 100644 index 000000000..48df83a93 --- /dev/null +++ b/src/main/java/li/strolch/service/RemoveResourceCollectionService.java @@ -0,0 +1,56 @@ +/* + * Copyright 2013 Robert von Burg + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package li.strolch.service; + +import java.util.List; + +import li.strolch.command.RemoveResourceCollectionCommand; +import li.strolch.model.Resource; +import li.strolch.persistence.api.StrolchTransaction; +import li.strolch.service.api.AbstractService; +import li.strolch.service.api.ServiceArgument; +import li.strolch.service.api.ServiceResult; + +/** + * @author Robert von Burg + */ +public class RemoveResourceCollectionService extends + AbstractService { + + private static final long serialVersionUID = 1L; + + @Override + protected ServiceResult getResultInstance() { + return new ServiceResult(); + } + + @Override + protected ServiceResult internalDoService(AddResourceCollectionArg arg) { + + try (StrolchTransaction tx = openTx(arg.realm)) { + RemoveResourceCollectionCommand command = new RemoveResourceCollectionCommand(getContainer(), tx); + command.setResources(arg.resources); + command.doCommand(); + } + + return ServiceResult.success(); + } + + public static class AddResourceCollectionArg extends ServiceArgument { + private static final long serialVersionUID = 1L; + public List resources; + } +} diff --git a/src/main/java/li/strolch/service/RemoveResourceService.java b/src/main/java/li/strolch/service/RemoveResourceService.java new file mode 100644 index 000000000..4e9585731 --- /dev/null +++ b/src/main/java/li/strolch/service/RemoveResourceService.java @@ -0,0 +1,53 @@ +/* + * Copyright 2013 Robert von Burg + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package li.strolch.service; + +import li.strolch.command.RemoveResourceCommand; +import li.strolch.model.Resource; +import li.strolch.persistence.api.StrolchTransaction; +import li.strolch.service.api.AbstractService; +import li.strolch.service.api.ServiceArgument; +import li.strolch.service.api.ServiceResult; + +/** + * @author Robert von Burg + */ +public class RemoveResourceService extends AbstractService { + + private static final long serialVersionUID = 1L; + + @Override + protected ServiceResult getResultInstance() { + return new ServiceResult(); + } + + @Override + protected ServiceResult internalDoService(AddResourceArg arg) { + + try (StrolchTransaction tx = openTx(arg.realm)) { + RemoveResourceCommand command = new RemoveResourceCommand(getContainer(), tx); + command.setResource(arg.resource); + command.doCommand(); + } + + return ServiceResult.success(); + } + + public static class AddResourceArg extends ServiceArgument { + private static final long serialVersionUID = 1L; + public Resource resource; + } +} diff --git a/src/main/java/li/strolch/service/UpdateOrderCollectionService.java b/src/main/java/li/strolch/service/UpdateOrderCollectionService.java new file mode 100644 index 000000000..3e4bcac91 --- /dev/null +++ b/src/main/java/li/strolch/service/UpdateOrderCollectionService.java @@ -0,0 +1,56 @@ +/* + * Copyright 2013 Robert von Burg + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package li.strolch.service; + +import java.util.List; + +import li.strolch.command.UpdateOrderCollectionCommand; +import li.strolch.model.Order; +import li.strolch.persistence.api.StrolchTransaction; +import li.strolch.service.api.AbstractService; +import li.strolch.service.api.ServiceArgument; +import li.strolch.service.api.ServiceResult; + +/** + * @author Robert von Burg + */ +public class UpdateOrderCollectionService extends + AbstractService { + + private static final long serialVersionUID = 1L; + + @Override + protected ServiceResult getResultInstance() { + return new ServiceResult(); + } + + @Override + protected ServiceResult internalDoService(AddOrderCollectionArg arg) { + + try (StrolchTransaction tx = openTx(arg.realm)) { + UpdateOrderCollectionCommand command = new UpdateOrderCollectionCommand(getContainer(), tx); + command.setOrders(arg.orders); + command.doCommand(); + } + + return ServiceResult.success(); + } + + public static class AddOrderCollectionArg extends ServiceArgument { + private static final long serialVersionUID = 1L; + public List orders; + } +} diff --git a/src/main/java/li/strolch/service/UpdateOrderService.java b/src/main/java/li/strolch/service/UpdateOrderService.java new file mode 100644 index 000000000..47db84604 --- /dev/null +++ b/src/main/java/li/strolch/service/UpdateOrderService.java @@ -0,0 +1,53 @@ +/* + * Copyright 2013 Robert von Burg + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package li.strolch.service; + +import li.strolch.command.UpdateOrderCommand; +import li.strolch.model.Order; +import li.strolch.persistence.api.StrolchTransaction; +import li.strolch.service.api.AbstractService; +import li.strolch.service.api.ServiceArgument; +import li.strolch.service.api.ServiceResult; + +/** + * @author Robert von Burg + */ +public class UpdateOrderService extends AbstractService { + + private static final long serialVersionUID = 1L; + + @Override + protected ServiceResult getResultInstance() { + return new ServiceResult(); + } + + @Override + protected ServiceResult internalDoService(AddOrderArg arg) { + + try (StrolchTransaction tx = openTx(arg.realm)) { + UpdateOrderCommand command = new UpdateOrderCommand(getContainer(), tx); + command.setOrder(arg.order); + command.doCommand(); + } + + return ServiceResult.success(); + } + + public static class AddOrderArg extends ServiceArgument { + private static final long serialVersionUID = 1L; + public Order order; + } +} diff --git a/src/main/java/li/strolch/service/UpdateResourceCollectionService.java b/src/main/java/li/strolch/service/UpdateResourceCollectionService.java new file mode 100644 index 000000000..1d982588f --- /dev/null +++ b/src/main/java/li/strolch/service/UpdateResourceCollectionService.java @@ -0,0 +1,56 @@ +/* + * Copyright 2013 Robert von Burg + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package li.strolch.service; + +import java.util.List; + +import li.strolch.command.UpdateResourceCollectionCommand; +import li.strolch.model.Resource; +import li.strolch.persistence.api.StrolchTransaction; +import li.strolch.service.api.AbstractService; +import li.strolch.service.api.ServiceArgument; +import li.strolch.service.api.ServiceResult; + +/** + * @author Robert von Burg + */ +public class UpdateResourceCollectionService extends + AbstractService { + + private static final long serialVersionUID = 1L; + + @Override + protected ServiceResult getResultInstance() { + return new ServiceResult(); + } + + @Override + protected ServiceResult internalDoService(AddResourceCollectionArg arg) { + + try (StrolchTransaction tx = openTx(arg.realm)) { + UpdateResourceCollectionCommand command = new UpdateResourceCollectionCommand(getContainer(), tx); + command.setResources(arg.resources); + command.doCommand(); + } + + return ServiceResult.success(); + } + + public static class AddResourceCollectionArg extends ServiceArgument { + private static final long serialVersionUID = 1L; + public List resources; + } +} diff --git a/src/main/java/li/strolch/service/UpdateResourceService.java b/src/main/java/li/strolch/service/UpdateResourceService.java new file mode 100644 index 000000000..56e13c1f9 --- /dev/null +++ b/src/main/java/li/strolch/service/UpdateResourceService.java @@ -0,0 +1,53 @@ +/* + * Copyright 2013 Robert von Burg + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package li.strolch.service; + +import li.strolch.command.UpdateResourceCommand; +import li.strolch.model.Resource; +import li.strolch.persistence.api.StrolchTransaction; +import li.strolch.service.api.AbstractService; +import li.strolch.service.api.ServiceArgument; +import li.strolch.service.api.ServiceResult; + +/** + * @author Robert von Burg + */ +public class UpdateResourceService extends AbstractService { + + private static final long serialVersionUID = 1L; + + @Override + protected ServiceResult getResultInstance() { + return new ServiceResult(); + } + + @Override + protected ServiceResult internalDoService(AddResourceArg arg) { + + try (StrolchTransaction tx = openTx(arg.realm)) { + UpdateResourceCommand command = new UpdateResourceCommand(getContainer(), tx); + command.setResource(arg.resource); + command.doCommand(); + } + + return ServiceResult.success(); + } + + public static class AddResourceArg extends ServiceArgument { + private static final long serialVersionUID = 1L; + public Resource resource; + } +}