Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordonald.g.dunne2016-09-27 14:52:02 -0400
committerdonald.g.dunne2016-09-27 16:29:47 -0400
commit3ba06a501b9812d2cf4dcfd0e67e2b5a65780035 (patch)
treed05b459fa32a4b1c098cb8053a728e1b3a07ef9b
parent3646fae79dbda0a5073ad8f7b19d86169b1dbb29 (diff)
downloadorg.eclipse.osee-3ba06a501b9812d2cf4dcfd0e67e2b5a65780035.tar.gz
org.eclipse.osee-3ba06a501b9812d2cf4dcfd0e67e2b5a65780035.tar.xz
org.eclipse.osee-3ba06a501b9812d2cf4dcfd0e67e2b5a65780035.zip
bug[ats_ATS317009]: Add OSEE System assignee cleanup
-rw-r--r--plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/query/IAtsQueryService.java7
-rw-r--r--plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/util/IAtsStoreService.java2
-rw-r--r--plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/IAtsClient.java3
-rw-r--r--plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/internal/AtsClientImpl.java7
-rw-r--r--plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/internal/AtsStoreService.java5
-rw-r--r--plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/internal/query/AtsQueryServiceImpl.java17
-rw-r--r--plugins/org.eclipse.osee.ats.core/META-INF/MANIFEST.MF1
-rw-r--r--plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/query/AbstractAtsQueryService.java65
-rw-r--r--plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/AtsServerImpl.java2
-rw-r--r--plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/query/AtsQueryServiceImpl.java23
-rw-r--r--plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/util/AtsStoreServiceImpl.java5
-rw-r--r--plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/navigate/AtsNavigateViewItems.java4
-rw-r--r--plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/CleanupOseeSystemAssignedWorkflows.java56
13 files changed, 188 insertions, 9 deletions
diff --git a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/query/IAtsQueryService.java b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/query/IAtsQueryService.java
index aecc1d6e6c..cd0da8c677 100644
--- a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/query/IAtsQueryService.java
+++ b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/query/IAtsQueryService.java
@@ -12,9 +12,12 @@ package org.eclipse.osee.ats.api.query;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.List;
import org.eclipse.osee.ats.api.IAtsWorkItem;
import org.eclipse.osee.ats.api.user.IAtsUser;
import org.eclipse.osee.ats.api.workflow.WorkItemType;
+import org.eclipse.osee.framework.core.data.ArtifactId;
+import org.eclipse.osee.framework.core.data.BranchId;
import org.eclipse.osee.framework.core.data.IArtifactType;
/**
@@ -24,6 +27,8 @@ public interface IAtsQueryService {
IAtsQuery createQuery(WorkItemType workItemType, WorkItemType... workItemTypes);
+ Collection<IAtsWorkItem> runQuery(String query, Object... data);
+
IAtsWorkItemFilter createFilter(Collection<? extends IAtsWorkItem> workItems);
ArrayList<AtsSearchData> getSavedSearches(IAtsUser atsUser, String namespace);
@@ -40,4 +45,6 @@ public interface IAtsQueryService {
IAtsConfigQuery createQuery(IArtifactType artifactType);
+ Collection<ArtifactId> getArtifacts(List<Integer> ids, BranchId branch);
+
}
diff --git a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/util/IAtsStoreService.java b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/util/IAtsStoreService.java
index c5a219d133..3b718af775 100644
--- a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/util/IAtsStoreService.java
+++ b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/util/IAtsStoreService.java
@@ -49,4 +49,6 @@ public interface IAtsStoreService {
boolean isDateType(IAttributeType attributeType);
+ boolean isOfType(ArtifactId artifact, IArtifactType artifactType);
+
}
diff --git a/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/IAtsClient.java b/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/IAtsClient.java
index ef51c13cc9..24cf5dfc42 100644
--- a/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/IAtsClient.java
+++ b/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/IAtsClient.java
@@ -22,6 +22,7 @@ import org.eclipse.osee.ats.api.review.IAtsReviewServiceProvider;
import org.eclipse.osee.ats.api.team.IAtsConfigItemFactory;
import org.eclipse.osee.ats.api.team.IAtsTeamDefinitionService;
import org.eclipse.osee.ats.api.team.IAtsWorkItemFactory;
+import org.eclipse.osee.ats.api.util.IAtsChangeSet;
import org.eclipse.osee.ats.api.util.IAtsEventService;
import org.eclipse.osee.ats.api.version.IAtsVersionServiceProvider;
import org.eclipse.osee.ats.api.version.IVersionFactory;
@@ -127,4 +128,6 @@ public interface IAtsClient extends IAtsServices, IAtsNotifier, IAttributeResolv
void reloadUserCache(boolean pend);
+ IAtsChangeSet createAtsChangeSet(String comment);
+
}
diff --git a/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/internal/AtsClientImpl.java b/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/internal/AtsClientImpl.java
index 563e86c306..8169dde6a2 100644
--- a/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/internal/AtsClientImpl.java
+++ b/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/internal/AtsClientImpl.java
@@ -237,7 +237,7 @@ public class AtsClientImpl extends AtsCoreServiceImpl implements IAtsClient {
atsStateFactory = AtsCoreFactory.newStateFactory(getServices(), atsLogFactory);
atsStoreService = new AtsStoreService(workItemFactory);
- atsQueryService = new AtsQueryServiceImpl(this);
+ atsQueryService = new AtsQueryServiceImpl(this, jdbcService);
actionableItemManager = new ActionableItemManager(attributeResolverService, atsStoreService, this);
sequenceProvider = new ISequenceProvider() {
@@ -772,4 +772,9 @@ public class AtsClientImpl extends AtsCoreServiceImpl implements IAtsClient {
configProvider.clearConfigurationsCaches();
}
+ @Override
+ public IAtsChangeSet createAtsChangeSet(String comment) {
+ return getStoreService().createAtsChangeSet(comment, getUserService().getCurrentUser());
+ }
+
}
diff --git a/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/internal/AtsStoreService.java b/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/internal/AtsStoreService.java
index 039d466354..cde0d64628 100644
--- a/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/internal/AtsStoreService.java
+++ b/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/internal/AtsStoreService.java
@@ -136,4 +136,9 @@ public class AtsStoreService implements IAtsStoreService {
return AttributeTypeManager.isBaseTypeCompatible(DateAttribute.class, attributeType);
}
+ @Override
+ public boolean isOfType(ArtifactId artifact, IArtifactType artifactType) {
+ return ((Artifact) artifact).isOfType(artifactType);
+ }
+
}
diff --git a/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/internal/query/AtsQueryServiceImpl.java b/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/internal/query/AtsQueryServiceImpl.java
index 4de0069664..88655499fb 100644
--- a/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/internal/query/AtsQueryServiceImpl.java
+++ b/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/internal/query/AtsQueryServiceImpl.java
@@ -12,6 +12,7 @@ package org.eclipse.osee.ats.core.client.internal.query;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.List;
import java.util.logging.Level;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -20,7 +21,6 @@ import org.eclipse.osee.ats.api.data.AtsAttributeTypes;
import org.eclipse.osee.ats.api.query.AtsSearchData;
import org.eclipse.osee.ats.api.query.IAtsConfigQuery;
import org.eclipse.osee.ats.api.query.IAtsQuery;
-import org.eclipse.osee.ats.api.query.IAtsQueryService;
import org.eclipse.osee.ats.api.query.IAtsSearchDataProvider;
import org.eclipse.osee.ats.api.query.IAtsWorkItemFilter;
import org.eclipse.osee.ats.api.user.IAtsUser;
@@ -29,23 +29,29 @@ import org.eclipse.osee.ats.api.workflow.IAttribute;
import org.eclipse.osee.ats.api.workflow.WorkItemType;
import org.eclipse.osee.ats.core.client.IAtsClient;
import org.eclipse.osee.ats.core.client.internal.Activator;
+import org.eclipse.osee.ats.core.query.AbstractAtsQueryService;
import org.eclipse.osee.ats.core.query.AtsWorkItemFilter;
import org.eclipse.osee.ats.core.util.AtsJsonFactory;
import org.eclipse.osee.framework.core.data.ArtifactId;
+import org.eclipse.osee.framework.core.data.BranchId;
import org.eclipse.osee.framework.core.data.IArtifactType;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
+import org.eclipse.osee.framework.jdk.core.util.Collections;
import org.eclipse.osee.framework.jdk.core.util.Conditions;
import org.eclipse.osee.framework.logging.OseeLog;
+import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
+import org.eclipse.osee.jdbc.JdbcService;
/**
* @author Donald G. Dunne
*/
-public class AtsQueryServiceImpl implements IAtsQueryService {
+public class AtsQueryServiceImpl extends AbstractAtsQueryService {
private final IAtsClient atsClient;
private static final Pattern namespacePattern = Pattern.compile("\"namespace\":\"(.*?)\"");
- public AtsQueryServiceImpl(IAtsClient atsClient) {
+ public AtsQueryServiceImpl(IAtsClient atsClient, JdbcService jdbcService) {
+ super(jdbcService, atsClient.getServices());
this.atsClient = atsClient;
}
@@ -221,4 +227,9 @@ public class AtsQueryServiceImpl implements IAtsQueryService {
return data;
}
+ @Override
+ public Collection<ArtifactId> getArtifacts(List<Integer> ids, BranchId branch) {
+ return Collections.castAll(ArtifactQuery.getArtifactListFromIds(ids, branch));
+ }
+
}
diff --git a/plugins/org.eclipse.osee.ats.core/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.ats.core/META-INF/MANIFEST.MF
index 5d4432d5b7..b979220e52 100644
--- a/plugins/org.eclipse.osee.ats.core/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.osee.ats.core/META-INF/MANIFEST.MF
@@ -19,6 +19,7 @@ Import-Package: com.google.common.base,
org.eclipse.osee.framework.jdk.core.util,
org.eclipse.osee.framework.jdk.core.util.xml,
org.eclipse.osee.framework.logging,
+ org.eclipse.osee.jdbc,
org.eclipse.osee.logger
Bundle-Vendor: Eclipse Open System Engineering Environment
Export-Package: org.eclipse.osee.ats.core,
diff --git a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/query/AbstractAtsQueryService.java b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/query/AbstractAtsQueryService.java
new file mode 100644
index 0000000000..c28d16c056
--- /dev/null
+++ b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/query/AbstractAtsQueryService.java
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 2016 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.query;
+
+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.IAtsWorkItem;
+import org.eclipse.osee.ats.api.data.AtsArtifactTypes;
+import org.eclipse.osee.ats.api.query.IAtsQueryService;
+import org.eclipse.osee.ats.core.util.AtsUtilCore;
+import org.eclipse.osee.framework.core.data.ArtifactId;
+import org.eclipse.osee.jdbc.JdbcService;
+import org.eclipse.osee.jdbc.JdbcStatement;
+
+/**
+ * @author Donald G. Dunne
+ */
+public abstract class AbstractAtsQueryService implements IAtsQueryService {
+
+ protected final JdbcService jdbcService;
+ private final IAtsServices services;
+
+ public AbstractAtsQueryService(JdbcService jdbcService, IAtsServices services) {
+ this.jdbcService = jdbcService;
+ this.services = services;
+ }
+
+ /**
+ * Run query that returns art_ids of IAtsWorkItems to return
+ */
+ @Override
+ public Collection<IAtsWorkItem> runQuery(String query, Object... data) {
+ JdbcStatement chStmt = jdbcService.getClient().getStatement();
+ List<Integer> ids = new LinkedList<Integer>();
+ try {
+ chStmt.runPreparedQuery(query, data);
+ while (chStmt.next()) {
+ ids.add(chStmt.getInt("art_id"));
+ }
+ } finally {
+ chStmt.close();
+ }
+ List<IAtsWorkItem> workItems = new LinkedList<>();
+ for (ArtifactId art : services.getQueryService().getArtifacts(ids, AtsUtilCore.getAtsBranch())) {
+ if (services.getStoreService().isOfType(art, AtsArtifactTypes.AbstractWorkflowArtifact)) {
+ IAtsWorkItem workItem = services.getWorkItemFactory().getWorkItem(art);
+ if (workItem != null) {
+ workItems.add(workItem);
+ }
+ }
+ }
+ return workItems;
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/AtsServerImpl.java b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/AtsServerImpl.java
index 00cd0d64ad..6ea8cfa4e1 100644
--- a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/AtsServerImpl.java
+++ b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/AtsServerImpl.java
@@ -244,7 +244,7 @@ public class AtsServerImpl extends AtsCoreServiceImpl implements IAtsServer {
}
};
- atsQueryService = new AtsQueryServiceImpl(this);
+ atsQueryService = new AtsQueryServiceImpl(this, jdbcService);
actionableItemManager = new ActionableItemManager(attributeResolverService, atsStoreService, this);
actionFactory = new ActionFactory(workItemFactory, utilService, sequenceProvider, actionableItemManager,
attributeResolverService, atsStateFactory, getServices());
diff --git a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/query/AtsQueryServiceImpl.java b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/query/AtsQueryServiceImpl.java
index 814da1d73a..7db2f4d78f 100644
--- a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/query/AtsQueryServiceImpl.java
+++ b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/query/AtsQueryServiceImpl.java
@@ -12,26 +12,33 @@ package org.eclipse.osee.ats.rest.internal.query;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.LinkedList;
+import java.util.List;
import org.eclipse.osee.ats.api.IAtsWorkItem;
import org.eclipse.osee.ats.api.query.AtsSearchData;
import org.eclipse.osee.ats.api.query.IAtsConfigQuery;
import org.eclipse.osee.ats.api.query.IAtsQuery;
-import org.eclipse.osee.ats.api.query.IAtsQueryService;
import org.eclipse.osee.ats.api.query.IAtsWorkItemFilter;
import org.eclipse.osee.ats.api.user.IAtsUser;
import org.eclipse.osee.ats.api.workflow.WorkItemType;
+import org.eclipse.osee.ats.core.query.AbstractAtsQueryService;
import org.eclipse.osee.ats.core.query.AtsWorkItemFilter;
import org.eclipse.osee.ats.rest.IAtsServer;
+import org.eclipse.osee.framework.core.data.ArtifactId;
+import org.eclipse.osee.framework.core.data.BranchId;
import org.eclipse.osee.framework.core.data.IArtifactType;
+import org.eclipse.osee.framework.jdk.core.util.Collections;
+import org.eclipse.osee.jdbc.JdbcService;
/**
* @author Donald G. Dunne
*/
-public class AtsQueryServiceImpl implements IAtsQueryService {
+public class AtsQueryServiceImpl extends AbstractAtsQueryService {
private final IAtsServer atsServer;
- public AtsQueryServiceImpl(IAtsServer atsServer) {
+ public AtsQueryServiceImpl(IAtsServer atsServer, JdbcService jdbcService) {
+ super(jdbcService, atsServer.getServices());
this.atsServer = atsServer;
}
@@ -87,4 +94,14 @@ public class AtsQueryServiceImpl implements IAtsQueryService {
throw new UnsupportedOperationException("Unsupported on the server");
}
+ @Override
+ public Collection<ArtifactId> getArtifacts(List<Integer> ids, BranchId branch) {
+ List<Long> uuids = new LinkedList<>();
+ for (Integer id : ids) {
+ uuids.add(Long.valueOf(id));
+ }
+ return Collections.castAll(
+ atsServer.getOrcsApi().getQueryFactory().fromBranch(branch).andUuids(uuids).getResults().getList());
+ }
+
}
diff --git a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/util/AtsStoreServiceImpl.java b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/util/AtsStoreServiceImpl.java
index cd85659c2f..8d51b18381 100644
--- a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/util/AtsStoreServiceImpl.java
+++ b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/util/AtsStoreServiceImpl.java
@@ -129,4 +129,9 @@ public class AtsStoreServiceImpl implements IAtsStoreService {
return atsServer.getOrcsApi().getOrcsTypes().getAttributeTypes().isDateType(attributeType);
}
+ @Override
+ public boolean isOfType(ArtifactId artifact, IArtifactType artifactType) {
+ return ((ArtifactReadable) artifact).isOfType(artifactType);
+ }
+
}
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/navigate/AtsNavigateViewItems.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/navigate/AtsNavigateViewItems.java
index 4cd3b3318b..79fa6b45ef 100644
--- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/navigate/AtsNavigateViewItems.java
+++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/navigate/AtsNavigateViewItems.java
@@ -48,6 +48,7 @@ import org.eclipse.osee.ats.operation.MoveTeamWorkflowsBlam;
import org.eclipse.osee.ats.search.AtsQuickSearchOperationFactory;
import org.eclipse.osee.ats.search.AtsSearchWorkflowSearchItem;
import org.eclipse.osee.ats.util.AtsEditor;
+import org.eclipse.osee.ats.util.CleanupOseeSystemAssignedWorkflows;
import org.eclipse.osee.ats.util.CreateActionUsingAllActionableItems;
import org.eclipse.osee.ats.util.DoesNotWorkItemAts;
import org.eclipse.osee.ats.util.Import.ImportActionsViaSpreadsheetBlam;
@@ -217,13 +218,14 @@ public final class AtsNavigateViewItems implements XNavigateViewItems, IXNavigat
new DoesNotWorkItemAts(adminItems);
new XNavigateItemAction(adminItems, new OpenChangeReportByTransactionIdAction(), FrameworkImage.BRANCH_CHANGE);
new XNavigateItemAction(adminItems, new OpenArtifactEditorById(), FrameworkImage.ARTIFACT_EDITOR);
- new XNavigateItemAction(adminItems, new OpenOrphanedTasks(), AtsImage.TASK);
new XNavigateItemAction(adminItems, new PurgeTransactionAction(), FrameworkImage.PURGE);
XNavigateItem healthItems = new XNavigateItemFolder(adminItems, "Health");
new ValidateAtsDatabase(healthItems);
new ValidateAtsConfiguration(healthItems);
new ValidateWorkspaceToDatabaseWorkDefinitions(healthItems);
+ new CleanupOseeSystemAssignedWorkflows(healthItems);
+ new XNavigateItemAction(adminItems, new OpenOrphanedTasks(), AtsImage.TASK);
XNavigateItem extra = new XNavigateItemFolder(adminItems, "Other");
Set<XNavigateExtensionPointData> extraItems =
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/CleanupOseeSystemAssignedWorkflows.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/CleanupOseeSystemAssignedWorkflows.java
new file mode 100644
index 0000000000..18466f02e1
--- /dev/null
+++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/CleanupOseeSystemAssignedWorkflows.java
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (c) 2016 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.util;
+
+import java.util.Collection;
+import org.eclipse.osee.ats.api.IAtsWorkItem;
+import org.eclipse.osee.ats.api.util.IAtsChangeSet;
+import org.eclipse.osee.ats.core.users.AtsCoreUsers;
+import org.eclipse.osee.ats.internal.AtsClientService;
+import org.eclipse.osee.framework.core.util.XResultData;
+import org.eclipse.osee.framework.ui.plugin.PluginUiImage;
+import org.eclipse.osee.framework.ui.plugin.xnavigate.XNavigateComposite.TableLoadOption;
+import org.eclipse.osee.framework.ui.plugin.xnavigate.XNavigateItem;
+import org.eclipse.osee.framework.ui.plugin.xnavigate.XNavigateItemAction;
+import org.eclipse.osee.framework.ui.skynet.results.XResultDataUI;
+
+/**
+ * @author Donald G. Dunne
+ */
+public class CleanupOseeSystemAssignedWorkflows extends XNavigateItemAction {
+
+ public CleanupOseeSystemAssignedWorkflows(XNavigateItem parent) {
+ super(parent, "Cleanup OSEE System assigned workflows.", PluginUiImage.ADMIN);
+ }
+
+ @Override
+ public void run(TableLoadOption... tableLoadOptions) {
+
+ XResultData results = new XResultData();
+ Collection<IAtsWorkItem> workItems = AtsClientService.get().getQueryService().runQuery(
+ "select art_id from osee_attribute where attr_type_id in (1152921504606847192) and value like '%99999999%'");
+ IAtsChangeSet changes = AtsClientService.get().createAtsChangeSet("OSEE System Assignee Cleanup");
+ for (IAtsWorkItem workItem : workItems) {
+ if (workItem.getAssignees().contains(AtsCoreUsers.SYSTEM_USER)) {
+ workItem.getStateMgr().removeAssignee(AtsCoreUsers.SYSTEM_USER);
+ results.log("Removed System User from " + workItem.toStringWithId());
+ changes.add(workItem);
+ if (workItem.getStateMgr().getAssignees().isEmpty()) {
+ workItem.getStateMgr().addAssignee(AtsCoreUsers.UNASSIGNED_USER);
+ results.log("Added UnAssigned to " + workItem.toStringWithId());
+ }
+ }
+ }
+ XResultDataUI.report(results, getName());
+ changes.execute();
+ }
+
+}

Back to the top