Merge branch 'dev' into mkoller/atfxadapter
Conflicts:
build.gradle
Signed-off-by: Matthias Koller <m.koller@peak-solution.de>
diff --git a/build.gradle b/build.gradle
index ef239a0..462505e 100644
--- a/build.gradle
+++ b/build.gradle
@@ -14,7 +14,7 @@
description = 'MDM API - Default Model'
group = 'org.eclipse.mdm'
-version = '5.1.0M8-SNAPSHOT'
+version = '5.1.0M8-ATFX-SNAPSHOT'
apply plugin: 'java'
apply plugin: 'maven'
diff --git a/src/main/java/org/eclipse/mdm/api/dflt/EntityManager.java b/src/main/java/org/eclipse/mdm/api/dflt/EntityManager.java
index 1f42019..00f6ac0 100644
--- a/src/main/java/org/eclipse/mdm/api/dflt/EntityManager.java
+++ b/src/main/java/org/eclipse/mdm/api/dflt/EntityManager.java
@@ -23,8 +23,12 @@
import org.eclipse.mdm.api.base.model.ContextType;
import org.eclipse.mdm.api.base.model.Entity;
import org.eclipse.mdm.api.base.model.StatusAttachable;
+import org.eclipse.mdm.api.base.model.Test;
+import org.eclipse.mdm.api.base.model.TestStep;
import org.eclipse.mdm.api.base.query.DataAccessException;
import org.eclipse.mdm.api.dflt.model.Status;
+import org.eclipse.mdm.api.dflt.model.TemplateTest;
+import org.eclipse.mdm.api.dflt.model.TemplateTestStep;
import org.eclipse.mdm.api.dflt.model.Versionable;
/**
@@ -144,4 +148,19 @@
}
<T extends StatusAttachable> List<T> loadAll(Class<T> entityClass, Status status, String pattern);
+
+
+ /**
+ * Loads the refereced {@link TemplateTest} for a {@link Test}.
+ * @param test {@link Test} referencing the desired template
+ * @return {@link Optional} with the loaded {@link TemplateTest}
+ */
+ Optional<TemplateTest> loadTemplate(Test test);
+
+ /**
+ * Loads the referenced {@link TemplateTestStep} for a {@link TestStep}
+ * @param testStep {@link TestStep} referencing the desired template
+ * @return {@link Optional} with the loaded {@link TemplateTestStep}
+ */
+ Optional<TemplateTestStep> loadTemplate(TestStep testStep);
}
diff --git a/src/main/java/org/eclipse/mdm/api/dflt/model/EntityFactory.java b/src/main/java/org/eclipse/mdm/api/dflt/model/EntityFactory.java
index f67d546..c199fca 100644
--- a/src/main/java/org/eclipse/mdm/api/dflt/model/EntityFactory.java
+++ b/src/main/java/org/eclipse/mdm/api/dflt/model/EntityFactory.java
@@ -798,6 +798,12 @@
return valueListValue;
}
+ public Classification createClassification(Domain domain, ProjectDomain projectDomain, Status status) {
+ String name = String.format("ProjDomainId_%s.DomainId_%s.StatusId_%s", projectDomain.getID(), domain.getID(),
+ status.getID());
+ return createClassification(name, status, projectDomain, domain);
+ }
+
public Classification createClassification(String name, Status status, ProjectDomain projectDomain, Domain domain) {
Classification classification = new Classification(createCore(Classification.class));
@@ -863,6 +869,80 @@
}
/**
+ *
+ * @param name
+ * @param pool
+ * @param templateTest
+ * @param withTestSteps
+ * @param status
+ * @return
+ */
+ public Test createTest(String name, Pool pool, TemplateTest templateTest, Classification classification,
+ boolean withTestSteps) {
+ // TODO
+ Test test = createTest(name, pool);
+
+ // relations
+ if (templateTest != null) {
+ getCore(test).getMutableStore().set(templateTest);
+ }
+ getCore(test).getMutableStore().set(classification);
+
+ if (withTestSteps && templateTest != null) {
+ // create default active and mandatory test steps according to the
+ // template
+ templateTest.getTemplateTestStepUsages().stream().filter(TemplateTestStepUsage.IS_IMPLICIT_CREATE)
+ .map(TemplateTestStepUsage::getTemplateTestStep).forEach(templateTestStep -> {
+ createTestStep(test, templateTestStep, classification);
+ });
+ }
+
+ return test;
+ }
+
+ /**
+ *
+ * @param test
+ * @param templateTestStep
+ * @param classification
+ * @return
+ */
+ public TestStep createTestStep(Test test, TemplateTestStep templateTestStep, Classification classification) {
+ TestStep testStep = createTestStep(test, templateTestStep);
+ getCore(testStep).getMutableStore().set(classification);
+ return testStep;
+ }
+
+ /**
+ *
+ * @param name
+ * @param test
+ * @param classification
+ * @return
+ */
+ public TestStep createTestStep(String name, Test test, Classification classification) {
+ TestStep testStep = createTestStep(name, test);
+ getCore(testStep).getMutableStore().set(classification);
+ return testStep;
+ }
+
+ /**
+ *
+ * @param name
+ * @param test
+ * @param templateTestStep
+ * @param classification
+ * @return
+ */
+ public TestStep createTestStep(String name, Test test, TemplateTestStep templateTestStep,
+ Classification classification) {
+ TestStep testStep = createTestStep(test, templateTestStep);
+ getCore(testStep).getMutableStore().set(classification);
+ testStep.setName(name);
+ return testStep;
+ }
+
+ /**
* Creates a new {@link Test} for given {@link Pool}.
*
* @param name Name of the created {@code Test}.
@@ -878,10 +958,6 @@
getCore(test).getPermanentStore().set(pool);
getCore(pool).getChildrenStore().add(test);
- if (status != null) {
- status.assign(test);
- }
-
return test;
}
diff --git a/src/main/java/org/eclipse/mdm/api/dflt/model/Status.java b/src/main/java/org/eclipse/mdm/api/dflt/model/Status.java
index 387c482..cdd0c5b 100644
--- a/src/main/java/org/eclipse/mdm/api/dflt/model/Status.java
+++ b/src/main/java/org/eclipse/mdm/api/dflt/model/Status.java
@@ -68,7 +68,13 @@
* @param statusAttachable This status will be assigned to it.
*/
public <T extends StatusAttachable> void assign(T statusAttachable) {
- getCore(statusAttachable).getMutableStore().set(this);
+ Classification classification = getCore(statusAttachable).getMutableStore().get(Classification.class);
+ if (classification == null) {
+ // TODO exceptionhandling or create classification
+ throw new RuntimeException("Mandatory element classification not found!");
+ }
+
+ getCore(classification).getMutableStore().set(this);
}
/**