Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordonald.g.dunne2017-10-02 02:25:50 +0000
committerdonald.g.dunne2017-10-02 22:24:36 +0000
commit76d040e56602dcbb192d629abae28bffd79a9b33 (patch)
treea0e1e97fa0665db07728a1731da061fc519780af
parent19d8d8426ef1530c8a2540a62979591f24356ddb (diff)
downloadorg.eclipse.osee-76d040e56602dcbb192d629abae28bffd79a9b33.tar.gz
org.eclipse.osee-76d040e56602dcbb192d629abae28bffd79a9b33.tar.xz
org.eclipse.osee-76d040e56602dcbb192d629abae28bffd79a9b33.zip
feature[ats_TW2227]: Add TeamDef and AI guid attributes upon action creation
-rw-r--r--plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/IAtsServices.java2
-rw-r--r--plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/data/AtsAttributeTypes.java4
-rw-r--r--plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/util/ActionFactory.java11
-rw-r--r--plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/util/AtsCoreServiceImpl.java4
-rw-r--r--plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/util/ConvertAtsConfigGuidAttributesOperations.java106
5 files changed, 122 insertions, 5 deletions
diff --git a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/IAtsServices.java b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/IAtsServices.java
index afc3566d4e4..34aae372ba9 100644
--- a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/IAtsServices.java
+++ b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/IAtsServices.java
@@ -149,7 +149,7 @@ public interface IAtsServices extends IAtsEarnedValueServiceProvider, IAtsConfig
Log getLogger();
- <T> T getConfigItem(ArtifactToken artifactToken);
+ <T> T getConfigItem(ArtifactId artifactToken);
<T> T getConfigItem(String guid);
diff --git a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/data/AtsAttributeTypes.java b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/data/AtsAttributeTypes.java
index 37fe8959ebc..2b1c10c0668 100644
--- a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/data/AtsAttributeTypes.java
+++ b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/data/AtsAttributeTypes.java
@@ -167,13 +167,13 @@ public final class AtsAttributeTypes {
// @formatter:on
- private static AttributeTypeToken createType(Long guid, String name) {
+ public static AttributeTypeToken createType(Long guid, String name) {
AttributeTypeToken type = AttributeTypeToken.valueOf(guid, "ats." + name);
nameToTypeMap.put(type.getName(), type);
return type;
}
- private static AttributeTypeToken createType(Long guid, String name, String description) {
+ public static AttributeTypeToken createType(Long guid, String name, String description) {
AttributeTypeToken type = AttributeTypeToken.valueOf(guid, "ats." + name, description);
nameToTypeMap.put(type.getName(), type);
return type;
diff --git a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/util/ActionFactory.java b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/util/ActionFactory.java
index c4700d1c075..edc8d8dc1fc 100644
--- a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/util/ActionFactory.java
+++ b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/util/ActionFactory.java
@@ -252,6 +252,17 @@ public class ActionFactory implements IAtsActionFactory {
changes.addWorkflowCreated(teamWf);
+ /**
+ * Add guid TeamDef and AI attributes. This can be removed after 0.26.0 where guids will no longer be needed.
+ */
+ String createGuidAttrs = services.getConfigValue("CreateGuidAttrs");
+ if (createGuidAttrs != null && createGuidAttrs.equals("true")) {
+ ConvertAtsConfigGuidAttributesOperations.convertActionableItemsIfNeeded(changes, teamWf.getStoreObject(),
+ services);
+ ConvertAtsConfigGuidAttributesOperations.convertTeamDefinitionIfNeeded(changes, teamWf.getStoreObject(),
+ services);
+ }
+
return teamWf;
}
diff --git a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/util/AtsCoreServiceImpl.java b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/util/AtsCoreServiceImpl.java
index f1453adbfcd..67f6a06f7fc 100644
--- a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/util/AtsCoreServiceImpl.java
+++ b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/util/AtsCoreServiceImpl.java
@@ -233,8 +233,8 @@ public abstract class AtsCoreServiceImpl implements IAtsServices {
}
@Override
- public <T> T getConfigItem(ArtifactToken artifactToken) {
- return getConfigItem(artifactToken.getId());
+ public <T> T getConfigItem(ArtifactId artifact) {
+ return getConfigItem(artifact.getId());
}
@SuppressWarnings("unchecked")
diff --git a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/util/ConvertAtsConfigGuidAttributesOperations.java b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/util/ConvertAtsConfigGuidAttributesOperations.java
new file mode 100644
index 00000000000..b2d9c3f5882
--- /dev/null
+++ b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/util/ConvertAtsConfigGuidAttributesOperations.java
@@ -0,0 +1,106 @@
+/*******************************************************************************
+ * Copyright (c) 2017 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.ats.core.util;
+
+import java.util.Collection;
+import java.util.LinkedList;
+import java.util.List;
+import org.eclipse.osee.ats.api.IAtsServices;
+import org.eclipse.osee.ats.api.ai.IAtsActionableItem;
+import org.eclipse.osee.ats.api.data.AtsAttributeTypes;
+import org.eclipse.osee.ats.api.team.IAtsTeamDefinition;
+import org.eclipse.osee.ats.api.util.IAtsChangeSet;
+import org.eclipse.osee.ats.api.workflow.IAttribute;
+import org.eclipse.osee.framework.core.data.ArtifactId;
+import org.eclipse.osee.framework.core.data.ArtifactToken;
+import org.eclipse.osee.framework.core.data.AttributeTypeToken;
+import org.eclipse.osee.framework.jdk.core.util.Strings;
+
+/**
+ * @author Donald G. Dunne
+ */
+public class ConvertAtsConfigGuidAttributesOperations {
+
+ public static final AttributeTypeToken TeamDefinition =
+ AtsAttributeTypes.createType(1152921504606847201L, "Team Definition");
+ public static final AttributeTypeToken ActionableItem = AtsAttributeTypes.createType(1152921504606847200L,
+ "Actionable Item", "Actionable Items that are impacted by this change.");
+
+ public static void convertActionableItemsIfNeeded(IAtsChangeSet changes, ArtifactToken art, IAtsServices services) {
+ // convert guids to id
+ Collection<ArtifactId> currentAiRefIds =
+ services.getAttributeResolver().getAttributeValues(art, AtsAttributeTypes.ActionableItemReference);
+
+ List<ArtifactId> neededAiRefIds = new LinkedList<>();
+ for (IAttribute<?> attr : services.getAttributeResolver().getAttributes(art, ActionableItem)) {
+ String aiArtGuid = (String) attr.getValue();
+ IAtsActionableItem ai = services.getConfigItem(aiArtGuid);
+ if (ai == null) {
+ services.getLogger().error("AI not found for aiArtGuid " + aiArtGuid + " for art " + art.toStringWithId());
+ } else if (!currentAiRefIds.contains(ai.getId())) {
+ neededAiRefIds.add(ai.getStoreObject());
+ }
+ }
+
+ for (ArtifactId need : neededAiRefIds) {
+ changes.addAttribute(art, AtsAttributeTypes.ActionableItemReference, need);
+ }
+
+ // convert id to guid
+ Collection<IAttribute<Object>> aiGuidAttrs = services.getAttributeResolver().getAttributes(art, ActionableItem);
+ List<String> currentAiGuidIds = new LinkedList<>();
+ for (IAttribute<Object> aiRefAttr : aiGuidAttrs) {
+ currentAiGuidIds.add(aiRefAttr.getValue().toString());
+ }
+
+ List<String> neededAiGuidIds = new LinkedList<>();
+ Collection<ArtifactId> aiArts =
+ services.getAttributeResolver().getAttributeValues(art, AtsAttributeTypes.ActionableItemReference);
+ for (ArtifactId id : aiArts) {
+ IAtsActionableItem ai = services.getConfigItem(id);
+ if (ai == null) {
+ services.getLogger().error("AI not found for id " + id + " for art " + art.toStringWithId());
+ } else if (!currentAiGuidIds.contains(ai.getStoreObject().getGuid())) {
+ neededAiGuidIds.add(ai.getStoreObject().getGuid());
+ }
+ }
+
+ for (String guid : neededAiGuidIds) {
+ changes.addAttribute(art, ActionableItem, guid);
+ }
+ }
+
+ public static void convertTeamDefinitionIfNeeded(IAtsChangeSet changes, ArtifactToken art, IAtsServices services) {
+ // convert guid to id
+ String teamDefId = services.getAttributeResolver().getSoleAttributeValueAsString(art,
+ AtsAttributeTypes.TeamDefinitionReference, null);
+ if (!Strings.isNumeric(teamDefId)) {
+ String teamDefGuid = services.getAttributeResolver().getSoleAttributeValue(art, TeamDefinition, "");
+ if (Strings.isValid(teamDefGuid)) {
+ IAtsTeamDefinition teamDef = services.getConfigItem(teamDefGuid);
+ changes.setSoleAttributeValue(art, AtsAttributeTypes.TeamDefinitionReference, teamDef.getStoreObject());
+ }
+ }
+ // convert id to guid
+ String teamDefGuid = services.getAttributeResolver().getSoleAttributeValue(art, TeamDefinition, "");
+ if (!Strings.isValid(teamDefGuid)) {
+ teamDefId = services.getAttributeResolver().getSoleAttributeValueAsString(art,
+ AtsAttributeTypes.TeamDefinitionReference, null);
+ if (Strings.isNumeric(teamDefId)) {
+ ArtifactId artifact = services.getArtifact(Long.valueOf(teamDefId));
+ if (artifact != null) {
+ changes.setSoleAttributeValue(art, TeamDefinition, artifact.getGuid());
+ }
+ }
+ }
+ }
+
+}

Back to the top