Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAngel Avila2014-07-22 21:45:15 +0000
committerRoberto E. Escobar2014-08-28 23:59:43 +0000
commit4f44aa3a48106090729e3974ea395d3adb646e3a (patch)
tree23565b36679993f75934b69eb1134ba665aac8c6 /plugins
parent0e4fe7510604344ef9c8aa8f07e029cd924d77c4 (diff)
downloadorg.eclipse.osee-4f44aa3a48106090729e3974ea395d3adb646e3a.tar.gz
org.eclipse.osee-4f44aa3a48106090729e3974ea395d3adb646e3a.tar.xz
org.eclipse.osee-4f44aa3a48106090729e3974ea395d3adb646e3a.zip
feature[ats_ATS73373]: Create Blam to correct ATS ID equal 0
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.osee.ats/plugin.xml8
-rw-r--r--plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/operation/AtsIdCheckBlam.java114
2 files changed, 122 insertions, 0 deletions
diff --git a/plugins/org.eclipse.osee.ats/plugin.xml b/plugins/org.eclipse.osee.ats/plugin.xml
index 0647b3f715c..37b4dc5227a 100644
--- a/plugins/org.eclipse.osee.ats/plugin.xml
+++ b/plugins/org.eclipse.osee.ats/plugin.xml
@@ -509,6 +509,14 @@
</Operation>
</extension>
<extension
+ id="ATSIDCheckBlam"
+ name="ATSIDCheckBlam"
+ point="org.eclipse.osee.framework.ui.skynet.BlamOperation">
+ <Operation
+ className="org.eclipse.osee.ats.operation.AtsIdCheckBlam">
+ </Operation>
+ </extension>
+ <extension
id="ModifyActionableItemsBlam"
name="ModifyActionableItemsBlam"
point="org.eclipse.osee.framework.ui.skynet.BlamOperation">
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/operation/AtsIdCheckBlam.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/operation/AtsIdCheckBlam.java
new file mode 100644
index 00000000000..790112c636c
--- /dev/null
+++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/operation/AtsIdCheckBlam.java
@@ -0,0 +1,114 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 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.operation;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.osee.ats.api.data.AtsArtifactTypes;
+import org.eclipse.osee.ats.api.data.AtsAttributeTypes;
+import org.eclipse.osee.ats.api.team.IAtsTeamDefinition;
+import org.eclipse.osee.ats.api.util.IAtsUtilService;
+import org.eclipse.osee.ats.api.util.ISequenceProvider;
+import org.eclipse.osee.ats.core.client.IAtsClient;
+import org.eclipse.osee.ats.core.client.team.TeamWorkFlowArtifact;
+import org.eclipse.osee.ats.internal.AtsClientService;
+import org.eclipse.osee.framework.core.enums.CoreBranches;
+import org.eclipse.osee.framework.core.enums.DeletionFlag;
+import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
+import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
+import org.eclipse.osee.framework.skynet.core.transaction.SkynetTransaction;
+import org.eclipse.osee.framework.skynet.core.transaction.TransactionManager;
+import org.eclipse.osee.framework.ui.skynet.blam.AbstractBlam;
+import org.eclipse.osee.framework.ui.skynet.blam.VariableMap;
+import org.eclipse.osee.framework.ui.swt.Displays;
+
+/**
+ * @author Angel Avila
+ */
+public class AtsIdCheckBlam extends AbstractBlam {
+ private static final String CHANGE_INVALID_IDS = "Correct Invalid ATS IDs?";
+
+ @Override
+ public void runOperation(final VariableMap variableMap, IProgressMonitor monitor) {
+ Displays.ensureInDisplayThread(new Runnable() {
+ @Override
+ public void run() {
+
+ boolean isPersist = variableMap.getBoolean(CHANGE_INVALID_IDS);
+
+ IAtsClient iAtsClient = AtsClientService.get();
+ IAtsUtilService utilService = iAtsClient.getUtilService();
+ ISequenceProvider sequenceProvider = AtsClientService.get().getSequenceProvider();
+
+ SkynetTransaction transaction = null;
+
+ //replace next lines with commented out lines when ATS81395 is completed
+ List<Artifact> workflowArtifacts =
+ ArtifactQuery.getArtifactListFromType(AtsArtifactTypes.TeamWorkflow, CoreBranches.COMMON,
+ DeletionFlag.INCLUDE_DELETED);
+ //QueryBuilderArtifact builder = ArtifactQuery.createQueryBuilder(CoreBranches.COMMON);
+ // builder.andIsOfType(AtsArtifactTypes.AbstractWorkflowArtifact);/
+ // builder.and(AtsAttributeTypes.AtsId, Operator.EQUAL, "0");
+ //ResultSet<Artifact> results = builder.getResults();
+
+ for (Artifact art : workflowArtifacts) {
+ // remove when ATS81395 is completed
+ String atsIdValue = art.getSoleAttributeValueAsString(AtsAttributeTypes.AtsId, "");
+ if (atsIdValue.equals("0")) {
+ // END Remove.
+
+ if (isPersist) {
+ // Don't wanna waste IDs unless we're gonna actually persist
+ TeamWorkFlowArtifact teamArt = (TeamWorkFlowArtifact) art;
+ IAtsTeamDefinition teamDefinition = teamArt.getTeamDefinition();
+ String nextAtsId = utilService.getNextAtsId(sequenceProvider, null, teamDefinition);
+
+ art.setSoleAttributeFromString(AtsAttributeTypes.AtsId, nextAtsId);
+ if (transaction == null) {
+ transaction =
+ TransactionManager.createTransaction(CoreBranches.COMMON, "Fix ATS Workflows with ID ATS0");
+ }
+ transaction.addArtifact(art);
+ logf(String.format("New ID for [%s] is [%s].", art.getName(), nextAtsId));
+ } else {
+ logf(String.format("%s Has an invalid ID = 0", art.getName()));
+ }
+ }
+ }
+
+ if (transaction != null && isPersist) {
+ transaction.execute();
+ }
+ };
+ });
+ }
+
+ @Override
+ public String getName() {
+ return "ATS ID Check";
+ }
+
+ @Override
+ public Collection<String> getCategories() {
+ return Arrays.asList("ATS");
+ }
+
+ @Override
+ public String getXWidgetsXml() {
+ return "<xWidgets>" +
+ //
+ "<XWidget xwidgetType=\"XCheckBox\" displayName=\"" + CHANGE_INVALID_IDS + "\" horizontalLabel=\"true\" defaultValue=\"false\"/>" +
+ //
+ "</xWidgets>";
+ }
+}

Back to the top