diff options
author | donald.g.dunne | 2015-07-09 07:24:11 +0000 |
---|---|---|
committer | Angel Avila | 2015-09-12 00:45:31 +0000 |
commit | 368cc526920b683a00ec9cfa567cf415bf0d5eb0 (patch) | |
tree | 6f51e25ae233a040b04ea616816c6a5bf8ffa8be | |
parent | be68d3e6269417590ecc66eae5c8be997d635638 (diff) | |
download | org.eclipse.osee-368cc526920b683a00ec9cfa567cf415bf0d5eb0.tar.gz org.eclipse.osee-368cc526920b683a00ec9cfa567cf415bf0d5eb0.tar.xz org.eclipse.osee-368cc526920b683a00ec9cfa567cf415bf0d5eb0.zip |
feature[ats_ATS212297]: Performance Reporting - Disable user creation of artifact types
Change-Id: Ia9919b6c9bbcb2ae2a53de02acae1860bb9abba8
19 files changed, 289 insertions, 51 deletions
diff --git a/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/AtsClientIntegrationTestSuite.java b/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/AtsClientIntegrationTestSuite.java index 64d6ffcaa99..a1870c9c0da 100644 --- a/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/AtsClientIntegrationTestSuite.java +++ b/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/AtsClientIntegrationTestSuite.java @@ -13,6 +13,7 @@ package org.eclipse.osee.ats.client.integration; import org.eclipse.osee.ats.client.integration.tests.AtsTest_AllAts_Suite; import org.eclipse.osee.ats.client.integration.tests.DemoDbPopulateSuite; import org.eclipse.osee.ats.client.integration.tests.DirtyArtifactCacheTest; +import org.eclipse.osee.ats.client.integration.tests.framework.skynet.core.artifact.SkyentCoreArtifact_Suite; import org.eclipse.osee.ats.client.integration.tests.framework.ui.skynet.dialog.FrameworkUiSkynetTest_Dialog_Suite; import org.eclipse.osee.ats.client.integration.tests.util.DbInitTest; import org.junit.runner.RunWith; @@ -26,6 +27,7 @@ import org.junit.runners.Suite; DbInitTest.class, DemoDbPopulateSuite.class, AtsTest_AllAts_Suite.class, + SkyentCoreArtifact_Suite.class, FrameworkUiSkynetTest_Dialog_Suite.class, DirtyArtifactCacheTest.class}) public class AtsClientIntegrationTestSuite { diff --git a/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/core/client/AtsCoreClient_Suite.java b/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/core/client/AtsCoreClient_Suite.java index 097740919d5..e097f7a8e7a 100644 --- a/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/core/client/AtsCoreClient_Suite.java +++ b/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/core/client/AtsCoreClient_Suite.java @@ -11,6 +11,7 @@ package org.eclipse.osee.ats.client.integration.tests.ats.core.client; import org.eclipse.osee.ats.client.integration.tests.ats.core.client.action.AtsCoreClient_Action_Suite; +import org.eclipse.osee.ats.client.integration.tests.ats.core.client.artifact.AtsCoreClient_Artifact_Suite; import org.eclipse.osee.ats.client.integration.tests.ats.core.client.branch.AtsCoreClient_Branch_Suite; import org.eclipse.osee.ats.client.integration.tests.ats.core.client.config.AtsCoreClient_Config_Suite; import org.eclipse.osee.ats.client.integration.tests.ats.core.client.operation.AtsCoreClient_Operation_Suite; @@ -31,6 +32,7 @@ import org.junit.runners.Suite; @Suite.SuiteClasses({ AtsTestUtilTest.class, AtsCoreClient_Action_Suite.class, + AtsCoreClient_Artifact_Suite.class, AtsCoreClient_Branch_Suite.class, AtsCoreClient_Config_Suite.class, AtsCoreClient_Operation_Suite.class, diff --git a/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/core/client/artifact/AtsArtifactFactoryTest.java b/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/core/client/artifact/AtsArtifactFactoryTest.java new file mode 100644 index 00000000000..fe4e6d5bb9e --- /dev/null +++ b/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/core/client/artifact/AtsArtifactFactoryTest.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * 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.core.client.artifact; + +import org.eclipse.osee.ats.api.data.AtsArtifactTypes; +import org.eclipse.osee.ats.client.demo.DemoArtifactTypes; +import org.eclipse.osee.framework.skynet.core.artifact.ArtifactTypeManager; +import org.junit.Assert; +import org.junit.Test; + +/** + * @author Donald G. Dunne + */ +public class AtsArtifactFactoryTest { + + @Test + public void test() { + Assert.assertFalse(ArtifactTypeManager.isUserCreationAllowed(AtsArtifactTypes.TeamWorkflow)); + + Assert.assertFalse(ArtifactTypeManager.isUserCreationAllowed(DemoArtifactTypes.DemoCodeTeamWorkflow)); + + Assert.assertTrue(ArtifactTypeManager.isUserCreationAllowed(AtsArtifactTypes.AgileFeatureGroup)); + } +} diff --git a/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/core/client/artifact/AtsCoreClient_Artifact_Suite.java b/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/core/client/artifact/AtsCoreClient_Artifact_Suite.java new file mode 100644 index 00000000000..921b7825999 --- /dev/null +++ b/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/core/client/artifact/AtsCoreClient_Artifact_Suite.java @@ -0,0 +1,35 @@ +/******************************************************************************* + * 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.core.client.artifact; + +import org.eclipse.osee.framework.jdk.core.util.OseeProperties; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +/** + * @author Donald G. Dunne + */ +@RunWith(Suite.class) +@Suite.SuiteClasses({AtsArtifactFactoryTest.class}) +public class AtsCoreClient_Artifact_Suite { + @BeforeClass + public static void setUp() throws Exception { + OseeProperties.setIsInTest(true); + System.out.println("\n\nBegin " + AtsCoreClient_Artifact_Suite.class.getSimpleName()); + } + + @AfterClass + public static void tearDown() throws Exception { + System.out.println("End " + AtsCoreClient_Artifact_Suite.class.getSimpleName()); + } +} diff --git a/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/framework/skynet/core/artifact/ArtifactTypeManagerTest.java b/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/framework/skynet/core/artifact/ArtifactTypeManagerTest.java new file mode 100644 index 00000000000..e5317a4f027 --- /dev/null +++ b/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/framework/skynet/core/artifact/ArtifactTypeManagerTest.java @@ -0,0 +1,29 @@ +/******************************************************************************* + * 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.framework.skynet.core.artifact; + +import org.eclipse.osee.framework.core.enums.CoreArtifactTypes; +import org.eclipse.osee.framework.skynet.core.artifact.ArtifactTypeManager; +import org.junit.Assert; +import org.junit.Test; + +/** + * @author Donald G. Dunne + */ +public class ArtifactTypeManagerTest { + + @Test + public void test() { + Assert.assertFalse(ArtifactTypeManager.isUserCreationAllowed(CoreArtifactTypes.User)); + + Assert.assertTrue(ArtifactTypeManager.isUserCreationAllowed(CoreArtifactTypes.SoftwareRequirement)); + } +} diff --git a/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/framework/skynet/core/artifact/SkyentCoreArtifact_Suite.java b/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/framework/skynet/core/artifact/SkyentCoreArtifact_Suite.java new file mode 100644 index 00000000000..6b468633e89 --- /dev/null +++ b/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/framework/skynet/core/artifact/SkyentCoreArtifact_Suite.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * Copyright (c) 2014 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.framework.skynet.core.artifact; + +import org.eclipse.osee.ats.client.integration.tests.util.DemoTestUtil; +import org.eclipse.osee.framework.jdk.core.util.OseeProperties; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +/** + * @author Donald G. Dunne + */ +@RunWith(Suite.class) +@Suite.SuiteClasses({ // + ArtifactTypeManagerTest.class, // +}) +public class SkyentCoreArtifact_Suite { + + @BeforeClass + public static void setUp() throws Exception { + OseeProperties.setIsInTest(true); + System.out.println("\n\nBegin " + SkyentCoreArtifact_Suite.class.getSimpleName()); + DemoTestUtil.setUpTest(); + } + + @AfterClass + public static void tearDown() throws Exception { + System.out.println("End " + SkyentCoreArtifact_Suite.class.getSimpleName()); + } +} 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 9c2d150ae5c..915cf11f59e 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 @@ -54,7 +54,6 @@ import org.eclipse.osee.ats.core.config.IAtsConfigProvider; import org.eclipse.osee.ats.core.config.ITeamDefinitionFactory; import org.eclipse.osee.ats.core.util.IAtsActionFactory; import org.eclipse.osee.ats.core.workflow.TeamWorkflowProviders; -import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.core.data.IArtifactToken; import org.eclipse.osee.framework.core.data.IOseeBranch; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; @@ -75,6 +74,7 @@ public interface IAtsClient extends IAtsServices, IAtsNotifier, IAttributeResolv /** * @return corresponding Artifact or null if not found */ + @Override Artifact getArtifact(IArtifactToken token) throws OseeCoreException; /** @@ -173,4 +173,6 @@ public interface IAtsClient extends IAtsServices, IAtsNotifier, IAttributeResolv TeamWorkflowProviders getTeamWorkflowProviders(); + void setConfigValue(String key, String value); + } diff --git a/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/artifact/AtsArtifactFactory.java b/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/artifact/AtsArtifactFactory.java index c52549efe31..583c55301ec 100644 --- a/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/artifact/AtsArtifactFactory.java +++ b/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/artifact/AtsArtifactFactory.java @@ -17,15 +17,19 @@ import java.util.logging.Level; import org.eclipse.osee.ats.api.data.AtsArtifactTypes; import org.eclipse.osee.ats.core.client.action.ActionArtifact; import org.eclipse.osee.ats.core.client.internal.Activator; +import org.eclipse.osee.ats.core.client.internal.AtsClientService; import org.eclipse.osee.ats.core.client.review.DecisionReviewArtifact; import org.eclipse.osee.ats.core.client.review.PeerToPeerReviewArtifact; import org.eclipse.osee.ats.core.client.task.TaskArtifact; import org.eclipse.osee.ats.core.client.team.TeamWorkFlowArtifact; import org.eclipse.osee.ats.core.client.team.TeamWorkFlowManager; +import org.eclipse.osee.ats.core.util.AtsUtilCore; import org.eclipse.osee.framework.core.data.IArtifactType; import org.eclipse.osee.framework.core.model.Branch; +import org.eclipse.osee.framework.core.model.type.ArtifactType; 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.util.Strings; import org.eclipse.osee.framework.logging.OseeLog; import org.eclipse.osee.framework.skynet.core.artifact.Artifact; import org.eclipse.osee.framework.skynet.core.artifact.ArtifactFactory; @@ -33,6 +37,7 @@ import org.eclipse.osee.framework.skynet.core.artifact.ArtifactTypeManager; /** * @author Ryan D. Brooks + * @author Donald G. Dunne */ public class AtsArtifactFactory extends ArtifactFactory { @@ -81,4 +86,21 @@ public class AtsArtifactFactory extends ArtifactFactory { return artifactTypes; } + @Override + public boolean isUserCreationEnabled(IArtifactType artifactType) { + ArtifactType forArtifactType = ArtifactTypeManager.getType(artifactType); + String configValue = AtsClientService.get().getConfigValue(AtsUtilCore.USER_CREATION_DISABLED); + if (Strings.isValid(configValue)) { + for (String artifactTypeName : configValue.split(";")) { + ArtifactType configArtifactType = ArtifactTypeManager.getType(artifactTypeName); + if (configArtifactType == null) { + OseeLog.logf(Activator.class, Level.SEVERE, + "Artifact Type Name [%s] specified in AtsConfig.[%s] is invalid", AtsUtilCore.USER_CREATION_DISABLED); + } else if (forArtifactType.inheritsFrom(configArtifactType)) { + return false; + } + } + } + return true; + } }
\ No newline at end of file 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 d5cf759fd33..f024b513e32 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 @@ -119,6 +119,7 @@ import org.eclipse.osee.framework.jdk.core.util.Strings; import org.eclipse.osee.framework.plugin.core.util.Jobs; 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.artifact.search.ArtifactQuery; import org.eclipse.osee.jdbc.JdbcService; @@ -602,6 +603,29 @@ public class AtsClientImpl implements IAtsClient { return result; } + @SuppressWarnings("deprecation") + @Override + public void setConfigValue(String key, String value) { + Artifact atsConfig = ArtifactQuery.getArtifactFromToken(AtsArtifactToken.AtsConfig, AtsUtilCore.getAtsBranch()); + if (atsConfig != null) { + String keyValue = String.format("%s=%s", key, value); + boolean found = false; + List<Attribute<String>> attributes = atsConfig.getAttributes(CoreAttributeTypes.GeneralStringData); + for (Attribute<String> attr : attributes) { + String str = attr.getValue(); + if (str.startsWith(key)) { + attr.setValue(keyValue); + found = true; + break; + } + } + if (!found) { + atsConfig.addAttribute(CoreAttributeTypes.GeneralStringData, keyValue); + } + } + atsConfig.persist(String.format("Update AtsConfig [%s] Key", key)); + } + @Override public IAtsServices getServices() { return this; diff --git a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/config/AbstractConfigItemFactory.java b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/config/AbstractConfigItemFactory.java index c2aab0b51b7..37f7ac589db 100644 --- a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/config/AbstractConfigItemFactory.java +++ b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/config/AbstractConfigItemFactory.java @@ -25,10 +25,9 @@ public abstract class AbstractConfigItemFactory implements IAtsConfigItemFactory public final List<IArtifactType> atsConfigArtifactTypes; public AbstractConfigItemFactory() { - atsConfigArtifactTypes = - Arrays.asList(AtsArtifactTypes.Version, AtsArtifactTypes.TeamDefinition, AtsArtifactTypes.ActionableItem, - AtsArtifactTypes.Program, AtsArtifactTypes.AgileTeam, AtsArtifactTypes.AgileFeatureGroup, - AtsArtifactTypes.Insertion, AtsArtifactTypes.InsertionFeature); + atsConfigArtifactTypes = Arrays.asList(AtsArtifactTypes.Version, AtsArtifactTypes.TeamDefinition, + AtsArtifactTypes.ActionableItem, AtsArtifactTypes.Program, AtsArtifactTypes.AgileTeam, + AtsArtifactTypes.AgileFeatureGroup, AtsArtifactTypes.Insertion, AtsArtifactTypes.InsertionActivity); } @Override diff --git a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/util/AtsUtilCore.java b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/util/AtsUtilCore.java index d261ccf7a78..b63ed856578 100644 --- a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/util/AtsUtilCore.java +++ b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/util/AtsUtilCore.java @@ -17,7 +17,6 @@ import java.util.List; import java.util.Map; import java.util.logging.Level; import org.eclipse.osee.ats.api.IAtsObject; -import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.core.data.IOseeBranch; import org.eclipse.osee.framework.core.data.TokenFactory; import org.eclipse.osee.framework.core.enums.CoreBranches; @@ -35,6 +34,7 @@ public class AtsUtilCore { private static final String ATS_BRANCH_UUID = "ats.branch.uuid"; public final static double DEFAULT_HOURS_PER_WORK_DAY = 8; public static final String DEFAULT_ATS_ID_VALUE = "0"; + public static final String USER_CREATION_DISABLED = "UserCreationDisabled"; private static final Object lock = new Object(); private volatile static IOseeBranch atsBranch; @@ -131,8 +131,8 @@ public class AtsUtilCore { public static String getGuid(IAtsObject atsObject) { String guid = uuidToGuidMap.get(atsObject.getUuid()); - if (!Strings.isValid(guid) && atsObject.getStoreObject() instanceof ArtifactId) { - guid = ((ArtifactId) atsObject.getStoreObject()).getGuid(); + if (!Strings.isValid(guid) && atsObject.getStoreObject() != null) { + guid = atsObject.getStoreObject().getGuid(); } return guid; } 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 697dd74eaba..d21dfde41ce 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 @@ -18,7 +18,9 @@ import java.util.List; import javax.ws.rs.core.Response; import org.eclipse.osee.ats.api.ai.IAtsActionableItem; import org.eclipse.osee.ats.api.data.AtsArtifactToken; +import org.eclipse.osee.ats.api.data.AtsArtifactTypes; import org.eclipse.osee.ats.api.team.IAtsTeamDefinition; +import org.eclipse.osee.ats.api.util.AtsActivity; import org.eclipse.osee.ats.api.workdef.IAtsWorkDefinitionAdmin; import org.eclipse.osee.ats.core.client.util.AtsChangeSet; import org.eclipse.osee.ats.core.client.util.AtsGroup; @@ -35,6 +37,7 @@ import org.eclipse.osee.framework.core.util.XResultData; import org.eclipse.osee.framework.database.init.IDbInitializationTask; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.framework.jdk.core.type.OseeStateException; +import org.eclipse.osee.framework.jdk.core.util.Collections; import org.eclipse.osee.framework.jdk.core.util.Lib; import org.eclipse.osee.framework.skynet.core.OseeSystemArtifacts; import org.eclipse.osee.framework.skynet.core.artifact.Artifact; @@ -74,9 +77,22 @@ public class AtsDatabaseConfig implements IDbInitializationTask { AtsGroup.AtsAdmin.getArtifact().persist(getClass().getSimpleName()); AtsGroup.AtsTempAdmin.getArtifact().persist(getClass().getSimpleName()); + ActivityLogJaxRsService.createActivityType(AtsActivity.ATSNAVIGATEITEM); + + createUserCreationDisabledConfig(); + createSafetyConfig(); } + private void createUserCreationDisabledConfig() { + AtsClientService.get().setConfigValue( + AtsUtilCore.USER_CREATION_DISABLED, + Collections.toString(";", Arrays.asList(AtsArtifactTypes.Action.getName(), + AtsArtifactTypes.TeamWorkflow.getName(), AtsArtifactTypes.Task.getName(), + AtsArtifactTypes.PeerToPeerReview.getName(), AtsArtifactTypes.DecisionReview.getName(), + AtsArtifactTypes.Goal.getName(), AtsArtifactTypes.AgileSprint.getName()))); + } + private void createSafetyConfig() { List<String> versions = new ArrayList<String>(); AtsConfigOperation operation = diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactFactory.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactFactory.java index 0499099336a..7dcba77e85b 100644 --- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactFactory.java +++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactFactory.java @@ -114,7 +114,7 @@ public abstract class ArtifactFactory { * call to the persistence manager to acquire the <code>Artifact</code> or else an infinite loop will occur since * this method is used by the persistence manager when it needs a new instance of the class to work with and can not * come up with it on its own. - * + * * @param branch branch on which this instance of this artifact will be associated * @param hrid */ @@ -146,4 +146,6 @@ public abstract class ArtifactFactory { return Collections.emptyList(); } + public abstract boolean isUserCreationEnabled(IArtifactType artifactType); + } 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 4f888d2751d..ac863ad7135 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 @@ -21,7 +21,6 @@ import java.util.Iterator; import java.util.LinkedHashSet; import java.util.List; import java.util.Set; -import org.eclipse.core.runtime.CoreException; import org.eclipse.osee.framework.core.data.IArtifactToken; import org.eclipse.osee.framework.core.data.IArtifactType; import org.eclipse.osee.framework.core.data.IAttributeType; @@ -51,7 +50,7 @@ import org.eclipse.osee.orcs.rest.model.TypesEndpoint; /** * Contains methods specific to artifact types. All artifact methods will eventually be moved from the * ConfigurationPersistenceManager to here. - * + * * @author Donald G. Dunne */ public class ArtifactTypeManager { @@ -190,11 +189,11 @@ public class ArtifactTypeManager { /** * Given a set of artifact types, they will be converted to the new artifact type and the old artifact types will be * purged - * + * * @param purgeArtifactTypes types to be converted and purged * @param newArtifactType new type to convert any existing artifacts of the old type */ - public static void purgeArtifactTypesWithCheck(Collection<? extends IArtifactType> purgeArtifactTypes, IArtifactType newArtifactType) throws CoreException, OseeCoreException { + public static void purgeArtifactTypesWithCheck(Collection<? extends IArtifactType> purgeArtifactTypes, IArtifactType newArtifactType) throws OseeCoreException { for (IArtifactType purgeArtifactType : purgeArtifactTypes) { // find all artifact of this type on all branches and make a unique list for type change (since it is not by branch) Set<Artifact> artifacts = new LinkedHashSet<Artifact>(); @@ -245,4 +244,15 @@ public class ArtifactTypeManager { return new OseeTypesExportOperation(typesEndpoint, outputStream); } + public static boolean isUserCreationAllowed(IArtifactType artifactType) { + boolean userCreationoAllowed = false; + ArtifactFactory factory = factoryManager.getFactory(artifactType); + if (factory != null && factory.isUserCreationEnabled(artifactType)) { + userCreationoAllowed = true; + } else if (factory == null) { + userCreationoAllowed = true; + } + return userCreationoAllowed; + } + } diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/factory/DefaultArtifactFactory.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/factory/DefaultArtifactFactory.java index 090ba77393e..356a607b62d 100644 --- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/factory/DefaultArtifactFactory.java +++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/factory/DefaultArtifactFactory.java @@ -11,6 +11,7 @@ package org.eclipse.osee.framework.skynet.core.artifact.factory; import org.eclipse.osee.framework.core.data.IArtifactType; +import org.eclipse.osee.framework.core.enums.CoreArtifactTypes; import org.eclipse.osee.framework.core.model.Branch; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.framework.skynet.core.artifact.Artifact; @@ -19,7 +20,7 @@ import org.eclipse.osee.framework.skynet.core.artifact.ArtifactFactory; /** * This artifact factory is used when no other ArtifactFactory has registered itself as being responsible. This is the * case when no specific ArtifactFactory has been defined such as when a new Artifact is created dynamically. - * + * * @author Donald G. Dunne */ public final class DefaultArtifactFactory extends ArtifactFactory { @@ -33,4 +34,12 @@ public final class DefaultArtifactFactory extends ArtifactFactory { return new Artifact(guid, branch, artifactType); } + @Override + public boolean isUserCreationEnabled(IArtifactType artifactType) { + if (artifactType.getGuid().equals(CoreArtifactTypes.RootArtifact.getGuid())) { + return false; + } + return true; + } + } diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/factory/UserArtifactFactory.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/factory/UserArtifactFactory.java index 8dcc3272dd5..8f59438df68 100644 --- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/factory/UserArtifactFactory.java +++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/factory/UserArtifactFactory.java @@ -32,4 +32,9 @@ public class UserArtifactFactory extends ArtifactFactory { return new User(guid, branch, artifactType); } + @Override + public boolean isUserCreationEnabled(IArtifactType artifactType) { + return false; + } + }
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.framework.ui.skynet/META-INF/MANIFEST.MF index 06aedad41a3..ce4586983d2 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.osee.framework.ui.skynet/META-INF/MANIFEST.MF @@ -103,6 +103,7 @@ Import-Package: com.google.common.base;version="15.0.0", org.eclipse.osee.framework.plugin.core.util, org.eclipse.osee.framework.skynet.core, org.eclipse.osee.framework.skynet.core.artifact, + org.eclipse.osee.framework.skynet.core.artifact.factory, org.eclipse.osee.framework.skynet.core.artifact.operation, org.eclipse.osee.framework.skynet.core.artifact.search, org.eclipse.osee.framework.skynet.core.artifact.update, diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/explorer/ArtifactExplorer.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/explorer/ArtifactExplorer.java index a392f08a721..989fbfc4f73 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/explorer/ArtifactExplorer.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/explorer/ArtifactExplorer.java @@ -39,7 +39,6 @@ import org.eclipse.jface.window.Window; import org.eclipse.osee.framework.access.AccessControlManager; import org.eclipse.osee.framework.core.data.IArtifactType; import org.eclipse.osee.framework.core.data.IOseeBranch; -import org.eclipse.osee.framework.core.enums.CoreArtifactTypes; import org.eclipse.osee.framework.core.enums.CoreRelationTypes; import org.eclipse.osee.framework.core.enums.DeletionFlag; import org.eclipse.osee.framework.core.enums.RelationOrderBaseTypes; @@ -50,6 +49,7 @@ import org.eclipse.osee.framework.core.operation.IOperation; import org.eclipse.osee.framework.core.operation.Operations; import org.eclipse.osee.framework.help.ui.OseeHelpContext; import org.eclipse.osee.framework.jdk.core.type.HashCollection; +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.jdk.core.util.Conditions; @@ -512,32 +512,32 @@ public class ArtifactExplorer extends GenericViewPart implements IArtifactExplor private void addOpenQuickSearchAction(IToolBarManager toolbarManager) { Action openQuickSearch = new Action("Quick Search", ImageManager.getImageDescriptor(FrameworkImage.ARTIFACT_SEARCH)) { - @Override - public void run() { - Job job = new UIJob("Open Quick Search") { + @Override + public void run() { + Job job = new UIJob("Open Quick Search") { - @Override - public IStatus runInUIThread(IProgressMonitor monitor) { - IStatus status = Status.OK_STATUS; - try { - IViewPart viewPart = - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView( - QuickSearchView.VIEW_ID); - if (viewPart != null) { - Branch branch = getBranch(monitor); - if (branch != null) { - ((QuickSearchView) viewPart).setBranch(branch); + @Override + public IStatus runInUIThread(IProgressMonitor monitor) { + IStatus status = Status.OK_STATUS; + try { + IViewPart viewPart = + PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView( + QuickSearchView.VIEW_ID); + if (viewPart != null) { + Branch branch = getBranch(monitor); + if (branch != null) { + ((QuickSearchView) viewPart).setBranch(branch); + } } + } catch (Exception ex) { + status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Error opening quick search", ex); } - } catch (Exception ex) { - status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Error opening quick search", ex); + return status; } - return status; - } - }; - Jobs.startJob(job); - } - }; + }; + Jobs.startJob(job); + } + }; openQuickSearch.setToolTipText("Open Quick Search View"); toolbarManager.add(openQuickSearch); } @@ -671,15 +671,16 @@ public class ArtifactExplorer extends GenericViewPart implements IArtifactExplor } private FilteredTreeArtifactTypeEntryDialog getDialog() throws OseeCoreException { - Collection<? extends IArtifactType> artifactTypes = - ArtifactTypeManager.getConcreteArtifactTypes(branchSelect.getData()); - - artifactTypes.remove(CoreArtifactTypes.RootArtifact); + List<IArtifactType> artifactTypes = new ArrayList<>(); + for (IArtifactType artifactType : ArtifactTypeManager.getConcreteArtifactTypes(branchSelect.getData())) { + if (ArtifactTypeManager.isUserCreationAllowed(artifactType)) { + artifactTypes.add(artifactType); + } + } FilteredTreeArtifactTypeEntryDialog dialog = new FilteredTreeArtifactTypeEntryDialog("New Child", "Enter name and select Artifact type to create", - "Artifact Name"); - dialog.setInput(artifactTypes); + "Artifact Name", artifactTypes); return dialog; } @@ -965,7 +966,10 @@ public class ArtifactExplorer extends GenericViewPart implements IArtifactExplor for (Object object : selection.toArray()) { if (object instanceof Artifact) { artifact = (Artifact) object; - + if (!ArtifactTypeManager.isUserCreationAllowed(artifact.getArtifactType())) { + throw new OseeArgumentException("Artifact Type [%s] can not be copied", + artifact.getArtifactTypeName()); + } artifactTransferData.add(artifact); } } @@ -1008,6 +1012,10 @@ public class ArtifactExplorer extends GenericViewPart implements IArtifactExplor Object object = selection.getFirstElement(); if (object instanceof Artifact) { + Artifact artifact = (Artifact) object; + if (!ArtifactTypeManager.isUserCreationAllowed(artifact.getArtifactType())) { + throw new OseeArgumentException("Artifact Type [%s] can not be copied", artifact.getArtifactTypeName()); + } destinationArtifact = (Artifact) object; } } @@ -1331,10 +1339,10 @@ public class ArtifactExplorer extends GenericViewPart implements IArtifactExplor return; } if (accessControlEvent.getEventType() == AccessControlEventType.UserAuthenticated || - // - accessControlEvent.getEventType() == AccessControlEventType.ArtifactsUnlocked || - // - accessControlEvent.getEventType() == AccessControlEventType.ArtifactsLocked) { + // + accessControlEvent.getEventType() == AccessControlEventType.ArtifactsUnlocked || + // + accessControlEvent.getEventType() == AccessControlEventType.ArtifactsLocked) { Displays.ensureInDisplayThread(new Runnable() { @Override public void run() { diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/explorer/menu/CreateRelatedMenuItem.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/explorer/menu/CreateRelatedMenuItem.java index 900377c8523..faa520417d3 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/explorer/menu/CreateRelatedMenuItem.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/explorer/menu/CreateRelatedMenuItem.java @@ -112,9 +112,9 @@ public class CreateRelatedMenuItem implements SelectionListener { // get valid artifact types for this relation List<IArtifactType> artifactTypes = new ArrayList<>(); Branch branch = artifactExplorer.getBranch(); - for (ArtifactType artType : ArtifactTypeManager.getConcreteArtifactTypes(branch)) { - if (relationType.isArtifactTypeAllowed(relationSide, artType)) { - artifactTypes.add(artType); + for (ArtifactType artifactType : ArtifactTypeManager.getConcreteArtifactTypes(branch)) { + if (relationType.isArtifactTypeAllowed(relationSide, artifactType) && ArtifactTypeManager.isUserCreationAllowed(artifactType)) { + artifactTypes.add(artifactType); } } |