Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDominic Guss2022-07-05 21:39:25 +0000
committerDominic Guss2022-08-12 16:01:20 +0000
commit41ad555e63e59ff68dc9dcab99701ce6767c1bcf (patch)
tree5390724f6b8591374162c89716c0ede94d8d5949
parentcbbdc2eebd3528b27b161d9b2bfd5a7beeb75294 (diff)
downloadorg.eclipse.osee-dguss/feature/VisualizerAndSerializerFeaturesPlusFollowAllFixes.tar.gz
org.eclipse.osee-dguss/feature/VisualizerAndSerializerFeaturesPlusFollowAllFixes.tar.xz
org.eclipse.osee-dguss/feature/VisualizerAndSerializerFeaturesPlusFollowAllFixes.zip
Change-Id: Ic0de9e33dc32529cd642216b1feee853e06c238e Signed-off-by: Dominic Guss <Dominic.Guss@boeing.com>
-rw-r--r--plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/ArtifactReadable.java2
-rw-r--r--plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/ArtifactReadableSerializer.java101
-rw-r--r--plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/util/JsonUtil.java3
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/QueryData.java9
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/criteria/CriteriaRelationTypeFollow.java10
-rw-r--r--plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/handlers/SqlHandlerFactoryUtilTest.java1
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/engines/QueryEngineImpl.java11
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/handlers/FollowRelationSqlHandler.java10
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/ArtifactEndpoint.java11
-rw-r--r--plugins/org.eclipse.osee.orcs.rest/META-INF/MANIFEST.MF1
-rw-r--r--plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/ArtifactEndpointImpl.java77
11 files changed, 231 insertions, 5 deletions
diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/ArtifactReadable.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/ArtifactReadable.java
index d28e73500bc..ba8e9f2ac59 100644
--- a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/ArtifactReadable.java
+++ b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/ArtifactReadable.java
@@ -15,6 +15,7 @@ package org.eclipse.osee.framework.core.data;
import static org.eclipse.osee.framework.core.enums.CoreArtifactTypes.Artifact;
import static org.eclipse.osee.framework.core.enums.CoreBranches.COMMON;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@@ -36,6 +37,7 @@ import org.eclipse.osee.framework.jdk.core.util.Collections;
* @author Andrew M. Finkbeiner
* @author Ryan D. Brooks
*/
+@JsonSerialize(using = ArtifactReadableSerializer.class)
public interface ArtifactReadable extends ArtifactToken, HasTransaction, OrcsReadable {
ArtifactReadable SENTINEL = new ArtifactReadableImpl();
diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/ArtifactReadableSerializer.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/ArtifactReadableSerializer.java
new file mode 100644
index 00000000000..a393bf0b1fd
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/ArtifactReadableSerializer.java
@@ -0,0 +1,101 @@
+/*********************************************************************
+ * Copyright (c) 2022 Boeing
+ *
+ * This program and the accompanying materials are made
+ * available under the terms of the Eclipse Public License 2.0
+ * which is available at https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.osee.framework.core.data;
+
+import com.fasterxml.jackson.core.JsonGenerationException;
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import com.fasterxml.jackson.databind.ser.std.StdScalarSerializer;
+import java.io.IOException;
+import java.util.Collection;
+import java.util.List;
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.osee.framework.core.enums.RelationSide;
+import org.eclipse.osee.framework.jdk.core.type.ResultSet;
+
+/**
+ * @author Dominic Guss
+ */
+@SuppressWarnings("serial")
+public class ArtifactReadableSerializer extends StdScalarSerializer<@NonNull ArtifactReadable> {
+
+ public ArtifactReadableSerializer() {
+ super(ArtifactReadable.class);
+ }
+
+ @Override
+ public void serialize(ArtifactReadable artifactReadable, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonGenerationException {
+ jgen.writeStartObject();
+ jgen.writeStringField("id", artifactReadable.getIdString());
+ jgen.writeStringField("name", artifactReadable.getName());
+ jgen.writeStringField("type", artifactReadable.getArtifactType().getName());
+ jgen.writeStringField("branchId", artifactReadable.getBranchIdString());
+
+ jgen.writeArrayFieldStart("attributes");
+ Collection<AttributeTypeToken> types = artifactReadable.getExistingAttributeTypes();
+ for (AttributeTypeToken type : types) {
+ List<?> values = artifactReadable.getAttributeValues(type);
+ for (Object value : values) {
+ jgen.writeStartObject();
+ jgen.writeStringField(type.getName(), value.toString());
+ jgen.writeEndObject();
+ }
+ }
+ jgen.writeEndArray();
+
+ jgen.writeArrayFieldStart("relations");
+ Collection<RelationTypeToken> relationTypes = artifactReadable.getExistingRelationTypes();
+ for (RelationTypeToken type : relationTypes) {
+ jgen.writeStartObject();
+ jgen.writeArrayFieldStart(type.getName()); // E.g. SubscribedUser array
+
+ // Begin Side A --------------------
+ jgen.writeStartObject();
+ jgen.writeArrayFieldStart(type.getSideName(RelationSide.SIDE_A)); // E.g. start Artifact array
+
+ ResultSet<ArtifactReadable> aRelations =
+ artifactReadable.getRelated(new RelationTypeSide(type, RelationSide.SIDE_A));
+ for (ArtifactReadable relation : aRelations) {
+ jgen.writeStartObject();
+ jgen.writeStringField("id", relation.getIdString());
+ jgen.writeStringField("name", relation.getName());
+ jgen.writeEndObject();
+ }
+ jgen.writeEndArray(); // E.g. end Artifact array
+ jgen.writeEndObject();
+ // End Side A ----------------------
+
+ // Begin Side B --------------------
+ jgen.writeStartObject();
+ jgen.writeArrayFieldStart(type.getSideName(RelationSide.SIDE_B)); // E.g. start User array
+
+ ResultSet<ArtifactReadable> bRelations =
+ artifactReadable.getRelated(new RelationTypeSide(type, RelationSide.SIDE_B));
+ for (ArtifactReadable relation : bRelations) {
+ jgen.writeStartObject();
+ jgen.writeStringField("id", relation.getIdString());
+ jgen.writeStringField("name", relation.getName());
+ jgen.writeEndObject();
+ }
+ jgen.writeEndArray(); // E.g. end User array
+ jgen.writeEndObject();
+ // End Side B ----------------------
+
+ jgen.writeEndArray(); // E.g. end SubscribedUser array
+ jgen.writeEndObject();
+ }
+ jgen.writeEndArray(); // End relations array
+ jgen.writeEndObject();
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/util/JsonUtil.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/util/JsonUtil.java
index 3afb2368248..a062b07ed8f 100644
--- a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/util/JsonUtil.java
+++ b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/util/JsonUtil.java
@@ -35,6 +35,8 @@ import org.eclipse.jdt.annotation.NonNull;
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.ArtifactReadable;
+import org.eclipse.osee.framework.core.data.ArtifactReadableSerializer;
import org.eclipse.osee.framework.core.data.ArtifactToken;
import org.eclipse.osee.framework.core.data.ArtifactTypeId;
import org.eclipse.osee.framework.core.data.TransactionId;
@@ -162,6 +164,7 @@ public class JsonUtil {
module.addSerializer(BranchState.class, idSerializer);
module.addSerializer(ApplicabilityId.class, idSerializer);
module.addSerializer(java.util.Date.class, DateSerializer.instance);
+ module.addSerializer(ArtifactReadable.class, new ArtifactReadableSerializer());
return module;
}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/QueryData.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/QueryData.java
index 77bcc3dbc80..819807b2888 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/QueryData.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/QueryData.java
@@ -84,13 +84,13 @@ public final class QueryData implements QueryBuilder, HasOptions, HasBranch {
private final BranchToken branch;
private final ArtifactId view;
private final QueryData parentQueryData;
- private final List<QueryData> childrenQueryData = new ArrayList<>(2);
+ private final List<QueryData> childrenQueryData = new ArrayList<>(20);
private AttributeTypeToken attributeType = AttributeTypeToken.SENTINEL;
private final CallableQueryFactory artQueryFactory;
private final QueryFactory queryFactory;
private final QueryEngine queryEngine;
private final OrcsTokenService tokenService;
- private final HashMap<SqlTable, String> mainAliases = new HashMap<>(4);
+ private final HashMap<SqlTable, String> mainAliases = new HashMap<>(40);
private QueryType queryType;
private boolean followCausesChild = true;
private final ApplicabilityId appId;
@@ -546,6 +546,7 @@ public final class QueryData implements QueryBuilder, HasOptions, HasBranch {
@Override
public QueryBuilder followRelation(RelationTypeSide relationTypeSide) {
addAndCheck(new CriteriaRelationTypeFollow(relationTypeSide, ArtifactTypeToken.SENTINEL, true));
+ //addAndCheck(new CriteriaRelationTypeFollow(relationTypeSide, ArtifactTypeToken.SENTINEL, true, false));
newCriteriaSet();
return this;
}
@@ -611,9 +612,13 @@ public final class QueryData implements QueryBuilder, HasOptions, HasBranch {
}
private QueryBuilder follow(RelationTypeSide relationTypeSide, ArtifactTypeToken artifactType, boolean terminalFollow) {
+ boolean isFollowAll = relationTypeSide.equals(RelationTypeSide.SENTINEL) && artifactType.equals(
+ ArtifactTypeToken.SENTINEL) && terminalFollow ? true : false;
QueryData followQueryData = followQueryData();
followQueryData.followCausesChild = terminalFollow;
followQueryData.addCriteria(new CriteriaRelationTypeFollow(relationTypeSide, artifactType, terminalFollow));
+ // followQueryData.addCriteria(
+ // new CriteriaRelationTypeFollow(relationTypeSide, artifactType, terminalFollow, isFollowAll));
return followQueryData;
}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/criteria/CriteriaRelationTypeFollow.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/criteria/CriteriaRelationTypeFollow.java
index 2645b91341f..9eb3c23a315 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/criteria/CriteriaRelationTypeFollow.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/criteria/CriteriaRelationTypeFollow.java
@@ -1,5 +1,5 @@
/*********************************************************************
- * Copyright (c) 2014 Boeing
+ * Copyright (c) 2022 Boeing
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
@@ -19,20 +19,24 @@ import org.eclipse.osee.orcs.core.ds.RelationTypeCriteria;
/**
* @author Roberto E. Escobar
+ * @author Dominic Guss
*/
public final class CriteriaRelationTypeFollow extends RelationTypeCriteria<RelationTypeSide> {
private final RelationTypeSide typeSide;
private final ArtifactTypeToken artifacType;
private final boolean terminalFollow;
+ //private final boolean isFollowAll;
/**
* @param terminalFollow true if this is the last (terminal) follow in this chain of follows for this (sub) query
*/
+ //public CriteriaRelationTypeFollow(RelationTypeSide typeSide, ArtifactTypeToken artifacType, boolean terminalFollow, boolean isFollowAll) {
public CriteriaRelationTypeFollow(RelationTypeSide typeSide, ArtifactTypeToken artifacType, boolean terminalFollow) {
super(typeSide);
this.typeSide = typeSide;
this.artifacType = artifacType;
this.terminalFollow = terminalFollow;
+ //this.isFollowAll = isFollowAll;
}
public ArtifactTypeToken getArtifacType() {
@@ -42,4 +46,8 @@ public final class CriteriaRelationTypeFollow extends RelationTypeCriteria<Relat
public boolean isTerminalFollow() {
return terminalFollow;
}
+
+ // public boolean isFollowAll() {
+ // return isFollowAll;
+ // }
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/handlers/SqlHandlerFactoryUtilTest.java b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/handlers/SqlHandlerFactoryUtilTest.java
index 8fa2b31a10a..f0bf2a9cd44 100644
--- a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/handlers/SqlHandlerFactoryUtilTest.java
+++ b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/handlers/SqlHandlerFactoryUtilTest.java
@@ -67,6 +67,7 @@ public class SqlHandlerFactoryUtilTest {
QueryData queryData = QueryData.mock();
queryData.addCriteria(new CriteriaArtifactGuids(null));
queryData.addCriteria(new CriteriaArtifactIds(Collections.emptyList()));
+ //queryData.addCriteria(new CriteriaRelationTypeFollow(null, ArtifactTypeToken.SENTINEL, false, false));
queryData.addCriteria(new CriteriaRelationTypeFollow(null, ArtifactTypeToken.SENTINEL, false));
queryData.addCriteria(new CriteriaArtifactType(null, true));
queryData.addCriteria(new CriteriaRelationTypeExists(null));
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/engines/QueryEngineImpl.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/engines/QueryEngineImpl.java
index 06d06065770..0afce6ed4da 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/engines/QueryEngineImpl.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/engines/QueryEngineImpl.java
@@ -345,8 +345,15 @@ public class QueryEngineImpl implements QueryEngine {
private void selectiveArtifactLoad(QueryData queryData, int numArtifacts, Consumer<JdbcStatement> consumer) {
QueryData rootQueryData = queryData.getRootQueryData();
- new SelectiveArtifactSqlWriter(sqlJoinFactory, jdbcClient, rootQueryData).runSql(consumer, handlerFactory,
- numArtifacts);
+ // new SelectiveArtifactSqlWriter(sqlJoinFactory, jdbcClient, rootQueryData).runSql(consumer, handlerFactory,
+ // numArtifacts);
+
+ SelectiveArtifactSqlWriter test = new SelectiveArtifactSqlWriter(sqlJoinFactory, jdbcClient, rootQueryData);
+ System.out.println("Test: " + test.toString());
+ test.runSql(consumer, handlerFactory, numArtifacts);
+ System.out.println("Test2: " + test.toString());
+
+ String test2 = "";
}
@Override
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/handlers/FollowRelationSqlHandler.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/handlers/FollowRelationSqlHandler.java
index d89a333d7da..472b780dbcb 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/handlers/FollowRelationSqlHandler.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/handlers/FollowRelationSqlHandler.java
@@ -78,7 +78,12 @@ public class FollowRelationSqlHandler extends SqlHandler<CriteriaRelationTypeFol
sourceArtColumn = previousFollow.toArtField;
}
+ //if (criteria.isFollowAll()) {
+ // writer.write(
+ // sourceArtTable + "." + sourceArtColumn + " IN (" + relAlias + "." + fromArtField + ", " + relAlias + "." + toArtField + ") AND ");
+ // } else {
writer.writeEqualsAnd(sourceArtTable, sourceArtColumn, relAlias, fromArtField);
+ // }
if (typeSide.getRelationType().isValid()) {
if (criteria.getType().isNewRelationTable()) {
@@ -92,7 +97,12 @@ public class FollowRelationSqlHandler extends SqlHandler<CriteriaRelationTypeFol
writer.writeTxBranchFilter(relTxsAlias, includeDeletedRelations);
if (criteria.isTerminalFollow()) {
writer.write(" AND ");
+ //if (criteria.isFollowAll()) {
+ // writer.write(writer.getMainTableAlias(
+ // OseeDb.ARTIFACT_TABLE) + ".art_id IN (" + relAlias + "." + toArtField + ", " + relAlias + "." + fromArtField + ")");
+ //} else {
writer.writeEquals(relAlias, toArtField, writer.getMainTableAlias(OseeDb.ARTIFACT_TABLE), "art_id");
+ //}
}
}
diff --git a/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/ArtifactEndpoint.java b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/ArtifactEndpoint.java
index 4946066b315..c0c98c1a14f 100644
--- a/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/ArtifactEndpoint.java
+++ b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/ArtifactEndpoint.java
@@ -28,6 +28,7 @@ import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import org.eclipse.osee.framework.core.data.ApplicabilityId;
import org.eclipse.osee.framework.core.data.ArtifactId;
+import org.eclipse.osee.framework.core.data.ArtifactReadable;
import org.eclipse.osee.framework.core.data.ArtifactToken;
import org.eclipse.osee.framework.core.data.ArtifactTypeToken;
import org.eclipse.osee.framework.core.data.AttributeTypeJoin;
@@ -151,4 +152,14 @@ public interface ArtifactEndpoint {
@Consumes({MediaType.APPLICATION_JSON})
List<ArtifactToken> findArtifactTokens(ArtifactSearchOptions searchOptions);
+ @GET
+ @Path("{artifact}/related/maps")
+ @Produces(MediaType.APPLICATION_JSON)
+ List<ArtifactReadable> getRelatedArtifactMaps(@PathParam("branch") BranchId branch, @PathParam("artifact") ArtifactId artifact);
+
+ @GET
+ @Path("{artifact}/related/maps2")
+ @Produces(MediaType.APPLICATION_JSON)
+ List<Map<String, Object>> getRelatedArtifactMaps2(@PathParam("branch") BranchId branch, @PathParam("artifact") ArtifactId artifact);
+
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.rest/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.orcs.rest/META-INF/MANIFEST.MF
index 22d71c93468..6803cce4efe 100644
--- a/plugins/org.eclipse.osee.orcs.rest/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.osee.orcs.rest/META-INF/MANIFEST.MF
@@ -25,6 +25,7 @@ Import-Package: com.fasterxml.jackson.core,
org.eclipse.jdt.core.dom,
org.eclipse.osee.activity,
org.eclipse.osee.activity.api,
+ org.eclipse.osee.ats.api.data,
org.eclipse.osee.framework.core,
org.eclipse.osee.framework.core.access,
org.eclipse.osee.framework.core.applicability,
diff --git a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/ArtifactEndpointImpl.java b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/ArtifactEndpointImpl.java
index 993fc24c27d..61e24c86d06 100644
--- a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/ArtifactEndpointImpl.java
+++ b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/ArtifactEndpointImpl.java
@@ -16,6 +16,8 @@ package org.eclipse.osee.orcs.rest.internal;
import static org.eclipse.osee.framework.core.enums.CoreRelationTypes.DefaultHierarchical_Child;
import static org.eclipse.osee.framework.core.enums.CoreRelationTypes.SupportingRequirement_LowerLevelRequirement;
import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@@ -31,9 +33,12 @@ import org.eclipse.osee.framework.core.data.AttributeTypeId;
import org.eclipse.osee.framework.core.data.AttributeTypeJoin;
import org.eclipse.osee.framework.core.data.AttributeTypeToken;
import org.eclipse.osee.framework.core.data.BranchId;
+import org.eclipse.osee.framework.core.data.RelationTypeSide;
+import org.eclipse.osee.framework.core.data.RelationTypeToken;
import org.eclipse.osee.framework.core.data.TransactionId;
import org.eclipse.osee.framework.core.data.TransactionToken;
import org.eclipse.osee.framework.core.enums.QueryOption;
+import org.eclipse.osee.framework.core.enums.RelationSide;
import org.eclipse.osee.framework.core.util.ArtifactSearchOptions;
import org.eclipse.osee.framework.jdk.core.type.MatchLocation;
import org.eclipse.osee.framework.jdk.core.type.MultipleItemsExist;
@@ -197,6 +202,78 @@ public class ArtifactEndpointImpl implements ArtifactEndpoint {
}
@Override
+ public List<ArtifactReadable> getRelatedArtifactMaps(BranchId branch, ArtifactId artifact) {
+ QueryBuilder query = orcsApi.getQueryFactory().fromBranch(branch);
+
+ // Test parallel follows() ---------------------------------------
+ // QueryBuilder builder = query.andId(artifact);
+ // builder.follow(AtsRelationTypes.TeamMember_Team);
+ // builder.follow(AtsRelationTypes.TeamMember_Member);
+ // builder.follow(AtsRelationTypes.FavoriteUser_Artifact);
+ // builder.follow(AtsRelationTypes.FavoriteUser_User);
+ // builder.follow(CoreRelationTypes.Users_Artifact);
+ // builder.follow(CoreRelationTypes.Users_User);
+ // builder.follow(AtsRelationTypes.TeamLead_Team);
+ // builder.follow(AtsRelationTypes.PrivilegedMember_Team);
+ // builder.follow(AtsRelationTypes.Goal_Member);
+ // builder.follow(CoreRelationTypes.DefaultHierarchical_Parent);
+ // builder.follow(CoreRelationTypes.DefaultHierarchical_Child);
+ // builder.follow(AtsRelationTypes.TeamDefinitionToWorkPackage_AtsTeamDefOrAi);
+ // builder.follow(AtsRelationTypes.TeamDefinitionToWorkPackage_WorkPackage);
+ // builder.follow(AtsRelationTypes.TeamDefinitionToVersion_TeamDefinition);
+ // builder.follow(AtsRelationTypes.TeamDefinitionToVersion_Version);
+ // builder.follow(AtsRelationTypes.TeamLead_Lead);
+ // builder.follow(AtsRelationTypes.AutoAddActionToGoal_AtsConfigObject);
+ // builder.follow(AtsRelationTypes.AutoAddActionToGoal_Goal);
+ // End test parallel follows() ----------------------------------
+
+ //return builder.asArtifacts();
+ //query.follow(CoreRelationTypes.Users_User);
+ return query.andId(artifact).followAll().asArtifacts(); // 13+ seconds
+ }
+
+ @Override
+ public List<Map<String, Object>> getRelatedArtifactMaps2(BranchId branch, ArtifactId artifact) {
+ List<Map<String, Object>> artifactMaps = new ArrayList<Map<String, Object>>();
+ QueryBuilder query = orcsApi.getQueryFactory().fromBranch(branch);
+ //List<ArtifactReadable> artifacts = query.andId(artifact).followAll().asArtifacts(); // 13+ seconds
+ List<ArtifactReadable> artifacts = query.andId(artifact).asArtifacts();// < 1 second (Does not include relation names)
+
+ //List<RelationTypeSide> relationTypes2 = query.andId(artifact).getRelationTypesForLevel(1);;
+ //List<ArtifactToken> artifactTokens = query.andId(artifact).followAll().asArtifactTokens(); // 5+ seconds
+
+ for (ArtifactReadable art : artifacts) {
+ //List<RelationTypeSide> relationTypes2 = query.andId(artifact).getRelationTypesForLevel(1);
+ //List<RelationTypeSide> relationTypes = query.andId(artifact).getRelationTypesForLevel(1);
+ Collection<RelationTypeToken> relationTypes = art.getExistingRelationTypes();
+ for (RelationTypeToken type : relationTypes) {
+ List<ArtifactId> relationsA = art.getRelatedIds(new RelationTypeSide(type, RelationSide.SIDE_A));
+ ResultSet<ArtifactReadable> related = art.getRelated(new RelationTypeSide(type, RelationSide.SIDE_A));
+ for (ArtifactReadable relation : related) {
+ ArtifactToken test = query.andId(relation).asArtifactToken();
+
+ String name = relation.getToken().getName();
+ }
+ ResultSet<ArtifactReadable> relationsB = art.getRelated(new RelationTypeSide(type, RelationSide.SIDE_B));
+ for (ArtifactReadable relation : relationsB) {
+ ArtifactToken test = query.andUuid(relation.getId()).asArtifactToken();
+
+ String name = test.getName();
+ }
+ }
+ }
+ Map<String, Object> relations = new HashMap<String, Object>();
+ Map<String, Object> attributes = new HashMap<String, Object>();
+ relations.put("relation1", "1");
+ relations.put("relation2", "2");
+ attributes.put("test", "blah");
+ attributes.put("test2", "blah2");
+ artifactMaps.add(attributes);
+ artifactMaps.add(relations);
+ return artifactMaps;
+ }
+
+ @Override
public List<ArtifactToken> getArtifactTokensByType(ArtifactTypeToken artifactType) {
return orcsApi.getQueryFactory().fromBranch(branch).andTypeEquals(artifactType).asArtifactTokens();
}

Back to the top