Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordonald.g.dunne2016-05-11 15:09:07 +0000
committerAngel Avila2016-05-11 15:09:07 +0000
commit4b3627fc33af06223f0eb43a22bac7dff5232a4a (patch)
treec84532889ddb6a843329cfcb1aac776b9dc4f851
parent51d7c6fed275a2f60b7bbd43ff6de6283b3eb64a (diff)
downloadorg.eclipse.osee-4b3627fc33af06223f0eb43a22bac7dff5232a4a.tar.gz
org.eclipse.osee-4b3627fc33af06223f0eb43a22bac7dff5232a4a.tar.xz
org.eclipse.osee-4b3627fc33af06223f0eb43a22bac7dff5232a4a.zip
feature[ats_UFM31]: Provide XWidget validators via OSGI
-rw-r--r--plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/IAtsServices.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.api/src/org/eclipse/osee/ats/api/workflow/transition/IAtsXWidgetValidator.java (renamed from plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/validator/IAtsXWidgetValidator.java)2
-rw-r--r--plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/workflow/transition/IAtsXWidgetValidatorProvider.java (renamed from plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/validator/AtsXWidgetValidatorProvider.java)4
-rw-r--r--plugins/org.eclipse.osee.ats.core.client/OSGI-INF/ats.client.service.xml1
-rw-r--r--plugins/org.eclipse.osee.ats.core.client/OSGI-INF/ats.xwidget.validator.provider.client.service.xml7
-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.java10
-rw-r--r--plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/internal/AtsStoreService.java6
-rw-r--r--plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/validator/AtsOperationalImpactWithWorkaroundValidator.java2
-rw-r--r--plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/validator/AtsXWidgetValidateManagerClient.java48
-rw-r--r--plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/validator/AtsXWidgetValidateManagerTest.java35
-rw-r--r--plugins/org.eclipse.osee.ats.core/OSGI-INF/ats.xwidget.validator.provider.ref.xml6
-rw-r--r--plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/util/ArtifactValueProvider.java100
-rw-r--r--plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/util/AtsCoreServiceImpl.java7
-rw-r--r--plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/validator/AtsCoreXWidgetValidatorProvider.java4
-rw-r--r--plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/validator/AtsXWidgetValidateManager.java46
-rw-r--r--plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/validator/AtsXWidgetValidator.java1
-rw-r--r--plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/workflow/AtsWorkItemServiceImpl.java3
-rw-r--r--plugins/org.eclipse.osee.ats.rest/OSGI-INF/ats.server.service.xml1
-rw-r--r--plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/AtsServerImpl.java12
-rw-r--r--plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/util/AtsStoreServiceImpl.java5
22 files changed, 216 insertions, 96 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 66baef8521..1ea276c832 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
@@ -29,11 +29,10 @@ import org.eclipse.osee.ats.api.util.IAtsStoreService;
import org.eclipse.osee.ats.api.util.IAtsUtilService;
import org.eclipse.osee.ats.api.util.ISequenceProvider;
import org.eclipse.osee.ats.api.version.IAtsVersionService;
-import org.eclipse.osee.ats.api.workdef.IAtsStateDefinition;
+import org.eclipse.osee.ats.api.workdef.IAtsWorkDefinitionAdmin;
import org.eclipse.osee.ats.api.workdef.IAtsWorkDefinitionService;
import org.eclipse.osee.ats.api.workdef.IAttributeResolver;
import org.eclipse.osee.ats.api.workdef.IRelationResolver;
-import org.eclipse.osee.ats.api.workdef.WidgetResult;
import org.eclipse.osee.ats.api.workflow.IAtsAction;
import org.eclipse.osee.ats.api.workflow.IAtsActionFactory;
import org.eclipse.osee.ats.api.workflow.IAtsBranchService;
@@ -96,8 +95,6 @@ public interface IAtsServices {
Collection<ITransitionListener> getTransitionListeners();
- Collection<WidgetResult> validateWidgetTransition(IAtsWorkItem workItem, IAtsStateDefinition toStateDef);
-
void clearImplementersCache(IAtsWorkItem workItem);
IArtifactResolver getArtifactResolver();
@@ -121,6 +118,8 @@ public interface IAtsServices {
IAtsImplementerService getImplementerService();
IAtsColumnService getColumnService();
+
+ IAtsWorkDefinitionAdmin getWorkDefinitionAdmin();
IAtsUtilService getUtilService();
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 f660c1d042..226267e5d8 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
@@ -48,5 +48,7 @@ public interface IAtsStoreService {
IAttributeType getAttributeType(String attrTypeName);
IArtifactType getArtifactType(ArtifactId artifact);
+
+ boolean isDateType(IAttributeType attributeType);
}
diff --git a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/validator/IAtsXWidgetValidator.java b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/workflow/transition/IAtsXWidgetValidator.java
index 5834b65a83..9174657a48 100644
--- a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/validator/IAtsXWidgetValidator.java
+++ b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/workflow/transition/IAtsXWidgetValidator.java
@@ -8,7 +8,7 @@
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
-package org.eclipse.osee.ats.core.validator;
+package org.eclipse.osee.ats.api.workflow.transition;
import org.eclipse.osee.ats.api.IAtsServices;
import org.eclipse.osee.ats.api.util.IValueProvider;
diff --git a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/validator/AtsXWidgetValidatorProvider.java b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/workflow/transition/IAtsXWidgetValidatorProvider.java
index 7a3bffdc79..2a748bafcd 100644
--- a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/validator/AtsXWidgetValidatorProvider.java
+++ b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/workflow/transition/IAtsXWidgetValidatorProvider.java
@@ -8,14 +8,14 @@
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
-package org.eclipse.osee.ats.core.validator;
+package org.eclipse.osee.ats.api.workflow.transition;
import java.util.Collection;
/**
* @author Donald G. Dunne
*/
-public interface AtsXWidgetValidatorProvider {
+public interface IAtsXWidgetValidatorProvider {
public Collection<IAtsXWidgetValidator> getValidators();
}
diff --git a/plugins/org.eclipse.osee.ats.core.client/OSGI-INF/ats.client.service.xml b/plugins/org.eclipse.osee.ats.core.client/OSGI-INF/ats.client.service.xml
index 22e1ca6a83..7b76b18f13 100644
--- a/plugins/org.eclipse.osee.ats.core.client/OSGI-INF/ats.client.service.xml
+++ b/plugins/org.eclipse.osee.ats.core.client/OSGI-INF/ats.client.service.xml
@@ -5,6 +5,7 @@
<provide interface="org.eclipse.osee.ats.core.client.IAtsClient"/>
<provide interface="org.eclipse.osee.ats.core.config.IAtsConfigProvider"/>
<provide interface="org.eclipse.osee.ats.core.client.internal.IAtsWorkItemArtifactServiceProvider"/>
+ <provide interface="org.eclipse.osee.ats.api.IAtsServices"/>
</service>
<reference bind="setAtsWorkDefinitionService" cardinality="1..1" interface="org.eclipse.osee.ats.api.workdef.IAtsWorkDefinitionService" name="IAtsWorkDefinitionService" policy="static"/>
<reference bind="setJdbcService" cardinality="1..1" interface="org.eclipse.osee.jdbc.JdbcService" name="JdbcService" policy="static" target="(osgi.binding=skynet.jdbc.service)"/>
diff --git a/plugins/org.eclipse.osee.ats.core.client/OSGI-INF/ats.xwidget.validator.provider.client.service.xml b/plugins/org.eclipse.osee.ats.core.client/OSGI-INF/ats.xwidget.validator.provider.client.service.xml
new file mode 100644
index 0000000000..c1afac2a5f
--- /dev/null
+++ b/plugins/org.eclipse.osee.ats.core.client/OSGI-INF/ats.xwidget.validator.provider.client.service.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" immediate="true">
+ <implementation class="org.eclipse.osee.ats.core.client.validator.AtsXWidgetValidateManagerClient"/>
+ <service>
+ <provide interface="org.eclipse.osee.ats.api.workflow.transition.IAtsXWidgetValidatorProvider"/>
+ </service>
+</scr:component>
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 f2e9ccbdf9..a93b91f769 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
@@ -36,7 +36,6 @@ import org.eclipse.osee.ats.api.util.IAtsUtilService;
import org.eclipse.osee.ats.api.util.ISequenceProvider;
import org.eclipse.osee.ats.api.version.IAtsVersionServiceProvider;
import org.eclipse.osee.ats.api.version.IVersionFactory;
-import org.eclipse.osee.ats.api.workdef.IAtsWorkDefinitionAdmin;
import org.eclipse.osee.ats.api.workdef.IAttributeResolverProvider;
import org.eclipse.osee.ats.api.workflow.IAtsActionFactory;
import org.eclipse.osee.ats.api.workflow.IAtsBranchService;
@@ -105,8 +104,6 @@ public interface IAtsClient extends IAtsServices, IAtsNotifier, IAttributeResolv
void invalidateAllCaches();
- IAtsWorkDefinitionAdmin getWorkDefinitionAdmin() throws OseeStateException;
-
@Override
IAtsUserService getUserService() throws OseeStateException;
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 7746e93c41..3486550129 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
@@ -52,12 +52,10 @@ import org.eclipse.osee.ats.api.util.IAtsUtilService;
import org.eclipse.osee.ats.api.util.ISequenceProvider;
import org.eclipse.osee.ats.api.version.IAtsVersion;
import org.eclipse.osee.ats.api.version.IVersionFactory;
-import org.eclipse.osee.ats.api.workdef.IAtsStateDefinition;
import org.eclipse.osee.ats.api.workdef.IAtsWorkDefinitionAdmin;
import org.eclipse.osee.ats.api.workdef.IAtsWorkDefinitionService;
import org.eclipse.osee.ats.api.workdef.IAttributeResolver;
import org.eclipse.osee.ats.api.workdef.IRelationResolver;
-import org.eclipse.osee.ats.api.workdef.WidgetResult;
import org.eclipse.osee.ats.api.workflow.IAtsAction;
import org.eclipse.osee.ats.api.workflow.IAtsActionFactory;
import org.eclipse.osee.ats.api.workflow.IAtsBranchService;
@@ -100,7 +98,6 @@ import org.eclipse.osee.ats.core.client.task.AtsTaskService;
import org.eclipse.osee.ats.core.client.team.AtsTeamDefinitionService;
import org.eclipse.osee.ats.core.client.util.AtsUtilClient;
import org.eclipse.osee.ats.core.client.util.IArtifactMembersCache;
-import org.eclipse.osee.ats.core.client.validator.AtsXWidgetValidateManagerClient;
import org.eclipse.osee.ats.core.client.workflow.AbstractWorkflowArtifact;
import org.eclipse.osee.ats.core.client.workflow.ChangeTypeUtil;
import org.eclipse.osee.ats.core.client.workflow.transition.TransitionListeners;
@@ -151,7 +148,6 @@ public class AtsClientImpl extends AtsCoreServiceImpl implements IAtsClient {
private IAtsClientVersionService versionService;
private IAtsArtifactStore artifactStore;
private CacheProvider<AtsArtifactConfigCache> configCacheProvider;
- private IAtsWorkDefinitionAdmin workDefAdmin;
private IActionableItemFactory actionableItemFactory;
private ITeamDefinitionFactory teamDefFactory;
private IVersionFactory versionFactory;
@@ -799,12 +795,6 @@ public class AtsClientImpl extends AtsCoreServiceImpl implements IAtsClient {
}
@Override
- public Collection<WidgetResult> validateWidgetTransition(IAtsWorkItem workItem, IAtsStateDefinition toStateDef) {
- return AtsXWidgetValidateManagerClient.instance.validateTransition((AbstractWorkflowArtifact) workItem,
- toStateDef);
- }
-
- @Override
public void clearImplementersCache(IAtsWorkItem workItem) {
((AbstractWorkflowArtifact) workItem).clearImplementersCache();
}
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 7f89bb07b3..3fb318190d 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
@@ -36,6 +36,7 @@ import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
import org.eclipse.osee.framework.skynet.core.artifact.ArtifactTypeManager;
import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
import org.eclipse.osee.framework.skynet.core.attribute.AttributeTypeManager;
+import org.eclipse.osee.framework.skynet.core.attribute.DateAttribute;
/**
* @author Donald G. Dunne
@@ -153,5 +154,10 @@ public class AtsStoreService implements IAtsStoreService {
public IArtifactType getArtifactType(ArtifactId artifact) {
return ((Artifact) artifact).getArtifactType();
}
+
+ @Override
+ public boolean isDateType(IAttributeType attributeType) {
+ return AttributeTypeManager.isBaseTypeCompatible(DateAttribute.class, attributeType);
+ }
}
diff --git a/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/validator/AtsOperationalImpactWithWorkaroundValidator.java b/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/validator/AtsOperationalImpactWithWorkaroundValidator.java
index bc4a8a604e..589d1d3848 100644
--- a/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/validator/AtsOperationalImpactWithWorkaroundValidator.java
+++ b/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/validator/AtsOperationalImpactWithWorkaroundValidator.java
@@ -17,8 +17,8 @@ import org.eclipse.osee.ats.api.workdef.IAtsStateDefinition;
import org.eclipse.osee.ats.api.workdef.IAtsWidgetDefinition;
import org.eclipse.osee.ats.api.workdef.WidgetResult;
import org.eclipse.osee.ats.api.workdef.WidgetStatus;
+import org.eclipse.osee.ats.api.workflow.transition.IAtsXWidgetValidator;
import org.eclipse.osee.ats.core.client.team.TeamWorkFlowArtifact;
-import org.eclipse.osee.ats.core.validator.IAtsXWidgetValidator;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.util.Strings;
diff --git a/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/validator/AtsXWidgetValidateManagerClient.java b/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/validator/AtsXWidgetValidateManagerClient.java
index 716b3e2247..f574a750c1 100644
--- a/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/validator/AtsXWidgetValidateManagerClient.java
+++ b/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/validator/AtsXWidgetValidateManagerClient.java
@@ -13,31 +13,17 @@ package org.eclipse.osee.ats.core.client.validator;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
-import org.eclipse.osee.ats.api.workdef.IAtsStateDefinition;
-import org.eclipse.osee.ats.api.workdef.IAtsWidgetDefinition;
-import org.eclipse.osee.ats.api.workdef.WidgetResult;
-import org.eclipse.osee.ats.core.client.internal.Activator;
-import org.eclipse.osee.ats.core.client.internal.AtsClientService;
+import org.eclipse.osee.ats.api.workflow.transition.IAtsXWidgetValidator;
+import org.eclipse.osee.ats.api.workflow.transition.IAtsXWidgetValidatorProvider;
import org.eclipse.osee.ats.core.client.review.defect.AtsXDefectValidator;
import org.eclipse.osee.ats.core.client.review.role.AtsXUserRoleValidator;
-import org.eclipse.osee.ats.core.client.workflow.AbstractWorkflowArtifact;
-import org.eclipse.osee.ats.core.validator.AtsCoreXWidgetValidatorProvider;
-import org.eclipse.osee.ats.core.validator.AtsXWidgetValidateManager;
-import org.eclipse.osee.ats.core.validator.AtsXWidgetValidatorProvider;
-import org.eclipse.osee.ats.core.validator.IAtsXWidgetValidator;
-import org.eclipse.osee.framework.jdk.core.type.OseeStateException;
-import org.eclipse.osee.framework.plugin.core.util.ExtensionDefinedObjects;
/**
* @author Donald G. Dunne
*/
-public class AtsXWidgetValidateManagerClient implements AtsXWidgetValidatorProvider {
- private static boolean loaded = false;
- private static final String EXTENSION_ELEMENT = "AtsXWidgetValidator";
- private static final String EXTENSION_ID = Activator.PLUGIN_ID + "." + EXTENSION_ELEMENT;
- private static final String CLASS_NAME_ATTRIBUTE = "classname";
+public class AtsXWidgetValidateManagerClient implements IAtsXWidgetValidatorProvider {
+
private static List<IAtsXWidgetValidator> atsValidators;
- public static AtsXWidgetValidateManagerClient instance = new AtsXWidgetValidateManagerClient();
@Override
public Collection<IAtsXWidgetValidator> getValidators() {
@@ -49,34 +35,8 @@ public class AtsXWidgetValidateManagerClient implements AtsXWidgetValidatorProvi
atsValidators.add(new AtsXCommitManagerValidator());
atsValidators.add(new AtsOperationalImpactValidator());
atsValidators.add(new AtsOperationalImpactWithWorkaroundValidator());
-
- ExtensionDefinedObjects<IAtsXWidgetValidator> validators = new ExtensionDefinedObjects<IAtsXWidgetValidator>(
- EXTENSION_ID, EXTENSION_ELEMENT, CLASS_NAME_ATTRIBUTE, true);
- for (IAtsXWidgetValidator validator : validators.getObjects()) {
- atsValidators.add(validator);
- }
}
return atsValidators;
}
- private void ensureLoaded() {
- if (!loaded) {
- loaded = true;
- AtsXWidgetValidateManager.instance.add(instance);
- AtsXWidgetValidateManager.instance.add(new AtsCoreXWidgetValidatorProvider());
- }
- }
-
- public Collection<WidgetResult> validateTransition(AbstractWorkflowArtifact awa, IAtsStateDefinition toStateDef) throws OseeStateException {
- ensureLoaded();
- List<WidgetResult> results = new ArrayList<>();
- for (IAtsWidgetDefinition widgetDef : AtsClientService.get().getWorkDefinitionAdmin().getWidgetsFromLayoutItems(
- awa.getStateDefinition())) {
- ArtifactValueProvider provider = new ArtifactValueProvider(awa, widgetDef);
- AtsXWidgetValidateManager.instance.validateTransition(results, provider, widgetDef, awa.getStateDefinition(),
- toStateDef, AtsClientService.get().getServices());
- }
- return results;
- }
-
}
diff --git a/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/validator/AtsXWidgetValidateManagerTest.java b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/validator/AtsXWidgetValidateManagerTest.java
index 4430cb3584..f2ca69db67 100644
--- a/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/validator/AtsXWidgetValidateManagerTest.java
+++ b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/validator/AtsXWidgetValidateManagerTest.java
@@ -19,6 +19,8 @@ import org.eclipse.osee.ats.api.workdef.IAtsStateDefinition;
import org.eclipse.osee.ats.api.workdef.IAtsWidgetDefinition;
import org.eclipse.osee.ats.api.workdef.WidgetResult;
import org.eclipse.osee.ats.api.workdef.WidgetStatus;
+import org.eclipse.osee.ats.api.workflow.transition.IAtsXWidgetValidator;
+import org.eclipse.osee.ats.api.workflow.transition.IAtsXWidgetValidatorProvider;
import org.eclipse.osee.ats.mocks.MockWidgetDefinition;
import org.eclipse.osee.framework.jdk.core.type.OseeStateException;
import org.junit.Assert;
@@ -36,8 +38,8 @@ public class AtsXWidgetValidateManagerTest {
public void testValidateTransition_emptyValidators() {
List<WidgetResult> results = new LinkedList<>();
- AtsXWidgetValidateManager manager = new AtsXWidgetValidateManager();
- manager.validateTransition(results, ValidatorTestUtil.emptyValueProvider, null, null, null, atsServices);
+ AtsXWidgetValidateManager.validateTransition(results, ValidatorTestUtil.emptyValueProvider, null, null, null,
+ atsServices);
Assert.assertTrue(results.isEmpty());
}
@@ -46,9 +48,12 @@ public class AtsXWidgetValidateManagerTest {
List<WidgetResult> results = new LinkedList<>();
AtsXWidgetValidateManager manager = new AtsXWidgetValidateManager();
- manager.add(new TestValidatorProvider(new AtsValidator()));
- manager.validateTransition(results, ValidatorTestUtil.emptyValueProvider, null, null, null, atsServices);
+ TestValidatorProvider provider = new TestValidatorProvider(new AtsValidator());
+ manager.add(provider);
+ AtsXWidgetValidateManager.validateTransition(results, ValidatorTestUtil.emptyValueProvider, null, null, null,
+ atsServices);
Assert.assertTrue(results.isEmpty());
+ manager.remove(provider);
}
@Test
@@ -56,9 +61,12 @@ public class AtsXWidgetValidateManagerTest {
List<WidgetResult> results = new LinkedList<>();
AtsXWidgetValidateManager manager = new AtsXWidgetValidateManager();
- manager.add(new TestValidatorProvider(new AtsErrorValidator()));
- manager.validateTransition(results, ValidatorTestUtil.emptyValueProvider, null, null, null, atsServices);
+ TestValidatorProvider provider = new TestValidatorProvider(new AtsErrorValidator());
+ manager.add(provider);
+ AtsXWidgetValidateManager.validateTransition(results, ValidatorTestUtil.emptyValueProvider, null, null, null,
+ atsServices);
Assert.assertFalse(results.isEmpty());
+ manager.remove(provider);
}
@Test
@@ -66,21 +74,18 @@ public class AtsXWidgetValidateManagerTest {
List<WidgetResult> results = new LinkedList<>();
AtsXWidgetValidateManager manager = new AtsXWidgetValidateManager();
- manager.add(new TestValidatorProvider(new AtsExceptoinValidator()));
+ TestValidatorProvider provider = new TestValidatorProvider(new AtsExceptoinValidator());
+ manager.add(provider);
MockWidgetDefinition widgetDef = new MockWidgetDefinition("Widget Name");
- manager.validateTransition(results, ValidatorTestUtil.emptyValueProvider, widgetDef, null, null, atsServices);
+ AtsXWidgetValidateManager.validateTransition(results, ValidatorTestUtil.emptyValueProvider, widgetDef, null, null,
+ atsServices);
Assert.assertFalse(results.isEmpty());
Assert.assertEquals(results.iterator().next().getStatus(), WidgetStatus.Exception);
Assert.assertEquals(
"Exception - Widget Name - Exception retriving validation for widget [AtsExceptoinValidator] Exception [problem]",
results.iterator().next().toString());
Assert.assertTrue(results.iterator().next().getException() instanceof OseeStateException);
- }
-
- @Test
- public void testAdd() {
- AtsXWidgetValidateManager manager = new AtsXWidgetValidateManager();
- manager.add(new TestValidatorProvider(new AtsValidator()));
+ manager.remove(provider);
}
private class AtsValidator implements IAtsXWidgetValidator {
@@ -108,7 +113,7 @@ public class AtsXWidgetValidateManagerTest {
}
- private class TestValidatorProvider implements AtsXWidgetValidatorProvider {
+ private class TestValidatorProvider implements IAtsXWidgetValidatorProvider {
private final LinkedList<IAtsXWidgetValidator> validators;
diff --git a/plugins/org.eclipse.osee.ats.core/OSGI-INF/ats.xwidget.validator.provider.ref.xml b/plugins/org.eclipse.osee.ats.core/OSGI-INF/ats.xwidget.validator.provider.ref.xml
new file mode 100644
index 0000000000..b21519d250
--- /dev/null
+++ b/plugins/org.eclipse.osee.ats.core/OSGI-INF/ats.xwidget.validator.provider.ref.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0">
+ <implementation class="org.eclipse.osee.ats.core.validator.AtsXWidgetValidateManager"/>
+ <reference bind="setAtsServices" cardinality="1..1" interface="org.eclipse.osee.ats.api.IAtsServices" name="IAtsServices" policy="static"/>
+ <reference bind="addWidgetValidatorProvider" cardinality="0..n" interface="org.eclipse.osee.ats.api.workflow.transition.IAtsXWidgetValidatorProvider" name="IAtsXWidgetValidatorProvider" policy="static"/>
+</scr:component>
diff --git a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/util/ArtifactValueProvider.java b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/util/ArtifactValueProvider.java
new file mode 100644
index 0000000000..58e18097e0
--- /dev/null
+++ b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/util/ArtifactValueProvider.java
@@ -0,0 +1,100 @@
+/*******************************************************************************
+ * 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.util;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+import org.eclipse.osee.ats.api.IAtsServices;
+import org.eclipse.osee.ats.api.util.IValueProvider;
+import org.eclipse.osee.ats.api.workdef.IAtsWidgetDefinition;
+import org.eclipse.osee.framework.core.data.ArtifactId;
+import org.eclipse.osee.framework.core.data.IAttributeType;
+import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
+import org.eclipse.osee.framework.jdk.core.util.Strings;
+
+/**
+ * @author Donald G. Dunne
+ */
+public class ArtifactValueProvider implements IValueProvider {
+
+ private final ArtifactId artifact;
+ private final String attributeTypeName;
+ private final IAtsServices services;
+
+ public ArtifactValueProvider(ArtifactId artifact, IAtsWidgetDefinition widgetDef, IAtsServices services) {
+ this.artifact = artifact;
+ this.services = services;
+ this.attributeTypeName = widgetDef.getAtrributeName();
+ }
+
+ public ArtifactValueProvider(ArtifactId artifact, IAttributeType attributeType, IAtsServices services) {
+ this.artifact = artifact;
+ this.services = services;
+ this.attributeTypeName = attributeType.getName();
+ }
+
+ @Override
+ public boolean isEmpty() throws OseeCoreException {
+ IAttributeType attributeType = getAtributeType();
+ if (attributeType != null) {
+ return services.getAttributeResolver().getAttributeCount(artifact, attributeType) == 0;
+ }
+ return true;
+ }
+
+ @Override
+ public Collection<String> getValues() throws OseeCoreException {
+ IAttributeType attributeType = getAtributeType();
+ if (attributeType != null) {
+ return services.getAttributeResolver().getAttributesToStringList(artifact, attributeType);
+ }
+ return Collections.emptyList();
+ }
+
+ public IAttributeType getAtributeType() throws OseeCoreException {
+ if (Strings.isValid(attributeTypeName)) {
+ IAttributeType attrType = services.getStoreService().getAttributeType(attributeTypeName);
+ return attrType;
+ }
+ return null;
+ }
+
+ @Override
+ public String getName() {
+ return artifact.getName();
+ }
+
+ @Override
+ public Collection<Date> getDateValues() throws OseeCoreException {
+ IAttributeType attributeType = getAtributeType();
+ if (attributeType != null && services.getStoreService().isDateType(attributeType)) {
+ List<Date> dates = new ArrayList<>();
+ for (String attr : services.getAttributeResolver().getAttributesToStringList(artifact, attributeType)) {
+ dates.add(new Date(Long.valueOf(attr)));
+ }
+ return dates;
+ }
+ return Collections.emptyList();
+
+ }
+
+ public ArtifactId getArtifact() {
+ return artifact;
+ }
+
+ public Object getObject() {
+ return artifact;
+ }
+
+}
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 f63928ffa5..608e15b4c8 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
@@ -13,6 +13,7 @@ package org.eclipse.osee.ats.core.util;
import org.eclipse.osee.ats.api.IAtsObject;
import org.eclipse.osee.ats.api.IAtsServices;
import org.eclipse.osee.ats.api.data.AtsAttributeTypes;
+import org.eclipse.osee.ats.api.workdef.IAtsWorkDefinitionAdmin;
import org.eclipse.osee.ats.api.workdef.IAttributeResolver;
import org.eclipse.osee.framework.core.data.ArtifactId;
import org.eclipse.osee.framework.jdk.core.util.Conditions;
@@ -22,6 +23,8 @@ import org.eclipse.osee.framework.jdk.core.util.Conditions;
*/
public abstract class AtsCoreServiceImpl implements IAtsServices {
+ protected IAtsWorkDefinitionAdmin workDefAdmin;
+
@Override
public String getAtsId(ArtifactId artifact) {
return getAtsId(getAttributeResolver(), artifact);
@@ -45,4 +48,8 @@ public abstract class AtsCoreServiceImpl implements IAtsServices {
return toReturn;
}
+ public IAtsWorkDefinitionAdmin getWorkDefAdmin() {
+ return workDefAdmin;
+ }
+
}
diff --git a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/validator/AtsCoreXWidgetValidatorProvider.java b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/validator/AtsCoreXWidgetValidatorProvider.java
index 820423e31e..86316e1d8f 100644
--- a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/validator/AtsCoreXWidgetValidatorProvider.java
+++ b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/validator/AtsCoreXWidgetValidatorProvider.java
@@ -13,11 +13,13 @@ package org.eclipse.osee.ats.core.validator;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
+import org.eclipse.osee.ats.api.workflow.transition.IAtsXWidgetValidatorProvider;
+import org.eclipse.osee.ats.api.workflow.transition.IAtsXWidgetValidator;
/**
* @author Donald G. Dunne
*/
-public class AtsCoreXWidgetValidatorProvider implements AtsXWidgetValidatorProvider {
+public class AtsCoreXWidgetValidatorProvider implements IAtsXWidgetValidatorProvider {
private static List<IAtsXWidgetValidator> atsValidators;
public static AtsCoreXWidgetValidatorProvider instance = new AtsCoreXWidgetValidatorProvider();
diff --git a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/validator/AtsXWidgetValidateManager.java b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/validator/AtsXWidgetValidateManager.java
index da75b30dc6..1707efb317 100644
--- a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/validator/AtsXWidgetValidateManager.java
+++ b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/validator/AtsXWidgetValidateManager.java
@@ -10,27 +10,41 @@
*******************************************************************************/
package org.eclipse.osee.ats.core.validator;
+import java.util.ArrayList;
+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.util.IValueProvider;
import org.eclipse.osee.ats.api.workdef.IAtsStateDefinition;
import org.eclipse.osee.ats.api.workdef.IAtsWidgetDefinition;
import org.eclipse.osee.ats.api.workdef.WidgetResult;
import org.eclipse.osee.ats.api.workdef.WidgetStatus;
+import org.eclipse.osee.ats.api.workflow.transition.IAtsXWidgetValidator;
+import org.eclipse.osee.ats.api.workflow.transition.IAtsXWidgetValidatorProvider;
+import org.eclipse.osee.ats.core.util.ArtifactValueProvider;
+import org.eclipse.osee.framework.jdk.core.type.OseeStateException;
/**
* @author Donald G. Dunne
*/
public class AtsXWidgetValidateManager {
- public static AtsXWidgetValidateManager instance = new AtsXWidgetValidateManager();
- private final List<AtsXWidgetValidatorProvider> providers = new LinkedList<>();
- protected AtsXWidgetValidateManager() {
+ private static final List<IAtsXWidgetValidatorProvider> providers = new LinkedList<>();
+ private static IAtsServices services;
+
+ public void setAtsServices(IAtsServices services) {
+ AtsXWidgetValidateManager.services = services;
}
- public void validateTransition(List<WidgetResult> results, IValueProvider valueProvider, IAtsWidgetDefinition widgetDef, IAtsStateDefinition fromStateDef, IAtsStateDefinition toStateDef, IAtsServices atsServices) {
- for (AtsXWidgetValidatorProvider provider : providers) {
+ public void addWidgetValidatorProvider(IAtsXWidgetValidatorProvider provider) {
+ System.err.println("Adding provider " + provider);
+ providers.add(provider);
+ }
+
+ public static List<WidgetResult> validateTransition(List<WidgetResult> results, IValueProvider valueProvider, IAtsWidgetDefinition widgetDef, IAtsStateDefinition fromStateDef, IAtsStateDefinition toStateDef, IAtsServices atsServices) {
+ for (IAtsXWidgetValidatorProvider provider : providers) {
for (IAtsXWidgetValidator validator : provider.getValidators()) {
try {
WidgetResult status =
@@ -43,14 +57,32 @@ public class AtsXWidgetValidateManager {
String.format("Exception retriving validation for widget [%s] Exception [%s]",
validator.getClass().getSimpleName(), ex.getLocalizedMessage()),
ex));
- return;
}
}
}
+ return results;
+ }
+
+ public static Collection<WidgetResult> validateTransition(IAtsWorkItem workItem, IAtsStateDefinition toStateDef) {
+ List<WidgetResult> results = new ArrayList<>();
+ if (services == null) {
+ throw new OseeStateException("ATS Services can not be null");
+ }
+ for (IAtsWidgetDefinition widgetDef : services.getWorkDefinitionAdmin().getWidgetsFromLayoutItems(
+ workItem.getStateDefinition())) {
+ ArtifactValueProvider provider = new ArtifactValueProvider(workItem.getStoreObject(), widgetDef, services);
+ AtsXWidgetValidateManager.validateTransition(results, provider, widgetDef, workItem.getStateDefinition(),
+ toStateDef, services);
+ }
+ return results;
}
- public void add(AtsXWidgetValidatorProvider provider) {
+ public void add(IAtsXWidgetValidatorProvider provider) {
providers.add(provider);
}
+ public void remove(IAtsXWidgetValidatorProvider provider) {
+ providers.remove(provider);
+ }
+
}
diff --git a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/validator/AtsXWidgetValidator.java b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/validator/AtsXWidgetValidator.java
index 4c1de4e30e..eb6a94d783 100644
--- a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/validator/AtsXWidgetValidator.java
+++ b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/validator/AtsXWidgetValidator.java
@@ -22,6 +22,7 @@ import org.eclipse.osee.ats.api.workdef.IAtsWidgetDefinitionListMinMaxSelectedCo
import org.eclipse.osee.ats.api.workdef.WidgetOption;
import org.eclipse.osee.ats.api.workdef.WidgetResult;
import org.eclipse.osee.ats.api.workdef.WidgetStatus;
+import org.eclipse.osee.ats.api.workflow.transition.IAtsXWidgetValidator;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.util.DateUtil;
diff --git a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/workflow/AtsWorkItemServiceImpl.java b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/workflow/AtsWorkItemServiceImpl.java
index 735e1e9e09..bc97395443 100644
--- a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/workflow/AtsWorkItemServiceImpl.java
+++ b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/workflow/AtsWorkItemServiceImpl.java
@@ -27,6 +27,7 @@ import org.eclipse.osee.ats.api.workflow.IAtsAction;
import org.eclipse.osee.ats.api.workflow.IAtsTeamWorkflow;
import org.eclipse.osee.ats.api.workflow.IAtsWorkItemService;
import org.eclipse.osee.ats.api.workflow.transition.ITransitionListener;
+import org.eclipse.osee.ats.core.validator.AtsXWidgetValidateManager;
import org.eclipse.osee.framework.core.data.ArtifactId;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.type.OseeStateException;
@@ -105,7 +106,7 @@ public class AtsWorkItemServiceImpl implements IAtsWorkItemService {
@Override
public Collection<WidgetResult> validateWidgetTransition(IAtsWorkItem workItem, IAtsStateDefinition toStateDef) throws OseeStateException {
- return services.validateWidgetTransition(workItem, toStateDef);
+ return AtsXWidgetValidateManager.validateTransition(workItem, toStateDef);
}
@Override
diff --git a/plugins/org.eclipse.osee.ats.rest/OSGI-INF/ats.server.service.xml b/plugins/org.eclipse.osee.ats.rest/OSGI-INF/ats.server.service.xml
index b4c2a80a16..b22af762e1 100644
--- a/plugins/org.eclipse.osee.ats.rest/OSGI-INF/ats.server.service.xml
+++ b/plugins/org.eclipse.osee.ats.rest/OSGI-INF/ats.server.service.xml
@@ -3,6 +3,7 @@
<implementation class="org.eclipse.osee.ats.rest.internal.AtsServerImpl"/>
<service>
<provide interface="org.eclipse.osee.ats.rest.IAtsServer"/>
+ <provide interface="org.eclipse.osee.ats.api.IAtsServices"/>
</service>
<reference bind="addNotifier" cardinality="1..n" interface="org.eclipse.osee.ats.rest.util.IAtsNotifierServer" name="IAtsNotifierServer" policy="dynamic" unbind="removeNotifier"/>
<reference bind="addAtsDatabaseConversion" cardinality="0..n" interface="org.eclipse.osee.ats.api.util.IAtsDatabaseConversion" name="IAtsDatabaseConversion" policy="dynamic" unbind="removeAtsDatabaseConversion"/>
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 1832b231b1..004fb0078b 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
@@ -48,12 +48,10 @@ import org.eclipse.osee.ats.api.util.IAtsStoreService;
import org.eclipse.osee.ats.api.util.IAtsUtilService;
import org.eclipse.osee.ats.api.util.ISequenceProvider;
import org.eclipse.osee.ats.api.version.IAtsVersionService;
-import org.eclipse.osee.ats.api.workdef.IAtsStateDefinition;
import org.eclipse.osee.ats.api.workdef.IAtsWorkDefinitionAdmin;
import org.eclipse.osee.ats.api.workdef.IAtsWorkDefinitionService;
import org.eclipse.osee.ats.api.workdef.IAttributeResolver;
import org.eclipse.osee.ats.api.workdef.IRelationResolver;
-import org.eclipse.osee.ats.api.workdef.WidgetResult;
import org.eclipse.osee.ats.api.workflow.IAtsAction;
import org.eclipse.osee.ats.api.workflow.IAtsActionFactory;
import org.eclipse.osee.ats.api.workflow.IAtsBranchService;
@@ -594,11 +592,6 @@ public class AtsServerImpl extends AtsCoreServiceImpl implements IAtsServer {
}
@Override
- public Collection<WidgetResult> validateWidgetTransition(IAtsWorkItem workItem, IAtsStateDefinition toStateDef) {
- return Collections.emptyList();
- }
-
- @Override
public void clearImplementersCache(IAtsWorkItem workItem) {
// do nothing; no cache on server
}
@@ -714,4 +707,9 @@ public class AtsServerImpl extends AtsCoreServiceImpl implements IAtsServer {
return implementerService;
}
+ @Override
+ public IAtsWorkDefinitionAdmin getWorkDefinitionAdmin() {
+ return workDefAdmin;
+ }
+
}
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 859dbc8285..3047c015dd 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
@@ -144,5 +144,10 @@ public class AtsStoreServiceImpl implements IAtsStoreService {
public IArtifactType getArtifactType(ArtifactId artifact) {
return ((ArtifactReadable) artifact).getArtifactType();
}
+
+ @Override
+ public boolean isDateType(IAttributeType attributeType) {
+ return atsServer.getOrcsApi().getOrcsTypes().getAttributeTypes().isDateType(attributeType);
+ }
}

Back to the top