bug[ats_ATS29251]: Allow remove all if attribute type not allowed on artifacts
Change-Id: Ia51fcf463c54fc037343e9d45200e2f1f9d77a7b
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/attribute/AttributeTypeManager.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/attribute/AttributeTypeManager.java
index 5e68ab8..9c4b2b6 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/attribute/AttributeTypeManager.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/attribute/AttributeTypeManager.java
@@ -28,6 +28,7 @@
import org.eclipse.osee.framework.core.services.IOseeCachingService;
import org.eclipse.osee.framework.jdk.core.type.OseeArgumentException;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
+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.Attribute;
import org.eclipse.osee.framework.skynet.core.attribute.providers.IAttributeDataProvider;
@@ -155,4 +156,21 @@
public static Class<? extends IAttributeDataProvider> getAttributeProviderClass(AttributeType attributeType) throws OseeCoreException {
return AttributeExtensionManager.getAttributeProviderClassFor(attributeType.getAttributeProviderId());
}
+
+ public static boolean checkIfRemovalAllowed(IAttributeType attributeType, Collection<? extends Artifact> artifacts) {
+ boolean removalAllowed = false;
+ if (getType(attributeType).getMinOccurrences() == 0) {
+ removalAllowed = true;
+ }
+ // if there is any artifact that allows the type, then removal is not allowed
+ boolean notAllowed = false;
+ for (Artifact art : artifacts) {
+ notAllowed = art.isAttributeTypeValid(attributeType);
+ if (notAllowed) {
+ break;
+ }
+ }
+
+ return removalAllowed || !notAllowed;
+ }
}
\ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/EnumSelectionDialog.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/EnumSelectionDialog.java
index d615d2f..29d1b56 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/EnumSelectionDialog.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/EnumSelectionDialog.java
@@ -58,7 +58,7 @@
try {
options = AttributeTypeManager.getEnumerationValues(attributeType);
isSingletonAttribute = AttributeTypeManager.getMaxOccurrences(attributeType) == 1;
- isRemoveAllAllowed = AttributeTypeManager.getMinOccurrences(attributeType) == 0;
+ isRemoveAllAllowed = AttributeTypeManager.checkIfRemovalAllowed(attributeType, artifacts);
if (isSingletonAttribute) {
selected = Selection.ReplaceAll;
}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/EnumSingletonSelectionDialog.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/EnumSingletonSelectionDialog.java
index 8ae3161..8ffda3b 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/EnumSingletonSelectionDialog.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/artifact/EnumSingletonSelectionDialog.java
@@ -43,7 +43,8 @@
Set<String> options;
try {
options = AttributeTypeManager.getEnumerationValues(attributeType);
- isRemoveAllAllowed = AttributeTypeManager.getType(attributeType).getMinOccurrences() == 0;
+ isRemoveAllAllowed = AttributeTypeManager.checkIfRemovalAllowed(attributeType, artifacts);
+
} catch (OseeCoreException ex) {
options = new HashSet<String>();
options.add(ex.getLocalizedMessage());