refactor[ats_A0KLY]: Allow change of Artifact type without prompt
Change-Id: I0ebf4d9a1ea59f13aa2af0768b118a17c738d416
diff --git a/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/skynet/core/ArtifactEventTest.java b/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/skynet/core/ArtifactEventTest.java
index d300588..02b8680 100644
--- a/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/skynet/core/ArtifactEventTest.java
+++ b/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/skynet/core/ArtifactEventTest.java
@@ -312,7 +312,7 @@
// reload Artifact
Assert.assertTrue(newArt.isOfType(CoreArtifactTypes.GeneralData));
- ChangeArtifactType.changeArtifactType(Arrays.asList(newArt), CoreArtifactTypes.Heading);
+ ChangeArtifactType.changeArtifactType(Arrays.asList(newArt), CoreArtifactTypes.Heading, true);
Assert.assertEquals(1, listener.getArtifacts().size());
EventChangeTypeBasicGuidArtifact guidArt =
diff --git a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/type/ArtifactType.java b/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/type/ArtifactType.java
index a5e9b24..651c8532 100644
--- a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/type/ArtifactType.java
+++ b/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/type/ArtifactType.java
@@ -39,7 +39,7 @@
private final Set<ArtifactType> superTypes = new HashSet<ArtifactType>();
private final Set<ArtifactType> childTypes = new HashSet<ArtifactType>();
private final Map<IOseeBranch, Collection<AttributeType>> attributes =
- new HashMap<IOseeBranch, Collection<AttributeType>>();
+ new HashMap<IOseeBranch, Collection<AttributeType>>();
public ArtifactType(Long guid, String name, boolean isAbstract) {
super(guid, name);
@@ -110,7 +110,8 @@
}
public boolean isValidAttributeType(IAttributeType attributeType, Branch branch) throws OseeCoreException {
- return getAttributeTypes(branch).contains(attributeType);
+ Collection<IAttributeType> attributes = getAttributeTypes(branch);
+ return attributes.contains(attributeType);
}
public Map<IOseeBranch, Collection<AttributeType>> getLocalAttributeTypes() throws OseeCoreException {
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactTypeManager.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactTypeManager.java
index 467c3b3..b114717 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactTypeManager.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactTypeManager.java
@@ -221,7 +221,7 @@
throw new OseeStateException("Found %d artifact references of type [%s] on branches [%s]",
artifacts.size(), purgeArtifactType, branches);
} else {
- ChangeArtifactType.changeArtifactType(artifactMap.values(), newArtifactType);
+ ChangeArtifactType.changeArtifactType(artifactMap.values(), newArtifactType, true);
}
}
purgeArtifactType(purgeArtifactType);
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ChangeArtifactType.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ChangeArtifactType.java
index 305cbfb..cd4473b 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ChangeArtifactType.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ChangeArtifactType.java
@@ -69,7 +69,7 @@
private static final IStatus promptStatus = new Status(IStatus.WARNING, Activator.PLUGIN_ID, 257, "", null);
private final Map<Integer, Integer> gammaToArtId = new HashMap<Integer, Integer>();
- public static void changeArtifactType(Collection<? extends Artifact> inputArtifacts, IArtifactType newArtifactTypeToken) throws OseeCoreException {
+ public static void changeArtifactType(Collection<? extends Artifact> inputArtifacts, IArtifactType newArtifactTypeToken, boolean prompt) throws OseeCoreException {
ChangeArtifactType app = new ChangeArtifactType();
if (inputArtifacts.isEmpty()) {
@@ -83,7 +83,7 @@
ArtifactType newArtifactType = ArtifactTypeManager.getType(newArtifactTypeToken);
try {
- app.internalChangeArtifactType(inputArtifacts, newArtifactType);
+ app.internalChangeArtifactType(inputArtifacts, newArtifactType, prompt);
} catch (Exception ex) {
ArtifactQuery.reloadArtifacts(app.modifiedArtifacts);
OseeExceptions.wrapAndThrow(ex);
@@ -97,10 +97,13 @@
* memory/database changes in such a manner that they stay in sync therefore, if any part of this blam fails, then
* the type should not be changed
*/
- private void internalChangeArtifactType(Collection<? extends Artifact> inputArtifacts, ArtifactType newArtifactType) throws OseeDataStoreException, OseeCoreException {
+ private void internalChangeArtifactType(Collection<? extends Artifact> inputArtifacts, ArtifactType newArtifactType, boolean prompt) throws OseeDataStoreException, OseeCoreException {
createAttributeRelationTransactions(inputArtifacts, newArtifactType);
- boolean changeOk = doesUserAcceptArtifactChange(newArtifactType);
+ boolean changeOk = !prompt;
+ if (prompt) {
+ changeOk = doesUserAcceptArtifactChange(newArtifactType);
+ }
if (!changeOk) {
ArtifactQuery.reloadArtifacts(modifiedArtifacts);
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/operation/ChangeArtifactTypeBlam.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/operation/ChangeArtifactTypeBlam.java
index 44bae2c..24937f5 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/operation/ChangeArtifactTypeBlam.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/operation/ChangeArtifactTypeBlam.java
@@ -35,7 +35,7 @@
@Override
public void runOperation(VariableMap variableMap, IProgressMonitor monitor) throws Exception {
ChangeArtifactType.changeArtifactType(variableMap.getArtifacts("artifacts"),
- variableMap.getArtifactType("New Artifact Type"));
+ variableMap.getArtifactType("New Artifact Type"), true);
}
@Override