Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordonald.g.dunne2017-07-24 22:06:34 -0400
committerdonald.g.dunne2017-07-25 11:41:47 -0400
commit52ea50af7b6a76de940724b9b0b43460e73007c7 (patch)
tree06e7e8f2327682ba3865555c163aa196d0b5d44f
parent561825da83222111f3849b454d608f411ce22a36 (diff)
downloadorg.eclipse.osee-52ea50af7b6a76de940724b9b0b43460e73007c7.tar.gz
org.eclipse.osee-52ea50af7b6a76de940724b9b0b43460e73007c7.tar.xz
org.eclipse.osee-52ea50af7b6a76de940724b9b0b43460e73007c7.zip
bug: Consolidate ATS caches to improve test reliability
-rw-r--r--plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/IAtsServices.java5
-rw-r--r--plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/workdef/model/RuleDefinitionOption.java1
-rw-r--r--plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/workflow/AtsTest_Workflow_Suite.java3
-rw-r--r--plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/workflow/CreateTaskRuleTest.java147
-rw-r--r--plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/util/DbInitTest.java5
-rw-r--r--plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/config/AtsBulkLoad.java2
-rw-r--r--plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/internal/AtsClientImpl.java19
-rw-r--r--plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/workdef/AtsCore_WorkDef_JT_Suite.java1
-rw-r--r--plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/workdef/AtsWorkDefinitionServiceImplRulesTest.java115
-rw-r--r--plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/util/AtsCoreServiceImpl.java11
-rw-r--r--plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/workdef/AtsWorkDefinitionServiceImpl.java5
-rw-r--r--plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/AtsServerImpl.java8
-rw-r--r--plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/config/AtsConfigOperation.java51
-rw-r--r--plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/config/AtsDatabaseConfig.java2
-rw-r--r--plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/config/copy/CopyAtsConfigurationOperation.java2
-rw-r--r--plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/navigate/AtsNavigateViewItems.java1
-rw-r--r--plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/navigate/ClearAtsConfigCache.java2
-rw-r--r--plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/navigate/ClearAtsWorkDefinitionCache.java43
18 files changed, 183 insertions, 240 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 dce86ec099..6103b5dba2 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
@@ -162,9 +162,7 @@ public interface IAtsServices extends IAtsEarnedValueServiceProvider, IAtsConfig
List<IAtsSearchDataProvider> getSearchDataProviders();
- void invalidateAllCaches();
-
- void invalidateWorkDefinitionCache();
+ void clearCaches();
ITeamWorkflowProvidersLazy getTeamWorkflowProviders();
@@ -185,4 +183,5 @@ public interface IAtsServices extends IAtsEarnedValueServiceProvider, IAtsConfig
IAgileService getAgileService();
ArtifactToken getArtifactByAtsId(String id);
+
}
diff --git a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/workdef/model/RuleDefinitionOption.java b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/workdef/model/RuleDefinitionOption.java
index 643119a6e9..140b4b6a3d 100644
--- a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/workdef/model/RuleDefinitionOption.java
+++ b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/workdef/model/RuleDefinitionOption.java
@@ -49,6 +49,5 @@ public enum RuleDefinitionOption {
for (int i = 0; i < locations.length; i++) {
this.ruleLocs.add(locations[i]);
}
-
}
}
diff --git a/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/workflow/AtsTest_Workflow_Suite.java b/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/workflow/AtsTest_Workflow_Suite.java
index f8fa272539..16ad0d5d59 100644
--- a/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/workflow/AtsTest_Workflow_Suite.java
+++ b/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/workflow/AtsTest_Workflow_Suite.java
@@ -29,8 +29,7 @@ import org.junit.runners.Suite;
AtsTaskEndpointImplTest.class,
WfePromptChangeStatusTest.class,
TeamWorkflowProvidersTest.class,
- AtsRelationResolverServiceTest.class,
- CreateTaskRuleTest.class //
+ AtsRelationResolverServiceTest.class //
})
public class AtsTest_Workflow_Suite {
diff --git a/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/workflow/CreateTaskRuleTest.java b/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/workflow/CreateTaskRuleTest.java
deleted file mode 100644
index 74b4146dbc..0000000000
--- a/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/workflow/CreateTaskRuleTest.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 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.client.integration.tests.ats.workflow;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Date;
-import org.eclipse.osee.ats.api.data.AtsArtifactToken;
-import org.eclipse.osee.ats.api.data.AtsAttributeTypes;
-import org.eclipse.osee.ats.api.team.ChangeType;
-import org.eclipse.osee.ats.api.user.IAtsUser;
-import org.eclipse.osee.ats.api.util.IAtsChangeSet;
-import org.eclipse.osee.ats.api.workdef.AddRuleData;
-import org.eclipse.osee.ats.api.workdef.CreateTaskRuleDefinition;
-import org.eclipse.osee.ats.api.workdef.IAtsRuleDefinition;
-import org.eclipse.osee.ats.api.workdef.NullRuleDefinition;
-import org.eclipse.osee.ats.api.workflow.ActionResult;
-import org.eclipse.osee.ats.api.workflow.IAtsTask;
-import org.eclipse.osee.ats.client.integration.tests.AtsClientService;
-import org.eclipse.osee.ats.client.integration.tests.ats.core.client.AtsTestUtil;
-import org.eclipse.osee.ats.core.client.IAtsClient;
-import org.eclipse.osee.ats.core.config.ActionableItems;
-import org.eclipse.osee.ats.demo.api.DemoArtifactToken;
-import org.eclipse.osee.framework.core.data.ArtifactToken;
-import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * Test unit for {@link CreateTaskRuleDefinition}
- *
- * @author Mark Joy
- */
-
-public class CreateTaskRuleTest {
-
- private static final String CREATE_TASK_ACTION_FROM_TEAM_DEF_TITLE = "CreateTaskActionFromTeamDefTitle";
- private static final String CREATE_TASK_ACTION_FROM_AI_TITLE = "CreateTaskActionFromAITitle";
- private static final String TEST_CREATE_TASK_RULE = "TestCreateTaskRule";
-
- @Before
- @After
- public void cleanup() throws Exception {
- IAtsClient atsClient = AtsClientService.get();
- Artifact ruleArtifact = atsClient.getArtifact(AtsArtifactToken.RuleDefinitions);
- ruleArtifact.deleteAttributes(AtsAttributeTypes.DslSheet);
- ruleArtifact.persist(getClass().getSimpleName());
- ruleArtifact.reloadAttributesAndRelations();
-
- Artifact teamDefArt = atsClient.getArtifact(DemoArtifactToken.SAW_Code);
- teamDefArt.deleteAttribute(AtsAttributeTypes.RuleDefinition, TEST_CREATE_TASK_RULE);
- teamDefArt.persist(getClass().getSimpleName());
- teamDefArt.reloadAttributesAndRelations();
-
- Artifact aiArt = atsClient.getArtifact(DemoArtifactToken.SAW_Test_AI);
- aiArt.deleteAttribute(AtsAttributeTypes.RuleDefinition, TEST_CREATE_TASK_RULE);
- aiArt.persist(getClass().getSimpleName());
- aiArt.reloadAttributesAndRelations();
-
- AtsTestUtil.cleanupSimpleTest(CREATE_TASK_ACTION_FROM_TEAM_DEF_TITLE);
- AtsTestUtil.cleanupSimpleTest(CREATE_TASK_ACTION_FROM_AI_TITLE);
- AtsTestUtil.cleanupSimpleTest(getClass().getSimpleName());
-
- AtsClientService.get().getWorkDefinitionService().clearRuleDefinitionsCache();
- }
-
- @Test
- public void testTeamDefConfig() {
- test(DemoArtifactToken.SAW_Code, DemoArtifactToken.SAW_Code_AI, CREATE_TASK_ACTION_FROM_TEAM_DEF_TITLE);
- }
-
- @Test
- public void testActionableItemConfig() {
- test(DemoArtifactToken.SAW_Test_AI, DemoArtifactToken.SAW_Test_AI, CREATE_TASK_ACTION_FROM_AI_TITLE);
- }
-
- public void test(ArtifactToken configObjectToken, ArtifactToken actionableItem, String title) {
- IAtsClient atsClient = AtsClientService.get();
- Collection<IAtsRuleDefinition> allRuleDefs = atsClient.getWorkDefinitionService().getAllRuleDefinitions();
- Assert.assertEquals("We should have no rules", 0, allRuleDefs.size());
-
- IAtsRuleDefinition ruleDef = atsClient.getWorkDefinitionService().getRuleDefinition(TEST_CREATE_TASK_RULE);
- Assert.assertTrue("Should be a NullRuleDefinition", ruleDef instanceof NullRuleDefinition);
-
- // Retrieve Rule DSL artifact and add new rules for testing with
- Artifact ruleArtifact = atsClient.getArtifact(AtsArtifactToken.RuleDefinitions);
- ruleArtifact.setSoleAttributeFromString(AtsAttributeTypes.DslSheet, getTestDSL());
- ruleArtifact.persist(getClass().getSimpleName());
-
- ruleArtifact.reloadAttributesAndRelations();
- // check that rule is added successfully
- ruleDef = atsClient.getWorkDefinitionService().getRuleDefinition(TEST_CREATE_TASK_RULE);
- Assert.assertEquals("Should have found rule " + TEST_CREATE_TASK_RULE, TEST_CREATE_TASK_RULE, ruleDef.getName());
-
- // Update/Create? TeamWorkflow with rule for testing create task rule
- AddRuleData setRuleData = new AddRuleData();
- setRuleData.setConfigItemUuid(configObjectToken.getId());
- setRuleData.setRuleName(TEST_CREATE_TASK_RULE);
- AtsClientService.getRuleEp().addRuleToConfig(setRuleData);
-
- Artifact teamDefArt = atsClient.getArtifact(configObjectToken);
- teamDefArt.reloadAttributesAndRelations();
- String ruleName = teamDefArt.getSoleAttributeValueAsString(AtsAttributeTypes.RuleDefinition, "");
- Assert.assertEquals("Rule name should be " + TEST_CREATE_TASK_RULE, TEST_CREATE_TASK_RULE, ruleName);
-
- // Create new Workflow - rule should be triggered
- IAtsUser currentUser = atsClient.getUserService().getCurrentUser();
- IAtsChangeSet changes = atsClient.getStoreService().createAtsChangeSet(getClass().getSimpleName(), currentUser);
- ActionResult result = atsClient.getActionFactory().createAction(currentUser, getClass().getSimpleName(), title,
- ChangeType.Improvement, "priority", false, null,
- ActionableItems.getActionableItems(Arrays.asList(actionableItem.getName()), AtsClientService.get()),
- new Date(), currentUser, null, changes);
- changes.execute();
-
- // verify that tasks have been created
- Collection<IAtsTask> tasks = atsClient.getTaskService().getTasks(result.getFirstTeam());
- Assert.assertEquals("There can be only one", 1, tasks.size());
- IAtsTask next = tasks.iterator().next();
- Assert.assertEquals("Name should be *Create a Task from Rule*", "Create a Task from Rule - CreateTaskRuleTest",
- next.getName());
- Assert.assertEquals("Should be a description", "This is the description of the task", next.getDescription());
-
- }
-
- private String getTestDSL() {
- String rule = "rule name \"" + TEST_CREATE_TASK_RULE + "\" { \n";
- rule += " title \"Create a Task from Rule - CreateTaskRuleTest\" \n";
- rule += " description \"This is the description of the task\" \n";
- rule += " ruleLocation TeamDefinition \n";
- rule += " assignees \"Joe Smith\" \n";
- rule += " relatedState \"Implement\" \n";
- rule += " taskWorkDef \"WorkDef_Team_Default\" \n";
- rule += " onEvent CreateWorkflow \n} \n";
- return rule;
- }
-
-}
diff --git a/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/util/DbInitTest.java b/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/util/DbInitTest.java
index b24b439bb7..9e71562f02 100644
--- a/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/util/DbInitTest.java
+++ b/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/util/DbInitTest.java
@@ -43,8 +43,6 @@ public class DbInitTest {
@org.junit.Test
public void testDbInit() throws Exception {
- System.out.println("\nBegin database initialization...");
-
List<String> protocols = ClientSessionManager.getAuthenticationProtocols();
Assert.assertTrue("Application Server must be running." + protocols, protocols.contains("demo"));
@@ -66,8 +64,7 @@ public class DbInitTest {
ClientSessionManager.releaseSession();
ClientSessionManager.getSession();
UserManager.releaseUser();
- AtsClientService.getConfigEndpoint().clearCaches();
- AtsClientService.get().getUserService().reloadCache();
+ AtsClientService.get().clearCaches();
if (UserManager.getUser().getUserId().equals("bootstrap")) {
throw new OseeStateException("Should not be bootstrap user here");
diff --git a/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/config/AtsBulkLoad.java b/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/config/AtsBulkLoad.java
index 6d61235027..1aa4bcddae 100644
--- a/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/config/AtsBulkLoad.java
+++ b/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/config/AtsBulkLoad.java
@@ -57,7 +57,7 @@ public class AtsBulkLoad {
if (pend) {
AtsClientService.get().reloadAllCaches(pend);
} else {
- AtsClientService.get().invalidateAllCaches();
+ AtsClientService.get().clearCaches();
}
}
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 e1a8eb1762..e833d601ca 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
@@ -250,9 +250,17 @@ public class AtsClientImpl extends AtsCoreServiceImpl implements IAtsClient {
}
@Override
- public void invalidateAllCaches() {
- super.invalidateAllCaches();
- invalidateWorkDefinitionCache();
+ public void clearCaches() {
+ super.clearCaches();
+
+ // clear server config cache
+ AtsClientService.getConfigEndpoint().clearCaches();
+
+ // clear client config cache (read from server)
+ clearConfigurationsCaches();
+ getWorkDefinitionService().clearCaches();
+ getUserService().reloadCache();
+
if (goalMembersCache != null) {
goalMembersCache.invalidate();
}
@@ -518,4 +526,9 @@ public class AtsClientImpl extends AtsCoreServiceImpl implements IAtsClient {
return getConfigurations().getWorkDefinitionsData();
}
+ @Override
+ public void clearConfigurationsCaches() {
+ configProvider.clearConfigurationsCaches();
+ }
+
}
diff --git a/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/workdef/AtsCore_WorkDef_JT_Suite.java b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/workdef/AtsCore_WorkDef_JT_Suite.java
index 609cd079ba..2c4639e706 100644
--- a/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/workdef/AtsCore_WorkDef_JT_Suite.java
+++ b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/workdef/AtsCore_WorkDef_JT_Suite.java
@@ -16,6 +16,7 @@ import org.junit.runners.Suite;
@RunWith(Suite.class)
@Suite.SuiteClasses({
AtsWorkDefinitionServiceImplTest.class,
+ AtsWorkDefinitionServiceImplRulesTest.class,
WorkDefinitionSheetTest.class,
StateEventTypeTest.class,
StateColorTest.class,
diff --git a/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/workdef/AtsWorkDefinitionServiceImplRulesTest.java b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/workdef/AtsWorkDefinitionServiceImplRulesTest.java
new file mode 100644
index 0000000000..a86770b83e
--- /dev/null
+++ b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/workdef/AtsWorkDefinitionServiceImplRulesTest.java
@@ -0,0 +1,115 @@
+/*******************************************************************************
+ * 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.workdef;
+
+import static org.mockito.Mockito.when;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import org.eclipse.osee.ats.api.IAtsServices;
+import org.eclipse.osee.ats.api.data.AtsAttributeTypes;
+import org.eclipse.osee.ats.api.review.IAtsAbstractReview;
+import org.eclipse.osee.ats.api.workdef.IAtsRuleDefinition;
+import org.eclipse.osee.ats.api.workdef.IAtsWorkDefinitionDslService;
+import org.eclipse.osee.ats.api.workdef.IAtsWorkDefinitionStringProvider;
+import org.eclipse.osee.ats.api.workdef.IAttributeResolver;
+import org.eclipse.osee.ats.api.workdef.NullRuleDefinition;
+import org.eclipse.osee.ats.api.workdef.model.RuleDefinitionOption;
+import org.eclipse.osee.ats.api.workflow.IAtsTeamWorkflow;
+import org.eclipse.osee.ats.core.config.TeamDefinition;
+import org.eclipse.osee.framework.core.data.ArtifactToken;
+import org.eclipse.osee.logger.Log;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+/**
+ * Test case for {@link AtsWorkDefinitionServiceImpl} for Rules
+ *
+ * @author Donald G. Dunne
+ */
+public class AtsWorkDefinitionServiceImplRulesTest {
+
+ // @formatter:off
+ @Mock AtsWorkDefinitionStoreService workDefinitionStore;
+ @Mock IAtsWorkDefinitionDslService workDefinitionDslService;
+ @Mock IAtsServices services;
+ @Mock IAtsWorkDefinitionStringProvider workDefinitionStringProvider;
+ @Mock IAtsRuleDefinition ruleDef1;
+ @Mock IAtsRuleDefinition ruleDef2;
+ @Mock IAtsTeamWorkflow teamWf;
+ @Mock ArtifactToken teamWfArt;
+ @Mock ArtifactToken teamDefArt;
+ @Mock IAtsAbstractReview review;
+ @Mock IAttributeResolver attrResolver;
+ @Mock Log logger;
+
+ AtsWorkDefinitionServiceImpl workDefService;
+
+ // @formatter:on
+
+ @Before
+ public void setup() throws Exception {
+ MockitoAnnotations.initMocks(this);
+
+ when(workDefinitionStore.loadRuleDefinitionString()).thenReturn("");
+ when(workDefinitionDslService.getRuleDefinitions("")).thenReturn(new ArrayList<IAtsRuleDefinition>());
+
+ workDefService = new AtsWorkDefinitionServiceImpl(services, workDefinitionStore, workDefinitionStringProvider,
+ workDefinitionDslService, null);
+
+ when(workDefinitionDslService.getRuleDefinitions("")).thenReturn(Arrays.asList(ruleDef1, ruleDef2));
+ when(ruleDef1.getName()).thenReturn("ruleDef1");
+ when(ruleDef2.getName()).thenReturn("ruleDef2");
+ }
+
+ @Test
+ public void getRuleDefinitionkByName() {
+
+ IAtsRuleDefinition ruleDefinition = workDefService.getRuleDefinition("asdf");
+ Assert.assertTrue(ruleDefinition instanceof NullRuleDefinition);
+
+ IAtsRuleDefinition ruleDefinition2 = workDefService.getRuleDefinition("ruleDef1");
+ Assert.assertNotNull(ruleDefinition2);
+
+ ruleDefinition = workDefService.getRuleDefinition("asdf");
+ Assert.assertTrue(ruleDefinition instanceof NullRuleDefinition);
+ }
+
+ @Test
+ public void getAllRuleDefinitions() {
+ Collection<IAtsRuleDefinition> ruleDefs = workDefService.getAllRuleDefinitions();
+ Assert.assertEquals(2, ruleDefs.size());
+ }
+
+ @Test
+ public void teamDefHasRule() {
+ when(review.getParentTeamWorkflow()).thenReturn(teamWf);
+ TeamDefinition teamDef = new TeamDefinition(logger, services, teamDefArt);
+ when(teamWf.getTeamDefinition()).thenReturn(teamDef);
+ when(services.getAttributeResolver()).thenReturn(attrResolver);
+ when(attrResolver.getAttributeValues(teamDefArt, AtsAttributeTypes.RuleDefinition)).thenReturn(
+ Arrays.asList(RuleDefinitionOption.AllowPrivilegedEditToTeamMember.name(),
+ RuleDefinitionOption.AllowPrivilegedEditToTeamMemberAndOriginator.name()));
+
+ boolean teamDefHasRule = workDefService.teamDefHasRule(teamWf, RuleDefinitionOption.AllowEditToAll);
+ Assert.assertFalse(teamDefHasRule);
+
+ teamDefHasRule = workDefService.teamDefHasRule(teamWf, RuleDefinitionOption.AllowPrivilegedEditToTeamMember);
+ Assert.assertTrue(teamDefHasRule);
+
+ teamDefHasRule = workDefService.teamDefHasRule(review, RuleDefinitionOption.AllowPrivilegedEditToTeamMember);
+ Assert.assertTrue(teamDefHasRule);
+ }
+
+}
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 0af470ff4a..b26b596fbb 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
@@ -190,12 +190,8 @@ public abstract class AtsCoreServiceImpl implements IAtsServices {
}
@Override
- public void invalidateAllCaches() {
+ public void clearCaches() {
atsCache.invalidate();
- }
-
- @Override
- public void invalidateWorkDefinitionCache() {
workDefinitionService.clearCaches();
}
@@ -368,11 +364,6 @@ public abstract class AtsCoreServiceImpl implements IAtsServices {
}
@Override
- public void clearConfigurationsCaches() {
- configProvider.clearConfigurationsCaches();
- }
-
- @Override
public ITeamWorkflowProvidersLazy getTeamWorkflowProviders() {
return teamWorkflowProvidersLazy;
}
diff --git a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/workdef/AtsWorkDefinitionServiceImpl.java b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/workdef/AtsWorkDefinitionServiceImpl.java
index 540f61bfd5..b5780f3d93 100644
--- a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/workdef/AtsWorkDefinitionServiceImpl.java
+++ b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/workdef/AtsWorkDefinitionServiceImpl.java
@@ -102,6 +102,7 @@ public class AtsWorkDefinitionServiceImpl implements IAtsWorkDefinitionService {
public void clearCaches() {
workDefIdToWorkDef.invalidateAll();
workItemToWorkDef.invalidateAll();
+ ruleDefinitionCache.invalidateAll();
}
@Override
@@ -578,8 +579,8 @@ public class AtsWorkDefinitionServiceImpl implements IAtsWorkDefinitionService {
try {
if (workItem instanceof IAtsTeamWorkflow) {
teamWf = (IAtsTeamWorkflow) workItem;
- } else if (this instanceof IAtsAbstractReview) {
- teamWf = ((IAtsAbstractReview) this).getParentTeamWorkflow();
+ } else if (workItem instanceof IAtsAbstractReview) {
+ teamWf = ((IAtsAbstractReview) workItem).getParentTeamWorkflow();
}
if (teamWf != null) {
hasRule = teamWf.getTeamDefinition().hasRule(option.name());
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 260398a564..3596fc8625 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
@@ -451,4 +451,12 @@ public class AtsServerImpl extends AtsCoreServiceImpl implements IAtsServer {
public List<WorkDefData> getWorkDefinitionsData() {
return workDefinitionStore.getWorkDefinitionsData();
}
+
+ @Override
+ public void clearCaches() {
+ super.clearCaches();
+
+ // clear client config cache (read from server)
+ clearConfigurationsCaches();
+ }
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/config/AtsConfigOperation.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/config/AtsConfigOperation.java
index 01c5c39d3c..366180c0c4 100644
--- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/config/AtsConfigOperation.java
+++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/config/AtsConfigOperation.java
@@ -38,6 +38,7 @@ import org.eclipse.osee.ats.util.AtsUtil;
import org.eclipse.osee.ats.workdef.AtsWorkDefinitionSheetProviders;
import org.eclipse.osee.ats.workdef.provider.AtsWorkDefinitionImporter;
import org.eclipse.osee.framework.core.data.ArtifactToken;
+import org.eclipse.osee.framework.core.data.TransactionId;
import org.eclipse.osee.framework.core.enums.CoreRelationTypes;
import org.eclipse.osee.framework.core.enums.PresentationType;
import org.eclipse.osee.framework.core.exception.OseeWrappedException;
@@ -45,6 +46,7 @@ import org.eclipse.osee.framework.core.operation.AbstractOperation;
import org.eclipse.osee.framework.core.util.result.XResultData;
import org.eclipse.osee.framework.jdk.core.type.OseeArgumentException;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
+import org.eclipse.osee.framework.jdk.core.type.OseeStateException;
import org.eclipse.osee.framework.logging.OseeLevel;
import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.osee.framework.plugin.core.util.Jobs;
@@ -69,7 +71,7 @@ public class AtsConfigOperation extends AbstractOperation {
private final String teamDefName;
private final Collection<String> versionNames;
private final Collection<String> actionableItemsNames;
- private IAtsTeamDefinition teamDefinition;
+ private IAtsTeamDefinition teamDef;
private Collection<IAtsActionableItem> actionableItems;
private IAtsWorkDefinition workDefinition = null;
private ArtifactToken teamDefToken = null;
@@ -116,16 +118,21 @@ public class AtsConfigOperation extends AbstractOperation {
checkWorkItemNamespaceUnique();
monitor.worked(calculateWork(0.10));
+ XResultData resultData = new XResultData();
+ this.workDefinition = createWorkflowDefinition(resultData);
+ if (resultData.isErrors()) {
+ throw new OseeStateException("Error created new Work Definition for Team Def %s", teamDef.toStringWithId());
+ }
+
IAtsChangeSet changes = AtsClientService.get().createChangeSet("Configure ATS for Default Team");
- teamDefinition = createTeamDefinition(changes, AtsClientService.get());
+ teamDef = createTeamDefinition(changes, AtsClientService.get());
+ // Relate new team def to workflow artifact
+ changes.setSoleAttributeValue(teamDef, AtsAttributeTypes.WorkflowDefinition, workDefinition.getName());
- actionableItems = createActionableItems(changes, teamDefinition, AtsClientService.get());
+ actionableItems = createActionableItems(changes, teamDef, AtsClientService.get());
- createVersions(changes, teamDefinition);
-
- XResultData resultData = new XResultData();
- this.workDefinition = createWorkflow(changes, resultData, teamDefinition);
+ createVersions(changes, teamDef);
changes.execute();
monitor.worked(calculateWork(0.30));
@@ -136,8 +143,8 @@ public class AtsConfigOperation extends AbstractOperation {
if (teamDefToken == null) {
teamDef = AtsClientService.get().createTeamDefinition(teamDefName, changes, services);
} else {
- teamDef = AtsClientService.get().createTeamDefinition(teamDefToken.getName(), teamDefToken.getId(),
- changes, services);
+ teamDef = AtsClientService.get().createTeamDefinition(teamDefToken.getName(), teamDefToken.getId(), changes,
+ services);
}
changes.relate(TeamDefinitions.getTopTeamDefinition(AtsClientService.get().getQueryService()),
AtsRelationTypes.TeamMember_Member, AtsClientService.get().getUserService().getCurrentUser());
@@ -190,32 +197,34 @@ public class AtsConfigOperation extends AbstractOperation {
}
}
- private IAtsWorkDefinition createWorkflow(IAtsChangeSet changes, XResultData resultData, IAtsTeamDefinition teamDef) throws OseeCoreException {
+ private IAtsWorkDefinition createWorkflowDefinition(XResultData resultData) throws OseeCoreException {
IAtsWorkDefinition workDef = AtsClientService.get().getWorkDefinitionService().getWorkDefinition(name);
// If can't be found, create a new one
if (workDef == null) {
- IAtsChangeSet changes2 = AtsClientService.get().getStoreService().createAtsChangeSet("Create Work Definition",
- AtsClientService.get().getUserService().getCurrentUser());
- workDef = generateDefaultWorkflow(name, resultData, changes2, teamDef);
+ IAtsChangeSet changes = AtsClientService.get().getStoreService().createAtsChangeSet(
+ "Create Work Definition - " + name, AtsClientService.get().getUserService().getCurrentUser());
+ workDef = generateDefaultWorkflow(name, resultData, changes);
+ Artifact workDefArt = null;
try {
String workDefXml = AtsClientService.get().getWorkDefinitionService().getStorageString(workDef, resultData);
- Artifact workDefArt = AtsWorkDefinitionImporter.get().importWorkDefinitionToDb(workDefXml,
- workDef.getName(), name, null, resultData, changes2);
+ workDefArt = AtsWorkDefinitionImporter.get().importWorkDefinitionToDb(workDefXml, workDef.getName(), name,
+ null, resultData, changes);
Artifact folder = AtsUtilClient.getFromToken(AtsArtifactToken.WorkDefinitionsFolder);
folder.addChild(workDefArt);
- changes2.add(folder);
+ changes.add(folder);
} catch (Exception ex) {
throw new OseeWrappedException(ex);
}
- changes2.executeIfNeeded();
+ TransactionId transactionId = changes.execute();
+ if (transactionId == null || !workDefArt.isInDb()) {
+ throw new OseeStateException("Work Def didn't persist");
+ }
AtsClientService.get().getWorkDefinitionService().addWorkDefinition(workDef);
}
- // Relate new team def to workflow artifact
- changes.setSoleAttributeValue(teamDef, AtsAttributeTypes.WorkflowDefinition, workDef.getName());
return workDef;
}
- private IAtsWorkDefinition generateDefaultWorkflow(String name, XResultData resultData, IAtsChangeSet changes, IAtsTeamDefinition teamDef) throws OseeCoreException {
+ private IAtsWorkDefinition generateDefaultWorkflow(String name, XResultData resultData, IAtsChangeSet changes) throws OseeCoreException {
IAtsWorkDefinition defaultWorkDef = AtsClientService.get().getWorkDefinitionService().getWorkDefinition(
AtsWorkDefinitionSheetProviders.WORK_DEF_TEAM_DEFAULT);
@@ -253,7 +262,7 @@ public class AtsConfigOperation extends AbstractOperation {
}
public IAtsTeamDefinition getTeamDefinition() {
- return teamDefinition;
+ return teamDef;
}
}
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/config/AtsDatabaseConfig.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/config/AtsDatabaseConfig.java
index 73f459876b..79610d8587 100644
--- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/config/AtsDatabaseConfig.java
+++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/config/AtsDatabaseConfig.java
@@ -72,7 +72,9 @@ public class AtsDatabaseConfig implements IDbInitializationTask {
changes.setSoleAttributeValue(aia, AtsAttributeTypes.Actionable, false);
changes.execute();
+ AtsClientService.get().clearCaches();
AtsWorkDefinitionSheetProviders.initializeDatabase(new XResultData(false), "ats");
+ AtsClientService.get().clearCaches();
AtsGroup.AtsAdmin.getArtifact().persist(getClass().getSimpleName());
AtsGroup.AtsTempAdmin.getArtifact().persist(getClass().getSimpleName());
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/config/copy/CopyAtsConfigurationOperation.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/config/copy/CopyAtsConfigurationOperation.java
index 54d3a57755..a723434811 100644
--- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/config/copy/CopyAtsConfigurationOperation.java
+++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/config/copy/CopyAtsConfigurationOperation.java
@@ -220,7 +220,7 @@ public class CopyAtsConfigurationOperation extends AbstractOperation {
private void persistOrUndoChanges(IAtsChangeSet changes) throws OseeCoreException {
if (data.isPersistChanges()) {
changes.execute();
- AtsClientService.get().invalidateAllCaches();
+ AtsClientService.get().clearCaches();
} else {
resultData.log("\n\nCleanup of created / modified artifacts\n\n");
for (Artifact artifact : newArtifacts) {
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 5f9a15dd34..8788ee2f01 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
@@ -255,7 +255,6 @@ public final class AtsNavigateViewItems implements XNavigateViewItems, IXNavigat
new GenerateGuidUuidArtId(utilItems);
new XNavigateItemOperation(utilItems, FrameworkImage.ARTIFACT_MASS_EDITOR, MassEditDirtyArtifactOperation.NAME,
new MassEditDirtyArtifactOperation());
- new ClearAtsWorkDefinitionCache(utilItems);
new ClearAtsConfigCache(utilItems);
new XNavigateItemBlam(utilItems, new MoveTeamWorkflowsBlam(), AtsImage.TEAM_WORKFLOW);
new AtsConfigResultsEditorNavigateItem(utilItems);
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/navigate/ClearAtsConfigCache.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/navigate/ClearAtsConfigCache.java
index f41f5f6dd6..b2776f21c1 100644
--- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/navigate/ClearAtsConfigCache.java
+++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/navigate/ClearAtsConfigCache.java
@@ -29,7 +29,7 @@ public class ClearAtsConfigCache extends XNavigateItemAction {
@Override
public void run(TableLoadOption... tableLoadOptions) {
- AtsClientService.get().invalidateAllCaches();
+ AtsClientService.get().clearCaches();
}
}
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/navigate/ClearAtsWorkDefinitionCache.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/navigate/ClearAtsWorkDefinitionCache.java
deleted file mode 100644
index 1e454b24ea..0000000000
--- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/navigate/ClearAtsWorkDefinitionCache.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * 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.navigate;
-
-import org.eclipse.osee.ats.internal.Activator;
-import org.eclipse.osee.ats.internal.AtsClientService;
-import org.eclipse.osee.framework.jdk.core.type.OseeStateException;
-import org.eclipse.osee.framework.logging.OseeLevel;
-import org.eclipse.osee.framework.logging.OseeLog;
-import org.eclipse.osee.framework.ui.plugin.util.AWorkbench;
-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.FrameworkImage;
-
-/**
- * @author Donald G. Dunne
- */
-public class ClearAtsWorkDefinitionCache extends XNavigateItemAction {
-
- public ClearAtsWorkDefinitionCache(XNavigateItem parent) {
- super(parent, "Clear ATS WorkDefinition Cache", FrameworkImage.GEAR);
- }
-
- @Override
- public void run(TableLoadOption... tableLoadOptions) {
- try {
- AtsClientService.get().getWorkDefinitionService().clearCaches();
- } catch (OseeStateException ex) {
- OseeLog.log(Activator.class, OseeLevel.SEVERE_POPUP, ex);
- }
- AWorkbench.popup("Completed");
- }
-}

Back to the top