[New] Added Update and Remove services and commands
This commit is contained in:
parent
04a0906513
commit
08185b415f
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
* Copyright 2013 Robert von Burg <eitch@eitchnet.ch>
|
||||
*
|
||||
* 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 <eitch@eitchnet.ch>
|
||||
*/
|
||||
public class RemoveOrderCollectionCommand extends Command {
|
||||
|
||||
private List<Order> orders;
|
||||
|
||||
/**
|
||||
* @param tx
|
||||
*/
|
||||
public RemoveOrderCollectionCommand(ComponentContainer container, StrolchTransaction tx) {
|
||||
super(container, tx);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param orders
|
||||
* the orders to set
|
||||
*/
|
||||
public void setOrders(List<Order> 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);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* Copyright 2013 Robert von Burg <eitch@eitchnet.ch>
|
||||
*
|
||||
* 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 <eitch@eitchnet.ch>
|
||||
*/
|
||||
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);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
* Copyright 2013 Robert von Burg <eitch@eitchnet.ch>
|
||||
*
|
||||
* 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 <eitch@eitchnet.ch>
|
||||
*/
|
||||
public class RemoveResourceCollectionCommand extends Command {
|
||||
|
||||
private List<Resource> resources;
|
||||
|
||||
/**
|
||||
* @param tx
|
||||
*/
|
||||
public RemoveResourceCollectionCommand(ComponentContainer container, StrolchTransaction tx) {
|
||||
super(container, tx);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param resources
|
||||
* the resources to set
|
||||
*/
|
||||
public void setResources(List<Resource> 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);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* Copyright 2013 Robert von Burg <eitch@eitchnet.ch>
|
||||
*
|
||||
* 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 <eitch@eitchnet.ch>
|
||||
*/
|
||||
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);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
* Copyright 2013 Robert von Burg <eitch@eitchnet.ch>
|
||||
*
|
||||
* 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 <eitch@eitchnet.ch>
|
||||
*/
|
||||
public class UpdateOrderCollectionCommand extends Command {
|
||||
|
||||
private List<Order> orders;
|
||||
|
||||
/**
|
||||
* @param tx
|
||||
*/
|
||||
public UpdateOrderCollectionCommand(ComponentContainer container, StrolchTransaction tx) {
|
||||
super(container, tx);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param orders
|
||||
* the orders to set
|
||||
*/
|
||||
public void setOrders(List<Order> 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);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* Copyright 2013 Robert von Burg <eitch@eitchnet.ch>
|
||||
*
|
||||
* 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 <eitch@eitchnet.ch>
|
||||
*/
|
||||
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);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
* Copyright 2013 Robert von Burg <eitch@eitchnet.ch>
|
||||
*
|
||||
* 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 <eitch@eitchnet.ch>
|
||||
*/
|
||||
public class UpdateResourceCollectionCommand extends Command {
|
||||
|
||||
private List<Resource> resources;
|
||||
|
||||
/**
|
||||
* @param tx
|
||||
*/
|
||||
public UpdateResourceCollectionCommand(ComponentContainer container, StrolchTransaction tx) {
|
||||
super(container, tx);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param resources
|
||||
* the resources to set
|
||||
*/
|
||||
public void setResources(List<Resource> 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);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* Copyright 2013 Robert von Burg <eitch@eitchnet.ch>
|
||||
*
|
||||
* 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 <eitch@eitchnet.ch>
|
||||
*/
|
||||
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);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* Copyright 2013 Robert von Burg <eitch@eitchnet.ch>
|
||||
*
|
||||
* 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 <eitch@eitchnet.ch>
|
||||
*/
|
||||
public class RemoveOrderCollectionService extends
|
||||
AbstractService<RemoveOrderCollectionService.AddOrderCollectionArg, ServiceResult> {
|
||||
|
||||
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<Order> orders;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* Copyright 2013 Robert von Burg <eitch@eitchnet.ch>
|
||||
*
|
||||
* 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 <eitch@eitchnet.ch>
|
||||
*/
|
||||
public class RemoveOrderService extends AbstractService<RemoveOrderService.AddOrderArg, ServiceResult> {
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* Copyright 2013 Robert von Burg <eitch@eitchnet.ch>
|
||||
*
|
||||
* 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 <eitch@eitchnet.ch>
|
||||
*/
|
||||
public class RemoveResourceCollectionService extends
|
||||
AbstractService<RemoveResourceCollectionService.AddResourceCollectionArg, ServiceResult> {
|
||||
|
||||
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<Resource> resources;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* Copyright 2013 Robert von Burg <eitch@eitchnet.ch>
|
||||
*
|
||||
* 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 <eitch@eitchnet.ch>
|
||||
*/
|
||||
public class RemoveResourceService extends AbstractService<RemoveResourceService.AddResourceArg, ServiceResult> {
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* Copyright 2013 Robert von Burg <eitch@eitchnet.ch>
|
||||
*
|
||||
* 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 <eitch@eitchnet.ch>
|
||||
*/
|
||||
public class UpdateOrderCollectionService extends
|
||||
AbstractService<UpdateOrderCollectionService.AddOrderCollectionArg, ServiceResult> {
|
||||
|
||||
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<Order> orders;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* Copyright 2013 Robert von Burg <eitch@eitchnet.ch>
|
||||
*
|
||||
* 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 <eitch@eitchnet.ch>
|
||||
*/
|
||||
public class UpdateOrderService extends AbstractService<UpdateOrderService.AddOrderArg, ServiceResult> {
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* Copyright 2013 Robert von Burg <eitch@eitchnet.ch>
|
||||
*
|
||||
* 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 <eitch@eitchnet.ch>
|
||||
*/
|
||||
public class UpdateResourceCollectionService extends
|
||||
AbstractService<UpdateResourceCollectionService.AddResourceCollectionArg, ServiceResult> {
|
||||
|
||||
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<Resource> resources;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* Copyright 2013 Robert von Burg <eitch@eitchnet.ch>
|
||||
*
|
||||
* 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 <eitch@eitchnet.ch>
|
||||
*/
|
||||
public class UpdateResourceService extends AbstractService<UpdateResourceService.AddResourceArg, ServiceResult> {
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue