+ *
+ * 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.model;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import li.strolch.exception.StrolchException;
+import ch.eitchnet.utils.helper.StringHelper;
+
+/**
+ *
+ * The {@link Locator} is an immutable object and is used to fully qualify the location of an object in the model. It
+ * consists of a {@link List} of Strings which starting from the first value, defining the root, with the last item
+ * defining the objects id.
+ *
+ *
+ *
+ * When the {@link Locator} is formatted to a String, it resembles the same format as is used in Unix based files
+ * systems, with slashes (/), separating the different list values
+ *
+ *
+ *
+ * A {@link Locator} is always immutable, modifications return a new instance
+ *
+ *
+ * @author Robert von Burg
+ */
+public class Locator {
+
+ /**
+ * The separator used when formatting a {@link Locator} object ot a string
+ */
+ public static final String PATH_SEPARATOR = "/"; //$NON-NLS-1$
+
+ /**
+ * {@link List} of path elements, with the first being the top level or root element
+ */
+ private final List pathElements;
+
+ /**
+ * Constructs a new {@link Locator} with the given list of path elements
+ *
+ * @param pathElements
+ * the elements making up the {@link Locator}
+ *
+ * @throws StrolchException
+ * if the path is invalid, meaning has less than two elements in it
+ */
+ public Locator(List pathElements) throws StrolchException {
+ if (pathElements == null || pathElements.isEmpty()) {
+ throw new StrolchException("The path elements may not be null and must contain at least 1 item"); //$NON-NLS-1$
+ }
+ this.pathElements = Collections.unmodifiableList(new ArrayList(pathElements));
+ }
+
+ /**
+ * Constructs a new {@link Locator} using the given path parts
+ *
+ * @param path
+ * the path to parse for instantiate this {@link Locator} with elements
+ *
+ * @throws StrolchException
+ * if the path is invalid, meaning has less than two elements in it
+ */
+ public Locator(String... path) throws StrolchException {
+ this.pathElements = Collections.unmodifiableList(Arrays.asList(path));
+ }
+
+ /**
+ * Constructs a new {@link Locator} by parsing the given string path.
+ *
+ * @param path
+ * the path to parse for instantiate this {@link Locator} with elements
+ *
+ * @throws StrolchException
+ * if the path is invalid, meaning has less than two elements in it
+ */
+ public Locator(String path) throws StrolchException {
+ this.pathElements = Collections.unmodifiableList(parsePath(path));
+ }
+
+ /**
+ * Internal constructor to append a sub path to a constructor
+ *
+ * @param path
+ * the base path of the locator
+ * @param subPath
+ * the additional path
+ */
+ private Locator(List path, List subPath) {
+ List fullPath = new ArrayList();
+ fullPath.addAll(path);
+ fullPath.addAll(subPath);
+ this.pathElements = Collections.unmodifiableList(fullPath);
+ }
+
+ /**
+ * Internal constructor to append a element to a constructor
+ *
+ * @param path
+ * the base path of the locator
+ * @param element
+ * the additional element
+ */
+ private Locator(List path, String element) {
+ List fullPath = new ArrayList();
+ fullPath.addAll(path);
+ fullPath.add(element);
+ this.pathElements = Collections.unmodifiableList(fullPath);
+ }
+
+ /**
+ * Returns the immutable list of path elements making up this locator
+ *
+ * @return the pathElements
+ */
+ public List getPathElements() {
+ return this.pathElements;
+ }
+
+ /**
+ * Returns the number of elements which this {@link Locator} contains
+ *
+ * @return the number of elements which this {@link Locator} contains
+ */
+ public int getSize() {
+ return this.pathElements.size();
+ }
+
+ /**
+ * Returns a new {@link Locator} where the given sub path is appended to the locator
+ *
+ * @param subPathElements
+ * the sub path to append
+ *
+ * @return the new locator
+ */
+ public Locator append(List subPathElements) {
+ return new Locator(this.pathElements, subPathElements);
+ }
+
+ /**
+ * Returns a new {@link Locator} where the given element is appended to the locator
+ *
+ * @param element
+ * the element to append
+ *
+ * @return the new locator
+ */
+ public Locator append(String element) {
+ return new Locator(this.pathElements, element);
+ }
+
+ /**
+ * Returns the string representation of this {@link Locator} by using the {@link #PATH_SEPARATOR} to separate the
+ * values
+ */
+ @Override
+ public String toString() {
+ return formatPath(this.pathElements);
+ }
+
+ /**
+ * Parses the given path to a {@link List} of path elements by splitting the string with the {@link #PATH_SEPARATOR}
+ *
+ * @param path
+ * the path to parse
+ *
+ * @return the list of path elements for the list
+ *
+ * @throws StrolchException
+ * if the path is empty, or does not contain at least 2 elements separated by {@link #PATH_SEPARATOR}
+ */
+ private List parsePath(String path) throws StrolchException {
+ if (StringHelper.isEmpty(path)) {
+ throw new StrolchException("A path may not be empty!"); //$NON-NLS-1$
+ }
+ String[] elements = path.split(Locator.PATH_SEPARATOR);
+ return Arrays.asList(elements);
+ }
+
+ /**
+ * Formats the given list of path elements to a String representation of the {@link Locator}
+ *
+ * @param pathElements
+ * the locator elements
+ *
+ * @return a string representation of the path elements
+ *
+ * @throws StrolchException
+ * if the path elements does not contain at least two items
+ */
+ private String formatPath(List pathElements) throws StrolchException {
+ StringBuilder sb = new StringBuilder();
+
+ Iterator iter = pathElements.iterator();
+ while (iter.hasNext()) {
+ String element = iter.next();
+ sb.append(element);
+ if (iter.hasNext()) {
+ sb.append(Locator.PATH_SEPARATOR);
+ }
+ }
+
+ return sb.toString();
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((this.pathElements == null) ? 0 : this.pathElements.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ Locator other = (Locator) obj;
+ if (this.pathElements == null) {
+ if (other.pathElements != null) {
+ return false;
+ }
+ } else if (!this.pathElements.equals(other.pathElements)) {
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Instantiates a new immutable {@link Locator} instance from the given string
+ *
+ * @param locatorPath
+ * the path from which to instantiate the locator
+ * @return the immutable {@link Locator} instance
+ */
+ public static Locator valueOf(String locatorPath) {
+ return new Locator(locatorPath);
+ }
+
+ /**
+ * Instantiates a new immutable {@link Locator} instance from the given path parts
+ *
+ * @param path
+ * the path from which to instantiate the locator
+ * @return the immutable {@link Locator} instance
+ */
+ public static Locator valueOf(String... path) {
+ return new Locator(path);
+ }
+
+ /**
+ * Creates a new {@link LocatorBuilder} instance and appends the given elements to it
+ *
+ * @param path
+ * the first element on the {@link Locator}
+ *
+ * @return a new {@link LocatorBuilder} instance with the given root element tag as the first element
+ */
+ public static LocatorBuilder newBuilder(String... path) {
+ return new LocatorBuilder().append(path);
+ }
+
+ /**
+ * Creates a new {@link LocatorBuilder} instance and appends the given root element tag to it
+ *
+ * @param rootElement
+ * the first element on the {@link Locator}
+ *
+ * @return a new {@link LocatorBuilder} instance with the given root element tag as the first element
+ */
+ public static LocatorBuilder newBuilder(String rootElement) {
+ return new LocatorBuilder().append(rootElement);
+ }
+
+ /**
+ * {@link LocatorBuilder} is used to build {@link Locator}s where a deep hierarchy is to be created. The
+ * {@link #append(String)} method returns itself for chain building
+ *
+ * @author Robert von Burg
+ */
+ public static class LocatorBuilder {
+
+ private final List pathElements;
+
+ /**
+ * Default constructor
+ */
+ public LocatorBuilder() {
+ this.pathElements = new ArrayList();
+ }
+
+ /**
+ * Append the given elements to the path
+ *
+ * @param path
+ * the path elements to add
+ *
+ * @return this instance for chaining
+ */
+ public LocatorBuilder append(String... path) {
+ for (String element : path) {
+ this.pathElements.add(element);
+ }
+ return this;
+ }
+
+ /**
+ * Append an element to the path
+ *
+ * @param element
+ * the element to add
+ *
+ * @return this instance for chaining
+ */
+ public LocatorBuilder append(String element) {
+ this.pathElements.add(element);
+ return this;
+ }
+
+ /**
+ * Remove the last element from the path
+ *
+ * @return this instance for chaining
+ */
+ public LocatorBuilder removeLast() {
+ this.pathElements.remove(this.pathElements.size() - 1);
+ return this;
+ }
+
+ /**
+ * Creates an immutable {@link Locator} instance with the current elements
+ *
+ * @return a new {@link Locator} instance
+ */
+ public Locator build() {
+ if (this.pathElements.isEmpty()) {
+ throw new StrolchException("The path elements must contain at least 1 item"); //$NON-NLS-1$
+ }
+ return new Locator(this.pathElements);
+ }
+ }
+}
diff --git a/li.strolch.model/src/main/java/li/strolch/model/ModelGenerator.java b/li.strolch.model/src/main/java/li/strolch/model/ModelGenerator.java
new file mode 100644
index 000000000..701b9a248
--- /dev/null
+++ b/li.strolch.model/src/main/java/li/strolch/model/ModelGenerator.java
@@ -0,0 +1,404 @@
+/*
+ * 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.model;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Random;
+import java.util.Set;
+
+import li.strolch.model.audit.AccessType;
+import li.strolch.model.audit.Audit;
+import li.strolch.model.parameter.BooleanParameter;
+import li.strolch.model.parameter.DateParameter;
+import li.strolch.model.parameter.FloatParameter;
+import li.strolch.model.parameter.IntegerParameter;
+import li.strolch.model.parameter.LongParameter;
+import li.strolch.model.parameter.Parameter;
+import li.strolch.model.parameter.StringListParameter;
+import li.strolch.model.parameter.StringParameter;
+import li.strolch.model.timedstate.BooleanTimedState;
+import li.strolch.model.timedstate.FloatTimedState;
+import li.strolch.model.timedstate.IntegerTimedState;
+import li.strolch.model.timedstate.StringSetTimedState;
+import li.strolch.model.timedstate.StrolchTimedState;
+import li.strolch.model.timevalue.impl.AString;
+import li.strolch.model.timevalue.impl.BooleanValue;
+import li.strolch.model.timevalue.impl.FloatValue;
+import li.strolch.model.timevalue.impl.IntegerValue;
+import li.strolch.model.timevalue.impl.StringSetValue;
+import li.strolch.model.timevalue.impl.ValueChange;
+import ch.eitchnet.utils.helper.StringHelper;
+
+/**
+ * Class which can be used to generate objects which implement {@link StrolchElement}. These generated classes can then
+ * be used in test classes etc.
+ *
+ * @author Robert von Burg
+ */
+@SuppressWarnings("nls")
+public class ModelGenerator {
+
+ public static final String PARAM_BOOLEAN_ID = "@param1";
+ public static final String PARAM_BOOLEAN_NAME = "Boolean Param";
+
+ public static final String PARAM_FLOAT_ID = "@param2";
+ public static final String PARAM_FLOAT_NAME = "Float Param";
+
+ public static final String PARAM_INTEGER_ID = "@param3";
+ public static final String PARAM_INTEGER_NAME = "Integer Param";
+
+ public static final String PARAM_LONG_ID = "@param4";
+ public static final String PARAM_LONG_NAME = "Long Param";
+
+ public static final String PARAM_STRING_ID = "@param5";
+ public static final String PARAM_STRING_NAME = "String Param";
+
+ public static final String PARAM_DATE_ID = "@param6";
+ public static final String PARAM_DATE_NAME = "Date Param";
+
+ public static final String PARAM_LIST_STRING_ID = "@param7";
+ public static final String PARAM_LIST_STRING_NAME = "StringList Param";
+
+ public static final String STATE_FLOAT_ID = "@state1";
+ public static final String STATE_FLOAT_NAME = "Float State";
+
+ public static final String STATE_INTEGER_ID = "@state2";
+ public static final String STATE_INTEGER_NAME = "Float State";
+
+ public static final String STATE_STRING_ID = "@state3";
+ public static final String STATE_STRING_NAME = "Float State";
+
+ public static final String STATE_BOOLEAN_ID = "@state4";
+ public static final String STATE_BOOLEAN_NAME = "Float State";
+
+ public static final long STATE_TIME_0 = 0L;
+ public static final long STATE_TIME_10 = 10L;
+ public static final long STATE_TIME_20 = 20L;
+ public static final long STATE_TIME_30 = 30L;
+
+ public static final Double STATE_FLOAT_TIME_0 = 0.0D;
+ public static final Double STATE_FLOAT_TIME_10 = 10.0D;
+ public static final Double STATE_FLOAT_TIME_20 = 20.0D;
+ public static final Double STATE_FLOAT_TIME_30 = 30.0D;
+
+ public static final Integer STATE_INTEGER_TIME_0 = 0;
+ public static final Integer STATE_INTEGER_TIME_10 = 10;
+ public static final Integer STATE_INTEGER_TIME_20 = 20;
+ public static final Integer STATE_INTEGER_TIME_30 = 30;
+
+ public static final String STATE_STRING_TIME_0 = "empty";
+ public static final String STATE_STRING_TIME_10 = "a";
+ public static final String STATE_STRING_TIME_20 = "b";
+ public static final String STATE_STRING_TIME_30 = "c";
+
+ public static final Boolean STATE_BOOLEAN_TIME_0 = Boolean.FALSE;
+ public static final Boolean STATE_BOOLEAN_TIME_10 = Boolean.TRUE;
+ public static final Boolean STATE_BOOLEAN_TIME_20 = Boolean.FALSE;
+ public static final Boolean STATE_BOOLEAN_TIME_30 = Boolean.TRUE;
+
+ public static final String BAG_ID = "@bag01";
+ public static final String BAG_NAME = "Test Bag";
+ public static final String BAG_TYPE = "TestBag";
+
+ /**
+ * Creates an {@link Resource} with the given values and adds a {@link ParameterBag} by calling
+ * {@link #createParameterBag(String, String, String)}
+ *
+ * @param id
+ * the id of the {@link Resource}
+ * @param name
+ * the name of the {@link Resource}
+ * @param type
+ * the type of the {@link Resource}
+ *
+ * @return the newly created {@link Resource}
+ */
+ public static Resource createResource(String id, String name, String type) {
+ Resource resource = new Resource(id, name, type);
+ ParameterBag bag = createParameterBag(BAG_ID, BAG_NAME, BAG_TYPE);
+ resource.addParameterBag(bag);
+ addTimedStates(resource);
+
+ return resource;
+ }
+
+ /**
+ * Creates {@link StrolchTimedState} instances and adds them to the {@link Resource}
+ *
+ * @param resource
+ * the resource to which to addd the newly created {@link StrolchTimedState}
+ */
+ public static void addTimedStates(Resource resource) {
+
+ // float state
+ FloatTimedState floatTimedState = new FloatTimedState(STATE_FLOAT_ID, STATE_FLOAT_NAME);
+ floatTimedState.applyChange(new ValueChange<>(STATE_TIME_0, new FloatValue(STATE_FLOAT_TIME_0)));
+ FloatValue floatValueChange = new FloatValue(STATE_FLOAT_TIME_10);
+ floatTimedState.applyChange(new ValueChange<>(STATE_TIME_10, floatValueChange));
+ floatTimedState.applyChange(new ValueChange<>(STATE_TIME_20, floatValueChange));
+ floatTimedState.applyChange(new ValueChange<>(STATE_TIME_30, floatValueChange));
+ resource.addTimedState(floatTimedState);
+
+ // integer state
+ IntegerTimedState integerTimedState = new IntegerTimedState(STATE_INTEGER_ID, STATE_INTEGER_NAME);
+ integerTimedState.applyChange(new ValueChange<>(STATE_TIME_0, new IntegerValue(STATE_INTEGER_TIME_0)));
+ IntegerValue integerValueChange = new IntegerValue(STATE_INTEGER_TIME_10);
+ integerTimedState.applyChange(new ValueChange<>(STATE_TIME_10, integerValueChange));
+ integerTimedState.applyChange(new ValueChange<>(STATE_TIME_20, integerValueChange));
+ integerTimedState.applyChange(new ValueChange<>(STATE_TIME_30, integerValueChange));
+ resource.addTimedState(integerTimedState);
+
+ // boolean state
+ BooleanTimedState booleanTimedState = new BooleanTimedState(STATE_BOOLEAN_ID, STATE_BOOLEAN_NAME);
+ booleanTimedState.applyChange(new ValueChange<>(STATE_TIME_0, new BooleanValue(STATE_BOOLEAN_TIME_0)));
+ BooleanValue booleanValueChange = new BooleanValue(STATE_BOOLEAN_TIME_10);
+ booleanTimedState.applyChange(new ValueChange<>(STATE_TIME_10, booleanValueChange));
+ booleanValueChange = booleanValueChange.getInverse();
+ booleanTimedState.applyChange(new ValueChange<>(STATE_TIME_20, booleanValueChange));
+ booleanValueChange = booleanValueChange.getInverse();
+ booleanTimedState.applyChange(new ValueChange<>(STATE_TIME_30, booleanValueChange));
+ resource.addTimedState(booleanTimedState);
+
+ // string state
+ StringSetTimedState stringTimedState = new StringSetTimedState(STATE_STRING_ID, STATE_STRING_NAME);
+ StringSetValue change = new StringSetValue(asSet(STATE_STRING_TIME_0));
+ stringTimedState.applyChange(new ValueChange<>(STATE_TIME_0, change));
+ change = change.getInverse();
+ change.add(asSet(STATE_STRING_TIME_10));
+ stringTimedState.applyChange(new ValueChange<>(STATE_TIME_10, change));
+ removeInverted(change.getValue());
+ change = change.getInverse();
+ change.add(asSet(STATE_STRING_TIME_20));
+ stringTimedState.applyChange(new ValueChange<>(STATE_TIME_20, change));
+ removeInverted(change.getValue());
+ change = change.getInverse();
+ change.add(asSet(STATE_STRING_TIME_30));
+ stringTimedState.applyChange(new ValueChange<>(STATE_TIME_30, change));
+ resource.addTimedState(stringTimedState);
+ }
+
+ private static Set asSet(String value) {
+ HashSet hashSet = new HashSet<>();
+ hashSet.add(new AString(value));
+ return hashSet;
+ }
+
+ private static void removeInverted(Set set) {
+ for (Iterator iter = set.iterator(); iter.hasNext();) {
+ AString aString = iter.next();
+ if (aString.isInverse()) {
+ iter.remove();
+ }
+ }
+ }
+
+ /**
+ * Creates a list of {@link Resource Resources} with the given values and adds a {@link ParameterBag} by calling
+ * {@link #createParameterBag(String, String, String)}
+ *
+ * @param idStart
+ * id range start
+ * @param count
+ * the number of elements to create
+ * @param idPrefix
+ * the prefix to generate IDs for the {@link Resource Resources}
+ * @param name
+ * the name of the {@link Resource}
+ * @param type
+ * the type of the {@link Resource}
+ *
+ * @return the list of newly created {@link Resource Resources}
+ */
+ public static List createResources(int idStart, int count, String idPrefix, String name, String type) {
+ List resources = new ArrayList<>();
+ for (int i = 0; i < count; i++) {
+ String id = StringHelper.normalizeLength(String.valueOf((i + idStart)), 8, true, '0');
+ resources.add(createResource(idPrefix + id, name + " " + i, type));
+ }
+ return resources;
+ }
+
+ /**
+ * Creates an {@link Order} with the given values and adds a {@link ParameterBag} by calling
+ * {@link #createParameterBag(String, String, String)}
+ *
+ * @param id
+ * the id of the {@link Order}
+ * @param name
+ * the name of the {@link Order}
+ * @param type
+ * the type of the {@link Order}
+ *
+ * @return the newly created {@link Order}
+ */
+ public static Order createOrder(String id, String name, String type) {
+ return createOrder(id, name, type, new Date(), State.CREATED);
+ }
+
+ /**
+ * Creates an {@link Order} with the given values and adds a {@link ParameterBag} by calling
+ * {@link #createParameterBag(String, String, String)}
+ *
+ * @param id
+ * the id of the {@link Order}
+ * @param name
+ * the name of the {@link Order}
+ * @param type
+ * the type of the {@link Order}
+ * @param date
+ * the date of the {@link Order}
+ * @param state
+ * the {@link State} of the {@link Order}
+ *
+ * @return the newly created {@link Order}
+ */
+ public static Order createOrder(String id, String name, String type, Date date, State state) {
+
+ Order order = new Order(id, name, type, date, state);
+ ParameterBag bag = createParameterBag(BAG_ID, BAG_NAME, BAG_TYPE);
+ order.addParameterBag(bag);
+
+ return order;
+ }
+
+ /**
+ * Creates a list of {@link Order Orders} with the given values and adds a {@link ParameterBag} by calling
+ * {@link #createParameterBag(String, String, String)}
+ *
+ * @param idStart
+ * id range start
+ * @param count
+ * the number of elements to create
+ * @param idPrefix
+ * the prefix to generate IDs for the {@link Order Orders}
+ * @param name
+ * the name of the {@link Order}
+ * @param type
+ * the type of the {@link Order}
+ *
+ * @return the list of newly created {@link Order Orders}
+ */
+ public static List createOrders(int idStart, int count, String idPrefix, String name, String type) {
+ List orders = new ArrayList<>();
+ for (int i = 0; i < count; i++) {
+ String id = StringHelper.normalizeLength(String.valueOf((i + idStart)), 8, true, '0');
+ orders.add(createOrder(idPrefix + id, name + " " + i, type));
+ }
+ return orders;
+ }
+
+ /**
+ * Creates a {@link ParameterBag} with the given values and calls {@link #addAllParameters(ParameterBag)} to add
+ * {@link Parameter}s
+ *
+ * @param id
+ * the id of the {@link ParameterBag}
+ * @param name
+ * the name of the {@link ParameterBag}
+ * @param type
+ * the type of the {@link ParameterBag}
+ *
+ * @return the newly created {@link ParameterBag}
+ */
+ public static ParameterBag createParameterBag(String id, String name, String type) {
+
+ ParameterBag bag = new ParameterBag(id, name, type);
+ addAllParameters(bag);
+ return bag;
+ }
+
+ /**
+ * Adds the following {@link Parameter}s to the given {@link ParameterBag}:
+ *
+ * - BooleanParameter - true
+ * - FloatParameter - 44.3
+ * - IntegerParameter - 77
+ * - LongParameter - 4453234566L
+ * - StringParameter - "Strolch"
+ * - DateParameter - 1354295525628L
+ * - StringListParameter - Hello, World
+ *
+ *
+ * @param bag
+ */
+ public static void addAllParameters(ParameterBag bag) {
+
+ BooleanParameter boolParam = new BooleanParameter(PARAM_BOOLEAN_ID, PARAM_BOOLEAN_NAME, true);
+ boolParam.setIndex(1);
+ bag.addParameter(boolParam);
+
+ FloatParameter floatParam = new FloatParameter(PARAM_FLOAT_ID, PARAM_FLOAT_NAME, 44.3);
+ floatParam.setIndex(2);
+ bag.addParameter(floatParam);
+
+ IntegerParameter integerParam = new IntegerParameter(PARAM_INTEGER_ID, PARAM_INTEGER_NAME, 77);
+ integerParam.setIndex(3);
+ bag.addParameter(integerParam);
+
+ LongParameter longParam = new LongParameter(PARAM_LONG_ID, PARAM_LONG_NAME, 4453234566L);
+ longParam.setIndex(4);
+ bag.addParameter(longParam);
+
+ StringParameter stringParam = new StringParameter(PARAM_STRING_ID, PARAM_STRING_NAME, "Strolch");
+ stringParam.setIndex(5);
+ bag.addParameter(stringParam);
+
+ DateParameter dateParam = new DateParameter(PARAM_DATE_ID, PARAM_DATE_NAME, new Date(1354295525628L));
+ dateParam.setIndex(6);
+ bag.addParameter(dateParam);
+
+ ArrayList stringList = new ArrayList();
+ stringList.add("Hello");
+ stringList.add("World");
+ StringListParameter stringListP = new StringListParameter(PARAM_LIST_STRING_ID, PARAM_LIST_STRING_NAME,
+ stringList);
+ stringListP.setIndex(7);
+ bag.addParameter(stringListP);
+ }
+
+ private static String randomValue(Random rand, String[] values) {
+ return values[rand.nextInt(values.length)];
+ }
+
+ public static Audit randomAudit() {
+
+ Random rand = new Random(234234L);
+ String[] usernames = new String[] { "bob", "alice", "jenny" };
+ String[] firstnames = new String[] { "Bob", "Alice", "Jenny" };
+ String[] lastnames = new String[] { "Richards", "Kennedy", "Davids" };
+ String[] types = new String[] { Tags.RESOURCE, Tags.ORDER, Tags.AUDIT };
+ String[] actions = new String[] { "AddResourceService", "UpdateResourceService", "RemoveResourceService",
+ "AddOrderService", "UpdateOrderService", "RemoveOrderService" };
+
+ Audit audit = new Audit();
+ audit.setId(StringHelper.getUniqueIdLong());
+ audit.setUsername(randomValue(rand, usernames));
+ audit.setFirstname(randomValue(rand, firstnames));
+ audit.setLastname(randomValue(rand, lastnames));
+ audit.setDate(new Date(rand.nextInt(5000)));
+ audit.setElementType(randomValue(rand, types));
+ audit.setElementAccessed(StringHelper.getUniqueId());
+ audit.setNewVersion(new Date(rand.nextInt(5000)));
+ audit.setAction(randomValue(rand, actions));
+ audit.setAccessType(AccessType.values()[rand.nextInt(AccessType.values().length)]);
+
+ return audit;
+ }
+}
diff --git a/li.strolch.model/src/main/java/li/strolch/model/ModelStatistics.java b/li.strolch.model/src/main/java/li/strolch/model/ModelStatistics.java
new file mode 100644
index 000000000..32315e47e
--- /dev/null
+++ b/li.strolch.model/src/main/java/li/strolch/model/ModelStatistics.java
@@ -0,0 +1,49 @@
+package li.strolch.model;
+
+import static ch.eitchnet.utils.helper.StringHelper.NULL;
+
+import java.util.Date;
+
+import ch.eitchnet.utils.helper.StringHelper;
+import ch.eitchnet.utils.iso8601.ISO8601FormatFactory;
+
+public class ModelStatistics {
+
+ public Date startTime;
+ public long durationNanos;
+ public long nrOfResources;
+ public long nrOfOrders;
+
+ /**
+ * @return the nrOfOrders
+ */
+ public long getNrOfOrders() {
+ return this.nrOfOrders;
+ }
+
+ /**
+ * @return the nrOfResources
+ */
+ public long getNrOfResources() {
+ return this.nrOfResources;
+ }
+
+ public long getNrOfElements() {
+ return this.nrOfOrders + this.nrOfResources;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append(getClass().getSimpleName() + " [startTime=");
+ builder.append(this.startTime == null ? NULL : ISO8601FormatFactory.getInstance().formatDate(this.startTime));
+ builder.append(", durationNanos=");
+ builder.append(StringHelper.formatNanoDuration(this.durationNanos));
+ builder.append(", nrOfResources=");
+ builder.append(this.nrOfResources);
+ builder.append(", nrOfOrders=");
+ builder.append(this.nrOfOrders);
+ builder.append("]");
+ return builder.toString();
+ }
+}
\ No newline at end of file
diff --git a/li.strolch.model/src/main/java/li/strolch/model/Order.java b/li.strolch.model/src/main/java/li/strolch/model/Order.java
new file mode 100644
index 000000000..3b8fb11eb
--- /dev/null
+++ b/li.strolch.model/src/main/java/li/strolch/model/Order.java
@@ -0,0 +1,208 @@
+/*
+ * 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.model;
+
+import java.util.Date;
+
+import li.strolch.model.Locator.LocatorBuilder;
+import li.strolch.model.visitor.StrolchRootElementVisitor;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import ch.eitchnet.utils.helper.StringHelper;
+import ch.eitchnet.utils.iso8601.ISO8601FormatFactory;
+
+/**
+ * The Order is an object used in the EDF to transfer data from one range to another. Orders are not to be thought of as
+ * Resources. Resources are supposed to be thought of as things i.e. a table, a machine and so forth, where a order is
+ * to be thought of as an object for doing something.
+ *
+ * In this sense, orders do not need to be verified, so all verifier chracteristics are disabled and the
+ * getVerifier()-method will return the null reference
+ *
+ * @author Robert von Burg
+ */
+public class Order extends GroupedParameterizedElement implements StrolchRootElement {
+
+ private static final long serialVersionUID = 0L;
+
+ private Date date;
+ private State state;
+
+ /**
+ * Empty constructor
+ */
+ public Order() {
+ //
+ }
+
+ /**
+ * Default Constructor
+ *
+ * @param id
+ * @param name
+ * @param type
+ */
+ public Order(String id, String name, String type) {
+ super(id, name, type);
+
+ setState(State.CREATED);
+ setDate(new Date());
+ }
+
+ /**
+ * Extended Constructor for date and {@link State}
+ *
+ * @param id
+ * @param name
+ * @param type
+ * @param date
+ * @param state
+ */
+ public Order(String id, String name, String type, Date date, State state) {
+ super(id, name, type);
+
+ setState(state);
+ setDate(date);
+ }
+
+ /**
+ * DOM Constructor
+ *
+ * @param element
+ */
+ public Order(Element element) {
+ super.fromDom(element);
+
+ String date = element.getAttribute(Tags.DATE);
+ String state = element.getAttribute(Tags.STATE);
+
+ if (StringHelper.isEmpty(date)) {
+ setDate(ISO8601FormatFactory.getInstance().getDateFormat().parse("-")); //$NON-NLS-1$
+ } else {
+ setDate(ISO8601FormatFactory.getInstance().getDateFormat().parse(date));
+ }
+
+ if (state == null || state.isEmpty()) {
+ setState(State.CREATED);
+ } else {
+ setState(State.valueOf(state));
+ }
+ }
+
+ /**
+ * @return the date
+ */
+ public Date getDate() {
+ return this.date;
+ }
+
+ /**
+ * @param date
+ * the date to set
+ */
+ public void setDate(Date date) {
+ this.date = date;
+ }
+
+ /**
+ * @return the state
+ */
+ public State getState() {
+ return this.state;
+ }
+
+ /**
+ * @param state
+ * the state to set
+ */
+ public void setState(State state) {
+ this.state = state;
+ }
+
+ @Override
+ public Element toDom(Document doc) {
+
+ Element orderElement = doc.createElement(Tags.ORDER);
+ fillElement(orderElement);
+
+ orderElement.setAttribute(Tags.DATE, ISO8601FormatFactory.getInstance().formatDate(this.date));
+ orderElement.setAttribute(Tags.STATE, this.state.toString());
+
+ return orderElement;
+ }
+
+ @Override
+ public Order getClone() {
+ Order clone = new Order();
+
+ super.fillClone(clone);
+
+ clone.setDate(this.date);
+ clone.setState(this.state);
+
+ return clone;
+ }
+
+ @Override
+ protected void fillLocator(LocatorBuilder lb) {
+ lb.append(Tags.ORDER).append(getType()).append(getId());
+ }
+
+ @Override
+ public Locator getLocator() {
+ LocatorBuilder lb = new LocatorBuilder();
+ fillLocator(lb);
+ return lb.build();
+ }
+
+ @Override
+ public StrolchElement getParent() {
+ return null;
+ }
+
+ @Override
+ public Order getRootElement() {
+ return this;
+ }
+
+ @Override
+ public T accept(StrolchRootElementVisitor visitor) {
+ return visitor.visitOrder(this);
+ }
+
+ @SuppressWarnings("nls")
+ @Override
+ public String toString() {
+
+ StringBuilder builder = new StringBuilder();
+
+ builder.append("Order [id=");
+ builder.append(this.id);
+ builder.append(", name=");
+ builder.append(this.name);
+ builder.append(", type=");
+ builder.append(this.type);
+ builder.append(", state=");
+ builder.append(this.state);
+ builder.append(", date=");
+ builder.append(ISO8601FormatFactory.getInstance().formatDate(this.date));
+ builder.append("]");
+
+ return builder.toString();
+ }
+}
diff --git a/li.strolch.model/src/main/java/li/strolch/model/OrderVisitor.java b/li.strolch.model/src/main/java/li/strolch/model/OrderVisitor.java
new file mode 100644
index 000000000..efcaf0684
--- /dev/null
+++ b/li.strolch.model/src/main/java/li/strolch/model/OrderVisitor.java
@@ -0,0 +1,27 @@
+/*
+ * 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.model;
+
+import li.strolch.model.visitor.StrolchElementVisitor;
+
+/**
+ * @author Robert von Burg
+ */
+public interface OrderVisitor extends StrolchElementVisitor {
+
+ @Override
+ public U visit(Order element);
+}
diff --git a/li.strolch.model/src/main/java/li/strolch/model/ParameterBag.java b/li.strolch.model/src/main/java/li/strolch/model/ParameterBag.java
new file mode 100644
index 000000000..2baff9fda
--- /dev/null
+++ b/li.strolch.model/src/main/java/li/strolch/model/ParameterBag.java
@@ -0,0 +1,80 @@
+/*
+ * 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.model;
+
+import li.strolch.model.Locator.LocatorBuilder;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+/**
+ * @author Robert von Burg
+ */
+public class ParameterBag extends ParameterizedElement {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Empty Constructor
+ */
+ public ParameterBag() {
+ //
+ }
+
+ /**
+ * Default constructor
+ *
+ * @param id
+ * @param name
+ * @param type
+ */
+ public ParameterBag(String id, String name, String type) {
+ super(id, name, type);
+ }
+
+ /**
+ * DOM Constructor
+ *
+ * @param bagElement
+ */
+ public ParameterBag(Element bagElement) {
+ super.fromDom(bagElement);
+ }
+
+ @Override
+ public ParameterBag getClone() {
+ ParameterBag clone = new ParameterBag();
+ super.fillClone(clone);
+ return clone;
+ }
+
+ @Override
+ public void fillLocator(LocatorBuilder lb) {
+ this.parent.fillLocator(lb);
+ lb.append(Tags.BAG);
+ lb.append(this.id);
+ }
+
+ @Override
+ public Element toDom(Document doc) {
+
+ Element element = doc.createElement(Tags.PARAMETER_BAG);
+
+ fillElement(element);
+
+ return element;
+ }
+}
diff --git a/li.strolch.model/src/main/java/li/strolch/model/ParameterizedElement.java b/li.strolch.model/src/main/java/li/strolch/model/ParameterizedElement.java
new file mode 100644
index 000000000..ac6270fbe
--- /dev/null
+++ b/li.strolch.model/src/main/java/li/strolch/model/ParameterizedElement.java
@@ -0,0 +1,308 @@
+/*
+ * 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.model;
+
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import li.strolch.exception.StrolchException;
+import li.strolch.model.Locator.LocatorBuilder;
+import li.strolch.model.parameter.BooleanParameter;
+import li.strolch.model.parameter.DateParameter;
+import li.strolch.model.parameter.FloatParameter;
+import li.strolch.model.parameter.IntegerParameter;
+import li.strolch.model.parameter.LongParameter;
+import li.strolch.model.parameter.Parameter;
+import li.strolch.model.parameter.StringListParameter;
+import li.strolch.model.parameter.StringParameter;
+
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+import ch.eitchnet.utils.dbc.DBC;
+import ch.eitchnet.utils.helper.StringHelper;
+
+/**
+ * @author Robert von Burg
+ */
+public abstract class ParameterizedElement extends AbstractStrolchElement {
+
+ private static final long serialVersionUID = 0L;
+
+ protected GroupedParameterizedElement parent;
+ protected Map> parameterMap;
+ protected String type;
+
+ /**
+ * Empty Constructor
+ */
+ protected ParameterizedElement() {
+ //
+ }
+
+ /**
+ * Default Constructor
+ *
+ * @param id
+ * @param name
+ * @param type
+ */
+ public ParameterizedElement(String id, String name, String type) {
+ setId(id);
+ setName(name);
+ setType(type);
+ }
+
+ @Override
+ public String getType() {
+ return this.type;
+ }
+
+ /**
+ * Sets the type of this {@link ParameterizedElement}
+ *
+ * @param type
+ * the type to set
+ */
+ public void setType(String type) {
+ if (StringHelper.isEmpty(type)) {
+ String msg = "Type may not be empty on element {0}"; //$NON-NLS-1$
+ msg = MessageFormat.format(msg, getLocator());
+ throw new StrolchException(msg);
+ }
+
+ this.type = type;
+ }
+
+ /**
+ * Returns the {@link Parameter} with the given id, or null if it does not exist
+ *
+ * @param key
+ * the id of the parameter to return
+ *
+ * @return the {@link Parameter} with the given id, or null if it does not exist
+ */
+ @SuppressWarnings("unchecked")
+ public T getParameter(String key) {
+ if (this.parameterMap == null) {
+ return null;
+ }
+ return (T) this.parameterMap.get(key);
+ }
+
+ /**
+ * Adds the given {@link Parameter} to the {@link ParameterizedElement}
+ *
+ * @param parameter
+ * the {@link Parameter} to add
+ */
+ public void addParameter(Parameter> parameter) {
+ if (this.parameterMap == null) {
+ this.parameterMap = new HashMap>();
+ }
+
+ if (this.parameterMap.containsKey(parameter.getId())) {
+ String msg = "A Parameter already exists with id {0} on {1}";
+ throw new StrolchException(MessageFormat.format(msg, parameter.getId(), getLocator()));
+ }
+ this.parameterMap.put(parameter.getId(), parameter);
+ parameter.setParent(this);
+ }
+
+ /**
+ * Removes the {@link Parameter} with the given key
+ *
+ * @param key
+ * the key of the {@link Parameter} to remove
+ *
+ * @return the removed {@link Parameter}, or null if it does not exist
+ */
+ @SuppressWarnings("unchecked")
+ public Parameter removeParameter(String key) {
+ if (this.parameterMap == null) {
+ return null;
+ }
+ return (Parameter) this.parameterMap.remove(key);
+ }
+
+ /**
+ * Returns a list of all the {@link Parameter}s in this {@link ParameterizedElement}
+ *
+ * @return a list of all the {@link Parameter}s in this {@link ParameterizedElement}
+ */
+ public List> getParameters() {
+ if (this.parameterMap == null) {
+ return Collections.emptyList();
+ }
+ return new ArrayList>(this.parameterMap.values());
+ }
+
+ /**
+ * Returns true, if the this {@link ParameterizedElement} has any {@link Parameter Parameters}, false otherwise
+ *
+ * @return true, if the this {@link ParameterizedElement} has any {@link Parameter Parameters}, false otherwise
+ */
+ public boolean hasParameters() {
+ return this.parameterMap != null && !this.parameterMap.isEmpty();
+ }
+
+ /**
+ * Returns true, if the {@link Parameter} exists with the given key, false otherwise
+ *
+ * @param key
+ * the key of the {@link Parameter} to check for
+ *
+ * @return true, if the {@link Parameter} exists with the given key, false otherwise
+ */
+ public boolean hasParameter(String key) {
+ if (this.parameterMap == null) {
+ return false;
+ }
+ return this.parameterMap.containsKey(key);
+ }
+
+ /**
+ * Returns a {@link Set} of all the {@link Parameter} keys in this {@link ParameterizedElement}
+ *
+ * @return a {@link Set} of all the {@link Parameter} keys in this {@link ParameterizedElement}
+ */
+ public Set getParameterKeySet() {
+ if (this.parameterMap == null) {
+ return Collections.emptySet();
+ }
+ return new HashSet(this.parameterMap.keySet());
+ }
+
+ @Override
+ public abstract void fillLocator(LocatorBuilder lb);
+
+ @Override
+ public Locator getLocator() {
+ LocatorBuilder lb = new LocatorBuilder();
+ fillLocator(lb);
+ return lb.build();
+ }
+
+ @Override
+ protected void fromDom(Element element) {
+ super.fromDom(element);
+
+ String type = element.getAttribute(Tags.TYPE);
+ setType(type);
+
+ // add all the parameters
+ NodeList parameterElements = element.getElementsByTagName(Tags.PARAMETER);
+ for (int i = 0; i < parameterElements.getLength(); i++) {
+ Element paramElement = (Element) parameterElements.item(i);
+ String paramtype = paramElement.getAttribute(Tags.TYPE);
+
+ DBC.PRE.assertNotEmpty("Type must be set on Parameter for bag with id " + this.id, paramtype);
+
+ if (paramtype.equals(StringParameter.TYPE)) {
+ StringParameter param = new StringParameter(paramElement);
+ addParameter(param);
+ } else if (paramtype.equals(IntegerParameter.TYPE)) {
+ IntegerParameter param = new IntegerParameter(paramElement);
+ addParameter(param);
+ } else if (paramtype.equals(FloatParameter.TYPE)) {
+ FloatParameter param = new FloatParameter(paramElement);
+ addParameter(param);
+ } else if (paramtype.equals(LongParameter.TYPE)) {
+ LongParameter param = new LongParameter(paramElement);
+ addParameter(param);
+ } else if (paramtype.equals(DateParameter.TYPE)) {
+ DateParameter param = new DateParameter(paramElement);
+ addParameter(param);
+ } else if (paramtype.equals(BooleanParameter.TYPE)) {
+ BooleanParameter param = new BooleanParameter(paramElement);
+ addParameter(param);
+ } else if (paramtype.equals(StringListParameter.TYPE)) {
+ StringListParameter param = new StringListParameter(paramElement);
+ addParameter(param);
+ } else {
+ String msg = "What kind of parameter is this: {0}"; //$NON-NLS-1$
+ msg = MessageFormat.format(msg, paramtype);
+ throw new StrolchException(msg);
+ }
+ }
+ }
+
+ @Override
+ protected void fillElement(Element element) {
+ super.fillElement(element);
+
+ if (this.parameterMap != null) {
+ for (Parameter> parameter : this.parameterMap.values()) {
+ element.appendChild(parameter.toDom(element.getOwnerDocument()));
+ }
+ }
+ }
+
+ @Override
+ protected void fillClone(StrolchElement clone) {
+ super.fillClone(clone);
+ ParameterizedElement peClone = (ParameterizedElement) clone;
+ peClone.setType(this.type);
+ if (this.parameterMap != null) {
+ for (Parameter> param : this.parameterMap.values()) {
+ peClone.addParameter(param.getClone());
+ }
+ }
+ }
+
+ @Override
+ public GroupedParameterizedElement getParent() {
+ return this.parent;
+ }
+
+ /**
+ * Set the parent for this {@link ParameterizedElement}
+ *
+ * @param parent
+ * the parent to set
+ */
+ public void setParent(GroupedParameterizedElement parent) {
+ this.parent = parent;
+ }
+
+ @Override
+ public StrolchRootElement getRootElement() {
+ return this.parent.getRootElement();
+ }
+
+ @SuppressWarnings("nls")
+ @Override
+ public String toString() {
+
+ StringBuilder builder = new StringBuilder();
+
+ builder.append("ParameterizedElement [id=");
+ builder.append(this.id);
+ builder.append(", name=");
+ builder.append(this.name);
+ builder.append(", type=");
+ builder.append(this.type);
+ builder.append("]");
+
+ return builder.toString();
+ }
+}
diff --git a/li.strolch.model/src/main/java/li/strolch/model/Resource.java b/li.strolch.model/src/main/java/li/strolch/model/Resource.java
new file mode 100644
index 000000000..1a535a4b6
--- /dev/null
+++ b/li.strolch.model/src/main/java/li/strolch/model/Resource.java
@@ -0,0 +1,221 @@
+/*
+ * 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.model;
+
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import li.strolch.exception.StrolchException;
+import li.strolch.model.Locator.LocatorBuilder;
+import li.strolch.model.timedstate.BooleanTimedState;
+import li.strolch.model.timedstate.FloatTimedState;
+import li.strolch.model.timedstate.IntegerTimedState;
+import li.strolch.model.timedstate.StringSetTimedState;
+import li.strolch.model.timedstate.StrolchTimedState;
+import li.strolch.model.timevalue.IValue;
+import li.strolch.model.visitor.StrolchRootElementVisitor;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+import ch.eitchnet.utils.dbc.DBC;
+
+/**
+ * @author Robert von Burg
+ */
+public class Resource extends GroupedParameterizedElement implements StrolchRootElement {
+
+ private static final long serialVersionUID = 0L;
+
+ private Map>> timedStateMap;
+
+ /**
+ * Empty constructor
+ */
+ public Resource() {
+ //
+ }
+
+ /**
+ * Default constructor
+ *
+ * @param id
+ * @param name
+ * @param type
+ */
+ public Resource(String id, String name, String type) {
+ super(id, name, type);
+ }
+
+ /**
+ * DOM Constructor
+ *
+ * @param element
+ */
+ public Resource(Element element) {
+ super.fromDom(element);
+
+ NodeList timedStateElems = element.getElementsByTagName(Tags.TIMED_STATE);
+ for (int i = 0; i < timedStateElems.getLength(); i++) {
+ Element timedStateElem = (Element) timedStateElems.item(i);
+ String typeS = timedStateElem.getAttribute(Tags.TYPE);
+
+ DBC.PRE.assertNotEmpty("Type must be set on TimedState for resource with id " + this.id, typeS);
+
+ if (typeS.equals(FloatTimedState.TYPE)) {
+ FloatTimedState timedState = new FloatTimedState(timedStateElem);
+ addTimedState(timedState);
+ } else if (typeS.equals(IntegerTimedState.TYPE)) {
+ IntegerTimedState timedState = new IntegerTimedState(timedStateElem);
+ addTimedState(timedState);
+ } else if (typeS.equals(BooleanTimedState.TYPE)) {
+ BooleanTimedState timedState = new BooleanTimedState(timedStateElem);
+ addTimedState(timedState);
+ } else if (typeS.equals(StringSetTimedState.TYPE)) {
+ StringSetTimedState timedState = new StringSetTimedState(timedStateElem);
+ addTimedState(timedState);
+ } else {
+ String msg = "What kind of TimedState is this: {0}"; //$NON-NLS-1$
+ msg = MessageFormat.format(msg, typeS);
+ throw new StrolchException(msg);
+ }
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public void addTimedState(StrolchTimedState> strolchTimedState) {
+ if (this.timedStateMap == null) {
+ this.timedStateMap = new HashMap<>();
+ }
+
+ this.timedStateMap.put(strolchTimedState.getId(), (StrolchTimedState>) strolchTimedState);
+ strolchTimedState.setParent(this);
+ }
+
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ public T getTimedState(String id) {
+ if (this.timedStateMap == null) {
+ return null;
+ }
+ return (T) this.timedStateMap.get(id);
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public T removeTimedState(String id) {
+ if (this.timedStateMap == null) {
+ return null;
+ }
+ return (T) this.timedStateMap.remove(id);
+ }
+
+ public Set getTimedStateKeySet() {
+ if (this.timedStateMap == null) {
+ return Collections.emptySet();
+ }
+ return new HashSet<>(this.timedStateMap.keySet());
+ }
+
+ public List>> getTimedStates() {
+ if (this.timedStateMap == null) {
+ return Collections.emptyList();
+ }
+ return new ArrayList<>(this.timedStateMap.values());
+ }
+
+ public boolean hasTimedStates() {
+ return this.timedStateMap != null && !this.timedStateMap.isEmpty();
+ }
+
+ public boolean hasTimedState(String id) {
+ return this.timedStateMap != null && this.timedStateMap.containsKey(id);
+ }
+
+ @Override
+ public Element toDom(Document doc) {
+
+ Element element = doc.createElement(Tags.RESOURCE);
+ fillElement(element);
+
+ if (this.timedStateMap != null) {
+ for (StrolchTimedState> state : this.timedStateMap.values()) {
+ Element timedStateElem = state.toDom(element.getOwnerDocument());
+ element.appendChild(timedStateElem);
+ }
+ }
+
+ return element;
+ }
+
+ @Override
+ public Resource getClone() {
+ Resource clone = new Resource();
+
+ super.fillClone(clone);
+
+ return clone;
+ }
+
+ @Override
+ public void fillLocator(LocatorBuilder lb) {
+ lb.append(Tags.RESOURCE).append(getType()).append(getId());
+ }
+
+ @Override
+ public Locator getLocator() {
+ LocatorBuilder lb = new LocatorBuilder();
+ fillLocator(lb);
+ return lb.build();
+ }
+
+ @Override
+ public StrolchElement getParent() {
+ return null;
+ }
+
+ @Override
+ public Resource getRootElement() {
+ return this;
+ }
+
+ @Override
+ public T accept(StrolchRootElementVisitor visitor) {
+ return visitor.visitResource(this);
+ }
+
+ @SuppressWarnings("nls")
+ @Override
+ public String toString() {
+
+ StringBuilder builder = new StringBuilder();
+
+ builder.append("Resource [id=");
+ builder.append(this.id);
+ builder.append(", name=");
+ builder.append(this.name);
+ builder.append(", type=");
+ builder.append(this.type);
+ builder.append("]");
+
+ return builder.toString();
+ }
+}
diff --git a/li.strolch.model/src/main/java/li/strolch/model/ResourceVisitor.java b/li.strolch.model/src/main/java/li/strolch/model/ResourceVisitor.java
new file mode 100644
index 000000000..67c014fc1
--- /dev/null
+++ b/li.strolch.model/src/main/java/li/strolch/model/ResourceVisitor.java
@@ -0,0 +1,28 @@
+/*
+ * 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.model;
+
+import li.strolch.model.visitor.StrolchElementVisitor;
+
+/**
+ * @author Robert von Burg
+ * @param
+ */
+public interface ResourceVisitor extends StrolchElementVisitor {
+
+ @Override
+ public U visit(Resource element);
+}
diff --git a/li.strolch.model/src/main/java/li/strolch/model/State.java b/li.strolch.model/src/main/java/li/strolch/model/State.java
new file mode 100644
index 000000000..9bf386425
--- /dev/null
+++ b/li.strolch.model/src/main/java/li/strolch/model/State.java
@@ -0,0 +1,43 @@
+/*
+ * 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.model;
+
+/**
+ * @author Robert von Burg
+ */
+public enum State {
+
+ CREATED("Created"), //$NON-NLS-1$
+ OPEN("Open"), //$NON-NLS-1$
+ EXECUTION("Execution"), //$NON-NLS-1$
+ CLOSED("Closed"); //$NON-NLS-1$
+
+ private String state;
+
+ /**
+ * @param state
+ */
+ private State(String state) {
+ this.state = state;
+ }
+
+ /**
+ * @return
+ */
+ public String getStateName() {
+ return this.state;
+ }
+}
diff --git a/li.strolch.model/src/main/java/li/strolch/model/StrolchElement.java b/li.strolch.model/src/main/java/li/strolch/model/StrolchElement.java
new file mode 100644
index 000000000..1fb148ffc
--- /dev/null
+++ b/li.strolch.model/src/main/java/li/strolch/model/StrolchElement.java
@@ -0,0 +1,116 @@
+/*
+ * 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.model;
+
+import java.io.Serializable;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+/**
+ * @author Robert von Burg
+ */
+public interface StrolchElement extends Serializable, Comparable {
+
+ /**
+ * Return the {@link Locator} for this element
+ *
+ * @return the {@link Locator} for this element
+ */
+ public Locator getLocator();
+
+ /**
+ * Set the semi unique id of this {@link StrolchElement}. This value should be unique under all concrete
+ * implementations of this interface
+ *
+ * @param id
+ */
+ public void setId(String id);
+
+ /**
+ * Returns the semi unique id of this {@link StrolchElement}. This value should be unique under all concrete
+ * implementations of this interface
+ *
+ * @return
+ */
+ public String getId();
+
+ /**
+ * Set the name of this {@link StrolchElement}
+ *
+ * @param name
+ */
+ public void setName(String name);
+
+ /**
+ * Returns the name of this {@link StrolchElement}
+ *
+ * @return
+ */
+ public String getName();
+
+ /**
+ * Set the currently set long value which defines the primary key for use in RDBM-Systems
+ *
+ * @param dbid
+ */
+ public void setDbid(long dbid);
+
+ /**
+ * Returns the currently set long value which defines the primary key for use in RDBM-Systems
+ *
+ * @return
+ */
+ public long getDbid();
+
+ /**
+ * Returns an {@link Element} object which is an XML representation of this object
+ *
+ * @param doc
+ * the document to which this element is being written. The client must not append to the document, the
+ * caller will perform this as needed
+ *
+ * @return
+ */
+ public Element toDom(Document doc);
+
+ /**
+ * Returns the type of this {@link StrolchElement}
+ *
+ * @return
+ */
+ public String getType();
+
+ public StrolchElement getParent();
+
+ public StrolchRootElement getRootElement();
+
+ /**
+ * Return a clone of this {@link StrolchElement}
+ *
+ * @return
+ */
+ public StrolchElement getClone();
+
+ @Override
+ public int hashCode();
+
+ @Override
+ public boolean equals(Object obj);
+
+ @Override
+ public int compareTo(StrolchElement o);
+}
diff --git a/li.strolch.model/src/main/java/li/strolch/model/StrolchModelConstants.java b/li.strolch.model/src/main/java/li/strolch/model/StrolchModelConstants.java
new file mode 100644
index 000000000..5b9caedf2
--- /dev/null
+++ b/li.strolch.model/src/main/java/li/strolch/model/StrolchModelConstants.java
@@ -0,0 +1,33 @@
+package li.strolch.model;
+
+import li.strolch.model.parameter.Parameter;
+
+public class StrolchModelConstants {
+
+ /**
+ * The type to set on {@link StrolchRootElement StrolchRootElements} when defining a template for a type of element
+ */
+ public static final String TEMPLATE = "Template"; //$NON-NLS-1$
+
+ /**
+ * This interpretation value indicates that the value of the {@link Parameter} should be understood as a reference
+ * to a {@link Resource}
+ */
+ public static final String INTERPRETATION_RESOURCE_REF = "Resource-Ref"; //$NON-NLS-1$
+
+ /**
+ * This interpretation value indicates that the value of the {@link Parameter} should be understood as a reference
+ * to an {@link Order}
+ */
+ public static final String INTERPRETATION_ORDER_REF = "Order-Ref"; //$NON-NLS-1$
+
+ /**
+ * This interpretation value indicates that the {@link Parameter} has no defined interpretation
+ */
+ public static final String INTERPRETATION_NONE = "None"; //$NON-NLS-1$
+
+ /**
+ * This uom value indicates that the {@link Parameter} has no defined uom
+ */
+ public static final String UOM_NONE = "None"; //$NON-NLS-1$
+}
diff --git a/li.strolch.model/src/main/java/li/strolch/model/StrolchRootElement.java b/li.strolch.model/src/main/java/li/strolch/model/StrolchRootElement.java
new file mode 100644
index 000000000..7b99b045d
--- /dev/null
+++ b/li.strolch.model/src/main/java/li/strolch/model/StrolchRootElement.java
@@ -0,0 +1,29 @@
+/*
+ * 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.model;
+
+import li.strolch.model.visitor.StrolchRootElementVisitor;
+
+/**
+ * Root element for all top level {@link StrolchElement}. These are elements which have no parent, e.g. {@link Resource
+ * Resources} and {@link Order Orders}
+ *
+ * @author Robert von Burg
+ */
+public interface StrolchRootElement extends StrolchElement {
+
+ public T accept(StrolchRootElementVisitor visitor);
+}
diff --git a/li.strolch.model/src/main/java/li/strolch/model/Tags.java b/li.strolch.model/src/main/java/li/strolch/model/Tags.java
new file mode 100644
index 000000000..b4fb9d22c
--- /dev/null
+++ b/li.strolch.model/src/main/java/li/strolch/model/Tags.java
@@ -0,0 +1,60 @@
+/*
+ * 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.model;
+
+@SuppressWarnings("nls")
+public class Tags {
+
+ public static final String CDATA = "CDATA";
+ public static final String ID = "Id";
+ public static final String NAME = "Name";
+ public static final String TYPE = "Type";
+ public static final String DATE = "Date";
+ public static final String STATE = "State";
+ public static final String VALUE = "Value";
+ public static final String TIME = "Time";
+ public static final String INTERPRETATION = "Interpretation";
+ public static final String UOM = "Uom";
+ public static final String HIDDEN = "Hidden";
+ public static final String INDEX = "Index";
+ public static final String PARAMETER = "Parameter";
+ public static final String TIMED_STATE = "TimedState";
+ public static final String PARAMETERIZED_ELEMENT = "ParameterizedElement";
+ public static final String RESOURCE = "Resource";
+ public static final String ORDER = "Order";
+ public static final String PARAMETER_BAG = "ParameterBag";
+ public static final String STROLCH_MODEL = "StrolchModel";
+ public static final String INCLUDE_FILE = "IncludeFile";
+ public static final String FILE = "file";
+ public static final String BAG = "Bag";
+ public static final String AUDIT = "Audit";
+
+ public class Audit {
+ public static final String ID = Tags.ID;
+
+ public static final String USERNAME = "Username";
+ public static final String FIRSTNAME = "Firstname";
+ public static final String LASTNAME = "Lastname";
+ public static final String DATE = "Date";
+
+ public static final String ELEMENT_TYPE = "ElementType";
+ public static final String ELEMENT_ACCESSED = "ElementAccessed";
+ public static final String NEW_VERSION = "NewVersion";
+
+ public static final String ACTION = "Action";
+ public static final String ACCESS_TYPE = "AccessType";
+ }
+}
diff --git a/li.strolch.model/src/main/java/li/strolch/model/audit/AccessType.java b/li.strolch.model/src/main/java/li/strolch/model/audit/AccessType.java
new file mode 100644
index 000000000..9c26d7846
--- /dev/null
+++ b/li.strolch.model/src/main/java/li/strolch/model/audit/AccessType.java
@@ -0,0 +1,27 @@
+/*
+ * 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.model.audit;
+
+import li.strolch.model.StrolchRootElement;
+
+/**
+ * Defines the type of access performed on a {@link StrolchRootElement}
+ *
+ * @author Robert von Burg
+ */
+public enum AccessType {
+ READ, CREATE, UPDATE, DELETE;
+}
\ No newline at end of file
diff --git a/li.strolch.model/src/main/java/li/strolch/model/audit/ActionSelection.java b/li.strolch.model/src/main/java/li/strolch/model/audit/ActionSelection.java
new file mode 100644
index 000000000..6a85a9627
--- /dev/null
+++ b/li.strolch.model/src/main/java/li/strolch/model/audit/ActionSelection.java
@@ -0,0 +1,63 @@
+/*
+ * 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.model.audit;
+
+import li.strolch.model.query.StringSelection;
+import ch.eitchnet.utils.StringMatchMode;
+
+/**
+ * @author Robert von Burg
+ */
+public class ActionSelection extends AuditSelection {
+
+ private StringSelection actionSelection;
+ private AccessType[] accessTypes;
+
+ public ActionSelection(AuditQuery query) {
+ super(query);
+ }
+
+ public ActionSelection actions(StringMatchMode matchMode, String... actions) {
+ this.actionSelection = new StringSelection(matchMode, actions);
+ return this;
+ }
+
+ public ActionSelection accessTypes(AccessType... accessTypes) {
+ this.accessTypes = accessTypes;
+ return this;
+ }
+
+ public AccessType[] getAccessTypes() {
+ return this.accessTypes;
+ }
+
+ public StringSelection getActionSelection() {
+ return this.actionSelection;
+ }
+
+ public boolean isWildcardActionType() {
+ return this.accessTypes == null || this.accessTypes.length == 0;
+ }
+
+ public boolean isWildcardAction() {
+ return this.actionSelection == null || this.actionSelection.isWildCard();
+ }
+
+ @Override
+ public void accept(AuditQueryVisitor visitor) {
+ visitor.visit(this);
+ }
+}
diff --git a/li.strolch.model/src/main/java/li/strolch/model/audit/Audit.java b/li.strolch.model/src/main/java/li/strolch/model/audit/Audit.java
new file mode 100644
index 000000000..d07111fb4
--- /dev/null
+++ b/li.strolch.model/src/main/java/li/strolch/model/audit/Audit.java
@@ -0,0 +1,233 @@
+/*
+ * 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.model.audit;
+
+import java.io.Serializable;
+import java.util.Date;
+
+import li.strolch.model.StrolchRootElement;
+
+/**
+ * Used to log/audit access to {@link StrolchRootElement}
+ *
+ * @author Robert von Burg
+ */
+public class Audit implements Comparable, Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ private Long id;
+ private String username;
+ private String firstname;
+ private String lastname;
+ private Date date;
+
+ private String elementType;
+ private String elementAccessed;
+ private Date newVersion;
+
+ private String action;
+ private AccessType accessType;
+
+ /**
+ * @return the id
+ */
+ public Long getId() {
+ return this.id;
+ }
+
+ /**
+ * @param id
+ * the id to set
+ */
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ /**
+ * @return the username
+ */
+ public String getUsername() {
+ return this.username;
+ }
+
+ /**
+ * @param username
+ * the username to set
+ */
+ public void setUsername(String username) {
+ this.username = username;
+ }
+
+ /**
+ * @return the firstname
+ */
+ public String getFirstname() {
+ return this.firstname;
+ }
+
+ /**
+ * @param firstname
+ * the firstname to set
+ */
+ public void setFirstname(String firstname) {
+ this.firstname = firstname;
+ }
+
+ /**
+ * @return the lastname
+ */
+ public String getLastname() {
+ return this.lastname;
+ }
+
+ /**
+ * @param lastname
+ * the lastname to set
+ */
+ public void setLastname(String lastname) {
+ this.lastname = lastname;
+ }
+
+ /**
+ * @return the date
+ */
+ public Date getDate() {
+ return this.date;
+ }
+
+ /**
+ * @param date
+ * the date to set
+ */
+ public void setDate(Date date) {
+ this.date = date;
+ }
+
+ /**
+ * @return the elementType
+ */
+ public String getElementType() {
+ return this.elementType;
+ }
+
+ /**
+ * @param elementType
+ * the elementType to set
+ */
+ public void setElementType(String elementType) {
+ this.elementType = elementType;
+ }
+
+ /**
+ * @return the elementAccessed
+ */
+ public String getElementAccessed() {
+ return this.elementAccessed;
+ }
+
+ /**
+ * @param elementAccessed
+ * the elementAccessed to set
+ */
+ public void setElementAccessed(String elementAccessed) {
+ this.elementAccessed = elementAccessed;
+ }
+
+ /**
+ * @return the newVersion
+ */
+ public Date getNewVersion() {
+ return this.newVersion;
+ }
+
+ /**
+ * @param newVersion
+ * the newVersion to set
+ */
+ public void setNewVersion(Date newVersion) {
+ this.newVersion = newVersion;
+ }
+
+ /**
+ * @return the action
+ */
+ public String getAction() {
+ return this.action;
+ }
+
+ /**
+ * @param action
+ * the action to set
+ */
+ public void setAction(String action) {
+ this.action = action;
+ }
+
+ /**
+ * @return the accessType
+ */
+ public AccessType getAccessType() {
+ return this.accessType;
+ }
+
+ /**
+ * @param accessType
+ * the accessType to set
+ */
+ public void setAccessType(AccessType accessType) {
+ this.accessType = accessType;
+ }
+
+ public U accept(AuditVisitor visitor) {
+ return visitor.visitAudit(this);
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((this.id == null) ? 0 : this.id.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ Audit other = (Audit) obj;
+ if (this.id == null) {
+ if (other.id != null) {
+ return false;
+ }
+ } else if (!this.id.equals(other.id)) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public int compareTo(Audit o) {
+ return getId().compareTo(o.getId());
+ }
+}
diff --git a/li.strolch.model/src/main/java/li/strolch/model/audit/AuditFromDomReader.java b/li.strolch.model/src/main/java/li/strolch/model/audit/AuditFromDomReader.java
new file mode 100644
index 000000000..123d5903c
--- /dev/null
+++ b/li.strolch.model/src/main/java/li/strolch/model/audit/AuditFromDomReader.java
@@ -0,0 +1,100 @@
+/*
+ * 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.model.audit;
+
+import java.text.MessageFormat;
+
+import li.strolch.model.Tags;
+
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import ch.eitchnet.utils.dbc.DBC;
+import ch.eitchnet.utils.iso8601.ISO8601FormatFactory;
+
+/**
+ * @author Robert von Burg
+ */
+public class AuditFromDomReader {
+
+ public Audit from(Element rootElement) {
+
+ Audit audit = new Audit();
+
+ String idS = rootElement.getAttribute(Tags.Audit.ID);
+ DBC.INTERIM.assertNotEmpty("Id must be set!", idS);
+ audit.setId(Long.valueOf(idS));
+
+ NodeList childNodes = rootElement.getChildNodes();
+ for (int i = 0; i < childNodes.getLength(); i++) {
+ Node item = childNodes.item(i);
+ if (!(item instanceof Element))
+ continue;
+
+ Element element = (Element) item;
+ String nodeName = element.getNodeName();
+ String txtContent = element.getTextContent();
+
+ switch (nodeName) {
+ case Tags.Audit.USERNAME:
+ audit.setUsername(txtContent);
+ break;
+ case Tags.Audit.FIRSTNAME:
+ audit.setFirstname(txtContent);
+ break;
+ case Tags.Audit.LASTNAME:
+ audit.setLastname(txtContent);
+ break;
+ case Tags.Audit.DATE:
+ audit.setDate(ISO8601FormatFactory.getInstance().getXmlDateFormat().parse(txtContent));
+ break;
+ case Tags.Audit.ELEMENT_TYPE:
+ audit.setElementType(txtContent);
+ break;
+ case Tags.Audit.ELEMENT_ACCESSED:
+ audit.setElementAccessed(txtContent);
+ break;
+ case Tags.Audit.NEW_VERSION:
+ audit.setNewVersion(ISO8601FormatFactory.getInstance().getXmlDateFormat().parse(txtContent));
+ break;
+ case Tags.Audit.ACTION:
+ audit.setAction(txtContent);
+ break;
+ case Tags.Audit.ACCESS_TYPE:
+ audit.setAccessType(AccessType.valueOf(txtContent));
+ break;
+
+ default:
+ throw new IllegalArgumentException(MessageFormat.format("Unhandled/Invalid tag {0} for Audit {1}",
+ nodeName, idS));
+ }
+ }
+
+ String msg = " missing for element with id " + audit.getId();
+ DBC.INTERIM.assertNotEmpty("Username" + msg, audit.getUsername());
+ DBC.INTERIM.assertNotEmpty("Firstname" + msg, audit.getFirstname());
+ DBC.INTERIM.assertNotEmpty("Lastname" + msg, audit.getLastname());
+ DBC.INTERIM.assertNotNull("Date" + msg, audit.getDate());
+ DBC.INTERIM.assertNotEmpty("ElementType" + msg, audit.getElementType());
+ DBC.INTERIM.assertNotEmpty("ElementAccessed" + msg, audit.getElementAccessed());
+ //DBC.INTERIM.assertNotNull("NewVersion" + msg, audit.getNewVersion());
+ DBC.INTERIM.assertNotEmpty("Action" + msg, audit.getAction());
+ DBC.INTERIM.assertNotNull("AccessType" + msg, audit.getAccessType());
+
+ return audit;
+ }
+}
diff --git a/li.strolch.model/src/main/java/li/strolch/model/audit/AuditQuery.java b/li.strolch.model/src/main/java/li/strolch/model/audit/AuditQuery.java
new file mode 100644
index 000000000..54dcf4914
--- /dev/null
+++ b/li.strolch.model/src/main/java/li/strolch/model/audit/AuditQuery.java
@@ -0,0 +1,91 @@
+/*
+ * 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.model.audit;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import li.strolch.model.query.StrolchQuery;
+import ch.eitchnet.utils.collections.DateRange;
+import ch.eitchnet.utils.dbc.DBC;
+
+/**
+ * @author Robert von Burg
+ */
+public class AuditQuery implements StrolchQuery {
+
+ private String elementTypeSelection;
+ private List selections;
+ private DateRange dateRange;
+
+ public AuditQuery(String elementTypeSelection, DateRange dateRange) {
+ DBC.PRE.assertFalse("dateRange may not be unbounded!", dateRange.isUnbounded());
+ this.elementTypeSelection = elementTypeSelection;
+ this.dateRange = dateRange;
+ this.selections = new ArrayList<>();
+ }
+
+ public String getElementTypeSelection() {
+ return this.elementTypeSelection;
+ }
+
+ public DateRange getDateRange() {
+ return this.dateRange;
+ }
+
+ public ActionSelection action() {
+ ActionSelection selection = new ActionSelection(this);
+ this.selections.add(selection);
+ return selection;
+ }
+
+ public ElementSelection element() {
+ ElementSelection selection = new ElementSelection(this);
+ this.selections.add(selection);
+ return selection;
+ }
+
+ public IdentitySelection identity() {
+ IdentitySelection selection = new IdentitySelection(this);
+ this.selections.add(selection);
+ return selection;
+ }
+
+ public void accept(AuditQueryVisitor visitor) {
+ DBC.PRE.assertNotNull("No elementTypeSelection (navigation) set!", this.elementTypeSelection); //$NON-NLS-1$
+ DBC.PRE.assertNotNull("No dateRange set!", this.dateRange); //$NON-NLS-1$
+ visitor.visit(this);
+ for (AuditSelection selection : this.selections) {
+ selection.accept(visitor);
+ }
+ }
+
+ /**
+ * @see ch.eitchnet.privilege.model.Restrictable#getPrivilegeName()
+ */
+ @Override
+ public String getPrivilegeName() {
+ return StrolchQuery.class.getName();
+ }
+
+ /**
+ * @see ch.eitchnet.privilege.model.Restrictable#getPrivilegeValue()
+ */
+ @Override
+ public Object getPrivilegeValue() {
+ return getClass().getName();
+ }
+}
diff --git a/li.strolch.model/src/main/java/li/strolch/model/audit/AuditQueryVisitor.java b/li.strolch.model/src/main/java/li/strolch/model/audit/AuditQueryVisitor.java
new file mode 100644
index 000000000..03fc601de
--- /dev/null
+++ b/li.strolch.model/src/main/java/li/strolch/model/audit/AuditQueryVisitor.java
@@ -0,0 +1,30 @@
+/*
+ * 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.model.audit;
+
+/**
+ * @author Robert von Burg
+ */
+public interface AuditQueryVisitor {
+
+ public void visit(ElementSelection selection);
+
+ public void visit(IdentitySelection selection);
+
+ public void visit(ActionSelection selection);
+
+ public void visit(AuditQuery auditQuery);
+}
diff --git a/li.strolch.model/src/main/java/li/strolch/model/audit/AuditSaxReader.java b/li.strolch.model/src/main/java/li/strolch/model/audit/AuditSaxReader.java
new file mode 100644
index 000000000..5b585ed8d
--- /dev/null
+++ b/li.strolch.model/src/main/java/li/strolch/model/audit/AuditSaxReader.java
@@ -0,0 +1,25 @@
+/*
+ * 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.model.audit;
+
+import org.xml.sax.helpers.DefaultHandler;
+
+/**
+ * @author Robert von Burg
+ */
+public class AuditSaxReader extends DefaultHandler {
+
+}
diff --git a/li.strolch.model/src/main/java/li/strolch/model/audit/AuditSelection.java b/li.strolch.model/src/main/java/li/strolch/model/audit/AuditSelection.java
new file mode 100644
index 000000000..f2e1cae63
--- /dev/null
+++ b/li.strolch.model/src/main/java/li/strolch/model/audit/AuditSelection.java
@@ -0,0 +1,35 @@
+/*
+ * 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.model.audit;
+
+/**
+ * @author Robert von Burg
+ */
+public abstract class AuditSelection {
+
+ private AuditQuery query;
+
+ public AuditSelection(AuditQuery query) {
+ super();
+ this.query = query;
+ }
+
+ public AuditQuery query() {
+ return this.query;
+ }
+
+ public abstract void accept(AuditQueryVisitor visitor);
+}
diff --git a/li.strolch.model/src/main/java/li/strolch/model/audit/AuditToDomVisitor.java b/li.strolch.model/src/main/java/li/strolch/model/audit/AuditToDomVisitor.java
new file mode 100644
index 000000000..f187cff84
--- /dev/null
+++ b/li.strolch.model/src/main/java/li/strolch/model/audit/AuditToDomVisitor.java
@@ -0,0 +1,66 @@
+/*
+ * 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.model.audit;
+
+import javax.xml.parsers.DocumentBuilder;
+
+import li.strolch.model.Tags;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import ch.eitchnet.utils.helper.DomUtil;
+import ch.eitchnet.utils.iso8601.ISO8601FormatFactory;
+
+/**
+ * @author Robert von Burg
+ */
+public class AuditToDomVisitor implements AuditVisitor {
+
+ @Override
+ public Document visitAudit(Audit audit) {
+ DocumentBuilder documentBuilder = DomUtil.createDocumentBuilder();
+ Document doc = documentBuilder.getDOMImplementation().createDocument(null, null, null);
+
+ Element auditE = doc.createElement(Tags.AUDIT);
+ auditE.setAttribute(Tags.Audit.ID, audit.getId().toString());
+
+ auditE.appendChild(elem(doc, Tags.Audit.USERNAME, audit.getUsername()));
+
+ auditE.appendChild(elem(doc, Tags.Audit.FIRSTNAME, audit.getUsername()));
+ auditE.appendChild(elem(doc, Tags.Audit.LASTNAME, audit.getUsername()));
+ auditE.appendChild(elem(doc, Tags.Audit.DATE, ISO8601FormatFactory.getInstance().formatDate(audit.getDate())));
+
+ auditE.appendChild(elem(doc, Tags.Audit.ELEMENT_TYPE, audit.getElementType()));
+ auditE.appendChild(elem(doc, Tags.Audit.ELEMENT_ACCESSED, audit.getElementAccessed()));
+
+ if (audit.getNewVersion() != null)
+ auditE.appendChild(elem(doc, Tags.Audit.NEW_VERSION,
+ ISO8601FormatFactory.getInstance().formatDate(audit.getNewVersion())));
+
+ auditE.appendChild(elem(doc, Tags.Audit.ACTION, audit.getAction()));
+ auditE.appendChild(elem(doc, Tags.Audit.ACCESS_TYPE, audit.getAccessType().name()));
+
+ doc.appendChild(auditE);
+ return doc;
+ }
+
+ private Element elem(Document doc, String tag, String txtValue) {
+ Element element = doc.createElement(tag);
+ element.setTextContent(txtValue);
+ return element;
+ }
+}
diff --git a/li.strolch.model/src/main/java/li/strolch/model/audit/AuditVisitor.java b/li.strolch.model/src/main/java/li/strolch/model/audit/AuditVisitor.java
new file mode 100644
index 000000000..002e4d922
--- /dev/null
+++ b/li.strolch.model/src/main/java/li/strolch/model/audit/AuditVisitor.java
@@ -0,0 +1,24 @@
+/*
+ * 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.model.audit;
+
+/**
+ * @author Robert von Burg
+ */
+public interface AuditVisitor {
+
+ public U visitAudit(Audit audit);
+}
diff --git a/li.strolch.model/src/main/java/li/strolch/model/audit/ElementSelection.java b/li.strolch.model/src/main/java/li/strolch/model/audit/ElementSelection.java
new file mode 100644
index 000000000..74b78975b
--- /dev/null
+++ b/li.strolch.model/src/main/java/li/strolch/model/audit/ElementSelection.java
@@ -0,0 +1,49 @@
+/*
+ * 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.model.audit;
+
+import li.strolch.model.query.StringSelection;
+import ch.eitchnet.utils.StringMatchMode;
+
+/**
+ * @author Robert von Burg
+ */
+public class ElementSelection extends AuditSelection {
+
+ private StringSelection elementAccessedSelection;
+
+ public ElementSelection(AuditQuery query) {
+ super(query);
+ }
+
+ public ElementSelection elementsAccessed(StringMatchMode matchMode, String... elementsAccessed) {
+ this.elementAccessedSelection = new StringSelection(matchMode, elementsAccessed);
+ return this;
+ }
+
+ public StringSelection getElementAccessedSelection() {
+ return this.elementAccessedSelection;
+ }
+
+ public boolean isElementsAccessedWildcard() {
+ return this.elementAccessedSelection == null || this.elementAccessedSelection.isWildCard();
+ }
+
+ @Override
+ public void accept(AuditQueryVisitor visitor) {
+ visitor.visit(this);
+ }
+}
diff --git a/li.strolch.model/src/main/java/li/strolch/model/audit/IdentitySelection.java b/li.strolch.model/src/main/java/li/strolch/model/audit/IdentitySelection.java
new file mode 100644
index 000000000..899442ff6
--- /dev/null
+++ b/li.strolch.model/src/main/java/li/strolch/model/audit/IdentitySelection.java
@@ -0,0 +1,90 @@
+/*
+ * 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.model.audit;
+
+import li.strolch.model.query.StringSelection;
+import ch.eitchnet.utils.StringMatchMode;
+
+/**
+ * @author Robert von Burg
+ */
+public class IdentitySelection extends AuditSelection {
+
+ private StringSelection usernameSelection;
+ private StringSelection firstnameSelection;
+ private StringSelection lastnameSelection;
+
+ public IdentitySelection(AuditQuery query) {
+ super(query);
+ }
+
+ public IdentitySelection usernames(StringMatchMode matchMode, String... usernames) {
+ this.usernameSelection = new StringSelection(matchMode, usernames);
+ return this;
+ }
+
+ public IdentitySelection firstnames(StringMatchMode matchMode, String... firstnames) {
+ this.firstnameSelection = new StringSelection(matchMode, firstnames);
+ return this;
+ }
+
+ public IdentitySelection lastnames(StringMatchMode matchMode, String... lastnames) {
+ this.lastnameSelection = new StringSelection(matchMode, lastnames);
+ return this;
+ }
+
+ /**
+ * @return the firstnameSelection
+ */
+ public StringSelection getFirstnameSelection() {
+ return this.firstnameSelection;
+ }
+
+ /**
+ * @return the lastnameSelection
+ */
+ public StringSelection getLastnameSelection() {
+ return this.lastnameSelection;
+ }
+
+ /**
+ * @return the usernameSelection
+ */
+ public StringSelection getUsernameSelection() {
+ return this.usernameSelection;
+ }
+
+ public boolean isFirstnameWildcard() {
+ return this.firstnameSelection == null || this.firstnameSelection.isWildCard();
+ }
+
+ public boolean isLastnameWildcard() {
+ return this.lastnameSelection == null || this.lastnameSelection.isWildCard();
+ }
+
+ public boolean isUsernameWildcard() {
+ return this.usernameSelection == null || this.usernameSelection.isWildCard();
+ }
+
+ public boolean isWildcard() {
+ return isFirstnameWildcard() && isLastnameWildcard() && isUsernameWildcard();
+ }
+
+ @Override
+ public void accept(AuditQueryVisitor visitor) {
+ visitor.visit(this);
+ }
+}
diff --git a/li.strolch.model/src/main/java/li/strolch/model/audit/NoStrategyAuditVisitor.java b/li.strolch.model/src/main/java/li/strolch/model/audit/NoStrategyAuditVisitor.java
new file mode 100644
index 000000000..5cede2cdb
--- /dev/null
+++ b/li.strolch.model/src/main/java/li/strolch/model/audit/NoStrategyAuditVisitor.java
@@ -0,0 +1,27 @@
+/*
+ * 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.model.audit;
+
+/**
+ * @author Robert von Burg
+ */
+public class NoStrategyAuditVisitor implements AuditVisitor {
+
+ @Override
+ public Audit visitAudit(Audit audit) {
+ return audit;
+ }
+}
diff --git a/li.strolch.model/src/main/java/li/strolch/model/parameter/AbstractParameter.java b/li.strolch.model/src/main/java/li/strolch/model/parameter/AbstractParameter.java
new file mode 100644
index 000000000..18296b782
--- /dev/null
+++ b/li.strolch.model/src/main/java/li/strolch/model/parameter/AbstractParameter.java
@@ -0,0 +1,267 @@
+/*
+ * 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.model.parameter;
+
+import static li.strolch.model.StrolchModelConstants.INTERPRETATION_NONE;
+import static li.strolch.model.StrolchModelConstants.UOM_NONE;
+
+import java.text.MessageFormat;
+
+import li.strolch.exception.StrolchException;
+import li.strolch.model.AbstractStrolchElement;
+import li.strolch.model.Locator;
+import li.strolch.model.Locator.LocatorBuilder;
+import li.strolch.model.ParameterizedElement;
+import li.strolch.model.StrolchRootElement;
+import li.strolch.model.Tags;
+import li.strolch.model.visitor.ParameterVisitor;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import ch.eitchnet.utils.helper.StringHelper;
+
+/**
+ * @author Robert von Burg
+ *
+ * @param
+ */
+public abstract class AbstractParameter extends AbstractStrolchElement implements Parameter {
+
+ private static final long serialVersionUID = 0L;
+
+ protected boolean hidden = false;
+ protected int index;
+ protected String interpretation = INTERPRETATION_NONE;
+ protected String uom = UOM_NONE;
+
+ protected ParameterizedElement parent;
+
+ /**
+ * Empty constructor
+ */
+ protected AbstractParameter() {
+ //
+ }
+
+ /**
+ * Default constructor
+ *
+ * @param id
+ * @param name
+ */
+ public AbstractParameter(String id, String name) {
+ super(id, name);
+ }
+
+ @Override
+ public boolean isHidden() {
+ return this.hidden;
+ }
+
+ @Override
+ public void setHidden(boolean hidden) {
+ this.hidden = hidden;
+ }
+
+ @Override
+ public String getInterpretation() {
+ return this.interpretation;
+ }
+
+ @Override
+ public void setInterpretation(String interpretation) {
+ if (StringHelper.isEmpty(interpretation)) {
+ this.interpretation = INTERPRETATION_NONE;
+ } else {
+ this.interpretation = interpretation;
+ }
+ }
+
+ @Override
+ public String getUom() {
+ return this.uom;
+ }
+
+ @Override
+ public void setUom(String uom) {
+ if (StringHelper.isEmpty(uom)) {
+ this.uom = UOM_NONE;
+ } else {
+ this.uom = uom;
+ }
+ }
+
+ @Override
+ public void setIndex(int index) {
+ this.index = index;
+ }
+
+ @Override
+ public int getIndex() {
+ return this.index;
+ }
+
+ @Override
+ public ParameterizedElement getParent() {
+ return this.parent;
+ }
+
+ @Override
+ public void setParent(ParameterizedElement parent) {
+ this.parent = parent;
+ }
+
+ @Override
+ public StrolchRootElement getRootElement() {
+ return this.parent.getRootElement();
+ }
+
+ @Override
+ public Element toDom(Document doc) {
+ Element element = doc.createElement(Tags.PARAMETER);
+ fillElement(element);
+
+ element.setAttribute(Tags.VALUE, getValueAsString());
+
+ if (!this.interpretation.equals(INTERPRETATION_NONE)) {
+ element.setAttribute(Tags.INTERPRETATION, this.interpretation);
+ }
+ if (!this.uom.equals(UOM_NONE)) {
+ element.setAttribute(Tags.UOM, this.uom);
+ }
+ if (this.hidden) {
+ element.setAttribute(Tags.HIDDEN, Boolean.toString(this.hidden));
+ }
+ if (this.index != 0) {
+ element.setAttribute(Tags.INDEX, Integer.toString(this.index));
+ }
+
+ return element;
+ }
+
+ @Override
+ public void fromDom(Element element) {
+
+ super.fromDom(element);
+
+ String typeS = element.getAttribute(Tags.TYPE);
+ if (StringHelper.isEmpty(typeS)) {
+ String msg = "Type must be set on element with id {0}"; //$NON-NLS-1$
+ msg = MessageFormat.format(msg, this.id);
+ throw new StrolchException(msg);
+ } else if (!typeS.equals(getType())) {
+ String msg = "{0} must have type {1}, not: {2}"; //$NON-NLS-1$
+ msg = MessageFormat.format(msg, getClass().getSimpleName(), getType(), typeS);
+ throw new StrolchException(msg);
+ }
+
+ String interpretation = element.getAttribute(Tags.INTERPRETATION);
+ String hidden = element.getAttribute(Tags.HIDDEN);
+ String uom = element.getAttribute(Tags.UOM);
+ String index = element.getAttribute(Tags.INDEX);
+
+ setInterpretation(interpretation);
+ setUom(uom);
+
+ if (StringHelper.isEmpty(index)) {
+ this.index = 0;
+ } else {
+ this.index = Integer.valueOf(index);
+ }
+
+ if (StringHelper.isEmpty(hidden)) {
+ setHidden(false);
+ } else {
+ if (hidden.equalsIgnoreCase(Boolean.TRUE.toString())) {
+ setHidden(true);
+ } else if (hidden.equalsIgnoreCase(Boolean.FALSE.toString())) {
+ setHidden(false);
+ } else {
+ String msg = "Boolean string must be either {0} or {1}"; //$NON-NLS-1$
+ msg = MessageFormat.format(msg, Boolean.TRUE.toString(), Boolean.FALSE.toString());
+ throw new StrolchException(msg);
+ }
+ }
+ }
+
+ @Override
+ protected void fillLocator(LocatorBuilder lb) {
+ lb.append(this.id);
+ }
+
+ @Override
+ public Locator getLocator() {
+ LocatorBuilder lb = new LocatorBuilder();
+ this.parent.fillLocator(lb);
+ fillLocator(lb);
+ return lb.build();
+ }
+
+ /**
+ * Validates that the value is legal. This is the case when it is not null in this implementation
+ *
+ * @param value
+ * the value to check for this parameter instance
+ *
+ * @throws StrolchException
+ * if the value is null
+ */
+ protected void validateValue(T value) throws StrolchException {
+ if (value == null) {
+ String msg = "{0} Parameter {1} may not have a null value!"; //$NON-NLS-1$
+ msg = MessageFormat.format(msg, getType(), getId());
+ throw new StrolchException(msg);
+ }
+ }
+
+ /**
+ * Fills the {@link Parameter} clone with the id, name, hidden, interpretation and uom
+ *
+ * @param clone
+ */
+ protected void fillClone(Parameter> clone) {
+ super.fillClone(clone);
+
+ clone.setHidden(this.hidden);
+ clone.setInterpretation(this.interpretation);
+ clone.setUom(this.uom);
+ clone.setIndex(this.index);
+ }
+
+ @Override
+ public U accept(ParameterVisitor visitor) {
+ return visitor.visitParam(this);
+ }
+
+ @SuppressWarnings("nls")
+ @Override
+ public String toString() {
+
+ StringBuilder builder = new StringBuilder();
+
+ builder.append(getClass().getSimpleName());
+ builder.append(" [id=");
+ builder.append(this.id);
+ builder.append(", name=");
+ builder.append(this.name);
+ builder.append(", value=");
+ builder.append(getValueAsString());
+ builder.append("]");
+
+ return builder.toString();
+ }
+}
diff --git a/li.strolch.model/src/main/java/li/strolch/model/parameter/BooleanParameter.java b/li.strolch.model/src/main/java/li/strolch/model/parameter/BooleanParameter.java
new file mode 100644
index 000000000..56c1aba28
--- /dev/null
+++ b/li.strolch.model/src/main/java/li/strolch/model/parameter/BooleanParameter.java
@@ -0,0 +1,114 @@
+/*
+ * 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.model.parameter;
+
+import java.text.MessageFormat;
+
+import li.strolch.exception.StrolchException;
+import li.strolch.model.Tags;
+import li.strolch.model.visitor.ParameterVisitor;
+
+import org.w3c.dom.Element;
+
+import ch.eitchnet.utils.helper.StringHelper;
+
+/**
+ * @author Robert von Burg
+ */
+public class BooleanParameter extends AbstractParameter {
+
+ public static final String TYPE = "Boolean"; //$NON-NLS-1$
+ private static final long serialVersionUID = 0L;
+
+ private Boolean value = Boolean.FALSE;
+
+ /**
+ * Empty constructor
+ */
+ public BooleanParameter() {
+ //
+ }
+
+ /**
+ * Default constructors
+ *
+ * @param id
+ * @param name
+ * @param value
+ */
+ public BooleanParameter(String id, String name, Boolean value) {
+ super(id, name);
+ setValue(value);
+ }
+
+ /**
+ * DOM Constructor
+ *
+ * @param element
+ */
+ public BooleanParameter(Element element) {
+ super.fromDom(element);
+
+ String valueS = element.getAttribute(Tags.VALUE);
+ if (StringHelper.isEmpty(valueS)) {
+ String msg = MessageFormat.format("No value defined for {0}", this.id); //$NON-NLS-1$
+ throw new StrolchException(msg);
+ }
+
+ setValue(parseFromString(valueS));
+ }
+
+ @Override
+ public String getValueAsString() {
+ return this.value.toString();
+ }
+
+ @Override
+ public Boolean getValue() {
+ return this.value;
+ }
+
+ @Override
+ public void setValue(Boolean value) {
+ validateValue(value);
+ this.value = value;
+ }
+
+ @Override
+ public String getType() {
+ return BooleanParameter.TYPE;
+ }
+
+ @Override
+ public BooleanParameter getClone() {
+ BooleanParameter clone = new BooleanParameter();
+
+ super.fillClone(clone);
+
+ clone.setValue(this.value);
+
+ return clone;
+ }
+
+ @Override
+ public U accept(ParameterVisitor visitor) {
+ return visitor.visitBooleanParam(this);
+ }
+
+ public static Boolean parseFromString(String valueS) {
+ return StringHelper.parseBoolean(valueS);
+ }
+}
diff --git a/li.strolch.model/src/main/java/li/strolch/model/parameter/DateParameter.java b/li.strolch.model/src/main/java/li/strolch/model/parameter/DateParameter.java
new file mode 100644
index 000000000..ffffb8462
--- /dev/null
+++ b/li.strolch.model/src/main/java/li/strolch/model/parameter/DateParameter.java
@@ -0,0 +1,116 @@
+/*
+ * 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.model.parameter;
+
+import java.text.MessageFormat;
+import java.util.Date;
+
+import li.strolch.exception.StrolchException;
+import li.strolch.model.Tags;
+import li.strolch.model.visitor.ParameterVisitor;
+
+import org.w3c.dom.Element;
+
+import ch.eitchnet.utils.helper.StringHelper;
+import ch.eitchnet.utils.iso8601.ISO8601FormatFactory;
+
+/**
+ * @author Robert von Burg
+ */
+public class DateParameter extends AbstractParameter {
+
+ public static final String TYPE = "Date"; //$NON-NLS-1$
+ private static final long serialVersionUID = 0L;
+
+ private Date value;
+
+ /**
+ * Empty constructor
+ */
+ public DateParameter() {
+ //
+ }
+
+ /**
+ * Default Constructor
+ *
+ * @param id
+ * @param name
+ * @param value
+ */
+ public DateParameter(String id, String name, Date value) {
+ super(id, name);
+ setValue(value);
+ }
+
+ /**
+ * DOM Constructor
+ *
+ * @param element
+ */
+ public DateParameter(Element element) {
+ super.fromDom(element);
+
+ String valueS = element.getAttribute(Tags.VALUE);
+ if (StringHelper.isEmpty(valueS)) {
+ String msg = MessageFormat.format("No value defined for {0}", this.id); //$NON-NLS-1$
+ throw new StrolchException(msg);
+ }
+
+ setValue(parseFromString(valueS));
+ }
+
+ @Override
+ public String getValueAsString() {
+ return ISO8601FormatFactory.getInstance().formatDate(this.value);
+ }
+
+ @Override
+ public Date getValue() {
+ return this.value;
+ }
+
+ @Override
+ public void setValue(Date value) {
+ validateValue(value);
+ this.value = value;
+ }
+
+ @Override
+ public String getType() {
+ return DateParameter.TYPE;
+ }
+
+ @Override
+ public DateParameter getClone() {
+ DateParameter clone = new DateParameter();
+
+ super.fillClone(clone);
+
+ clone.setValue(this.value);
+
+ return clone;
+ }
+
+ @Override
+ public U accept(ParameterVisitor visitor) {
+ return visitor.visitDateParam(this);
+ }
+
+ public static Date parseFromString(String valueS) {
+ return ISO8601FormatFactory.getInstance().getDateFormat().parse(valueS);
+ }
+}
diff --git a/li.strolch.model/src/main/java/li/strolch/model/parameter/FloatParameter.java b/li.strolch.model/src/main/java/li/strolch/model/parameter/FloatParameter.java
new file mode 100644
index 000000000..565ce2738
--- /dev/null
+++ b/li.strolch.model/src/main/java/li/strolch/model/parameter/FloatParameter.java
@@ -0,0 +1,116 @@
+/*
+ * 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.model.parameter;
+
+import java.text.MessageFormat;
+
+import li.strolch.exception.StrolchException;
+import li.strolch.model.Tags;
+import li.strolch.model.visitor.ParameterVisitor;
+
+import org.w3c.dom.Element;
+
+import ch.eitchnet.utils.helper.StringHelper;
+
+/**
+ * @author Robert von Burg
+ *
+ */
+public class FloatParameter extends AbstractParameter {
+
+ public static final String TYPE = "Float"; //$NON-NLS-1$
+ private static final long serialVersionUID = 0L;
+
+ private Double value = Double.MAX_VALUE;
+
+ /**
+ * Empty constructor
+ */
+ public FloatParameter() {
+ //
+ }
+
+ /**
+ * Default constructor
+ *
+ * @param id
+ * @param name
+ * @param value
+ */
+ public FloatParameter(String id, String name, Double value) {
+ super(id, name);
+
+ setValue(value);
+ }
+
+ /**
+ * DOM Constructor
+ *
+ * @param element
+ */
+ public FloatParameter(Element element) {
+ super.fromDom(element);
+
+ String valueS = element.getAttribute(Tags.VALUE);
+ if (StringHelper.isEmpty(valueS)) {
+ String msg = MessageFormat.format("No value defined for {0}", this.id); //$NON-NLS-1$
+ throw new StrolchException(msg);
+ }
+
+ setValue(parseFromString(valueS));
+ }
+
+ @Override
+ public String getValueAsString() {
+ return Double.toString(this.value);
+ }
+
+ @Override
+ public Double getValue() {
+ return this.value;
+ }
+
+ @Override
+ public void setValue(Double value) {
+ validateValue(value);
+ this.value = value;
+ }
+
+ @Override
+ public String getType() {
+ return FloatParameter.TYPE;
+ }
+
+ @Override
+ public FloatParameter getClone() {
+ FloatParameter clone = new FloatParameter();
+
+ super.fillClone(clone);
+
+ clone.setValue(this.value);
+
+ return clone;
+ }
+
+ @Override
+ public U accept(ParameterVisitor visitor) {
+ return visitor.visitFloatParam(this);
+ }
+
+ public static Double parseFromString(String valueS) {
+ return Double.valueOf(valueS);
+ }
+}
diff --git a/li.strolch.model/src/main/java/li/strolch/model/parameter/IntegerParameter.java b/li.strolch.model/src/main/java/li/strolch/model/parameter/IntegerParameter.java
new file mode 100644
index 000000000..cf29997d4
--- /dev/null
+++ b/li.strolch.model/src/main/java/li/strolch/model/parameter/IntegerParameter.java
@@ -0,0 +1,115 @@
+/*
+ * 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.model.parameter;
+
+import java.text.MessageFormat;
+
+import li.strolch.exception.StrolchException;
+import li.strolch.model.Tags;
+import li.strolch.model.visitor.ParameterVisitor;
+
+import org.w3c.dom.Element;
+
+import ch.eitchnet.utils.helper.StringHelper;
+
+/**
+ * @author Robert von Burg
+ *
+ */
+public class IntegerParameter extends AbstractParameter {
+
+ public static final String TYPE = "Integer"; //$NON-NLS-1$
+ private static final long serialVersionUID = 0L;
+
+ private Integer value = Integer.MAX_VALUE;
+
+ /**
+ * Empty constructor
+ */
+ public IntegerParameter() {
+ //
+ }
+
+ /**
+ * Default constructor
+ *
+ * @param id
+ * @param name
+ * @param value
+ */
+ public IntegerParameter(String id, String name, Integer value) {
+ super(id, name);
+ setValue(value);
+ }
+
+ /**
+ * DOM Constructor
+ *
+ * @param element
+ */
+ public IntegerParameter(Element element) {
+ super.fromDom(element);
+
+ String valueS = element.getAttribute(Tags.VALUE);
+ if (StringHelper.isEmpty(valueS)) {
+ String msg = MessageFormat.format("No value defined for {0}", this.id); //$NON-NLS-1$
+ throw new StrolchException(msg);
+ }
+
+ setValue(parseFromString(valueS));
+ }
+
+ @Override
+ public String getType() {
+ return IntegerParameter.TYPE;
+ }
+
+ @Override
+ public String getValueAsString() {
+ return Integer.toString(this.value);
+ }
+
+ @Override
+ public Integer getValue() {
+ return this.value;
+ }
+
+ @Override
+ public void setValue(Integer value) {
+ validateValue(value);
+ this.value = value;
+ }
+
+ @Override
+ public IntegerParameter getClone() {
+ IntegerParameter clone = new IntegerParameter();
+
+ super.fillClone(clone);
+
+ clone.setValue(this.value);
+
+ return clone;
+ }
+
+ @Override
+ public U accept(ParameterVisitor visitor) {
+ return visitor.visitIntegerParam(this);
+ }
+
+ public static Integer parseFromString(String valueS) {
+ return Integer.valueOf(valueS);
+ }
+}
diff --git a/li.strolch.model/src/main/java/li/strolch/model/parameter/ListParameter.java b/li.strolch.model/src/main/java/li/strolch/model/parameter/ListParameter.java
new file mode 100644
index 000000000..d599bb29b
--- /dev/null
+++ b/li.strolch.model/src/main/java/li/strolch/model/parameter/ListParameter.java
@@ -0,0 +1,45 @@
+/*
+ * 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.model.parameter;
+
+import java.util.List;
+
+/**
+ * @author Robert von Burg
+ *
+ */
+public interface ListParameter extends Parameter> {
+
+ public static final String VALUE_SEPARATOR = ";"; //$NON-NLS-1$
+
+ /**
+ * Adds a single value to the {@link List} of values
+ *
+ * @param value
+ * the value to add
+ */
+ public void addValue(E value);
+
+ /**
+ * Removes a single value from the {@link List} of values
+ *
+ * @param value
+ * the value to remove
+ *
+ * @return true if the value was removed, false if it did not exist
+ */
+ public boolean removeValue(E value);
+}
diff --git a/li.strolch.model/src/main/java/li/strolch/model/parameter/LongParameter.java b/li.strolch.model/src/main/java/li/strolch/model/parameter/LongParameter.java
new file mode 100644
index 000000000..0e47f51a9
--- /dev/null
+++ b/li.strolch.model/src/main/java/li/strolch/model/parameter/LongParameter.java
@@ -0,0 +1,115 @@
+/*
+ * 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.model.parameter;
+
+import java.text.MessageFormat;
+
+import li.strolch.exception.StrolchException;
+import li.strolch.model.Tags;
+import li.strolch.model.visitor.ParameterVisitor;
+
+import org.w3c.dom.Element;
+
+import ch.eitchnet.utils.helper.StringHelper;
+
+/**
+ * @author Robert von Burg
+ *
+ */
+public class LongParameter extends AbstractParameter {
+
+ public static final String TYPE = "Long"; //$NON-NLS-1$
+ private static final long serialVersionUID = 0L;
+
+ protected Long value;
+
+ /**
+ * Empty constructor
+ */
+ public LongParameter() {
+ //
+ }
+
+ /**
+ * Default constructor
+ *
+ * @param id
+ * @param name
+ * @param value
+ */
+ public LongParameter(String id, String name, Long value) {
+ super(id, name);
+ setValue(value);
+ }
+
+ /**
+ * DOM Constructor
+ *
+ * @param element
+ */
+ public LongParameter(Element element) {
+ super.fromDom(element);
+
+ String valueS = element.getAttribute(Tags.VALUE);
+ if (StringHelper.isEmpty(valueS)) {
+ String msg = MessageFormat.format("No value defined for {0}", this.id); //$NON-NLS-1$
+ throw new StrolchException(msg);
+ }
+
+ setValue(parseFromString(valueS));
+ }
+
+ @Override
+ public String getValueAsString() {
+ return this.value.toString();
+ }
+
+ @Override
+ public Long getValue() {
+ return this.value;
+ }
+
+ @Override
+ public void setValue(Long value) {
+ validateValue(value);
+ this.value = value;
+ }
+
+ @Override
+ public String getType() {
+ return LongParameter.TYPE;
+ }
+
+ @Override
+ public LongParameter getClone() {
+ LongParameter clone = new LongParameter();
+
+ super.fillClone(clone);
+
+ clone.setValue(this.value);
+
+ return clone;
+ }
+
+ @Override
+ public U accept(ParameterVisitor visitor) {
+ return visitor.visitLongParam(this);
+ }
+
+ public static Long parseFromString(String valueS) {
+ return Long.valueOf(valueS);
+ }
+}
diff --git a/li.strolch.model/src/main/java/li/strolch/model/parameter/Parameter.java b/li.strolch.model/src/main/java/li/strolch/model/parameter/Parameter.java
new file mode 100644
index 000000000..f55b99594
--- /dev/null
+++ b/li.strolch.model/src/main/java/li/strolch/model/parameter/Parameter.java
@@ -0,0 +1,141 @@
+/*
+ * 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.model.parameter;
+
+import li.strolch.model.ParameterizedElement;
+import li.strolch.model.StrolchElement;
+import li.strolch.model.StrolchModelConstants;
+import li.strolch.model.visitor.ParameterVisitor;
+
+/**
+ * @author Robert von Burg
+ */
+public interface Parameter extends StrolchElement {
+
+ /**
+ * the value of the parameter as string
+ *
+ * @return String
+ */
+ public String getValueAsString();
+
+ /**
+ * the value of the parameter
+ *
+ * @return
+ */
+ public T getValue();
+
+ /**
+ * the value of the parameter
+ *
+ * @param value
+ */
+ public void setValue(T value);
+
+ /**
+ * get the hidden attribute
+ *
+ * @return
+ */
+ public boolean isHidden();
+
+ /**
+ * set the hidden attribute
+ *
+ * @param hidden
+ */
+ public void setHidden(boolean hidden);
+
+ /**
+ * Get the UOM of this {@link Parameter}
+ *
+ * @return
+ */
+ public String getUom();
+
+ /**
+ * Set the UOM of this {@link Parameter}
+ *
+ * @param uom
+ */
+ public void setUom(String uom);
+
+ /**
+ * Returns the index of this {@link Parameter}. This can be used to sort the parameters in a UI
+ *
+ * @return the index of this {@link Parameter}. This can be used to sort the parameters in a UI
+ */
+ public int getIndex();
+
+ /**
+ * Set the index of this {@link Parameter}. This can be used to sort the parameters in a UI
+ *
+ * @param index
+ * the index to set
+ */
+ public void setIndex(int index);
+
+ /**
+ * Returns the interpretation of this {@link Parameter}. The interpretation semantic describes what the value of
+ * this {@link Parameter} means. Currently there are three definitions, but any String value can be used:
+ *
+ * - {@link StrolchModelConstants#INTERPRETATION_NONE}
+ * - {@link StrolchModelConstants#INTERPRETATION_ORDER_REF}
+ * - {@link StrolchModelConstants#INTERPRETATION_RESOURCE_REF}
+ *
+ *
+ * @return string value
+ */
+ public String getInterpretation();
+
+ /**
+ * Set the interpretation of this {@link Parameter}. The interpretation semantic describes what the value of this
+ * {@link Parameter} means. Currently there are three definitions, but any String value can be used:
+ *
+ * - {@link StrolchModelConstants#INTERPRETATION_NONE}
+ * - {@link StrolchModelConstants#INTERPRETATION_ORDER_REF}
+ * - {@link StrolchModelConstants#INTERPRETATION_RESOURCE_REF}
+ *
+ *
+ * @param interpretation
+ */
+ public void setInterpretation(String interpretation);
+
+ /**
+ * The {@link ParameterizedElement} parent to which this {@link Parameter} belongs
+ *
+ * @return
+ */
+ @Override
+ public ParameterizedElement getParent();
+
+ /**
+ * Sets the parent for this {@link Parameter}
+ */
+ public void setParent(ParameterizedElement parent);
+
+ @Override
+ public int hashCode();
+
+ @Override
+ public boolean equals(Object obj);
+
+ @Override
+ public Parameter getClone();
+
+ public U accept(ParameterVisitor visitor);
+}
diff --git a/li.strolch.model/src/main/java/li/strolch/model/parameter/StringListParameter.java b/li.strolch.model/src/main/java/li/strolch/model/parameter/StringListParameter.java
new file mode 100644
index 000000000..3068011f9
--- /dev/null
+++ b/li.strolch.model/src/main/java/li/strolch/model/parameter/StringListParameter.java
@@ -0,0 +1,154 @@
+/*
+ * 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.model.parameter;
+
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import li.strolch.exception.StrolchException;
+import li.strolch.model.Tags;
+import li.strolch.model.visitor.ParameterVisitor;
+
+import org.w3c.dom.Element;
+
+import ch.eitchnet.utils.helper.StringHelper;
+
+/**
+ * @author Robert von Burg
+ */
+public class StringListParameter extends AbstractParameter> implements ListParameter {
+
+ public static final String TYPE = "StringList"; //$NON-NLS-1$
+ private static final long serialVersionUID = 1L;
+
+ protected List value;
+
+ /**
+ * Empty constructor
+ */
+ public StringListParameter() {
+ //
+ }
+
+ /**
+ * Default constructor
+ *
+ * @param id
+ * @param name
+ * @param value
+ */
+ public StringListParameter(String id, String name, List value) {
+ super(id, name);
+
+ setValue(value);
+ }
+
+ /**
+ * DOM Constructor
+ *
+ * @param element
+ */
+ public StringListParameter(Element element) {
+ super.fromDom(element);
+
+ String valueS = element.getAttribute(Tags.VALUE);
+ if (StringHelper.isEmpty(valueS)) {
+ String msg = MessageFormat.format("No value defined for {0}", this.id); //$NON-NLS-1$
+ throw new StrolchException(msg);
+ }
+
+ setValue(parseFromString(valueS));
+ }
+
+ @Override
+ public String getValueAsString() {
+ if (this.value.isEmpty()) {
+ return StringHelper.EMPTY;
+ }
+
+ StringBuilder sb = new StringBuilder();
+ Iterator iter = this.value.iterator();
+ while (iter.hasNext()) {
+
+ sb.append(iter.next());
+
+ if (iter.hasNext()) {
+ sb.append(VALUE_SEPARATOR);
+ }
+ }
+
+ return sb.toString();
+ }
+
+ @Override
+ public List getValue() {
+ return new ArrayList(this.value);
+ }
+
+ @Override
+ public void setValue(List value) {
+ validateValue(value);
+ if (this.value == null) {
+ this.value = new ArrayList(value.size());
+ }
+ this.value.clear();
+ this.value.addAll(value);
+ }
+
+ @Override
+ public void addValue(String value) {
+ this.value.add(value);
+ }
+
+ @Override
+ public boolean removeValue(String value) {
+ return this.value.remove(value);
+ }
+
+ @Override
+ public String getType() {
+ return TYPE;
+ }
+
+ @Override
+ public StringListParameter getClone() {
+ StringListParameter clone = new StringListParameter();
+
+ super.fillClone(clone);
+
+ clone.setValue(this.value);
+
+ return clone;
+ }
+
+ @Override
+ public U accept(ParameterVisitor visitor) {
+ return visitor.visitStringListParam(this);
+ }
+
+ public static List parseFromString(String value) {
+ if (value.isEmpty()) {
+ return Collections.emptyList();
+ }
+
+ String[] valueArr = value.split(VALUE_SEPARATOR);
+ return Arrays.asList(valueArr);
+ }
+}
diff --git a/li.strolch.model/src/main/java/li/strolch/model/parameter/StringParameter.java b/li.strolch.model/src/main/java/li/strolch/model/parameter/StringParameter.java
new file mode 100644
index 000000000..b7c65b897
--- /dev/null
+++ b/li.strolch.model/src/main/java/li/strolch/model/parameter/StringParameter.java
@@ -0,0 +1,113 @@
+/*
+ * 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.model.parameter;
+
+import java.text.MessageFormat;
+
+import li.strolch.exception.StrolchException;
+import li.strolch.model.Tags;
+import li.strolch.model.visitor.ParameterVisitor;
+
+import org.w3c.dom.Element;
+
+import ch.eitchnet.utils.helper.StringHelper;
+
+/**
+ * @author Robert von Burg
+ *
+ */
+public class StringParameter extends AbstractParameter {
+
+ public static final String UNDEFINED_VALUE = "-"; //$NON-NLS-1$
+ public static final String TYPE = "String"; //$NON-NLS-1$
+ private static final long serialVersionUID = 0L;
+
+ private String value = UNDEFINED_VALUE;
+
+ /**
+ * Empty constructor
+ *
+ */
+ public StringParameter() {
+ //
+ }
+
+ /**
+ * Default constructor
+ *
+ * @param id
+ * @param name
+ * @param value
+ */
+ public StringParameter(String id, String name, String value) {
+ super(id, name);
+ setValue(value);
+ }
+
+ /**
+ * DOM Constructor
+ *
+ * @param element
+ */
+ public StringParameter(Element element) {
+ super.fromDom(element);
+
+ String valueS = element.getAttribute(Tags.VALUE);
+ if (StringHelper.isEmpty(valueS)) {
+ String msg = MessageFormat.format("No value defined for {0}", this.id); //$NON-NLS-1$
+ throw new StrolchException(msg);
+ }
+
+ setValue(valueS);
+ }
+
+ @Override
+ public String getType() {
+ return StringParameter.TYPE;
+ }
+
+ @Override
+ public String getValue() {
+ return this.value;
+ }
+
+ @Override
+ public String getValueAsString() {
+ return this.value;
+ }
+
+ @Override
+ public void setValue(String value) {
+ validateValue(value);
+ this.value = value;
+ }
+
+ @Override
+ public StringParameter getClone() {
+ StringParameter clone = new StringParameter();
+
+ super.fillClone(clone);
+
+ clone.setValue(this.value);
+
+ return clone;
+ }
+
+ @Override
+ public U accept(ParameterVisitor visitor) {
+ return visitor.visitStringParam(this);
+ }
+}
diff --git a/li.strolch.model/src/main/java/li/strolch/model/query/AndSelection.java b/li.strolch.model/src/main/java/li/strolch/model/query/AndSelection.java
new file mode 100644
index 000000000..877ba4f50
--- /dev/null
+++ b/li.strolch.model/src/main/java/li/strolch/model/query/AndSelection.java
@@ -0,0 +1,63 @@
+/*
+ * 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.model.query;
+
+import java.util.List;
+
+/**
+ * @author Robert von Burg
+ */
+public class AndSelection extends BooleanSelection {
+
+ public AndSelection() {
+ super();
+ }
+
+ @SafeVarargs
+ public AndSelection(Selection... selections) {
+ super(selections);
+ }
+
+ /**
+ * @param selections
+ */
+ public AndSelection(List selections) {
+ super(selections);
+ }
+
+ @Override
+ public AndSelection with(Selection selection) {
+ super.with(selection);
+ return this;
+ }
+
+ @Override
+ public AndSelection with(List selections) {
+ super.with(selections);
+ return this;
+ }
+
+ @Override
+ public AndSelection with(Selection... selections) {
+ super.with(selections);
+ return this;
+ }
+
+ @Override
+ public void accept(QueryVisitor visitor) {
+ visitor.visitAnd(this);
+ }
+}
diff --git a/li.strolch.model/src/main/java/li/strolch/model/query/AnySelection.java b/li.strolch.model/src/main/java/li/strolch/model/query/AnySelection.java
new file mode 100644
index 000000000..79762b54c
--- /dev/null
+++ b/li.strolch.model/src/main/java/li/strolch/model/query/AnySelection.java
@@ -0,0 +1,32 @@
+/*
+ * 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.model.query;
+
+/**
+ * @author Robert von Burg
+ */
+public class AnySelection implements Selection {
+
+ @Override
+ public void accept(QueryVisitor visitor) {
+ visitor.visitAny();
+ }
+
+ @Override
+ public boolean hasSelection() {
+ return true;
+ }
+}
diff --git a/li.strolch.model/src/main/java/li/strolch/model/query/BooleanSelection.java b/li.strolch.model/src/main/java/li/strolch/model/query/BooleanSelection.java
new file mode 100644
index 000000000..afc7284b7
--- /dev/null
+++ b/li.strolch.model/src/main/java/li/strolch/model/query/BooleanSelection.java
@@ -0,0 +1,85 @@
+/*
+ * 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.model.query;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * @author Robert von Burg
+ */
+public abstract class BooleanSelection implements Selection {
+
+ protected List selections;
+
+ public BooleanSelection() {
+ this.selections = new ArrayList<>(1);
+ }
+
+ public BooleanSelection(List selections) {
+ this.selections = selections;
+ }
+
+ public BooleanSelection(Selection leftHandSide, Selection rightHandSide) {
+ this.selections = new ArrayList<>(2);
+ this.selections.add(leftHandSide);
+ this.selections.add(rightHandSide);
+ }
+
+ public BooleanSelection(Selection... selections) {
+ this.selections = Arrays.asList(selections);
+ }
+
+ @Override
+ public boolean hasSelection() {
+ if (this.selections == null || this.selections.isEmpty())
+ return false;
+
+ for (Selection selection : this.selections) {
+ if (selection.hasSelection()) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ public List getSelections() {
+ return Collections.unmodifiableList(this.selections);
+ }
+
+ public BooleanSelection with(Selection selection) {
+ this.selections.add(selection);
+ return this;
+ }
+
+ public BooleanSelection with(Selection... selections) {
+ for (Selection selection : selections) {
+ this.selections.add(selection);
+ }
+ return this;
+ }
+
+ public BooleanSelection with(List selections) {
+ this.selections.addAll(selections);
+ return this;
+ }
+
+ @Override
+ public abstract void accept(QueryVisitor visitor);
+}
diff --git a/li.strolch.model/src/main/java/li/strolch/model/query/DateSelection.java b/li.strolch.model/src/main/java/li/strolch/model/query/DateSelection.java
new file mode 100644
index 000000000..ea3ef2645
--- /dev/null
+++ b/li.strolch.model/src/main/java/li/strolch/model/query/DateSelection.java
@@ -0,0 +1,79 @@
+/*
+ * 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.model.query;
+
+import java.util.Date;
+
+import ch.eitchnet.utils.collections.DateRange;
+
+/**
+ * @author Robert von Burg
+ */
+public class DateSelection extends OrderSelection {
+
+ private DateRange dateRange;
+
+ public DateSelection() {
+ this.dateRange = new DateRange();
+ }
+
+ public DateSelection from(Date from, boolean inclusive) {
+ this.dateRange.from(from, inclusive);
+ return this;
+ }
+
+ public DateSelection to(Date to, boolean inclusive) {
+ this.dateRange.to(to, inclusive);
+ return this;
+ }
+
+ public Date getFromDate() {
+ return this.dateRange.getFromDate();
+ }
+
+ public Date getToDate() {
+ return this.dateRange.getToDate();
+ }
+
+ public boolean isFromBounded() {
+ return this.dateRange.isFromBounded();
+ }
+
+ public boolean isToBounded() {
+ return this.dateRange.isToBounded();
+ }
+
+ public boolean isUnbounded() {
+ return this.dateRange.isUnbounded();
+ }
+
+ public boolean isBounded() {
+ return this.dateRange.isBounded();
+ }
+
+ public boolean contains(Date date) {
+ return this.dateRange.contains(date);
+ }
+
+ public DateRange getDateRange() {
+ return this.dateRange;
+ }
+
+ @Override
+ public void accept(OrderSelectionVisitor visitor) {
+ visitor.visit(this);
+ }
+}
diff --git a/li.strolch.model/src/main/java/li/strolch/model/query/IdSelection.java b/li.strolch.model/src/main/java/li/strolch/model/query/IdSelection.java
new file mode 100644
index 000000000..1aea0f913
--- /dev/null
+++ b/li.strolch.model/src/main/java/li/strolch/model/query/IdSelection.java
@@ -0,0 +1,75 @@
+/*
+ * 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.model.query;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * @author Robert von Burg
+ */
+public class IdSelection extends StrolchElementSelection {
+
+ private List ids;
+
+ public IdSelection() {
+ this.ids = new ArrayList<>(1);
+ }
+
+ /**
+ * @param id
+ */
+ public IdSelection(String id) {
+ this.ids = new ArrayList<>(1);
+ this.ids.add(id);
+ }
+
+ /**
+ * @param ids
+ */
+ public IdSelection(String... ids) {
+ this.ids = Arrays.asList(ids);
+ }
+
+ /**
+ * @param ids
+ */
+ public IdSelection(List ids) {
+ this.ids = ids;
+ }
+
+ /**
+ * @return the ids
+ */
+ public List getIds() {
+ return this.ids;
+ }
+
+ /**
+ * @param id
+ * @return
+ */
+ public IdSelection with(String id) {
+ this.ids.add(id);
+ return this;
+ }
+
+ @Override
+ public void accept(StrolchElementSelectionVisitor visitor) {
+ visitor.visit(this);
+ }
+}
diff --git a/li.strolch.model/src/main/java/li/strolch/model/query/NameSelection.java b/li.strolch.model/src/main/java/li/strolch/model/query/NameSelection.java
new file mode 100644
index 000000000..9b618563d
--- /dev/null
+++ b/li.strolch.model/src/main/java/li/strolch/model/query/NameSelection.java
@@ -0,0 +1,55 @@
+/*
+ * 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.model.query;
+
+import ch.eitchnet.utils.StringMatchMode;
+
+/**
+ * @author Robert von Burg
+ */
+public class NameSelection extends StrolchElementSelection {
+
+ private StringMatchMode matchMode;
+ private String name;
+
+ /**
+ * @param name
+ * @param matchMode
+ */
+ public NameSelection(String name, StringMatchMode matchMode) {
+ this.name = name;
+ this.matchMode = matchMode;
+ }
+
+ /**
+ * @return the name
+ */
+ public String getName() {
+ return this.name;
+ }
+
+ /**
+ * @return the matchMode
+ */
+ public StringMatchMode getMatchMode() {
+ return this.matchMode;
+ }
+
+ @Override
+ public void accept(StrolchElementSelectionVisitor visitor) {
+ visitor.visit(this);
+ }
+}
diff --git a/li.strolch.model/src/main/java/li/strolch/model/query/Navigation.java b/li.strolch.model/src/main/java/li/strolch/model/query/Navigation.java
new file mode 100644
index 000000000..b184bdd02
--- /dev/null
+++ b/li.strolch.model/src/main/java/li/strolch/model/query/Navigation.java
@@ -0,0 +1,24 @@
+/*
+ * 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.model.query;
+
+/**
+ * @author Robert von Burg
+ */
+public interface Navigation {
+
+ public void accept(QueryVisitor visitor);
+}
diff --git a/li.strolch.model/src/main/java/li/strolch/model/query/NotSelection.java b/li.strolch.model/src/main/java/li/strolch/model/query/NotSelection.java
new file mode 100644
index 000000000..a6ea2e0cf
--- /dev/null
+++ b/li.strolch.model/src/main/java/li/strolch/model/query/NotSelection.java
@@ -0,0 +1,47 @@
+/*
+ * 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.model.query;
+
+/**
+ * @author Robert von Burg
+ */
+public class NotSelection extends BooleanSelection {
+
+ /**
+ * @param selection
+ */
+ public NotSelection(Selection selection) {
+ super(selection);
+ }
+
+ /**
+ * @throws UnsupportedOperationException
+ * because a {@link NotSelection} can only work on a single {@link Selection}
+ */
+ @Override
+ public NotSelection with(Selection selection) {
+ throw new UnsupportedOperationException("NotSelection can only have a single selection"); //$NON-NLS-1$
+ }
+
+ public Selection getSelection() {
+ return this.selections.get(0);
+ }
+
+ @Override
+ public void accept(QueryVisitor visitor) {
+ visitor.visitNot(this);
+ }
+}
diff --git a/li.strolch.model/src/main/java/li/strolch/model/query/OrSelection.java b/li.strolch.model/src/main/java/li/strolch/model/query/OrSelection.java
new file mode 100644
index 000000000..e2b0d582c
--- /dev/null
+++ b/li.strolch.model/src/main/java/li/strolch/model/query/OrSelection.java
@@ -0,0 +1,60 @@
+/*
+ * 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.model.query;
+
+import java.util.List;
+
+/**
+ * @author Robert von Burg
+ */
+public class OrSelection extends BooleanSelection {
+
+ public OrSelection() {
+ super();
+ }
+
+ public OrSelection(List selections) {
+ super(selections);
+ }
+
+ @SafeVarargs
+ public OrSelection(Selection... selections) {
+ super(selections);
+ }
+
+ @Override
+ public OrSelection with(Selection selection) {
+ super.with(selection);
+ return this;
+ }
+
+ @Override
+ public OrSelection with(List selections) {
+ super.with(selections);
+ return this;
+ }
+
+ @Override
+ public OrSelection with(Selection... selections) {
+ super.with(selections);
+ return this;
+ }
+
+ @Override
+ public void accept(QueryVisitor visitor) {
+ visitor.visitOr(this);
+ }
+}
diff --git a/li.strolch.model/src/main/java/li/strolch/model/query/OrderQuery.java b/li.strolch.model/src/main/java/li/strolch/model/query/OrderQuery.java
new file mode 100644
index 000000000..b7d3347c9
--- /dev/null
+++ b/li.strolch.model/src/main/java/li/strolch/model/query/OrderQuery.java
@@ -0,0 +1,62 @@
+/*
+ * 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.model.query;
+
+import li.strolch.model.Order;
+import li.strolch.model.OrderVisitor;
+import li.strolch.model.parameter.Parameter;
+
+/**
+ * {@link OrderQuery} is the user API to query {@link Order Orders} in Strolch. The {@link Navigation} is used to
+ * navigate to a type of order on which any further {@link Selection Selections} will be performed. The
+ * {@link OrderVisitor} is used to transform the returned object into a domain specific object (if required). This
+ * mechanism allows you to query only the values of a {@link Parameter} instead of having to return all the elements and
+ * then performing this transformation.
+ *
+ * @author Robert von Burg
+ */
+public class OrderQuery extends StrolchElementQuery {
+
+ public OrderQuery(Navigation navigation) {
+ super(navigation);
+ }
+
+ @Override
+ public OrderQuery with(Selection selection) {
+ super.with(selection);
+ return this;
+ }
+
+ @Override
+ public OrderQuery not(Selection selection) {
+ super.not(selection);
+ return this;
+ }
+
+ @Override
+ public OrderQuery withAny() {
+ super.withAny();
+ return this;
+ }
+
+ public static OrderQuery query(Navigation navigation) {
+ return new OrderQuery(navigation);
+ }
+
+ public static OrderQuery query(String type) {
+ return new OrderQuery(new StrolchTypeNavigation(type));
+ }
+}
diff --git a/li.strolch.model/src/main/java/li/strolch/model/query/OrderQueryVisitor.java b/li.strolch.model/src/main/java/li/strolch/model/query/OrderQueryVisitor.java
new file mode 100644
index 000000000..91196a0f3
--- /dev/null
+++ b/li.strolch.model/src/main/java/li/strolch/model/query/OrderQueryVisitor.java
@@ -0,0 +1,25 @@
+/*
+ * 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.model.query;
+
+/**
+ * @author Robert von Burg
+ *
+ */
+public interface OrderQueryVisitor extends OrderSelectionVisitor, ParameterSelectionVisitor {
+
+ // marker interface
+}
diff --git a/li.strolch.model/src/main/java/li/strolch/model/query/OrderSelection.java b/li.strolch.model/src/main/java/li/strolch/model/query/OrderSelection.java
new file mode 100644
index 000000000..4a904d612
--- /dev/null
+++ b/li.strolch.model/src/main/java/li/strolch/model/query/OrderSelection.java
@@ -0,0 +1,35 @@
+/*
+ * 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.model.query;
+
+/**
+ * @author Robert von Burg
+ *
+ */
+public abstract class OrderSelection implements Selection {
+
+ @Override
+ public void accept(QueryVisitor visitor) {
+ accept((OrderSelectionVisitor) visitor);
+ }
+
+ @Override
+ public boolean hasSelection() {
+ return true;
+ }
+
+ public abstract void accept(OrderSelectionVisitor visitor);
+}
diff --git a/li.strolch.model/src/main/java/li/strolch/model/query/OrderSelectionVisitor.java b/li.strolch.model/src/main/java/li/strolch/model/query/OrderSelectionVisitor.java
new file mode 100644
index 000000000..6f3c36349
--- /dev/null
+++ b/li.strolch.model/src/main/java/li/strolch/model/query/OrderSelectionVisitor.java
@@ -0,0 +1,27 @@
+/*
+ * 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.model.query;
+
+/**
+ * @author Robert von Burg
+ *
+ */
+public interface OrderSelectionVisitor extends StrolchRootElementSelectionVisitor {
+
+ public void visit(DateSelection selection);
+
+ public void visit(StateSelection selection);
+}
diff --git a/li.strolch.model/src/main/java/li/strolch/model/query/ParameterBagSelection.java b/li.strolch.model/src/main/java/li/strolch/model/query/ParameterBagSelection.java
new file mode 100644
index 000000000..c1910d2ea
--- /dev/null
+++ b/li.strolch.model/src/main/java/li/strolch/model/query/ParameterBagSelection.java
@@ -0,0 +1,71 @@
+/*
+ * 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.model.query;
+
+/**
+ * @author Robert von Burg
+ */
+public class ParameterBagSelection implements Selection {
+
+ private String bagKey;
+
+ public ParameterBagSelection(String bagKey) {
+ this.bagKey = bagKey;
+ }
+
+ /**
+ * @return the bagKey
+ */
+ public String getBagKey() {
+ return this.bagKey;
+ }
+
+ @Override
+ public boolean hasSelection() {
+ return true;
+ }
+
+ @Override
+ public void accept(QueryVisitor visitor) {
+ accept((StrolchRootElementSelectionVisitor) visitor);
+ }
+
+ public void accept(StrolchRootElementSelectionVisitor visitor) {
+ visitor.visit(this);
+ }
+
+ @SuppressWarnings("nls")
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append(getClass().getSimpleName() + " [bagKey=");
+ builder.append(this.bagKey);
+ builder.append("]");
+ return builder.toString();
+ }
+
+ public static class NullParameterBagSelection extends ParameterBagSelection {
+
+ public NullParameterBagSelection(String bagKey) {
+ super(bagKey);
+ }
+
+ @Override
+ public void accept(StrolchRootElementSelectionVisitor visitor) {
+ visitor.visit(this);
+ }
+ }
+}
diff --git a/li.strolch.model/src/main/java/li/strolch/model/query/ParameterSelection.java b/li.strolch.model/src/main/java/li/strolch/model/query/ParameterSelection.java
new file mode 100644
index 000000000..d6742d54c
--- /dev/null
+++ b/li.strolch.model/src/main/java/li/strolch/model/query/ParameterSelection.java
@@ -0,0 +1,288 @@
+/*
+ * 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.model.query;
+
+import java.util.Date;
+import java.util.List;
+
+import ch.eitchnet.utils.StringMatchMode;
+import ch.eitchnet.utils.dbc.DBC;
+
+/**
+ * @author Robert von Burg
+ */
+public abstract class ParameterSelection implements Selection {
+
+ private String bagKey;
+ private String paramKey;
+
+ public ParameterSelection(String bagKey, String paramKey) {
+ this.bagKey = bagKey;
+ this.paramKey = paramKey;
+ }
+
+ /**
+ * @return the bagKey
+ */
+ public String getBagKey() {
+ return this.bagKey;
+ }
+
+ /**
+ * @return the paramKey
+ */
+ public String getParamKey() {
+ return this.paramKey;
+ }
+
+ @Override
+ public boolean hasSelection() {
+ return true;
+ }
+
+ @Override
+ public void accept(QueryVisitor visitor) {
+ accept((ParameterSelectionVisitor) visitor);
+ }
+
+ @SuppressWarnings("nls")
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append(getClass().getSimpleName() + " [bagKey=");
+ builder.append(this.bagKey);
+ builder.append(", paramKey=");
+ builder.append(this.paramKey);
+ builder.append("]");
+ return builder.toString();
+ }
+
+ public abstract void accept(ParameterSelectionVisitor visitor);
+
+ public static StringParameterSelection stringSelection(String bagKey, String paramKey, String value,
+ StringMatchMode matchMode) {
+ return new StringParameterSelection(bagKey, paramKey, value, matchMode);
+ }
+
+ public static IntegerParameterSelection integerSelection(String bagKey, String paramKey, int value) {
+ return new IntegerParameterSelection(bagKey, paramKey, value);
+ }
+
+ public static BooleanParameterSelection booleanSelection(String bagKey, String paramKey, boolean value) {
+ return new BooleanParameterSelection(bagKey, paramKey, value);
+ }
+
+ public static FloatParameterSelection floatSelection(String bagKey, String paramKey, double value) {
+ return new FloatParameterSelection(bagKey, paramKey, value);
+ }
+
+ public static LongParameterSelection longSelection(String bagKey, String paramKey, long value) {
+ return new LongParameterSelection(bagKey, paramKey, value);
+ }
+
+ public static DateParameterSelection dateSelection(String bagKey, String paramKey, Date value) {
+ return new DateParameterSelection(bagKey, paramKey, value);
+ }
+
+ public static DateRangeParameterSelection dateRangeSelection(String bagKey, String paramKey, Date from, Date to) {
+ return new DateRangeParameterSelection(bagKey, paramKey, from, to);
+ }
+
+ public static StringListParameterSelection stringListSelection(String bagKey, String paramKey, List value) {
+ return new StringListParameterSelection(bagKey, paramKey, value);
+ }
+
+ public static NullParameterSelection nullSelection(String bagKey, String paramKey) {
+ return new NullParameterSelection(bagKey, paramKey);
+ }
+
+ public static class NullParameterSelection extends ParameterSelection {
+
+ public NullParameterSelection(String bagKey, String paramKey) {
+ super(bagKey, paramKey);
+ }
+
+ @Override
+ public void accept(ParameterSelectionVisitor visitor) {
+ visitor.visit(this);
+ }
+ }
+
+ public static class StringParameterSelection extends ParameterSelection {
+
+ private StringMatchMode matchMode;
+ private String value;
+
+ public StringParameterSelection(String bagKey, String paramKey, String value, StringMatchMode matchMode) {
+ super(bagKey, paramKey);
+ this.value = value;
+ this.matchMode = matchMode;
+ }
+
+ public String getValue() {
+ return this.value;
+ }
+
+ public StringMatchMode getMatchMode() {
+ return this.matchMode;
+ }
+
+ @Override
+ public void accept(ParameterSelectionVisitor visitor) {
+ visitor.visit(this);
+ }
+ }
+
+ public static class IntegerParameterSelection extends ParameterSelection {
+
+ private Integer value;
+
+ public IntegerParameterSelection(String bagKey, String paramKey, Integer value) {
+ super(bagKey, paramKey);
+ this.value = value;
+ }
+
+ public Integer getValue() {
+ return this.value;
+ }
+
+ @Override
+ public void accept(ParameterSelectionVisitor visitor) {
+ visitor.visit(this);
+ }
+ }
+
+ public static class BooleanParameterSelection extends ParameterSelection {
+
+ private Boolean value;
+
+ public BooleanParameterSelection(String bagKey, String paramKey, Boolean value) {
+ super(bagKey, paramKey);
+ this.value = value;
+ }
+
+ public Boolean getValue() {
+ return this.value;
+ }
+
+ @Override
+ public void accept(ParameterSelectionVisitor visitor) {
+ visitor.visit(this);
+ }
+ }
+
+ public static class LongParameterSelection extends ParameterSelection {
+
+ private Long value;
+
+ public LongParameterSelection(String bagKey, String paramKey, Long value) {
+ super(bagKey, paramKey);
+ this.value = value;
+ }
+
+ public Long getValue() {
+ return this.value;
+ }
+
+ @Override
+ public void accept(ParameterSelectionVisitor visitor) {
+ visitor.visit(this);
+ }
+ }
+
+ public static class FloatParameterSelection extends ParameterSelection {
+
+ private Double value;
+
+ public FloatParameterSelection(String bagKey, String paramKey, Double value) {
+ super(bagKey, paramKey);
+ this.value = value;
+ }
+
+ public Double getValue() {
+ return this.value;
+ }
+
+ @Override
+ public void accept(ParameterSelectionVisitor visitor) {
+ visitor.visit(this);
+ }
+ }
+
+ public static class DateParameterSelection extends ParameterSelection {
+
+ private Date value;
+
+ public DateParameterSelection(String bagKey, String paramKey, Date value) {
+ super(bagKey, paramKey);
+ this.value = value;
+ }
+
+ public Date getValue() {
+ return this.value;
+ }
+
+ @Override
+ public void accept(ParameterSelectionVisitor visitor) {
+ visitor.visit(this);
+ }
+ }
+
+ public static class DateRangeParameterSelection extends ParameterSelection {
+
+ private Date from;
+ private Date to;
+
+ public DateRangeParameterSelection(String bagKey, String paramKey, Date from, Date to) {
+ super(bagKey, paramKey);
+ DBC.PRE.assertFalse("Either 'to' or 'from' must be set! Both can not be null!", from == null && to == null); //$NON-NLS-1$
+ this.from = from;
+ this.to = to;
+ }
+
+ public Date getFrom() {
+ return this.from;
+ }
+
+ public Date getTo() {
+ return this.to;
+ }
+
+ @Override
+ public void accept(ParameterSelectionVisitor visitor) {
+ visitor.visit(this);
+ }
+ }
+
+ public static class StringListParameterSelection extends ParameterSelection {
+
+ private List value;
+
+ public StringListParameterSelection(String bagKey, String paramKey, List value) {
+ super(bagKey, paramKey);
+ this.value = value;
+ }
+
+ public List getValue() {
+ return this.value;
+ }
+
+ @Override
+ public void accept(ParameterSelectionVisitor visitor) {
+ visitor.visit(this);
+ }
+ }
+}
diff --git a/li.strolch.model/src/main/java/li/strolch/model/query/ParameterSelectionVisitor.java b/li.strolch.model/src/main/java/li/strolch/model/query/ParameterSelectionVisitor.java
new file mode 100644
index 000000000..3b53f54f6
--- /dev/null
+++ b/li.strolch.model/src/main/java/li/strolch/model/query/ParameterSelectionVisitor.java
@@ -0,0 +1,50 @@
+/*
+ * 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.model.query;
+
+import li.strolch.model.query.ParameterSelection.BooleanParameterSelection;
+import li.strolch.model.query.ParameterSelection.DateParameterSelection;
+import li.strolch.model.query.ParameterSelection.DateRangeParameterSelection;
+import li.strolch.model.query.ParameterSelection.FloatParameterSelection;
+import li.strolch.model.query.ParameterSelection.IntegerParameterSelection;
+import li.strolch.model.query.ParameterSelection.LongParameterSelection;
+import li.strolch.model.query.ParameterSelection.NullParameterSelection;
+import li.strolch.model.query.ParameterSelection.StringListParameterSelection;
+import li.strolch.model.query.ParameterSelection.StringParameterSelection;
+
+/**
+ * @author Robert von Burg
+ */
+public interface ParameterSelectionVisitor extends QueryVisitor {
+
+ public void visit(StringParameterSelection selection);
+
+ public void visit(IntegerParameterSelection selection);
+
+ public void visit(BooleanParameterSelection selection);
+
+ public void visit(LongParameterSelection selection);
+
+ public void visit(FloatParameterSelection selection);
+
+ public void visit(DateParameterSelection selection);
+
+ public void visit(DateRangeParameterSelection selection);
+
+ public void visit(StringListParameterSelection selection);
+
+ public void visit(NullParameterSelection nullParameterSelection);
+}
diff --git a/li.strolch.model/src/main/java/li/strolch/model/query/QueryVisitor.java b/li.strolch.model/src/main/java/li/strolch/model/query/QueryVisitor.java
new file mode 100644
index 000000000..0209ae2bc
--- /dev/null
+++ b/li.strolch.model/src/main/java/li/strolch/model/query/QueryVisitor.java
@@ -0,0 +1,30 @@
+/*
+ * 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.model.query;
+
+/**
+ * @author Robert von Burg
+ */
+public interface QueryVisitor {
+
+ public void visitAny();
+
+ public void visitAnd(AndSelection andSelection);
+
+ public void visitOr(OrSelection orSelection);
+
+ public void visitNot(NotSelection notSelection);
+}
diff --git a/li.strolch.model/src/main/java/li/strolch/model/query/ResourceQuery.java b/li.strolch.model/src/main/java/li/strolch/model/query/ResourceQuery.java
new file mode 100644
index 000000000..900d2659a
--- /dev/null
+++ b/li.strolch.model/src/main/java/li/strolch/model/query/ResourceQuery.java
@@ -0,0 +1,66 @@
+/*
+ * 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.model.query;
+
+import li.strolch.model.Resource;
+import li.strolch.model.ResourceVisitor;
+import li.strolch.model.parameter.Parameter;
+
+/**
+ * {@link ResourceQuery} is the user API to query {@link Resource Resources} in Strolch. The {@link Navigation} is used
+ * to navigate to a type of resource on which any further {@link Selection Selections} will be performed. The
+ * {@link ResourceVisitor} is used to transform the returned object into a domain specific object (if required). This
+ * mechanism allows you to query only the values of a {@link Parameter} instead of having to return all the elements and
+ * then performing this transformation.
+ *
+ * @author Robert von Burg
+ */
+public class ResourceQuery extends StrolchElementQuery {
+
+ /**
+ * @param navigation
+ * @param elementVisitor
+ */
+ public ResourceQuery(Navigation navigation) {
+ super(navigation);
+ }
+
+ @Override
+ public ResourceQuery with(Selection selection) {
+ super.with(selection);
+ return this;
+ }
+
+ @Override
+ public ResourceQuery not(Selection selection) {
+ super.not(selection);
+ return this;
+ }
+
+ @Override
+ public ResourceQuery withAny() {
+ super.withAny();
+ return this;
+ }
+
+ public static ResourceQuery query(Navigation navigation) {
+ return new ResourceQuery(navigation);
+ }
+
+ public static ResourceQuery query(String type) {
+ return new ResourceQuery(new StrolchTypeNavigation(type));
+ }
+}
diff --git a/li.strolch.model/src/main/java/li/strolch/model/query/ResourceQueryVisitor.java b/li.strolch.model/src/main/java/li/strolch/model/query/ResourceQueryVisitor.java
new file mode 100644
index 000000000..867e0b344
--- /dev/null
+++ b/li.strolch.model/src/main/java/li/strolch/model/query/ResourceQueryVisitor.java
@@ -0,0 +1,24 @@
+/*
+ * 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.model.query;
+
+/**
+ * @author Robert von Burg
+ */
+public interface ResourceQueryVisitor extends StrolchRootElementSelectionVisitor, ParameterSelectionVisitor {
+
+ // marker interface
+}
diff --git a/li.strolch.model/src/main/java/li/strolch/model/query/Selection.java b/li.strolch.model/src/main/java/li/strolch/model/query/Selection.java
new file mode 100644
index 000000000..7d720035e
--- /dev/null
+++ b/li.strolch.model/src/main/java/li/strolch/model/query/Selection.java
@@ -0,0 +1,26 @@
+/*
+ * 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.model.query;
+
+/**
+ * @author Robert von Burg
+ */
+public interface Selection {
+
+ public void accept(QueryVisitor visitor);
+
+ public boolean hasSelection();
+}
diff --git a/li.strolch.model/src/main/java/li/strolch/model/query/StateSelection.java b/li.strolch.model/src/main/java/li/strolch/model/query/StateSelection.java
new file mode 100644
index 000000000..8c4aae742
--- /dev/null
+++ b/li.strolch.model/src/main/java/li/strolch/model/query/StateSelection.java
@@ -0,0 +1,39 @@
+/*
+ * 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.model.query;
+
+import li.strolch.model.State;
+
+/**
+ * @author Robert von Burg
+ */
+public class StateSelection extends OrderSelection {
+
+ private State state;
+
+ public StateSelection(State state) {
+ this.state = state;
+ }
+
+ public State getState() {
+ return this.state;
+ }
+
+ @Override
+ public void accept(OrderSelectionVisitor visitor) {
+ visitor.visit(this);
+ }
+}
diff --git a/li.strolch.model/src/main/java/li/strolch/model/query/StringSelection.java b/li.strolch.model/src/main/java/li/strolch/model/query/StringSelection.java
new file mode 100644
index 000000000..f5fa5d39a
--- /dev/null
+++ b/li.strolch.model/src/main/java/li/strolch/model/query/StringSelection.java
@@ -0,0 +1,85 @@
+/*
+ * 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.model.query;
+
+import ch.eitchnet.utils.StringMatchMode;
+
+/**
+ * @author Robert von Burg
+ */
+public class StringSelection {
+
+ private StringMatchMode matchMode;
+ private String[] values;
+
+ public StringSelection() {
+ //
+ }
+
+ /**
+ * @param matchMode
+ * @param values
+ */
+ public StringSelection(StringMatchMode matchMode, String[] values) {
+ this.matchMode = matchMode;
+ this.values = values;
+ }
+
+ /**
+ * @return the matchMode
+ */
+ public StringMatchMode getMatchMode() {
+ return this.matchMode;
+ }
+
+ /**
+ * @param matchMode
+ * the matchMode to set
+ */
+ public void setMatchMode(StringMatchMode matchMode) {
+ this.matchMode = matchMode;
+ }
+
+ /**
+ * @return the values
+ */
+ public String[] getValues() {
+ return this.values;
+ }
+
+ /**
+ * @param values
+ * the values to set
+ */
+ public void setValues(String... values) {
+ this.values = values;
+ }
+
+ /**
+ * @return
+ */
+ public boolean isWildCard() {
+ return this.values == null || this.values.length == 0;
+ }
+
+ public boolean matches(String value) {
+ for (String sel : this.values) {
+ if (this.matchMode.matches(value, sel))
+ return true;
+ }
+ return false;
+ }
+}
diff --git a/li.strolch.model/src/main/java/li/strolch/model/query/StrolchElementQuery.java b/li.strolch.model/src/main/java/li/strolch/model/query/StrolchElementQuery.java
new file mode 100644
index 000000000..78c429815
--- /dev/null
+++ b/li.strolch.model/src/main/java/li/strolch/model/query/StrolchElementQuery.java
@@ -0,0 +1,103 @@
+/*
+ * 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.model.query;
+
+import ch.eitchnet.utils.dbc.DBC;
+
+/**
+ * @author Robert von Burg
+ */
+public abstract class StrolchElementQuery implements StrolchQuery {
+
+ private Navigation navigation;
+ private Selection selection;
+
+ public StrolchElementQuery(Navigation navigation) {
+ this.navigation = navigation;
+ }
+
+ public boolean hasNavigation() {
+ return this.navigation != null;
+ }
+
+ public boolean hasSelection() {
+ return this.selection != null && this.selection.hasSelection();
+ }
+
+ public Selection getSelection() {
+ return this.selection;
+ }
+
+ public StrolchElementQuery with(Selection selection) {
+ assertNoSelectionYetSet();
+ this.selection = selection;
+ return this;
+ }
+
+ private void assertNoSelectionYetSet() {
+ String msg = "A selection is already set! Use a cascaded boolean operators to perform multiple selections"; //$NON-NLS-1$
+ DBC.PRE.assertNull(msg, this.selection);
+ }
+
+ public StrolchElementQuery withAny() {
+ assertNoSelectionYetSet();
+ this.selection = new AnySelection();
+ return this;
+ }
+
+ public AndSelection and() {
+ assertNoSelectionYetSet();
+ AndSelection and = new AndSelection();
+ this.selection = and;
+ return and;
+ }
+
+ public OrSelection or() {
+ assertNoSelectionYetSet();
+ OrSelection or = new OrSelection();
+ this.selection = or;
+ return or;
+ }
+
+ public StrolchElementQuery not(Selection selection) {
+ assertNoSelectionYetSet();
+ this.selection = new NotSelection(selection);
+ return this;
+ }
+
+ public void accept(T visitor) {
+ DBC.PRE.assertNotNull("No navigation set!", this.navigation); //$NON-NLS-1$
+ DBC.PRE.assertNotNull("No selection defined!", this.selection); //$NON-NLS-1$
+ this.navigation.accept(visitor);
+ this.selection.accept(visitor);
+ }
+
+ /**
+ * @see ch.eitchnet.privilege.model.Restrictable#getPrivilegeName()
+ */
+ @Override
+ public String getPrivilegeName() {
+ return StrolchQuery.class.getName();
+ }
+
+ /**
+ * @see ch.eitchnet.privilege.model.Restrictable#getPrivilegeValue()
+ */
+ @Override
+ public Object getPrivilegeValue() {
+ return getClass().getName();
+ }
+}
diff --git a/li.strolch.model/src/main/java/li/strolch/model/query/StrolchElementSelection.java b/li.strolch.model/src/main/java/li/strolch/model/query/StrolchElementSelection.java
new file mode 100644
index 000000000..0d33dc4bc
--- /dev/null
+++ b/li.strolch.model/src/main/java/li/strolch/model/query/StrolchElementSelection.java
@@ -0,0 +1,34 @@
+/*
+ * 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.model.query;
+
+/**
+ * @author Robert von Burg
+ */
+public abstract class StrolchElementSelection implements Selection {
+
+ @Override
+ public void accept(QueryVisitor visitor) {
+ accept((StrolchElementSelectionVisitor) visitor);
+ }
+
+ @Override
+ public boolean hasSelection() {
+ return true;
+ }
+
+ public abstract void accept(StrolchElementSelectionVisitor visitor);
+}
diff --git a/li.strolch.model/src/main/java/li/strolch/model/query/StrolchElementSelectionVisitor.java b/li.strolch.model/src/main/java/li/strolch/model/query/StrolchElementSelectionVisitor.java
new file mode 100644
index 000000000..b7bf67fdb
--- /dev/null
+++ b/li.strolch.model/src/main/java/li/strolch/model/query/StrolchElementSelectionVisitor.java
@@ -0,0 +1,28 @@
+/*
+ * 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.model.query;
+
+/**
+ * @author Robert von Burg
+ */
+public interface StrolchElementSelectionVisitor extends QueryVisitor {
+
+ public void visit(StrolchTypeNavigation navigation);
+
+ public void visit(IdSelection selection);
+
+ public void visit(NameSelection selection);
+}
diff --git a/li.strolch.model/src/main/java/li/strolch/model/query/StrolchQuery.java b/li.strolch.model/src/main/java/li/strolch/model/query/StrolchQuery.java
new file mode 100644
index 000000000..018e3b9e4
--- /dev/null
+++ b/li.strolch.model/src/main/java/li/strolch/model/query/StrolchQuery.java
@@ -0,0 +1,26 @@
+/*
+ * 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.model.query;
+
+import ch.eitchnet.privilege.model.Restrictable;
+
+/**
+ * @author Robert von Burg
+ */
+public interface StrolchQuery extends Restrictable {
+
+ // marker interface
+}
diff --git a/li.strolch.model/src/main/java/li/strolch/model/query/StrolchRootElementSelectionVisitor.java b/li.strolch.model/src/main/java/li/strolch/model/query/StrolchRootElementSelectionVisitor.java
new file mode 100644
index 000000000..3a2c3cace
--- /dev/null
+++ b/li.strolch.model/src/main/java/li/strolch/model/query/StrolchRootElementSelectionVisitor.java
@@ -0,0 +1,28 @@
+/*
+ * 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.model.query;
+
+import li.strolch.model.query.ParameterBagSelection.NullParameterBagSelection;
+
+/**
+ * @author Robert von Burg
+ */
+public interface StrolchRootElementSelectionVisitor extends StrolchElementSelectionVisitor {
+
+ public void visit(ParameterBagSelection selection);
+
+ public void visit(NullParameterBagSelection selection);
+}
diff --git a/li.strolch.model/src/main/java/li/strolch/model/query/StrolchTypeNavigation.java b/li.strolch.model/src/main/java/li/strolch/model/query/StrolchTypeNavigation.java
new file mode 100644
index 000000000..a4f7c9fa2
--- /dev/null
+++ b/li.strolch.model/src/main/java/li/strolch/model/query/StrolchTypeNavigation.java
@@ -0,0 +1,44 @@
+/*
+ * 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.model.query;
+
+/**
+ * @author Robert von Burg