diff options
author | Matthias Koller | 2019-02-27 11:11:18 +0000 |
---|---|---|
committer | Matthias Koller | 2019-02-27 11:11:18 +0000 |
commit | dc302e9323bb05368f7a259a22d348dbe6bc7b5a (patch) | |
tree | c6e441873bbcf2ce4315ae6caae7bfa2a0621fbf | |
parent | 7c38f056bafadd329742108b934f9184bbc7b53d (diff) | |
parent | 0a78ac1369a84a94a517c88225030357d97afd52 (diff) | |
download | org.eclipse.mdm.api.base-dc302e9323bb05368f7a259a22d348dbe6bc7b5a.tar.gz org.eclipse.mdm.api.base-dc302e9323bb05368f7a259a22d348dbe6bc7b5a.tar.xz org.eclipse.mdm.api.base-dc302e9323bb05368f7a259a22d348dbe6bc7b5a.zip |
Merge branch 'dev'
Change-Id: I44eb5537b6160a6d956da95764e8a2bdc36a20d9
18 files changed, 680 insertions, 346 deletions
@@ -17,13 +17,13 @@ For more information regarding authorship of content, please consult the listed source code repository logs. Copyright (c) 2016-2018 Gigatronik Ingolstadt GmbH -Copyright (c) 2016-2018 Peak Solution GmbH +Copyright (c) 2016-2019 Peak Solution GmbH Copyright (c) 2017-2018 science + computing AG Tuebingen (ATOS SE) Copyright (c) 2017-2018 Canoo Engineering AG Copyright (c) 2017 Florian Schmitt -Copyright (c) 2017-2018 Angelika Wittek +Copyright (c) 2017-2019 Angelika Wittek Copyright (c) 2018 Elektronische Fahrwerksysteme GMBH -Copyright (c) 2018 Karakun AG +Copyright (c) 2018-2019 Karakun AG ## Declared Project Licenses @@ -61,7 +61,13 @@ commons-codec-1.2.jar (1.2) commons-httpclient-3.1.jar (3.1) * License: Apache License, 2.0 -commons-lang3-3.4.jar (3.4) +commons-lang3-3.8.1.jar (3.8.1) + * License: Apache License, 2.0 + +commons-text-1.6.jar (1.6) + * License: Apache License, 2.0 + +commons-math-2.2.jar (2.2) * License: Apache License, 2.0 gson-2.7.jar (2.7) @@ -71,7 +77,7 @@ Google Guava Version: 25.0-jre (25.0) * License: Apache License, 2.0 Gradle Wrapper (4.10.2) - * License: Apache License, 2.0 + * License: Apache License, 2.0 hk2-api-2.5.0-b05.jar (2.5.0-b05) * License: CDDL-1.1 @@ -130,6 +136,9 @@ jersey-media-jaxb-2.23.2.jar(2.23.2) jersey-media-sse-2.23.2.jar (2.23.2) * License: CDDL +jersey-media-multipart-2.23.2.jar (2.23.2) + * License: CDDL + jersey-server-2.23.2.jar (2.23.2) * License: Apache-2.0 @@ -317,10 +326,10 @@ Permission of use: From Dr. Ralph Noerenberg Date: 08/15/2016 "Herewith, we release the generated Client-Source-Code generated from our CORBA IDLs, namely -* CORBANotification Service (generated from „AvalonEvent.idl”) -* CORBAFileServer (generated from „CorbaFileServer.idl“), -Under the Eclipse Public License (EPL). This agreement does not include the „AvalonEvent.idl“ and -„CorbaFileServer.idl“ itself, which remain protected property of HighQSoft. " +* CORBANotification Service (generated from AvalonEvent.idl) +* CORBAFileServer (generated from CorbaFileServer.idl), +Under the Eclipse Public License (EPL). This agreement does not include the AvalonEvent.idl and +CorbaFileServer.idl itself, which remain protected property of HighQSoft. " OMG Notification Service Specification Version: 1.1 The terms of use are defined in section "Freely Available And Available diff --git a/build.gradle b/build.gradle index 23ed413..768c495 100644 --- a/build.gradle +++ b/build.gradle @@ -15,7 +15,7 @@ description = 'MDM API - Base Model'
group = 'org.eclipse.mdm'
-version = '5.1.0M1'
+version = '5.1.0M2-SNAPSHOT'
apply plugin: 'java'
apply plugin: 'maven'
@@ -36,4 +36,13 @@ dependencies { jar {
metaInf { from 'NOTICE.txt' }
metaInf { from 'LICENSE.txt' }
+}
+
+task sourcesJar(type: Jar, dependsOn: classes) {
+ classifier = 'sources'
+ from sourceSets.main.allSource
+}
+
+artifacts {
+ archives sourcesJar
}
\ No newline at end of file diff --git a/src/main/java/org/eclipse/mdm/api/base/BaseEntityManager.java b/src/main/java/org/eclipse/mdm/api/base/BaseEntityManager.java index 9a24edb..98a7ec5 100644 --- a/src/main/java/org/eclipse/mdm/api/base/BaseEntityManager.java +++ b/src/main/java/org/eclipse/mdm/api/base/BaseEntityManager.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; @@ -272,6 +272,14 @@ public interface BaseEntityManager { throws DataAccessException; /** + * @param entity The entity + * @param relationName The name of the relation, which entities should be loaded. + * @param relatedClass Class of the related entities. + * @return The related entities for the given {@link Entity} and relationName + */ + <T extends Entity> List<T> loadRelatedEntities(Entity entity, String relationName, Class<T> relatedClass); + + /** * Retrieves the {@link MeasuredValues} as specified by the given * {@link ReadRequest}. * diff --git a/src/main/java/org/eclipse/mdm/api/base/adapter/Core.java b/src/main/java/org/eclipse/mdm/api/base/adapter/Core.java index 0726073..aec71eb 100644 --- a/src/main/java/org/eclipse/mdm/api/base/adapter/Core.java +++ b/src/main/java/org/eclipse/mdm/api/base/adapter/Core.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; @@ -197,4 +197,12 @@ public interface Core { // as it is not permitted to go to the other stores. Does this work at all? ChildrenStore getChildrenStore(); + /** + * Returns the {@link RelationStore}. This store holds related + * entities for N to M relations. + * + * @return The {@link RelationStore} is returned + */ + RelationStore getNtoMStore(); + } diff --git a/src/main/java/org/eclipse/mdm/api/base/adapter/DefaultCore.java b/src/main/java/org/eclipse/mdm/api/base/adapter/DefaultCore.java index 47958b6..e5a5bf8 100644 --- a/src/main/java/org/eclipse/mdm/api/base/adapter/DefaultCore.java +++ b/src/main/java/org/eclipse/mdm/api/base/adapter/DefaultCore.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; @@ -48,6 +48,7 @@ public class DefaultCore implements Core { private final EntityStore permanentEntityStorage = new EntityStore(); private final EntityStore mutableEntityStorage = new EntityStore(); private final ChildrenStore childrenStore = new ChildrenStore(); + private final RelationStore ntoMStore = new RelationStore(); private final Map<String, Value> values = new HashMap<>(); private final Map<String, Value> hiddenValues = new HashMap<>(); @@ -194,4 +195,12 @@ public class DefaultCore implements Core { return childrenStore; } + /** + * {@inheritDoc} + */ + @Override + public RelationStore getNtoMStore() { + return ntoMStore; + } + } diff --git a/src/main/java/org/eclipse/mdm/api/base/adapter/Relation.java b/src/main/java/org/eclipse/mdm/api/base/adapter/Relation.java index 5257061..f281524 100644 --- a/src/main/java/org/eclipse/mdm/api/base/adapter/Relation.java +++ b/src/main/java/org/eclipse/mdm/api/base/adapter/Relation.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; @@ -111,4 +111,10 @@ public interface Relation { */ boolean isIncoming(RelationType relationType); + /** + * Checks whether this relation is a N to M relation. + * + * @return Returns {@code true} if this relation is N to M. + */ + boolean isNtoM(); } diff --git a/src/main/java/org/eclipse/mdm/api/base/adapter/RelationStore.java b/src/main/java/org/eclipse/mdm/api/base/adapter/RelationStore.java new file mode 100644 index 0000000..9c2e7b6 --- /dev/null +++ b/src/main/java/org/eclipse/mdm/api/base/adapter/RelationStore.java @@ -0,0 +1,115 @@ +/******************************************************************************** + * 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 RelationStore { + + private final Map<String, List<? extends Deletable>> added = new HashMap<>(0); + private final Map<String, 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<String, List<? extends Deletable>> getAdded() { + return Collections.unmodifiableMap(added); + } + + /** + * Returns current set of removed related children mapped by their type. + * + * @return Returned {@code Map} is unmodifiable. + */ + public Map<String, 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(String relation) { + return Collections.unmodifiableList((List<T>) added.computeIfAbsent(relation, 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(String relation, Comparator<? super T> comparator) { + List<T> children = (List<T>) added.get(relation); + if (children != null) { + children.sort(comparator); + } + } + + /** + * Adds given child entity. + * + * @param child + * The new child. + */ + @SuppressWarnings("unchecked") + public void add(String relation, Deletable relatedEntity) { + removed.getOrDefault(relation, new ArrayList<>()).remove(relatedEntity); + ((List<Deletable>) added.computeIfAbsent(relation, k -> new ArrayList<>())).add(relatedEntity); + } + + /** + * Removes given child entity. + * + * @param relatedEntity + * The child which will be removed. + */ + @SuppressWarnings("unchecked") + public void remove(String relation, Deletable relatedEntity) { + added.getOrDefault(relation, new ArrayList<>()).remove(relatedEntity); + ((List<Deletable>) removed.computeIfAbsent(relation, k -> new ArrayList<>())).add(relatedEntity); + } + + /** + * 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/massdata/IndependentBuilder.java b/src/main/java/org/eclipse/mdm/api/base/massdata/IndependentBuilder.java index c7dcff4..9e303d9 100644 --- a/src/main/java/org/eclipse/mdm/api/base/massdata/IndependentBuilder.java +++ b/src/main/java/org/eclipse/mdm/api/base/massdata/IndependentBuilder.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; @@ -70,5 +70,16 @@ public class IndependentBuilder extends WriteRequestFinalizer { getWriteRequest().setIndependent(); return this; } + + /** + * Triggers the measured values of the underlying {@link Channel} to be + * independent or not, depending on the value specified. + * + * @return The {@link WriteRequestFinalizer} is returned. + */ + public final WriteRequestFinalizer independent(boolean independent) { + getWriteRequest().setIndependent(independent); + return this; + } } diff --git a/src/main/java/org/eclipse/mdm/api/base/massdata/ReadRequest.java b/src/main/java/org/eclipse/mdm/api/base/massdata/ReadRequest.java index c664cfb..5fb5834 100644 --- a/src/main/java/org/eclipse/mdm/api/base/massdata/ReadRequest.java +++ b/src/main/java/org/eclipse/mdm/api/base/massdata/ReadRequest.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; @@ -21,6 +21,7 @@ import java.util.Map; import org.eclipse.mdm.api.base.model.Channel; import org.eclipse.mdm.api.base.model.ChannelGroup; +import org.eclipse.mdm.api.base.model.SequenceRepresentation; import org.eclipse.mdm.api.base.model.Unit; /** @@ -31,6 +32,20 @@ import org.eclipse.mdm.api.base.model.Unit; * @author Sebastian Dirsch, Gigatronik Ingolstadt GmbH */ public final class ReadRequest { + public enum ValuesMode + { + /** + * MeasuredValues will contain the final values, calculated for non-explicit sequence representations + * using generation parameters and, if applicable, the raw values. + * No generation parameters are returned in the resulting MeasuredValues, {@link SequenceRepresentation} will + * be EXPLICIT. + */ + CALCULATED, + /** + * MeasuredValues will contain the (raw) values and generation parameters as present in the storage. + */ + STORAGE + } // ====================================================================== // Instance variables @@ -43,6 +58,8 @@ public final class ReadRequest { private int requestSize = 100_000; private int startIndex; + + private ValuesMode valuesMode = ValuesMode.CALCULATED; // ====================================================================== // Constructors @@ -60,6 +77,7 @@ public final class ReadRequest { loadAllChannels = readRequest.loadAllChannels; requestSize = readRequest.getRequestSize(); startIndex = readRequest.getStartIndex() + readRequest.getRequestSize(); + valuesMode = readRequest.getValuesMode(); } /** @@ -161,6 +179,15 @@ public final class ReadRequest { public int getStartIndex() { return startIndex; } + + /** + * Returns the {link ValuesMode} for measured values retrieval. + * + * @return The valuesMode is returned. + */ + public ValuesMode getValuesMode() { + return valuesMode; + } // ====================================================================== // Package methods @@ -229,6 +256,17 @@ public final class ReadRequest { void setStartIndex(int startIndex) { this.startIndex = startIndex; } + + /** + * Sets the {@link ValuesMode} for measured values retrieval. + * + * @param valuesMode + * The {@link VAluesMode} to set. + */ + void setValuesMode(ValuesMode valuesMode) + { + this.valuesMode = valuesMode; + } /** * Checks whether there are still more values to retrieve. diff --git a/src/main/java/org/eclipse/mdm/api/base/massdata/ReadRequestBuilder.java b/src/main/java/org/eclipse/mdm/api/base/massdata/ReadRequestBuilder.java index 458e39d..980f75b 100644 --- a/src/main/java/org/eclipse/mdm/api/base/massdata/ReadRequestBuilder.java +++ b/src/main/java/org/eclipse/mdm/api/base/massdata/ReadRequestBuilder.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; @@ -18,6 +18,7 @@ package org.eclipse.mdm.api.base.massdata; import java.util.Arrays; import java.util.List; +import org.eclipse.mdm.api.base.massdata.ReadRequest.ValuesMode; import org.eclipse.mdm.api.base.model.Channel; import org.eclipse.mdm.api.base.model.Unit; @@ -157,6 +158,18 @@ public final class ReadRequestBuilder { } /** + * Configures the valuesMode. + * @param valuesMode + * {@link ValuesMode} to use for the read request. + * @return This builder is returned. + */ + public ReadRequestBuilder valuesMode(ReadRequest.ValuesMode valuesMode) + { + readRequest.setValuesMode(valuesMode); + return this; + } + + /** * Configures the {@link ReadRequest} to load all measured values of each * configured {@link Channel} and returns the configured {@code * ReadRequest}. diff --git a/src/main/java/org/eclipse/mdm/api/base/massdata/WriteRequest.java b/src/main/java/org/eclipse/mdm/api/base/massdata/WriteRequest.java index 6b2a70b..d440a53 100644 --- a/src/main/java/org/eclipse/mdm/api/base/massdata/WriteRequest.java +++ b/src/main/java/org/eclipse/mdm/api/base/massdata/WriteRequest.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; @@ -300,6 +300,16 @@ public final class WriteRequest { void setIndependent() { independent = true; } + + /** + * Sets the independent flag for this request to the value specified. + * + * @param independent + * The independent flag. + */ + void setIndependent(boolean independent) { + this.independent = independent; + } /** * Triggers an adjustment of the generation parameters and modification of diff --git a/src/main/java/org/eclipse/mdm/api/base/model/MeasuredValues.java b/src/main/java/org/eclipse/mdm/api/base/model/MeasuredValues.java index fe0ffca..b12aada 100644 --- a/src/main/java/org/eclipse/mdm/api/base/model/MeasuredValues.java +++ b/src/main/java/org/eclipse/mdm/api/base/model/MeasuredValues.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; @@ -43,14 +43,19 @@ public final class MeasuredValues { /* * TODO: - replace name and unit with the corresponding Channel & Unit - * entities - provide AxisType, Independent flag and further informations if - * required - provide an overall offset for this value sequence + * entities - provide further information if required + * - provide an overall offset for this value sequence */ private final String name; private final String unit; private final int length; + + private final SequenceRepresentation sequenceRepresentation; + private final double[] generationParameters; + private final boolean independent; + private final AxisType axisType; // ====================================================================== // Constructors @@ -65,6 +70,14 @@ public final class MeasuredValues { * This is the name of the corresponding {@link Channel}. * @param unit * Name of the unit the contained values are of. + * @param sequenceRepresentation + * The {@link SequenceRepresentation} of the measured values. + * @param generationParameters + * The generation parameters for the measured values. + * @param independent + * The independent flag of the measured values. + * @param axisType + * The {@link AxisType} of the measured values. * @param values * The measured values. * @param flags @@ -73,10 +86,14 @@ public final class MeasuredValues { * Thrown if values or flags is null or length of values and * flags is not equal. */ - MeasuredValues(ScalarType scalarType, String name, String unit, Object values, boolean[] flags) { + MeasuredValues(ScalarType scalarType, String name, String unit, SequenceRepresentation sequenceRepresentation, double[] generationParameters, boolean independent, AxisType axisType, Object values, boolean[] flags) { this.name = name; - this.unit = unit == null ? "" : unit; + this.unit = (unit == null ? "" : unit); this.scalarType = scalarType; + this.sequenceRepresentation = sequenceRepresentation; + this.generationParameters = generationParameters; + this.independent = independent; + this.axisType = axisType; this.values = values; if (values == null || flags == null) { @@ -128,6 +145,42 @@ public final class MeasuredValues { public int getLength() { return length; } + + /** + * Returns the {@link SequenceRepresentation} of this measured values sequence. + * + * @return The {@code SequenceRepresentation} is returned. + */ + public SequenceRepresentation getSequenceRepresentation() { + return sequenceRepresentation; + } + + /** + * Returns the generation parameters for this measured values sequence. + * + * @return The generation parameters are returned. + */ + public double[] getGenerationParameters() { + return generationParameters; + } + + /** + * Returns the independent flag of this measured values sequence. + * + * @return The independent flag is returned. + */ + public boolean isIndependent() { + return independent; + } + + /** + * Returns the {@link AxisType} of this measured values sequence. + * + * @return The {@code AxisType} is returned. + */ + public AxisType getAxisType() { + return axisType; + } /** * Returns a typed {@link ValueIterator}. Its usage is described below: diff --git a/src/main/java/org/eclipse/mdm/api/base/model/Measurement.java b/src/main/java/org/eclipse/mdm/api/base/model/Measurement.java index d4c1917..b2ab8ec 100644 --- a/src/main/java/org/eclipse/mdm/api/base/model/Measurement.java +++ b/src/main/java/org/eclipse/mdm/api/base/model/Measurement.java @@ -16,6 +16,7 @@ package org.eclipse.mdm.api.base.model; import java.time.LocalDateTime; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -153,9 +154,22 @@ public class Measurement extends BaseEntity * {@inheritDoc} */ @Override - public Map<ContextType, ContextRoot> loadContexts(BaseEntityManager manager, - ContextType... contextTypes) throws DataAccessException { - return manager.loadContexts(this, contextTypes); + public Map<ContextType, ContextRoot> loadContexts(BaseEntityManager manager, ContextType... contextTypes) + throws DataAccessException { + + Map<ContextType, ContextRoot> map = new HashMap<>(); + + for (ContextType contextType : contextTypes) { + ContextRoot c = getCore().getMutableStore().get(ContextRoot.class, contextType); + if (c != null) { + map.put(contextType, c); + } + } + if (map.isEmpty()) { + return manager.loadContexts(this, contextTypes); + } else { + return map; + } } } diff --git a/src/main/java/org/eclipse/mdm/api/base/model/ScalarType.java b/src/main/java/org/eclipse/mdm/api/base/model/ScalarType.java index fb3784e..a13775e 100644 --- a/src/main/java/org/eclipse/mdm/api/base/model/ScalarType.java +++ b/src/main/java/org/eclipse/mdm/api/base/model/ScalarType.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; @@ -174,6 +174,12 @@ public final class ScalarType extends EnumerationValue { * This is the name of the corresponding {@link Channel}. * @param unit * Name of the unit the contained values are of. + * @param sequenceRepresentation + * The {@link SequenceRepresentation} of the measured values. + * @param independent + * The independent flag of the measured values. + * @param axisType + * The {@link AxisType} of the measured values. * @param input * The measured values. * @param flags @@ -185,14 +191,14 @@ public final class ScalarType extends EnumerationValue { * @throws IllegalArgumentException * Thrown if given values are not assignment compatible. */ - public MeasuredValues createMeasuredValues(String name, String unit, Object input, boolean[] flags) { + public MeasuredValues createMeasuredValues(String name, String unit, SequenceRepresentation sequenceRepresentation, double[] generationParameters, boolean independent, AxisType axisType, Object input, boolean[] flags) { if (isEnumeration() || isUnknown()) { throw new IllegalStateException("It is not allowed to create measured values of type '" + this + "'."); } else if (!arrayType.isInstance(input)) { throw new IllegalArgumentException("Given values of type '" + input.getClass() + "'."); } - return new MeasuredValues(this, name, unit, input, flags); + return new MeasuredValues(this, name, unit, sequenceRepresentation, generationParameters, independent, axisType, input, flags); } /** diff --git a/src/main/java/org/eclipse/mdm/api/base/model/TestStep.java b/src/main/java/org/eclipse/mdm/api/base/model/TestStep.java index 85e07af..9f42915 100644 --- a/src/main/java/org/eclipse/mdm/api/base/model/TestStep.java +++ b/src/main/java/org/eclipse/mdm/api/base/model/TestStep.java @@ -1,20 +1,21 @@ -/********************************************************************************
- * 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; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -113,7 +114,20 @@ public class TestStep extends BaseEntity implements ContextDescribable, Datable, @Override public Map<ContextType, ContextRoot> loadContexts(BaseEntityManager manager, ContextType... contextTypes) throws DataAccessException { - return manager.loadContexts(this, contextTypes); + + Map<ContextType, ContextRoot> map = new HashMap<>(); + + for (ContextType contextType : contextTypes) { + ContextRoot c = getCore().getMutableStore().get(ContextRoot.class, contextType); + if (c != null) { + map.put(contextType, c); + } + } + if (map.isEmpty()) { + return manager.loadContexts(this, contextTypes); + } else { + return map; + } } } diff --git a/src/test/java/org/eclipse/mdm/api/base/CoreImpl.java b/src/test/java/org/eclipse/mdm/api/base/CoreImpl.java index 82356db..895c17b 100755 --- a/src/test/java/org/eclipse/mdm/api/base/CoreImpl.java +++ b/src/test/java/org/eclipse/mdm/api/base/CoreImpl.java @@ -1,94 +1,100 @@ -/********************************************************************************
- * 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 java.util.Map;
-
-import org.eclipse.mdm.api.base.adapter.ChildrenStore;
-import org.eclipse.mdm.api.base.adapter.Core;
-import org.eclipse.mdm.api.base.adapter.EntityStore;
-import org.eclipse.mdm.api.base.model.Value;
-
-/**
- *
- * Very basic implementation of the Core class. The contents is initialized via
- * a given map (instead of using a database or some other method)
- *
- * @author Florian Schmitt
- */
-public class CoreImpl implements Core {
-
- private Map<String, Value> values;
- private EntityStore mutableStore;
-
- public CoreImpl(Map<String, Value> values) {
- super();
- this.values = values;
- this.mutableStore = new EntityStore();
- }
-
- @Override
- public String getSourceName() {
- return "UnitTestSource";
- }
-
- @Override
- public String getTypeName() {
- return "UnitTestType";
- }
-
- @Override
- public String getID() {
- return "4711l";
- }
-
- @Override
- public void setID(String instanceID) {
-
- }
-
- @Override
- public Map<String, Value> getValues() {
- return values;
- }
-
- @Override
- public void hideValues(Collection<String> names) {
-
- }
-
- @Override
- public Map<String, Value> getAllValues() {
- return values;
- }
-
- @Override
- public EntityStore getMutableStore() {
- return mutableStore;
- }
-
- @Override
- public EntityStore getPermanentStore() {
- return new EntityStore();
- }
-
- @Override
- public ChildrenStore getChildrenStore() {
- return new ChildrenStore();
- }
-
+/******************************************************************************** + * 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 java.util.Map; + +import org.eclipse.mdm.api.base.adapter.ChildrenStore; +import org.eclipse.mdm.api.base.adapter.Core; +import org.eclipse.mdm.api.base.adapter.EntityStore; +import org.eclipse.mdm.api.base.adapter.RelationStore; +import org.eclipse.mdm.api.base.model.Value; + +/** + * + * Very basic implementation of the Core class. The contents is initialized via + * a given map (instead of using a database or some other method) + * + * @author Florian Schmitt + */ +public class CoreImpl implements Core { + + private Map<String, Value> values; + private EntityStore mutableStore; + + public CoreImpl(Map<String, Value> values) { + super(); + this.values = values; + this.mutableStore = new EntityStore(); + } + + @Override + public String getSourceName() { + return "UnitTestSource"; + } + + @Override + public String getTypeName() { + return "UnitTestType"; + } + + @Override + public String getID() { + return "4711l"; + } + + @Override + public void setID(String instanceID) { + + } + + @Override + public Map<String, Value> getValues() { + return values; + } + + @Override + public void hideValues(Collection<String> names) { + + } + + @Override + public Map<String, Value> getAllValues() { + return values; + } + + @Override + public EntityStore getMutableStore() { + return mutableStore; + } + + @Override + public EntityStore getPermanentStore() { + return new EntityStore(); + } + + @Override + public ChildrenStore getChildrenStore() { + return new ChildrenStore(); + } + + @Override + public RelationStore getNtoMStore() { + return new RelationStore(); + } + }
\ No newline at end of file diff --git a/src/test/java/org/eclipse/mdm/api/base/RelationImpl.java b/src/test/java/org/eclipse/mdm/api/base/RelationImpl.java index 576c8e9..5df7172 100755 --- a/src/test/java/org/eclipse/mdm/api/base/RelationImpl.java +++ b/src/test/java/org/eclipse/mdm/api/base/RelationImpl.java @@ -1,74 +1,79 @@ -/********************************************************************************
- * 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 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.adapter.RelationType;
-
-public class RelationImpl implements Relation {
-
- public enum AttributeType {
- ID, UNKNOWN;
- }
-
- AttributeType type;
-
- public RelationImpl(AttributeType type) {
- this.type = type;
- }
-
- @Override
- public String getName() {
- return type.name();
- }
-
- @Override
- public EntityType getSource() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public EntityType getTarget() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public RelationType getRelationType() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Attribute getAttribute() {
- switch (type) {
- case ID:
- return new AttributeImpl(AttributeImpl.Type.ID);
- default:
- throw new UnsupportedOperationException();
- }
- }
-
- @Override
- public boolean isOutgoing(RelationType relationType) {
- return true;
- }
-
- @Override
- public boolean isIncoming(RelationType relationType) {
- return false;
- }
-}
+/******************************************************************************** + * 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 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.adapter.RelationType; + +public class RelationImpl implements Relation { + + public enum AttributeType { + ID, UNKNOWN; + } + + AttributeType type; + + public RelationImpl(AttributeType type) { + this.type = type; + } + + @Override + public String getName() { + return type.name(); + } + + @Override + public EntityType getSource() { + throw new UnsupportedOperationException(); + } + + @Override + public EntityType getTarget() { + throw new UnsupportedOperationException(); + } + + @Override + public RelationType getRelationType() { + throw new UnsupportedOperationException(); + } + + @Override + public Attribute getAttribute() { + switch (type) { + case ID: + return new AttributeImpl(AttributeImpl.Type.ID); + default: + throw new UnsupportedOperationException(); + } + } + + @Override + public boolean isOutgoing(RelationType relationType) { + return true; + } + + @Override + public boolean isIncoming(RelationType relationType) { + return false; + } + + @Override + public boolean isNtoM() { + return false; + } +} diff --git a/src/test/java/org/eclipse/mdm/api/base/model/ModelTest.java b/src/test/java/org/eclipse/mdm/api/base/model/ModelTest.java index 1c115d1..a21db22 100755 --- a/src/test/java/org/eclipse/mdm/api/base/model/ModelTest.java +++ b/src/test/java/org/eclipse/mdm/api/base/model/ModelTest.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; @@ -70,7 +70,7 @@ public class ModelTest { public void measuredValueFloat() { Float[] vals = { 1.0f, 2.0f, 3.7f, 2.1f }; boolean[] flags = { true, true, false, true }; - MeasuredValues mv = new MeasuredValues(ScalarType.FLOAT, "Value1", "lightyears", vals, flags); + MeasuredValues mv = new MeasuredValues(ScalarType.FLOAT, "Value1", "lightyears", SequenceRepresentation.EXPLICIT, new double[0], false, AxisType.Y_AXIS, vals, flags); ValueIterator<Float> valueIterator = mv.iterator(); int i = 0; while (valueIterator.hasNext()) { @@ -90,7 +90,7 @@ public class ModelTest { public void measuredValueDouble() { Double[] vals = { 1.0d, 2.0d, 3.7d, 2.1d }; boolean[] flags = { true, true, false, true }; - MeasuredValues mv = new MeasuredValues(ScalarType.DOUBLE, "Value1", "lightyears", vals, flags); + MeasuredValues mv = new MeasuredValues(ScalarType.DOUBLE, "Value1", "lightyears", SequenceRepresentation.EXPLICIT, new double[0], false, AxisType.Y_AXIS, vals, flags); ValueIterator<Double> valueIterator = mv.iterator(); int i = 0; while (valueIterator.hasNext()) { @@ -110,7 +110,7 @@ public class ModelTest { public void measuredValueString() { String[] vals = { "str1", "str2", "str3", "str4" }; boolean[] flags = { true, true, false, true }; - MeasuredValues mv = new MeasuredValues(ScalarType.STRING, "Value1", "lightyears", vals, flags); + MeasuredValues mv = new MeasuredValues(ScalarType.STRING, "Value1", "lightyears", SequenceRepresentation.EXPLICIT, new double[0], false, AxisType.Y_AXIS, vals, flags); ValueIterator<String> valueIterator = mv.iterator(); int i = 0; while (valueIterator.hasNext()) { |