diff options
Diffstat (limited to 'src/main/java/org')
81 files changed, 2955 insertions, 2955 deletions
diff --git a/src/main/java/org/eclipse/mdm/api/base/BaseApplicationContext.java b/src/main/java/org/eclipse/mdm/api/base/BaseApplicationContext.java index 3d961fd..dbbc1ff 100644 --- a/src/main/java/org/eclipse/mdm/api/base/BaseApplicationContext.java +++ b/src/main/java/org/eclipse/mdm/api/base/BaseApplicationContext.java @@ -1,16 +1,16 @@ -/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
+/******************************************************************************** + * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ package org.eclipse.mdm.api.base; diff --git a/src/main/java/org/eclipse/mdm/api/base/BaseApplicationContextFactory.java b/src/main/java/org/eclipse/mdm/api/base/BaseApplicationContextFactory.java index e1ad5b6..a62abbb 100644 --- a/src/main/java/org/eclipse/mdm/api/base/BaseApplicationContextFactory.java +++ b/src/main/java/org/eclipse/mdm/api/base/BaseApplicationContextFactory.java @@ -1,16 +1,16 @@ -/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
+/******************************************************************************** + * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ package org.eclipse.mdm.api.base; diff --git a/src/main/java/org/eclipse/mdm/api/base/ConnectionException.java b/src/main/java/org/eclipse/mdm/api/base/ConnectionException.java index b4d0d78..0c9b781 100644 --- a/src/main/java/org/eclipse/mdm/api/base/ConnectionException.java +++ b/src/main/java/org/eclipse/mdm/api/base/ConnectionException.java @@ -1,16 +1,16 @@ -/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
+/******************************************************************************** + * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ package org.eclipse.mdm.api.base; diff --git a/src/main/java/org/eclipse/mdm/api/base/ServiceNotProvidedException.java b/src/main/java/org/eclipse/mdm/api/base/ServiceNotProvidedException.java index 5e7c9d0..220a435 100644 --- a/src/main/java/org/eclipse/mdm/api/base/ServiceNotProvidedException.java +++ b/src/main/java/org/eclipse/mdm/api/base/ServiceNotProvidedException.java @@ -1,32 +1,32 @@ -/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
-
-package org.eclipse.mdm.api.base;
-
-/**
- * This exception indicates that a service is not provided by an adapter.
- */
-public class ServiceNotProvidedException extends RuntimeException {
-
- private static final long serialVersionUID = -4829618036958929415L;
-
- /**
- * Constructor.
- *
- * @param clazz the service that is not provided
- */
- public ServiceNotProvidedException(Class<?> clazz) {
- super("The service '" + clazz + "' is not implemented!");
- }
-}
+/******************************************************************************** + * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ + +package org.eclipse.mdm.api.base; + +/** + * This exception indicates that a service is not provided by an adapter. + */ +public class ServiceNotProvidedException extends RuntimeException { + + private static final long serialVersionUID = -4829618036958929415L; + + /** + * Constructor. + * + * @param clazz the service that is not provided + */ + public ServiceNotProvidedException(Class<?> clazz) { + super("The service '" + clazz + "' is not implemented!"); + } +} diff --git a/src/main/java/org/eclipse/mdm/api/base/Transaction.java b/src/main/java/org/eclipse/mdm/api/base/Transaction.java index e1ebb64..a521198 100644 --- a/src/main/java/org/eclipse/mdm/api/base/Transaction.java +++ b/src/main/java/org/eclipse/mdm/api/base/Transaction.java @@ -1,105 +1,105 @@ -/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
-
-
-package org.eclipse.mdm.api.base;
-
-import java.util.Collection;
-
-import org.eclipse.mdm.api.base.massdata.WriteRequest;
-import org.eclipse.mdm.api.base.model.Deletable;
-import org.eclipse.mdm.api.base.model.Entity;
-import org.eclipse.mdm.api.base.model.MeasuredValues;
-import org.eclipse.mdm.api.base.query.DataAccessException;
-
-/**
- * Provides business layer write operations (CREATE, UPDATE, DELETE).
- *
- * @since 1.0.0
- * @author Viktor Stoehr, Gigatronik Ingolstadt GmbH
- */
-public interface Transaction {
-
- // ======================================================================
- // Public methods
- // ======================================================================
-
- // TODO: it should be possible to a attach a listener
- // -> progress notification updates while uploading files
- // -> any other useful informations?!
-
- /**
- * Persists given entities and implicitly updates their instance IDs.
- *
- * @param <T>
- * Most common type of the given entities.
- * @param entities
- * Entities that will be persisted.
- * @throws DataAccessException
- * Thrown in case of errors while writing entities.
- */
- <T extends Entity> void create(Collection<T> entities) throws DataAccessException;
-
- /**
- * Updates given entities.
- *
- * @param <T>
- * Most common type of the given entities.
- * @param entities
- * Entities that will be updated.
- * @throws DataAccessException
- * Thrown in case of errors while writing entities.
- */
- <T extends Entity> void update(Collection<T> entities) throws DataAccessException;
-
- /**
- * Deletes given entities. Related children will be searched and
- * automatically removed.
- *
- * @param <T>
- * Most common type of the given entities.
- * @param entities
- * Entities that will be deleted (including their children).
- * @throws DataAccessException
- * Thrown in case of errors while deleting entities.
- */
- <T extends Deletable> void delete(Collection<T> entities) throws DataAccessException;
-
- /**
- * Creates {@link MeasuredValues} as specified by the given
- * {@link WriteRequest}s.
- *
- * @param writeRequests
- * Provides all required informations to process the request.
- * @throws DataAccessException
- * Thrown if unable to create specified measured values.
- */
- void writeMeasuredValues(Collection<WriteRequest> writeRequests) throws DataAccessException;
-
- /**
- * Commit this transaction. Any changes made within this transaction become
- * permanent.
- *
- * @throws DataAccessException
- * Thrown if unable to commit this transaction.
- */
- void commit() throws DataAccessException;
-
- /**
- * Aborts (rollback) this transaction. Any changes made within this
- * transaction will be lost.
- */
- void abort();
-
-}
+/******************************************************************************** + * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ + + +package org.eclipse.mdm.api.base; + +import java.util.Collection; + +import org.eclipse.mdm.api.base.massdata.WriteRequest; +import org.eclipse.mdm.api.base.model.Deletable; +import org.eclipse.mdm.api.base.model.Entity; +import org.eclipse.mdm.api.base.model.MeasuredValues; +import org.eclipse.mdm.api.base.query.DataAccessException; + +/** + * Provides business layer write operations (CREATE, UPDATE, DELETE). + * + * @since 1.0.0 + * @author Viktor Stoehr, Gigatronik Ingolstadt GmbH + */ +public interface Transaction { + + // ====================================================================== + // Public methods + // ====================================================================== + + // TODO: it should be possible to a attach a listener + // -> progress notification updates while uploading files + // -> any other useful informations?! + + /** + * Persists given entities and implicitly updates their instance IDs. + * + * @param <T> + * Most common type of the given entities. + * @param entities + * Entities that will be persisted. + * @throws DataAccessException + * Thrown in case of errors while writing entities. + */ + <T extends Entity> void create(Collection<T> entities) throws DataAccessException; + + /** + * Updates given entities. + * + * @param <T> + * Most common type of the given entities. + * @param entities + * Entities that will be updated. + * @throws DataAccessException + * Thrown in case of errors while writing entities. + */ + <T extends Entity> void update(Collection<T> entities) throws DataAccessException; + + /** + * Deletes given entities. Related children will be searched and + * automatically removed. + * + * @param <T> + * Most common type of the given entities. + * @param entities + * Entities that will be deleted (including their children). + * @throws DataAccessException + * Thrown in case of errors while deleting entities. + */ + <T extends Deletable> void delete(Collection<T> entities) throws DataAccessException; + + /** + * Creates {@link MeasuredValues} as specified by the given + * {@link WriteRequest}s. + * + * @param writeRequests + * Provides all required informations to process the request. + * @throws DataAccessException + * Thrown if unable to create specified measured values. + */ + void writeMeasuredValues(Collection<WriteRequest> writeRequests) throws DataAccessException; + + /** + * Commit this transaction. Any changes made within this transaction become + * permanent. + * + * @throws DataAccessException + * Thrown if unable to commit this transaction. + */ + void commit() throws DataAccessException; + + /** + * Aborts (rollback) this transaction. Any changes made within this + * transaction will be lost. + */ + void abort(); + +} diff --git a/src/main/java/org/eclipse/mdm/api/base/adapter/Attribute.java b/src/main/java/org/eclipse/mdm/api/base/adapter/Attribute.java index be7cee5..13d39f9 100644 --- a/src/main/java/org/eclipse/mdm/api/base/adapter/Attribute.java +++ b/src/main/java/org/eclipse/mdm/api/base/adapter/Attribute.java @@ -1,16 +1,16 @@ -/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
+/******************************************************************************** + * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ package org.eclipse.mdm.api.base.adapter; diff --git a/src/main/java/org/eclipse/mdm/api/base/adapter/ChildrenStore.java b/src/main/java/org/eclipse/mdm/api/base/adapter/ChildrenStore.java index 3f48249..fd17f93 100644 --- a/src/main/java/org/eclipse/mdm/api/base/adapter/ChildrenStore.java +++ b/src/main/java/org/eclipse/mdm/api/base/adapter/ChildrenStore.java @@ -1,117 +1,117 @@ -/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
-
-package org.eclipse.mdm.api.base.adapter;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.mdm.api.base.model.Deletable;
-
-/**
- * Holds related entities of any kind and keeps track of modifications.
- */
-public final class ChildrenStore {
-
- private final Map<Class<? extends Deletable>, List<? extends Deletable>> current = new HashMap<>(0);
- private final Map<Class<? extends Deletable>, List<? extends Deletable>> removed = new HashMap<>(0);
-
- /**
- * Returns current set of related children mapped by their type.
- *
- * @return Returned {@code Map} is unmodifiable.
- */
- public Map<Class<? extends Deletable>, List<? extends Deletable>> getCurrent() {
- return Collections.unmodifiableMap(current);
- }
-
- /**
- * Returns current set of removed related children mapped by their type.
- *
- * @return Returned {@code Map} is unmodifiable.
- */
- public Map<Class<? extends Deletable>, List<? extends Deletable>> getRemoved() {
- return Collections.unmodifiableMap(removed);
- }
-
- /**
- * Returns related child entities of given type.
- *
- * @param <T>
- * Desired entity type.
- * @param entityClass
- * Used as identifier.
- * @return Returned {@code List} is unmodifiable.
- */
- @SuppressWarnings("unchecked")
- public <T extends Deletable> List<T> get(Class<T> entityClass) {
- return Collections.unmodifiableList((List<T>) current.computeIfAbsent(entityClass, k -> new ArrayList<>()));
- }
-
- /**
- * Sorts the child entities with given {@code Comparator}.
- *
- * @param <T>
- * Desired entity type.
- * @param entityClass
- * Used as identifier.
- * @param comparator
- * Used for sorting.
- */
- @SuppressWarnings("unchecked")
- public <T extends Deletable> void sort(Class<T> entityClass, Comparator<? super T> comparator) {
- List<T> children = (List<T>) current.get(entityClass);
- if (children != null) {
- children.sort(comparator);
- }
- }
-
- /**
- * Adds given child entity.
- *
- * @param child
- * The new child.
- */
- @SuppressWarnings("unchecked")
- public void add(Deletable child) {
- removed.getOrDefault(child.getClass(), new ArrayList<>()).remove(child);
- ((List<Deletable>) current.computeIfAbsent(child.getClass(), k -> new ArrayList<>())).add(child);
- }
-
- /**
- * Removes given child entity.
- *
- * @param child
- * The child which will be removed.
- */
- @SuppressWarnings("unchecked")
- public void remove(Deletable child) {
- List<Deletable> children = (List<Deletable>) current.getOrDefault(child.getClass(), new ArrayList<>());
- if (children.remove(child) && child.getID() != null && child.getID().length() > 0) {
- ((List<Deletable>) removed.computeIfAbsent(child.getClass(), k -> new ArrayList<>())).add(child);
- }
- }
-
- /**
- * Clean up list of removed entities.
- */
- void apply() {
- removed.clear();
- }
-
+/******************************************************************************** + * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ + +package org.eclipse.mdm.api.base.adapter; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.eclipse.mdm.api.base.model.Deletable; + +/** + * Holds related entities of any kind and keeps track of modifications. + */ +public final class ChildrenStore { + + private final Map<Class<? extends Deletable>, List<? extends Deletable>> current = new HashMap<>(0); + private final Map<Class<? extends Deletable>, List<? extends Deletable>> removed = new HashMap<>(0); + + /** + * Returns current set of related children mapped by their type. + * + * @return Returned {@code Map} is unmodifiable. + */ + public Map<Class<? extends Deletable>, List<? extends Deletable>> getCurrent() { + return Collections.unmodifiableMap(current); + } + + /** + * Returns current set of removed related children mapped by their type. + * + * @return Returned {@code Map} is unmodifiable. + */ + public Map<Class<? extends Deletable>, List<? extends Deletable>> getRemoved() { + return Collections.unmodifiableMap(removed); + } + + /** + * Returns related child entities of given type. + * + * @param <T> + * Desired entity type. + * @param entityClass + * Used as identifier. + * @return Returned {@code List} is unmodifiable. + */ + @SuppressWarnings("unchecked") + public <T extends Deletable> List<T> get(Class<T> entityClass) { + return Collections.unmodifiableList((List<T>) current.computeIfAbsent(entityClass, k -> new ArrayList<>())); + } + + /** + * Sorts the child entities with given {@code Comparator}. + * + * @param <T> + * Desired entity type. + * @param entityClass + * Used as identifier. + * @param comparator + * Used for sorting. + */ + @SuppressWarnings("unchecked") + public <T extends Deletable> void sort(Class<T> entityClass, Comparator<? super T> comparator) { + List<T> children = (List<T>) current.get(entityClass); + if (children != null) { + children.sort(comparator); + } + } + + /** + * Adds given child entity. + * + * @param child + * The new child. + */ + @SuppressWarnings("unchecked") + public void add(Deletable child) { + removed.getOrDefault(child.getClass(), new ArrayList<>()).remove(child); + ((List<Deletable>) current.computeIfAbsent(child.getClass(), k -> new ArrayList<>())).add(child); + } + + /** + * Removes given child entity. + * + * @param child + * The child which will be removed. + */ + @SuppressWarnings("unchecked") + public void remove(Deletable child) { + List<Deletable> children = (List<Deletable>) current.getOrDefault(child.getClass(), new ArrayList<>()); + if (children.remove(child) && child.getID() != null && child.getID().length() > 0) { + ((List<Deletable>) removed.computeIfAbsent(child.getClass(), k -> new ArrayList<>())).add(child); + } + } + + /** + * Clean up list of removed entities. + */ + void apply() { + removed.clear(); + } + }
\ No newline at end of file diff --git a/src/main/java/org/eclipse/mdm/api/base/adapter/EntityStore.java b/src/main/java/org/eclipse/mdm/api/base/adapter/EntityStore.java index 42826a9..c2b5918 100644 --- a/src/main/java/org/eclipse/mdm/api/base/adapter/EntityStore.java +++ b/src/main/java/org/eclipse/mdm/api/base/adapter/EntityStore.java @@ -1,199 +1,199 @@ -/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
-
-package org.eclipse.mdm.api.base.adapter;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.mdm.api.base.model.ContextType;
-import org.eclipse.mdm.api.base.model.Entity;
-
-/**
- * Holds related entities of any kind and keeps track of modifications.
- */
-public final class EntityStore {
-
- private final Map<String, Entity> current = new HashMap<>(0);
- private final Map<String, Entity> removed = new HashMap<>(0);
-
- /**
- * Returns current set of related entities.
- *
- * @return Returned {@code Collection} is unmodifiable.
- */
- public Collection<Entity> getCurrent() {
- return Collections.unmodifiableCollection(current.values());
- }
-
- /**
- * Returns current set of removed related entities.
- *
- * @return Returned {@code Collection} is unmodifiable.
- */
- public Collection<Entity> getRemoved() {
- return Collections.unmodifiableCollection(removed.values());
- }
-
- /**
- * Returns related entity identified by given entity class.
- *
- * @param <T>
- * The desired entity type.
- * @param entityClass
- * Used as identifier.
- * @return The related entity is returned or null of not defined.
- */
- public <T extends Entity> T get(Class<T> entityClass) {
- return get(entityClass.getSimpleName(), entityClass);
- }
-
- /**
- * Returns related entity identified by given entity class.
- *
- * @param <T>
- * The desired entity type.
- * @param relationName
- * The relation name the entity is referenced by.
- * @param entityClass
- * Used as identifier.
- * @return The related entity is returned or null of not defined.
- */
- public <T extends Entity> T get(String relationName, Class<T> entityClass) {
- return entityClass.cast(current.get(relationName));
- }
-
- /**
- * Replaces a related entity with the given one.
- *
- * @param entity
- * The new related entity.
- */
- public void set(Entity entity) {
- set(entity.getClass().getSimpleName(), entity);
- }
-
- /**
- * Replaces a related entity with the given one.
- *
- * @param name
- * The name of the relation the entity is referenced by.
- * @param entity
- * The new related entity.
- */
- public void set(String name, Entity entity) {
- Entity old = current.put(name, entity);
- if (old != null) {
- removed.put(name, old);
- }
- }
-
- /**
- * Removes a related entity for given entity class.
- *
- * @param entityClass
- * Used as identifier.
- */
- public void remove(Class<? extends Entity> entityClass) {
- String key = entityClass.getSimpleName();
- remove(key, entityClass);
- }
-
- /**
- * Removes a related entity for given relation name and entity class.
- *
- * @param name
- * The name of the relation the entity is referenced by.
- * @param entityClass
- * Used as identifier.
- */
- public void remove(String name, Class<? extends Entity> entityClass) {
- Entity old = current.remove(name);
- if (old != null) {
- removed.put(name, old);
- }
- }
-
- /**
- * Returns related entity identified by given entity class and
- * {@link ContextType}.
- *
- * @param <T>
- * The desired entity type.
- * @param entityClass
- * Used as identifier.
- * @param contextType
- * Used as identifier.
- * @return The related entity is returned or null of not defined.
- */
- public <T extends Entity> T get(Class<T> entityClass, ContextType contextType) {
- return entityClass.cast(current.get(createContextTypeKey(entityClass, contextType)));
- }
-
- /**
- * Replaces a related entity with the given one.
- *
- * @param entity
- * The new related entity.
- * @param contextType
- * Used as identifier.
- */
- public void set(Entity entity, ContextType contextType) {
- String key = createContextTypeKey(entity.getClass(), contextType);
- Entity old = current.put(key, entity);
- if (old != null) {
- removed.put(key, old);
- }
- }
-
- /**
- * Removes a related entity for given entity class and
- * {@link ContextType}.
- *
- * @param entityClass
- * Used as identifier.
- * @param contextType
- * Used as identifier.
- */
- public void remove(Class<? extends Entity> entityClass, ContextType contextType) {
- String key = createContextTypeKey(entityClass, contextType);
- Entity old = current.remove(key);
- if (old != null) {
- removed.put(key, old);
- }
- }
-
- /**
- * Clean up list of removed entities.
- */
- void apply() {
- removed.clear();
- }
-
- /**
- * Generates a key from given entity class and {@link ContextType}.
- *
- * @param entityClass
- * Identifier part 1.
- * @param contextType
- * Identifier part 2.
- * @return A context type dependent key is returned.
- */
- private static String createContextTypeKey(Class<? extends Entity> entityClass, ContextType contextType) {
- return entityClass.getSimpleName() + '_' + contextType;
- }
-
+/******************************************************************************** + * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ + +package org.eclipse.mdm.api.base.adapter; + +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + +import org.eclipse.mdm.api.base.model.ContextType; +import org.eclipse.mdm.api.base.model.Entity; + +/** + * Holds related entities of any kind and keeps track of modifications. + */ +public final class EntityStore { + + private final Map<String, Entity> current = new HashMap<>(0); + private final Map<String, Entity> removed = new HashMap<>(0); + + /** + * Returns current set of related entities. + * + * @return Returned {@code Collection} is unmodifiable. + */ + public Collection<Entity> getCurrent() { + return Collections.unmodifiableCollection(current.values()); + } + + /** + * Returns current set of removed related entities. + * + * @return Returned {@code Collection} is unmodifiable. + */ + public Collection<Entity> getRemoved() { + return Collections.unmodifiableCollection(removed.values()); + } + + /** + * Returns related entity identified by given entity class. + * + * @param <T> + * The desired entity type. + * @param entityClass + * Used as identifier. + * @return The related entity is returned or null of not defined. + */ + public <T extends Entity> T get(Class<T> entityClass) { + return get(entityClass.getSimpleName(), entityClass); + } + + /** + * Returns related entity identified by given entity class. + * + * @param <T> + * The desired entity type. + * @param relationName + * The relation name the entity is referenced by. + * @param entityClass + * Used as identifier. + * @return The related entity is returned or null of not defined. + */ + public <T extends Entity> T get(String relationName, Class<T> entityClass) { + return entityClass.cast(current.get(relationName)); + } + + /** + * Replaces a related entity with the given one. + * + * @param entity + * The new related entity. + */ + public void set(Entity entity) { + set(entity.getClass().getSimpleName(), entity); + } + + /** + * Replaces a related entity with the given one. + * + * @param name + * The name of the relation the entity is referenced by. + * @param entity + * The new related entity. + */ + public void set(String name, Entity entity) { + Entity old = current.put(name, entity); + if (old != null) { + removed.put(name, old); + } + } + + /** + * Removes a related entity for given entity class. + * + * @param entityClass + * Used as identifier. + */ + public void remove(Class<? extends Entity> entityClass) { + String key = entityClass.getSimpleName(); + remove(key, entityClass); + } + + /** + * Removes a related entity for given relation name and entity class. + * + * @param name + * The name of the relation the entity is referenced by. + * @param entityClass + * Used as identifier. + */ + public void remove(String name, Class<? extends Entity> entityClass) { + Entity old = current.remove(name); + if (old != null) { + removed.put(name, old); + } + } + + /** + * Returns related entity identified by given entity class and + * {@link ContextType}. + * + * @param <T> + * The desired entity type. + * @param entityClass + * Used as identifier. + * @param contextType + * Used as identifier. + * @return The related entity is returned or null of not defined. + */ + public <T extends Entity> T get(Class<T> entityClass, ContextType contextType) { + return entityClass.cast(current.get(createContextTypeKey(entityClass, contextType))); + } + + /** + * Replaces a related entity with the given one. + * + * @param entity + * The new related entity. + * @param contextType + * Used as identifier. + */ + public void set(Entity entity, ContextType contextType) { + String key = createContextTypeKey(entity.getClass(), contextType); + Entity old = current.put(key, entity); + if (old != null) { + removed.put(key, old); + } + } + + /** + * Removes a related entity for given entity class and + * {@link ContextType}. + * + * @param entityClass + * Used as identifier. + * @param contextType + * Used as identifier. + */ + public void remove(Class<? extends Entity> entityClass, ContextType contextType) { + String key = createContextTypeKey(entityClass, contextType); + Entity old = current.remove(key); + if (old != null) { + removed.put(key, old); + } + } + + /** + * Clean up list of removed entities. + */ + void apply() { + removed.clear(); + } + + /** + * Generates a key from given entity class and {@link ContextType}. + * + * @param entityClass + * Identifier part 1. + * @param contextType + * Identifier part 2. + * @return A context type dependent key is returned. + */ + private static String createContextTypeKey(Class<? extends Entity> entityClass, ContextType contextType) { + return entityClass.getSimpleName() + '_' + contextType; + } + }
\ No newline at end of file diff --git a/src/main/java/org/eclipse/mdm/api/base/adapter/EntityType.java b/src/main/java/org/eclipse/mdm/api/base/adapter/EntityType.java index 6b118ca..188fdc4 100644 --- a/src/main/java/org/eclipse/mdm/api/base/adapter/EntityType.java +++ b/src/main/java/org/eclipse/mdm/api/base/adapter/EntityType.java @@ -1,16 +1,16 @@ -/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
+/******************************************************************************** + * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ package org.eclipse.mdm.api.base.adapter; diff --git a/src/main/java/org/eclipse/mdm/api/base/adapter/ModelManager.java b/src/main/java/org/eclipse/mdm/api/base/adapter/ModelManager.java index 91c0e0b..55beee7 100644 --- a/src/main/java/org/eclipse/mdm/api/base/adapter/ModelManager.java +++ b/src/main/java/org/eclipse/mdm/api/base/adapter/ModelManager.java @@ -1,16 +1,16 @@ -/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
+/******************************************************************************** + * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ package org.eclipse.mdm.api.base.adapter; diff --git a/src/main/java/org/eclipse/mdm/api/base/adapter/RelationType.java b/src/main/java/org/eclipse/mdm/api/base/adapter/RelationType.java index 5548beb..2857855 100644 --- a/src/main/java/org/eclipse/mdm/api/base/adapter/RelationType.java +++ b/src/main/java/org/eclipse/mdm/api/base/adapter/RelationType.java @@ -1,16 +1,16 @@ -/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
+/******************************************************************************** + * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ package org.eclipse.mdm.api.base.adapter; diff --git a/src/main/java/org/eclipse/mdm/api/base/file/FileService.java b/src/main/java/org/eclipse/mdm/api/base/file/FileService.java index a822dc4..6650c1d 100644 --- a/src/main/java/org/eclipse/mdm/api/base/file/FileService.java +++ b/src/main/java/org/eclipse/mdm/api/base/file/FileService.java @@ -1,16 +1,16 @@ -/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
+/******************************************************************************** + * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ package org.eclipse.mdm.api.base.file; diff --git a/src/main/java/org/eclipse/mdm/api/base/massdata/AnyTypeValuesBuilder.java b/src/main/java/org/eclipse/mdm/api/base/massdata/AnyTypeValuesBuilder.java index 0e68f8b..3ff5b61 100644 --- a/src/main/java/org/eclipse/mdm/api/base/massdata/AnyTypeValuesBuilder.java +++ b/src/main/java/org/eclipse/mdm/api/base/massdata/AnyTypeValuesBuilder.java @@ -1,16 +1,16 @@ -/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
+/******************************************************************************** + * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ package org.eclipse.mdm.api.base.massdata; diff --git a/src/main/java/org/eclipse/mdm/api/base/massdata/BaseValuesBuilder.java b/src/main/java/org/eclipse/mdm/api/base/massdata/BaseValuesBuilder.java index c167111..18da641 100644 --- a/src/main/java/org/eclipse/mdm/api/base/massdata/BaseValuesBuilder.java +++ b/src/main/java/org/eclipse/mdm/api/base/massdata/BaseValuesBuilder.java @@ -1,16 +1,16 @@ -/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
+/******************************************************************************** + * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ package org.eclipse.mdm.api.base.massdata; diff --git a/src/main/java/org/eclipse/mdm/api/base/massdata/ComplexNumericalValuesBuilder.java b/src/main/java/org/eclipse/mdm/api/base/massdata/ComplexNumericalValuesBuilder.java index c1e80f6..fa6aed2 100644 --- a/src/main/java/org/eclipse/mdm/api/base/massdata/ComplexNumericalValuesBuilder.java +++ b/src/main/java/org/eclipse/mdm/api/base/massdata/ComplexNumericalValuesBuilder.java @@ -1,16 +1,16 @@ -/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
+/******************************************************************************** + * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ package org.eclipse.mdm.api.base.massdata; diff --git a/src/main/java/org/eclipse/mdm/api/base/massdata/ExternalComponent.java b/src/main/java/org/eclipse/mdm/api/base/massdata/ExternalComponent.java index ce1f399..f7e5906 100644 --- a/src/main/java/org/eclipse/mdm/api/base/massdata/ExternalComponent.java +++ b/src/main/java/org/eclipse/mdm/api/base/massdata/ExternalComponent.java @@ -1,16 +1,16 @@ -/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
+/******************************************************************************** + * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ package org.eclipse.mdm.api.base.massdata; diff --git a/src/main/java/org/eclipse/mdm/api/base/massdata/NumericalValuesBuilder.java b/src/main/java/org/eclipse/mdm/api/base/massdata/NumericalValuesBuilder.java index 9b5ac5f..49e1445 100644 --- a/src/main/java/org/eclipse/mdm/api/base/massdata/NumericalValuesBuilder.java +++ b/src/main/java/org/eclipse/mdm/api/base/massdata/NumericalValuesBuilder.java @@ -1,16 +1,16 @@ -/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
+/******************************************************************************** + * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ package org.eclipse.mdm.api.base.massdata; diff --git a/src/main/java/org/eclipse/mdm/api/base/massdata/ReadRequestIterable.java b/src/main/java/org/eclipse/mdm/api/base/massdata/ReadRequestIterable.java index 00015af..7cc3707 100644 --- a/src/main/java/org/eclipse/mdm/api/base/massdata/ReadRequestIterable.java +++ b/src/main/java/org/eclipse/mdm/api/base/massdata/ReadRequestIterable.java @@ -1,16 +1,16 @@ -/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
+/******************************************************************************** + * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ package org.eclipse.mdm.api.base.massdata; diff --git a/src/main/java/org/eclipse/mdm/api/base/massdata/UnitBuilder.java b/src/main/java/org/eclipse/mdm/api/base/massdata/UnitBuilder.java index cecc1a6..58dbfd2 100644 --- a/src/main/java/org/eclipse/mdm/api/base/massdata/UnitBuilder.java +++ b/src/main/java/org/eclipse/mdm/api/base/massdata/UnitBuilder.java @@ -1,16 +1,16 @@ -/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
+/******************************************************************************** + * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ package org.eclipse.mdm.api.base.massdata; diff --git a/src/main/java/org/eclipse/mdm/api/base/massdata/UnitIndependentBuilder.java b/src/main/java/org/eclipse/mdm/api/base/massdata/UnitIndependentBuilder.java index 321cc69..a54c822 100644 --- a/src/main/java/org/eclipse/mdm/api/base/massdata/UnitIndependentBuilder.java +++ b/src/main/java/org/eclipse/mdm/api/base/massdata/UnitIndependentBuilder.java @@ -1,16 +1,16 @@ -/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
+/******************************************************************************** + * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ package org.eclipse.mdm.api.base.massdata; diff --git a/src/main/java/org/eclipse/mdm/api/base/massdata/WriteRequestBuilder.java b/src/main/java/org/eclipse/mdm/api/base/massdata/WriteRequestBuilder.java index f77ac8a..6bcc117 100644 --- a/src/main/java/org/eclipse/mdm/api/base/massdata/WriteRequestBuilder.java +++ b/src/main/java/org/eclipse/mdm/api/base/massdata/WriteRequestBuilder.java @@ -1,16 +1,16 @@ -/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
+/******************************************************************************** + * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ package org.eclipse.mdm.api.base.massdata; diff --git a/src/main/java/org/eclipse/mdm/api/base/massdata/WriteRequestFinalizer.java b/src/main/java/org/eclipse/mdm/api/base/massdata/WriteRequestFinalizer.java index 19d2fea..6928dc8 100644 --- a/src/main/java/org/eclipse/mdm/api/base/massdata/WriteRequestFinalizer.java +++ b/src/main/java/org/eclipse/mdm/api/base/massdata/WriteRequestFinalizer.java @@ -1,16 +1,16 @@ -/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
+/******************************************************************************** + * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ package org.eclipse.mdm.api.base.massdata; diff --git a/src/main/java/org/eclipse/mdm/api/base/model/AxisType.java b/src/main/java/org/eclipse/mdm/api/base/model/AxisType.java index d2e0c1f..acefa92 100644 --- a/src/main/java/org/eclipse/mdm/api/base/model/AxisType.java +++ b/src/main/java/org/eclipse/mdm/api/base/model/AxisType.java @@ -1,16 +1,16 @@ -/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
+/******************************************************************************** + * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ package org.eclipse.mdm.api.base.model; diff --git a/src/main/java/org/eclipse/mdm/api/base/model/BaseEntity.java b/src/main/java/org/eclipse/mdm/api/base/model/BaseEntity.java index b70249b..3d0a353 100644 --- a/src/main/java/org/eclipse/mdm/api/base/model/BaseEntity.java +++ b/src/main/java/org/eclipse/mdm/api/base/model/BaseEntity.java @@ -1,16 +1,16 @@ -/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
+/******************************************************************************** + * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ package org.eclipse.mdm.api.base.model; diff --git a/src/main/java/org/eclipse/mdm/api/base/model/BaseEntityFactory.java b/src/main/java/org/eclipse/mdm/api/base/model/BaseEntityFactory.java index 95367a8..8e2087d 100644 --- a/src/main/java/org/eclipse/mdm/api/base/model/BaseEntityFactory.java +++ b/src/main/java/org/eclipse/mdm/api/base/model/BaseEntityFactory.java @@ -1,626 +1,626 @@ -/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
-
-
-package org.eclipse.mdm.api.base.model;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.time.LocalDateTime;
-import java.util.List;
-import java.util.Optional;
-
-import org.eclipse.mdm.api.base.adapter.ChildrenStore;
-import org.eclipse.mdm.api.base.adapter.Core;
-import org.eclipse.mdm.api.base.adapter.EntityStore;
-
-/**
- * Implementation of an abstract entity factory which creates new entities.
- *
- * @since 1.0.0
- * @author Viktor Stoehr, Gigatronik Ingolstadt GmbH
- * @author Sebastian Dirsch, Gigatronik Ingolstadt GmbH
- */
-public abstract class BaseEntityFactory {
-
- // ======================================================================
- // Public methods
- // ======================================================================
-
- /**
- * Creates a new {@link Channel}. The name of the returned {@code Channel}
- * is retrieved from given {@link Quantity}.
- *
- * @param measurement
- * The parent {@link Measurement}.
- * @param quantity
- * The {@code Quantity} is used for default initialization.
- * @return The created {@code Channel} is returned.
- */
- public Channel createChannel(Measurement measurement, Quantity quantity) {
- return createChannel(quantity.getDefaultChannelName(), measurement, quantity);
- }
-
- /**
- * Creates a new {@link Channel}.
- *
- * @param name
- * Name of the created {@code Channel}.
- * @param measurement
- * The parent {@link Measurement}.
- * @param quantity
- * The {@code Quantity} is used for default initialization.
- * @return The created {@code Channel} is returned.
- */
- public Channel createChannel(String name, Measurement measurement, Quantity quantity) {
- Channel channel = new Channel(createCore(Channel.class));
-
- // relations
- getCore(channel).getPermanentStore().set(measurement);
- getCore(measurement).getChildrenStore().add(channel);
- getCore(channel).getMutableStore().set(quantity.getDefaultUnit());
- getCore(channel).getMutableStore().set(quantity);
-
- // properties
- channel.setName(name);
- channel.setDescription(quantity.getDescription());
- channel.setInterpolation(Interpolation.NONE);
- channel.setScalarType(quantity.getDefaultScalarType());
- channel.setRank(quantity.getDefaultRank());
- channel.setTypeSize(quantity.getDefaultTypeSize());
-
- return channel;
- }
-
- /**
- * Creates a new {@link ChannelGroup}.
- *
- * @param name
- * Name of the created {@code ChannelGroup}.
- * @param numberOfValues
- * The number of values per each related {@link Channel}.
- * @param measurement
- * The parent {@link Measurement}.
- * @return The created {@code ChannelGroup} is returned.
- * @throws IllegalArgumentException
- * Thrown if numberOfValues is negative.
- */
- public ChannelGroup createChannelGroup(String name, int numberOfValues, Measurement measurement) {
- if (numberOfValues < 0) {
- throw new IllegalArgumentException("Number of values must be equal or greater than 0.");
- }
-
- ChannelGroup channelGroup = new ChannelGroup(createCore(ChannelGroup.class));
-
- // relations
- getCore(channelGroup).getPermanentStore().set(measurement);
- getCore(measurement).getChildrenStore().add(channelGroup);
-
- // properties
- channelGroup.setName(name);
- channelGroup.setNumberOfValues(Integer.valueOf(numberOfValues));
-
- return channelGroup;
- }
-
- /**
- * Creates a new {@link Measurement}.
- *
- * @param name
- * Name of the created {@code Measurement}.
- * @param testStep
- * The parent {@link TestStep}.
- * @param contextRoots
- * {@link ContextRoot}s containing the descriptive data.
- * @return The created {@code Measurement} is returned.
- */
- public Measurement createMeasurement(String name, TestStep testStep, ContextRoot... contextRoots) {
- Measurement measurement = new Measurement(createCore(Measurement.class));
-
- // relations
- getCore(measurement).getPermanentStore().set(testStep);
- getCore(testStep).getChildrenStore().add(measurement);
- for (ContextRoot contextRoot : contextRoots) {
- getCore(measurement).getMutableStore().set(contextRoot, contextRoot.getContextType());
- }
-
- // properties
- measurement.setName(name);
- measurement.setDateCreated(LocalDateTime.now());
-
- return measurement;
- }
-
- /**
- * Creates a new {@link Parameter} with initialized with given value.
- *
- * @param name
- * Name of the created {@code Parameter}.
- * @param value
- * The value of the created {@code Parameter}.
- * @param unit
- * An optionally related {@link Unit}.
- * @param parameterSet
- * The parent {@link ParameterSet}.
- * @return The created {@code Parameter} is returned.
- * @throws IllegalArgumentException
- * Thrown if the {@code ParameterSet} already contains a
- * {@code Parameter} with given name.
- * @see Parameter#setObjectValue(Object, Unit)
- */
- public Parameter createParameter(String name, Object value, Unit unit, ParameterSet parameterSet) {
- if (parameterSet.getParameter(name).isPresent()) {
- throw new IllegalArgumentException("Parameter with name '" + name + "' already exists.");
- }
-
- Parameter parameter = new Parameter(createCore(Parameter.class));
-
- // relations
- getCore(parameter).getPermanentStore().set(parameterSet);
- getCore(parameterSet).getChildrenStore().add(parameter);
-
- // properties
- parameter.setName(name);
- parameter.setObjectValue(value, unit);
-
- return parameter;
- }
-
- /**
- * Creates a new {@link ParameterSet} for given {@link Measurement}.
- *
- * @param name
- * Name of the created {@code ParameterSet}.
- * @param version
- * Version of the created {@code ParameterSet}.
- * @param measurement
- * The owning {@code Measurement}.
- * @return The created {@code ParameterSet} is returned.
- */
- public ParameterSet createParameterSet(String name, String version, Measurement measurement) {
- ParameterSet parameterSet = new ParameterSet(createCore(ParameterSet.class));
-
- // relations
- getCore(parameterSet).getPermanentStore().set(measurement);
- getCore(measurement).getChildrenStore().add(parameterSet);
-
- // properties
- parameterSet.setName(name);
- parameterSet.setVersion(version);
-
- return parameterSet;
- }
-
- /**
- * Creates a new {@link ParameterSet} for given {@link Channel}.
- *
- * @param name
- * Name of the created {@code ParameterSet}.
- * @param version
- * Version of the created {@code ParameterSet}.
- * @param channel
- * The owning {@code Channel}.
- * @return The created {@code ParameterSet} is returned.
- */
- public ParameterSet createParameterSet(String name, String version, Channel channel) {
- ParameterSet parameterSet = new ParameterSet(createCore(ParameterSet.class));
-
- // relations
- getCore(parameterSet).getPermanentStore().set(channel);
- getCore(channel).getChildrenStore().add(parameterSet);
-
- // properties
- parameterSet.setName(name);
- parameterSet.setVersion(version);
-
- return parameterSet;
- }
-
- /**
- * Creates a new {@link PhysicalDimension}.
- *
- * @param name
- * Name of the created {@code PhysicalDimension}.
- * @return The created {@code PhysicalDimension} is returned.
- */
- public PhysicalDimension createPhysicalDimension(String name) {
- PhysicalDimension physicalDimension = new PhysicalDimension(createCore(PhysicalDimension.class));
-
- // properties
- physicalDimension.setName(name);
- physicalDimension.setLength(Integer.valueOf(0));
- physicalDimension.setMass(Integer.valueOf(0));
- physicalDimension.setTime(Integer.valueOf(0));
- physicalDimension.setTemperature(Integer.valueOf(0));
- physicalDimension.setCurrent(Integer.valueOf(0));
- physicalDimension.setMolarAmount(Integer.valueOf(0));
- physicalDimension.setLuminousIntensity(Integer.valueOf(0));
- physicalDimension.setAngle(Integer.valueOf(0));
-
- return physicalDimension;
- }
-
- /**
- * Creates a new {@link Quantity}.
- *
- * @param name
- * Name of the created {@code Quantity}.
- * @param defaultUnit
- * The default {@link Unit}.
- * @return The created {@code Quantity} is returned.
- */
- public Quantity createQuantity(String name, Unit defaultUnit) {
- Quantity quantity = new Quantity(createCore(Quantity.class));
-
- // relations
- getCore(quantity).getMutableStore().set(defaultUnit);
-
- // properties
- quantity.setName(name);
- quantity.setDateCreated(LocalDateTime.now());
- quantity.setDefaultRank(Integer.valueOf(1));
- quantity.setDefaultDimension(new int[] { 0 });
- quantity.setDefaultTypeSize(Integer.valueOf(1));
- quantity.setDefaultChannelName(name);
- quantity.setDefaultScalarType(ScalarType.FLOAT);
-
- quantity.getValue("Version").set("1");
- quantity.getValue("ValidFlag").set(VersionState.VALID);
-
- return quantity;
- }
-
- /**
- * Creates a new {@link Test} with a reference to the logged in
- * {@link User}, if there is one.
- *
- * @param name
- * Name of the created {@code Test}.
- * @return The created {@code Test} is returned.
- */
- public Test createTest(String name) {
- Test test = new Test(createCore(Test.class));
-
- // relations
- Optional<User> responsiblePerson = getLoggedInUser();
- if (responsiblePerson.isPresent()) {
- // may be null if user entities are not available
- getCore(test).getMutableStore().set(responsiblePerson.get());
- }
-
- // properties
- test.setName(name);
- test.setDateCreated(LocalDateTime.now());
-
- return test;
- }
-
- /**
- * Creates a new {@link TestStep}.
- *
- * @param name
- * Name of the created {@code TestStep}.
- * @param test
- * The parent {@link Test}.
- * @return The created {@code TestStep} is returned.
- */
- public TestStep createTestStep(String name, Test test) {
- TestStep testStep = new TestStep(createCore(TestStep.class));
-
- // relations
- getCore(testStep).getPermanentStore().set(test);
- getCore(test).getChildrenStore().add(testStep);
-
- // properties
- testStep.setName(name);
- testStep.setDateCreated(LocalDateTime.now());
- testStep.setOptional(Boolean.TRUE);
-
- if (test.getID() != null && test.getID().length() > 0) {
- // highest sort index in use will be queried before written
- testStep.setSortIndex(Integer.valueOf(-1));
- } else {
- testStep.setSortIndex(nextIndex(getCore(test).getChildrenStore().get(TestStep.class)));
- }
-
- return testStep;
- }
-
- /**
- * Creates a new {@link Unit}.
- *
- * @param name
- * Name of the created {@code Unit}.
- * @param physicalDimension
- * The {@link PhysicalDimension}.
- * @return The created {@code Unit} is returned.
- */
- public Unit createUnit(String name, PhysicalDimension physicalDimension) {
- Unit unit = new Unit(createCore(Unit.class));
-
- // relations
- getCore(unit).getMutableStore().set(physicalDimension);
-
- // properties
- unit.setName(name);
- unit.setOffset(Double.valueOf(0D));
- unit.setFactor(Double.valueOf(1D));
-
- return unit;
- }
-
- /**
- * Creates a new {@link User}.
- *
- * @param name
- * Name of the created {@code User}.
- * @param givenName
- * Given name of the created {@code User}.
- * @param surname
- * Surname of the created {@code User}.
- * @return The created {@code User} is returned.
- */
- public User createUser(String name, String givenName, String surname) {
- User user = new User(createCore(User.class));
-
- // properties
- user.setName(name);
- user.setGivenName(givenName);
- user.setSurname(surname);
-
- return user;
- }
-
- // ======================================================================
- // Protected methods
- // ======================================================================
-
- /**
- * Creates a new {@link ContextRoot}.
- *
- * @param name
- * Name of the created {@code ContextRoot}.
- * @param contextType
- * {@link ContextType} of the created {@code ContextRoot}.
- * @return The created {@code ContextRoot} is returned.
- */
- protected ContextRoot createContextRoot(String name, ContextType contextType) {
- ContextRoot contextRoot = new ContextRoot(createCore(ContextRoot.class, contextType));
-
- // properties
- contextRoot.setName(name);
- contextRoot.setVersion(String.valueOf(0));
-
- return contextRoot;
- }
-
- /**
- * Creates a new {@link ContextComponent}.
- *
- * @param name
- * Name of the created {@code ContextComponent}.
- * @param contextRoot
- * The parent {@link ContextRoot}.
- * @return The created {@code ContextComponent} is returned.
- */
- protected ContextComponent createContextComponent(String name, ContextRoot contextRoot) {
- ContextComponent contextComponent = new ContextComponent(createCore(name, ContextComponent.class));
-
- // relations
- getCore(contextComponent).getPermanentStore().set(contextRoot);
- getCore(contextRoot).getChildrenStore().add(contextComponent);
-
- // properties
- contextComponent.setName(name);
-
- return contextComponent;
- }
-
- /**
- * Creates a new {@link ContextSensor}.
- *
- * @param name
- * Name of the created {@code ContextSensor}.
- * @param contextComponent
- * The parent {@link ContextComponent}.
- * @return The created {@code ContextSensor} is returned.
- */
- protected ContextSensor createContextSensor(String name, ContextComponent contextComponent) {
- ContextSensor contextSensor = new ContextSensor(createCore(name, ContextSensor.class));
- // relations
- getCore(contextSensor).getPermanentStore().set(contextComponent);
- getCore(contextComponent).getChildrenStore().add(contextSensor);
-
- // properties
- contextSensor.setName(name);
-
- return contextSensor;
- }
-
- /**
- * Returns the next usable sort index for given {@code List} of
- * {@link Sortable}s.
- *
- * @param sortables
- * The {@code Sortable} whose max sort index will be searched.
- * @return {@code 1} is returned if given {@code List} is empty, otherwise
- * the max sort index increased by 1 is returned.
- */
- protected static final Integer nextIndex(List<? extends Sortable> sortables) {
- Optional<Integer> maxIndex = sortables.stream().max(Sortable.COMPARATOR).map(Sortable::getSortIndex);
- return Integer.valueOf(maxIndex.isPresent() ? maxIndex.get().intValue() + 1 : 1);
- }
-
- /**
- * Returns the {@link ChildrenStore} for given {@link BaseEntity}.
- * Please be aware that the contents of this store is subject
- * to the adapter creating it. It is up to the adapter to decide
- * which related entities are included.
- * As there are adapter specific details to the contents of the store it
- * should be protected from external access.
- * Therefore by declaring this method protected, the
- * related functionality is hidden from other classes since the only
- * classes which can access them (outside this package) are derivatives of
- * BaseEntityFactory, and it is through such derivatives that BaseEntity's
- * Stores should be accessed elsewhere if needed.
- *
- * @param entity
- * The {@code BaseEntity} whose {@code ChildrenStore} will be
- * returned.
- * @return The {@code ChildrenStore} is returned.
- */
- protected static ChildrenStore getChildrenStore(BaseEntity entity) {
- return getCore(entity).getChildrenStore();
- }
-
- /**
- * Returns the mutable {@link EntityStore} for given {@link BaseEntity}.
- * Please be aware that the contents of this store is subject
- * to the adapter creating it. It is up to the adapter to decide
- * which related entities are included.
- * As there are adapter specific details to the contents of the store it
- * should be protected from external access.
- * Therefore by declaring this method protected, the
- * related functionality is hidden from other classes since the only
- * classes which can access them (outside this package) are derivatives of
- * BaseEntityFactory, and it is through such derivatives that BaseEntity's
- * Stores should be accessed elsewhere if needed.
- *
- *
- * @param entity
- * The {@code BaseEntity} whose {@code ChildrenStore} will be
- * returned.
- * @return The mutable {@code EntityStore} is returned.
- */
- protected static EntityStore getMutableStore(BaseEntity entity) {
- return getCore(entity).getMutableStore();
- }
-
- /**
- * Returns the permanent {@link EntityStore} for given {@link BaseEntity}.
- * Please be aware that the contents of this store is subject
- * to the adapter creating it. It is up to the adapter to decide
- * which related entities are included.
- * As there are adapter specific details to the contents of the store it
- * should be protected from external access.
- * Therefore by declaring this method protected, the
- * related functionality is hidden from other classes since the only
- * classes which can access them (outside this package) are derivatives of
- * BaseEntityFactory, and it is through such derivatives that BaseEntity's
- * Stores should be accessed elsewhere if needed.
- *
- * @param entity
- * The {@code BaseEntity} whose {@code ChildrenStore} will be
- * returned.
- * @return The permanent {@code EntityStore} is returned.
- */
- protected static EntityStore getPermanentStore(BaseEntity entity) {
- return getCore(entity).getPermanentStore();
- }
-
- /**
- * Returns {@link Core} of given {@link Entity}. Uses protected method from
- * BaseEntity, which is accessible here as BaseEntity resides in the same
- * package as BaseEntityFactory. By declaring this method protected, the
- * Core-related functionality is hidden from other classes since the only
- * classes which can access them (outside this package) are derivatives of
- * BaseEntityFactory, and it is through such derivatives that a BaseEntity's
- * Core should be accessed elsewhere if needed.
- *
- * @param entity
- * The {@code BaseEntity} whose {@code Core} is required.
- * @return The {@code Core} is returned.
- */
- protected static final Core getCore(BaseEntity entity) {
- return entity.getCore();
- }
-
- /**
- * Create an instance of {@link BaseEntity} (or derivative) with core as the
- * instance's {@link Core}. By declaring this method protected, the Core-related
- * functionality is hidden from other classes since the only classes which can
- * access them (outside this package) are derivatives of BaseEntityFactory, and
- * it is through such derivatives that a BaseEntity's Core should be accessed
- * elsewhere if needed.
- * <br> <br>
- * This method accesses the (usually protected) Constructor(Core) of clazz, so
- * this method should be overridden in a derived class and call
- * super.createBaseEntity() if that constructor is invisible from the derived
- * class.
- *
- * @param clazz
- * The class to instantiate, must extend {@link BaseEntity}.
- * @param core
- * The {@link Core} to use for the newly created instance.
- * @return The newly created instance.
- */
- protected <T extends BaseEntity> T createBaseEntity(Class<T> clazz, Core core) {
- try {
- Constructor<T> constructor = clazz.getDeclaredConstructor(Core.class);
- try {
- return constructor.newInstance(core);
- } catch (IllegalAccessException exc) {
- throw new IllegalStateException("Cannot access Constructor(Core) of class '" + clazz.getName() + "'!");
- }
- } catch (NoSuchMethodException | InvocationTargetException | InstantiationException exc) {
- throw new IllegalStateException(exc.getMessage(), exc);
- }
- }
-
- /**
- * Returns the {@link User} which is bound to the current session.
- *
- * @return {@code Optional} is empty if {@code User} entities do not exist.
- */
- protected abstract Optional<User> getLoggedInUser();
-
- /**
- * Returns a new {@link Core} for given entity class.
- *
- * @param <T>
- * The entity class type.
- * @param entityClass
- * The entity class.
- * @return A new {@code Core} instance is returned.
- */
- protected abstract <T extends Entity> Core createCore(Class<T> entityClass);
-
- /**
- * Returns a new {@link Core} for given entity class and
- * {@link ContextType}.
- *
- * @param <T>
- * The entity class type.
- * @param entityClass
- * The entity class.
- * @param contextType
- * The {@code ContextType}.
- * @return A new {@code Core} instance is returned.
- */
- protected abstract <T extends Entity> Core createCore(Class<T> entityClass, ContextType contextType);
-
- /**
- * Returns a new {@link Core} for given entity class and type name.
- *
- * @param <T>
- * The entity class type.
- * @param name
- * Name of the entity type.
- * @param entityClass
- * The entity class.
- * @return A new {@code Core} instance is returned.
- */
- protected abstract <T extends Entity> Core createCore(String name, Class<T> entityClass);
-
-}
+/******************************************************************************** + * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ + + +package org.eclipse.mdm.api.base.model; + +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.time.LocalDateTime; +import java.util.List; +import java.util.Optional; + +import org.eclipse.mdm.api.base.adapter.ChildrenStore; +import org.eclipse.mdm.api.base.adapter.Core; +import org.eclipse.mdm.api.base.adapter.EntityStore; + +/** + * Implementation of an abstract entity factory which creates new entities. + * + * @since 1.0.0 + * @author Viktor Stoehr, Gigatronik Ingolstadt GmbH + * @author Sebastian Dirsch, Gigatronik Ingolstadt GmbH + */ +public abstract class BaseEntityFactory { + + // ====================================================================== + // Public methods + // ====================================================================== + + /** + * Creates a new {@link Channel}. The name of the returned {@code Channel} + * is retrieved from given {@link Quantity}. + * + * @param measurement + * The parent {@link Measurement}. + * @param quantity + * The {@code Quantity} is used for default initialization. + * @return The created {@code Channel} is returned. + */ + public Channel createChannel(Measurement measurement, Quantity quantity) { + return createChannel(quantity.getDefaultChannelName(), measurement, quantity); + } + + /** + * Creates a new {@link Channel}. + * + * @param name + * Name of the created {@code Channel}. + * @param measurement + * The parent {@link Measurement}. + * @param quantity + * The {@code Quantity} is used for default initialization. + * @return The created {@code Channel} is returned. + */ + public Channel createChannel(String name, Measurement measurement, Quantity quantity) { + Channel channel = new Channel(createCore(Channel.class)); + + // relations + getCore(channel).getPermanentStore().set(measurement); + getCore(measurement).getChildrenStore().add(channel); + getCore(channel).getMutableStore().set(quantity.getDefaultUnit()); + getCore(channel).getMutableStore().set(quantity); + + // properties + channel.setName(name); + channel.setDescription(quantity.getDescription()); + channel.setInterpolation(Interpolation.NONE); + channel.setScalarType(quantity.getDefaultScalarType()); + channel.setRank(quantity.getDefaultRank()); + channel.setTypeSize(quantity.getDefaultTypeSize()); + + return channel; + } + + /** + * Creates a new {@link ChannelGroup}. + * + * @param name + * Name of the created {@code ChannelGroup}. + * @param numberOfValues + * The number of values per each related {@link Channel}. + * @param measurement + * The parent {@link Measurement}. + * @return The created {@code ChannelGroup} is returned. + * @throws IllegalArgumentException + * Thrown if numberOfValues is negative. + */ + public ChannelGroup createChannelGroup(String name, int numberOfValues, Measurement measurement) { + if (numberOfValues < 0) { + throw new IllegalArgumentException("Number of values must be equal or greater than 0."); + } + + ChannelGroup channelGroup = new ChannelGroup(createCore(ChannelGroup.class)); + + // relations + getCore(channelGroup).getPermanentStore().set(measurement); + getCore(measurement).getChildrenStore().add(channelGroup); + + // properties + channelGroup.setName(name); + channelGroup.setNumberOfValues(Integer.valueOf(numberOfValues)); + + return channelGroup; + } + + /** + * Creates a new {@link Measurement}. + * + * @param name + * Name of the created {@code Measurement}. + * @param testStep + * The parent {@link TestStep}. + * @param contextRoots + * {@link ContextRoot}s containing the descriptive data. + * @return The created {@code Measurement} is returned. + */ + public Measurement createMeasurement(String name, TestStep testStep, ContextRoot... contextRoots) { + Measurement measurement = new Measurement(createCore(Measurement.class)); + + // relations + getCore(measurement).getPermanentStore().set(testStep); + getCore(testStep).getChildrenStore().add(measurement); + for (ContextRoot contextRoot : contextRoots) { + getCore(measurement).getMutableStore().set(contextRoot, contextRoot.getContextType()); + } + + // properties + measurement.setName(name); + measurement.setDateCreated(LocalDateTime.now()); + + return measurement; + } + + /** + * Creates a new {@link Parameter} with initialized with given value. + * + * @param name + * Name of the created {@code Parameter}. + * @param value + * The value of the created {@code Parameter}. + * @param unit + * An optionally related {@link Unit}. + * @param parameterSet + * The parent {@link ParameterSet}. + * @return The created {@code Parameter} is returned. + * @throws IllegalArgumentException + * Thrown if the {@code ParameterSet} already contains a + * {@code Parameter} with given name. + * @see Parameter#setObjectValue(Object, Unit) + */ + public Parameter createParameter(String name, Object value, Unit unit, ParameterSet parameterSet) { + if (parameterSet.getParameter(name).isPresent()) { + throw new IllegalArgumentException("Parameter with name '" + name + "' already exists."); + } + + Parameter parameter = new Parameter(createCore(Parameter.class)); + + // relations + getCore(parameter).getPermanentStore().set(parameterSet); + getCore(parameterSet).getChildrenStore().add(parameter); + + // properties + parameter.setName(name); + parameter.setObjectValue(value, unit); + + return parameter; + } + + /** + * Creates a new {@link ParameterSet} for given {@link Measurement}. + * + * @param name + * Name of the created {@code ParameterSet}. + * @param version + * Version of the created {@code ParameterSet}. + * @param measurement + * The owning {@code Measurement}. + * @return The created {@code ParameterSet} is returned. + */ + public ParameterSet createParameterSet(String name, String version, Measurement measurement) { + ParameterSet parameterSet = new ParameterSet(createCore(ParameterSet.class)); + + // relations + getCore(parameterSet).getPermanentStore().set(measurement); + getCore(measurement).getChildrenStore().add(parameterSet); + + // properties + parameterSet.setName(name); + parameterSet.setVersion(version); + + return parameterSet; + } + + /** + * Creates a new {@link ParameterSet} for given {@link Channel}. + * + * @param name + * Name of the created {@code ParameterSet}. + * @param version + * Version of the created {@code ParameterSet}. + * @param channel + * The owning {@code Channel}. + * @return The created {@code ParameterSet} is returned. + */ + public ParameterSet createParameterSet(String name, String version, Channel channel) { + ParameterSet parameterSet = new ParameterSet(createCore(ParameterSet.class)); + + // relations + getCore(parameterSet).getPermanentStore().set(channel); + getCore(channel).getChildrenStore().add(parameterSet); + + // properties + parameterSet.setName(name); + parameterSet.setVersion(version); + + return parameterSet; + } + + /** + * Creates a new {@link PhysicalDimension}. + * + * @param name + * Name of the created {@code PhysicalDimension}. + * @return The created {@code PhysicalDimension} is returned. + */ + public PhysicalDimension createPhysicalDimension(String name) { + PhysicalDimension physicalDimension = new PhysicalDimension(createCore(PhysicalDimension.class)); + + // properties + physicalDimension.setName(name); + physicalDimension.setLength(Integer.valueOf(0)); + physicalDimension.setMass(Integer.valueOf(0)); + physicalDimension.setTime(Integer.valueOf(0)); + physicalDimension.setTemperature(Integer.valueOf(0)); + physicalDimension.setCurrent(Integer.valueOf(0)); + physicalDimension.setMolarAmount(Integer.valueOf(0)); + physicalDimension.setLuminousIntensity(Integer.valueOf(0)); + physicalDimension.setAngle(Integer.valueOf(0)); + + return physicalDimension; + } + + /** + * Creates a new {@link Quantity}. + * + * @param name + * Name of the created {@code Quantity}. + * @param defaultUnit + * The default {@link Unit}. + * @return The created {@code Quantity} is returned. + */ + public Quantity createQuantity(String name, Unit defaultUnit) { + Quantity quantity = new Quantity(createCore(Quantity.class)); + + // relations + getCore(quantity).getMutableStore().set(defaultUnit); + + // properties + quantity.setName(name); + quantity.setDateCreated(LocalDateTime.now()); + quantity.setDefaultRank(Integer.valueOf(1)); + quantity.setDefaultDimension(new int[] { 0 }); + quantity.setDefaultTypeSize(Integer.valueOf(1)); + quantity.setDefaultChannelName(name); + quantity.setDefaultScalarType(ScalarType.FLOAT); + + quantity.getValue("Version").set("1"); + quantity.getValue("ValidFlag").set(VersionState.VALID); + + return quantity; + } + + /** + * Creates a new {@link Test} with a reference to the logged in + * {@link User}, if there is one. + * + * @param name + * Name of the created {@code Test}. + * @return The created {@code Test} is returned. + */ + public Test createTest(String name) { + Test test = new Test(createCore(Test.class)); + + // relations + Optional<User> responsiblePerson = getLoggedInUser(); + if (responsiblePerson.isPresent()) { + // may be null if user entities are not available + getCore(test).getMutableStore().set(responsiblePerson.get()); + } + + // properties + test.setName(name); + test.setDateCreated(LocalDateTime.now()); + + return test; + } + + /** + * Creates a new {@link TestStep}. + * + * @param name + * Name of the created {@code TestStep}. + * @param test + * The parent {@link Test}. + * @return The created {@code TestStep} is returned. + */ + public TestStep createTestStep(String name, Test test) { + TestStep testStep = new TestStep(createCore(TestStep.class)); + + // relations + getCore(testStep).getPermanentStore().set(test); + getCore(test).getChildrenStore().add(testStep); + + // properties + testStep.setName(name); + testStep.setDateCreated(LocalDateTime.now()); + testStep.setOptional(Boolean.TRUE); + + if (test.getID() != null && test.getID().length() > 0) { + // highest sort index in use will be queried before written + testStep.setSortIndex(Integer.valueOf(-1)); + } else { + testStep.setSortIndex(nextIndex(getCore(test).getChildrenStore().get(TestStep.class))); + } + + return testStep; + } + + /** + * Creates a new {@link Unit}. + * + * @param name + * Name of the created {@code Unit}. + * @param physicalDimension + * The {@link PhysicalDimension}. + * @return The created {@code Unit} is returned. + */ + public Unit createUnit(String name, PhysicalDimension physicalDimension) { + Unit unit = new Unit(createCore(Unit.class)); + + // relations + getCore(unit).getMutableStore().set(physicalDimension); + + // properties + unit.setName(name); + unit.setOffset(Double.valueOf(0D)); + unit.setFactor(Double.valueOf(1D)); + + return unit; + } + + /** + * Creates a new {@link User}. + * + * @param name + * Name of the created {@code User}. + * @param givenName + * Given name of the created {@code User}. + * @param surname + * Surname of the created {@code User}. + * @return The created {@code User} is returned. + */ + public User createUser(String name, String givenName, String surname) { + User user = new User(createCore(User.class)); + + // properties + user.setName(name); + user.setGivenName(givenName); + user.setSurname(surname); + + return user; + } + + // ====================================================================== + // Protected methods + // ====================================================================== + + /** + * Creates a new {@link ContextRoot}. + * + * @param name + * Name of the created {@code ContextRoot}. + * @param contextType + * {@link ContextType} of the created {@code ContextRoot}. + * @return The created {@code ContextRoot} is returned. + */ + protected ContextRoot createContextRoot(String name, ContextType contextType) { + ContextRoot contextRoot = new ContextRoot(createCore(ContextRoot.class, contextType)); + + // properties + contextRoot.setName(name); + contextRoot.setVersion(String.valueOf(0)); + + return contextRoot; + } + + /** + * Creates a new {@link ContextComponent}. + * + * @param name + * Name of the created {@code ContextComponent}. + * @param contextRoot + * The parent {@link ContextRoot}. + * @return The created {@code ContextComponent} is returned. + */ + protected ContextComponent createContextComponent(String name, ContextRoot contextRoot) { + ContextComponent contextComponent = new ContextComponent(createCore(name, ContextComponent.class)); + + // relations + getCore(contextComponent).getPermanentStore().set(contextRoot); + getCore(contextRoot).getChildrenStore().add(contextComponent); + + // properties + contextComponent.setName(name); + + return contextComponent; + } + + /** + * Creates a new {@link ContextSensor}. + * + * @param name + * Name of the created {@code ContextSensor}. + * @param contextComponent + * The parent {@link ContextComponent}. + * @return The created {@code ContextSensor} is returned. + */ + protected ContextSensor createContextSensor(String name, ContextComponent contextComponent) { + ContextSensor contextSensor = new ContextSensor(createCore(name, ContextSensor.class)); + // relations + getCore(contextSensor).getPermanentStore().set(contextComponent); + getCore(contextComponent).getChildrenStore().add(contextSensor); + + // properties + contextSensor.setName(name); + + return contextSensor; + } + + /** + * Returns the next usable sort index for given {@code List} of + * {@link Sortable}s. + * + * @param sortables + * The {@code Sortable} whose max sort index will be searched. + * @return {@code 1} is returned if given {@code List} is empty, otherwise + * the max sort index increased by 1 is returned. + */ + protected static final Integer nextIndex(List<? extends Sortable> sortables) { + Optional<Integer> maxIndex = sortables.stream().max(Sortable.COMPARATOR).map(Sortable::getSortIndex); + return Integer.valueOf(maxIndex.isPresent() ? maxIndex.get().intValue() + 1 : 1); + } + + /** + * Returns the {@link ChildrenStore} for given {@link BaseEntity}. + * Please be aware that the contents of this store is subject + * to the adapter creating it. It is up to the adapter to decide + * which related entities are included. + * As there are adapter specific details to the contents of the store it + * should be protected from external access. + * Therefore by declaring this method protected, the + * related functionality is hidden from other classes since the only + * classes which can access them (outside this package) are derivatives of + * BaseEntityFactory, and it is through such derivatives that BaseEntity's + * Stores should be accessed elsewhere if needed. + * + * @param entity + * The {@code BaseEntity} whose {@code ChildrenStore} will be + * returned. + * @return The {@code ChildrenStore} is returned. + */ + protected static ChildrenStore getChildrenStore(BaseEntity entity) { + return getCore(entity).getChildrenStore(); + } + + /** + * Returns the mutable {@link EntityStore} for given {@link BaseEntity}. + * Please be aware that the contents of this store is subject + * to the adapter creating it. It is up to the adapter to decide + * which related entities are included. + * As there are adapter specific details to the contents of the store it + * should be protected from external access. + * Therefore by declaring this method protected, the + * related functionality is hidden from other classes since the only + * classes which can access them (outside this package) are derivatives of + * BaseEntityFactory, and it is through such derivatives that BaseEntity's + * Stores should be accessed elsewhere if needed. + * + * + * @param entity + * The {@code BaseEntity} whose {@code ChildrenStore} will be + * returned. + * @return The mutable {@code EntityStore} is returned. + */ + protected static EntityStore getMutableStore(BaseEntity entity) { + return getCore(entity).getMutableStore(); + } + + /** + * Returns the permanent {@link EntityStore} for given {@link BaseEntity}. + * Please be aware that the contents of this store is subject + * to the adapter creating it. It is up to the adapter to decide + * which related entities are included. + * As there are adapter specific details to the contents of the store it + * should be protected from external access. + * Therefore by declaring this method protected, the + * related functionality is hidden from other classes since the only + * classes which can access them (outside this package) are derivatives of + * BaseEntityFactory, and it is through such derivatives that BaseEntity's + * Stores should be accessed elsewhere if needed. + * + * @param entity + * The {@code BaseEntity} whose {@code ChildrenStore} will be + * returned. + * @return The permanent {@code EntityStore} is returned. + */ + protected static EntityStore getPermanentStore(BaseEntity entity) { + return getCore(entity).getPermanentStore(); + } + + /** + * Returns {@link Core} of given {@link Entity}. Uses protected method from + * BaseEntity, which is accessible here as BaseEntity resides in the same + * package as BaseEntityFactory. By declaring this method protected, the + * Core-related functionality is hidden from other classes since the only + * classes which can access them (outside this package) are derivatives of + * BaseEntityFactory, and it is through such derivatives that a BaseEntity's + * Core should be accessed elsewhere if needed. + * + * @param entity + * The {@code BaseEntity} whose {@code Core} is required. + * @return The {@code Core} is returned. + */ + protected static final Core getCore(BaseEntity entity) { + return entity.getCore(); + } + + /** + * Create an instance of {@link BaseEntity} (or derivative) with core as the + * instance's {@link Core}. By declaring this method protected, the Core-related + * functionality is hidden from other classes since the only classes which can + * access them (outside this package) are derivatives of BaseEntityFactory, and + * it is through such derivatives that a BaseEntity's Core should be accessed + * elsewhere if needed. + * <br> <br> + * This method accesses the (usually protected) Constructor(Core) of clazz, so + * this method should be overridden in a derived class and call + * super.createBaseEntity() if that constructor is invisible from the derived + * class. + * + * @param clazz + * The class to instantiate, must extend {@link BaseEntity}. + * @param core + * The {@link Core} to use for the newly created instance. + * @return The newly created instance. + */ + protected <T extends BaseEntity> T createBaseEntity(Class<T> clazz, Core core) { + try { + Constructor<T> constructor = clazz.getDeclaredConstructor(Core.class); + try { + return constructor.newInstance(core); + } catch (IllegalAccessException exc) { + throw new IllegalStateException("Cannot access Constructor(Core) of class '" + clazz.getName() + "'!"); + } + } catch (NoSuchMethodException | InvocationTargetException | InstantiationException exc) { + throw new IllegalStateException(exc.getMessage(), exc); + } + } + + /** + * Returns the {@link User} which is bound to the current session. + * + * @return {@code Optional} is empty if {@code User} entities do not exist. + */ + protected abstract Optional<User> getLoggedInUser(); + + /** + * Returns a new {@link Core} for given entity class. + * + * @param <T> + * The entity class type. + * @param entityClass + * The entity class. + * @return A new {@code Core} instance is returned. + */ + protected abstract <T extends Entity> Core createCore(Class<T> entityClass); + + /** + * Returns a new {@link Core} for given entity class and + * {@link ContextType}. + * + * @param <T> + * The entity class type. + * @param entityClass + * The entity class. + * @param contextType + * The {@code ContextType}. + * @return A new {@code Core} instance is returned. + */ + protected abstract <T extends Entity> Core createCore(Class<T> entityClass, ContextType contextType); + + /** + * Returns a new {@link Core} for given entity class and type name. + * + * @param <T> + * The entity class type. + * @param name + * Name of the entity type. + * @param entityClass + * The entity class. + * @return A new {@code Core} instance is returned. + */ + protected abstract <T extends Entity> Core createCore(String name, Class<T> entityClass); + +} diff --git a/src/main/java/org/eclipse/mdm/api/base/model/BaseParameter.java b/src/main/java/org/eclipse/mdm/api/base/model/BaseParameter.java index 029464d..b026988 100644 --- a/src/main/java/org/eclipse/mdm/api/base/model/BaseParameter.java +++ b/src/main/java/org/eclipse/mdm/api/base/model/BaseParameter.java @@ -1,16 +1,16 @@ -/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
+/******************************************************************************** + * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ package org.eclipse.mdm.api.base.model; diff --git a/src/main/java/org/eclipse/mdm/api/base/model/Channel.java b/src/main/java/org/eclipse/mdm/api/base/model/Channel.java index f0f86be..cce8bcc 100644 --- a/src/main/java/org/eclipse/mdm/api/base/model/Channel.java +++ b/src/main/java/org/eclipse/mdm/api/base/model/Channel.java @@ -1,16 +1,16 @@ -/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
+/******************************************************************************** + * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ package org.eclipse.mdm.api.base.model; diff --git a/src/main/java/org/eclipse/mdm/api/base/model/ChannelGroup.java b/src/main/java/org/eclipse/mdm/api/base/model/ChannelGroup.java index 7a10e88..14a5e67 100644 --- a/src/main/java/org/eclipse/mdm/api/base/model/ChannelGroup.java +++ b/src/main/java/org/eclipse/mdm/api/base/model/ChannelGroup.java @@ -1,16 +1,16 @@ -/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
+/******************************************************************************** + * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ package org.eclipse.mdm.api.base.model; diff --git a/src/main/java/org/eclipse/mdm/api/base/model/ContextComponent.java b/src/main/java/org/eclipse/mdm/api/base/model/ContextComponent.java index 749ba95..dbad35b 100644 --- a/src/main/java/org/eclipse/mdm/api/base/model/ContextComponent.java +++ b/src/main/java/org/eclipse/mdm/api/base/model/ContextComponent.java @@ -1,120 +1,120 @@ -/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
-
-
-package org.eclipse.mdm.api.base.model;
-
-import java.util.List;
-import java.util.Optional;
-import java.util.stream.Collectors;
-
-import org.eclipse.mdm.api.base.adapter.Core;
-
-/**
- * Implementation of the context component entity types. Instances of this class
- * are only provided / managed via the owning descriptive {@link ContextRoot}.
- * Additionally if the owning {@code ContextRoot} is of type
- * {@link ContextType#TESTEQUIPMENT} this context component may have relations
- * to {@link ContextSensor}s whose names have to be unique.
- *
- * @since 1.0.0
- * @author Viktor Stoehr, Gigatronik Ingolstadt GmbH
- * @author Sebastian Dirsch, Gigatronik Ingolstadt GmbH
- */
-public class ContextComponent extends BaseEntity implements Deletable {
-
- // ======================================================================
- // Constructors
- // ======================================================================
-
- /**
- * Constructor.
- *
- * @param core
- * The {@link Core}.
- */
- ContextComponent(Core core) {
- super(core);
- }
-
- // ======================================================================
- // Public methods
- // ======================================================================
-
- /**
- * Returns the {@link ContextSensor} identified by given name.
- *
- * @param name
- * The name of the {@code ContextSensor}.
- * @return The {@code Optional} is empty if a {@code ContextSensor} with
- * given name does not exist.
- */
- public Optional<ContextSensor> getContextSensor(String name) {
- return getContextSensors().stream().filter(cs -> cs.nameEquals(name)).findAny();
- }
-
- /**
- * Returns all available {@link ContextSensor}s related to this context
- * component.
- *
- * @return The returned {@code List} is unmodifiable.
- */
- public List<ContextSensor> getContextSensors() {
- return getCore().getChildrenStore().get(ContextSensor.class);
- }
-
- /**
- * Returns the {@link ContextRoot} this context component belongs to.
- *
- * @return The parent {@link ContextRoot}.
- */
- public ContextRoot getContextRoot() {
- return getCore().getPermanentStore().get(ContextRoot.class);
- }
-
- /**
- * Removes the {@link ContextSensor} identified by given name.
- *
- * @param name
- * Name of the {@code ContextSensor} that has to be removed.
- * @return Returns {@code true} if the {@code ContextSensor} with given name
- * has been removed.
- */
- public boolean removeContextSensor(String name) {
- Optional<ContextSensor> catalogSensor = getContextSensor(name);
- if (catalogSensor.isPresent()) {
- getCore().getChildrenStore().remove(catalogSensor.get());
- return true;
- }
-
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder(getClass().getSimpleName()).append('(');
- sb.append(getValues().values().stream().map(Value::toString).collect(Collectors.joining(", ")));
-
- List<ContextSensor> contextSensors = getContextSensors();
- if (!contextSensors.isEmpty()) {
- sb.append(", ContextSensors = ").append(contextSensors);
- }
-
- return sb.append(')').toString();
- }
-
-}
+/******************************************************************************** + * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ + + +package org.eclipse.mdm.api.base.model; + +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; + +import org.eclipse.mdm.api.base.adapter.Core; + +/** + * Implementation of the context component entity types. Instances of this class + * are only provided / managed via the owning descriptive {@link ContextRoot}. + * Additionally if the owning {@code ContextRoot} is of type + * {@link ContextType#TESTEQUIPMENT} this context component may have relations + * to {@link ContextSensor}s whose names have to be unique. + * + * @since 1.0.0 + * @author Viktor Stoehr, Gigatronik Ingolstadt GmbH + * @author Sebastian Dirsch, Gigatronik Ingolstadt GmbH + */ +public class ContextComponent extends BaseEntity implements Deletable { + + // ====================================================================== + // Constructors + // ====================================================================== + + /** + * Constructor. + * + * @param core + * The {@link Core}. + */ + ContextComponent(Core core) { + super(core); + } + + // ====================================================================== + // Public methods + // ====================================================================== + + /** + * Returns the {@link ContextSensor} identified by given name. + * + * @param name + * The name of the {@code ContextSensor}. + * @return The {@code Optional} is empty if a {@code ContextSensor} with + * given name does not exist. + */ + public Optional<ContextSensor> getContextSensor(String name) { + return getContextSensors().stream().filter(cs -> cs.nameEquals(name)).findAny(); + } + + /** + * Returns all available {@link ContextSensor}s related to this context + * component. + * + * @return The returned {@code List} is unmodifiable. + */ + public List<ContextSensor> getContextSensors() { + return getCore().getChildrenStore().get(ContextSensor.class); + } + + /** + * Returns the {@link ContextRoot} this context component belongs to. + * + * @return The parent {@link ContextRoot}. + */ + public ContextRoot getContextRoot() { + return getCore().getPermanentStore().get(ContextRoot.class); + } + + /** + * Removes the {@link ContextSensor} identified by given name. + * + * @param name + * Name of the {@code ContextSensor} that has to be removed. + * @return Returns {@code true} if the {@code ContextSensor} with given name + * has been removed. + */ + public boolean removeContextSensor(String name) { + Optional<ContextSensor> catalogSensor = getContextSensor(name); + if (catalogSensor.isPresent()) { + getCore().getChildrenStore().remove(catalogSensor.get()); + return true; + } + + return false; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(getClass().getSimpleName()).append('('); + sb.append(getValues().values().stream().map(Value::toString).collect(Collectors.joining(", "))); + + List<ContextSensor> contextSensors = getContextSensors(); + if (!contextSensors.isEmpty()) { + sb.append(", ContextSensors = ").append(contextSensors); + } + + return sb.append(')').toString(); + } + +} diff --git a/src/main/java/org/eclipse/mdm/api/base/model/ContextDescribable.java b/src/main/java/org/eclipse/mdm/api/base/model/ContextDescribable.java index bf150d9..bce58f8 100644 --- a/src/main/java/org/eclipse/mdm/api/base/model/ContextDescribable.java +++ b/src/main/java/org/eclipse/mdm/api/base/model/ContextDescribable.java @@ -1,16 +1,16 @@ -/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
+/******************************************************************************** + * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ package org.eclipse.mdm.api.base.model; diff --git a/src/main/java/org/eclipse/mdm/api/base/model/ContextRoot.java b/src/main/java/org/eclipse/mdm/api/base/model/ContextRoot.java index ce3c709..49dc9a4 100644 --- a/src/main/java/org/eclipse/mdm/api/base/model/ContextRoot.java +++ b/src/main/java/org/eclipse/mdm/api/base/model/ContextRoot.java @@ -1,217 +1,217 @@ -/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
-
-
-package org.eclipse.mdm.api.base.model;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Locale;
-import java.util.Optional;
-import java.util.stream.Collectors;
-
-import org.eclipse.mdm.api.base.adapter.Core;
-
-/**
- * Implementation of the context root entity types. This is the root node of the
- * descriptive component structure for a {@link ContextType}. This element is
- * used for both, order and measured result description data. If it belongs to
- * an order description, then a relation to a {@link TestStep} exists. Otherwise
- * it represents the description of a measurement and therefore has one ore more
- * relations to {@link Measurement}s. In the base application model the
- * component structure is provided as is. An extension of the base application
- * model may define a template, the structure of contained
- * {@link ContextComponent}s and {@link ContextSensor}s will be restricted to.
- * Additionally the <b>names</b> of all related {@code ContextComponent}s have
- * to be unique.
- *
- * @since 1.0.0
- * @author Viktor Stoehr, Gigatronik Ingolstadt GmbH
- * @author Sebastian Dirsch, Gigatronik Ingolstadt GmbH
- */
-public class ContextRoot extends BaseEntity implements Deletable {
-
- // ======================================================================
- // Class variables
- // ======================================================================
-
- /**
- * The 'Version' attribute name.
- */
- public static final String ATTR_VERSION = "Version";
-
- // ======================================================================
- // Instance variables
- // ======================================================================
-
- private final ContextType contextType;
-
- // ======================================================================
- // Constructors
- // ======================================================================
-
- /**
- * Constructor.
- *
- * @param core
- * The {@link Core}.
- */
- ContextRoot(Core core) {
- super(core);
- contextType = ContextType.valueOf(core.getTypeName().toUpperCase(Locale.ROOT));
- }
-
- // ======================================================================
- // Public methods
- // ======================================================================
-
- /**
- * Returns the {@link ContextType} of this context root.
- *
- * @return The {@code ContextType} is returned.
- */
- public ContextType getContextType() {
- return contextType;
- }
-
- /**
- * Returns the {@link ContextComponent} identified by given name.
- *
- * @param name
- * The name of the {@code ContextComponent}.
- * @return The {@code Optional} is empty if a {@code ContextComponent} with
- * given name does not exist.
- */
- public Optional<ContextComponent> getContextComponent(String name) {
- return getContextComponents().stream().filter(cc -> cc.nameEquals(name)).findAny();
- }
-
- /**
- * Returns all available {@link ContextComponent}s related to this context
- * root.
- *
- * @return The returned {@code List} is unmodifiable.
- */
- public List<ContextComponent> getContextComponents() {
- return getCore().getChildrenStore().get(ContextComponent.class);
- }
-
- /**
- * Removes the {@link ContextComponent} identified by given name.
- *
- * @param name
- * Name of the {@code ContextComponent} that have to be removed.
- * @return Returns {@code true} if the {@code ContextComponent} with given
- * name has been removed.
- */
- public boolean removeContextComponent(String name) {
- Optional<ContextComponent> contextComponent = getContextComponent(name);
- if (contextComponent.isPresent()) {
- getCore().getChildrenStore().remove(contextComponent.get());
- return true;
- }
-
- return false;
- }
-
- /**
- * Returns all available {@link ContextSensor}s related to the
- * {@link ContextComponent}s, which are held by this context root.
- *
- * @return The returned {@code List} will always be empty if this context
- * root is of type {@link ContextType#UNITUNDERTEST} or
- * {@link ContextType#TESTSEQUENCE}.
- */
- public List<ContextSensor> getContextSensors() {
- if (!getContextType().isTestEquipment()) {
- return Collections.emptyList();
- }
-
- return getContextComponents().stream().map(ContextComponent::getContextSensors).collect(ArrayList::new,
- List::addAll, List::addAll);
- }
-
- /**
- * Returns the version of this context root.
- *
- * @return The version is returned.
- */
- public String getVersion() {
- return getValue(ATTR_VERSION).extract();
- }
-
- /**
- * Sets new version for this context root.
- *
- * @param version
- * The new version.
- */
- public void setVersion(String version) {
- getValue(ATTR_VERSION).set(version);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder(getClass().getSimpleName()).append('(');
- sb.append("ContextType = ").append(getContextType()).append(", ");
- sb.append(getValues().values().stream().map(Value::toString).collect(Collectors.joining(", ")));
-
- List<ContextComponent> contextComponents = getContextComponents();
- if (!contextComponents.isEmpty()) {
- sb.append(", ContextComponents = ").append(contextComponents);
- }
-
- return sb.append(')').toString();
- }
-
- /**
- * Convenience method to access the {@link ContextRoot}s of newly created
- * {@link ContextDescribable}.
- *
- * @param contextDescribable
- * Either a {@link TestStep} or a {@link Measurement}.
- * @return The {@code ContextRoot}s are returned.
- */
- public static List<ContextRoot> of(ContextDescribable contextDescribable) {
- List<ContextRoot> contextRoots = new ArrayList<>();
- of(contextDescribable, ContextType.UNITUNDERTEST).ifPresent(contextRoots::add);
- of(contextDescribable, ContextType.TESTSEQUENCE).ifPresent(contextRoots::add);
- of(contextDescribable, ContextType.TESTEQUIPMENT).ifPresent(contextRoots::add);
- return contextRoots;
- }
-
- // ======================================================================
- // Private methods
- // ======================================================================
-
- /**
- * Returns the {@link ContextRoot} with given {@link ContextType} from given
- * {@link ContextDescribable}.
- *
- * @param contextDescribable
- * Either a {@link TestStep} or a {@link Measurement}.
- * @param contextType
- * The requested {@code ContextType}.
- * @return {@code Optional} is empty if a {@code ContextRoot} with given
- * {@code ContextType} does not exist.
- */
- private static Optional<ContextRoot> of(ContextDescribable contextDescribable, ContextType contextType) {
- return Optional.ofNullable(getCore(contextDescribable).getMutableStore().get(ContextRoot.class, contextType));
- }
-
-}
+/******************************************************************************** + * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ + + +package org.eclipse.mdm.api.base.model; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Locale; +import java.util.Optional; +import java.util.stream.Collectors; + +import org.eclipse.mdm.api.base.adapter.Core; + +/** + * Implementation of the context root entity types. This is the root node of the + * descriptive component structure for a {@link ContextType}. This element is + * used for both, order and measured result description data. If it belongs to + * an order description, then a relation to a {@link TestStep} exists. Otherwise + * it represents the description of a measurement and therefore has one ore more + * relations to {@link Measurement}s. In the base application model the + * component structure is provided as is. An extension of the base application + * model may define a template, the structure of contained + * {@link ContextComponent}s and {@link ContextSensor}s will be restricted to. + * Additionally the <b>names</b> of all related {@code ContextComponent}s have + * to be unique. + * + * @since 1.0.0 + * @author Viktor Stoehr, Gigatronik Ingolstadt GmbH + * @author Sebastian Dirsch, Gigatronik Ingolstadt GmbH + */ +public class ContextRoot extends BaseEntity implements Deletable { + + // ====================================================================== + // Class variables + // ====================================================================== + + /** + * The 'Version' attribute name. + */ + public static final String ATTR_VERSION = "Version"; + + // ====================================================================== + // Instance variables + // ====================================================================== + + private final ContextType contextType; + + // ====================================================================== + // Constructors + // ====================================================================== + + /** + * Constructor. + * + * @param core + * The {@link Core}. + */ + ContextRoot(Core core) { + super(core); + contextType = ContextType.valueOf(core.getTypeName().toUpperCase(Locale.ROOT)); + } + + // ====================================================================== + // Public methods + // ====================================================================== + + /** + * Returns the {@link ContextType} of this context root. + * + * @return The {@code ContextType} is returned. + */ + public ContextType getContextType() { + return contextType; + } + + /** + * Returns the {@link ContextComponent} identified by given name. + * + * @param name + * The name of the {@code ContextComponent}. + * @return The {@code Optional} is empty if a {@code ContextComponent} with + * given name does not exist. + */ + public Optional<ContextComponent> getContextComponent(String name) { + return getContextComponents().stream().filter(cc -> cc.nameEquals(name)).findAny(); + } + + /** + * Returns all available {@link ContextComponent}s related to this context + * root. + * + * @return The returned {@code List} is unmodifiable. + */ + public List<ContextComponent> getContextComponents() { + return getCore().getChildrenStore().get(ContextComponent.class); + } + + /** + * Removes the {@link ContextComponent} identified by given name. + * + * @param name + * Name of the {@code ContextComponent} that have to be removed. + * @return Returns {@code true} if the {@code ContextComponent} with given + * name has been removed. + */ + public boolean removeContextComponent(String name) { + Optional<ContextComponent> contextComponent = getContextComponent(name); + if (contextComponent.isPresent()) { + getCore().getChildrenStore().remove(contextComponent.get()); + return true; + } + + return false; + } + + /** + * Returns all available {@link ContextSensor}s related to the + * {@link ContextComponent}s, which are held by this context root. + * + * @return The returned {@code List} will always be empty if this context + * root is of type {@link ContextType#UNITUNDERTEST} or + * {@link ContextType#TESTSEQUENCE}. + */ + public List<ContextSensor> getContextSensors() { + if (!getContextType().isTestEquipment()) { + return Collections.emptyList(); + } + + return getContextComponents().stream().map(ContextComponent::getContextSensors).collect(ArrayList::new, + List::addAll, List::addAll); + } + + /** + * Returns the version of this context root. + * + * @return The version is returned. + */ + public String getVersion() { + return getValue(ATTR_VERSION).extract(); + } + + /** + * Sets new version for this context root. + * + * @param version + * The new version. + */ + public void setVersion(String version) { + getValue(ATTR_VERSION).set(version); + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(getClass().getSimpleName()).append('('); + sb.append("ContextType = ").append(getContextType()).append(", "); + sb.append(getValues().values().stream().map(Value::toString).collect(Collectors.joining(", "))); + + List<ContextComponent> contextComponents = getContextComponents(); + if (!contextComponents.isEmpty()) { + sb.append(", ContextComponents = ").append(contextComponents); + } + + return sb.append(')').toString(); + } + + /** + * Convenience method to access the {@link ContextRoot}s of newly created + * {@link ContextDescribable}. + * + * @param contextDescribable + * Either a {@link TestStep} or a {@link Measurement}. + * @return The {@code ContextRoot}s are returned. + */ + public static List<ContextRoot> of(ContextDescribable contextDescribable) { + List<ContextRoot> contextRoots = new ArrayList<>(); + of(contextDescribable, ContextType.UNITUNDERTEST).ifPresent(contextRoots::add); + of(contextDescribable, ContextType.TESTSEQUENCE).ifPresent(contextRoots::add); + of(contextDescribable, ContextType.TESTEQUIPMENT).ifPresent(contextRoots::add); + return contextRoots; + } + + // ====================================================================== + // Private methods + // ====================================================================== + + /** + * Returns the {@link ContextRoot} with given {@link ContextType} from given + * {@link ContextDescribable}. + * + * @param contextDescribable + * Either a {@link TestStep} or a {@link Measurement}. + * @param contextType + * The requested {@code ContextType}. + * @return {@code Optional} is empty if a {@code ContextRoot} with given + * {@code ContextType} does not exist. + */ + private static Optional<ContextRoot> of(ContextDescribable contextDescribable, ContextType contextType) { + return Optional.ofNullable(getCore(contextDescribable).getMutableStore().get(ContextRoot.class, contextType)); + } + +} diff --git a/src/main/java/org/eclipse/mdm/api/base/model/ContextSensor.java b/src/main/java/org/eclipse/mdm/api/base/model/ContextSensor.java index 2f408f5..2d76e80 100644 --- a/src/main/java/org/eclipse/mdm/api/base/model/ContextSensor.java +++ b/src/main/java/org/eclipse/mdm/api/base/model/ContextSensor.java @@ -1,16 +1,16 @@ -/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
+/******************************************************************************** + * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ package org.eclipse.mdm.api.base.model; diff --git a/src/main/java/org/eclipse/mdm/api/base/model/ContextType.java b/src/main/java/org/eclipse/mdm/api/base/model/ContextType.java index 0117ca0..cb0964d 100644 --- a/src/main/java/org/eclipse/mdm/api/base/model/ContextType.java +++ b/src/main/java/org/eclipse/mdm/api/base/model/ContextType.java @@ -1,16 +1,16 @@ -/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
+/******************************************************************************** + * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ package org.eclipse.mdm.api.base.model; diff --git a/src/main/java/org/eclipse/mdm/api/base/model/Datable.java b/src/main/java/org/eclipse/mdm/api/base/model/Datable.java index e1f2b33..dac0785 100644 --- a/src/main/java/org/eclipse/mdm/api/base/model/Datable.java +++ b/src/main/java/org/eclipse/mdm/api/base/model/Datable.java @@ -1,16 +1,16 @@ -/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
+/******************************************************************************** + * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ package org.eclipse.mdm.api.base.model; diff --git a/src/main/java/org/eclipse/mdm/api/base/model/Deletable.java b/src/main/java/org/eclipse/mdm/api/base/model/Deletable.java index 5453ca7..4e5e14c 100644 --- a/src/main/java/org/eclipse/mdm/api/base/model/Deletable.java +++ b/src/main/java/org/eclipse/mdm/api/base/model/Deletable.java @@ -1,16 +1,16 @@ -/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
+/******************************************************************************** + * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ package org.eclipse.mdm.api.base.model; diff --git a/src/main/java/org/eclipse/mdm/api/base/model/Describable.java b/src/main/java/org/eclipse/mdm/api/base/model/Describable.java index 83484dc..b2f412d 100644 --- a/src/main/java/org/eclipse/mdm/api/base/model/Describable.java +++ b/src/main/java/org/eclipse/mdm/api/base/model/Describable.java @@ -1,16 +1,16 @@ -/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
+/******************************************************************************** + * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ package org.eclipse.mdm.api.base.model; diff --git a/src/main/java/org/eclipse/mdm/api/base/model/DoubleComplex.java b/src/main/java/org/eclipse/mdm/api/base/model/DoubleComplex.java index 37d8712..f016044 100644 --- a/src/main/java/org/eclipse/mdm/api/base/model/DoubleComplex.java +++ b/src/main/java/org/eclipse/mdm/api/base/model/DoubleComplex.java @@ -1,16 +1,16 @@ -/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
+/******************************************************************************** + * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ package org.eclipse.mdm.api.base.model; diff --git a/src/main/java/org/eclipse/mdm/api/base/model/Entity.java b/src/main/java/org/eclipse/mdm/api/base/model/Entity.java index e9524dc..fcf5004 100644 --- a/src/main/java/org/eclipse/mdm/api/base/model/Entity.java +++ b/src/main/java/org/eclipse/mdm/api/base/model/Entity.java @@ -1,16 +1,16 @@ -/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
+/******************************************************************************** + * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ package org.eclipse.mdm.api.base.model; diff --git a/src/main/java/org/eclipse/mdm/api/base/model/EnumRegistry.java b/src/main/java/org/eclipse/mdm/api/base/model/EnumRegistry.java index 2d7eb89..b40fce6 100644 --- a/src/main/java/org/eclipse/mdm/api/base/model/EnumRegistry.java +++ b/src/main/java/org/eclipse/mdm/api/base/model/EnumRegistry.java @@ -1,16 +1,16 @@ -/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
+/******************************************************************************** + * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ package org.eclipse.mdm.api.base.model; diff --git a/src/main/java/org/eclipse/mdm/api/base/model/Enumeration.java b/src/main/java/org/eclipse/mdm/api/base/model/Enumeration.java index b074105..07af4dc 100644 --- a/src/main/java/org/eclipse/mdm/api/base/model/Enumeration.java +++ b/src/main/java/org/eclipse/mdm/api/base/model/Enumeration.java @@ -1,16 +1,16 @@ -/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
+/******************************************************************************** + * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ package org.eclipse.mdm.api.base.model; diff --git a/src/main/java/org/eclipse/mdm/api/base/model/EnumerationValue.java b/src/main/java/org/eclipse/mdm/api/base/model/EnumerationValue.java index c61be41..ea2b9f7 100644 --- a/src/main/java/org/eclipse/mdm/api/base/model/EnumerationValue.java +++ b/src/main/java/org/eclipse/mdm/api/base/model/EnumerationValue.java @@ -1,16 +1,16 @@ -/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
+/******************************************************************************** + * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ package org.eclipse.mdm.api.base.model; diff --git a/src/main/java/org/eclipse/mdm/api/base/model/Environment.java b/src/main/java/org/eclipse/mdm/api/base/model/Environment.java index 8380345..a3a099a 100644 --- a/src/main/java/org/eclipse/mdm/api/base/model/Environment.java +++ b/src/main/java/org/eclipse/mdm/api/base/model/Environment.java @@ -1,16 +1,16 @@ -/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
+/******************************************************************************** + * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ package org.eclipse.mdm.api.base.model; diff --git a/src/main/java/org/eclipse/mdm/api/base/model/FilesAttachable.java b/src/main/java/org/eclipse/mdm/api/base/model/FilesAttachable.java index f8b92c0..c72b794 100644 --- a/src/main/java/org/eclipse/mdm/api/base/model/FilesAttachable.java +++ b/src/main/java/org/eclipse/mdm/api/base/model/FilesAttachable.java @@ -1,16 +1,16 @@ -/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
+/******************************************************************************** + * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ package org.eclipse.mdm.api.base.model; diff --git a/src/main/java/org/eclipse/mdm/api/base/model/FloatComplex.java b/src/main/java/org/eclipse/mdm/api/base/model/FloatComplex.java index c3d5e53..92bef75 100644 --- a/src/main/java/org/eclipse/mdm/api/base/model/FloatComplex.java +++ b/src/main/java/org/eclipse/mdm/api/base/model/FloatComplex.java @@ -1,16 +1,16 @@ -/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
+/******************************************************************************** + * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ package org.eclipse.mdm.api.base.model; diff --git a/src/main/java/org/eclipse/mdm/api/base/model/Interpolation.java b/src/main/java/org/eclipse/mdm/api/base/model/Interpolation.java index fc99988..4baf06c 100644 --- a/src/main/java/org/eclipse/mdm/api/base/model/Interpolation.java +++ b/src/main/java/org/eclipse/mdm/api/base/model/Interpolation.java @@ -1,16 +1,16 @@ -/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
+/******************************************************************************** + * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ package org.eclipse.mdm.api.base.model; diff --git a/src/main/java/org/eclipse/mdm/api/base/model/MimeType.java b/src/main/java/org/eclipse/mdm/api/base/model/MimeType.java index 88a9595..ac06e48 100644 --- a/src/main/java/org/eclipse/mdm/api/base/model/MimeType.java +++ b/src/main/java/org/eclipse/mdm/api/base/model/MimeType.java @@ -1,16 +1,16 @@ -/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
+/******************************************************************************** + * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ package org.eclipse.mdm.api.base.model; diff --git a/src/main/java/org/eclipse/mdm/api/base/model/Parameter.java b/src/main/java/org/eclipse/mdm/api/base/model/Parameter.java index 84493b9..ebebae6 100644 --- a/src/main/java/org/eclipse/mdm/api/base/model/Parameter.java +++ b/src/main/java/org/eclipse/mdm/api/base/model/Parameter.java @@ -1,16 +1,16 @@ -/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
+/******************************************************************************** + * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ package org.eclipse.mdm.api.base.model; diff --git a/src/main/java/org/eclipse/mdm/api/base/model/ParameterSet.java b/src/main/java/org/eclipse/mdm/api/base/model/ParameterSet.java index af6d772..b43c50d 100644 --- a/src/main/java/org/eclipse/mdm/api/base/model/ParameterSet.java +++ b/src/main/java/org/eclipse/mdm/api/base/model/ParameterSet.java @@ -1,141 +1,141 @@ -/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
-
-
-package org.eclipse.mdm.api.base.model;
-
-import java.util.List;
-import java.util.Optional;
-import java.util.stream.Collectors;
-
-import org.eclipse.mdm.api.base.adapter.Core;
-
-/**
- * Implementation of the parameter set entity type. Instances of this class
- * group a set of further describing data stored in {@link Parameter}s.
- * Parameter sets are attached either to a {@link Measurement} or
- * {@link Channel}.
- *
- * @since 1.0.0
- * @author Viktor Stoehr, Gigatronik Ingolstadt GmbH
- * @author Sebastian Dirsch, Gigatronik Ingolstadt GmbH
- */
-public class ParameterSet extends BaseEntity implements Deletable {
-
- // ======================================================================
- // Class variables
- // ======================================================================
-
- /**
- * The {@link Measurement} parent type.
- */
- public static final Class<Measurement> PARENT_TYPE_MEASUREMENT = Measurement.class;
-
- /**
- * The {@link ChannelGroup} parent type.
- */
- public static final Class<Channel> PARENT_TYPE_CHANNEL = Channel.class;
-
- /**
- * The 'Version' attribute name.
- */
- public static final String ATTR_VERSION = "Version";
-
- // ======================================================================
- // Constructors
- // ======================================================================
-
- /**
- * Constructor.
- *
- * @param core
- * The {@link Core}.
- */
- ParameterSet(Core core) {
- super(core);
- }
-
- // ======================================================================
- // Public methods
- // ======================================================================
-
- /**
- * Returns the {@link Parameter} identified by given name.
- *
- * @param name
- * The name of the {@code Parameter}.
- * @return The {@code Optional} is empty if a {@code Parameter} with given
- * name does not exist.
- */
- public Optional<Parameter> getParameter(String name) {
- return getParameters().stream().filter(p -> p.nameEquals(name)).findAny();
- }
-
- /**
- * Returns all available {@link Parameter}s related to this parameter set.
- *
- * @return The returned {@code List} is unmodifiable.
- */
- public List<Parameter> getParameters() {
- return getCore().getChildrenStore().get(Parameter.class);
- }
-
- /**
- * Removes the {@link Parameter} identified by given name.
- *
- * @param name
- * Name of the {@code Parameter} that have to be removed.
- * @return Returns {@code true} if the {@code Parameter} with given name has
- * been removed.
- */
- public boolean removeParameter(String name) {
- Optional<Parameter> parameter = getParameter(name);
- if (parameter.isPresent()) {
- getCore().getChildrenStore().remove(parameter.get());
- return true;
- }
-
- return false;
- }
-
- /**
- * Returns the version of this parameter set.
- *
- * @return The version is returned.
- */
- public String getVersion() {
- return getValue(ATTR_VERSION).extract();
- }
-
- /**
- * Sets new version for this parameter set.
- *
- * @param version
- * The new version.
- */
- public void setVersion(String version) {
- getValue(ATTR_VERSION).set(version);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder(getClass().getSimpleName()).append('(');
- sb.append(getValues().values().stream().map(Value::toString).collect(Collectors.joining(", ")));
- return sb.append(", Parameters = ").append(getParameters()).append(')').toString();
- }
-
-}
+/******************************************************************************** + * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ + + +package org.eclipse.mdm.api.base.model; + +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; + +import org.eclipse.mdm.api.base.adapter.Core; + +/** + * Implementation of the parameter set entity type. Instances of this class + * group a set of further describing data stored in {@link Parameter}s. + * Parameter sets are attached either to a {@link Measurement} or + * {@link Channel}. + * + * @since 1.0.0 + * @author Viktor Stoehr, Gigatronik Ingolstadt GmbH + * @author Sebastian Dirsch, Gigatronik Ingolstadt GmbH + */ +public class ParameterSet extends BaseEntity implements Deletable { + + // ====================================================================== + // Class variables + // ====================================================================== + + /** + * The {@link Measurement} parent type. + */ + public static final Class<Measurement> PARENT_TYPE_MEASUREMENT = Measurement.class; + + /** + * The {@link ChannelGroup} parent type. + */ + public static final Class<Channel> PARENT_TYPE_CHANNEL = Channel.class; + + /** + * The 'Version' attribute name. + */ + public static final String ATTR_VERSION = "Version"; + + // ====================================================================== + // Constructors + // ====================================================================== + + /** + * Constructor. + * + * @param core + * The {@link Core}. + */ + ParameterSet(Core core) { + super(core); + } + + // ====================================================================== + // Public methods + // ====================================================================== + + /** + * Returns the {@link Parameter} identified by given name. + * + * @param name + * The name of the {@code Parameter}. + * @return The {@code Optional} is empty if a {@code Parameter} with given + * name does not exist. + */ + public Optional<Parameter> getParameter(String name) { + return getParameters().stream().filter(p -> p.nameEquals(name)).findAny(); + } + + /** + * Returns all available {@link Parameter}s related to this parameter set. + * + * @return The returned {@code List} is unmodifiable. + */ + public List<Parameter> getParameters() { + return getCore().getChildrenStore().get(Parameter.class); + } + + /** + * Removes the {@link Parameter} identified by given name. + * + * @param name + * Name of the {@code Parameter} that have to be removed. + * @return Returns {@code true} if the {@code Parameter} with given name has + * been removed. + */ + public boolean removeParameter(String name) { + Optional<Parameter> parameter = getParameter(name); + if (parameter.isPresent()) { + getCore().getChildrenStore().remove(parameter.get()); + return true; + } + + return false; + } + + /** + * Returns the version of this parameter set. + * + * @return The version is returned. + */ + public String getVersion() { + return getValue(ATTR_VERSION).extract(); + } + + /** + * Sets new version for this parameter set. + * + * @param version + * The new version. + */ + public void setVersion(String version) { + getValue(ATTR_VERSION).set(version); + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(getClass().getSimpleName()).append('('); + sb.append(getValues().values().stream().map(Value::toString).collect(Collectors.joining(", "))); + return sb.append(", Parameters = ").append(getParameters()).append(')').toString(); + } + +} diff --git a/src/main/java/org/eclipse/mdm/api/base/model/PhysicalDimension.java b/src/main/java/org/eclipse/mdm/api/base/model/PhysicalDimension.java index 3e43318..aa4047c 100644 --- a/src/main/java/org/eclipse/mdm/api/base/model/PhysicalDimension.java +++ b/src/main/java/org/eclipse/mdm/api/base/model/PhysicalDimension.java @@ -1,16 +1,16 @@ -/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
+/******************************************************************************** + * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ package org.eclipse.mdm.api.base.model; diff --git a/src/main/java/org/eclipse/mdm/api/base/model/Quantity.java b/src/main/java/org/eclipse/mdm/api/base/model/Quantity.java index 282ed35..89dc868 100644 --- a/src/main/java/org/eclipse/mdm/api/base/model/Quantity.java +++ b/src/main/java/org/eclipse/mdm/api/base/model/Quantity.java @@ -1,16 +1,16 @@ -/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
+/******************************************************************************** + * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ package org.eclipse.mdm.api.base.model; diff --git a/src/main/java/org/eclipse/mdm/api/base/model/SequenceRepresentation.java b/src/main/java/org/eclipse/mdm/api/base/model/SequenceRepresentation.java index afe3f42..8c8a219 100644 --- a/src/main/java/org/eclipse/mdm/api/base/model/SequenceRepresentation.java +++ b/src/main/java/org/eclipse/mdm/api/base/model/SequenceRepresentation.java @@ -1,16 +1,16 @@ -/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
+/******************************************************************************** + * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ package org.eclipse.mdm.api.base.model; diff --git a/src/main/java/org/eclipse/mdm/api/base/model/Sortable.java b/src/main/java/org/eclipse/mdm/api/base/model/Sortable.java index 404415e..17d4851 100644 --- a/src/main/java/org/eclipse/mdm/api/base/model/Sortable.java +++ b/src/main/java/org/eclipse/mdm/api/base/model/Sortable.java @@ -1,16 +1,16 @@ -/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
+/******************************************************************************** + * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ package org.eclipse.mdm.api.base.model; diff --git a/src/main/java/org/eclipse/mdm/api/base/model/StatusAttachable.java b/src/main/java/org/eclipse/mdm/api/base/model/StatusAttachable.java index 328e247..02abb68 100644 --- a/src/main/java/org/eclipse/mdm/api/base/model/StatusAttachable.java +++ b/src/main/java/org/eclipse/mdm/api/base/model/StatusAttachable.java @@ -1,16 +1,16 @@ -/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
+/******************************************************************************** + * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ package org.eclipse.mdm.api.base.model; diff --git a/src/main/java/org/eclipse/mdm/api/base/model/Tagable.java b/src/main/java/org/eclipse/mdm/api/base/model/Tagable.java index 21d5111..fa97a23 100644 --- a/src/main/java/org/eclipse/mdm/api/base/model/Tagable.java +++ b/src/main/java/org/eclipse/mdm/api/base/model/Tagable.java @@ -1,16 +1,16 @@ -/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
+/******************************************************************************** + * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ package org.eclipse.mdm.api.base.model; diff --git a/src/main/java/org/eclipse/mdm/api/base/model/Test.java b/src/main/java/org/eclipse/mdm/api/base/model/Test.java index f8fdf92..321dd1e 100644 --- a/src/main/java/org/eclipse/mdm/api/base/model/Test.java +++ b/src/main/java/org/eclipse/mdm/api/base/model/Test.java @@ -1,16 +1,16 @@ -/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
+/******************************************************************************** + * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ package org.eclipse.mdm.api.base.model; diff --git a/src/main/java/org/eclipse/mdm/api/base/model/TypeSpecification.java b/src/main/java/org/eclipse/mdm/api/base/model/TypeSpecification.java index 77e185e..b8c6ed8 100644 --- a/src/main/java/org/eclipse/mdm/api/base/model/TypeSpecification.java +++ b/src/main/java/org/eclipse/mdm/api/base/model/TypeSpecification.java @@ -1,16 +1,16 @@ -/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
+/******************************************************************************** + * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ package org.eclipse.mdm.api.base.model; diff --git a/src/main/java/org/eclipse/mdm/api/base/model/Unit.java b/src/main/java/org/eclipse/mdm/api/base/model/Unit.java index dd73025..0748e6e 100644 --- a/src/main/java/org/eclipse/mdm/api/base/model/Unit.java +++ b/src/main/java/org/eclipse/mdm/api/base/model/Unit.java @@ -1,16 +1,16 @@ -/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
+/******************************************************************************** + * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ package org.eclipse.mdm.api.base.model; diff --git a/src/main/java/org/eclipse/mdm/api/base/model/User.java b/src/main/java/org/eclipse/mdm/api/base/model/User.java index bb6d545..70e6d80 100644 --- a/src/main/java/org/eclipse/mdm/api/base/model/User.java +++ b/src/main/java/org/eclipse/mdm/api/base/model/User.java @@ -1,16 +1,16 @@ -/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
+/******************************************************************************** + * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ package org.eclipse.mdm.api.base.model; diff --git a/src/main/java/org/eclipse/mdm/api/base/model/Value.java b/src/main/java/org/eclipse/mdm/api/base/model/Value.java index 5ba91d3..4175779 100644 --- a/src/main/java/org/eclipse/mdm/api/base/model/Value.java +++ b/src/main/java/org/eclipse/mdm/api/base/model/Value.java @@ -1,16 +1,16 @@ -/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
+/******************************************************************************** + * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ package org.eclipse.mdm.api.base.model; diff --git a/src/main/java/org/eclipse/mdm/api/base/model/ValueType.java b/src/main/java/org/eclipse/mdm/api/base/model/ValueType.java index c15b83f..0b7ef41 100644 --- a/src/main/java/org/eclipse/mdm/api/base/model/ValueType.java +++ b/src/main/java/org/eclipse/mdm/api/base/model/ValueType.java @@ -1,16 +1,16 @@ -/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
+/******************************************************************************** + * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ package org.eclipse.mdm.api.base.model; diff --git a/src/main/java/org/eclipse/mdm/api/base/model/VersionState.java b/src/main/java/org/eclipse/mdm/api/base/model/VersionState.java index c282768..a51c387 100644 --- a/src/main/java/org/eclipse/mdm/api/base/model/VersionState.java +++ b/src/main/java/org/eclipse/mdm/api/base/model/VersionState.java @@ -1,16 +1,16 @@ -/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
+/******************************************************************************** + * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ package org.eclipse.mdm.api.base.model; diff --git a/src/main/java/org/eclipse/mdm/api/base/notification/NotificationException.java b/src/main/java/org/eclipse/mdm/api/base/notification/NotificationException.java index dcb3771..d948f88 100644 --- a/src/main/java/org/eclipse/mdm/api/base/notification/NotificationException.java +++ b/src/main/java/org/eclipse/mdm/api/base/notification/NotificationException.java @@ -1,16 +1,16 @@ -/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
+/******************************************************************************** + * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ package org.eclipse.mdm.api.base.notification; diff --git a/src/main/java/org/eclipse/mdm/api/base/notification/NotificationFilter.java b/src/main/java/org/eclipse/mdm/api/base/notification/NotificationFilter.java index 2c94f79..1c5125f 100644 --- a/src/main/java/org/eclipse/mdm/api/base/notification/NotificationFilter.java +++ b/src/main/java/org/eclipse/mdm/api/base/notification/NotificationFilter.java @@ -1,16 +1,16 @@ -/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
+/******************************************************************************** + * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ package org.eclipse.mdm.api.base.notification; diff --git a/src/main/java/org/eclipse/mdm/api/base/notification/NotificationListener.java b/src/main/java/org/eclipse/mdm/api/base/notification/NotificationListener.java index 5cc530f..e3506ec 100644 --- a/src/main/java/org/eclipse/mdm/api/base/notification/NotificationListener.java +++ b/src/main/java/org/eclipse/mdm/api/base/notification/NotificationListener.java @@ -1,16 +1,16 @@ -/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
+/******************************************************************************** + * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ package org.eclipse.mdm.api.base.notification; diff --git a/src/main/java/org/eclipse/mdm/api/base/notification/NotificationService.java b/src/main/java/org/eclipse/mdm/api/base/notification/NotificationService.java index 7da6872..c30a342 100644 --- a/src/main/java/org/eclipse/mdm/api/base/notification/NotificationService.java +++ b/src/main/java/org/eclipse/mdm/api/base/notification/NotificationService.java @@ -1,16 +1,16 @@ -/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
+/******************************************************************************** + * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ package org.eclipse.mdm.api.base.notification; diff --git a/src/main/java/org/eclipse/mdm/api/base/query/Aggregation.java b/src/main/java/org/eclipse/mdm/api/base/query/Aggregation.java index fa4356e..c238a4f 100644 --- a/src/main/java/org/eclipse/mdm/api/base/query/Aggregation.java +++ b/src/main/java/org/eclipse/mdm/api/base/query/Aggregation.java @@ -1,16 +1,16 @@ -/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
+/******************************************************************************** + * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ package org.eclipse.mdm.api.base.query; diff --git a/src/main/java/org/eclipse/mdm/api/base/query/BooleanOperator.java b/src/main/java/org/eclipse/mdm/api/base/query/BooleanOperator.java index 9b87d41..3d66d04 100644 --- a/src/main/java/org/eclipse/mdm/api/base/query/BooleanOperator.java +++ b/src/main/java/org/eclipse/mdm/api/base/query/BooleanOperator.java @@ -1,16 +1,16 @@ -/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
+/******************************************************************************** + * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ package org.eclipse.mdm.api.base.query; diff --git a/src/main/java/org/eclipse/mdm/api/base/query/BracketOperator.java b/src/main/java/org/eclipse/mdm/api/base/query/BracketOperator.java index 9bdc974..e57bea5 100644 --- a/src/main/java/org/eclipse/mdm/api/base/query/BracketOperator.java +++ b/src/main/java/org/eclipse/mdm/api/base/query/BracketOperator.java @@ -1,52 +1,52 @@ -/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
-
-
-package org.eclipse.mdm.api.base.query;
-
-/**
-* The bracket operator enumeration.
-*
-* @since 1.0.0
-* @see Condition
-* @see Filter
-*/
-
-public enum BracketOperator {
- /**
- * Left parenthesis.
- */
- OPEN,
-
- /**
- * Right parenthesis.
- */
- CLOSE;
-
- /*
- * (non-Javadoc)
- * @see java.lang.Enum#toString()
- */
- @Override
- public String toString() {
- switch (this) {
- case OPEN:
- return "(";
- case CLOSE:
- return ")";
- default:
- return this.toString();
- }
- }
-}
+/******************************************************************************** + * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ + + +package org.eclipse.mdm.api.base.query; + +/** +* The bracket operator enumeration. +* +* @since 1.0.0 +* @see Condition +* @see Filter +*/ + +public enum BracketOperator { + /** + * Left parenthesis. + */ + OPEN, + + /** + * Right parenthesis. + */ + CLOSE; + + /* + * (non-Javadoc) + * @see java.lang.Enum#toString() + */ + @Override + public String toString() { + switch (this) { + case OPEN: + return "("; + case CLOSE: + return ")"; + default: + return this.toString(); + } + } +} diff --git a/src/main/java/org/eclipse/mdm/api/base/query/ComparisonOperator.java b/src/main/java/org/eclipse/mdm/api/base/query/ComparisonOperator.java index 04399f6..549b9f2 100644 --- a/src/main/java/org/eclipse/mdm/api/base/query/ComparisonOperator.java +++ b/src/main/java/org/eclipse/mdm/api/base/query/ComparisonOperator.java @@ -1,16 +1,16 @@ -/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
+/******************************************************************************** + * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ package org.eclipse.mdm.api.base.query; diff --git a/src/main/java/org/eclipse/mdm/api/base/query/Condition.java b/src/main/java/org/eclipse/mdm/api/base/query/Condition.java index 0b50469..d96b041 100644 --- a/src/main/java/org/eclipse/mdm/api/base/query/Condition.java +++ b/src/main/java/org/eclipse/mdm/api/base/query/Condition.java @@ -1,16 +1,16 @@ -/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
+/******************************************************************************** + * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ package org.eclipse.mdm.api.base.query; diff --git a/src/main/java/org/eclipse/mdm/api/base/query/DataAccessException.java b/src/main/java/org/eclipse/mdm/api/base/query/DataAccessException.java index 0c6dda6..551420e 100644 --- a/src/main/java/org/eclipse/mdm/api/base/query/DataAccessException.java +++ b/src/main/java/org/eclipse/mdm/api/base/query/DataAccessException.java @@ -1,16 +1,16 @@ -/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
+/******************************************************************************** + * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ package org.eclipse.mdm.api.base.query; diff --git a/src/main/java/org/eclipse/mdm/api/base/query/Filter.java b/src/main/java/org/eclipse/mdm/api/base/query/Filter.java index bed881d..674834c 100644 --- a/src/main/java/org/eclipse/mdm/api/base/query/Filter.java +++ b/src/main/java/org/eclipse/mdm/api/base/query/Filter.java @@ -1,16 +1,16 @@ -/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
+/******************************************************************************** + * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ package org.eclipse.mdm.api.base.query; diff --git a/src/main/java/org/eclipse/mdm/api/base/query/FilterItem.java b/src/main/java/org/eclipse/mdm/api/base/query/FilterItem.java index 919def9..d2f0e99 100644 --- a/src/main/java/org/eclipse/mdm/api/base/query/FilterItem.java +++ b/src/main/java/org/eclipse/mdm/api/base/query/FilterItem.java @@ -1,16 +1,16 @@ -/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
+/******************************************************************************** + * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ package org.eclipse.mdm.api.base.query; diff --git a/src/main/java/org/eclipse/mdm/api/base/query/JoinType.java b/src/main/java/org/eclipse/mdm/api/base/query/JoinType.java index 5480dad..1876613 100644 --- a/src/main/java/org/eclipse/mdm/api/base/query/JoinType.java +++ b/src/main/java/org/eclipse/mdm/api/base/query/JoinType.java @@ -1,16 +1,16 @@ -/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
+/******************************************************************************** + * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ package org.eclipse.mdm.api.base.query; diff --git a/src/main/java/org/eclipse/mdm/api/base/query/Query.java b/src/main/java/org/eclipse/mdm/api/base/query/Query.java index 512974a..b45b941 100644 --- a/src/main/java/org/eclipse/mdm/api/base/query/Query.java +++ b/src/main/java/org/eclipse/mdm/api/base/query/Query.java @@ -1,16 +1,16 @@ -/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
+/******************************************************************************** + * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ package org.eclipse.mdm.api.base.query; diff --git a/src/main/java/org/eclipse/mdm/api/base/query/QueryService.java b/src/main/java/org/eclipse/mdm/api/base/query/QueryService.java index 4e3f213..6e46f39 100644 --- a/src/main/java/org/eclipse/mdm/api/base/query/QueryService.java +++ b/src/main/java/org/eclipse/mdm/api/base/query/QueryService.java @@ -1,34 +1,34 @@ -/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
-
-package org.eclipse.mdm.api.base.query;
-
-/**
- * The {@link QueryService} provides access to the low level query API.
- *
- * A {@link Query}, created by this service, can be used to build and execute
- * queries on the underlying datastore. The results are returned as a list
- * of {@link Result}s.
- *
- * @since 1.0.0
- */
-public interface QueryService {
-
- /**
- * Creates a new and empty {@link Query}.
- *
- * @return Created {@code Query} is returned.
- */
- Query createQuery();
-}
+/******************************************************************************** + * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ + +package org.eclipse.mdm.api.base.query; + +/** + * The {@link QueryService} provides access to the low level query API. + * + * A {@link Query}, created by this service, can be used to build and execute + * queries on the underlying datastore. The results are returned as a list + * of {@link Result}s. + * + * @since 1.0.0 + */ +public interface QueryService { + + /** + * Creates a new and empty {@link Query}. + * + * @return Created {@code Query} is returned. + */ + Query createQuery(); +} diff --git a/src/main/java/org/eclipse/mdm/api/base/query/Record.java b/src/main/java/org/eclipse/mdm/api/base/query/Record.java index 47e685c..81a66d9 100644 --- a/src/main/java/org/eclipse/mdm/api/base/query/Record.java +++ b/src/main/java/org/eclipse/mdm/api/base/query/Record.java @@ -1,16 +1,16 @@ -/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
+/******************************************************************************** + * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ package org.eclipse.mdm.api.base.query; diff --git a/src/main/java/org/eclipse/mdm/api/base/query/Result.java b/src/main/java/org/eclipse/mdm/api/base/query/Result.java index 8ad4a68..5e13ea0 100644 --- a/src/main/java/org/eclipse/mdm/api/base/query/Result.java +++ b/src/main/java/org/eclipse/mdm/api/base/query/Result.java @@ -1,16 +1,16 @@ -/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
+/******************************************************************************** + * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ package org.eclipse.mdm.api.base.query; diff --git a/src/main/java/org/eclipse/mdm/api/base/search/SearchQuery.java b/src/main/java/org/eclipse/mdm/api/base/search/SearchQuery.java index d881a6a..f5d807c 100644 --- a/src/main/java/org/eclipse/mdm/api/base/search/SearchQuery.java +++ b/src/main/java/org/eclipse/mdm/api/base/search/SearchQuery.java @@ -1,16 +1,16 @@ -/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
+/******************************************************************************** + * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ package org.eclipse.mdm.api.base.search; diff --git a/src/main/java/org/eclipse/mdm/api/base/search/SearchService.java b/src/main/java/org/eclipse/mdm/api/base/search/SearchService.java index 6337df7..a4f57cd 100644 --- a/src/main/java/org/eclipse/mdm/api/base/search/SearchService.java +++ b/src/main/java/org/eclipse/mdm/api/base/search/SearchService.java @@ -1,404 +1,404 @@ -/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
-
-
-package org.eclipse.mdm.api.base.search;
-
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.mdm.api.base.adapter.Attribute;
-import org.eclipse.mdm.api.base.adapter.EntityType;
-import org.eclipse.mdm.api.base.adapter.Relation;
-import org.eclipse.mdm.api.base.model.Entity;
-import org.eclipse.mdm.api.base.model.Value;
-import org.eclipse.mdm.api.base.query.DataAccessException;
-import org.eclipse.mdm.api.base.query.Filter;
-import org.eclipse.mdm.api.base.query.Record;
-import org.eclipse.mdm.api.base.query.Result;
-
-/**
- * This search service uses given {@link Entity} type to execute the associated
- * predefined {@link SearchQuery} and returns the results.
- *
- * @since 1.0.0
- * @author Viktor Stoehr, Gigatronik Ingolstadt GmbH
- * @author Sebastian Dirsch, Gigatronik Ingolstadt GmbH
- * @see EntityType
- * @see Searchable
- * @see Attribute
- * @see Value
- * @see Filter
- * @see Result
- */
-public interface SearchService {
-
- /**
- * Returns all {@link Entity} types this search service provides a
- * predefined {@link SearchQuery} for.
- *
- * @return The returned {@code List} with supported types may be immutable.
- */
- List<Class<? extends Entity>> listSearchableTypes();
-
- /**
- * Returns all {@link EntityType}s supported by the {@link SearchQuery}
- * associated with given {@link Entity} type.
- *
- * @param entityClass
- * Used as the {@code SearchQuery} identifier.
- * @return The returned {@code List} may be immutable.
- * @throws IllegalArgumentException
- * Thrown if given type is not associated with a predefined
- * {@code SearchQuery}.
- * @see #listSearchableTypes()
- */
- List<EntityType> listEntityTypes(Class<? extends Entity> entityClass);
-
- /**
- * Returns the {@link Searchable}, which describes a hierarchical order of
- * the {@link EntityType}s supported by the {@link SearchQuery} associated
- * with given {@link Entity} type.
- *
- * @param entityClass
- * Used as the {@code SearchQuery} identifier.
- * @return The {@code Searchable} root is returned.
- * @throws IllegalArgumentException
- * Thrown if given type is not associated with a predefined
- * {@code SearchQuery}.
- * @see #listSearchableTypes()
- */
- Searchable getSearchableRoot(Class<? extends Entity> entityClass);
-
- /**
- * Returns the distinct {@link Value} sequence for given {@link Attribute}.
- * The {@code Attribute} must be supported by the {@link SearchQuery}
- * associated with given {@link Entity} type. The returned {@code Value}
- * sequence is intended to be used for building filter criteria.
- *
- * @param entityClass
- * Used as the {@code SearchQuery} identifier.
- * @param attribute
- * The {@code Attribute} whose distinct values will be queried.
- * @return A distinct {@code List} of all available {@code Value}s is
- * returned.
- * @throws DataAccessException
- * Thrown in case of errors while executing the query or
- * generating the distinct {@code Value} sequence.
- * @throws IllegalArgumentException
- * Thrown if given type is not associated with a predefined
- * {@code SearchQuery}.
- * @see #listSearchableTypes()
- * @see #getSearchableRoot(Class)
- * @see #listEntityTypes(Class)
- * @see #getFilterValues(Class, Attribute, Filter)
- */
- default List<Value> getFilterValues(Class<? extends Entity> entityClass, Attribute attribute)
- throws DataAccessException {
- return getFilterValues(entityClass, attribute, Filter.and());
- }
-
- /**
- * Returns the distinct {@link Value} sequence for given {@link Attribute}
- * and {@link Filter}. Both must be fully supported by the
- * {@link SearchQuery} associated with given {@link Entity} type. The
- * returned {@code Value} sequence is intended to be used for building
- * filter criteria.
- *
- * @param entityClass
- * Used as the {@code SearchQuery} identifier.
- * @param attribute
- * The {@code Attribute} whose distinct values will be queried.
- * @param filter
- * The criteria sequence.
- * @return A distinct {@code List} of {@code Value}s is returned.
- * @throws DataAccessException
- * Thrown in case of errors while executing the query or
- * generating the distinct {@code Value} sequence.
- * @throws IllegalArgumentException
- * Thrown if given type is not associated with a predefined
- * {@code SearchQuery}.
- * @see #listSearchableTypes()
- * @see #getSearchableRoot(Class)
- * @see #listEntityTypes(Class)
- * @see #getFilterValues(Class, Attribute)
- */
- List<Value> getFilterValues(Class<? extends Entity> entityClass, Attribute attribute, Filter filter)
- throws DataAccessException;
-
- /**
- * Executes the associated {@link SearchQuery} with given
- * {@link EntityType}s. The {@code EntityType}s must be fully supported by
- * the {@code SearchQuery} associated with given {@link Entity} type. This
- * method selects all {@link Attribute}s of each given {@code EntityType}.
- *
- * It is only guaranteed that this method loads the selected entities,
- * and their relations among themselves. No information about additional related entities
- * is necessarily loaded.
- *
- * <p>
- * <b>Note:</b> Related {@code Record}s may be merged according to the
- * cardinality of the associated {@link Relation}.
- *
- * @param <T>
- * Type of the entities that will be generated for each result.
- * @param entityCass
- * Used as the {@code SearchQuery} identifier.
- * @param entityTypes
- * Select statements will be added for all {@code Attribute}s of
- * each given {@code EntityType}.
- * @return All matched entities are returned in a {@code List}.
- * @throws DataAccessException
- * Thrown in case of errors while executing the
- * {@code SearchQuery} or analyzing its {@code Result}s.
- * @throws IllegalArgumentException
- * Thrown if given type is not associated with a predefined
- * {@code SearchQuery}.
- * @see #listSearchableTypes()
- * @see #getSearchableRoot(Class)
- * @see #listEntityTypes(Class)
- * @see #fetch(Class, List)
- * @see Record#merge(Record)
- */
- default <T extends Entity> List<T> fetchComplete(Class<T> entityCass, List<EntityType> entityTypes)
- throws DataAccessException {
- return fetchComplete(entityCass, entityTypes, Filter.and());
- }
-
- /**
- * Executes the associated {@link SearchQuery} with given
- * {@link EntityType}s and {@link Filter}. Both must be fully supported by
- * the {@code SearchQuery} associated with given {@link Entity} type. This
- * method selects all {@link Attribute}s of each given {@code EntityType}.
- *
- * It is only guaranteed that this method loads the selected entities,
- * and their relations among themselves. No information about additional related entities
- * is necessarily loaded.
- *
- * <p>
- * <b>Note:</b> Related {@code Record}s may be merged according to the
- * cardinality of the associated {@link Relation}.
- *
- * @param <T>
- * Type of the entities that will be generated for each. result.
- * @param entityClass
- * Used as the {@code SearchQuery} identifier.
- * @param entityTypes
- * Select statements will be added for all {@code Attribute}s of
- * each given {@code EntityType}.
- * @param filter
- * The criteria sequence.
- * @return All matched entities are returned in a {@code List}.
- * @throws DataAccessException
- * Thrown in case of errors while executing the
- * {@code SearchQuery} or analyzing its {@code Result}s.
- * @throws IllegalArgumentException
- * Thrown if given type is not associated with a predefined
- * {@code SearchQuery}.
- * @see #listSearchableTypes()
- * @see #getSearchableRoot(Class)
- * @see #listEntityTypes(Class)
- * @see #fetch(Class, List, Filter)
- * @see Record#merge(Record)
- */
- <T extends Entity> List<T> fetchComplete(Class<T> entityClass, List<EntityType> entityTypes, Filter filter)
- throws DataAccessException;
-
- /**
- * Executes the associated {@link SearchQuery} and returns all available
- * instances of the specified {@link Entity} type.
- *
- * It is only guaranteed that this method loads the selected entity,
- * no information about related entities is necessarily loaded.
- *
- * @param <T>
- * Type of the entities that will be generated for each result.
- * @param entityClass
- * Used as the {@code SearchQuery} identifier.
- * @return All available entities are returned in a {@code List}.
- * @throws DataAccessException
- * Thrown in case of errors while executing the
- * {@code SearchQuery} or analyzing its {@code Result}s.
- * @throws IllegalArgumentException
- * Thrown if given type is not associated with a predefined
- * {@code SearchQuery}.
- * @see #listSearchableTypes()
- * @see #fetch(Class, Filter)
- */
- default <T extends Entity> List<T> fetch(Class<T> entityClass) throws DataAccessException {
- return fetch(entityClass, Filter.and());
- }
-
- /**
- * Executes the associated {@link SearchQuery} with given {@link Filter}.
- * The {@code Filter} must be fully supported by the {@code SearchQuery}
- * associated with given {@link Entity} type.
- * It is only guaranteed that this method loads the selected entity,
- * no information about related entities is necessarily loaded.
- *
- *
- * @param <T>
- * Type of the entities that will be generated for each result.
- * @param entityClass
- * Used as the {@code SearchQuery} identifier.
- * @param filter
- * The criteria sequence.
- * @return All matched entities are returned in a {@code List}.
- * @throws DataAccessException
- * Thrown in case of errors while executing the
- * {@code SearchQuery} or analyzing its {@code Result}s.
- * @throws IllegalArgumentException
- * Thrown if given type is not associated with a predefined
- * {@code SearchQuery}.
- * @see #listSearchableTypes()
- * @see #getSearchableRoot(Class)
- * @see #listEntityTypes(Class)
- * @see #fetch(Class)
- */
- default <T extends Entity> List<T> fetch(Class<T> entityClass, Filter filter) throws DataAccessException {
- return fetch(entityClass, Collections.emptyList(), filter);
- }
-
- /**
- * Executes the associated {@link SearchQuery} with given
- * {@link Attribute}s. The {@code Attribute}s must be fully supported by the
- * {@code SearchQuery} associated with given {@link Entity} type. This
- * method allows fine grained {@link Record} configuration.
- *
- * It is only guaranteed that this method loads the selected entity or attributes,
- * no additional information about related entities is necessarily loaded.
- *
- * <p>
- * <b>Note:</b> Related {@code Record}s may be merged according to the
- * cardinality of the associated {@link Relation}.
- *
- * @param <T>
- * Type of the entities that will be generated for each result.
- * @param entityClass
- * Used as the {@code SearchQuery} identifier.
- * @param attributes
- * Select statements will be added for each {@code
- * Attribute}.
- * @return All matched entities are returned in a {@code List}.
- * @throws DataAccessException
- * Thrown in case of errors while executing the
- * {@code SearchQuery} or analyzing its {@code Result}s.
- * @throws IllegalArgumentException
- * Thrown if given type is not associated with a predefined
- * {@code SearchQuery}.
- * @see #listSearchableTypes()
- * @see #getSearchableRoot(Class)
- * @see #listEntityTypes(Class)
- * @see #fetchComplete(Class, List)
- * @see Record#merge(Record)
- */
- default <T extends Entity> List<T> fetch(Class<T> entityClass, List<Attribute> attributes)
- throws DataAccessException {
- return fetch(entityClass, attributes, Filter.and());
- }
-
- /**
- * Executes the associated {@link SearchQuery} with given {@link Attribute}s
- * and {@link Filter}. Both must be fully supported by the
- * {@code SearchQuery} associated with given {@link Entity} type. This
- * method allows fine grained {@link Record} configuration.
- *
- * It is only guaranteed that this method loads the selected entity or attributes,
- * no additional information about related entities is necessarily loaded.
- *
- * <p>
- * <b>Note:</b> Related {@code Record}s may be merged according to the
- * cardinality of the associated {@link Relation}.
- *
- * @param <T>
- * Type of the entities that will be generated for each result.
- * @param entityClass
- * Used as the {@code SearchQuery} identifier.
- * @param attributes
- * Select statements will be added for each {@code
- * Attribute}.
- * @param filter
- * The criteria sequence.
- * @return All matched entities are returned in a {@code List}.
- * @throws DataAccessException
- * Thrown in case of errors while executing the
- * {@code SearchQuery} or analyzing its {@code Result}s.
- * @throws IllegalArgumentException
- * Thrown if given type is not associated with a predefined
- * {@code SearchQuery}.
- * @see #listSearchableTypes()
- * @see #getSearchableRoot(Class)
- * @see #listEntityTypes(Class)
- * @see #fetchComplete(Class, List, Filter)
- * @see Record#merge(Record)
- */
- <T extends Entity> List<T> fetch(Class<T> entityClass, List<Attribute> attributes, Filter filter)
- throws DataAccessException;
-
- /**
- * Executes the associated {@link SearchQuery} with given {@link Attribute}s
- * and {@link Filter}. Both must be fully supported by the
- * {@code SearchQuery} associated with given {@link Entity} type. This
- * method allows fine grained {@link Record} configuration. This method
- * allows to specify a fulltext search query string.
- *
- * It is only guaranteed that this method loads the selected entity or attributes,
- * no additional information about related entities is necessarily loaded.
- *
- * <p>
- * <b>Note:</b> Related {@code Record}s may be merged according to the
- * cardinality of the associated {@link Relation}.
- *
- * @param entityClass
- * Used as the {@code SearchQuery} identifier.
- * @param attributes
- * Select statements will be added for each {@code
- * Attribute}.
- * @param filter
- * The criteria sequence.
- * @param query
- * The fulltext search query
- * @return All {@link Result}s found by the {@link SearchQuery} with given
- * {@link Attribute}s.
- * @throws DataAccessException
- * Thrown in case of errors while executing the
- * {@code SearchQuery} or analyzing its {@code Result}s.
- * @throws IllegalArgumentException
- * Thrown if given type is not associated with a predefined
- * {@code SearchQuery}.
- * @see #listSearchableTypes()
- * @see #getSearchableRoot(Class)
- * @see #listEntityTypes(Class)
- * @see Record#merge(Record)
- */
- default List<Result> fetchResults(Class<? extends Entity> entityClass, List<Attribute> attributes, Filter filter,
- String query) throws DataAccessException {
- throw new UnsupportedOperationException();
- }
-
- default boolean isTextSearchAvailable() {
- return false;
- }
-
- @SuppressWarnings("unchecked")
- default <T extends Entity> List<T> fetch(Class<T> entityClass, String query) throws DataAccessException {
- return (List<T>) fetch(query).getOrDefault(entityClass, Collections.emptyList());
- }
-
- default Map<Class<? extends Entity>, List<Entity>> fetch(String query) throws DataAccessException {
- throw new UnsupportedOperationException();
- }
-
-}
+/******************************************************************************** + * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ + + +package org.eclipse.mdm.api.base.search; + +import java.util.Collections; +import java.util.List; +import java.util.Map; + +import org.eclipse.mdm.api.base.adapter.Attribute; +import org.eclipse.mdm.api.base.adapter.EntityType; +import org.eclipse.mdm.api.base.adapter.Relation; +import org.eclipse.mdm.api.base.model.Entity; +import org.eclipse.mdm.api.base.model.Value; +import org.eclipse.mdm.api.base.query.DataAccessException; +import org.eclipse.mdm.api.base.query.Filter; +import org.eclipse.mdm.api.base.query.Record; +import org.eclipse.mdm.api.base.query.Result; + +/** + * This search service uses given {@link Entity} type to execute the associated + * predefined {@link SearchQuery} and returns the results. + * + * @since 1.0.0 + * @author Viktor Stoehr, Gigatronik Ingolstadt GmbH + * @author Sebastian Dirsch, Gigatronik Ingolstadt GmbH + * @see EntityType + * @see Searchable + * @see Attribute + * @see Value + * @see Filter + * @see Result + */ +public interface SearchService { + + /** + * Returns all {@link Entity} types this search service provides a + * predefined {@link SearchQuery} for. + * + * @return The returned {@code List} with supported types may be immutable. + */ + List<Class<? extends Entity>> listSearchableTypes(); + + /** + * Returns all {@link EntityType}s supported by the {@link SearchQuery} + * associated with given {@link Entity} type. + * + * @param entityClass + * Used as the {@code SearchQuery} identifier. + * @return The returned {@code List} may be immutable. + * @throws IllegalArgumentException + * Thrown if given type is not associated with a predefined + * {@code SearchQuery}. + * @see #listSearchableTypes() + */ + List<EntityType> listEntityTypes(Class<? extends Entity> entityClass); + + /** + * Returns the {@link Searchable}, which describes a hierarchical order of + * the {@link EntityType}s supported by the {@link SearchQuery} associated + * with given {@link Entity} type. + * + * @param entityClass + * Used as the {@code SearchQuery} identifier. + * @return The {@code Searchable} root is returned. + * @throws IllegalArgumentException + * Thrown if given type is not associated with a predefined + * {@code SearchQuery}. + * @see #listSearchableTypes() + */ + Searchable getSearchableRoot(Class<? extends Entity> entityClass); + + /** + * Returns the distinct {@link Value} sequence for given {@link Attribute}. + * The {@code Attribute} must be supported by the {@link SearchQuery} + * associated with given {@link Entity} type. The returned {@code Value} + * sequence is intended to be used for building filter criteria. + * + * @param entityClass + * Used as the {@code SearchQuery} identifier. + * @param attribute + * The {@code Attribute} whose distinct values will be queried. + * @return A distinct {@code List} of all available {@code Value}s is + * returned. + * @throws DataAccessException + * Thrown in case of errors while executing the query or + * generating the distinct {@code Value} sequence. + * @throws IllegalArgumentException + * Thrown if given type is not associated with a predefined + * {@code SearchQuery}. + * @see #listSearchableTypes() + * @see #getSearchableRoot(Class) + * @see #listEntityTypes(Class) + * @see #getFilterValues(Class, Attribute, Filter) + */ + default List<Value> getFilterValues(Class<? extends Entity> entityClass, Attribute attribute) + throws DataAccessException { + return getFilterValues(entityClass, attribute, Filter.and()); + } + + /** + * Returns the distinct {@link Value} sequence for given {@link Attribute} + * and {@link Filter}. Both must be fully supported by the + * {@link SearchQuery} associated with given {@link Entity} type. The + * returned {@code Value} sequence is intended to be used for building + * filter criteria. + * + * @param entityClass + * Used as the {@code SearchQuery} identifier. + * @param attribute + * The {@code Attribute} whose distinct values will be queried. + * @param filter + * The criteria sequence. + * @return A distinct {@code List} of {@code Value}s is returned. + * @throws DataAccessException + * Thrown in case of errors while executing the query or + * generating the distinct {@code Value} sequence. + * @throws IllegalArgumentException + * Thrown if given type is not associated with a predefined + * {@code SearchQuery}. + * @see #listSearchableTypes() + * @see #getSearchableRoot(Class) + * @see #listEntityTypes(Class) + * @see #getFilterValues(Class, Attribute) + */ + List<Value> getFilterValues(Class<? extends Entity> entityClass, Attribute attribute, Filter filter) + throws DataAccessException; + + /** + * Executes the associated {@link SearchQuery} with given + * {@link EntityType}s. The {@code EntityType}s must be fully supported by + * the {@code SearchQuery} associated with given {@link Entity} type. This + * method selects all {@link Attribute}s of each given {@code EntityType}. + * + * It is only guaranteed that this method loads the selected entities, + * and their relations among themselves. No information about additional related entities + * is necessarily loaded. + * + * <p> + * <b>Note:</b> Related {@code Record}s may be merged according to the + * cardinality of the associated {@link Relation}. + * + * @param <T> + * Type of the entities that will be generated for each result. + * @param entityCass + * Used as the {@code SearchQuery} identifier. + * @param entityTypes + * Select statements will be added for all {@code Attribute}s of + * each given {@code EntityType}. + * @return All matched entities are returned in a {@code List}. + * @throws DataAccessException + * Thrown in case of errors while executing the + * {@code SearchQuery} or analyzing its {@code Result}s. + * @throws IllegalArgumentException + * Thrown if given type is not associated with a predefined + * {@code SearchQuery}. + * @see #listSearchableTypes() + * @see #getSearchableRoot(Class) + * @see #listEntityTypes(Class) + * @see #fetch(Class, List) + * @see Record#merge(Record) + */ + default <T extends Entity> List<T> fetchComplete(Class<T> entityCass, List<EntityType> entityTypes) + throws DataAccessException { + return fetchComplete(entityCass, entityTypes, Filter.and()); + } + + /** + * Executes the associated {@link SearchQuery} with given + * {@link EntityType}s and {@link Filter}. Both must be fully supported by + * the {@code SearchQuery} associated with given {@link Entity} type. This + * method selects all {@link Attribute}s of each given {@code EntityType}. + * + * It is only guaranteed that this method loads the selected entities, + * and their relations among themselves. No information about additional related entities + * is necessarily loaded. + * + * <p> + * <b>Note:</b> Related {@code Record}s may be merged according to the + * cardinality of the associated {@link Relation}. + * + * @param <T> + * Type of the entities that will be generated for each. result. + * @param entityClass + * Used as the {@code SearchQuery} identifier. + * @param entityTypes + * Select statements will be added for all {@code Attribute}s of + * each given {@code EntityType}. + * @param filter + * The criteria sequence. + * @return All matched entities are returned in a {@code List}. + * @throws DataAccessException + * Thrown in case of errors while executing the + * {@code SearchQuery} or analyzing its {@code Result}s. + * @throws IllegalArgumentException + * Thrown if given type is not associated with a predefined + * {@code SearchQuery}. + * @see #listSearchableTypes() + * @see #getSearchableRoot(Class) + * @see #listEntityTypes(Class) + * @see #fetch(Class, List, Filter) + * @see Record#merge(Record) + */ + <T extends Entity> List<T> fetchComplete(Class<T> entityClass, List<EntityType> entityTypes, Filter filter) + throws DataAccessException; + + /** + * Executes the associated {@link SearchQuery} and returns all available + * instances of the specified {@link Entity} type. + * + * It is only guaranteed that this method loads the selected entity, + * no information about related entities is necessarily loaded. + * + * @param <T> + * Type of the entities that will be generated for each result. + * @param entityClass + * Used as the {@code SearchQuery} identifier. + * @return All available entities are returned in a {@code List}. + * @throws DataAccessException + * Thrown in case of errors while executing the + * {@code SearchQuery} or analyzing its {@code Result}s. + * @throws IllegalArgumentException + * Thrown if given type is not associated with a predefined + * {@code SearchQuery}. + * @see #listSearchableTypes() + * @see #fetch(Class, Filter) + */ + default <T extends Entity> List<T> fetch(Class<T> entityClass) throws DataAccessException { + return fetch(entityClass, Filter.and()); + } + + /** + * Executes the associated {@link SearchQuery} with given {@link Filter}. + * The {@code Filter} must be fully supported by the {@code SearchQuery} + * associated with given {@link Entity} type. + * It is only guaranteed that this method loads the selected entity, + * no information about related entities is necessarily loaded. + * + * + * @param <T> + * Type of the entities that will be generated for each result. + * @param entityClass + * Used as the {@code SearchQuery} identifier. + * @param filter + * The criteria sequence. + * @return All matched entities are returned in a {@code List}. + * @throws DataAccessException + * Thrown in case of errors while executing the + * {@code SearchQuery} or analyzing its {@code Result}s. + * @throws IllegalArgumentException + * Thrown if given type is not associated with a predefined + * {@code SearchQuery}. + * @see #listSearchableTypes() + * @see #getSearchableRoot(Class) + * @see #listEntityTypes(Class) + * @see #fetch(Class) + */ + default <T extends Entity> List<T> fetch(Class<T> entityClass, Filter filter) throws DataAccessException { + return fetch(entityClass, Collections.emptyList(), filter); + } + + /** + * Executes the associated {@link SearchQuery} with given + * {@link Attribute}s. The {@code Attribute}s must be fully supported by the + * {@code SearchQuery} associated with given {@link Entity} type. This + * method allows fine grained {@link Record} configuration. + * + * It is only guaranteed that this method loads the selected entity or attributes, + * no additional information about related entities is necessarily loaded. + * + * <p> + * <b>Note:</b> Related {@code Record}s may be merged according to the + * cardinality of the associated {@link Relation}. + * + * @param <T> + * Type of the entities that will be generated for each result. + * @param entityClass + * Used as the {@code SearchQuery} identifier. + * @param attributes + * Select statements will be added for each {@code + * Attribute}. + * @return All matched entities are returned in a {@code List}. + * @throws DataAccessException + * Thrown in case of errors while executing the + * {@code SearchQuery} or analyzing its {@code Result}s. + * @throws IllegalArgumentException + * Thrown if given type is not associated with a predefined + * {@code SearchQuery}. + * @see #listSearchableTypes() + * @see #getSearchableRoot(Class) + * @see #listEntityTypes(Class) + * @see #fetchComplete(Class, List) + * @see Record#merge(Record) + */ + default <T extends Entity> List<T> fetch(Class<T> entityClass, List<Attribute> attributes) + throws DataAccessException { + return fetch(entityClass, attributes, Filter.and()); + } + + /** + * Executes the associated {@link SearchQuery} with given {@link Attribute}s + * and {@link Filter}. Both must be fully supported by the + * {@code SearchQuery} associated with given {@link Entity} type. This + * method allows fine grained {@link Record} configuration. + * + * It is only guaranteed that this method loads the selected entity or attributes, + * no additional information about related entities is necessarily loaded. + * + * <p> + * <b>Note:</b> Related {@code Record}s may be merged according to the + * cardinality of the associated {@link Relation}. + * + * @param <T> + * Type of the entities that will be generated for each result. + * @param entityClass + * Used as the {@code SearchQuery} identifier. + * @param attributes + * Select statements will be added for each {@code + * Attribute}. + * @param filter + * The criteria sequence. + * @return All matched entities are returned in a {@code List}. + * @throws DataAccessException + * Thrown in case of errors while executing the + * {@code SearchQuery} or analyzing its {@code Result}s. + * @throws IllegalArgumentException + * Thrown if given type is not associated with a predefined + * {@code SearchQuery}. + * @see #listSearchableTypes() + * @see #getSearchableRoot(Class) + * @see #listEntityTypes(Class) + * @see #fetchComplete(Class, List, Filter) + * @see Record#merge(Record) + */ + <T extends Entity> List<T> fetch(Class<T> entityClass, List<Attribute> attributes, Filter filter) + throws DataAccessException; + + /** + * Executes the associated {@link SearchQuery} with given {@link Attribute}s + * and {@link Filter}. Both must be fully supported by the + * {@code SearchQuery} associated with given {@link Entity} type. This + * method allows fine grained {@link Record} configuration. This method + * allows to specify a fulltext search query string. + * + * It is only guaranteed that this method loads the selected entity or attributes, + * no additional information about related entities is necessarily loaded. + * + * <p> + * <b>Note:</b> Related {@code Record}s may be merged according to the + * cardinality of the associated {@link Relation}. + * + * @param entityClass + * Used as the {@code SearchQuery} identifier. + * @param attributes + * Select statements will be added for each {@code + * Attribute}. + * @param filter + * The criteria sequence. + * @param query + * The fulltext search query + * @return All {@link Result}s found by the {@link SearchQuery} with given + * {@link Attribute}s. + * @throws DataAccessException + * Thrown in case of errors while executing the + * {@code SearchQuery} or analyzing its {@code Result}s. + * @throws IllegalArgumentException + * Thrown if given type is not associated with a predefined + * {@code SearchQuery}. + * @see #listSearchableTypes() + * @see #getSearchableRoot(Class) + * @see #listEntityTypes(Class) + * @see Record#merge(Record) + */ + default List<Result> fetchResults(Class<? extends Entity> entityClass, List<Attribute> attributes, Filter filter, + String query) throws DataAccessException { + throw new UnsupportedOperationException(); + } + + default boolean isTextSearchAvailable() { + return false; + } + + @SuppressWarnings("unchecked") + default <T extends Entity> List<T> fetch(Class<T> entityClass, String query) throws DataAccessException { + return (List<T>) fetch(query).getOrDefault(entityClass, Collections.emptyList()); + } + + default Map<Class<? extends Entity>, List<Entity>> fetch(String query) throws DataAccessException { + throw new UnsupportedOperationException(); + } + +} diff --git a/src/main/java/org/eclipse/mdm/api/base/search/Searchable.java b/src/main/java/org/eclipse/mdm/api/base/search/Searchable.java index e1bb19b..d40551b 100644 --- a/src/main/java/org/eclipse/mdm/api/base/search/Searchable.java +++ b/src/main/java/org/eclipse/mdm/api/base/search/Searchable.java @@ -1,16 +1,16 @@ -/********************************************************************************
- * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
- *
- * See the NOTICE file(s) distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- ********************************************************************************/
+/******************************************************************************** + * Copyright (c) 2015-2018 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ package org.eclipse.mdm.api.base.search; |