Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMorgan E. Cook2017-08-23 16:24:04 -0400
committerMorgan Cook2017-08-29 20:26:56 -0400
commite02581faedfc8d647fd9ce0b1aabc5815ea69fc0 (patch)
treef243068911ef5ef0370e4606330874d4e5baa40d
parent799f6b4527e3398c8e72c6914fa26f2a07d3108e (diff)
downloadorg.eclipse.osee-e02581faedfc8d647fd9ce0b1aabc5815ea69fc0.tar.gz
org.eclipse.osee-e02581faedfc8d647fd9ce0b1aabc5815ea69fc0.tar.xz
org.eclipse.osee-e02581faedfc8d647fd9ce0b1aabc5815ea69fc0.zip
refactor: Cleanup ApplicabilityEndpoint
Signed-off-by: Morgan E. Cook <morgan.e.cook@boeing.com> Change-Id: I183ace7d90fba88a07026376d5f93e428cd16012
-rw-r--r--plugins/org.eclipse.osee.define.report/src/org/eclipse/osee/define/report/internal/wordupdate/WordUpdateArtifact.java10
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/word/WordTemplateProcessor.java2
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xviewer/skynet/column/ViewApplicabilityColumn.java2
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/ApplicabilityQueryImpl.java187
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/QueryFactoryImpl.java2
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/TransactionBuilderImpl.java104
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/ApplicabilityEndpoint.java109
-rw-r--r--plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/ApplicabilityEndpointImpl.java308
-rw-r--r--plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/search/ApplicabilityQuery.java24
-rw-r--r--plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/search/QueryFactory.java1
-rw-r--r--plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/transaction/TransactionBuilder.java14
11 files changed, 431 insertions, 332 deletions
diff --git a/plugins/org.eclipse.osee.define.report/src/org/eclipse/osee/define/report/internal/wordupdate/WordUpdateArtifact.java b/plugins/org.eclipse.osee.define.report/src/org/eclipse/osee/define/report/internal/wordupdate/WordUpdateArtifact.java
index db3e5286d4..6d8748bcfb 100644
--- a/plugins/org.eclipse.osee.define.report/src/org/eclipse/osee/define/report/internal/wordupdate/WordUpdateArtifact.java
+++ b/plugins/org.eclipse.osee.define.report/src/org/eclipse/osee/define/report/internal/wordupdate/WordUpdateArtifact.java
@@ -239,16 +239,8 @@ public class WordUpdateArtifact {
}
private HashCollection<String, String> getValidFeatureValuesForBranch(BranchId branch) {
- BranchReadable br = orcsApi.getQueryFactory().branchQuery().andId(branch).getResults().getOneOrNull();
- if (br.getBranchType().equals(BranchType.MERGE)) {
- branch = br.getParentBranch();
- }
-
- List<ArtifactReadable> featureDefinitionArts = orcsApi.getQueryFactory().fromBranch(branch).andIsOfType(
- CoreArtifactTypes.FeatureDefinition).getResults().getList();
-
List<FeatureDefinitionData> featureDefinitionData =
- orcsApi.getQueryFactory().applicabilityQuery().getFeatureDefinitionData(featureDefinitionArts);
+ orcsApi.getQueryFactory().applicabilityQuery().getFeatureDefinitionData(branch);
HashCollection<String, String> validFeatureValues = new HashCollection<>();
for (FeatureDefinitionData feat : featureDefinitionData) {
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/word/WordTemplateProcessor.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/word/WordTemplateProcessor.java
index 2614998df9..fa96e6ab8c 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/word/WordTemplateProcessor.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/word/WordTemplateProcessor.java
@@ -296,7 +296,7 @@ public class WordTemplateProcessor {
ApplicabilityEndpoint applEndpoint = ServiceUtil.getOseeClient().getApplicabilityEndpoint(branch);
applicabilityTokens = new HashMap<>();
- Collection<ApplicabilityToken> appTokens = applEndpoint.getApplicabilityTokenMap();
+ Collection<ApplicabilityToken> appTokens = applEndpoint.getApplicabilityTokens();
for (ApplicabilityToken token : appTokens) {
applicabilityTokens.put(token, token);
}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xviewer/skynet/column/ViewApplicabilityColumn.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xviewer/skynet/column/ViewApplicabilityColumn.java
index 22a24e8d83..42243ad1dc 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xviewer/skynet/column/ViewApplicabilityColumn.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xviewer/skynet/column/ViewApplicabilityColumn.java
@@ -82,7 +82,7 @@ public class ViewApplicabilityColumn extends XViewerColumn implements IXViewerPr
BranchId branch = artifacts.iterator().next().getBranch();
ApplicabilityEndpoint applEndpoint = ServiceUtil.getOseeClient().getApplicabilityEndpoint(branch);
List<Pair<ArtifactId, ApplicabilityToken>> applicabilities =
- applEndpoint.getApplicabilityTokensForArts(artifacts);
+ applEndpoint.getApplicabilityTokens(artifacts);
for (Pair<ArtifactId, ApplicabilityToken> pair : applicabilities) {
preComputedValueMap.put(pair.getFirst().getId(), pair.getSecond().getName());
}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/ApplicabilityQueryImpl.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/ApplicabilityQueryImpl.java
index 49a442355e..bec2076d6a 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/ApplicabilityQueryImpl.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/ApplicabilityQueryImpl.java
@@ -16,17 +16,25 @@ import static org.eclipse.osee.framework.core.enums.CoreTupleTypes.ViewApplicabi
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Date;
import java.util.HashMap;
+import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import java.util.function.BiConsumer;
import org.codehaus.jackson.map.ObjectMapper;
+import org.eclipse.osee.framework.core.data.ApplicabilityId;
import org.eclipse.osee.framework.core.data.ApplicabilityToken;
import org.eclipse.osee.framework.core.data.ArtifactId;
import org.eclipse.osee.framework.core.data.BranchId;
import org.eclipse.osee.framework.core.data.BranchViewData;
import org.eclipse.osee.framework.core.data.FeatureDefinitionData;
+import org.eclipse.osee.framework.core.data.TransactionId;
+import org.eclipse.osee.framework.core.enums.BranchType;
+import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
import org.eclipse.osee.framework.core.enums.CoreTupleTypes;
import org.eclipse.osee.framework.jdk.core.type.HashCollection;
@@ -34,7 +42,11 @@ import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.type.Pair;
import org.eclipse.osee.orcs.core.ds.ApplicabilityDsQuery;
import org.eclipse.osee.orcs.data.ArtifactReadable;
+import org.eclipse.osee.orcs.data.BranchReadable;
import org.eclipse.osee.orcs.search.ApplicabilityQuery;
+import org.eclipse.osee.orcs.search.BranchQuery;
+import org.eclipse.osee.orcs.search.QueryFactory;
+import org.eclipse.osee.orcs.search.TransactionQuery;
import org.eclipse.osee.orcs.search.TupleQuery;
/**
@@ -43,10 +55,16 @@ import org.eclipse.osee.orcs.search.TupleQuery;
public class ApplicabilityQueryImpl implements ApplicabilityQuery {
private final TupleQuery tupleQuery;
private final ApplicabilityDsQuery applicabilityDsQuery;
+ private final TransactionQuery transactionQuery;
+ private final BranchQuery branchQuery;
+ private final QueryFactory queryFactory;
- public ApplicabilityQueryImpl(TupleQuery tupleQuery, ApplicabilityDsQuery applicabilityDsQuery) {
- this.tupleQuery = tupleQuery;
+ public ApplicabilityQueryImpl(ApplicabilityDsQuery applicabilityDsQuery, QueryFactory queryFactory) {
+ this.tupleQuery = queryFactory.tupleQuery();
this.applicabilityDsQuery = applicabilityDsQuery;
+ this.transactionQuery = queryFactory.transactionQuery();
+ this.branchQuery = queryFactory.branchQuery();
+ this.queryFactory = queryFactory;
}
@Override
@@ -80,7 +98,42 @@ public class ApplicabilityQueryImpl implements ApplicabilityQuery {
}
@Override
- public List<FeatureDefinitionData> getFeatureDefinitionData(List<ArtifactReadable> featureDefinitionArts) {
+ public List<ApplicabilityId> getApplicabilitiesReferenced(ArtifactId artifact, BranchId branch) {
+ List<ApplicabilityId> appIds = new LinkedList<>();
+ for (ApplicabilityId tuple2 : tupleQuery.getTuple2(CoreTupleTypes.ArtifactReferenceApplicabilityType, branch,
+ artifact)) {
+ appIds.add(tuple2);
+ }
+ return appIds;
+ }
+
+ @Override
+ public List<ApplicabilityToken> getApplicabilityReferenceTokens(ArtifactId artifact, BranchId branch) {
+ List<ApplicabilityToken> tokens = new LinkedList<>();
+ tupleQuery.getTuple2NamedId(CoreTupleTypes.ArtifactReferenceApplicabilityType, branch, artifact,
+ (e2, value) -> tokens.add(ApplicabilityToken.create(e2, value)));
+ return tokens;
+ }
+
+ @Override
+ public List<ApplicabilityToken> getViewApplicabilityTokens(ArtifactId artId, BranchId branch) {
+ List<ApplicabilityToken> result = new ArrayList<>();
+ BiConsumer<Long, String> consumer = (id, name) -> result.add(new ApplicabilityToken(id, name));
+ tupleQuery.getTuple2KeyValuePair(ViewApplicability, artId, branch, consumer);
+ return result;
+ }
+
+ @Override
+ public List<FeatureDefinitionData> getFeatureDefinitionData(BranchId branch) {
+ BranchId branchToUse = branch;
+ BranchReadable br = branchQuery.andId(branch).getResults().getOneOrNull();
+ if (br.getBranchType().equals(BranchType.MERGE)) {
+ branchToUse = br.getParentBranch();
+ }
+
+ List<ArtifactReadable> featureDefinitionArts =
+ queryFactory.fromBranch(branchToUse).andIsOfType(CoreArtifactTypes.FeatureDefinition).getResults().getList();
+
List<FeatureDefinitionData> featureDefinition = new ArrayList<>();
for (ArtifactReadable art : featureDefinitionArts) {
@@ -128,14 +181,6 @@ public class ApplicabilityQueryImpl implements ApplicabilityQuery {
}
@Override
- public List<ApplicabilityToken> getViewApplicabilityTokens(ArtifactId artId, BranchId branch) {
- List<ApplicabilityToken> result = new ArrayList<>();
- BiConsumer<Long, String> consumer = (id, name) -> result.add(new ApplicabilityToken(id, name));
- tupleQuery.getTuple2KeyValuePair(ViewApplicability, artId, branch, consumer);
- return result;
- }
-
- @Override
public List<BranchViewData> getViews() {
HashCollection<BranchId, ArtifactId> branchAndViewIds = new HashCollection<>();
BiConsumer<Long, Long> consumer =
@@ -151,6 +196,66 @@ public class ApplicabilityQueryImpl implements ApplicabilityQuery {
}
@Override
+ public String getViewTable(BranchId branch) {
+ StringBuilder html = new StringBuilder(
+ "<!DOCTYPE html><html><head><style> table { border-spacing: 0px } th,td { padding: 3px; } </style></head><body>");
+ List<BranchViewData> views = this.getViews();
+ for (BranchViewData branchView : views) {
+ if (branchView.getBranch().equals(branch)) {
+ html.append(String.format("<h1>Features for branch [%s]</h1>",
+ branchQuery.andId(branch).getResults().getExactlyOne().getName()));
+ html.append("<table border=\"1\">");
+ List<ArtifactId> branchViews = branchView.getBranchViews();
+
+ List<FeatureDefinitionData> featureDefinitionData = getFeatureDefinitionData(branch);
+
+ Collections.sort(featureDefinitionData, new Comparator<FeatureDefinitionData>() {
+ @Override
+ public int compare(FeatureDefinitionData obj1, FeatureDefinitionData obj2) {
+ return obj1.getName().compareTo(obj2.getName());
+ }
+ });
+
+ printColumnHeadings(html, branchViews, branch);
+ Map<ArtifactId, Map<String, List<String>>> branchViewsMap = new HashMap<>();
+
+ for (ArtifactId artId : branchViews) {
+ branchViewsMap.put(artId, getBranchViewFeatureValues(branch, artId));
+ }
+ for (FeatureDefinitionData featureDefinition : featureDefinitionData) {
+ html.append("<tr>");
+ html.append(String.format("<td>%s</td>", featureDefinition.getName()));
+ html.append(String.format("<td>%s</td>", featureDefinition.getDescription()));
+ for (ArtifactId view : branchViews) {
+ List<String> list = branchViewsMap.get(view).get(featureDefinition.getName());
+ // every view should have a value for each feature, if incorrectly configured returns null
+ if (list != null) {
+ html.append(
+ "<td>" + org.eclipse.osee.framework.jdk.core.util.Collections.toString(",", list) + "</td>");
+ } else {
+ html.append("<td> </td>");
+ }
+ }
+ html.append("</tr>");
+ }
+ }
+ }
+ html.append("</table></body></html>");
+ return html.toString();
+ }
+
+ private void printColumnHeadings(StringBuilder html, List<ArtifactId> branchViews, BranchId branch) {
+ html.append("<tr>");
+ html.append("<th>Feature Name</th>");
+ html.append("<th>Feature Description</th>");
+ for (ArtifactId artId : branchViews) {
+ html.append(String.format("<th>%s</th>",
+ queryFactory.fromBranch(branch).andId(artId).getResults().getExactlyOne().getName()));
+ }
+ html.append("</tr>");
+ }
+
+ @Override
public ArtifactId getVersionConfig(ArtifactId art, BranchId branch) {
Iterable<Long> tuple2 = tupleQuery.getTuple2Raw(CoreTupleTypes.VersionConfig, branch, art);
if (tuple2.iterator().hasNext()) {
@@ -158,4 +263,64 @@ public class ApplicabilityQueryImpl implements ApplicabilityQuery {
}
return ArtifactId.SENTINEL;
}
+
+ @Override
+ public List<BranchId> getAffectedBranches(Long injectDateMs, Long removalDateMs, List<ApplicabilityId> applicabilityIds, BranchId branch) {
+ ArrayList<BranchId> toReturn = new ArrayList<>();
+ Date injection = new Date(injectDateMs);
+ Date removal = new Date(removalDateMs);
+
+ // Get all Branch Views
+ List<BranchViewData> branchViews = getViews();
+
+ HashMap<Long, BranchReadable> childBaselineBranchIds = new HashMap<>();
+ for (BranchReadable childBranch : branchQuery.andIsChildOf(branch).getResults()) {
+ if (childBranch.getBranchType().equals(BranchType.BASELINE)) {
+ childBaselineBranchIds.put(childBranch.getId(), childBranch);
+ }
+ }
+
+ HashMap<Long, ApplicabilityId> applicabilityIdsMap = new HashMap<>();
+ for (ApplicabilityId applicId : applicabilityIds) {
+ applicabilityIdsMap.put(applicId.getId(), applicId);
+ }
+
+ for (BranchViewData branchView : branchViews) {
+ BranchReadable baseBranch = childBaselineBranchIds.get(branchView.getBranch().getId());
+ if (baseBranch != null) {
+ // Check Dates on baseBranch
+ Date baseDate =
+ transactionQuery.andTxId(baseBranch.getBaseTransaction()).getResults().getExactlyOne().getDate();
+ if (baseDate.after(injection) && (removalDateMs == -1 || baseDate.before(removal))) {
+ // now determine what views of this branch are applicable
+ for (ArtifactId view : branchView.getBranchViews()) {
+ // Get all applicability tokens for the view of this branch
+ List<ApplicabilityToken> viewApplicabilityTokens =
+ getViewApplicabilityTokens(view, branchView.getBranch());
+ // Cross check applicabilityTokens with valid ApplicabilityIds sent in
+ for (ApplicabilityToken applicToken : viewApplicabilityTokens) {
+ // If applictoken is found, add toReturn list
+ if (applicabilityIdsMap.containsKey(applicToken.getId())) {
+ toReturn.add(BranchId.create(branchView.getBranch().getId(), view));
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return toReturn;
+ }
+
+ @Override
+ public List<BranchId> getAffectedBranches(TransactionId injectionTx, TransactionId removalTx, List<ApplicabilityId> applicabilityIds, BranchId branch) {
+
+ long timeInjectionMs = transactionQuery.andTxId(injectionTx).getResults().getExactlyOne().getDate().getTime();
+ long timeRemovalMs = removalTx.isInvalid() ? -1 : transactionQuery.andTxId(
+ removalTx).getResults().getExactlyOne().getDate().getTime();
+
+ return getAffectedBranches(timeInjectionMs, timeRemovalMs, applicabilityIds, branch);
+ }
+
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/QueryFactoryImpl.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/QueryFactoryImpl.java
index 0578661949..efe528b309 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/QueryFactoryImpl.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/QueryFactoryImpl.java
@@ -118,6 +118,6 @@ public class QueryFactoryImpl implements QueryFactory {
@Override
public ApplicabilityQuery applicabilityQuery() {
- return new ApplicabilityQueryImpl(tupleQuery, applicabilityDsQuery);
+ return new ApplicabilityQueryImpl(applicabilityDsQuery, this);
}
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/TransactionBuilderImpl.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/TransactionBuilderImpl.java
index 2f9cbfad0d..a7cc3a5595 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/TransactionBuilderImpl.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/TransactionBuilderImpl.java
@@ -10,9 +10,13 @@
*******************************************************************************/
package org.eclipse.osee.orcs.core.internal.transaction;
+import static org.eclipse.osee.framework.core.data.ApplicabilityToken.BASE;
import java.io.InputStream;
import java.util.Arrays;
import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map.Entry;
import org.eclipse.osee.executor.admin.CancellableCallable;
import org.eclipse.osee.framework.core.data.ApplicabilityId;
import org.eclipse.osee.framework.core.data.ArtifactId;
@@ -27,7 +31,11 @@ import org.eclipse.osee.framework.core.data.RelationTypeSide;
import org.eclipse.osee.framework.core.data.Tuple2Type;
import org.eclipse.osee.framework.core.data.Tuple3Type;
import org.eclipse.osee.framework.core.data.Tuple4Type;
+import org.eclipse.osee.framework.core.enums.CoreArtifactTokens;
+import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
+import org.eclipse.osee.framework.core.enums.CoreBranches;
+import org.eclipse.osee.framework.core.enums.CoreTupleTypes;
import org.eclipse.osee.framework.core.enums.RelationSorter;
import org.eclipse.osee.framework.jdk.core.type.Id;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
@@ -39,6 +47,7 @@ import org.eclipse.osee.orcs.core.internal.attribute.Attribute;
import org.eclipse.osee.orcs.core.internal.search.QueryModule;
import org.eclipse.osee.orcs.data.ArtifactReadable;
import org.eclipse.osee.orcs.data.TransactionReadable;
+import org.eclipse.osee.orcs.search.TupleQuery;
import org.eclipse.osee.orcs.transaction.TransactionBuilder;
/**
@@ -353,6 +362,100 @@ public class TransactionBuilderImpl implements TransactionBuilder {
txManager.setApplicabilityId(txData, artId, applicId);
}
+ @Override
+ public void setApplicabilityReference(HashMap<ArtifactId, List<ApplicabilityId>> artifacts) {
+ TupleQuery tupleQuery = query.createQueryFactory(txData.getSession()).tupleQuery();
+
+ for (Entry<? extends ArtifactId, List<ApplicabilityId>> entry : artifacts.entrySet()) {
+ for (ApplicabilityId appId : entry.getValue()) {
+ if (!tupleQuery.doesTuple2Exist(CoreTupleTypes.ArtifactReferenceApplicabilityType, entry.getKey(), appId)) {
+ addTuple2(CoreTupleTypes.ArtifactReferenceApplicabilityType, entry.getKey(), appId);
+ }
+ }
+ }
+ }
+
+ @Override
+ public void setApplicability(ApplicabilityId applicId, List<? extends ArtifactId> artifacts) {
+ for (ArtifactId artifact : artifacts) {
+ setApplicability(artifact, applicId);
+ }
+ }
+
+ @Override
+ public ArtifactId createView(BranchId branch, String viewName) {
+ ArtifactId art = createArtifact(CoreArtifactTypes.BranchView, viewName);
+ ArtifactId folder = query.createQueryFactory(txData.getSession()).fromBranch(branch).andTypeEquals(
+ CoreArtifactTypes.Folder).andNameEquals("Product Line").getResults().getOneOrNull();
+ if (folder == null || folder.isInvalid()) {
+ folder = createArtifact(CoreArtifactTypes.Folder, "Product Line");
+ addChildren(CoreArtifactTokens.DefaultHierarchyRoot, folder);
+ }
+
+ addChildren(folder, art);
+ addTuple2(CoreTupleTypes.BranchView, CoreBranches.COMMON.getId(), art.getId());
+
+ return art;
+ }
+
+ @Override
+ public void createApplicabilityForView(ArtifactId viewId, String applicability) {
+ addTuple2(CoreTupleTypes.ViewApplicability, viewId, applicability);
+
+ }
+
+ @Override
+ public void createDemoApplicability() {
+ ArtifactId config1 = createArtifact(CoreArtifactTypes.BranchView, "Config1");
+ ArtifactId config2 = createArtifact(CoreArtifactTypes.BranchView, "Config2");
+ ArtifactId folder = createArtifact(CoreArtifactTypes.Folder, "Product Line");
+ ArtifactId featureDefinition =
+ createArtifact(CoreArtifactTypes.FeatureDefinition, "Feature Definition_SAW_Bld_1");
+
+ keyValueOps.putByKey(BASE.getId(), BASE.getName());
+
+ addChildren(CoreArtifactTokens.DefaultHierarchyRoot, folder);
+ addChildren(folder, config1, config2, featureDefinition);
+
+ addTuple2(CoreTupleTypes.ViewApplicability, config1, "Base");
+ addTuple2(CoreTupleTypes.ViewApplicability, config2, "Base");
+
+ addTuple2(CoreTupleTypes.ViewApplicability, config1, "Config = Config1");
+ addTuple2(CoreTupleTypes.ViewApplicability, config2, "Config = Config2");
+
+ addTuple2(CoreTupleTypes.ViewApplicability, config1, "A = Included");
+ addTuple2(CoreTupleTypes.ViewApplicability, config2, "A = Excluded");
+
+ addTuple2(CoreTupleTypes.ViewApplicability, config1, "B = Choice1");
+ addTuple2(CoreTupleTypes.ViewApplicability, config2, "B = Choice2");
+ addTuple2(CoreTupleTypes.ViewApplicability, config2, "B = Choice3");
+
+ addTuple2(CoreTupleTypes.ViewApplicability, config1, "C = Included");
+ addTuple2(CoreTupleTypes.ViewApplicability, config2, "C = Excluded");
+
+ String featureDefJson = "[{" + "\"name\": \"A\"," + //
+ "\"type\": \"single\"," + //
+ "\"values\": [\"Included\", \"Excluded\"]," + //
+ "\"defaultValue\": \"Included\"," + //
+ "\"description\": \"Test A\"" + //
+ "}, {" + //
+ "\"name\": \"B\"," + //
+ "\"type\": \"multiple\"," + //
+ "\"values\": [\"Choice1\", \"Choice2\", \"Choice3\"]," + //
+ "\"defaultValue\": \"\"," + //
+ "\"description\": \"Test B\"" + //
+ "},{" + //
+ "\"name\": \"C\"," + //
+ "\"type\": \"single\"," + //
+ "\"values\": [\"Included\", \"Excluded\"]," + //
+ "\"defaultValue\": \"Included\"," + //
+ "\"description\": \"Test C\"" + //
+ "}" + //
+ "]";
+
+ createAttribute(featureDefinition, CoreAttributeTypes.GeneralStringData, featureDefJson);
+ }
+
private Long insertValue(String value) {
return keyValueOps.putIfAbsent(value);
}
@@ -400,4 +503,5 @@ public class TransactionBuilderImpl implements TransactionBuilder {
public <E1, E2, E3, E4> boolean deleteTupple4(Tuple4Type<E1, E2, E3, E4> tupleType, E1 element1, E2 element2, E3 element3, E4 element4) {
return false;
}
+
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/ApplicabilityEndpoint.java b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/ApplicabilityEndpoint.java
index 7f536f5246..3422af5760 100644
--- a/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/ApplicabilityEndpoint.java
+++ b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/ApplicabilityEndpoint.java
@@ -23,7 +23,6 @@ import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
import org.eclipse.osee.framework.core.data.ApplicabilityId;
import org.eclipse.osee.framework.core.data.ApplicabilityToken;
import org.eclipse.osee.framework.core.data.ArtifactId;
@@ -42,27 +41,19 @@ public interface ApplicabilityEndpoint {
@GET
@Produces({MediaType.APPLICATION_JSON})
- List<ApplicabilityToken> getApplicabilityTokens();
+ Collection<ApplicabilityToken> getApplicabilityTokens();
@GET
- @Path("feature/data")
- @Produces({MediaType.APPLICATION_JSON})
- List<FeatureDefinitionData> getFeatureDefinitionData();
+ @Path("artifacts/")
+ @Consumes({MediaType.APPLICATION_JSON})
+ @Produces(MediaType.APPLICATION_JSON)
+ List<Pair<ArtifactId, ApplicabilityToken>> getApplicabilityTokens(@QueryParam("artIds") Collection<? extends ArtifactId> artIds);
@GET
- @Path("view/{viewId}")
- @Produces({MediaType.APPLICATION_JSON})
- List<ApplicabilityToken> getViewApplicabilityTokens(@PathParam("viewId") ArtifactId view);
-
- /**
- * Set the applicabilities referenced by the provided artifacts. This is stored in the tuple table which means it
- * does not impact applicability in a branch view.
- */
- @PUT
- @Path("artifact/reference")
+ @Path("artifact/{artId}")
@Consumes({MediaType.APPLICATION_JSON})
@Produces({MediaType.APPLICATION_JSON})
- Response setApplicabilityReference(HashMap<ArtifactId, List<ApplicabilityId>> artifacts);
+ ApplicabilityToken getApplicabilityToken(@PathParam("artId") ArtifactId artId);
@GET
@Path("artifact/reference/{artId}")
@@ -76,76 +67,86 @@ public interface ApplicabilityEndpoint {
@Produces({MediaType.APPLICATION_JSON})
List<ApplicabilityToken> getApplicabilityReferenceTokens(@PathParam("artId") ArtifactId artifact);
- /**
- * Set the applicability in osee_txs for the given artifacts. This affects whether the artifact is included in a
- * branch view.
- */
- @PUT
- @Path("{applicId}")
+ @GET
+ @Path("view/{viewId}")
@Consumes({MediaType.APPLICATION_JSON})
@Produces({MediaType.APPLICATION_JSON})
- Response setApplicability(@PathParam("applicId") ApplicabilityId applicId, List<? extends ArtifactId> artifacts);
+ List<ApplicabilityToken> getViewApplicabilityTokens(@PathParam("viewId") ArtifactId view);
- @POST
- void createDemoApplicability();
+ @GET
+ @Path("views")
+ @Produces({MediaType.APPLICATION_JSON})
+ List<BranchViewData> getViews();
@GET
- @Path("artifact/{artId}")
- @Consumes({MediaType.APPLICATION_JSON})
+ @Path("feature-data")
@Produces({MediaType.APPLICATION_JSON})
- ApplicabilityToken getApplicabilityToken(@PathParam("artId") ArtifactId artId);
+ List<FeatureDefinitionData> getFeatureDefinitionData();
- @PUT
+ /**
+ * @return a list of branches that contain the injected change (prior to removalDate)
+ * @param injectDateMs & removalDateMs are relative to the change injection/removal into the root branch.
+ * @param removalDateMs if default value of -1 is used, return list of branches after injectionDate
+ */
+ @GET
+ @Path("change/")
@Consumes({MediaType.APPLICATION_JSON})
@Produces(MediaType.APPLICATION_JSON)
- List<Pair<ArtifactId, ApplicabilityToken>> getApplicabilityTokensForArts(Collection<? extends ArtifactId> artIds);
-
- @GET
- @Path("tokenMap")
- @Produces({MediaType.APPLICATION_JSON})
- Collection<ApplicabilityToken> getApplicabilityTokenMap();
+ List<BranchId> getAffectedBranches(@QueryParam("injectionDateMs") Long injectDateMs, @QueryParam("removalDateMs") @DefaultValue("-1") Long removalDateMs, List<ApplicabilityId> applicabilityIds);
@GET
- @Path("views")
- @Produces({MediaType.APPLICATION_JSON})
- List<BranchViewData> getViews();
+ @Path("change/")
+ @Consumes({MediaType.APPLICATION_JSON})
+ @Produces(MediaType.APPLICATION_JSON)
+ List<BranchId> getAffectedBranches(@QueryParam("injectiontx") TransactionId injectionTx, @QueryParam("removaltx") @DefaultValue("-1") TransactionId removalTx, List<ApplicabilityId> applicabilityIds);
@GET
@Path("table")
@Produces({MediaType.TEXT_HTML})
String getViewTable();
+ /**
+ * Set the applicability in osee_txs for the given artifacts. This affects whether the artifact is included in a
+ * branch view.
+ */
@PUT
- @Path("branchview/{branchView}")
+ @Path("{applicId}")
@Consumes({MediaType.APPLICATION_JSON})
- void setView(@PathParam("branchView") ArtifactId branchView);
+ @Produces({MediaType.APPLICATION_JSON})
+ TransactionToken setApplicability(@PathParam("applicId") ApplicabilityId applicId, List<? extends ArtifactId> artifacts);
/**
- * @return a list of branches that contain the injected change (prior to removalDate)
- * @param injectDateMs & removalDateMs are relative to the change injection/removal into the root branch.
- * @param removalDateMs if default value of -1 is used, return list of branches after injectionDate
+ * Set the applicabilities referenced by the provided artifacts. This is stored in the tuple table which means it
+ * does not impact applicability in a branch view.
*/
@PUT
- @Path("change/")
+ @Path("artifact/reference")
@Consumes({MediaType.APPLICATION_JSON})
- @Produces(MediaType.APPLICATION_JSON)
- List<BranchId> getAffectedBranches(@QueryParam("injectionDateMs") Long injectDateMs, @QueryParam("removalDateMs") @DefaultValue("-1") Long removalDateMs, List<ApplicabilityId> applicabilityIds);
+ @Produces({MediaType.APPLICATION_JSON})
+ TransactionToken setApplicabilityReference(HashMap<ArtifactId, List<ApplicabilityId>> artifacts);
- @PUT
- @Path("change/")
+ @GET
+ @Path("versionConfig/{version}")
+ @Produces({MediaType.APPLICATION_JSON})
+ @Consumes({MediaType.APPLICATION_JSON})
+ ArtifactId getVersionConfig(@PathParam("version") ArtifactId version);
+
+ @POST
+ @Path("view/{view-name}")
@Consumes({MediaType.APPLICATION_JSON})
@Produces(MediaType.APPLICATION_JSON)
- List<BranchId> getAffectedBranches(@QueryParam("injectiontx") TransactionId injectionTx, @QueryParam("removaltx") @DefaultValue("-1") TransactionId removalTx, List<ApplicabilityId> applicabilityIds);
+ TransactionToken createView(@PathParam("view-name") String viewName);
@POST
@Path("view/{viewId}/applic")
@Consumes({MediaType.APPLICATION_JSON})
@Produces(MediaType.APPLICATION_JSON)
- TransactionToken createNewApplicabilityForView(@PathParam("viewId") ArtifactId viewId, String applicability);
+ TransactionToken createApplicabilityForView(@PathParam("viewId") ArtifactId viewId, String applicability);
- @GET
- @Path("versionConfig/{version}")
- @Produces({MediaType.APPLICATION_JSON})
- ArtifactId getVersionConfig(@PathParam("version") ArtifactId version);
+ /**
+ * Used for Demo DB Init.
+ */
+ @POST
+ void createDemoApplicability();
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/ApplicabilityEndpointImpl.java b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/ApplicabilityEndpointImpl.java
index c0a0b5b4c5..f94c1063ea 100644
--- a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/ApplicabilityEndpointImpl.java
+++ b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/ApplicabilityEndpointImpl.java
@@ -10,18 +10,9 @@
*******************************************************************************/
package org.eclipse.osee.orcs.rest.internal;
-import static org.eclipse.osee.framework.core.data.ApplicabilityToken.BASE;
-import java.util.ArrayList;
import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.Date;
import java.util.HashMap;
-import java.util.LinkedList;
import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import javax.ws.rs.core.Response;
import org.eclipse.osee.framework.core.data.ApplicabilityId;
import org.eclipse.osee.framework.core.data.ApplicabilityToken;
import org.eclipse.osee.framework.core.data.ArtifactId;
@@ -31,19 +22,14 @@ import org.eclipse.osee.framework.core.data.FeatureDefinitionData;
import org.eclipse.osee.framework.core.data.TransactionId;
import org.eclipse.osee.framework.core.data.TransactionToken;
import org.eclipse.osee.framework.core.data.UserId;
-import org.eclipse.osee.framework.core.enums.BranchType;
-import org.eclipse.osee.framework.core.enums.CoreArtifactTokens;
import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
-import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
import org.eclipse.osee.framework.core.enums.CoreBranches;
import org.eclipse.osee.framework.core.enums.CoreTupleTypes;
import org.eclipse.osee.framework.jdk.core.type.Pair;
import org.eclipse.osee.orcs.OrcsApi;
import org.eclipse.osee.orcs.data.ArtifactReadable;
-import org.eclipse.osee.orcs.data.BranchReadable;
import org.eclipse.osee.orcs.rest.model.ApplicabilityEndpoint;
import org.eclipse.osee.orcs.search.ApplicabilityQuery;
-import org.eclipse.osee.orcs.search.TupleQuery;
import org.eclipse.osee.orcs.transaction.TransactionBuilder;
/**
@@ -53,311 +39,137 @@ public class ApplicabilityEndpointImpl implements ApplicabilityEndpoint {
private final OrcsApi orcsApi;
private final BranchId branch;
- private final TupleQuery tupleQuery;
+ private final ApplicabilityQuery applicabilityQuery;
private final UserId account;
public ApplicabilityEndpointImpl(OrcsApi orcsApi, BranchId branch, UserId account) {
this.orcsApi = orcsApi;
this.branch = branch;
- this.tupleQuery = orcsApi.getQueryFactory().tupleQuery();
+ this.applicabilityQuery = orcsApi.getQueryFactory().applicabilityQuery();
this.account = account;
}
@Override
- public void createDemoApplicability() {
- TransactionBuilder tx =
- orcsApi.getTransactionFactory().createTransaction(branch, account, "Create Demo Applicability");
-
- ArtifactId config1 = tx.createArtifact(CoreArtifactTypes.BranchView, "Config1");
- ArtifactId config2 = tx.createArtifact(CoreArtifactTypes.BranchView, "Config2");
- ArtifactId folder = tx.createArtifact(CoreArtifactTypes.Folder, "Product Line");
- ArtifactId featureDefinition =
- tx.createArtifact(CoreArtifactTypes.FeatureDefinition, "Feature Definition_SAW_Bld_1");
-
- orcsApi.getKeyValueOps().putByKey(BASE.getId(), BASE.getName());
-
- tx.addChildren(CoreArtifactTokens.DefaultHierarchyRoot, folder);
- tx.addChildren(folder, config1, config2, featureDefinition);
-
- tx.addTuple2(CoreTupleTypes.ViewApplicability, config1, "Base");
- tx.addTuple2(CoreTupleTypes.ViewApplicability, config2, "Base");
-
- tx.addTuple2(CoreTupleTypes.ViewApplicability, config1, "Config = Config1");
- tx.addTuple2(CoreTupleTypes.ViewApplicability, config2, "Config = Config2");
-
- tx.addTuple2(CoreTupleTypes.ViewApplicability, config1, "A = Included");
- tx.addTuple2(CoreTupleTypes.ViewApplicability, config2, "A = Excluded");
-
- tx.addTuple2(CoreTupleTypes.ViewApplicability, config1, "B = Choice1");
- tx.addTuple2(CoreTupleTypes.ViewApplicability, config2, "B = Choice2");
- tx.addTuple2(CoreTupleTypes.ViewApplicability, config2, "B = Choice3");
-
- tx.addTuple2(CoreTupleTypes.ViewApplicability, config1, "C = Included");
- tx.addTuple2(CoreTupleTypes.ViewApplicability, config2, "C = Excluded");
-
- String featureDefJson = "[{" + "\"name\": \"A\"," + //
- "\"type\": \"single\"," + //
- "\"values\": [\"Included\", \"Excluded\"]," + //
- "\"defaultValue\": \"Included\"," + //
- "\"description\": \"Test A\"" + //
- "}, {" + //
- "\"name\": \"B\"," + //
- "\"type\": \"multiple\"," + //
- "\"values\": [\"Choice1\", \"Choice2\", \"Choice3\"]," + //
- "\"defaultValue\": \"\"," + //
- "\"description\": \"Test B\"" + //
- "},{" + //
- "\"name\": \"C\"," + //
- "\"type\": \"single\"," + //
- "\"values\": [\"Included\", \"Excluded\"]," + //
- "\"defaultValue\": \"Included\"," + //
- "\"description\": \"Test C\"" + //
- "}" + //
- "]";
-
- tx.createAttribute(featureDefinition, CoreAttributeTypes.GeneralStringData, featureDefJson);
+ public Collection<ApplicabilityToken> getApplicabilityTokens() {
+ return applicabilityQuery.getApplicabilityTokens(branch).values();
+ }
- tx.commit();
+ @Override
+ public List<Pair<ArtifactId, ApplicabilityToken>> getApplicabilityTokens(Collection<? extends ArtifactId> artIds) {
+ return applicabilityQuery.getApplicabilityTokens(artIds, branch);
+ }
- setView(config1);
- setView(config2);
+ @Override
+ public ApplicabilityToken getApplicabilityToken(ArtifactId artId) {
+ return applicabilityQuery.getApplicabilityToken(artId, branch);
}
@Override
- public List<ApplicabilityToken> getApplicabilityTokens() {
- List<ApplicabilityToken> toReturn = new LinkedList<>();
- tupleQuery.getTuple2UniqueE2Pair(CoreTupleTypes.ViewApplicability, branch,
- (id, name) -> toReturn.add(new ApplicabilityToken(id, name)));
- return toReturn;
+ public List<ApplicabilityId> getApplicabilitiesReferenced(ArtifactId artifact) {
+ return applicabilityQuery.getApplicabilitiesReferenced(artifact, branch);
}
@Override
- public ApplicabilityToken getApplicabilityToken(ArtifactId artId) {
- return orcsApi.getQueryFactory().applicabilityQuery().getApplicabilityToken(artId, branch);
+ public List<ApplicabilityToken> getApplicabilityReferenceTokens(ArtifactId artifact) {
+ return applicabilityQuery.getApplicabilityReferenceTokens(artifact, branch);
}
@Override
- public Collection<ApplicabilityToken> getApplicabilityTokenMap() {
- return orcsApi.getQueryFactory().applicabilityQuery().getApplicabilityTokens(branch).values();
+ public List<ApplicabilityToken> getViewApplicabilityTokens(ArtifactId view) {
+ return applicabilityQuery.getViewApplicabilityTokens(view, branch);
}
@Override
- public List<FeatureDefinitionData> getFeatureDefinitionData() {
- BranchId branchToUse = branch;
- BranchReadable br = orcsApi.getQueryFactory().branchQuery().andId(branch).getResults().getOneOrNull();
- if (br.getBranchType().equals(BranchType.MERGE)) {
- branchToUse = br.getParentBranch();
- }
- List<ArtifactReadable> featureDefinitionArts = orcsApi.getQueryFactory().fromBranch(branchToUse).andIsOfType(
- CoreArtifactTypes.FeatureDefinition).getResults().getList();
- return orcsApi.getQueryFactory().applicabilityQuery().getFeatureDefinitionData(featureDefinitionArts);
+ public List<BranchViewData> getViews() {
+ return applicabilityQuery.getViews();
}
@Override
- public Response setApplicability(ApplicabilityId applicId, List<? extends ArtifactId> artifacts) {
- TransactionBuilder tx =
- orcsApi.getTransactionFactory().createTransaction(branch, account, "Set Applicability Ids for Artifacts");
- for (ArtifactId artId : artifacts) {
- tx.setApplicability(artId, applicId);
- }
- tx.commit();
- return Response.ok().build();
+ public List<FeatureDefinitionData> getFeatureDefinitionData() {
+ return applicabilityQuery.getFeatureDefinitionData(branch);
}
@Override
- public List<Pair<ArtifactId, ApplicabilityToken>> getApplicabilityTokensForArts(Collection<? extends ArtifactId> artIds) {
- return orcsApi.getQueryFactory().applicabilityQuery().getApplicabilityTokens(artIds, branch);
+ public List<BranchId> getAffectedBranches(Long injectDateMs, Long removalDateMs, List<ApplicabilityId> applicabilityIds) {
+ return applicabilityQuery.getAffectedBranches(injectDateMs, removalDateMs, applicabilityIds, branch);
}
@Override
- public List<ApplicabilityId> getApplicabilitiesReferenced(ArtifactId artifact) {
- List<ApplicabilityId> appIds = new LinkedList<>();
- for (ApplicabilityId tuple2 : orcsApi.getQueryFactory().tupleQuery().getTuple2(
- CoreTupleTypes.ArtifactReferenceApplicabilityType, branch, artifact)) {
- appIds.add(tuple2);
- }
- return appIds;
+ public List<BranchId> getAffectedBranches(TransactionId injectionTx, TransactionId removalTx, List<ApplicabilityId> applicabilityIds) {
+ return applicabilityQuery.getAffectedBranches(injectionTx, removalTx, applicabilityIds, branch);
}
@Override
- public List<ApplicabilityToken> getApplicabilityReferenceTokens(ArtifactId artifact) {
- List<ApplicabilityToken> tokens = new LinkedList<>();
- orcsApi.getQueryFactory().tupleQuery().getTuple2NamedId(CoreTupleTypes.ArtifactReferenceApplicabilityType, branch,
- artifact, (e2, value) -> tokens.add(ApplicabilityToken.create(e2, value)));
- return tokens;
+ public TransactionToken setApplicability(ApplicabilityId applicId, List<? extends ArtifactId> artifacts) {
+ TransactionBuilder tx =
+ orcsApi.getTransactionFactory().createTransaction(branch, account, "Set Applicability Ids for Artifacts");
+ tx.setApplicability(applicId, artifacts);
+ return tx.commit();
}
/**
* TBD: Need to delete tuples that are not in the set. Update this when tx.removeTuple2 is implemented.
*/
@Override
- public Response setApplicabilityReference(HashMap<ArtifactId, List<ApplicabilityId>> artToApplMap) {
+ public TransactionToken setApplicabilityReference(HashMap<ArtifactId, List<ApplicabilityId>> artToApplMap) {
TransactionBuilder tx = orcsApi.getTransactionFactory().createTransaction(branch, account,
"Set Reference Applicability Ids for Artifacts");
- for (Entry<? extends ArtifactId, List<ApplicabilityId>> entry : artToApplMap.entrySet()) {
- for (ApplicabilityId appId : entry.getValue()) {
- if (!orcsApi.getQueryFactory().tupleQuery().doesTuple2Exist(
- CoreTupleTypes.ArtifactReferenceApplicabilityType, entry.getKey(), appId)) {
- tx.addTuple2(CoreTupleTypes.ArtifactReferenceApplicabilityType, entry.getKey(), appId);
- }
- }
- }
- tx.commit();
- return Response.ok().build();
- }
-
- @Override
- public List<ApplicabilityToken> getViewApplicabilityTokens(ArtifactId view) {
- return orcsApi.getQueryFactory().applicabilityQuery().getViewApplicabilityTokens(view, branch);
+ tx.setApplicabilityReference(artToApplMap);
+ return tx.commit();
}
@Override
- public List<BranchViewData> getViews() {
- return orcsApi.getQueryFactory().applicabilityQuery().getViews();
- }
+ public TransactionToken createView(String viewName) {
+ TransactionBuilder tx = orcsApi.getTransactionFactory().createTransaction(branch, account, "Create Branch View");
+ ArtifactId viewArtifact = tx.createView(branch, viewName);
+ tx.commit();
- @Override
- public void setView(ArtifactId branchView) {
- TransactionBuilder tx =
+ TransactionBuilder tx2 =
orcsApi.getTransactionFactory().createTransaction(CoreBranches.COMMON, account, "Create Branch View");
- tx.addTuple2(CoreTupleTypes.BranchView, branch.getId(), branchView.getId());
- tx.commit();
+
+ tx2.addTuple2(CoreTupleTypes.BranchView, CoreBranches.COMMON.getId(), viewArtifact.getId());
+
+ return tx2.commit();
}
@Override
- public TransactionToken createNewApplicabilityForView(ArtifactId viewId, String applicability) {
+ public TransactionToken createApplicabilityForView(ArtifactId viewId, String applicability) {
TransactionBuilder tx =
orcsApi.getTransactionFactory().createTransaction(branch, account, "Create new applicability");
- tx.addTuple2(CoreTupleTypes.ViewApplicability, viewId, applicability);
+ tx.createApplicabilityForView(viewId, applicability);
return tx.commit();
}
@Override
- public List<BranchId> getAffectedBranches(Long injectDateMs, Long removalDateMs, List<ApplicabilityId> applicabilityIds) {
- ArrayList<BranchId> toReturn = new ArrayList<>();
- Date injection = new Date(injectDateMs);
- Date removal = new Date(removalDateMs);
-
- // Get all Branch Views
- List<BranchViewData> branchViews = orcsApi.getQueryFactory().applicabilityQuery().getViews();
+ public void createDemoApplicability() {
+ TransactionBuilder tx =
+ orcsApi.getTransactionFactory().createTransaction(branch, account, "Create Demo Applicability");
+ tx.createDemoApplicability();
+ tx.commit();
- HashMap<Long, BranchReadable> childBaselineBranchIds = new HashMap<>();
- for (BranchReadable childBranch : orcsApi.getQueryFactory().branchQuery().andIsChildOf(branch).getResults()) {
- if (childBranch.getBranchType().equals(BranchType.BASELINE)) {
- childBaselineBranchIds.put(childBranch.getId(), childBranch);
- }
- }
+ // set the view on common branch
+ List<ArtifactReadable> branchViewArtifacts = orcsApi.getQueryFactory().fromBranch(branch).andTypeEquals(
+ CoreArtifactTypes.BranchView).getResults().getList();
- HashMap<Long, ApplicabilityId> applicabilityIdsMap = new HashMap<>();
- for (ApplicabilityId applicId : applicabilityIds) {
- applicabilityIdsMap.put(applicId.getId(), applicId);
- }
+ TransactionBuilder tx2 =
+ orcsApi.getTransactionFactory().createTransaction(CoreBranches.COMMON, account, "Create Branch View");
- for (BranchViewData branchView : branchViews) {
- BranchReadable baseBranch = childBaselineBranchIds.get(branchView.getBranch().getId());
- if (baseBranch != null) {
- // Check Dates on baseBranch
- Date baseDate = orcsApi.getTransactionFactory().getTx(baseBranch.getBaseTransaction()).getDate();
- if (baseDate.after(injection) && (removalDateMs == -1 || baseDate.before(removal))) {
- // now determine what views of this branch are applicable
- for (ArtifactId view : branchView.getBranchViews()) {
- // Get all applicability tokens for the view of this branch
- List<ApplicabilityToken> viewApplicabilityTokens =
- orcsApi.getQueryFactory().applicabilityQuery().getViewApplicabilityTokens(view,
- branchView.getBranch());
- // Cross check applicabilityTokens with valid ApplicabilityIds sent in
- for (ApplicabilityToken applicToken : viewApplicabilityTokens) {
- // If applictoken is found, add toReturn list
- if (applicabilityIdsMap.containsKey(applicToken.getId())) {
- toReturn.add(BranchId.create(branchView.getBranch().getId(), view));
- break;
- }
- }
- }
- }
- }
+ for (ArtifactReadable artifact : branchViewArtifacts) {
+ tx2.addTuple2(CoreTupleTypes.BranchView, branch.getId(), artifact.getId());
}
- return toReturn;
- }
-
- @Override
- public List<BranchId> getAffectedBranches(TransactionId injectionTx, TransactionId removalTx, List<ApplicabilityId> applicabilityIds) {
- long timeInjectionMs = orcsApi.getTransactionFactory().getTx(injectionTx).getDate().getTime();
- long timeRemovalMs =
- removalTx.isInvalid() ? -1 : orcsApi.getTransactionFactory().getTx(removalTx).getDate().getTime();
+ tx2.commit();
- return getAffectedBranches(timeInjectionMs, timeRemovalMs, applicabilityIds);
}
@Override
public ArtifactId getVersionConfig(ArtifactId version) {
- return orcsApi.getQueryFactory().applicabilityQuery().getVersionConfig(version, branch);
+ return applicabilityQuery.getVersionConfig(version, branch);
}
@Override
public String getViewTable() {
- StringBuilder html = new StringBuilder(
- "<!DOCTYPE html><html><head><style> table { border-spacing: 0px } th,td { padding: 3px; } </style></head><body>");
- List<BranchViewData> views = this.getViews();
- ApplicabilityQuery applicabilityQuery = orcsApi.getQueryFactory().applicabilityQuery();
- for (BranchViewData branchView : views) {
- if (branchView.getBranch().equals(branch)) {
- html.append(String.format("<h1>Features for branch [%s]</h1>",
- orcsApi.getQueryFactory().branchQuery().andId(branch).getResults().getExactlyOne().getName()));
- html.append("<table border=\"1\">");
- List<ArtifactId> branchViews = branchView.getBranchViews();
-
- List<ArtifactReadable> featureDefinitionArts = orcsApi.getQueryFactory().fromBranch(branch).andIsOfType(
- CoreArtifactTypes.FeatureDefinition).getResults().getList();
-
- List<FeatureDefinitionData> featureDefinitionData =
- applicabilityQuery.getFeatureDefinitionData(featureDefinitionArts);
-
- // List<ApplicabilityToken> tokens = getApplicabilityTokens(); // list of all of the applicability views
- Collections.sort(featureDefinitionData, new Comparator<FeatureDefinitionData>() {
- @Override
- public int compare(FeatureDefinitionData obj1, FeatureDefinitionData obj2) {
- return obj1.getName().compareTo(obj2.getName());
- }
- });
-
- printColumnHeadings(html, branchViews);
- Map<ArtifactId, Map<String, List<String>>> branchViewsMap = new HashMap<>();
-
- for (ArtifactId artId : branchViews) {
- branchViewsMap.put(artId, applicabilityQuery.getBranchViewFeatureValues(branch, artId));
- }
- for (FeatureDefinitionData featureDefinition : featureDefinitionData) {
- html.append("<tr>");
- html.append(String.format("<td>%s</td>", featureDefinition.getName()));
- html.append(String.format("<td>%s</td>", featureDefinition.getDescription()));
- for (ArtifactId view : branchViews) {
- List<String> list = branchViewsMap.get(view).get(featureDefinition.getName());
- // every view should have a value for each feature, if incorrectly configured returns null
- if (list != null) {
- html.append(
- "<td>" + org.eclipse.osee.framework.jdk.core.util.Collections.toString(",", list) + "</td>");
- } else {
- html.append("<td> </td>");
- }
- }
- html.append("</tr>");
- }
- }
- }
- html.append("</table></body></html>");
- return html.toString();
+ return applicabilityQuery.getViewTable(branch);
}
- private void printColumnHeadings(StringBuilder html, List<ArtifactId> branchViews) {
- html.append("<tr>");
- html.append("<th>Feature Name</th>");
- html.append("<th>Feature Description</th>");
- for (ArtifactId artId : branchViews) {
- html.append(String.format("<th>%s</th>",
- orcsApi.getQueryFactory().fromBranch(branch).andId(artId).getResults().getExactlyOne().getName()));
- }
- html.append("</tr>");
- }
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/search/ApplicabilityQuery.java b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/search/ApplicabilityQuery.java
index 52a3f504f0..2823ca903f 100644
--- a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/search/ApplicabilityQuery.java
+++ b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/search/ApplicabilityQuery.java
@@ -14,34 +14,46 @@ import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import org.eclipse.osee.framework.core.data.ApplicabilityId;
import org.eclipse.osee.framework.core.data.ApplicabilityToken;
import org.eclipse.osee.framework.core.data.ArtifactId;
import org.eclipse.osee.framework.core.data.BranchId;
import org.eclipse.osee.framework.core.data.BranchViewData;
import org.eclipse.osee.framework.core.data.FeatureDefinitionData;
+import org.eclipse.osee.framework.core.data.TransactionId;
import org.eclipse.osee.framework.jdk.core.type.Pair;
-import org.eclipse.osee.orcs.data.ArtifactReadable;
/**
* @author Ryan D. Brooks
*/
public interface ApplicabilityQuery {
+ HashMap<Long, ApplicabilityToken> getApplicabilityTokens(BranchId branch);
+
ApplicabilityToken getApplicabilityToken(ArtifactId artId, BranchId branch);
- List<Pair<ArtifactId, ApplicabilityToken>> getApplicabilityTokens(Collection<? extends ArtifactId> artIds, BranchId branch);
+ List<ApplicabilityId> getApplicabilitiesReferenced(ArtifactId artifact, BranchId branch);
- HashMap<Long, ApplicabilityToken> getApplicabilityTokens(BranchId branch1, BranchId branch2);
+ List<ApplicabilityToken> getApplicabilityReferenceTokens(ArtifactId artifact, BranchId branch);
- HashMap<Long, ApplicabilityToken> getApplicabilityTokens(BranchId branch);
-
- List<FeatureDefinitionData> getFeatureDefinitionData(List<ArtifactReadable> featureDefinitionArts);
+ List<Pair<ArtifactId, ApplicabilityToken>> getApplicabilityTokens(Collection<? extends ArtifactId> artIds, BranchId branch);
List<ApplicabilityToken> getViewApplicabilityTokens(ArtifactId artId, BranchId branch);
+ HashMap<Long, ApplicabilityToken> getApplicabilityTokens(BranchId branch1, BranchId branch2);
+
+ List<FeatureDefinitionData> getFeatureDefinitionData(BranchId branch);
+
Map<String, List<String>> getBranchViewFeatureValues(BranchId branch, ArtifactId viewId);
List<BranchViewData> getViews();
+ String getViewTable(BranchId branch);
+
ArtifactId getVersionConfig(ArtifactId art, BranchId branch);
+
+ List<BranchId> getAffectedBranches(Long injectDateMs, Long removalDateMs, List<ApplicabilityId> applicabilityIds, BranchId branch);
+
+ List<BranchId> getAffectedBranches(TransactionId injectionTx, TransactionId removalTx, List<ApplicabilityId> applicabilityIds, BranchId branch);
+
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/search/QueryFactory.java b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/search/QueryFactory.java
index ea734b9425..65f3795d02 100644
--- a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/search/QueryFactory.java
+++ b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/search/QueryFactory.java
@@ -35,4 +35,5 @@ public interface QueryFactory {
TupleQuery tupleQuery();
ApplicabilityQuery applicabilityQuery();
+
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/transaction/TransactionBuilder.java b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/transaction/TransactionBuilder.java
index 84c0b00302..5eca176fdf 100644
--- a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/transaction/TransactionBuilder.java
+++ b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/transaction/TransactionBuilder.java
@@ -12,6 +12,8 @@ package org.eclipse.osee.orcs.transaction;
import java.io.InputStream;
import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
import org.eclipse.osee.framework.core.data.ApplicabilityId;
import org.eclipse.osee.framework.core.data.ArtifactId;
import org.eclipse.osee.framework.core.data.ArtifactToken;
@@ -138,9 +140,19 @@ public interface TransactionBuilder {
void setRelationApplicability(ArtifactId artA, IRelationType relType, ArtifactId artB, ApplicabilityId applicId);
- // Applic
+ // Applicability
void setApplicability(ArtifactId art, ApplicabilityId applicId);
+ void setApplicabilityReference(HashMap<ArtifactId, List<ApplicabilityId>> artifacts);
+
+ void setApplicability(ApplicabilityId applicId, List<? extends ArtifactId> artifacts);
+
+ ArtifactId createView(BranchId branch, String viewName);
+
+ void createApplicabilityForView(ArtifactId viewId, String applicability);
+
+ void createDemoApplicability();
+
// Tuples
<E1, E2> GammaId addTuple2(Tuple2Type<E1, E2> tupleType, E1 e1, E2 e2);

Back to the top