diff options
author | donald.g.dunne | 2014-09-15 15:41:52 +0000 |
---|---|---|
committer | Roberto E. Escobar | 2014-10-01 21:04:55 +0000 |
commit | b8e06822c886c165200ad185995350a92953788e (patch) | |
tree | 8d4713afea63730ccb5bacd441d0f495d1a706a8 /plugins | |
parent | a54770b7411aff166b7488461df934090d3a02a5 (diff) | |
download | org.eclipse.osee-b8e06822c886c165200ad185995350a92953788e.tar.gz org.eclipse.osee-b8e06822c886c165200ad185995350a92953788e.tar.xz org.eclipse.osee-b8e06822c886c165200ad185995350a92953788e.zip |
feature[ats_ATS72141]: CPA: Make ATS Program artifact available to eclipse.org
Change-Id: I9e429bfc38be5637d238448f221d9d2b74480b87
Diffstat (limited to 'plugins')
42 files changed, 1159 insertions, 197 deletions
diff --git a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/data/AtsArtifactTypes.java b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/data/AtsArtifactTypes.java index c5d53ac8561..cf3e8fbb9aa 100644 --- a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/data/AtsArtifactTypes.java +++ b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/data/AtsArtifactTypes.java @@ -34,6 +34,7 @@ public final class AtsArtifactTypes { public static final IArtifactType AtsArtifact = TokenFactory.createArtifactType(0x000000000000003FL, "ats.Ats Artifact"); public static final IArtifactType WorkDefinition = TokenFactory.createArtifactType(0x000000000000003EL, "Work Definition"); public static final IArtifactType WorkPackage = TokenFactory.createArtifactType(0x0000000000000322L, "Work Definition"); + public static final IArtifactType Program = TokenFactory.createArtifactType(0x0000BA123443210004L, "Program"); // @formatter:on private AtsArtifactTypes() { diff --git a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/data/AtsAttributeTypes.java b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/data/AtsAttributeTypes.java index 4f0970c4ecb..a062c847523 100644 --- a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/data/AtsAttributeTypes.java +++ b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/data/AtsAttributeTypes.java @@ -145,6 +145,9 @@ public final class AtsAttributeTypes { public static final IAttributeType ProgramUuid = createType(0x10000089157000AAL, "Program Uuid"); public static final IAttributeType Rationale = createType(0x10000089159900AAL, "Rationale"); + // Program + public static final IAttributeType Namespace = createType(0x40E507303063999EL, "Namespace"); + // @formatter:on private static IAttributeType createType(Long guid, String name) { diff --git a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/program/AtsProgram.java b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/program/AtsProgram.java deleted file mode 100644 index 5407eccd233..00000000000 --- a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/program/AtsProgram.java +++ /dev/null @@ -1,35 +0,0 @@ -/******************************************************************************* - * 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.api.program; - -import javax.xml.bind.annotation.XmlRootElement; -import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; -import org.eclipse.osee.framework.jdk.core.type.UuidNamedIdentity; - -/** - * @author Donald G. Dunne - */ -@XmlRootElement -public class AtsProgram extends UuidNamedIdentity<Long> implements IAtsProgram { - - private final boolean active; - - public AtsProgram(String name, Long uuid, boolean active) { - super(uuid, name); - this.active = active; - } - - @Override - public boolean isActive() throws OseeCoreException { - return active; - } - -} diff --git a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/program/IAtsProgram.java b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/program/IAtsProgram.java index abae4c4b39e..1482da408e2 100644 --- a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/program/IAtsProgram.java +++ b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/program/IAtsProgram.java @@ -10,17 +10,21 @@ *******************************************************************************/ package org.eclipse.osee.ats.api.program; +import org.eclipse.osee.ats.api.IAtsConfigObject; +import org.eclipse.osee.ats.api.team.IAtsTeamDefinition; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; /** * @author Donald G. Dunne */ -public interface IAtsProgram { - - public String getName(); +public interface IAtsProgram extends IAtsConfigObject { public boolean isActive() throws OseeCoreException; public Long getUuid(); + public IAtsTeamDefinition getTeamDefinition(); + + public String getNamespace(); + } diff --git a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/team/IAtsConfigItemFactory.java b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/team/IAtsConfigItemFactory.java index 1d12907db7a..618f3dcfad4 100644 --- a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/team/IAtsConfigItemFactory.java +++ b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/team/IAtsConfigItemFactory.java @@ -12,6 +12,7 @@ package org.eclipse.osee.ats.api.team; import org.eclipse.osee.ats.api.IAtsConfigObject; import org.eclipse.osee.ats.api.ai.IAtsActionableItem; +import org.eclipse.osee.ats.api.program.IAtsProgram; import org.eclipse.osee.ats.api.version.IAtsVersion; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; @@ -28,4 +29,6 @@ public interface IAtsConfigItemFactory { IAtsVersion getVersion(Object artifact) throws OseeCoreException; + IAtsProgram getProgram(Object artifact); + } diff --git a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/util/ActiveView.java b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/util/ActiveView.java new file mode 100644 index 00000000000..f4bed8a7e02 --- /dev/null +++ b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/util/ActiveView.java @@ -0,0 +1,30 @@ +/******************************************************************************* + * 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.api.util; + +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +/** + * Annotation on resource methods used to indicate that the return type should include active flag + * + * @author Donald G. Dunne + */ +@Documented +@Retention(RUNTIME) +@Target({TYPE, METHOD}) +public @interface ActiveView { + // +} diff --git a/plugins/org.eclipse.osee.ats.client.demo/src/org/eclipse/osee/ats/client/demo/DemoArtifactToken.java b/plugins/org.eclipse.osee.ats.client.demo/src/org/eclipse/osee/ats/client/demo/DemoArtifactToken.java index bd13ed9244b..54ed523fced 100644 --- a/plugins/org.eclipse.osee.ats.client.demo/src/org/eclipse/osee/ats/client/demo/DemoArtifactToken.java +++ b/plugins/org.eclipse.osee.ats.client.demo/src/org/eclipse/osee/ats/client/demo/DemoArtifactToken.java @@ -28,6 +28,8 @@ public final class DemoArtifactToken { public static IArtifactToken Tools_Team = TokenFactory.createArtifactToken("At2WHxCFyQPidx78iuAA", "Tools_Team", AtsArtifactTypes.TeamDefinition); + public static final IArtifactToken SAW_Program = TokenFactory.createArtifactToken("At2WHxCeMCHacr02EkAA", + "SAW Program", AtsArtifactTypes.Program); public static IArtifactToken SAW_HW = TokenFactory.createArtifactToken("At2WHxCeMCHfcr02EkAA", "SAW_HW", AtsArtifactTypes.TeamDefinition); public static IArtifactToken SAW_Code = TokenFactory.createArtifactToken("At2WHxC2lxLOGB0YiuQA", "SAW_Code", @@ -51,6 +53,8 @@ public final class DemoArtifactToken { public static IArtifactToken SAW_Bld_3 = TokenFactory.createArtifactToken("A8msa8LrcxhyrUTsbuwA", "SAW_Bld_3", AtsArtifactTypes.Version); + public static final IArtifactToken CIS_Program = TokenFactory.createArtifactToken("At2WHxCeMCHbcr02EkAA", + "CIS Program", AtsArtifactTypes.Program); public static IArtifactToken CIS_SW = TokenFactory.createArtifactToken("At2WHxF7jmUa8jXR3iwA", "CIS_SW", AtsArtifactTypes.TeamDefinition); public static IArtifactToken CIS_Code = TokenFactory.createArtifactToken("At2WHxGo4A1nnGWYjgwA", "CIS_Code", diff --git a/plugins/org.eclipse.osee.ats.client.demo/src/org/eclipse/osee/ats/client/demo/config/DemoDatabaseConfig.java b/plugins/org.eclipse.osee.ats.client.demo/src/org/eclipse/osee/ats/client/demo/config/DemoDatabaseConfig.java index 163106825e5..7d2b8ef7392 100644 --- a/plugins/org.eclipse.osee.ats.client.demo/src/org/eclipse/osee/ats/client/demo/config/DemoDatabaseConfig.java +++ b/plugins/org.eclipse.osee.ats.client.demo/src/org/eclipse/osee/ats/client/demo/config/DemoDatabaseConfig.java @@ -60,14 +60,35 @@ public class DemoDatabaseConfig implements IDbInitializationTask { // Create Work Packages createWorkPackages(); + createPrograms(); + } + + private void createPrograms() throws OseeCoreException { + SkynetTransaction transaction = + TransactionManager.createTransaction(AtsUtilCore.getAtsBranch(), "Create Programs"); + + Artifact sawSw = ArtifactQuery.getArtifactFromToken(DemoArtifactToken.SAW_SW, AtsUtilCore.getAtsBranch()); + Artifact sawProgram = ArtifactTypeManager.addArtifact(DemoArtifactToken.SAW_Program, AtsUtilCore.getAtsBranch()); + sawProgram.setSoleAttributeValue(AtsAttributeTypes.Namespace, "org.demo.saw"); + sawProgram.setSoleAttributeValue(AtsAttributeTypes.Description, "Program object for SAW Program"); + sawProgram.setSoleAttributeValue(AtsAttributeTypes.TeamDefinition, sawSw.getGuid()); + sawProgram.persist(transaction); + + Artifact cisSw = ArtifactQuery.getArtifactFromToken(DemoArtifactToken.CIS_SW, AtsUtilCore.getAtsBranch()); + Artifact cisProgram = ArtifactTypeManager.addArtifact(DemoArtifactToken.CIS_Program, AtsUtilCore.getAtsBranch()); + cisProgram.setSoleAttributeValue(AtsAttributeTypes.Namespace, "org.demo.cis"); + cisProgram.setSoleAttributeValue(AtsAttributeTypes.Description, "Program object for CIS Program"); + cisProgram.setSoleAttributeValue(AtsAttributeTypes.TeamDefinition, cisSw.getGuid()); + cisProgram.persist(transaction); + + transaction.execute(); } private void createWorkPackages() throws OseeCoreException { SkynetTransaction transaction = TransactionManager.createTransaction(AtsUtilCore.getAtsBranch(), "Create Work Packages"); - Artifact codeTeamArt = - ArtifactQuery.getArtifactFromToken(DemoArtifactToken.SAW_Code, AtsUtilCore.getAtsBranch()); + Artifact codeTeamArt = ArtifactQuery.getArtifactFromToken(DemoArtifactToken.SAW_Code, AtsUtilCore.getAtsBranch()); Artifact workPkg1 = createWorkPackage(DemoArtifactToken.SAW_Code_Team_WorkPackage_01, "ASDHFA443"); workPkg1.addRelation(AtsRelationTypes.WorkPackage_TeamDefOrAi, codeTeamArt); diff --git a/plugins/org.eclipse.osee.ats.client.integration.tests/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.ats.client.integration.tests/META-INF/MANIFEST.MF index 125159b19b4..8f0731f9728 100644 --- a/plugins/org.eclipse.osee.ats.client.integration.tests/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.osee.ats.client.integration.tests/META-INF/MANIFEST.MF @@ -13,7 +13,10 @@ Require-Bundle: org.junit;bundle-version="4.11.0", org.mockito;bundle-version="1.9.0", org.hamcrest.core, org.objenesis -Import-Package: org.eclipse.nebula.widgets.xviewer, +Import-Package: com.google.gson;version="2.1.0", + javax.ws.rs.client;version="2.0.0", + javax.ws.rs.core;version="2.0.0", + org.eclipse.nebula.widgets.xviewer, org.eclipse.nebula.widgets.xviewer.customize, org.eclipse.nebula.widgets.xviewer.customize.dialog, org.eclipse.osee.ats, @@ -115,6 +118,7 @@ Import-Package: org.eclipse.nebula.widgets.xviewer, org.eclipse.osee.framework.ui.skynet.widgets.util, org.eclipse.osee.framework.ui.skynet.widgets.xnavigate, org.eclipse.osee.framework.ui.swt, + org.eclipse.osee.jaxrs.client, org.eclipse.osee.support.test.util, org.osgi.framework Service-Component: OSGI-INF/*.xml diff --git a/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/config/AbstractConfigurationRestTest.java b/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/config/AbstractConfigurationRestTest.java new file mode 100644 index 00000000000..8990ca63d84 --- /dev/null +++ b/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/config/AbstractConfigurationRestTest.java @@ -0,0 +1,53 @@ +/******************************************************************************* + * 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.ats.config; + +import java.net.URI; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.UriBuilder; +import org.eclipse.osee.framework.core.client.OseeClientProperties; +import org.eclipse.osee.jaxrs.client.JaxRsClient; +import org.junit.Assert; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; + +/** + * @author Donald G. Dunne + */ +public abstract class AbstractConfigurationRestTest { + + protected JsonObject getObjectNamed(String name, JsonArray array) throws Exception { + for (int x = 0; x < array.size(); x++) { + JsonObject obj = (JsonObject) array.get(x); + if (obj.get("Name").getAsString().equals(name)) { + return obj; + } + } + return null; + } + + protected JsonArray getAndCheck(String url) throws Exception { + String appServer = OseeClientProperties.getOseeApplicationServer(); + URI uri = UriBuilder.fromUri(appServer).path(url).build(); + + Response response = JaxRsClient.newClient().target(uri).request(MediaType.APPLICATION_JSON).get(); + Assert.assertEquals(javax.ws.rs.core.Response.Status.OK.getStatusCode(), response.getStatus()); + String json = response.readEntity(String.class); + + JsonParser jp = new JsonParser(); + JsonElement je = jp.parse(json); + return (JsonArray) je; + } + +} diff --git a/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/config/ActionableItemResourceTest.java b/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/config/ActionableItemResourceTest.java new file mode 100644 index 00000000000..3285439008b --- /dev/null +++ b/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/config/ActionableItemResourceTest.java @@ -0,0 +1,70 @@ +/******************************************************************************* + * 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.ats.config; + +import org.eclipse.osee.ats.api.data.AtsArtifactTypes; +import org.eclipse.osee.ats.core.util.AtsUtilCore; +import org.eclipse.osee.framework.skynet.core.artifact.Artifact; +import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery; +import org.junit.Assert; +import org.junit.Test; +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; + +/** + * Unit Test for {@link ActionableItemResource} + * + * @author Donald G. Dunne + */ +public class ActionableItemResourceTest extends AbstractConfigurationRestTest { + + @Test + public void testAtsAisRestCall() throws Exception { + JsonArray array = getAndCheck("/ats/ai"); + Assert.assertEquals(44, array.size()); + JsonObject obj = getObjectNamed("SAW Code", array); + Assert.assertNotNull("Did not find value SAW Code", obj); + Assert.assertFalse(obj.has("ats.Active")); + } + + @Test + public void testAtsAisDetailsRestCall() throws Exception { + JsonArray array = getAndCheck("/ats/ai/details"); + Assert.assertEquals(44, array.size()); + JsonObject obj = getObjectNamed("SAW Code", array); + Assert.assertNotNull("Did not find value SAW Code", obj); + Assert.assertTrue(obj.has("ats.Active")); + } + + @Test + public void testAtsAiRestCall() throws Exception { + JsonArray array = getAndCheck("/ats/ai/" + getSawCodeAi().getArtId()); + Assert.assertEquals(1, array.size()); + JsonObject obj = getObjectNamed("SAW Code", array); + Assert.assertNotNull("Did not find value SAW Code", obj); + Assert.assertFalse(obj.has("ats.Active")); + } + + @Test + public void testAtsAiDetailsRestCall() throws Exception { + JsonArray array = getAndCheck("/ats/ai/" + getSawCodeAi().getArtId() + "/details"); + Assert.assertEquals(1, array.size()); + JsonObject obj = getObjectNamed("SAW Code", array); + Assert.assertNotNull("Did not find value SAW Code", obj); + Assert.assertTrue(obj.has("ats.Active")); + } + + private Artifact getSawCodeAi() { + return ArtifactQuery.getArtifactFromTypeAndName(AtsArtifactTypes.ActionableItem, "SAW Code", + AtsUtilCore.getAtsBranch()); + } + +} diff --git a/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/config/AtsTest_Config_Suite.java b/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/config/AtsTest_Config_Suite.java index 0bacdbfc231..353d7ab665e 100644 --- a/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/config/AtsTest_Config_Suite.java +++ b/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/config/AtsTest_Config_Suite.java @@ -19,7 +19,13 @@ import org.junit.runner.RunWith; import org.junit.runners.Suite; @RunWith(Suite.class) -@Suite.SuiteClasses({AtsTest_Demo_Copy_Suite.class, AtsBranchConfigurationTest.class}) +@Suite.SuiteClasses({ + TeamResourceTest.class, + VersionResourceTest.class, + ProgramResourceTest.class, + ActionableItemResourceTest.class, + AtsTest_Demo_Copy_Suite.class, + AtsBranchConfigurationTest.class}) /** * This test suite contains test that can be run against any production db * diff --git a/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/config/ProgramResourceTest.java b/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/config/ProgramResourceTest.java new file mode 100644 index 00000000000..cfe55b50cb2 --- /dev/null +++ b/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/config/ProgramResourceTest.java @@ -0,0 +1,70 @@ +/******************************************************************************* + * 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.ats.config; + +import org.eclipse.osee.ats.api.data.AtsArtifactTypes; +import org.eclipse.osee.ats.core.util.AtsUtilCore; +import org.eclipse.osee.framework.skynet.core.artifact.Artifact; +import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery; +import org.junit.Assert; +import org.junit.Test; +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; + +/** + * Unit Test for {@link ProgramResource} + * + * @author Donald G. Dunne + */ +public class ProgramResourceTest extends AbstractConfigurationRestTest { + + @Test + public void testAtsProgramsRestCall() throws Exception { + JsonArray array = getAndCheck("/ats/program"); + Assert.assertEquals(2, array.size()); + JsonObject obj = getObjectNamed("SAW Program", array); + Assert.assertNotNull("Did not find value SAW Program", obj); + Assert.assertFalse(obj.has("ats.Description")); + } + + @Test + public void testAtsProgramsDetailsRestCall() throws Exception { + JsonArray array = getAndCheck("/ats/program/details"); + Assert.assertEquals(2, array.size()); + JsonObject obj = getObjectNamed("SAW Program", array); + Assert.assertNotNull("Did not find value SAW Program", obj); + Assert.assertTrue(obj.has("ats.Description")); + } + + @Test + public void testAtsProgramRestCall() throws Exception { + JsonArray array = getAndCheck("/ats/program/" + getSawProgram().getArtId()); + Assert.assertEquals(1, array.size()); + JsonObject obj = getObjectNamed("SAW Program", array); + Assert.assertNotNull("Did not find value SAW Program", obj); + Assert.assertFalse(obj.has("ats.Description")); + } + + @Test + public void testAtsProgramDetailsRestCall() throws Exception { + JsonArray array = getAndCheck("/ats/program/" + getSawProgram().getArtId() + "/details"); + Assert.assertEquals(1, array.size()); + JsonObject obj = getObjectNamed("SAW Program", array); + Assert.assertNotNull("Did not find value SAW Program", obj); + Assert.assertTrue(obj.has("ats.Description")); + } + + private Artifact getSawProgram() { + return ArtifactQuery.getArtifactFromTypeAndName(AtsArtifactTypes.Program, "SAW Program", + AtsUtilCore.getAtsBranch()); + } + +} diff --git a/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/config/TeamResourceTest.java b/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/config/TeamResourceTest.java new file mode 100644 index 00000000000..a7fb25aa922 --- /dev/null +++ b/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/config/TeamResourceTest.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * 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.ats.config; + +import org.eclipse.osee.ats.client.demo.DemoTeam; +import org.eclipse.osee.ats.core.util.AtsUtilCore; +import org.eclipse.osee.framework.skynet.core.artifact.Artifact; +import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery; +import org.junit.Assert; +import org.junit.Test; +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; + +/** + * Unit Test for {@link TeamResource} + * + * @author Donald G. Dunne + */ +public class TeamResourceTest extends AbstractConfigurationRestTest { + + @Test + public void testAtsTeamsRestCall() throws Exception { + JsonArray array = getAndCheck("/ats/team"); + Assert.assertEquals(17, array.size()); + JsonObject obj = getObjectNamed("SAW SW", array); + Assert.assertNotNull(String.format("Did not find value SAW SW in JsonArray [%s]", array), obj); + Assert.assertFalse(obj.has("version")); + Assert.assertFalse(obj.has("ats.Active")); + } + + @Test + public void testAtsTeamsDetailsRestCall() throws Exception { + JsonArray array = getAndCheck("/ats/team/details"); + Assert.assertEquals(17, array.size()); + JsonObject obj = getObjectNamed("SAW SW", array); + Assert.assertNotNull(String.format("Did not find value SAW SW in JsonArray [%s]", array), obj); + Assert.assertEquals(3, obj.getAsJsonArray("version").size()); + Assert.assertTrue(obj.has("ats.Active")); + } + + @Test + public void testAtsTeamRestCall() throws Exception { + JsonArray array = getAndCheck("/ats/team/" + getSawSwTeamDef().getArtId()); + Assert.assertEquals(1, array.size()); + JsonObject obj = getObjectNamed("SAW SW", array); + Assert.assertNotNull(String.format("Did not find value SAW SW in JsonArray [%s]", array), obj); + Assert.assertFalse(obj.has("version")); + Assert.assertFalse(obj.has("ats.Active")); + } + + @Test + public void testAtsTeamDetailsRestCall() throws Exception { + JsonArray array = getAndCheck("/ats/team/" + getSawSwTeamDef().getArtId() + "/details"); + Assert.assertEquals(1, array.size()); + JsonObject obj = getObjectNamed("SAW SW", array); + Assert.assertNotNull(String.format("Did not find value SAW SW in JsonArray [%s]", array), obj); + Assert.assertTrue(obj.has("version")); + Assert.assertTrue(obj.has("ats.Active")); + } + + private Artifact getSawSwTeamDef() { + return ArtifactQuery.getArtifactFromToken(DemoTeam.SAW_SW.getTeamDefToken(), AtsUtilCore.getAtsBranch()); + } +} diff --git a/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/config/VersionResourceTest.java b/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/config/VersionResourceTest.java new file mode 100644 index 00000000000..dde69a0c900 --- /dev/null +++ b/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/config/VersionResourceTest.java @@ -0,0 +1,69 @@ +/******************************************************************************* + * 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.ats.config; + +import org.eclipse.osee.ats.api.data.AtsArtifactTypes; +import org.eclipse.osee.ats.core.util.AtsUtilCore; +import org.eclipse.osee.framework.skynet.core.artifact.Artifact; +import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery; +import org.junit.Assert; +import org.junit.Test; +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; + +/** + * Unit Test for {@link VersionResource} + * + * @author Donald G. Dunne + */ +public class VersionResourceTest extends AbstractConfigurationRestTest { + + @Test + public void testAtsVersionsRestCall() throws Exception { + JsonArray array = getAndCheck("/ats/version"); + Assert.assertEquals(6, array.size()); + JsonObject obj = getObjectNamed("SAW_Bld_1", array); + Assert.assertNotNull("Did not find value SAW_Bld_1", obj); + Assert.assertFalse(obj.has("ats.Released")); + } + + @Test + public void testAtsVersionsDetailsRestCall() throws Exception { + JsonArray array = getAndCheck("/ats/version/details"); + Assert.assertEquals(6, array.size()); + JsonObject obj = getObjectNamed("SAW_Bld_1", array); + Assert.assertNotNull("Did not find value SAW_Bld_1", obj); + Assert.assertTrue(obj.has("ats.Released")); + } + + @Test + public void testAtsVersionRestCall() throws Exception { + JsonArray array = getAndCheck("/ats/version/" + getSawBld1().getArtId()); + Assert.assertEquals(1, array.size()); + JsonObject obj = getObjectNamed("SAW_Bld_1", array); + Assert.assertNotNull("Did not find value SAW_Bld_1", obj); + Assert.assertFalse(obj.has("ats.Released")); + } + + @Test + public void testAtsVersionDetailsRestCall() throws Exception { + JsonArray array = getAndCheck("/ats/version/" + getSawBld1().getArtId() + "/details"); + Assert.assertEquals(1, array.size()); + JsonObject obj = getObjectNamed("SAW_Bld_1", array); + Assert.assertNotNull("Did not find value SAW_Bld_1", obj); + Assert.assertTrue(obj.has("ats.Released")); + } + + private Artifact getSawBld1() { + return ArtifactQuery.getArtifactFromTypeAndName(AtsArtifactTypes.Version, "SAW_Bld_1", AtsUtilCore.getAtsBranch()); + } + +} diff --git a/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/config/AbstractAtsProgramClient.java b/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/config/AbstractAtsProgramClient.java new file mode 100644 index 00000000000..cac95ff9973 --- /dev/null +++ b/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/config/AbstractAtsProgramClient.java @@ -0,0 +1,104 @@ +/******************************************************************************* + * 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.core.client.config; + +import org.eclipse.osee.ats.api.data.AtsAttributeTypes; +import org.eclipse.osee.ats.api.team.IAtsTeamDefinition; +import org.eclipse.osee.ats.core.client.internal.AtsClientService; +import org.eclipse.osee.ats.core.config.AbstractAtsProgram; +import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; +import org.eclipse.osee.framework.skynet.core.artifact.Artifact; + +public abstract class AbstractAtsProgramClient extends AbstractAtsProgram implements IAtsProgramClient { + + IAtsTeamDefinition teamDefinition = null; + private Artifact artifact; + + public AbstractAtsProgramClient(Artifact artifact) { + super((artifact != null ? Long.valueOf(artifact.getArtId()) : 0L), + (artifact != null ? artifact.getName() : "Null")); + this.artifact = artifact; + } + + @Override + public boolean isActive() throws OseeCoreException { + return getArtifact().getSoleAttributeValue(AtsAttributeTypes.Active, false); + } + + @Override + public Object getStoreObject() { + return artifact; + } + + @Override + public void setStoreObject(Object object) { + this.artifact = (Artifact) object; + } + + @Override + public String getName() { + try { + return getArtifact().getName(); + } catch (Exception ex) { + return this.getStaticIdPrefix(); + } + } + + @Override + public IAtsTeamDefinition getTeamDefHoldingVersions() throws OseeCoreException { + return getTeamDefinition(); + } + + @Override + public IAtsTeamDefinition getTeamDefinition() { + if (teamDefinition == null) { + AtsClientService.get().getConfig().getSoleByGuid( + artifact.getSoleAttributeValue(AtsAttributeTypes.TeamDefinition, ""), IAtsTeamDefinition.class); + } + return teamDefinition; + } + + @Override + public String getStaticIdPrefix() { + return artifact.getSoleAttributeValue(AtsAttributeTypes.Namespace, ""); + } + + @Override + public String getProgramName() throws OseeCoreException { + return getName(); + } + + @Override + public Artifact getArtifact() throws OseeCoreException { + return artifact; + } + + @Override + public void setArtifact(Artifact artifact) throws OseeCoreException { + this.artifact = artifact; + } + + @Override + public String getGuid() { + return artifact.getGuid(); + } + + @Override + public String getDescription() { + return artifact.getSoleAttributeValue(AtsAttributeTypes.Description, ""); + } + + @Override + public String getNamespace() { + return getStaticIdPrefix(); + } + +} diff --git a/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/config/IAtsProgram.java b/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/config/IAtsProgramClient.java index 05a7bf05664..20aabfda76a 100644 --- a/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/config/IAtsProgram.java +++ b/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/config/IAtsProgramClient.java @@ -3,13 +3,14 @@ * 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 + * http://www.eclipse.org/legal/eplv10.html * * Contributors: - * Boeing - initial API and implementation + * Boeing initial API and implementation *******************************************************************************/ package org.eclipse.osee.ats.core.client.config; +import org.eclipse.osee.ats.api.program.IAtsProgram; import org.eclipse.osee.ats.api.team.IAtsTeamDefinition; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.framework.skynet.core.artifact.Artifact; @@ -17,20 +18,15 @@ import org.eclipse.osee.framework.skynet.core.artifact.Artifact; /** * @author Donald G. Dunne */ -public interface IAtsProgram extends org.eclipse.osee.ats.api.program.IAtsProgram { - - @Override - public String getName(); - - @Override - public boolean isActive() throws OseeCoreException; +public interface IAtsProgramClient extends IAtsProgram { public Artifact getArtifact() throws OseeCoreException; + public void setArtifact(Artifact artifact) throws OseeCoreException; + public String getStaticIdPrefix() throws OseeCoreException; public String getProgramName() throws OseeCoreException; public IAtsTeamDefinition getTeamDefHoldingVersions() throws OseeCoreException; - } diff --git a/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/config/IAtsProgramManager.java b/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/config/IAtsProgramManager.java index 5ad75c7b818..b147636ede0 100644 --- a/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/config/IAtsProgramManager.java +++ b/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/config/IAtsProgramManager.java @@ -29,13 +29,13 @@ public interface IAtsProgramManager { public String getName(); - public Collection<? extends IAtsProgram> getPrograms() throws OseeCoreException; + public Collection<? extends IAtsProgramClient> getPrograms() throws OseeCoreException; public void reloadCache() throws OseeCoreException; public String getXProgramComboWidgetName(); - public IAtsProgram getProgram(TeamWorkFlowArtifact teamArt) throws OseeCoreException; + public IAtsProgramClient getProgram(TeamWorkFlowArtifact teamArt) throws OseeCoreException; public IArtifactToken getWcafeReviewAssigneeUserGroup() throws OseeCoreException; diff --git a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/config/AbstractAtsProgram.java b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/config/AbstractAtsProgram.java new file mode 100644 index 00000000000..c16fa6c8a55 --- /dev/null +++ b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/config/AbstractAtsProgram.java @@ -0,0 +1,38 @@ +/******************************************************************************* + * 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.core.config; + +import org.eclipse.osee.ats.api.program.IAtsProgram; +import org.eclipse.osee.framework.jdk.core.type.Identity; +import org.eclipse.osee.framework.jdk.core.type.UuidNamedIdentity; + +public abstract class AbstractAtsProgram extends UuidNamedIdentity<Long> implements IAtsProgram { + + public AbstractAtsProgram(Long uid, String name) { + super(uid, name); + } + + @Override + public String toStringWithId() { + return String.format("[%s][%s]", getUuid(), getName()); + } + + @Override + public boolean matches(Identity<?>... identities) { + for (Identity<?> identity : identities) { + if (equals(identity)) { + return true; + } + } + return false; + } + +} diff --git a/plugins/org.eclipse.osee.ats.impl/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.ats.impl/META-INF/MANIFEST.MF index 10dda2a04dd..37e85ee67fe 100644 --- a/plugins/org.eclipse.osee.ats.impl/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.osee.ats.impl/META-INF/MANIFEST.MF @@ -13,6 +13,7 @@ Import-Package: com.google.inject, org.eclipse.osee.ats.api.commit, org.eclipse.osee.ats.api.data, org.eclipse.osee.ats.api.notify, + org.eclipse.osee.ats.api.program, org.eclipse.osee.ats.api.review, org.eclipse.osee.ats.api.team, org.eclipse.osee.ats.api.user, @@ -40,6 +41,7 @@ Import-Package: com.google.inject, org.eclipse.osee.framework.jdk.core.type, org.eclipse.osee.framework.jdk.core.util, org.eclipse.osee.framework.logging, + org.eclipse.osee.jaxrs.mvc, org.eclipse.osee.logger, org.eclipse.osee.mail.api, org.eclipse.osee.orcs, @@ -53,4 +55,5 @@ Bundle-ActivationPolicy: lazy Require-Bundle: org.eclipse.core.runtime Export-Package: org.eclipse.osee.ats.impl, org.eclipse.osee.ats.impl.action, + org.eclipse.osee.ats.impl.config, org.eclipse.osee.ats.impl.resource diff --git a/plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/config/AbstractConfigResource.java b/plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/config/AbstractConfigResource.java new file mode 100644 index 00000000000..f917ad4d8ee --- /dev/null +++ b/plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/config/AbstractConfigResource.java @@ -0,0 +1,81 @@ +/******************************************************************************* + * 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.impl.config; + +import java.util.ArrayList; +import java.util.List; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import org.eclipse.osee.ats.api.IAtsConfigObject; +import org.eclipse.osee.ats.impl.IAtsServer; +import org.eclipse.osee.framework.core.data.IArtifactType; +import org.eclipse.osee.jaxrs.mvc.IdentityView; +import org.eclipse.osee.orcs.data.ArtifactReadable; + +/** + * @author Donald G. Dunne + */ +public abstract class AbstractConfigResource { + + private final IAtsServer atsServer; + private final IArtifactType artifactType; + + public AbstractConfigResource(IArtifactType artifactType, IAtsServer atsServer) { + this.artifactType = artifactType; + this.atsServer = atsServer; + } + + @GET + @IdentityView + @Produces(MediaType.APPLICATION_JSON) + public List<IAtsConfigObject> get() throws Exception { + return getObjects(); + } + + @GET + @Path("details") + @Produces(MediaType.APPLICATION_JSON) + public List<IAtsConfigObject> getObjectsJson() throws Exception { + return getObjects(); + } + + @GET + @Path("{uuid}") + @IdentityView + @Produces(MediaType.APPLICATION_JSON) + public IAtsConfigObject getObjectJson(@PathParam("uuid") int uuid) throws Exception { + return getObject(uuid); + } + + @GET + @Path("{uuid}/details") + @Produces(MediaType.APPLICATION_JSON) + public IAtsConfigObject getObjectDetails(@PathParam("uuid") int uuid) throws Exception { + return getObject(uuid); + } + + private IAtsConfigObject getObject(int uuid) { + ArtifactReadable configArt = atsServer.getQuery().andLocalId(Integer.valueOf(uuid)).getResults().getExactlyOne(); + return atsServer.getConfigItemFactory().getConfigObject(configArt); + } + + private List<IAtsConfigObject> getObjects() { + List<IAtsConfigObject> configs = new ArrayList<IAtsConfigObject>(); + for (ArtifactReadable art : atsServer.getQuery().andIsOfType(artifactType).getResults()) { + configs.add(atsServer.getConfigItemFactory().getConfigObject(art)); + } + return configs; + } + +} diff --git a/plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/internal/workitem/ConfigItemFactory.java b/plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/internal/workitem/ConfigItemFactory.java index 3cc344114dc..4ffaed30a59 100644 --- a/plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/internal/workitem/ConfigItemFactory.java +++ b/plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/internal/workitem/ConfigItemFactory.java @@ -13,6 +13,7 @@ package org.eclipse.osee.ats.impl.internal.workitem; import org.eclipse.osee.ats.api.IAtsConfigObject; import org.eclipse.osee.ats.api.ai.IAtsActionableItem; import org.eclipse.osee.ats.api.data.AtsArtifactTypes; +import org.eclipse.osee.ats.api.program.IAtsProgram; import org.eclipse.osee.ats.api.team.IAtsConfigItemFactory; import org.eclipse.osee.ats.api.team.IAtsTeamDefinition; import org.eclipse.osee.ats.api.version.IAtsVersion; @@ -46,6 +47,8 @@ public class ConfigItemFactory implements IAtsConfigItemFactory { configObject = getTeamDef(artRead); } else if (artRead.isOfType(AtsArtifactTypes.ActionableItem)) { configObject = getActionableItem(artRead); + } else if (artRead.isOfType(AtsArtifactTypes.Program)) { + configObject = getProgram(artRead); } } } catch (OseeCoreException ex) { @@ -60,7 +63,7 @@ public class ConfigItemFactory implements IAtsConfigItemFactory { if (artifact instanceof ArtifactReadable) { ArtifactReadable artRead = (ArtifactReadable) artifact; if (artRead.isOfType(AtsArtifactTypes.Version)) { - version = new Version(logger, atsServer, (ArtifactReadable) artifact); + version = new Version(logger, atsServer, artRead); } } return version; @@ -72,7 +75,7 @@ public class ConfigItemFactory implements IAtsConfigItemFactory { if (artifact instanceof ArtifactReadable) { ArtifactReadable artRead = (ArtifactReadable) artifact; if (artRead.isOfType(AtsArtifactTypes.TeamDefinition)) { - teamDef = new TeamDefinition(logger, atsServer, (ArtifactReadable) artifact); + teamDef = new TeamDefinition(logger, atsServer, artRead); } } return teamDef; @@ -84,10 +87,22 @@ public class ConfigItemFactory implements IAtsConfigItemFactory { if (artifact instanceof ArtifactReadable) { ArtifactReadable artRead = (ArtifactReadable) artifact; if (artRead.isOfType(AtsArtifactTypes.ActionableItem)) { - ai = new ActionableItem(logger, atsServer, (ArtifactReadable) artifact); + ai = new ActionableItem(logger, atsServer, artRead); } } return ai; } + @Override + public IAtsProgram getProgram(Object artifact) { + IAtsProgram program = null; + if (artifact instanceof ArtifactReadable) { + ArtifactReadable artRead = (ArtifactReadable) artifact; + if (artRead.isOfType(AtsArtifactTypes.Program)) { + program = new Program(logger, atsServer, artRead); + } + } + return program; + } + } diff --git a/plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/internal/workitem/Program.java b/plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/internal/workitem/Program.java new file mode 100644 index 00000000000..229fa1f6ecb --- /dev/null +++ b/plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/internal/workitem/Program.java @@ -0,0 +1,54 @@ +/******************************************************************************* + * 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.impl.internal.workitem; + +import org.eclipse.osee.ats.api.data.AtsAttributeTypes; +import org.eclipse.osee.ats.api.program.IAtsProgram; +import org.eclipse.osee.ats.api.team.IAtsTeamDefinition; +import org.eclipse.osee.ats.impl.IAtsServer; +import org.eclipse.osee.logger.Log; +import org.eclipse.osee.orcs.data.ArtifactReadable; + +/** + * @author Donald G Dunne + */ +public class Program extends AtsConfigObject implements IAtsProgram { + IAtsTeamDefinition teamDefinition = null; + + public Program(Log logger, IAtsServer atsServer, ArtifactReadable artifact) { + super(logger, atsServer, artifact); + } + + @Override + public String getTypeName() { + return "Program"; + } + + @Override + public Long getUuid() { + return artifact.getLocalId().longValue(); + } + + @Override + public IAtsTeamDefinition getTeamDefinition() { + if (teamDefinition == null) { + getAtsServer().getConfig().getSoleByGuid(artifact.getSoleAttributeValue(AtsAttributeTypes.TeamDefinition, ""), + IAtsTeamDefinition.class); + } + return teamDefinition; + } + + @Override + public String getNamespace() { + return artifact.getSoleAttributeValue(AtsAttributeTypes.Namespace, ""); + } + +} diff --git a/plugins/org.eclipse.osee.ats.rest/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.ats.rest/META-INF/MANIFEST.MF index db93fa28f86..019d7057934 100644 --- a/plugins/org.eclipse.osee.ats.rest/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.osee.ats.rest/META-INF/MANIFEST.MF @@ -15,15 +15,18 @@ Import-Package: com.google.gson;version="2.1.0", javax.ws.rs.core, javax.ws.rs.ext, org.apache.commons.lang, + org.codehaus.jackson;version="1.9.13", org.eclipse.osee.ats.api, org.eclipse.osee.ats.api.ai, org.eclipse.osee.ats.api.config, org.eclipse.osee.ats.api.cpa, org.eclipse.osee.ats.api.data, org.eclipse.osee.ats.api.notify, + org.eclipse.osee.ats.api.program, org.eclipse.osee.ats.api.team, org.eclipse.osee.ats.api.user, org.eclipse.osee.ats.api.util, + org.eclipse.osee.ats.api.version, org.eclipse.osee.ats.api.workdef, org.eclipse.osee.ats.api.workflow, org.eclipse.osee.ats.api.workflow.state, @@ -36,6 +39,7 @@ Import-Package: com.google.gson;version="2.1.0", org.eclipse.osee.ats.core.workflow.transition, org.eclipse.osee.ats.impl, org.eclipse.osee.ats.impl.action, + org.eclipse.osee.ats.impl.config, org.eclipse.osee.ats.impl.resource, org.eclipse.osee.framework.core.data, org.eclipse.osee.framework.core.enums, @@ -46,6 +50,7 @@ Import-Package: com.google.gson;version="2.1.0", org.eclipse.osee.framework.jdk.core.type, org.eclipse.osee.framework.jdk.core.util, org.eclipse.osee.jaxrs, + org.eclipse.osee.jaxrs.mvc, org.eclipse.osee.logger, org.eclipse.osee.orcs, org.eclipse.osee.orcs.data, diff --git a/plugins/org.eclipse.osee.ats.rest/OSGI-INF/config.json.writer.xml b/plugins/org.eclipse.osee.ats.rest/OSGI-INF/config.json.writer.xml new file mode 100644 index 00000000000..602ec02fd88 --- /dev/null +++ b/plugins/org.eclipse.osee.ats.rest/OSGI-INF/config.json.writer.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8"?> +<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" activate="start" deactivate="stop"> + <implementation class="org.eclipse.osee.ats.rest.internal.config.ConfigJsonWriter"/> + <service> + <provide interface="java.lang.Object"/> + <provide interface="javax.ws.rs.ext.MessageBodyWriter"/> + </service> + <reference bind="setAtsServer" cardinality="1..1" interface="org.eclipse.osee.ats.impl.IAtsServer" name="IAtsServer" policy="static"/> +</scr:component> diff --git a/plugins/org.eclipse.osee.ats.rest/OSGI-INF/configs.json.writer.xml b/plugins/org.eclipse.osee.ats.rest/OSGI-INF/configs.json.writer.xml new file mode 100644 index 00000000000..55995042a71 --- /dev/null +++ b/plugins/org.eclipse.osee.ats.rest/OSGI-INF/configs.json.writer.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8"?> +<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" activate="start" deactivate="stop"> + <implementation class="org.eclipse.osee.ats.rest.internal.config.ConfigsJsonWriter"/> + <service> + <provide interface="java.lang.Object"/> + <provide interface="javax.ws.rs.ext.MessageBodyWriter"/> + </service> + <reference bind="setAtsServer" cardinality="1..1" interface="org.eclipse.osee.ats.impl.IAtsServer" name="IAtsServer" policy="static"/> +</scr:component> diff --git a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/AtsApplication.java b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/AtsApplication.java index 4da90e73ede..d2f08f842ba 100644 --- a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/AtsApplication.java +++ b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/AtsApplication.java @@ -17,14 +17,16 @@ import javax.ws.rs.core.Application; import org.eclipse.osee.ats.impl.IAtsServer; import org.eclipse.osee.ats.impl.resource.AtsResourceTokens; import org.eclipse.osee.ats.rest.internal.build.report.resources.BuildTraceReportResource; +import org.eclipse.osee.ats.rest.internal.config.ActionableItemResource; +import org.eclipse.osee.ats.rest.internal.config.ProgramResource; +import org.eclipse.osee.ats.rest.internal.config.TeamResource; +import org.eclipse.osee.ats.rest.internal.config.VersionResource; import org.eclipse.osee.ats.rest.internal.cpa.CpaResource; import org.eclipse.osee.ats.rest.internal.cpa.CpaServiceRegistry; import org.eclipse.osee.ats.rest.internal.resources.ActionResource; import org.eclipse.osee.ats.rest.internal.resources.AtsUiResource; import org.eclipse.osee.ats.rest.internal.resources.ConvertResource; -import org.eclipse.osee.ats.rest.internal.resources.TeamResource; import org.eclipse.osee.ats.rest.internal.resources.UserResource; -import org.eclipse.osee.ats.rest.internal.resources.VersionResource; import org.eclipse.osee.framework.jdk.core.type.IResourceRegistry; import org.eclipse.osee.framework.jdk.core.type.ResourceRegistry; import org.eclipse.osee.logger.Log; @@ -66,11 +68,15 @@ public class AtsApplication extends Application { AtsRestTemplateTokens.register(registry); OseeTemplateTokens.register(registry); + // Config resources + singletons.add(new VersionResource(atsServer)); + singletons.add(new TeamResource(atsServer)); + singletons.add(new ProgramResource(atsServer)); + singletons.add(new ActionableItemResource(atsServer)); + singletons.add(new BuildTraceReportResource(logger, registry, orcsApi)); singletons.add(new ActionResource(atsServer, orcsApi, registry)); singletons.add(new ConvertResource(atsServer, registry)); - singletons.add(new TeamResource(atsServer)); - singletons.add(new VersionResource(atsServer)); singletons.add(new CpaResource(orcsApi, atsServer, cpaRegistry)); singletons.add(new UserResource(atsServer.getUserService())); diff --git a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/ActionableItemResource.java b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/ActionableItemResource.java new file mode 100644 index 00000000000..59dd29108d9 --- /dev/null +++ b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/ActionableItemResource.java @@ -0,0 +1,28 @@ +/******************************************************************************* + * 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.rest.internal.config; + +import javax.ws.rs.Path; +import org.eclipse.osee.ats.api.data.AtsArtifactTypes; +import org.eclipse.osee.ats.impl.IAtsServer; +import org.eclipse.osee.ats.impl.config.AbstractConfigResource; + +/** + * Donald G. Dunne + */ +@Path("ai") +public class ActionableItemResource extends AbstractConfigResource { + + public ActionableItemResource(IAtsServer atsServer) { + super(AtsArtifactTypes.ActionableItem, atsServer); + } + +} diff --git a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/ConfigJsonWriter.java b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/ConfigJsonWriter.java new file mode 100644 index 00000000000..00069aa9cad --- /dev/null +++ b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/ConfigJsonWriter.java @@ -0,0 +1,160 @@ +package org.eclipse.osee.ats.rest.internal.config; + +import java.io.IOException; +import java.io.OutputStream; +import java.lang.annotation.Annotation; +import java.lang.reflect.Type; +import java.util.Collection; +import java.util.List; +import javax.ws.rs.WebApplicationException; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.MultivaluedMap; +import javax.ws.rs.ext.MessageBodyWriter; +import javax.ws.rs.ext.Provider; +import org.codehaus.jackson.JsonFactory; +import org.codehaus.jackson.JsonGenerationException; +import org.codehaus.jackson.JsonGenerator; +import org.codehaus.jackson.JsonProcessingException; +import org.eclipse.osee.ats.api.IAtsConfigObject; +import org.eclipse.osee.ats.api.data.AtsRelationTypes; +import org.eclipse.osee.ats.api.program.IAtsProgram; +import org.eclipse.osee.ats.api.team.IAtsTeamDefinition; +import org.eclipse.osee.ats.api.version.IAtsVersion; +import org.eclipse.osee.ats.impl.IAtsServer; +import org.eclipse.osee.framework.core.data.IAttributeType; +import org.eclipse.osee.framework.jdk.core.type.ResultSet; +import org.eclipse.osee.jaxrs.mvc.IdentityView; +import org.eclipse.osee.orcs.data.ArtifactReadable; +import org.eclipse.osee.orcs.data.AttributeReadable; +import org.eclipse.osee.orcs.data.AttributeTypes; + +/** + * @author Donald G. Dunne + */ +@Provider +public class ConfigJsonWriter implements MessageBodyWriter<IAtsConfigObject> { + + private JsonFactory jsonFactory; + private IAtsServer atsServer; + + public void setAtsServer(IAtsServer atsServer) { + this.atsServer = atsServer; + } + + public void start() { + jsonFactory = new JsonFactory(); + } + + public void stop() { + jsonFactory = null; + } + + @Override + public long getSize(IAtsConfigObject data, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) { + return -1; + } + + @Override + public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) { + boolean assignableFrom = IAtsConfigObject.class.isAssignableFrom(type); + return assignableFrom && MediaType.APPLICATION_JSON_TYPE.equals(mediaType); + } + + private boolean matches(Class<? extends Annotation> toMatch, Annotation[] annotations) { + for (Annotation annotation : annotations) { + if (annotation.annotationType().isAssignableFrom(toMatch)) { + return true; + } + } + return false; + } + + private AttributeTypes getAttributeTypes() { + return atsServer.getOrcsApi().getOrcsTypes(null).getAttributeTypes(); + } + + @Override + public void writeTo(IAtsConfigObject config, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException, WebApplicationException { + JsonGenerator writer = null; + try { + writer = jsonFactory.createJsonGenerator(entityStream); + writer.writeStartArray(); + addProgramObject(atsServer, config, annotations, writer, matches(IdentityView.class, annotations), + getAttributeTypes()); + writer.writeEndArray(); + } finally { + if (writer != null) { + writer.flush(); + } + } + } + + public static void addProgramObject(IAtsServer atsServer, IAtsConfigObject config, Annotation[] annotations, JsonGenerator writer, boolean identityView, AttributeTypes attributeTypes) throws IOException, JsonGenerationException, JsonProcessingException { + ArtifactReadable artifact = (ArtifactReadable) config.getStoreObject(); + writer.writeStartObject(); + writer.writeNumberField("uuid", getUuid(config)); + writer.writeStringField("Name", config.getName()); + writer.writeStringField("Description", config.getDescription()); + + if (config instanceof IAtsTeamDefinition) { + if (!identityView) { + writer.writeArrayFieldStart("version"); + for (ArtifactReadable verArt : artifact.getRelated(AtsRelationTypes.TeamDefinitionToVersion_Version)) { + IAtsVersion version = atsServer.getConfig().getSoleByGuid(verArt.getGuid(), IAtsVersion.class); + addProgramObject(atsServer, version, annotations, writer, true, attributeTypes); + } + writer.writeEndArray(); + } + } + if (config instanceof IAtsVersion) { + if (!identityView) { + writer.writeArrayFieldStart("workflow"); + for (ArtifactReadable workArt : artifact.getRelated(AtsRelationTypes.TeamWorkflowTargetedForVersion_Workflow)) { + addArtifactIdentity(writer, workArt); + } + writer.writeEndArray(); + } + } else if (config instanceof IAtsProgram) { + IAtsProgram program = (IAtsProgram) config; + writer.writeStringField("Namespace", program.getNamespace()); + writer.writeBooleanField("Active", program.isActive()); + } + if (!identityView) { + Collection<? extends IAttributeType> attrTypes = attributeTypes.getAll(); + ResultSet<? extends AttributeReadable<Object>> attributes = artifact.getAttributes(); + if (!attributes.isEmpty()) { + for (IAttributeType attrType : attrTypes) { + if (artifact.isAttributeTypeValid(attrType)) { + List<Object> attributeValues = artifact.getAttributeValues(attrType); + if (!attributeValues.isEmpty()) { + + if (attributeValues.size() > 1) { + writer.writeArrayFieldStart(attrType.getName()); + for (Object value : attributeValues) { + writer.writeObject(value); + } + writer.writeEndArray(); + } else if (attributeValues.size() == 1) { + Object value = attributeValues.iterator().next(); + writer.writeObjectField(attrType.getName(), value); + } + + } + } + } + } + } + writer.writeEndObject(); + } + + private static void addArtifactIdentity(JsonGenerator writer, ArtifactReadable workArt) throws IOException, JsonGenerationException, JsonProcessingException { + writer.writeStartObject(); + writer.writeNumberField("uuid", workArt.getLocalId()); + writer.writeStringField("Name", workArt.getName()); + writer.writeEndObject(); + } + + private static Long getUuid(IAtsConfigObject config) { + return ((ArtifactReadable) config.getStoreObject()).getLocalId().longValue(); + } +}
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/ConfigsJsonWriter.java b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/ConfigsJsonWriter.java new file mode 100644 index 00000000000..d19778a3cb6 --- /dev/null +++ b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/ConfigsJsonWriter.java @@ -0,0 +1,95 @@ +package org.eclipse.osee.ats.rest.internal.config; + +import java.io.IOException; +import java.io.OutputStream; +import java.lang.annotation.Annotation; +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; +import java.util.Collection; +import javax.ws.rs.WebApplicationException; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.MultivaluedMap; +import javax.ws.rs.ext.MessageBodyWriter; +import javax.ws.rs.ext.Provider; +import org.codehaus.jackson.JsonFactory; +import org.codehaus.jackson.JsonGenerator; +import org.eclipse.osee.ats.api.IAtsConfigObject; +import org.eclipse.osee.ats.impl.IAtsServer; +import org.eclipse.osee.jaxrs.mvc.IdentityView; +import org.eclipse.osee.orcs.data.AttributeTypes; + +/** + * @author Donald G. Dunne + */ +@Provider +public class ConfigsJsonWriter implements MessageBodyWriter<Collection<IAtsConfigObject>> { + + private JsonFactory jsonFactory; + + private IAtsServer atsServer; + + public void setAtsServer(IAtsServer atsServer) { + this.atsServer = atsServer; + } + + public void start() { + jsonFactory = new JsonFactory(); + } + + public void stop() { + jsonFactory = null; + } + + @Override + public long getSize(Collection<IAtsConfigObject> data, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) { + return -1; + } + + @Override + public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) { + boolean isWriteable = false; + if (Collection.class.isAssignableFrom(type) && genericType instanceof ParameterizedType) { + ParameterizedType parameterizedType = (ParameterizedType) genericType; + Type[] actualTypeArgs = parameterizedType.getActualTypeArguments(); + if (actualTypeArgs.length == 1) { + Type t = actualTypeArgs[0]; + if (t instanceof Class) { + Class<?> clazz = (Class<?>) t; + isWriteable = IAtsConfigObject.class.isAssignableFrom(clazz); + } + } + } + return isWriteable; + } + + private boolean matches(Class<? extends Annotation> toMatch, Annotation[] annotations) { + for (Annotation annotation : annotations) { + if (annotation.annotationType().isAssignableFrom(toMatch)) { + return true; + } + } + return false; + } + + private AttributeTypes getAttributeTypes() { + return atsServer.getOrcsApi().getOrcsTypes(null).getAttributeTypes(); + } + + @Override + public void writeTo(Collection<IAtsConfigObject> programs, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException, WebApplicationException { + JsonGenerator writer = null; + try { + writer = jsonFactory.createJsonGenerator(entityStream); + writer.writeStartArray(); + for (IAtsConfigObject program : programs) { + ConfigJsonWriter.addProgramObject(atsServer, program, annotations, writer, + matches(IdentityView.class, annotations), getAttributeTypes()); + } + writer.writeEndArray(); + } finally { + if (writer != null) { + writer.flush(); + } + } + } +}
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/ProgramResource.java b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/ProgramResource.java new file mode 100644 index 00000000000..f100e57fecd --- /dev/null +++ b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/ProgramResource.java @@ -0,0 +1,28 @@ +/******************************************************************************* + * 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.rest.internal.config; + +import javax.ws.rs.Path; +import org.eclipse.osee.ats.api.data.AtsArtifactTypes; +import org.eclipse.osee.ats.impl.IAtsServer; +import org.eclipse.osee.ats.impl.config.AbstractConfigResource; + +/** + * Donald G. Dunne + */ +@Path("program") +public class ProgramResource extends AbstractConfigResource { + + public ProgramResource(IAtsServer atsServer) { + super(AtsArtifactTypes.Program, atsServer); + } + +} diff --git a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/TeamResource.java b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/TeamResource.java new file mode 100644 index 00000000000..1599c7b7687 --- /dev/null +++ b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/TeamResource.java @@ -0,0 +1,28 @@ +/******************************************************************************* + * 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.rest.internal.config; + +import javax.ws.rs.Path; +import org.eclipse.osee.ats.api.data.AtsArtifactTypes; +import org.eclipse.osee.ats.impl.IAtsServer; +import org.eclipse.osee.ats.impl.config.AbstractConfigResource; + +/** + * Donald G. Dunne + */ +@Path("team") +public class TeamResource extends AbstractConfigResource { + + public TeamResource(IAtsServer atsServer) { + super(AtsArtifactTypes.TeamDefinition, atsServer); + } + +} diff --git a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/VersionResource.java b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/VersionResource.java new file mode 100644 index 00000000000..5913cfd8a07 --- /dev/null +++ b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/VersionResource.java @@ -0,0 +1,28 @@ +/******************************************************************************* + * 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.rest.internal.config; + +import javax.ws.rs.Path; +import org.eclipse.osee.ats.api.data.AtsArtifactTypes; +import org.eclipse.osee.ats.impl.IAtsServer; +import org.eclipse.osee.ats.impl.config.AbstractConfigResource; + +/** + * Donald G. Dunne + */ +@Path("version") +public class VersionResource extends AbstractConfigResource { + + public VersionResource(IAtsServer atsServer) { + super(AtsArtifactTypes.Version, atsServer); + } + +} diff --git a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/resources/TeamResource.java b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/resources/TeamResource.java deleted file mode 100644 index 142891f51f3..00000000000 --- a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/resources/TeamResource.java +++ /dev/null @@ -1,59 +0,0 @@ -/******************************************************************************* - * 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.rest.internal.resources; - -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; -import org.eclipse.osee.ats.api.data.AtsArtifactTypes; -import org.eclipse.osee.ats.api.data.AtsRelationTypes; -import org.eclipse.osee.ats.impl.IAtsServer; -import org.eclipse.osee.framework.jdk.core.type.ResultSet; -import org.eclipse.osee.orcs.data.ArtifactReadable; -import org.eclipse.osee.orcs.utility.RestUtil; -import org.json.JSONArray; -import org.json.JSONObject; - -/** - * @author Donald G. Dunne - */ -@Path("team") -public final class TeamResource { - - private final IAtsServer atsServer; - - public TeamResource(IAtsServer atsServer) { - this.atsServer = atsServer; - } - - @GET - @Produces(MediaType.APPLICATION_JSON) - public String get() throws Exception { - ResultSet<ArtifactReadable> artifacts = - atsServer.getQuery().andTypeEquals(AtsArtifactTypes.TeamDefinition).getResults(); - JSONArray jsonArray = RestUtil.getDefaultJSonArray(artifacts); - return RestUtil.jsonToPretty(jsonArray, true); - } - - @GET - @Path("{uuid}") - @Produces(MediaType.APPLICATION_JSON) - public String getTeam(@PathParam("uuid") int uuid) throws Exception { - ArtifactReadable teamArt = atsServer.getQuery().andLocalId(Integer.valueOf(uuid)).getResults().getExactlyOne(); - JSONObject team = RestUtil.getDefaultJSon(teamArt); - team.put("versions", - RestUtil.getDefaultJSonArray(teamArt.getRelated(AtsRelationTypes.TeamDefinitionToVersion_Version))); - return RestUtil.jsonToPretty(team, true); - } - -} diff --git a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/resources/VersionResource.java b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/resources/VersionResource.java deleted file mode 100644 index 6cab47a090c..00000000000 --- a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/resources/VersionResource.java +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************* - * 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.rest.internal.resources; - -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; -import org.eclipse.osee.ats.api.data.AtsArtifactTypes; -import org.eclipse.osee.ats.api.data.AtsRelationTypes; -import org.eclipse.osee.ats.impl.IAtsServer; -import org.eclipse.osee.framework.jdk.core.type.ResultSet; -import org.eclipse.osee.orcs.data.ArtifactReadable; -import org.eclipse.osee.orcs.utility.RestUtil; -import org.json.JSONArray; -import org.json.JSONObject; - -/** - * @author Donald G. Dunne - */ -@Path("version") -public final class VersionResource { - - private final IAtsServer atsServer; - - public VersionResource(IAtsServer atsServer) { - this.atsServer = atsServer; - } - - @GET - @Produces(MediaType.APPLICATION_JSON) - public String get() throws Exception { - ResultSet<ArtifactReadable> artifacts = atsServer.getQuery().andTypeEquals(AtsArtifactTypes.Version).getResults(); - JSONArray jsonArray = RestUtil.getDefaultJSonArray(artifacts); - return RestUtil.jsonToPretty(jsonArray, true); - } - - @GET - @Path("{uuid}") - @Produces(MediaType.APPLICATION_JSON) - public String getVersion(@PathParam("uuid") int uuid) throws Exception { - ArtifactReadable verArt = atsServer.getQuery().andLocalId(Integer.valueOf(uuid)).getResults().getExactlyOne(); - JSONObject version = RestUtil.getDefaultJSon(verArt); - version.put("workflows", - RestUtil.getDefaultJSonArray(verArt.getRelated(AtsRelationTypes.TeamWorkflowTargetedForVersion_Workflow))); - return RestUtil.jsonToPretty(version, true); - } - -} diff --git a/plugins/org.eclipse.osee.ats/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.ats/META-INF/MANIFEST.MF index e2138fcddd9..f1a5a379052 100644 --- a/plugins/org.eclipse.osee.ats/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.osee.ats/META-INF/MANIFEST.MF @@ -74,6 +74,7 @@ Import-Package: com.google.gson, org.eclipse.osee.ats.api.data, org.eclipse.osee.ats.api.ev, org.eclipse.osee.ats.api.notify, + org.eclipse.osee.ats.api.program, org.eclipse.osee.ats.api.query, org.eclipse.osee.ats.api.review, org.eclipse.osee.ats.api.rule, diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/operation/DetailedTestStatusBlam.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/operation/DetailedTestStatusBlam.java index c864d3bea5d..ba2a391bb86 100644 --- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/operation/DetailedTestStatusBlam.java +++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/operation/DetailedTestStatusBlam.java @@ -35,7 +35,7 @@ import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.osee.ats.api.data.AtsAttributeTypes; import org.eclipse.osee.ats.api.user.IAtsUser; import org.eclipse.osee.ats.api.version.IAtsVersion; -import org.eclipse.osee.ats.core.client.config.IAtsProgram; +import org.eclipse.osee.ats.core.client.config.IAtsProgramClient; 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.util.AtsTaskCache; @@ -102,7 +102,7 @@ public class DetailedTestStatusBlam extends AbstractBlam { private XVersionList versionsListViewer; private IOseeBranch selectedBranch; - private IAtsProgram selectedProgram; + private IAtsProgramClient selectedProgram; private enum Index { Category, @@ -148,7 +148,7 @@ public class DetailedTestStatusBlam extends AbstractBlam { Iterator<?> iter = selection.iterator(); if (iter.hasNext()) { - selectedProgram = (IAtsProgram) iter.next(); + selectedProgram = (IAtsProgramClient) iter.next(); selectedBranch = null; try { diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/operation/DetailedTestStatusOld.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/operation/DetailedTestStatusOld.java index 89fec087421..7dd4f87411b 100644 --- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/operation/DetailedTestStatusOld.java +++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/operation/DetailedTestStatusOld.java @@ -37,7 +37,7 @@ import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.osee.ats.api.data.AtsAttributeTypes; import org.eclipse.osee.ats.api.user.IAtsUser; import org.eclipse.osee.ats.api.version.IAtsVersion; -import org.eclipse.osee.ats.core.client.config.IAtsProgram; +import org.eclipse.osee.ats.core.client.config.IAtsProgramClient; import org.eclipse.osee.ats.core.client.task.TaskArtifact; import org.eclipse.osee.ats.core.client.team.TeamWorkFlowArtifact; import org.eclipse.osee.ats.core.util.AtsObjects; @@ -114,7 +114,7 @@ public class DetailedTestStatusOld extends AbstractBlam { private Collection<String> availableTraceHandlers; private IOseeBranch selectedBranch; - private IAtsProgram selectedProgram; + private IAtsProgramClient selectedProgram; private static final int MAX_EXCEL_COLUMNS = 256; private enum Index { @@ -162,7 +162,7 @@ public class DetailedTestStatusOld extends AbstractBlam { Iterator<?> iter = selection.iterator(); if (iter.hasNext()) { - selectedProgram = (IAtsProgram) iter.next(); + selectedProgram = (IAtsProgramClient) iter.next(); selectedBranch = null; try { diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/widgets/AtsProgramLabelProvider.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/widgets/AtsProgramLabelProvider.java index dfad7cee13f..6bd7c826f4b 100644 --- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/widgets/AtsProgramLabelProvider.java +++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/widgets/AtsProgramLabelProvider.java @@ -12,7 +12,7 @@ package org.eclipse.osee.ats.util.widgets; import org.eclipse.jface.viewers.ILabelProvider; import org.eclipse.jface.viewers.ILabelProviderListener; -import org.eclipse.osee.ats.core.client.config.IAtsProgram; +import org.eclipse.osee.ats.core.client.config.IAtsProgramClient; import org.eclipse.osee.ats.internal.Activator; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.framework.logging.OseeLevel; @@ -31,8 +31,8 @@ public class AtsProgramLabelProvider implements ILabelProvider { @Override public String getText(Object element) { - if (element instanceof IAtsProgram) { - IAtsProgram program = (IAtsProgram) element; + if (element instanceof IAtsProgramClient) { + IAtsProgramClient program = (IAtsProgramClient) element; boolean active; try { active = program.isActive(); @@ -40,7 +40,7 @@ public class AtsProgramLabelProvider implements ILabelProvider { OseeLog.log(Activator.class, OseeLevel.SEVERE_POPUP, ex); return "Exception: " + ex.getLocalizedMessage(); } - return ((IAtsProgram) element).getName() + (active ? "" : " (InActive)"); + return ((IAtsProgramClient) element).getName() + (active ? "" : " (InActive)"); } return "Unknown"; } diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/widgets/AtsProgramViewerSorter.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/widgets/AtsProgramViewerSorter.java index ee0de14219f..a03daa1134a 100644 --- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/widgets/AtsProgramViewerSorter.java +++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/widgets/AtsProgramViewerSorter.java @@ -12,7 +12,7 @@ package org.eclipse.osee.ats.util.widgets; import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.viewers.ViewerSorter; -import org.eclipse.osee.ats.core.client.config.IAtsProgram; +import org.eclipse.osee.ats.core.client.config.IAtsProgramClient; /** * @author Donald G. Dunne @@ -22,6 +22,6 @@ public class AtsProgramViewerSorter extends ViewerSorter { @SuppressWarnings("unchecked") @Override public int compare(Viewer viewer, Object e1, Object e2) { - return getComparator().compare(((IAtsProgram) e1).getName(), ((IAtsProgram) e2).getName()); + return getComparator().compare(((IAtsProgramClient) e1).getName(), ((IAtsProgramClient) e2).getName()); } }
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/widgets/XAtsProgramComboWidget.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/widgets/XAtsProgramComboWidget.java index 72ca58077da..cd62dd538af 100644 --- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/widgets/XAtsProgramComboWidget.java +++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/widgets/XAtsProgramComboWidget.java @@ -14,7 +14,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; import org.eclipse.jface.viewers.ArrayContentProvider; -import org.eclipse.osee.ats.core.client.config.IAtsProgram; +import org.eclipse.osee.ats.core.client.config.IAtsProgramClient; import org.eclipse.osee.ats.core.client.config.IAtsProgramManager; import org.eclipse.osee.ats.core.client.config.ProgramManagers; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; @@ -28,9 +28,9 @@ import org.eclipse.swt.widgets.Composite; */ public class XAtsProgramComboWidget extends XComboViewer { - private final Collection<? extends IAtsProgram> atsPrograms; + private final Collection<? extends IAtsProgramClient> atsPrograms; - public XAtsProgramComboWidget(String displayLabel, Collection<? extends IAtsProgram> atsPrograms) { + public XAtsProgramComboWidget(String displayLabel, Collection<? extends IAtsProgramClient> atsPrograms) { super(displayLabel, SWT.READ_ONLY); this.atsPrograms = atsPrograms; setLabelProvider(new AtsProgramLabelProvider()); @@ -46,8 +46,8 @@ public class XAtsProgramComboWidget extends XComboViewer { this("ATS Program", getAllPrograms()); } - private static Collection<? extends IAtsProgram> getAllPrograms() throws OseeCoreException { - List<IAtsProgram> programs = new ArrayList<IAtsProgram>(); + private static Collection<? extends IAtsProgramClient> getAllPrograms() throws OseeCoreException { + List<IAtsProgramClient> programs = new ArrayList<IAtsProgramClient>(); for (IAtsProgramManager manager : ProgramManagers.getAtsProgramManagers()) { programs.addAll(manager.getPrograms()); } @@ -62,9 +62,9 @@ public class XAtsProgramComboWidget extends XComboViewer { reload(atsPrograms); } - public void reload(Collection<? extends IAtsProgram> lbaPrograms) { + public void reload(Collection<? extends IAtsProgramClient> lbaPrograms) { Collection<Object> objs = new ArrayList<Object>(); - for (IAtsProgram proj : atsPrograms) { + for (IAtsProgramClient proj : atsPrograms) { objs.add(proj); } setInput(objs); diff --git a/plugins/org.eclipse.osee.ats/support/OseeTypes_ATS.osee b/plugins/org.eclipse.osee.ats/support/OseeTypes_ATS.osee index b9ab37d22d4..0487be7b080 100644 --- a/plugins/org.eclipse.osee.ats/support/OseeTypes_ATS.osee +++ b/plugins/org.eclipse.osee.ats/support/OseeTypes_ATS.osee @@ -19,6 +19,13 @@ abstract artifactType "ats.Ats Team Definition or AI" extends "ats.Ats Config Ar uuid 0x0000000000000323 } +artifactType "Program" extends "ats.Ats Config Artifact" { + uuid 0x0000BA123443210004 + attribute "ats.Team Definition" + attribute "ats.Namespace" + attribute "ats.Description" +} + artifactType "ats.Review" extends "ats.State Machine" { uuid 0x0000000000000040 attribute "ats.Actionable Item" @@ -1070,6 +1077,15 @@ attributeType "ats.Category" extends StringAttribute { mediaType "text/plain" } +attributeType "ats.Namespace" extends StringAttribute { + uuid 0x40E507303063999E + dataProvider DefaultAttributeDataProvider + min 0 + max 1 + taggerId DefaultAttributeTaggerProvider + mediaType "text/plain" +} + attributeType "ats.Operational Impact" extends StringAttribute { uuid 0x10000000000000ED dataProvider DefaultAttributeDataProvider |