Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordonald.g.dunne2016-10-05 21:50:58 +0000
committerDonald Dunne2016-10-12 00:57:09 +0000
commit45496a9945a6b1ffd406ebb81a143d7b4454ec89 (patch)
tree84b703616d63fbfa9b6069a65a0aea91eb02ad10 /plugins
parent17ad6692663d22337f4b1fbcb4c89aa763f70ef0 (diff)
downloadorg.eclipse.osee-45496a9945a6b1ffd406ebb81a143d7b4454ec89.tar.gz
org.eclipse.osee-45496a9945a6b1ffd406ebb81a143d7b4454ec89.tar.xz
org.eclipse.osee-45496a9945a6b1ffd406ebb81a143d7b4454ec89.zip
refinement: Add error check for ORCS Writer booleans
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/writer/OrcsCollectorValidator.java25
-rw-r--r--plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/writer/OrcsCollectorWriter.java6
2 files changed, 22 insertions, 9 deletions
diff --git a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/writer/OrcsCollectorValidator.java b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/writer/OrcsCollectorValidator.java
index 011946354df..c477fbf4a33 100644
--- a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/writer/OrcsCollectorValidator.java
+++ b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/writer/OrcsCollectorValidator.java
@@ -14,6 +14,7 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
+import org.eclipse.osee.framework.core.data.IAttributeType;
import org.eclipse.osee.framework.core.enums.SystemUser;
import org.eclipse.osee.framework.core.util.XResultData;
import org.eclipse.osee.framework.jdk.core.util.Strings;
@@ -37,6 +38,7 @@ public class OrcsCollectorValidator {
private final Set<Long> artifactsExist;
private final IOrcsValidationHelper helper;
private boolean branchValid;
+ private OrcsApi orcsApi;
public OrcsCollectorValidator(OwCollector collector, IOrcsValidationHelper helper) {
this.collector = collector;
@@ -47,6 +49,7 @@ public class OrcsCollectorValidator {
public OrcsCollectorValidator(OrcsApi orcsApi, OwCollector collector2) {
this(collector2, new OrcsValidationHelperAdapter(orcsApi));
+ this.orcsApi = orcsApi;
}
public XResultData run() {
@@ -180,15 +183,25 @@ public class OrcsCollectorValidator {
results.errorf("Artifact [%s] does not have Name attribute.\n", artifact);
}
for (OwAttribute attribute : artifact.getAttributes()) {
- OwAttributeType attrType = attribute.getType();
+ OwAttributeType owAttrType = attribute.getType();
+ IAttributeType attrType = OrcsCollectorWriter.getAttributeType(orcsApi, owAttrType);
if (attrType == null) {
- results.errorf("Invalid Attribute Type for artifact [%s].\n", artifact);
- } else if (attrType.getUuid() <= 0L && !helper.isAttributeTypeExists(attrType.getName())) {
- results.errorf("Invalid Attribute Type uuid [%s] for artifact [%s].\n", attrType, artifact);
- } else if (attrType.getUuid() > 0L && !helper.isAttributeTypeExists(attrType.getUuid())) {
- results.errorf("Attribute Type [%s] does not exist for artifact [%s].\n", attrType, artifact);
+ results.errorf("Invalid Attribute Type [%s] for artifact [%s].\n", owAttrType, artifact);
}
+
+ if (orcsApi.getOrcsTypes().getAttributeTypes().isBooleanType(attrType)) {
+ if (attribute.values.size() > 1) {
+ results.errorf("Cannot have multiple values for Boolean Attribute [%s] for artifact [%s].\n",
+ attribute, artifact);
+ }
+ } else if (orcsApi.getOrcsTypes().getAttributeTypes().isDateType(attrType)) {
+ if (attribute.values.size() > 1) {
+ results.errorf("Cannot have multiple attributes Date Attribute [%s] for artifact [%s]", attribute,
+ artifact);
+ }
+ }
+
}
}
diff --git a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/writer/OrcsCollectorWriter.java b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/writer/OrcsCollectorWriter.java
index ebccad67cdb..d6330fa6b59 100644
--- a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/writer/OrcsCollectorWriter.java
+++ b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/writer/OrcsCollectorWriter.java
@@ -110,7 +110,7 @@ public class OrcsCollectorWriter {
try {
for (OwAttribute owAttribute : owArtifact.getAttributes()) {
- IAttributeType attrType = getAttributeType(owAttribute.getType());
+ IAttributeType attrType = getAttributeType(orcsApi, owAttribute.getType());
if (artifact.getAttributeCount(attrType) <= 1 && owAttribute.getValues().size() <= 1) {
String currValue = artifact.getSoleAttributeAsString(attrType, null);
@@ -234,7 +234,7 @@ public class OrcsCollectorWriter {
return null;
}
- private IAttributeType getAttributeType(OwAttributeType attributeType) {
+ protected static IAttributeType getAttributeType(OrcsApi orcsApi, OwAttributeType attributeType) {
if (attributeType.getUuid() <= 0L) {
for (IAttributeType type : orcsApi.getOrcsTypes().getAttributeTypes().getAll()) {
if (type.getName().equals(attributeType.getName())) {
@@ -318,7 +318,7 @@ public class OrcsCollectorWriter {
for (OwAttribute owAttribute : owArtifact.getAttributes()) {
if (!CoreAttributeTypes.Name.getGuid().equals(owAttribute.getType().getUuid())) {
OwAttributeType owAttrType = owAttribute.getType();
- IAttributeType attrType = getAttributeType(owAttrType);
+ IAttributeType attrType = getAttributeType(orcsApi, owAttrType);
List<Object> values = owAttribute.getValues();
for (Object value : values) {

Back to the top