diff options
85 files changed, 2433 insertions, 344 deletions
diff --git a/plugins/org.eclipse.osee.ats.api/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.ats.api/META-INF/MANIFEST.MF index 95c2ea27bd7..77ea068deb8 100644 --- a/plugins/org.eclipse.osee.ats.api/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.osee.ats.api/META-INF/MANIFEST.MF @@ -10,6 +10,7 @@ Export-Package: org.eclipse.osee.ats.api, org.eclipse.osee.ats.api.ai, org.eclipse.osee.ats.api.commit, org.eclipse.osee.ats.api.config, + org.eclipse.osee.ats.api.country, org.eclipse.osee.ats.api.cpa, org.eclipse.osee.ats.api.data, org.eclipse.osee.ats.api.ev, @@ -37,4 +38,5 @@ Import-Package: javax.ws.rs;version="2.0.0", org.eclipse.osee.framework.core.util, org.eclipse.osee.framework.jdk.core.type, org.eclipse.osee.framework.jdk.core.util, - org.eclipse.osee.framework.logging + org.eclipse.osee.framework.logging, + org.eclipse.osee.jaxrs.mvc diff --git a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/IAtsServices.java b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/IAtsServices.java index 0fc89a7536c..273d22fd059 100644 --- a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/IAtsServices.java +++ b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/IAtsServices.java @@ -17,6 +17,7 @@ import org.eclipse.osee.ats.api.team.IAtsConfigItemFactory; import org.eclipse.osee.ats.api.team.IAtsWorkItemFactory; import org.eclipse.osee.ats.api.user.IAtsUserService; import org.eclipse.osee.ats.api.util.IAtsChangeSet; +import org.eclipse.osee.ats.api.util.IAtsStoreService; import org.eclipse.osee.ats.api.version.IAtsVersionService; import org.eclipse.osee.ats.api.workdef.IAtsWorkDefinitionService; import org.eclipse.osee.ats.api.workdef.IAttributeResolver; @@ -70,4 +71,8 @@ public interface IAtsServices { ArtifactId getArtifact(IArtifactToken token); + IAtsStoreService getStoreService(); + + <A extends IAtsConfigObject> A getSoleByUuid(long uuid, Class<A> clazz) throws OseeCoreException; + } diff --git a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/agile/AbstractJaxNewAgileTeamObject.java b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/agile/AbstractJaxNewAgileTeamObject.java index f0bc3d0b219..3212480c5ca 100644 --- a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/agile/AbstractJaxNewAgileTeamObject.java +++ b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/agile/AbstractJaxNewAgileTeamObject.java @@ -11,12 +11,13 @@ package org.eclipse.osee.ats.api.agile; import javax.xml.bind.annotation.XmlRootElement; +import org.eclipse.osee.ats.api.config.JaxAtsObject; /** * @author Donald G. Dunne */ @XmlRootElement -public class AbstractJaxNewAgileTeamObject extends AbstractJaxNewAgileObject { +public class AbstractJaxNewAgileTeamObject extends JaxAtsObject { private long teamUuid; diff --git a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/agile/AgileItem.java b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/agile/AgileItem.java index f284b9f6047..74c2629caf4 100644 --- a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/agile/AgileItem.java +++ b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/agile/AgileItem.java @@ -11,12 +11,13 @@ package org.eclipse.osee.ats.api.agile; import javax.xml.bind.annotation.XmlRootElement; +import org.eclipse.osee.ats.api.config.JaxAtsObject; /** * Donald G. Dunne */ @XmlRootElement -public class AgileItem extends AbstractAgileObject { +public class AgileItem extends JaxAtsObject { private String name; private String assignees; diff --git a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/agile/JaxAgileBacklog.java b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/agile/JaxAgileBacklog.java index a98e58b1bfc..b35d21ba1d7 100644 --- a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/agile/JaxAgileBacklog.java +++ b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/agile/JaxAgileBacklog.java @@ -11,12 +11,13 @@ package org.eclipse.osee.ats.api.agile; import javax.xml.bind.annotation.XmlRootElement; +import org.eclipse.osee.ats.api.config.JaxAtsObject; /** * @author Donald G. Dunne */ @XmlRootElement -public class JaxAgileBacklog extends AbstractAgileObject { +public class JaxAgileBacklog extends JaxAtsObject { private long teamUuid; diff --git a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/agile/JaxAgileFeatureGroup.java b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/agile/JaxAgileFeatureGroup.java index 98209b65bb2..521db192c3b 100644 --- a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/agile/JaxAgileFeatureGroup.java +++ b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/agile/JaxAgileFeatureGroup.java @@ -11,12 +11,13 @@ package org.eclipse.osee.ats.api.agile; import javax.xml.bind.annotation.XmlRootElement; +import org.eclipse.osee.ats.api.config.JaxAtsObject; /** * @author Donald G. Dunne */ @XmlRootElement -public class JaxAgileFeatureGroup extends AbstractAgileObject { +public class JaxAgileFeatureGroup extends JaxAtsObject { private long teamUuid; diff --git a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/agile/JaxAgileSprint.java b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/agile/JaxAgileSprint.java index 05a12be39a0..c25f22a1b10 100644 --- a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/agile/JaxAgileSprint.java +++ b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/agile/JaxAgileSprint.java @@ -11,12 +11,13 @@ package org.eclipse.osee.ats.api.agile; import javax.xml.bind.annotation.XmlRootElement; +import org.eclipse.osee.ats.api.config.JaxAtsObject; /** * @author Donald G. Dunne */ @XmlRootElement -public class JaxAgileSprint extends AbstractAgileObject { +public class JaxAgileSprint extends JaxAtsObject { private long teamUuid; diff --git a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/agile/JaxAgileTeam.java b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/agile/JaxAgileTeam.java index 058cb1691b0..0c952907ddf 100644 --- a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/agile/JaxAgileTeam.java +++ b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/agile/JaxAgileTeam.java @@ -13,12 +13,13 @@ package org.eclipse.osee.ats.api.agile; import java.util.ArrayList; import java.util.List; import javax.xml.bind.annotation.XmlRootElement; +import org.eclipse.osee.ats.api.config.JaxAtsObject; /** * @author Donald G. Dunne */ @XmlRootElement -public class JaxAgileTeam extends AbstractAgileObject { +public class JaxAgileTeam extends JaxAtsObject { private List<Long> atsTeamUuids = new ArrayList<Long>(); private long backlogUuid = 0; diff --git a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/agile/JaxNewAgileTeam.java b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/agile/JaxNewAgileTeam.java index c54e8bff927..b19a24250d2 100644 --- a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/agile/JaxNewAgileTeam.java +++ b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/agile/JaxNewAgileTeam.java @@ -11,11 +11,12 @@ package org.eclipse.osee.ats.api.agile; import javax.xml.bind.annotation.XmlRootElement; +import org.eclipse.osee.ats.api.config.JaxAtsObject; /** * @author Donald G. Dunne */ @XmlRootElement -public class JaxNewAgileTeam extends AbstractJaxNewAgileObject { +public class JaxNewAgileTeam extends JaxAtsObject { // Nothing to implement } diff --git a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/config/BaseConfigEndpointApi.java b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/config/BaseConfigEndpointApi.java new file mode 100644 index 00000000000..21b6757ce56 --- /dev/null +++ b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/config/BaseConfigEndpointApi.java @@ -0,0 +1,46 @@ +/******************************************************************************* + * 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.api.config; + +import java.util.List; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +/** + * @author Donald G. Dunne + */ +public interface BaseConfigEndpointApi<T extends JaxAtsObject> { + + @GET + @Produces(MediaType.APPLICATION_JSON) + public List<T> get() throws Exception; + + @GET + @Path("{uuid}") + @Produces(MediaType.APPLICATION_JSON) + public T get(@PathParam("uuid") long uuid) throws Exception; + + @POST + @Consumes(MediaType.APPLICATION_JSON) + public Response create(T atsConfigObject) throws Exception; + + @DELETE + @Path("{uuid}") + public Response delete(@PathParam("uuid") long uuid) throws Exception; + +} diff --git a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/config/JaxAtsObject.java b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/config/JaxAtsObject.java new file mode 100644 index 00000000000..d87a816db4c --- /dev/null +++ b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/config/JaxAtsObject.java @@ -0,0 +1,111 @@ +/******************************************************************************* + * 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.api.config; + +import javax.xml.bind.annotation.XmlRootElement; +import org.eclipse.osee.framework.jdk.core.type.UuidIdentity; + +/** + * @author Donald G. Dunne + */ +@XmlRootElement +public class JaxAtsObject { + + private String name; + private long uuid; + private boolean active; + private String description; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public long getUuid() { + return uuid; + } + + /** + * Provided for deserialization. Setting will not apply to new artifact. + */ + public void setUuid(long uuid) { + this.uuid = uuid; + } + + @Override + public String toString() { + return getName(); + } + + public boolean isActive() { + return active; + } + + public void setActive(boolean active) { + this.active = active; + } + + public boolean matches(JaxAtsObject... identities) { + for (JaxAtsObject identity : identities) { + if (equals(identity)) { + return true; + } + } + return false; + } + + public boolean matches(UuidIdentity... identities) { + for (UuidIdentity identity : identities) { + if (equals(identity)) { + return true; + } + } + return false; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + (int) (uuid ^ (uuid >>> 32)); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (!(obj instanceof JaxAtsObject)) { + return false; + } + JaxAtsObject other = (JaxAtsObject) obj; + if (uuid != other.getUuid()) { + return false; + } + return true; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + +} diff --git a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/config/JaxNewAtsConfigObject.java b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/config/JaxNewAtsConfigObject.java new file mode 100644 index 00000000000..6018ad7efb0 --- /dev/null +++ b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/config/JaxNewAtsConfigObject.java @@ -0,0 +1,34 @@ +/******************************************************************************* + * 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.api.config; + +import javax.xml.bind.annotation.XmlRootElement; +import org.eclipse.osee.framework.core.data.ArtifactId; + +/** + * @author Donald G. Dunne + */ +@XmlRootElement +public class JaxNewAtsConfigObject extends JaxAtsObject { + + public final String toStringWithId() { + return String.format("[%d][%s]", getUuid(), getName()); + } + + public ArtifactId getStoreObject() { + return null; + } + + public void setStoreObject(ArtifactId artifact) { + // do nothing + } + +} diff --git a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/country/CountryEndpointApi.java b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/country/CountryEndpointApi.java new file mode 100644 index 00000000000..081d02d40d2 --- /dev/null +++ b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/country/CountryEndpointApi.java @@ -0,0 +1,37 @@ +/******************************************************************************* + * 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.api.country; + +import javax.ws.rs.Consumes; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import org.eclipse.osee.ats.api.config.BaseConfigEndpointApi; +import org.eclipse.osee.ats.api.program.ProgramEndpointApi; + +/** + * @author Donald G. Dunne + */ +@Path("countryep") +public interface CountryEndpointApi extends BaseConfigEndpointApi<JaxCountry> { + + @PUT + @Consumes(MediaType.APPLICATION_JSON) + public Response update(JaxCountry country) throws Exception; + + @Path("{countryUuid}/program") + @Produces(MediaType.APPLICATION_JSON) + public ProgramEndpointApi getProgram(@PathParam("countryUuid") long countryUuid); + +} diff --git a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/country/IAtsCountry.java b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/country/IAtsCountry.java new file mode 100644 index 00000000000..ed2826a07fd --- /dev/null +++ b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/country/IAtsCountry.java @@ -0,0 +1,20 @@ +/******************************************************************************* + * 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.api.country; + +import org.eclipse.osee.ats.api.IAtsConfigObject; + +/** + * @author Donald G. Dunne + */ +public interface IAtsCountry extends IAtsConfigObject { + // do nothing +} diff --git a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/insertion/JaxNewInsertionActivity.java b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/country/JaxCountry.java index 2a7c81c4584..9d640f321ed 100644 --- a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/insertion/JaxNewInsertionActivity.java +++ b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/country/JaxCountry.java @@ -8,15 +8,15 @@ * Contributors: * Boeing - initial API and implementation *******************************************************************************/ -package org.eclipse.osee.ats.api.insertion; +package org.eclipse.osee.ats.api.country; import javax.xml.bind.annotation.XmlRootElement; -import org.eclipse.osee.ats.api.agile.AbstractJaxNewAgileTeamObject; +import org.eclipse.osee.ats.api.config.JaxNewAtsConfigObject; /** - * @author David W. Miller + * @author Donald G. Dunne */ @XmlRootElement -public class JaxNewInsertionActivity extends AbstractJaxNewAgileTeamObject { - // Nothing to implement +public class JaxCountry extends JaxNewAtsConfigObject { + // do nothing } diff --git a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/data/AtsArtifactToken.java b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/data/AtsArtifactToken.java index 3fe9b346fb8..bdaadaee854 100644 --- a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/data/AtsArtifactToken.java +++ b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/data/AtsArtifactToken.java @@ -29,6 +29,10 @@ public final class AtsArtifactToken { "Teams", AtsArtifactTypes.TeamDefinition); public static IArtifactToken TopActionableItem = TokenFactory.createArtifactToken(122894, "AAABER+37QEA8O7WSQaqJQ", "Actionable Items", AtsArtifactTypes.ActionableItem); + public static IArtifactToken CountryFolder = TokenFactory.createArtifactToken(7968155, "AYi8V8esln8KJkjesqAA", + "Countries", CoreArtifactTypes.Folder); + public static IArtifactToken ProgramFolder = TokenFactory.createArtifactToken(90442279, "AYi8V9LSJgjD2734BqQA", + "Programs", CoreArtifactTypes.Folder); public static IArtifactToken ConfigFolder = TokenFactory.createArtifactToken(113036, "AAABF4n18eYAc1ruQSSWdg", "Config", CoreArtifactTypes.Folder); public static IArtifactToken ConfigsFolder = TokenFactory.createArtifactToken(5086714, "BEmf1DEFnwkUqC9o3hwA", 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 43c262fa41b..2722719bb86 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 @@ -35,6 +35,7 @@ public final class AtsArtifactTypes { 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"); + public static final IArtifactType Country = TokenFactory.createArtifactType(0x44C69E6EBB2D8324L, "Country"); public static final IArtifactType AgileTeam = TokenFactory.createArtifactType(0x68D469C51DA01041L, "Agile Team"); public static final IArtifactType AgileFeatureGroup = TokenFactory.createArtifactType(0x07C6AA0E42EE7661L, "Agile Feature Group"); diff --git a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/data/AtsRelationTypes.java b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/data/AtsRelationTypes.java index e80691cd64b..412677f9858 100644 --- a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/data/AtsRelationTypes.java +++ b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/data/AtsRelationTypes.java @@ -84,6 +84,9 @@ public final class AtsRelationTypes { public static final IRelationTypeSide TeamDefinitionToAtsConfigObject_TeamDefinition = TokenFactory.createRelationTypeSide(RelationSide.SIDE_A, 0x2000000000000170L, "TeamDefinitionAtsConfigObject"); public static final IRelationTypeSide TeamDefinitionToAtsConfigObject_AtsConfigObject = TeamDefinitionToVersion_TeamDefinition.getOpposite(); + public static final IRelationTypeSide CountryToProgram_Country = TokenFactory.createRelationTypeSide(RelationSide.SIDE_A, 0x2000033300000169L, "CountryToProgram"); + public static final IRelationTypeSide CountryToProgram_Program = CountryToProgram_Country.getOpposite(); + public static final IRelationTypeSide TeamLead_Team = TokenFactory.createRelationTypeSide(RelationSide.SIDE_A, 0x2000000000000169L, "TeamLead"); public static final IRelationTypeSide TeamLead_Lead = TeamLead_Team.getOpposite(); diff --git a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/insertion/IAtsInsertion.java b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/insertion/IAtsInsertion.java index a8ac9ab242d..68a0aaee191 100644 --- a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/insertion/IAtsInsertion.java +++ b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/insertion/IAtsInsertion.java @@ -16,6 +16,7 @@ import org.eclipse.osee.ats.api.IAtsConfigObject; * @author David W. Miller */ public interface IAtsInsertion extends IAtsConfigObject { - // marker interface + + long getProgramUuid(); } diff --git a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/insertion/IAtsInsertionActivity.java b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/insertion/IAtsInsertionActivity.java index 6baf3f1f25c..c51150389bc 100644 --- a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/insertion/IAtsInsertionActivity.java +++ b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/insertion/IAtsInsertionActivity.java @@ -16,5 +16,7 @@ import org.eclipse.osee.ats.api.IAtsConfigObject; * @author David W. Miller */ public interface IAtsInsertionActivity extends IAtsConfigObject { - // marker interface + + long getInsertionUuid(); + } diff --git a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/insertion/InsertionActivityEndpointApi.java b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/insertion/InsertionActivityEndpointApi.java new file mode 100644 index 00000000000..d818a17cc28 --- /dev/null +++ b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/insertion/InsertionActivityEndpointApi.java @@ -0,0 +1,30 @@ +/******************************************************************************* + * 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.api.insertion; + +import javax.ws.rs.Consumes; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import org.eclipse.osee.ats.api.config.BaseConfigEndpointApi; + +/** + * @author Donald G. Dunne + */ +@Path("insertionactivityep") +public interface InsertionActivityEndpointApi extends BaseConfigEndpointApi<JaxInsertionActivity> { + + @PUT + @Consumes(MediaType.APPLICATION_JSON) + public Response update(JaxInsertionActivity activity) throws Exception; + +} diff --git a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/insertion/InsertionEndpointApi.java b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/insertion/InsertionEndpointApi.java new file mode 100644 index 00000000000..cebc1a355aa --- /dev/null +++ b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/insertion/InsertionEndpointApi.java @@ -0,0 +1,36 @@ +/******************************************************************************* + * 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.api.insertion; + +import javax.ws.rs.Consumes; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import org.eclipse.osee.ats.api.config.BaseConfigEndpointApi; + +/** + * @author Donald G. Dunne + */ +@Path("insertionep") +public interface InsertionEndpointApi extends BaseConfigEndpointApi<JaxInsertion> { + + @PUT + @Consumes(MediaType.APPLICATION_JSON) + public Response update(JaxInsertion insertion) throws Exception; + + @Path("{insertionUuid}/activity") + @Produces(MediaType.APPLICATION_JSON) + public InsertionActivityEndpointApi getInsertionActivity(@PathParam("insertionUuid") long insertionUuid); + +} diff --git a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/insertion/JaxInsertion.java b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/insertion/JaxInsertion.java new file mode 100644 index 00000000000..04f3257ba16 --- /dev/null +++ b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/insertion/JaxInsertion.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.api.insertion; + +import javax.xml.bind.annotation.XmlRootElement; +import org.eclipse.osee.ats.api.config.JaxAtsObject; + +/** + * @author David W. Miller + */ +@XmlRootElement +public class JaxInsertion extends JaxAtsObject { + + private long programUuid; + + public long getProgramUuid() { + return programUuid; + } + + public void setProgramUuid(long programUuid) { + this.programUuid = programUuid; + } + +} diff --git a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/insertion/JaxNewInsertion.java b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/insertion/JaxInsertionActivity.java index d6ac4222527..bf0a26e5f5c 100644 --- a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/insertion/JaxNewInsertion.java +++ b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/insertion/JaxInsertionActivity.java @@ -17,6 +17,15 @@ import org.eclipse.osee.ats.api.agile.AbstractJaxNewAgileTeamObject; * @author David W. Miller */ @XmlRootElement -public class JaxNewInsertion extends AbstractJaxNewAgileTeamObject { - // Nothing to implement +public class JaxInsertionActivity extends AbstractJaxNewAgileTeamObject { + + private long insertionUuid; + + public long getInsertionUuid() { + return insertionUuid; + } + + public void setInsertionUuid(long insertionUuid) { + this.insertionUuid = insertionUuid; + } } 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 71f20768926..027bed5861e 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 @@ -22,4 +22,6 @@ public interface IAtsProgram extends IAtsConfigObject { public String getNamespace(); + long getCountryUuid(); + } diff --git a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/program/IAtsProgramService.java b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/program/IAtsProgramService.java index 53c95a70525..445465f249d 100644 --- a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/program/IAtsProgramService.java +++ b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/program/IAtsProgramService.java @@ -10,7 +10,9 @@ *******************************************************************************/ package org.eclipse.osee.ats.api.program; +import java.util.List; import org.eclipse.osee.ats.api.IAtsWorkItem; +import org.eclipse.osee.ats.api.country.IAtsCountry; import org.eclipse.osee.ats.api.team.IAtsTeamDefinition; /** @@ -23,4 +25,8 @@ public interface IAtsProgramService { IAtsProgram getProgram(IAtsWorkItem workItem); IAtsProgram getProgramByGuid(String guid); + + IAtsCountry getCountry(IAtsProgram atsProgram); + + List<IAtsProgram> getPrograms(IAtsCountry atsCountry); } diff --git a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/program/JaxProgram.java b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/program/JaxProgram.java new file mode 100644 index 00000000000..446ab6ad66d --- /dev/null +++ b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/program/JaxProgram.java @@ -0,0 +1,31 @@ +/******************************************************************************* + * 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.api.program; + +import javax.xml.bind.annotation.XmlRootElement; +import org.eclipse.osee.ats.api.config.JaxNewAtsConfigObject; + +/** + * @author Donald G. Dunne + */ +@XmlRootElement +public class JaxProgram extends JaxNewAtsConfigObject { + + long countryUuid; + + public long getCountryUuid() { + return countryUuid; + } + + public void setCountryUuid(long countryUuid) { + this.countryUuid = countryUuid; + } +} diff --git a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/program/ProgramEndpointApi.java b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/program/ProgramEndpointApi.java new file mode 100644 index 00000000000..7386d641396 --- /dev/null +++ b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/program/ProgramEndpointApi.java @@ -0,0 +1,37 @@ +/******************************************************************************* + * 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.api.program; + +import javax.ws.rs.Consumes; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import org.eclipse.osee.ats.api.config.BaseConfigEndpointApi; +import org.eclipse.osee.ats.api.insertion.InsertionEndpointApi; + +/** + * @author Donald G. Dunne + */ +@Path("programep") +public interface ProgramEndpointApi extends BaseConfigEndpointApi<JaxProgram> { + + @PUT + @Consumes(MediaType.APPLICATION_JSON) + public Response update(JaxProgram program) throws Exception; + + @Path("{programUuid}/program") + @Produces(MediaType.APPLICATION_JSON) + public InsertionEndpointApi getInsertion(@PathParam("programUuid") long programUuid); + +} 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 3208126454a..4da02b84f64 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 @@ -15,10 +15,11 @@ import org.eclipse.osee.ats.api.IAtsConfigObject; import org.eclipse.osee.ats.api.agile.IAgileFeatureGroup; import org.eclipse.osee.ats.api.agile.IAgileTeam; import org.eclipse.osee.ats.api.ai.IAtsActionableItem; +import org.eclipse.osee.ats.api.country.IAtsCountry; import org.eclipse.osee.ats.api.insertion.IAtsInsertion; import org.eclipse.osee.ats.api.insertion.IAtsInsertionActivity; -import org.eclipse.osee.ats.api.insertion.JaxNewInsertion; -import org.eclipse.osee.ats.api.insertion.JaxNewInsertionActivity; +import org.eclipse.osee.ats.api.insertion.JaxInsertion; +import org.eclipse.osee.ats.api.insertion.JaxInsertionActivity; import org.eclipse.osee.ats.api.program.IAtsProgram; import org.eclipse.osee.ats.api.version.IAtsVersion; import org.eclipse.osee.framework.core.data.ArtifactId; @@ -46,17 +47,17 @@ public interface IAtsConfigItemFactory { IAtsInsertion getInsertion(ArtifactId artifact); - IAtsInsertion createInsertion(ArtifactId programArtifact, JaxNewInsertion newInsertion); + IAtsInsertion createInsertion(ArtifactId programArtifact, JaxInsertion newInsertion); - IAtsInsertion updateInsertion(JaxNewInsertion newInsertion); + IAtsInsertion updateInsertion(JaxInsertion newInsertion); void deleteInsertion(ArtifactId artifact); IAtsInsertionActivity getInsertionActivity(ArtifactId artifact); - IAtsInsertionActivity createInsertionActivity(ArtifactId insertion, JaxNewInsertionActivity newActivity); + IAtsInsertionActivity createInsertionActivity(ArtifactId insertion, JaxInsertionActivity newActivity); - IAtsInsertionActivity updateInsertionActivity(JaxNewInsertionActivity newFeature); + IAtsInsertionActivity updateInsertionActivity(JaxInsertionActivity newFeature); void deleteInsertionActivity(ArtifactId artifact); @@ -64,4 +65,8 @@ public interface IAtsConfigItemFactory { List<IArtifactType> getAtsConfigArtifactTypes(); + IAtsCountry getCountry(ArtifactId artifact); + + IAtsCountry getCountry(long uuid); + } diff --git a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/util/IAtsChangeSet.java b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/util/IAtsChangeSet.java index 76a9e113565..ef8ccb4ffee 100644 --- a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/util/IAtsChangeSet.java +++ b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/util/IAtsChangeSet.java @@ -16,6 +16,7 @@ import org.eclipse.osee.ats.api.IAtsWorkItem; import org.eclipse.osee.ats.api.notify.AtsNotificationCollector; import org.eclipse.osee.ats.api.workflow.IAttribute; import org.eclipse.osee.framework.core.data.ArtifactId; +import org.eclipse.osee.framework.core.data.IArtifactToken; import org.eclipse.osee.framework.core.data.IArtifactType; import org.eclipse.osee.framework.core.data.IAttributeType; import org.eclipse.osee.framework.core.data.IRelationTypeSide; @@ -77,5 +78,9 @@ public interface IAtsChangeSet { public void setRelations(Object object, IRelationTypeSide relationSide, Collection<? extends Object> objects); <T> void setAttribute(Object workItem, int attributeId, T value); + + ArtifactId createArtifact(IArtifactToken token); + + void deleteArtifact(ArtifactId artifact); } diff --git a/plugins/org.eclipse.osee.ats.client.demo/src/org/eclipse/osee/ats/client/demo/config/DemoCountry.java b/plugins/org.eclipse.osee.ats.client.demo/src/org/eclipse/osee/ats/client/demo/config/DemoCountry.java new file mode 100644 index 00000000000..a5e178513b2 --- /dev/null +++ b/plugins/org.eclipse.osee.ats.client.demo/src/org/eclipse/osee/ats/client/demo/config/DemoCountry.java @@ -0,0 +1,53 @@ +/******************************************************************************* + * 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.demo.config; + +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; +import org.eclipse.osee.ats.api.country.JaxCountry; + +/** + * @author Donald G. Dunne + */ +public class DemoCountry extends JaxCountry { + + public static DemoCountry usg = new DemoCountry("USG", 7777L, "ATS Configuration is support of US Govt"); + + public static DemoCountry cntry = new DemoCountry("CNTRY", 77771L, "ATS Configuration is support of Country"); + + List<DemoProgram> programs; + private static List<DemoCountry> countries; + + public DemoCountry(String name, long uuid, String description) { + setName(name); + setUuid(uuid); + setDescription(description); + setActive(true); + this.programs = new ArrayList<>(); + for (DemoProgram prog : programs) { + this.programs.add(prog); + } + if (countries == null) { + countries = new LinkedList<>(); + } + countries.add(this); + } + + public List<DemoProgram> getPrograms() { + return programs; + } + + public static List<DemoCountry> getCountries() { + return countries; + } + +} 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 8f79d2c561e..cbb584f8b00 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 @@ -10,20 +10,30 @@ *******************************************************************************/ package org.eclipse.osee.ats.client.demo.config; +import org.eclipse.osee.ats.api.country.CountryEndpointApi; +import org.eclipse.osee.ats.api.country.JaxCountry; import org.eclipse.osee.ats.api.data.AtsArtifactTypes; import org.eclipse.osee.ats.api.data.AtsAttributeTypes; import org.eclipse.osee.ats.api.data.AtsRelationTypes; +import org.eclipse.osee.ats.api.insertion.InsertionActivityEndpointApi; +import org.eclipse.osee.ats.api.insertion.InsertionEndpointApi; +import org.eclipse.osee.ats.api.insertion.JaxInsertion; +import org.eclipse.osee.ats.api.insertion.JaxInsertionActivity; +import org.eclipse.osee.ats.api.program.JaxProgram; +import org.eclipse.osee.ats.api.program.ProgramEndpointApi; import org.eclipse.osee.ats.client.demo.DemoArtifactToken; import org.eclipse.osee.ats.client.demo.DemoCISBuilds; import org.eclipse.osee.ats.client.demo.DemoSawBuilds; import org.eclipse.osee.ats.client.demo.DemoSubsystems; import org.eclipse.osee.ats.client.demo.DemoUsers; +import org.eclipse.osee.ats.client.demo.internal.AtsClientService; import org.eclipse.osee.ats.config.AtsDatabaseConfig; import org.eclipse.osee.ats.core.client.util.AtsGroup; import org.eclipse.osee.ats.core.util.AtsUtilCore; import org.eclipse.osee.framework.core.data.IArtifactToken; import org.eclipse.osee.framework.core.data.IOseeBranch; import org.eclipse.osee.framework.core.enums.CoreArtifactTypes; +import org.eclipse.osee.framework.core.exception.OseeWrappedException; import org.eclipse.osee.framework.database.init.IDbInitializationTask; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.framework.skynet.core.OseeSystemArtifacts; @@ -39,7 +49,7 @@ import org.eclipse.osee.support.test.util.TestUtil; /** * Initialization class that will load configuration information for a sample DB. - * + * * @author Donald G. Dunne */ public class DemoDatabaseConfig implements IDbInitializationTask { @@ -60,9 +70,127 @@ public class DemoDatabaseConfig implements IDbInitializationTask { AtsGroup.AtsTempAdmin.addMember(UserManager.getUser(DemoUsers.Joe_Smith)); AtsGroup.AtsTempAdmin.getArtifact().persist("Set Joe as Temp Admin"); + AtsDatabaseConfig.organizePrograms(AtsArtifactTypes.Program, DemoArtifactToken.DemoPrograms); + + createUsgCountryConfig(); + createCntryCountryConfig(); + // Create Work Packages createWorkPackages(); - AtsDatabaseConfig.organizePrograms(AtsArtifactTypes.Program, DemoArtifactToken.DemoPrograms); + } + + // configure USG for country, program, insertion, activity and work package + private void createUsgCountryConfig() { + try { + CountryEndpointApi countryEp = AtsClientService.getCountryEp(); + InsertionEndpointApi insertionEp = AtsClientService.getInsertionEp(); + InsertionActivityEndpointApi insertionActivityEp = AtsClientService.getInsertionActivityEp(); + + // create country + createCountry(countryEp, DemoCountry.usg); + + // relate country to programs + SkynetTransaction transaction = + TransactionManager.createTransaction(AtsUtilCore.getAtsBranch(), "Create USG Country Config"); + Artifact country = ArtifactQuery.getArtifactFromId(DemoCountry.usg.getUuid(), AtsUtilCore.getAtsBranch()); + Artifact program = + ArtifactQuery.getArtifactFromId(DemoProgram.sawProgram.getUuid(), AtsUtilCore.getAtsBranch()); + country.addRelation(AtsRelationTypes.CountryToProgram_Program, program); + program.persist(transaction); + + program = ArtifactQuery.getArtifactFromId(DemoProgram.cisProgram.getUuid(), AtsUtilCore.getAtsBranch()); + country.addRelation(AtsRelationTypes.CountryToProgram_Program, program); + program.persist(transaction); + country.persist(transaction); + transaction.execute(); + + // create and relate insertion and insertion activities + DemoInsertion.getInsertions(); + DemoInsertionActivity.getActivities(); + for (DemoProgram demoProg : DemoCountry.usg.getPrograms()) { + createInsertions(insertionEp, insertionActivityEp, demoProg); + } + + } catch (Exception ex) { + throw new OseeWrappedException("Error creating ATS USG Country Config", ex); + } + } + + private void createCntryCountryConfig() { + try { + DemoCountry country = DemoCountry.cntry; + CountryEndpointApi countryEp = AtsClientService.getCountryEp(); + ProgramEndpointApi programEp = AtsClientService.getProgramEp(); + InsertionEndpointApi insertionEp = AtsClientService.getInsertionEp(); + InsertionActivityEndpointApi insertionActivityEp = AtsClientService.getInsertionActivityEp(); + + // create country + createCountry(countryEp, country); + + // create and relate programs + DemoInsertion.getInsertions(); + DemoInsertionActivity.getActivities(); + for (DemoProgram program : country.getPrograms()) { + createProgram(programEp, program); + createInsertions(insertionEp, insertionActivityEp, program); + } + } catch (Exception ex) { + throw new OseeWrappedException("Error creating ATS Cntry Country Config", ex); + } + } + + private void createInsertions(InsertionEndpointApi insertionEp, InsertionActivityEndpointApi insertionActivityEp, DemoProgram demoProg) throws Exception { + for (DemoInsertion demoIns : demoProg.getInsertions()) { + createInsertion(insertionEp, demoIns); + + // create and relate insertion activities + for (DemoInsertionActivity demoInsertionActivity : demoIns.getActivities()) { + createInsertionActivity(insertionActivityEp, demoInsertionActivity); + } + } + } + + private JaxInsertionActivity createInsertionActivity(InsertionActivityEndpointApi insertionActivityEp, DemoInsertionActivity insertionActivity) throws Exception { + JaxInsertionActivity jaxInsertionActivity = new JaxInsertionActivity(); + jaxInsertionActivity.setName(insertionActivity.getName()); + jaxInsertionActivity.setUuid(insertionActivity.getUuid()); + jaxInsertionActivity.setActive(insertionActivity.isActive()); + jaxInsertionActivity.setDescription(insertionActivity.getDescription()); + jaxInsertionActivity.setInsertionUuid(insertionActivity.getInsertionUuid()); + insertionActivityEp.create(jaxInsertionActivity); + return jaxInsertionActivity; + } + + private JaxInsertion createInsertion(InsertionEndpointApi insertionEp, DemoInsertion insertion) throws Exception { + JaxInsertion jaxInsertion = new JaxInsertion(); + jaxInsertion.setName(insertion.getName()); + jaxInsertion.setUuid(insertion.getUuid()); + jaxInsertion.setActive(insertion.isActive()); + jaxInsertion.setDescription(insertion.getDescription()); + jaxInsertion.setProgramUuid(insertion.getProgramUuid()); + insertionEp.create(jaxInsertion); + return jaxInsertion; + } + + private JaxProgram createProgram(ProgramEndpointApi programEp, DemoProgram program) throws Exception { + JaxProgram jaxProgram = new JaxProgram(); + jaxProgram.setName(program.getName()); + jaxProgram.setUuid(program.getUuid()); + jaxProgram.setActive(program.isActive()); + jaxProgram.setDescription(program.getDescription()); + jaxProgram.setCountryUuid(program.getCountryUuid()); + programEp.create(jaxProgram); + return jaxProgram; + } + + private JaxCountry createCountry(CountryEndpointApi countryEp, DemoCountry country) throws Exception { + JaxCountry jaxCountry = new JaxCountry(); + jaxCountry.setName(country.getName()); + jaxCountry.setUuid(country.getUuid()); + jaxCountry.setActive(country.isActive()); + jaxCountry.setDescription(country.getDescription()); + countryEp.create(jaxCountry); + return jaxCountry; } private void createWorkPackages() throws OseeCoreException { @@ -73,15 +201,18 @@ public class DemoDatabaseConfig implements IDbInitializationTask { Artifact workPkg1 = createWorkPackage(DemoArtifactToken.SAW_Code_Team_WorkPackage_01, "ASDHFA443"); workPkg1.addRelation(AtsRelationTypes.WorkPackage_TeamDefOrAi, codeTeamArt); + relateInsertionActivity(workPkg1, DemoInsertionActivity.commPage); workPkg1.persist(transaction); Artifact workPkg2 = createWorkPackage(DemoArtifactToken.SAW_Code_Team_WorkPackage_02, "ASDHFA443"); workPkg2.addRelation(AtsRelationTypes.WorkPackage_TeamDefOrAi, codeTeamArt); + relateInsertionActivity(workPkg2, DemoInsertionActivity.commPage); workPkg2.persist(transaction); Artifact workPkg3 = createWorkPackage(DemoArtifactToken.SAW_Code_Team_WorkPackage_03, "ASDHFA443"); workPkg3.setSoleAttributeValue(AtsAttributeTypes.Active, false); workPkg3.addRelation(AtsRelationTypes.WorkPackage_TeamDefOrAi, codeTeamArt); + relateInsertionActivity(workPkg3, DemoInsertionActivity.commButton); workPkg3.persist(transaction); Artifact testTeamArt = @@ -89,20 +220,28 @@ public class DemoDatabaseConfig implements IDbInitializationTask { Artifact workPkg11 = createWorkPackage(DemoArtifactToken.SAW_Test_AI_WorkPackage_0A, "AHESSH3"); workPkg11.addRelation(AtsRelationTypes.WorkPackage_TeamDefOrAi, testTeamArt); + relateInsertionActivity(workPkg11, DemoInsertionActivity.commPage); workPkg11.persist(transaction); Artifact workPkg21 = createWorkPackage(DemoArtifactToken.SAW_Test_AI_WorkPackage_0B, "HAKSHD3"); workPkg21.addRelation(AtsRelationTypes.WorkPackage_TeamDefOrAi, testTeamArt); + relateInsertionActivity(workPkg21, DemoInsertionActivity.commPage); workPkg21.persist(transaction); Artifact workPkg31 = createWorkPackage(DemoArtifactToken.SAW_Test_AI_WorkPackage_0C, "EHA4DS"); workPkg31.setSoleAttributeValue(AtsAttributeTypes.Active, false); workPkg31.addRelation(AtsRelationTypes.WorkPackage_TeamDefOrAi, testTeamArt); + relateInsertionActivity(workPkg31, DemoInsertionActivity.commButton); workPkg31.persist(transaction); transaction.execute(); } + private void relateInsertionActivity(Artifact workPackageArt, DemoInsertionActivity insertionActivity) { + Artifact insertionActivityArt = AtsClientService.get().getArtifact(insertionActivity.getUuid()); + insertionActivityArt.addRelation(AtsRelationTypes.InsertionActivityToWorkPackage_WorkPackage, workPackageArt); + } + private Artifact createWorkPackage(IArtifactToken workPackageToken, String activityId) throws OseeCoreException { Artifact workPkg1 = ArtifactTypeManager.addArtifact(workPackageToken, AtsUtilCore.getAtsBranch()); char charAt = workPackageToken.getName().charAt(workPackageToken.getName().length() - 1); @@ -132,7 +271,7 @@ public class DemoDatabaseConfig implements IDbInitializationTask { Requirements.HARDWARE_REQUIREMENTS, "Verification Tests", "Validation Tests", - "Integration Tests"}) { + "Integration Tests"}) { programRoot.addChild(ArtifactTypeManager.addArtifact(CoreArtifactTypes.Folder, programBranch, name)); } diff --git a/plugins/org.eclipse.osee.ats.client.demo/src/org/eclipse/osee/ats/client/demo/config/DemoInsertion.java b/plugins/org.eclipse.osee.ats.client.demo/src/org/eclipse/osee/ats/client/demo/config/DemoInsertion.java new file mode 100644 index 00000000000..013da0d036c --- /dev/null +++ b/plugins/org.eclipse.osee.ats.client.demo/src/org/eclipse/osee/ats/client/demo/config/DemoInsertion.java @@ -0,0 +1,80 @@ +/******************************************************************************* + * 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.demo.config; + +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; +import org.eclipse.osee.ats.api.insertion.JaxInsertion; + +/** + * @author Donald G. Dunne + */ +public class DemoInsertion extends JaxInsertion { + + public static DemoInsertion sawComm = new DemoInsertion(DemoProgram.sawProgram, "COMM", 23477771L, "COMM Insertion"); + public static DemoInsertion sawIdm = + new DemoInsertion(DemoProgram.sawProgram, "IDM", 23477772L, "SAW IDM Insertion"); + public static DemoInsertion sawFixes = + new DemoInsertion(DemoProgram.sawProgram, "Fixes", 23477773L, "Fixes for SAW"); + public static DemoInsertion sawTechApproach = new DemoInsertion(DemoProgram.sawProgram, "TA", 23477774L, + "Tech Approaches for SAW"); + + public static DemoInsertion cisTechApproach = new DemoInsertion(DemoProgram.cisProgram, "TA", 23477775L, + "Tech Approaches for CIS"); + public static DemoInsertion cisAsdf = new DemoInsertion(DemoProgram.cisProgram, "ASDF", 23577776L, "ASDF Insertion"); + + public static DemoInsertion ver1TechApproach = new DemoInsertion(DemoProgram.ver1, "TA", 23477777L, "TA Insertion"); + public static DemoInsertion ver1WetrPhase1 = new DemoInsertion(DemoProgram.ver1, "WETR Phase 1", 23577778L, + "WETR Insertion"); + + public static DemoInsertion ver2TechApproach = + new DemoInsertion(DemoProgram.ver2, "TA", 23477779L, "WETR Insertion"); + public static DemoInsertion ver2WetrPhase1 = new DemoInsertion(DemoProgram.ver2, "WETR Phase 2", 23577770L, + "WETR Phase 2 Insertion"); + + public static DemoInsertion ver3TechApproach = new DemoInsertion(DemoProgram.ver3, "TA", 234777711L, + "WETR Insertion"); + public static DemoInsertion ver3WetrPhase1 = new DemoInsertion(DemoProgram.ver3, "WETR Phase 3", 235777712L, + "WETR Phase 3 Insertion"); + private static List<DemoInsertion> insertions; + + List<DemoInsertionActivity> activities; + private final DemoProgram program; + + public DemoInsertion(DemoProgram program, String name, long uuid, String description) { + this.program = program; + setName(name); + setUuid(uuid); + setActive(true); + this.activities = new ArrayList<>(); + this.program.getInsertions().add(this); + setDescription(description); + setProgramUuid(program.getUuid()); + if (insertions == null) { + insertions = new LinkedList<>(); + } + insertions.add(this); + } + + public List<DemoInsertionActivity> getActivities() { + return activities; + } + + public DemoProgram getProgram() { + return program; + } + + public static List<DemoInsertion> getInsertions() { + return insertions; + } + +} diff --git a/plugins/org.eclipse.osee.ats.client.demo/src/org/eclipse/osee/ats/client/demo/config/DemoInsertionActivity.java b/plugins/org.eclipse.osee.ats.client.demo/src/org/eclipse/osee/ats/client/demo/config/DemoInsertionActivity.java new file mode 100644 index 00000000000..6d1c651b639 --- /dev/null +++ b/plugins/org.eclipse.osee.ats.client.demo/src/org/eclipse/osee/ats/client/demo/config/DemoInsertionActivity.java @@ -0,0 +1,74 @@ +/******************************************************************************* + * 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.demo.config; + +import java.util.LinkedList; +import java.util.List; +import org.eclipse.osee.ats.api.insertion.JaxInsertionActivity; + +/** + * @author Donald G. Dunne + */ +public class DemoInsertionActivity extends JaxInsertionActivity { + + public static DemoInsertionActivity commPage = new DemoInsertionActivity(DemoInsertion.sawComm, "COMM Page", + 23477781L, "description"); + public static DemoInsertionActivity commButton = new DemoInsertionActivity(DemoInsertion.sawComm, "COMM Button", + 23477782L, "description"); + + public static DemoInsertionActivity cisAsdf = new DemoInsertionActivity(DemoInsertion.cisAsdf, "cisAsdf Activity", + 23477783L, "description"); + public static DemoInsertionActivity cisTechApproach = new DemoInsertionActivity(DemoInsertion.cisTechApproach, + "cisAsdf TA Activity", 2347778L, "description"); + + public static DemoInsertionActivity ver1TechApproachActivity = new DemoInsertionActivity( + DemoInsertion.ver1TechApproach, 23477784L); + public static DemoInsertionActivity ver1WetrPhase1 = new DemoInsertionActivity(DemoInsertion.ver1WetrPhase1, + 23477785L); + public static DemoInsertionActivity ver2TechApproach = new DemoInsertionActivity(DemoInsertion.ver2TechApproach, + 23477786L); + public static DemoInsertionActivity ver2WetrPhase1 = new DemoInsertionActivity(DemoInsertion.ver2WetrPhase1, + 23477787L); + public static DemoInsertionActivity ver3TechApproach = new DemoInsertionActivity(DemoInsertion.ver3TechApproach, + 23477788L); + public static DemoInsertionActivity ver3WetrPhase1 = new DemoInsertionActivity(DemoInsertion.ver3WetrPhase1, + 23477789L); + private static List<DemoInsertionActivity> activities; + + DemoInsertion insertion; + + public DemoInsertionActivity(DemoInsertion insertion, String name, long uuid, String description) { + this.insertion = insertion; + setName(name); + setUuid(uuid); + setActive(true); + insertion.getActivities().add(this); + setDescription(description); + setInsertionUuid(insertion.getUuid()); + if (activities == null) { + activities = new LinkedList<>(); + } + activities.add(this); + } + + public DemoInsertionActivity(DemoInsertion insertion, long uuid) { + this(insertion, insertion.getName() + " Activity", uuid, "description"); + } + + public static List<DemoInsertionActivity> getActivities() { + return activities; + } + + public DemoInsertion getInsertion() { + return insertion; + } + +} diff --git a/plugins/org.eclipse.osee.ats.client.demo/src/org/eclipse/osee/ats/client/demo/config/DemoProgram.java b/plugins/org.eclipse.osee.ats.client.demo/src/org/eclipse/osee/ats/client/demo/config/DemoProgram.java new file mode 100644 index 00000000000..e98121b9d34 --- /dev/null +++ b/plugins/org.eclipse.osee.ats.client.demo/src/org/eclipse/osee/ats/client/demo/config/DemoProgram.java @@ -0,0 +1,66 @@ +/******************************************************************************* + * 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.demo.config; + +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; +import org.eclipse.osee.ats.api.program.JaxProgram; + +/** + * @author Donald G. Dunne + */ +public class DemoProgram extends JaxProgram { + + public static DemoProgram sawProgram = new DemoProgram(DemoCountry.usg, "SAW Program", 19196003L, + "SAW Program description"); + public static DemoProgram cisProgram = new DemoProgram(DemoCountry.usg, "CIS Program", 8242414L, + "CIS Program description"); + + public static DemoProgram ver1 = new DemoProgram(DemoCountry.cntry, "Cntry V1", 888L, + "CNTRY Ver1 Program description"); + public static DemoProgram ver2 = new DemoProgram(DemoCountry.cntry, "Cntry V2", 8881L, + "CNTRY Ver2 Program description"); + public static DemoProgram ver3 = new DemoProgram(DemoCountry.cntry, "Cntry V3", 8882L, + "CNTRY Ver3 Program description"); + + List<DemoInsertion> insertions; + private final DemoCountry country; + private static List<DemoProgram> programs; + + public DemoProgram(DemoCountry country, String name, long uuid, String description) { + this.country = country; + setName(name); + setUuid(uuid); + setDescription(description); + setActive(true); + this.insertions = new ArrayList<>(); + country.getPrograms().add(this); + setCountryUuid(country.getUuid()); + if (programs == null) { + programs = new LinkedList<>(); + } + programs.add(this); + } + + public List<DemoInsertion> getInsertions() { + return insertions; + } + + public DemoCountry getCountry() { + return country; + } + + public static List<DemoProgram> getPrograms() { + return programs; + } + +} diff --git a/plugins/org.eclipse.osee.ats.client.demo/src/org/eclipse/osee/ats/client/demo/internal/AtsClientService.java b/plugins/org.eclipse.osee.ats.client.demo/src/org/eclipse/osee/ats/client/demo/internal/AtsClientService.java index 257a665cc2b..dea08e492eb 100644 --- a/plugins/org.eclipse.osee.ats.client.demo/src/org/eclipse/osee/ats/client/demo/internal/AtsClientService.java +++ b/plugins/org.eclipse.osee.ats.client.demo/src/org/eclipse/osee/ats/client/demo/internal/AtsClientService.java @@ -11,6 +11,10 @@ package org.eclipse.osee.ats.client.demo.internal; import org.eclipse.osee.ats.api.agile.AgileEndpointApi; +import org.eclipse.osee.ats.api.country.CountryEndpointApi; +import org.eclipse.osee.ats.api.insertion.InsertionActivityEndpointApi; +import org.eclipse.osee.ats.api.insertion.InsertionEndpointApi; +import org.eclipse.osee.ats.api.program.ProgramEndpointApi; import org.eclipse.osee.ats.core.client.IAtsClient; import org.eclipse.osee.framework.core.client.OseeClientProperties; import org.eclipse.osee.jaxrs.client.JaxRsClient; @@ -24,6 +28,10 @@ public class AtsClientService { private static IAtsClient atsClient; private static AgileEndpointApi agile; private static JaxRsWebTarget target; + private static CountryEndpointApi countryEp; + private static ProgramEndpointApi programEp; + private static InsertionEndpointApi insertionEp; + private static InsertionActivityEndpointApi insertionActivityEp; public void setAtsClient(IAtsClient atsClient) { AtsClientService.atsClient = atsClient; @@ -50,4 +58,32 @@ public class AtsClientService { return agile; } + public static CountryEndpointApi getCountryEp() { + if (countryEp == null) { + countryEp = getTarget().newProxy(CountryEndpointApi.class); + } + return countryEp; + } + + public static ProgramEndpointApi getProgramEp() { + if (programEp == null) { + programEp = getTarget().newProxy(ProgramEndpointApi.class); + } + return programEp; + } + + public static InsertionEndpointApi getInsertionEp() { + if (insertionEp == null) { + insertionEp = getTarget().newProxy(InsertionEndpointApi.class); + } + return insertionEp; + } + + public static InsertionActivityEndpointApi getInsertionActivityEp() { + if (insertionActivityEp == null) { + insertionActivityEp = getTarget().newProxy(InsertionActivityEndpointApi.class); + } + return insertionActivityEp; + } + } diff --git a/plugins/org.eclipse.osee.ats.client.demo/src/org/eclipse/osee/ats/client/demo/internal/AtsJaxRsService.java b/plugins/org.eclipse.osee.ats.client.demo/src/org/eclipse/osee/ats/client/demo/internal/AtsJaxRsService.java new file mode 100644 index 00000000000..d6459400e95 --- /dev/null +++ b/plugins/org.eclipse.osee.ats.client.demo/src/org/eclipse/osee/ats/client/demo/internal/AtsJaxRsService.java @@ -0,0 +1,37 @@ +/******************************************************************************* + * 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.demo.internal; + +import org.eclipse.osee.ats.api.AtsJaxRsApi; +import org.eclipse.osee.framework.core.client.OseeClientProperties; +import org.eclipse.osee.jaxrs.client.JaxRsClient; + +/** + * @author Donald G. Dunne + */ +public class AtsJaxRsService { + + private static AtsJaxRsApi atsEndpoint; + + public static AtsJaxRsApi get() { + if (atsEndpoint == null) { + String appServer = OseeClientProperties.getOseeApplicationServer(); + String atsUri = String.format("%s/ats", appServer); + + atsEndpoint = JaxRsClient.newBuilder() // + .createThreadSafeProxyClients(true) // if the client needs to be shared between threads + .build() // + .targetProxy(atsUri, AtsJaxRsApi.class); + } + return atsEndpoint; + } + +} diff --git a/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/AtsClientService.java b/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/AtsClientService.java index 655001342e9..07a22713ab6 100644 --- a/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/AtsClientService.java +++ b/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/AtsClientService.java @@ -11,6 +11,10 @@ package org.eclipse.osee.ats.client.integration.tests; import org.eclipse.osee.ats.api.agile.AgileEndpointApi; +import org.eclipse.osee.ats.api.country.CountryEndpointApi; +import org.eclipse.osee.ats.api.insertion.InsertionActivityEndpointApi; +import org.eclipse.osee.ats.api.insertion.InsertionEndpointApi; +import org.eclipse.osee.ats.api.program.ProgramEndpointApi; import org.eclipse.osee.ats.core.client.IAtsClient; import org.eclipse.osee.framework.core.client.OseeClientProperties; import org.eclipse.osee.jaxrs.client.JaxRsClient; @@ -26,6 +30,10 @@ public class AtsClientService { private static AgileEndpointApi agile; private static JaxRsWebTarget target; private static OrcsWriterEndpoint orcsWriter; + private static CountryEndpointApi countryEp; + private static ProgramEndpointApi programEp; + private static InsertionEndpointApi insertionEp; + private static InsertionActivityEndpointApi insertionActivityEp; public void setAtsClient(IAtsClient atsClient) { AtsClientService.atsClient = atsClient; @@ -62,4 +70,32 @@ public class AtsClientService { return orcsWriter; } + public static CountryEndpointApi getCountryEp() { + if (countryEp == null) { + countryEp = getTarget().newProxy(CountryEndpointApi.class); + } + return countryEp; + } + + public static ProgramEndpointApi getProgramEp() { + if (programEp == null) { + programEp = getTarget().newProxy(ProgramEndpointApi.class); + } + return programEp; + } + + public static InsertionEndpointApi getInsertionEp() { + if (insertionEp == null) { + insertionEp = getTarget().newProxy(InsertionEndpointApi.class); + } + return insertionEp; + } + + public static InsertionActivityEndpointApi getInsertionActivityEp() { + if (insertionActivityEp == null) { + insertionActivityEp = getTarget().newProxy(InsertionActivityEndpointApi.class); + } + return insertionActivityEp; + } + } diff --git a/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/DemoDbPopulateSuite.java b/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/DemoDbPopulateSuite.java index 1d5866db359..13684868598 100644 --- a/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/DemoDbPopulateSuite.java +++ b/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/DemoDbPopulateSuite.java @@ -12,6 +12,7 @@ package org.eclipse.osee.ats.client.integration.tests; import static org.junit.Assert.assertTrue; import org.eclipse.osee.ats.client.demo.DemoUtil; +import org.eclipse.osee.ats.client.integration.tests.ats.DemoCountryConfigTest; import org.eclipse.osee.framework.core.client.ClientSessionManager; import org.eclipse.osee.framework.jdk.core.util.OseeProperties; import org.eclipse.osee.framework.ui.skynet.render.RenderingUtil; @@ -25,6 +26,7 @@ import org.junit.runners.Suite; @Suite.SuiteClasses({// PopulateDemoDatabaseTest.class, DemoDbGroupsTest.class, + DemoCountryConfigTest.class, PopulateDemoActionsTest.class, DemoDbPopulateValidateAtsDatabaseTest.class // }) diff --git a/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/DemoCountryConfigTest.java b/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/DemoCountryConfigTest.java new file mode 100644 index 00000000000..3d371e21c3e --- /dev/null +++ b/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/DemoCountryConfigTest.java @@ -0,0 +1,120 @@ +/******************************************************************************* + * Copyright (c) 2011 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; + +import java.util.List; +import org.eclipse.osee.ats.api.country.JaxCountry; +import org.eclipse.osee.ats.api.insertion.JaxInsertion; +import org.eclipse.osee.ats.api.insertion.JaxInsertionActivity; +import org.eclipse.osee.ats.api.program.JaxProgram; +import org.eclipse.osee.ats.client.demo.DemoUtil; +import org.eclipse.osee.ats.client.demo.config.DemoCountry; +import org.eclipse.osee.ats.client.demo.config.DemoInsertion; +import org.eclipse.osee.ats.client.demo.config.DemoInsertionActivity; +import org.eclipse.osee.ats.client.demo.config.DemoProgram; +import org.eclipse.osee.ats.client.integration.tests.AtsClientService; +import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +/** + * @author Donald G. Dunne + */ +public class DemoCountryConfigTest { + + @BeforeClass + public static void validateDbInit() throws OseeCoreException { + DemoUtil.checkDbInitAndPopulateSuccess(); + } + + @Test + public void testCreateCountry() throws Exception { + List<JaxCountry> countries = AtsClientService.getCountryEp().get(); + Assert.assertEquals(2, countries.size()); + } + + @Test + public void testCreateProgram() throws Exception { + List<JaxProgram> programs = AtsClientService.getProgramEp().get(); + Assert.assertEquals(5, programs.size()); + } + + @Test + public void testCreateInsertion() throws Exception { + List<JaxInsertion> insertions = AtsClientService.getInsertionEp().get(); + Assert.assertEquals(12, insertions.size()); + } + + @Test + public void testCreateInsertionActivity() throws Exception { + List<JaxInsertionActivity> insertionActivities = AtsClientService.getInsertionActivityEp().get(); + Assert.assertEquals(10, insertionActivities.size()); + } + + @Test + public void testCreateSawConfig() throws Exception { + List<JaxCountry> countries = AtsClientService.getCountryEp().get(); + JaxCountry usgCountry = null; + for (JaxCountry country : countries) { + if (country.getUuid() == DemoCountry.usg.getUuid()) { + usgCountry = country; + break; + } + } + Assert.assertNotNull(usgCountry); + Assert.assertEquals(DemoCountry.usg.getName(), usgCountry.getName()); + Assert.assertEquals(DemoCountry.usg.getDescription(), usgCountry.getDescription()); + + List<JaxProgram> programs = AtsClientService.getCountryEp().getProgram(usgCountry.getUuid()).get(); + Assert.assertEquals(2, programs.size()); + + JaxProgram sawProgram = null; + for (JaxProgram program : programs) { + if (program.getUuid() == DemoProgram.sawProgram.getUuid()) { + sawProgram = program; + break; + } + } + + Assert.assertNotNull(sawProgram); + Assert.assertEquals(DemoProgram.sawProgram.getName(), sawProgram.getName()); + + List<JaxInsertion> insertions = AtsClientService.getProgramEp().getInsertion(sawProgram.getUuid()).get(); + Assert.assertEquals(4, insertions.size()); + + JaxInsertion sawCommInsertion = null; + for (JaxInsertion insertion : insertions) { + if (insertion.getUuid() == DemoInsertion.sawComm.getUuid()) { + sawCommInsertion = insertion; + break; + } + } + Assert.assertNotNull(sawCommInsertion); + Assert.assertEquals(DemoInsertion.sawComm.getName(), sawCommInsertion.getName()); + Assert.assertEquals(DemoInsertion.sawComm.getDescription(), sawCommInsertion.getDescription()); + + List<JaxInsertionActivity> insertionActivities = + AtsClientService.getInsertionEp().getInsertionActivity(sawCommInsertion.getUuid()).get(); + Assert.assertEquals(2, insertionActivities.size()); + + JaxInsertionActivity commPageInsertionActivity = null; + for (JaxInsertionActivity activity : insertionActivities) { + if (activity.getUuid() == DemoInsertionActivity.commPage.getUuid()) { + commPageInsertionActivity = activity; + break; + } + } + Assert.assertNotNull(commPageInsertionActivity); + Assert.assertEquals(DemoInsertionActivity.commPage.getName(), commPageInsertionActivity.getName()); + Assert.assertEquals(DemoInsertionActivity.commPage.getDescription(), commPageInsertionActivity.getDescription()); + } +} diff --git a/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/agile/AgileEndpointTest.java b/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/agile/AgileEndpointTest.java index b3b94a740a8..55a774db8ff 100644 --- a/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/agile/AgileEndpointTest.java +++ b/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/agile/AgileEndpointTest.java @@ -22,7 +22,6 @@ import org.eclipse.osee.ats.api.agile.JaxNewAgileFeatureGroup; import org.eclipse.osee.ats.api.agile.JaxNewAgileSprint; import org.eclipse.osee.ats.api.agile.JaxNewAgileTeam; import org.eclipse.osee.ats.client.integration.tests.AtsClientService; -import org.eclipse.osee.framework.jdk.core.util.GUID; import org.eclipse.osee.framework.jdk.core.util.Lib; import org.eclipse.osee.framework.skynet.core.artifact.Artifact; import org.junit.After; @@ -32,7 +31,7 @@ import org.junit.Test; /** * Test unit for AgileEndpointImpl - * + * * @author Donald G. Dunne */ public class AgileEndpointTest { @@ -161,7 +160,6 @@ public class AgileEndpointTest { JaxNewAgileBacklog backlog = new JaxNewAgileBacklog(); backlog.setName("My Backlog"); backlog.setTeamUuid(teamUuid); - String guid = GUID.create(); Long uuid = Lib.generateArtifactIdAsInt(); backlog.setUuid(uuid); 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 6a1221291ce..01a72dc2196 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 @@ -22,7 +22,10 @@ import org.junit.runners.Suite; @Suite.SuiteClasses({ TeamResourceTest.class, VersionResourceTest.class, + CountryResourceTest.class, ProgramResourceTest.class, + InsertionResourceTest.class, + InsertionActivityResourceTest.class, ActionableItemResourceTest.class, AtsTest_Demo_Copy_Suite.class, AtsBranchConfigurationTest.class, diff --git a/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/config/CountryResourceTest.java b/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/config/CountryResourceTest.java new file mode 100644 index 00000000000..71aef7d32da --- /dev/null +++ b/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/config/CountryResourceTest.java @@ -0,0 +1,62 @@ +/******************************************************************************* + * 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.config; + +import org.eclipse.osee.ats.client.demo.config.DemoCountry; +import org.junit.Assert; +import org.junit.Test; +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; + +/** + * Unit Test for {@link CountryResource} + * + * @author Donald G. Dunne + */ +public class CountryResourceTest extends AbstractConfigurationRestTest { + + @Test + public void testAtsCountriesRestCall() throws Exception { + JsonArray array = getAndCheck("/ats/country"); + Assert.assertEquals(2, array.size()); + JsonObject obj = getObjectNamed("USG", array); + Assert.assertNotNull("Did not find value USG", obj); + Assert.assertFalse(obj.has("ats.Description")); + } + + @Test + public void testAtsCountriesDetailsRestCall() throws Exception { + JsonArray array = getAndCheck("/ats/country/details"); + Assert.assertEquals(2, array.size()); + JsonObject obj = getObjectNamed("USG", array); + Assert.assertNotNull("Did not find value USG", obj); + Assert.assertTrue(obj.has("ats.Description")); + } + + @Test + public void testAtsCountryRestCall() throws Exception { + JsonArray array = getAndCheck("/ats/country/" + DemoCountry.usg.getUuid()); + Assert.assertEquals(1, array.size()); + JsonObject obj = getObjectNamed("USG", array); + Assert.assertNotNull("Did not find value USG", obj); + Assert.assertFalse(obj.has("ats.Description")); + } + + @Test + public void testAtsCountryDetailsRestCall() throws Exception { + JsonArray array = getAndCheck("/ats/country/" + DemoCountry.usg.getUuid() + "/details"); + Assert.assertEquals(1, array.size()); + JsonObject obj = getObjectNamed("USG", array); + Assert.assertNotNull("Did not find value USG", obj); + Assert.assertTrue(obj.has("ats.Description")); + } + +} diff --git a/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/config/InsertionActivityResourceTest.java b/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/config/InsertionActivityResourceTest.java new file mode 100644 index 00000000000..09e35d7fe67 --- /dev/null +++ b/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/config/InsertionActivityResourceTest.java @@ -0,0 +1,62 @@ +/******************************************************************************* + * 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.config; + +import org.eclipse.osee.ats.client.demo.config.DemoInsertionActivity; +import org.junit.Assert; +import org.junit.Test; +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; + +/** + * Unit Test for {@link InsertionResource} + * + * @author Donald G. Dunne + */ +public class InsertionActivityResourceTest extends AbstractConfigurationRestTest { + + @Test + public void testAtsInsertionActivitiesRestCall() throws Exception { + JsonArray array = getAndCheck("/ats/insertionactivity"); + Assert.assertEquals(10, array.size()); + JsonObject obj = getObjectNamed("COMM Page", array); + Assert.assertNotNull("Did not find value COMM Page", obj); + Assert.assertFalse(obj.has("ats.Description")); + } + + @Test + public void testAtsInsertionActivitiesDetailsRestCall() throws Exception { + JsonArray array = getAndCheck("/ats/insertionactivity/details"); + Assert.assertEquals(10, array.size()); + JsonObject obj = getObjectNamed("COMM Page", array); + Assert.assertNotNull("Did not find value COMM Page", obj); + Assert.assertTrue(obj.has("ats.Description")); + } + + @Test + public void testAtsInsertionActivityRestCall() throws Exception { + JsonArray array = getAndCheck("/ats/insertionactivity/" + DemoInsertionActivity.commPage.getUuid()); + Assert.assertEquals(1, array.size()); + JsonObject obj = getObjectNamed("COMM Page", array); + Assert.assertNotNull("Did not find value COMM Page", obj); + Assert.assertFalse(obj.has("ats.Description")); + } + + @Test + public void testAtsInsertionActivityDetailsRestCall() throws Exception { + JsonArray array = getAndCheck("/ats/insertionactivity/" + DemoInsertionActivity.commPage.getUuid() + "/details"); + Assert.assertEquals(1, array.size()); + JsonObject obj = getObjectNamed("COMM Page", array); + Assert.assertNotNull("Did not find value COMM Page", obj); + Assert.assertTrue(obj.has("ats.Description")); + } + +} diff --git a/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/config/InsertionResourceTest.java b/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/config/InsertionResourceTest.java new file mode 100644 index 00000000000..44fda27237e --- /dev/null +++ b/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/config/InsertionResourceTest.java @@ -0,0 +1,62 @@ +/******************************************************************************* + * 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.config; + +import org.eclipse.osee.ats.client.demo.config.DemoInsertion; +import org.junit.Assert; +import org.junit.Test; +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; + +/** + * Unit Test for {@link InsertionResource} + * + * @author Donald G. Dunne + */ +public class InsertionResourceTest extends AbstractConfigurationRestTest { + + @Test + public void testAtsInsertionsRestCall() throws Exception { + JsonArray array = getAndCheck("/ats/insertion"); + Assert.assertEquals(12, array.size()); + JsonObject obj = getObjectNamed("COMM", array); + Assert.assertNotNull("Did not find value COMM", obj); + Assert.assertFalse(obj.has("ats.Description")); + } + + @Test + public void testAtsInsertionsDetailsRestCall() throws Exception { + JsonArray array = getAndCheck("/ats/insertion/details"); + Assert.assertEquals(12, array.size()); + JsonObject obj = getObjectNamed("COMM", array); + Assert.assertNotNull("Did not find value COMM", obj); + Assert.assertTrue(obj.has("ats.Description")); + } + + @Test + public void testAtsInsertionRestCall() throws Exception { + JsonArray array = getAndCheck("/ats/insertion/" + DemoInsertion.sawComm.getUuid()); + Assert.assertEquals(1, array.size()); + JsonObject obj = getObjectNamed("COMM", array); + Assert.assertNotNull("Did not find value COMM", obj); + Assert.assertFalse(obj.has("ats.Description")); + } + + @Test + public void testAtsInsertionDetailsRestCall() throws Exception { + JsonArray array = getAndCheck("/ats/insertion/" + DemoInsertion.sawComm.getUuid() + "/details"); + Assert.assertEquals(1, array.size()); + JsonObject obj = getObjectNamed("COMM", array); + Assert.assertNotNull("Did not find value COMM", obj); + Assert.assertTrue(obj.has("ats.Description")); + } + +} 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 index 686da030115..65cd2ce3590 100644 --- 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 @@ -10,11 +10,8 @@ *******************************************************************************/ package org.eclipse.osee.ats.client.integration.tests.ats.config; -import javax.ws.rs.client.Entity; -import javax.ws.rs.core.MediaType; import org.eclipse.osee.ats.api.data.AtsArtifactTypes; import org.eclipse.osee.ats.core.util.AtsUtilCore; -import org.eclipse.osee.framework.core.client.server.HttpRequest.HttpMethod; import org.eclipse.osee.framework.skynet.core.artifact.Artifact; import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery; import org.junit.Assert; @@ -32,7 +29,7 @@ public class ProgramResourceTest extends AbstractConfigurationRestTest { @Test public void testAtsProgramsRestCall() throws Exception { JsonArray array = getAndCheck("/ats/program"); - Assert.assertEquals(2, array.size()); + Assert.assertEquals(5, array.size()); JsonObject obj = getObjectNamed("SAW Program", array); Assert.assertNotNull("Did not find value SAW Program", obj); Assert.assertFalse(obj.has("ats.Description")); @@ -41,7 +38,7 @@ public class ProgramResourceTest extends AbstractConfigurationRestTest { @Test public void testAtsProgramsDetailsRestCall() throws Exception { JsonArray array = getAndCheck("/ats/program/details"); - Assert.assertEquals(2, array.size()); + Assert.assertEquals(5, array.size()); JsonObject obj = getObjectNamed("SAW Program", array); Assert.assertNotNull("Did not find value SAW Program", obj); Assert.assertTrue(obj.has("ats.Description")); @@ -65,128 +62,9 @@ public class ProgramResourceTest extends AbstractConfigurationRestTest { Assert.assertTrue(obj.has("ats.Description")); } - @Test - public void testAtsProgramInsertionNegativeProgramIdRestCall() throws Exception { - String result = - doRequestString("/ats/program/" + Integer.toString(-5) + "/insertion", HttpMethod.GET, null, - javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - Assert.assertTrue(result.contains("SERVER_ERROR")); - } - - @Test - public void testAtsProgramInsertionBadProgramIdRestCall() throws Exception { - String result = - doRequestString("/ats/program/" + getSawTeam() + "/insertion", HttpMethod.GET, null, - javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - Assert.assertTrue(result.contains("SERVER_ERROR")); - } - - @Test - public void testAtsProgramInsertionCrudRestCalls() throws Exception { - String insertion = "{\"name\":\"JAX Insertion\",\"uuid\":12345678}"; - String updatedInsertion = "{\"name\":\"Renamed Insertion\",\"uuid\":12345678}"; - testCreateInsertion(insertion); - testGetInsertion(); - testUpdateInsertion(updatedInsertion); - testDeleteInsertion(); - } - - @Test - public void testAtsProgramInsertionActivityNegativeInsertionRestCall() throws Exception { - String result = - doRequestString( - "/ats/program/" + getSawProgram().getUuid() + "/insertion/" + Integer.toString(-5) + "/activity", - HttpMethod.GET, null, javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - Assert.assertTrue(result.contains("SERVER_ERROR")); - } - - @Test - public void testAtsProgramInsertionActivityBadInsertionRestCall() throws Exception { - String result = - doRequestString("/ats/program/" + getSawProgram().getUuid() + "/insertion/" + getSawTeam() + "/activity", - HttpMethod.GET, null, javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - Assert.assertTrue(result.contains("SERVER_ERROR")); - } - - @Test - public void testAtsProgramInsertionActivityCrudRestCalls() throws Exception { - String insertion = "{\"name\":\"JAX Insertion\",\"uuid\":1234567800}"; - String insertionActivity = "{\"name\":\"JAX Insertion Activity\",\"uuid\":87654321}"; - String insertionActivityUpdate = "{\"name\":\"Renamed Insertion Activity\",\"uuid\":87654321}"; - testCreateInsertionActivity(insertion, insertionActivity); - testGetInsertionActivity(); - testUpdateInsertionActivity(insertionActivityUpdate); - testDeleteInsertionActivity(); - } - private Artifact getSawProgram() { return ArtifactQuery.getArtifactFromTypeAndName(AtsArtifactTypes.Program, "SAW Program", AtsUtilCore.getAtsBranch()); } - private Long getSawTeam() { - return org.eclipse.osee.ats.client.demo.DemoArtifactToken.SAW_Requirements.getUuid(); - } - - private void testCreateInsertion(String insertion) throws Exception { - String url = "/ats/program/" + getSawProgram().getUuid() + "/insertion"; - JsonArray array = postAndCheck(url, Entity.entity(insertion, MediaType.APPLICATION_JSON_TYPE)); - Assert.assertEquals(1, array.size()); - JsonObject obj = getObjectNamed("JAX Insertion", array); - Assert.assertNotNull("Did not find value Jax Insertion", obj); - } - - private void testGetInsertion() throws Exception { - String url = "/ats/program/" + getSawProgram().getUuid() + "/insertion"; - JsonArray array = getAndCheck(url); - JsonObject obj = getObjectNamed("JAX Insertion", array); - Assert.assertNotNull("Did not find value Jax Insertion", obj); - } - - private void testUpdateInsertion(String updatedInsertion) throws Exception { - String url = "/ats/program/" + getSawProgram().getUuid() + "/insertion"; - JsonArray array = putAndCheck(url, Entity.entity(updatedInsertion, MediaType.APPLICATION_JSON_TYPE)); - Assert.assertEquals(1, array.size()); - JsonObject obj = getObjectNamed("Renamed Insertion", array); - Assert.assertNotNull("Did not find value Renamed Insertion", obj); - } - - private void testDeleteInsertion() throws Exception { - String url = "/ats/program/" + getSawProgram().getUuid() + "/insertion/12345678"; - deleteAndCheck(url); - } - - private void testCreateInsertionActivity(String insertion, String insertionActivity) throws Exception { - String urlInsertion = "/ats/program/" + getSawProgram().getUuid() + "/insertion"; - String urlActivity = "/ats/program/" + getSawProgram().getUuid() + "/insertion/1234567800/activity"; - JsonArray setup = postAndCheck(urlInsertion, Entity.entity(insertion, MediaType.APPLICATION_JSON_TYPE)); - JsonArray array = postAndCheck(urlActivity, Entity.entity(insertionActivity, MediaType.APPLICATION_JSON_TYPE)); - Assert.assertEquals(1, array.size()); - JsonObject obj = getObjectNamed("JAX Insertion Activity", array); - Assert.assertNotNull("Did not find value Jax Insertion Activity", obj); - } - - private void testGetInsertionActivity() throws Exception { - String url = "/ats/program/" + getSawProgram().getUuid() + "/insertion/1234567800/activity"; - JsonArray array = getAndCheck(url); - Assert.assertEquals(1, array.size()); - JsonObject obj = getObjectNamed("JAX Insertion Activity", array); - Assert.assertNotNull("Did not find value Jax Insertion Activity", obj); - } - - private void testUpdateInsertionActivity(String insertion) throws Exception { - String url = "/ats/program/" + getSawProgram().getUuid() + "/insertion/1234567800/activity"; - JsonArray array = putAndCheck(url, Entity.entity(insertion, MediaType.APPLICATION_JSON_TYPE)); - Assert.assertEquals(1, array.size()); - JsonObject obj = getObjectNamed("Renamed Insertion Activity", array); - Assert.assertNotNull("Did not find value Renamed Insertion Activity", obj); - } - - private void testDeleteInsertionActivity() throws Exception { - String url = "/ats/program/" + getSawProgram().getUuid() + "/insertion/1234567800/activity/87654321"; - deleteAndCheck(url); - // clean up insertion, too - url = "/ats/program/" + getSawProgram().getUuid() + "/insertion/1234567800"; - deleteAndCheck(url); - } } diff --git a/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/util/AtsJaxRsService.java b/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/util/AtsJaxRsService.java new file mode 100644 index 00000000000..9db7ffe8ef2 --- /dev/null +++ b/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/util/AtsJaxRsService.java @@ -0,0 +1,37 @@ +/******************************************************************************* + * 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.util; + +import org.eclipse.osee.ats.api.AtsJaxRsApi; +import org.eclipse.osee.framework.core.client.OseeClientProperties; +import org.eclipse.osee.jaxrs.client.JaxRsClient; + +/** + * @author Donald G. Dunne + */ +public class AtsJaxRsService { + + private static AtsJaxRsApi atsEndpoint; + + public static AtsJaxRsApi get() { + if (atsEndpoint == null) { + String appServer = OseeClientProperties.getOseeApplicationServer(); + String atsUri = String.format("%s/ats", appServer); + + atsEndpoint = JaxRsClient.newBuilder() // + .createThreadSafeProxyClients(true) // if the client needs to be shared between threads + .build() // + .targetProxy(atsUri, AtsJaxRsApi.class); + } + return atsEndpoint; + } + +} diff --git a/plugins/org.eclipse.osee.ats.core.client/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.ats.core.client/META-INF/MANIFEST.MF index 9ee485ede00..1ee45791228 100644 --- a/plugins/org.eclipse.osee.ats.core.client/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.osee.ats.core.client/META-INF/MANIFEST.MF @@ -61,6 +61,7 @@ Import-Package: com.google.inject, org.eclipse.osee.framework.ui.skynet.util, org.eclipse.osee.jaxrs.client, org.eclipse.osee.jdbc, + org.eclipse.osee.logger, org.eclipse.osee.orcs.rest.client, org.eclipse.osee.orcs.search, org.osgi.framework diff --git a/plugins/org.eclipse.osee.ats.core.client/OSGI-INF/ats.client.service.xml b/plugins/org.eclipse.osee.ats.core.client/OSGI-INF/ats.client.service.xml index aef7c137791..30dc73db4e6 100644 --- a/plugins/org.eclipse.osee.ats.core.client/OSGI-INF/ats.client.service.xml +++ b/plugins/org.eclipse.osee.ats.core.client/OSGI-INF/ats.client.service.xml @@ -8,4 +8,5 @@ </service> <reference bind="setAtsWorkDefinitionService" cardinality="1..1" interface="org.eclipse.osee.ats.api.workdef.IAtsWorkDefinitionService" name="IAtsWorkDefinitionService" policy="static"/> <reference bind="setJdbcService" cardinality="1..1" interface="org.eclipse.osee.jdbc.JdbcService" name="JdbcService" policy="static" target="(osgi.binding=skynet.jdbc.service)"/> + <reference bind="setLogger" cardinality="1..1" interface="org.eclipse.osee.logger.Log" name="Log" policy="static"/> </scr:component> 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 915cf11f59e..831fa7d36ff 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 @@ -169,6 +169,7 @@ public interface IAtsClient extends IAtsServices, IAtsNotifier, IAttributeResolv Artifact checkArtifactFromId(long uuid, IOseeBranch atsBranch); + @Override IAtsStoreService getStoreService(); TeamWorkflowProviders getTeamWorkflowProviders(); 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 index decd97d9e71..217d778f5d3 100644 --- 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 @@ -11,6 +11,7 @@ package org.eclipse.osee.ats.core.client.config; import org.eclipse.osee.ats.api.data.AtsAttributeTypes; +import org.eclipse.osee.ats.api.data.AtsRelationTypes; 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; @@ -96,4 +97,14 @@ public abstract class AbstractAtsProgramClient extends AbstractAtsProgram implem return artifact.getSoleAttributeValue(AtsAttributeTypes.Description, ""); } + @Override + public long getCountryUuid() { + long countryUuid = 0L; + Artifact countryArt = artifact.getRelatedArtifactOrNull(AtsRelationTypes.CountryToProgram_Country); + if (countryArt != null) { + countryUuid = countryArt.getUuid(); + } + return countryUuid; + } + } 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 f024b513e32..b598496e96d 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 @@ -122,6 +122,7 @@ 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; +import org.eclipse.osee.logger.Log; /** * @author Donald G. Dunne @@ -167,6 +168,7 @@ public class AtsClientImpl implements IAtsClient { private ArtifactCollectorsCache<SprintArtifact> sprintItemsCache; private AtsStoreService atsStoreService; private TeamWorkflowProviders teamWorkflowProvidersLazy; + private Log logger; public void setJdbcService(JdbcService jdbcService) { this.jdbcService = jdbcService; @@ -176,6 +178,10 @@ public class AtsClientImpl implements IAtsClient { this.workDefService = workDefService; } + public void setLogger(Log logger) { + this.logger = logger; + } + public void start() throws OseeCoreException { Conditions.checkNotNull(workDefService, "IAtsWorkDefinitionService"); Map<Class<? extends IAtsConfigObject>, IAtsArtifactWriter<? extends IAtsConfigObject>> writers = @@ -195,7 +201,7 @@ public class AtsClientImpl implements IAtsClient { configCacheProvider = new AtsConfigCacheProvider(artifactStore); earnedValueService = new AtsEarnedValueImpl(); - configItemFactory = new ConfigItemFactory(this); + configItemFactory = new ConfigItemFactory(logger, this); AtsVersionCache versionCache = new AtsVersionCache(configCacheProvider); versionService = new AtsVersionServiceImpl(this, configCacheProvider, versionCache); @@ -559,11 +565,11 @@ public class AtsClientImpl implements IAtsClient { AtsCoreFactory.getColumnUtilities(getReviewService(), getWorkItemService(), new IAtsEarnedValueServiceProvider() { - @Override - public IAtsEarnedValueService getEarnedValueService() throws OseeStateException { - return fEarnedValueService; - } - }); + @Override + public IAtsEarnedValueService getEarnedValueService() throws OseeStateException { + return fEarnedValueService; + } + }); } return columnUtilities; } @@ -774,4 +780,9 @@ public class AtsClientImpl implements IAtsClient { return getArtifact(token.getUuid()); } + @Override + public <A extends IAtsConfigObject> A getSoleByUuid(long uuid, Class<A> clazz) throws OseeCoreException { + return getConfig().getSoleByUuid(uuid, clazz); + } + } diff --git a/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/internal/ConfigItemFactory.java b/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/internal/ConfigItemFactory.java index 92a647b48a5..c56558e45d6 100644 --- a/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/internal/ConfigItemFactory.java +++ b/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/internal/ConfigItemFactory.java @@ -14,22 +14,24 @@ import org.eclipse.osee.ats.api.IAtsConfigObject; import org.eclipse.osee.ats.api.agile.IAgileFeatureGroup; import org.eclipse.osee.ats.api.agile.IAgileTeam; import org.eclipse.osee.ats.api.ai.IAtsActionableItem; +import org.eclipse.osee.ats.api.country.IAtsCountry; import org.eclipse.osee.ats.api.data.AtsArtifactTypes; import org.eclipse.osee.ats.api.insertion.IAtsInsertion; import org.eclipse.osee.ats.api.insertion.IAtsInsertionActivity; -import org.eclipse.osee.ats.api.insertion.JaxNewInsertion; -import org.eclipse.osee.ats.api.insertion.JaxNewInsertionActivity; +import org.eclipse.osee.ats.api.insertion.JaxInsertion; +import org.eclipse.osee.ats.api.insertion.JaxInsertionActivity; 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.core.client.IAtsClient; import org.eclipse.osee.ats.core.client.agile.AgileFeatureGroup; import org.eclipse.osee.ats.core.client.agile.AgileTeam; -import org.eclipse.osee.ats.core.client.program.internal.Program; import org.eclipse.osee.ats.core.config.AbstractConfigItemFactory; +import org.eclipse.osee.ats.core.config.Program; import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.framework.skynet.core.artifact.Artifact; +import org.eclipse.osee.logger.Log; /** * @author Donald G. Dunne @@ -37,8 +39,10 @@ import org.eclipse.osee.framework.skynet.core.artifact.Artifact; public class ConfigItemFactory extends AbstractConfigItemFactory { private final IAtsClient atsClient; + private final Log logger; - public ConfigItemFactory(IAtsClient atsClient) { + public ConfigItemFactory(Log logger, IAtsClient atsClient) { + this.logger = logger; this.atsClient = atsClient; } @@ -61,6 +65,12 @@ public class ConfigItemFactory extends AbstractConfigItemFactory { configObject = getAgileTeam(artifact); } else if (artifact.isOfType(AtsArtifactTypes.AgileFeatureGroup)) { configObject = getAgileFeatureGroup(artifact); + } else if (artifact.isOfType(AtsArtifactTypes.Insertion)) { + configObject = getInsertion(artifact); + } else if (artifact.isOfType(AtsArtifactTypes.InsertionActivity)) { + configObject = getInsertionActivity(artifact); + } else if (artifact.isOfType(AtsArtifactTypes.Country)) { + configObject = getCountry(artifact); } } return configObject; @@ -99,7 +109,7 @@ public class ConfigItemFactory extends AbstractConfigItemFactory { if (object instanceof IAtsProgram) { program = (IAtsProgram) object; } else if ((object instanceof Artifact) && ((Artifact) object).isOfType(AtsArtifactTypes.Program)) { - program = new Program(atsClient, (Artifact) object); + program = new Program(logger, atsClient.getServices(), object); } return program; } @@ -137,12 +147,12 @@ public class ConfigItemFactory extends AbstractConfigItemFactory { } @Override - public IAtsInsertion createInsertion(ArtifactId teamArtifact, JaxNewInsertion newInsertion) { + public IAtsInsertion createInsertion(ArtifactId teamArtifact, JaxInsertion newInsertion) { throw new UnsupportedOperationException("createInsertion not implemented on client"); } @Override - public IAtsInsertion updateInsertion(JaxNewInsertion newInsertion) { + public IAtsInsertion updateInsertion(JaxInsertion newInsertion) { throw new UnsupportedOperationException("updateInsertion not implemented on client"); } @@ -152,12 +162,12 @@ public class ConfigItemFactory extends AbstractConfigItemFactory { } @Override - public IAtsInsertionActivity createInsertionActivity(ArtifactId insertion, JaxNewInsertionActivity newActivity) { + public IAtsInsertionActivity createInsertionActivity(ArtifactId insertion, JaxInsertionActivity newActivity) { throw new UnsupportedOperationException("createInsertionActivity not implemented on client"); } @Override - public IAtsInsertionActivity updateInsertionActivity(JaxNewInsertionActivity newActivity) { + public IAtsInsertionActivity updateInsertionActivity(JaxInsertionActivity newActivity) { throw new UnsupportedOperationException("updateInsertionActivity not implemented on client"); } @@ -171,4 +181,18 @@ public class ConfigItemFactory extends AbstractConfigItemFactory { return getAtsConfigArtifactTypes().contains(((Artifact) artifact).getArtifactType()); } + @Override + public IAtsCountry getCountry(ArtifactId artifact) { + IAtsCountry country = null; + if ((artifact instanceof Artifact) && ((Artifact) artifact).isOfType(AtsArtifactTypes.Country)) { + country = (IAtsCountry) atsClient.getConfigObject((Artifact) artifact); + } + return country; + } + + @Override + public IAtsCountry getCountry(long uuid) { + return getCountry(atsClient.getArtifact(uuid)); + } + } diff --git a/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/program/internal/AtsProgramService.java b/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/program/internal/AtsProgramService.java index 795e6c9d5af..2ed01eafbc7 100644 --- a/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/program/internal/AtsProgramService.java +++ b/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/program/internal/AtsProgramService.java @@ -10,7 +10,9 @@ *******************************************************************************/ package org.eclipse.osee.ats.core.client.program.internal; +import java.util.List; import org.eclipse.osee.ats.api.IAtsWorkItem; +import org.eclipse.osee.ats.api.country.IAtsCountry; import org.eclipse.osee.ats.api.data.AtsAttributeTypes; import org.eclipse.osee.ats.api.program.IAtsProgram; import org.eclipse.osee.ats.api.program.IAtsProgramService; @@ -59,4 +61,14 @@ public class AtsProgramService implements IAtsProgramService { throw new UnsupportedOperationException("Not implemented yet"); } + @Override + public IAtsCountry getCountry(IAtsProgram atsProgram) { + throw new UnsupportedOperationException("Not implemented yet"); + } + + @Override + public List<IAtsProgram> getPrograms(IAtsCountry atsCountry) { + throw new UnsupportedOperationException("Not implemented yet"); + } + } diff --git a/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/program/internal/Program.java b/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/program/internal/Program.java deleted file mode 100644 index f5833ca07aa..00000000000 --- a/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/program/internal/Program.java +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013 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.program.internal; - -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.core.client.IAtsClient; -import org.eclipse.osee.ats.core.client.internal.config.AtsConfigObject; -import org.eclipse.osee.framework.jdk.core.util.Strings; -import org.eclipse.osee.framework.skynet.core.artifact.Artifact; - -/** - * @author Donald G. Dunne - */ -public class Program extends AtsConfigObject implements IAtsProgram { - - public Program(IAtsClient atsClient, Artifact artifact) { - super(atsClient, artifact); - } - - @Override - public long getUuid() { - return getUuid(); - } - - @Override - public IAtsTeamDefinition getTeamDefinition() { - IAtsTeamDefinition teamDef = null; - String teamDefGuid = getAttributeValue(AtsAttributeTypes.TeamDefinition, ""); - if (Strings.isValid(teamDefGuid)) { - Long uuid = getAtsClient().getStoreService().getUuidFromGuid(teamDefGuid); - teamDef = getAtsClient().getConfig().getSoleByUuid(uuid, IAtsTeamDefinition.class); - } - return teamDef; - } - - @Override - public String getNamespace() { - return getAttributeValue(AtsAttributeTypes.Namespace, ""); - } - - @Override - public String getTypeName() { - return artifact.getArtifactTypeName(); - } - -} diff --git a/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/util/AtsChangeSet.java b/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/util/AtsChangeSet.java index 29a47d88ea7..9957a4b6a87 100644 --- a/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/util/AtsChangeSet.java +++ b/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/util/AtsChangeSet.java @@ -296,4 +296,10 @@ public class AtsChangeSet extends AbstractAtsChangeSet { } add(artifact); } + + @Override + public void deleteArtifact(ArtifactId artifact) { + getArtifact(artifact).delete(); + add(getArtifact(artifact)); + } } diff --git a/plugins/org.eclipse.osee.ats.core/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.ats.core/META-INF/MANIFEST.MF index ee8dfce8c48..c589768c196 100644 --- a/plugins/org.eclipse.osee.ats.core/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.osee.ats.core/META-INF/MANIFEST.MF @@ -20,6 +20,7 @@ Export-Package: org.eclipse.osee.ats.core, org.eclipse.osee.ats.core.column, org.eclipse.osee.ats.core.config, org.eclipse.osee.ats.core.cpa, + org.eclipse.osee.ats.core.insertion, org.eclipse.osee.ats.core.internal.state, org.eclipse.osee.ats.core.model, org.eclipse.osee.ats.core.model.impl, 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 37f7ac589db..7b20a796777 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,9 +25,10 @@ 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.InsertionActivity); + atsConfigArtifactTypes = + Arrays.asList(AtsArtifactTypes.Version, AtsArtifactTypes.TeamDefinition, AtsArtifactTypes.ActionableItem, + AtsArtifactTypes.Country, AtsArtifactTypes.Program, AtsArtifactTypes.Insertion, + AtsArtifactTypes.InsertionActivity, AtsArtifactTypes.AgileTeam, AtsArtifactTypes.AgileFeatureGroup); } @Override diff --git a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/config/Country.java b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/config/Country.java new file mode 100644 index 00000000000..152d46ba945 --- /dev/null +++ b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/config/Country.java @@ -0,0 +1,43 @@ +/******************************************************************************* + * 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.core.config; + +import org.eclipse.osee.ats.api.IAtsServices; +import org.eclipse.osee.ats.api.country.IAtsCountry; +import org.eclipse.osee.ats.api.data.AtsAttributeTypes; +import org.eclipse.osee.ats.core.model.impl.AtsConfigObject; +import org.eclipse.osee.framework.core.data.ArtifactId; +import org.eclipse.osee.logger.Log; + +/** + * @author Donald G Dunne + */ +public class Country extends AtsConfigObject implements IAtsCountry { + + public Country(Log logger, IAtsServices atsServer, ArtifactId artifact) { + super(logger, atsServer, artifact); + } + + @Override + public String getTypeName() { + return "Country"; + } + + @Override + public long getUuid() { + return artifact.getUuid(); + } + + @Override + public String getDescription() { + return atsServices.getAttributeResolver().getSoleAttributeValue(artifact, AtsAttributeTypes.Description, ""); + } +} 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.core/src/org/eclipse/osee/ats/core/config/Program.java index 48a897ce7b9..fd86f8ddcda 100644 --- a/plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/internal/workitem/Program.java +++ b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/config/Program.java @@ -8,30 +8,27 @@ * Contributors: * Boeing - initial API and implementation *******************************************************************************/ -package org.eclipse.osee.ats.impl.internal.workitem; +package org.eclipse.osee.ats.core.config; +import org.eclipse.osee.ats.api.IAtsServices; import org.eclipse.osee.ats.api.data.AtsAttributeTypes; +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.core.model.impl.AtsConfigObject; -import org.eclipse.osee.ats.impl.IAtsServer; +import org.eclipse.osee.framework.core.data.ArtifactId; 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; - private final IAtsServer atsServer; + private final IAtsServices atsServices; - public Program(Log logger, IAtsServer atsServer, ArtifactReadable artifact) { - super(logger, atsServer, artifact); - this.atsServer = atsServer; - } - - private ArtifactReadable getArtifact() { - return (ArtifactReadable) artifact; + public Program(Log logger, IAtsServices atsServices, ArtifactId artifact) { + super(logger, atsServices, artifact); + this.atsServices = atsServices; } @Override @@ -47,16 +44,28 @@ public class Program extends AtsConfigObject implements IAtsProgram { @Override public IAtsTeamDefinition getTeamDefinition() { if (teamDefinition == null) { - String teamDefGuid = getArtifact().getSoleAttributeValue(AtsAttributeTypes.TeamDefinition, ""); - Long uuid = atsServer.getStoreService().getUuidFromGuid(teamDefGuid); - teamDefinition = atsServer.getConfig().getSoleByUuid(uuid, IAtsTeamDefinition.class); + String teamDefGuid = + atsServices.getAttributeResolver().getSoleAttributeValue(artifact, AtsAttributeTypes.TeamDefinition, ""); + Long uuid = atsServices.getStoreService().getUuidFromGuid(teamDefGuid); + teamDefinition = atsServices.getSoleByUuid(uuid, IAtsTeamDefinition.class); } return teamDefinition; } @Override public String getNamespace() { - return getArtifact().getSoleAttributeValue(AtsAttributeTypes.Namespace, ""); + return atsServices.getAttributeResolver().getSoleAttributeValue(artifact, AtsAttributeTypes.Namespace, ""); + } + + @Override + public long getCountryUuid() { + long uuid = 0L; + ArtifactId countryArt = + atsServices.getRelationResolver().getRelatedOrNull(artifact, AtsRelationTypes.CountryToProgram_Country); + if (countryArt != null) { + uuid = countryArt.getUuid(); + } + return uuid; } } diff --git a/plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/internal/workitem/Insertion.java b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/insertion/Insertion.java index b33185ff409..997c5bf4a94 100644 --- a/plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/internal/workitem/Insertion.java +++ b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/insertion/Insertion.java @@ -8,21 +8,23 @@ * Contributors: * Boeing - initial API and implementation *******************************************************************************/ -package org.eclipse.osee.ats.impl.internal.workitem; +package org.eclipse.osee.ats.core.insertion; +import org.eclipse.osee.ats.api.IAtsServices; import org.eclipse.osee.ats.api.insertion.IAtsInsertion; import org.eclipse.osee.ats.core.model.impl.AtsConfigObject; -import org.eclipse.osee.ats.impl.IAtsServer; +import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.logger.Log; -import org.eclipse.osee.orcs.data.ArtifactReadable; /** * @author David W. Miller */ public class Insertion extends AtsConfigObject implements IAtsInsertion { - public Insertion(Log logger, IAtsServer atsServer, ArtifactReadable artifact) { - super(logger, atsServer, artifact); + private long programUuid; + + public Insertion(Log logger, IAtsServices atsServices, ArtifactId artifact) { + super(logger, atsServices, artifact); } @Override @@ -30,4 +32,12 @@ public class Insertion extends AtsConfigObject implements IAtsInsertion { return "Insertion"; } + @Override + public long getProgramUuid() { + return programUuid; + } + + public void setProgramUuid(long programUuid) { + this.programUuid = programUuid; + } } diff --git a/plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/internal/workitem/InsertionActivity.java b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/insertion/InsertionActivity.java index 33c5f083e6f..a1fbe8fcde1 100644 --- a/plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/internal/workitem/InsertionActivity.java +++ b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/insertion/InsertionActivity.java @@ -8,20 +8,22 @@ * Contributors: * Boeing - initial API and implementation *******************************************************************************/ -package org.eclipse.osee.ats.impl.internal.workitem; +package org.eclipse.osee.ats.core.insertion; +import org.eclipse.osee.ats.api.IAtsServices; import org.eclipse.osee.ats.api.insertion.IAtsInsertionActivity; import org.eclipse.osee.ats.core.model.impl.AtsConfigObject; -import org.eclipse.osee.ats.impl.IAtsServer; +import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.logger.Log; -import org.eclipse.osee.orcs.data.ArtifactReadable; /** * @author David W. Miller */ public class InsertionActivity extends AtsConfigObject implements IAtsInsertionActivity { - public InsertionActivity(Log logger, IAtsServer atsServer, ArtifactReadable artifact) { + private long insertionUuid; + + public InsertionActivity(Log logger, IAtsServices atsServer, ArtifactId artifact) { super(logger, atsServer, artifact); } @@ -30,4 +32,13 @@ public class InsertionActivity extends AtsConfigObject implements IAtsInsertionA return "Insertion Activity"; } + @Override + public long getInsertionUuid() { + return insertionUuid; + } + + public void setInsertionUuid(long insertionUuid) { + this.insertionUuid = insertionUuid; + } + } diff --git a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/model/impl/AtsConfigObject.java b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/model/impl/AtsConfigObject.java index 6b10cf85d8a..341f8bf1dc0 100644 --- a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/model/impl/AtsConfigObject.java +++ b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/model/impl/AtsConfigObject.java @@ -132,4 +132,8 @@ public abstract class AtsConfigObject extends org.eclipse.osee.ats.core.model.im return artifact.getUuid(); } + @Override + public String getDescription() { + return atsServices.getAttributeResolver().getSoleAttributeValue(artifact, AtsAttributeTypes.Description, ""); + } } diff --git a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/util/AbstractAtsChangeSet.java b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/util/AbstractAtsChangeSet.java index 84f0a29cafb..042283d1962 100644 --- a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/util/AbstractAtsChangeSet.java +++ b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/util/AbstractAtsChangeSet.java @@ -17,6 +17,8 @@ import org.eclipse.osee.ats.api.notify.AtsNotificationCollector; import org.eclipse.osee.ats.api.user.IAtsUser; import org.eclipse.osee.ats.api.util.IAtsChangeSet; import org.eclipse.osee.ats.api.util.IExecuteListener; +import org.eclipse.osee.framework.core.data.ArtifactId; +import org.eclipse.osee.framework.core.data.IArtifactToken; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.framework.jdk.core.util.Conditions; @@ -108,4 +110,9 @@ public abstract class AbstractAtsChangeSet implements IAtsChangeSet { return notifications; } + @Override + public ArtifactId createArtifact(IArtifactToken token) { + return createArtifact(token.getArtifactType(), token.getName(), token.getGuid(), token.getUuid()); + } + } 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 72efd81fc03..62566dd675f 100644 --- a/plugins/org.eclipse.osee.ats.impl/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.osee.ats.impl/META-INF/MANIFEST.MF @@ -12,6 +12,7 @@ Import-Package: com.google.common.cache;version="15.0.0", org.eclipse.core.runtime, org.eclipse.osee.ats.core.ai, org.eclipse.osee.ats.core.config, + org.eclipse.osee.ats.core.insertion, org.eclipse.osee.ats.core.model.impl, org.eclipse.osee.ats.core.query, org.eclipse.osee.ats.core.review, diff --git a/plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/IAtsServer.java b/plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/IAtsServer.java index 7ae8d479483..80d521856f7 100644 --- a/plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/IAtsServer.java +++ b/plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/IAtsServer.java @@ -55,6 +55,7 @@ public interface IAtsServer extends IAtsServices, IAtsNotifier, IAtsConfigItemFa ArtifactReadable getArtifactByGuid(String guid); + @Override IAtsStoreService getStoreService(); @Override diff --git a/plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/config/BaseConfigEndpointImpl.java b/plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/config/BaseConfigEndpointImpl.java new file mode 100644 index 00000000000..ac76b886692 --- /dev/null +++ b/plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/config/BaseConfigEndpointImpl.java @@ -0,0 +1,135 @@ +/******************************************************************************* + * 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.net.URI; +import java.util.List; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.core.Response; +import org.eclipse.osee.ats.api.IAtsObject; +import org.eclipse.osee.ats.api.config.BaseConfigEndpointApi; +import org.eclipse.osee.ats.api.config.JaxAtsObject; +import org.eclipse.osee.ats.api.data.AtsArtifactToken; +import org.eclipse.osee.ats.api.data.AtsAttributeTypes; +import org.eclipse.osee.ats.api.util.IAtsChangeSet; +import org.eclipse.osee.ats.core.users.AtsCoreUsers; +import org.eclipse.osee.ats.impl.IAtsServer; +import org.eclipse.osee.framework.core.data.ArtifactId; +import org.eclipse.osee.framework.core.data.IArtifactToken; +import org.eclipse.osee.framework.core.data.IArtifactType; +import org.eclipse.osee.framework.core.enums.CoreRelationTypes; +import org.eclipse.osee.framework.jdk.core.type.OseeStateException; +import org.eclipse.osee.framework.jdk.core.util.GUID; +import org.eclipse.osee.framework.jdk.core.util.Strings; +import org.eclipse.osee.orcs.data.ArtifactReadable; + +/** + * @author Donald G. Dunne + */ +public abstract class BaseConfigEndpointImpl<T extends JaxAtsObject> implements BaseConfigEndpointApi<T> { + + protected final IAtsServer atsServer; + protected final IArtifactType artifactType; + protected final IArtifactToken typeFolder; + + public BaseConfigEndpointImpl(IArtifactType artifactType, IArtifactToken typeFolder, IAtsServer atsServer) { + this.artifactType = artifactType; + this.typeFolder = typeFolder; + this.atsServer = atsServer; + } + + @Override + @GET + public List<T> get() throws Exception { + return getObjects(); + } + + @Override + @GET + @Path("{uuid}") + public T get(@PathParam("uuid") long uuid) throws Exception { + return getObject(uuid); + } + + @Override + @POST + public Response create(T jaxAtsObject) throws Exception { + if (jaxAtsObject.getUuid() <= 0L) { + throw new OseeStateException("Invalid uuid %d"); + } else if (!Strings.isValid(jaxAtsObject.getName())) { + throw new OseeStateException("Invalid name [%d]"); + } + ArtifactReadable artifact = atsServer.getArtifactByUuid(jaxAtsObject.getUuid()); + if (artifact != null) { + throw new OseeStateException("Artifact with uuid %d already exists", jaxAtsObject.getUuid()); + } + IAtsChangeSet changes = + atsServer.getStoreService().createAtsChangeSet("Create " + artifactType.getName(), AtsCoreUsers.SYSTEM_USER); + ArtifactId newArtifact = + changes.createArtifact(artifactType, jaxAtsObject.getName(), GUID.create(), jaxAtsObject.getUuid()); + IAtsObject newAtsObject = atsServer.getConfigItemFactory().getConfigObject(newArtifact); + if (typeFolder != null) { + ArtifactReadable typeFolderArtifact = atsServer.getArtifact(typeFolder); + if (typeFolderArtifact == null) { + typeFolderArtifact = (ArtifactReadable) changes.createArtifact(AtsArtifactToken.CountryFolder); + } + if (typeFolderArtifact.getParent() == null) { + ArtifactReadable headingFolder = atsServer.getArtifact(AtsArtifactToken.HeadingFolder); + changes.relate(headingFolder, CoreRelationTypes.Default_Hierarchical__Child, typeFolderArtifact); + } + changes.relate(typeFolderArtifact, CoreRelationTypes.Default_Hierarchical__Child, newArtifact); + } + if (Strings.isValid(jaxAtsObject.getDescription())) { + changes.setSoleAttributeValue(newAtsObject, AtsAttributeTypes.Description, jaxAtsObject.getDescription()); + } else { + changes.deleteAttributes(newAtsObject, AtsAttributeTypes.Description); + } + changes.setSoleAttributeValue(newAtsObject, AtsAttributeTypes.Active, jaxAtsObject.isActive()); + create(jaxAtsObject, newArtifact, changes); + changes.execute(); + return Response.created(new URI("/" + jaxAtsObject.getUuid())).build(); + } + + /** + * Implement by subclass to perform other checks and sets during artifact creation + */ + protected void create(T jaxAtsObject, ArtifactId newArtifact, IAtsChangeSet changes) { + // provided for subclass implementation + } + + @Override + @DELETE + public Response delete(@PathParam("uuid") long uuid) throws Exception { + ArtifactReadable artifact = atsServer.getArtifactByUuid(uuid); + if (artifact == null) { + throw new OseeStateException("Artifact with uuid %d not found", uuid); + } + IAtsChangeSet changes = + atsServer.getStoreService().createAtsChangeSet("Create " + artifactType.getName(), AtsCoreUsers.SYSTEM_USER); + changes.deleteArtifact(artifact); + changes.execute(); + return Response.ok().build(); + } + + public abstract T getConfigObject(ArtifactId artifact); + + protected T getObject(long uuid) { + ArtifactReadable configArt = atsServer.getQuery().andUuid(uuid).getResults().getExactlyOne(); + return getConfigObject(configArt); + } + + public abstract List<T> getObjects(); + +} diff --git a/plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/internal/AtsServerImpl.java b/plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/internal/AtsServerImpl.java index 392f12dba2c..9206ff9a221 100644 --- a/plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/internal/AtsServerImpl.java +++ b/plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/internal/AtsServerImpl.java @@ -18,6 +18,7 @@ import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.CopyOnWriteArrayList; +import org.eclipse.osee.ats.api.IAtsConfigObject; import org.eclipse.osee.ats.api.IAtsObject; import org.eclipse.osee.ats.api.IAtsServices; import org.eclipse.osee.ats.api.IAtsWorkItem; @@ -436,7 +437,7 @@ public class AtsServerImpl implements IAtsServer { String result = null; @SuppressWarnings("unchecked") ArtifactReadable atsConfig = - orcsApi.getQueryFactory().fromBranch(CoreBranches.COMMON).andIds(AtsArtifactToken.AtsConfig).getResults().getAtMostOneOrNull(); + orcsApi.getQueryFactory().fromBranch(CoreBranches.COMMON).andIds(AtsArtifactToken.AtsConfig).getResults().getAtMostOneOrNull(); if (atsConfig != null) { for (Object obj : atsConfig.getAttributeValues(CoreAttributeTypes.GeneralStringData)) { String str = (String) obj; @@ -577,4 +578,9 @@ public class AtsServerImpl implements IAtsServer { return getArtifactByUuid(uuid); } + @Override + public <A extends IAtsConfigObject> A getSoleByUuid(long uuid, Class<A> clazz) throws OseeCoreException { + return getConfig().getSoleByUuid(uuid, clazz); + } + } diff --git a/plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/internal/util/AtsChangeSet.java b/plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/internal/util/AtsChangeSet.java index 2a95fa46d26..44f110298e6 100644 --- a/plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/internal/util/AtsChangeSet.java +++ b/plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/internal/util/AtsChangeSet.java @@ -260,5 +260,11 @@ public class AtsChangeSet extends AbstractAtsChangeSet { } add(object); } + + @Override + public void deleteArtifact(ArtifactId artifact) { + getTransaction().deleteArtifact(artifact); + add(artifact); + } } diff --git a/plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/internal/workitem/AtsProgramService.java b/plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/internal/workitem/AtsProgramService.java index 55e1429fa3e..8ddc1fbc421 100644 --- a/plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/internal/workitem/AtsProgramService.java +++ b/plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/internal/workitem/AtsProgramService.java @@ -10,10 +10,14 @@ *******************************************************************************/ package org.eclipse.osee.ats.impl.internal.workitem; +import java.util.LinkedList; +import java.util.List; import java.util.concurrent.TimeUnit; import org.eclipse.osee.ats.api.IAtsWorkItem; +import org.eclipse.osee.ats.api.country.IAtsCountry; import org.eclipse.osee.ats.api.data.AtsArtifactTypes; import org.eclipse.osee.ats.api.data.AtsAttributeTypes; +import org.eclipse.osee.ats.api.data.AtsRelationTypes; import org.eclipse.osee.ats.api.program.IAtsProgram; import org.eclipse.osee.ats.api.program.IAtsProgramService; import org.eclipse.osee.ats.api.team.IAtsTeamDefinition; @@ -73,4 +77,30 @@ public class AtsProgramService implements IAtsProgramService { return atsServer.getConfigItemFactory().getProgram(prgArt); } + @Override + public IAtsCountry getCountry(IAtsProgram atsProgram) { + IAtsCountry country = null; + ArtifactReadable artifact = ((ArtifactReadable) atsProgram.getStoreObject()); + if (artifact != null) { + ArtifactReadable countryArt = + artifact.getRelated(AtsRelationTypes.CountryToProgram_Country).getAtMostOneOrNull(); + if (countryArt != null) { + country = atsServer.getConfigItemFactory().getCountry(countryArt); + } + } + return country; + } + + @Override + public List<IAtsProgram> getPrograms(IAtsCountry atsCountry) { + List<IAtsProgram> programs = new LinkedList<>(); + ArtifactReadable artifact = ((ArtifactReadable) atsCountry.getStoreObject()); + if (artifact != null) { + for (ArtifactReadable related : artifact.getRelated(AtsRelationTypes.CountryToProgram_Program)) { + programs.add(atsServer.getConfigItemFactory().getProgram(related)); + } + } + return programs; + } + } 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 2aaaba6c749..053c0da1764 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 @@ -14,16 +14,21 @@ import org.eclipse.osee.ats.api.IAtsConfigObject; import org.eclipse.osee.ats.api.agile.IAgileFeatureGroup; import org.eclipse.osee.ats.api.agile.IAgileTeam; import org.eclipse.osee.ats.api.ai.IAtsActionableItem; +import org.eclipse.osee.ats.api.country.IAtsCountry; import org.eclipse.osee.ats.api.data.AtsArtifactTypes; import org.eclipse.osee.ats.api.data.AtsRelationTypes; import org.eclipse.osee.ats.api.insertion.IAtsInsertion; import org.eclipse.osee.ats.api.insertion.IAtsInsertionActivity; -import org.eclipse.osee.ats.api.insertion.JaxNewInsertion; -import org.eclipse.osee.ats.api.insertion.JaxNewInsertionActivity; +import org.eclipse.osee.ats.api.insertion.JaxInsertion; +import org.eclipse.osee.ats.api.insertion.JaxInsertionActivity; 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.core.config.AbstractConfigItemFactory; +import org.eclipse.osee.ats.core.config.Country; +import org.eclipse.osee.ats.core.config.Program; +import org.eclipse.osee.ats.core.insertion.Insertion; +import org.eclipse.osee.ats.core.insertion.InsertionActivity; import org.eclipse.osee.ats.core.util.AtsUtilCore; import org.eclipse.osee.ats.impl.IAtsServer; import org.eclipse.osee.ats.impl.internal.util.AtsChangeSet; @@ -73,6 +78,8 @@ public class ConfigItemFactory extends AbstractConfigItemFactory { configObject = getInsertion(artRead); } else if (artRead.isOfType(AtsArtifactTypes.InsertionActivity)) { configObject = getInsertionActivity(artRead); + } else if (artRead.isOfType(AtsArtifactTypes.Country)) { + configObject = getCountry(artRead); } } } catch (OseeCoreException ex) { @@ -119,7 +126,7 @@ public class ConfigItemFactory extends AbstractConfigItemFactory { @Override public IAtsProgram getProgram(ArtifactId artifact) { - IAtsProgram program = null; + Program program = null; if (artifact instanceof ArtifactReadable) { ArtifactReadable artRead = (ArtifactReadable) artifact; if (artRead.isOfType(AtsArtifactTypes.Program)) { @@ -155,11 +162,16 @@ public class ConfigItemFactory extends AbstractConfigItemFactory { @Override public IAtsInsertion getInsertion(ArtifactId artifact) { - IAtsInsertion insertion = null; + Insertion insertion = null; if (artifact instanceof ArtifactReadable) { ArtifactReadable artRead = (ArtifactReadable) artifact; if (artRead.isOfType(AtsArtifactTypes.Insertion)) { - insertion = new Insertion(logger, atsServer, artRead); + insertion = new Insertion(logger, atsServer.getServices(), artRead); + ArtifactReadable programArt = + ((ArtifactReadable) artifact).getRelated(AtsRelationTypes.ProgramToInsertion_Program).getOneOrNull(); + if (programArt != null) { + insertion.setProgramUuid(programArt.getUuid()); + } } else { throw new OseeCoreException("Requested uuid not Insertion"); } @@ -169,11 +181,16 @@ public class ConfigItemFactory extends AbstractConfigItemFactory { @Override public IAtsInsertionActivity getInsertionActivity(ArtifactId artifact) { - IAtsInsertionActivity insertionActivity = null; + InsertionActivity insertionActivity = null; if (artifact instanceof ArtifactReadable) { ArtifactReadable artRead = (ArtifactReadable) artifact; if (artRead.isOfType(AtsArtifactTypes.InsertionActivity)) { - insertionActivity = new InsertionActivity(logger, atsServer, artRead); + insertionActivity = new InsertionActivity(logger, atsServer.getServices(), artRead); + ArtifactReadable insertionArt = + ((ArtifactReadable) artifact).getRelated(AtsRelationTypes.InsertionToInsertionActivity_Insertion).getOneOrNull(); + if (insertionArt != null) { + insertionActivity.setInsertionUuid(insertionArt.getUuid()); + } } else { throw new OseeCoreException("Requested uuid not Insertion Activity"); } @@ -182,7 +199,7 @@ public class ConfigItemFactory extends AbstractConfigItemFactory { } @Override - public IAtsInsertion createInsertion(ArtifactId programArtifact, JaxNewInsertion newInsertion) { + public IAtsInsertion createInsertion(ArtifactId programArtifact, JaxInsertion newInsertion) { Long uuid = newInsertion.getUuid(); if (uuid == null || uuid <= 0) { @@ -201,7 +218,7 @@ public class ConfigItemFactory extends AbstractConfigItemFactory { } @Override - public IAtsInsertion updateInsertion(JaxNewInsertion updatedInsertion) { + public IAtsInsertion updateInsertion(JaxInsertion updatedInsertion) { AtsChangeSet changes = (AtsChangeSet) atsServer.getStoreService().createAtsChangeSet("Update Insertion", atsServer.getUserService().getCurrentUser()); @@ -217,7 +234,7 @@ public class ConfigItemFactory extends AbstractConfigItemFactory { } @Override - public IAtsInsertionActivity createInsertionActivity(ArtifactId insertion, JaxNewInsertionActivity newActivity) { + public IAtsInsertionActivity createInsertionActivity(ArtifactId insertion, JaxInsertionActivity newActivity) { Long uuid = newActivity.getUuid(); if (uuid == null || uuid <= 0) { uuid = Lib.generateArtifactIdAsInt(); @@ -235,7 +252,7 @@ public class ConfigItemFactory extends AbstractConfigItemFactory { } @Override - public IAtsInsertionActivity updateInsertionActivity(JaxNewInsertionActivity updatedActivity) { + public IAtsInsertionActivity updateInsertionActivity(JaxInsertionActivity updatedActivity) { AtsChangeSet changes = (AtsChangeSet) atsServer.getStoreService().createAtsChangeSet("Update Insertion", atsServer.getUserService().getCurrentUser()); @@ -274,4 +291,24 @@ public class ConfigItemFactory extends AbstractConfigItemFactory { public boolean isAtsConfigArtifact(ArtifactId artifact) { return getAtsConfigArtifactTypes().contains(((ArtifactReadable) artifact).getArtifactType()); } + + @Override + public IAtsCountry getCountry(ArtifactId artifact) { + IAtsCountry country = null; + if (artifact instanceof ArtifactReadable) { + ArtifactReadable artRead = (ArtifactReadable) artifact; + if (artRead.isOfType(AtsArtifactTypes.Country)) { + country = new Country(logger, atsServer.getServices(), artRead); + } else { + throw new OseeCoreException("Requested uuid not Country"); + } + } + return country; + } + + @Override + public IAtsCountry getCountry(long uuid) { + return getCountry(atsServer.getArtifactByUuid(uuid)); + } + } 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 b998fda3684..452b256471e 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,8 +17,16 @@ import javax.ws.rs.core.Application; import org.eclipse.osee.ats.impl.IAtsServer; import org.eclipse.osee.ats.rest.internal.agile.AgileEndpointImpl; import org.eclipse.osee.ats.rest.internal.config.ActionableItemResource; +import org.eclipse.osee.ats.rest.internal.config.AtsConfigEndpointImpl; import org.eclipse.osee.ats.rest.internal.config.ConvertCreateUpdateAtsConfig; import org.eclipse.osee.ats.rest.internal.config.ConvertResource; +import org.eclipse.osee.ats.rest.internal.config.CountryEndpointImpl; +import org.eclipse.osee.ats.rest.internal.config.CountryResource; +import org.eclipse.osee.ats.rest.internal.config.InsertionActivityEndpointImpl; +import org.eclipse.osee.ats.rest.internal.config.InsertionActivityResource; +import org.eclipse.osee.ats.rest.internal.config.InsertionEndpointImpl; +import org.eclipse.osee.ats.rest.internal.config.InsertionResource; +import org.eclipse.osee.ats.rest.internal.config.ProgramEndpointImpl; 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.UserResource; @@ -71,23 +79,32 @@ public class AtsApplication extends Application { ConvertCreateUpdateAtsConfig conversion = new ConvertCreateUpdateAtsConfig(atsServer); atsServer.addAtsDatabaseConversion(conversion); - // Agile resources - singletons.add(new AgileEndpointImpl(atsServer)); - - // Config resources + // Resources singletons.add(new VersionResource(atsServer)); singletons.add(new TeamResource(atsServer)); - singletons.add(new ProgramResource(atsServer)); singletons.add(new ActionableItemResource(atsServer)); + singletons.add(new CountryResource(atsServer)); + singletons.add(new ProgramResource(atsServer)); + singletons.add(new InsertionResource(atsServer)); + singletons.add(new InsertionActivityResource(atsServer)); + singletons.add(new ActionResource(atsServer, orcsApi)); singletons.add(new StateResource(atsServer)); singletons.add(new ConvertResource(atsServer)); singletons.add(new CpaResource(orcsApi, atsServer, cpaRegistry)); singletons.add(new UserResource(atsServer.getUserService())); + // Endpoints + singletons.add(new AgileEndpointImpl(atsServer)); singletons.add(new AtsEndpointImpl(atsServer, logger, registry, cpaRegistry)); + singletons.add(new CountryEndpointImpl(atsServer)); + singletons.add(new ProgramEndpointImpl(atsServer)); + singletons.add(new InsertionEndpointImpl(atsServer)); + singletons.add(new InsertionActivityEndpointImpl(atsServer)); + singletons.add(new AtsConfigEndpointImpl(atsServer, orcsApi, logger)); + // UIs singletons.add(new ActionUiResource(atsServer, logger)); } diff --git a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/AtsConfigEndpointImpl.java b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/AtsConfigEndpointImpl.java index 5db1a45a4ed..ffa03a61cab 100644 --- a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/AtsConfigEndpointImpl.java +++ b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/AtsConfigEndpointImpl.java @@ -11,6 +11,7 @@ package org.eclipse.osee.ats.rest.internal.config; import java.util.concurrent.Callable; +import javax.ws.rs.Path; import javax.ws.rs.core.Context; import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.core.Response; @@ -60,8 +61,8 @@ public final class AtsConfigEndpointImpl implements AtsConfigEndpointApi { @Override public AtsConfigurations get() { - ResultSet<ArtifactReadable> artifacts = - orcsApi.getQueryFactory().fromBranch(CoreBranches.COMMON).andTypeEquals(AtsArtifactTypes.Configuration).getResults(); + ResultSet<ArtifactReadable> artifacts = orcsApi.getQueryFactory().fromBranch(CoreBranches.COMMON).andTypeEquals( + AtsArtifactTypes.Configuration).getResults(); AtsConfigurations configs = new AtsConfigurations(); for (ArtifactReadable art : artifacts) { AtsConfiguration config = new AtsConfiguration(); @@ -83,6 +84,7 @@ public final class AtsConfigEndpointImpl implements AtsConfigEndpointApi { } @Override + @Path("") public AtsConfiguration createConfig(MultivaluedMap<String, String> form, @Context UriInfo uriInfo) { // get parameters @@ -126,9 +128,8 @@ public final class AtsConfigEndpointImpl implements AtsConfigEndpointApi { TransactionBuilder tx = orcsApi.getTransactionFactory().createTransaction(newBranch, userArt, "Add ATS Configuration"); - ArtifactId headingArt = - introduceAndRelateTo(tx, fromBranch, AtsArtifactToken.HeadingFolder, newBranch, - CoreArtifactTokens.DefaultHierarchyRoot, null); + ArtifactId headingArt = introduceAndRelateTo(tx, fromBranch, AtsArtifactToken.HeadingFolder, newBranch, + CoreArtifactTokens.DefaultHierarchyRoot, null); introduceAndRelateTo(tx, fromBranch, AtsArtifactToken.TopActionableItem, newBranch, null, headingArt); introduceAndRelateTo(tx, fromBranch, AtsArtifactToken.TopTeamDefinition, newBranch, null, headingArt); ArtifactId configArt = @@ -165,8 +166,8 @@ public final class AtsConfigEndpointImpl implements AtsConfigEndpointApi { relateToArt = orcsApi.getQueryFactory().fromBranch(newBranch).andIds(relateToToken).getResults().getAtMostOneOrNull(); if (relateToArt == null) { - relateToArt = - orcsApi.getQueryFactory().fromBranch(newBranch).andTypeEquals(relateToToken.getArtifactType()).andNameEquals( + relateToArt = orcsApi.getQueryFactory().fromBranch(newBranch).andTypeEquals( + relateToToken.getArtifactType()).andNameEquals( relateToToken.getName()).getResults().getAtMostOneOrNull(); } } 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 index c9b2b2309e4..d56a7ba5589 100644 --- 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 @@ -20,7 +20,10 @@ import org.eclipse.osee.ats.api.IAtsObject; import org.eclipse.osee.ats.api.agile.IAgileFeatureGroup; import org.eclipse.osee.ats.api.agile.IAgileSprint; import org.eclipse.osee.ats.api.agile.IAgileTeam; +import org.eclipse.osee.ats.api.country.IAtsCountry; import org.eclipse.osee.ats.api.data.AtsRelationTypes; +import org.eclipse.osee.ats.api.insertion.IAtsInsertion; +import org.eclipse.osee.ats.api.insertion.IAtsInsertionActivity; import org.eclipse.osee.ats.api.program.IAtsProgram; import org.eclipse.osee.ats.api.team.IAtsTeamDefinition; import org.eclipse.osee.ats.api.version.IAtsVersion; @@ -118,10 +121,66 @@ public class ConfigJsonWriter implements MessageBodyWriter<IAtsConfigObject> { } writer.writeEndArray(); } + } else if (atsObject instanceof IAtsInsertionActivity) { + IAtsInsertionActivity activity = (IAtsInsertionActivity) atsObject; + writer.writeBooleanField("Active", activity.isActive()); + if (!identityView) { + writer.writeArrayFieldStart("insertion"); + for (ArtifactReadable insertion : artifact.getRelated(AtsRelationTypes.InsertionToInsertionActivity_Insertion)) { + addArtifactIdentity(writer, insertion); + } + writer.writeEndArray(); + writer.writeArrayFieldStart("workpackage"); + for (ArtifactReadable workPackage : artifact.getRelated(AtsRelationTypes.InsertionActivityToWorkPackage_WorkPackage)) { + addArtifactIdentity(writer, workPackage); + } + writer.writeEndArray(); + } + } else if (atsObject instanceof IAtsInsertion) { + IAtsInsertion insertion = (IAtsInsertion) atsObject; + writer.writeBooleanField("Active", insertion.isActive()); + if (!identityView) { + writer.writeArrayFieldStart("program"); + for (ArtifactReadable program : artifact.getRelated(AtsRelationTypes.ProgramToInsertion_Program)) { + addArtifactIdentity(writer, program); + } + writer.writeEndArray(); + writer.writeArrayFieldStart("insertionactivity"); + for (ArtifactReadable activity : artifact.getRelated(AtsRelationTypes.InsertionToInsertionActivity_InsertionActivity)) { + addArtifactIdentity(writer, activity); + } + writer.writeEndArray(); + } } else if (atsObject instanceof IAtsProgram) { IAtsProgram program = (IAtsProgram) atsObject; writer.writeStringField("Namespace", program.getNamespace()); writer.writeBooleanField("Active", program.isActive()); + if (!identityView) { + writer.writeArrayFieldStart("country"); + for (ArtifactReadable country : artifact.getRelated(AtsRelationTypes.CountryToProgram_Country)) { + addArtifactIdentity(writer, country); + } + writer.writeEndArray(); + writer.writeArrayFieldStart("insertion"); + for (ArtifactReadable insertion : artifact.getRelated(AtsRelationTypes.ProgramToInsertion_Insertion)) { + addArtifactIdentity(writer, insertion); + } + writer.writeEndArray(); + } + } else if (atsObject instanceof IAtsCountry) { + IAtsCountry country = (IAtsCountry) atsObject; + if (!identityView) { + writer.writeArrayFieldStart("programs"); + Collection<IAtsProgram> programs = atsServer.getProgramService().getPrograms(country); + for (IAtsProgram program : programs) { + writer.writeStartObject(); + writer.writeNumberField("uuid", program.getUuid()); + writer.writeStringField("Name", program.getName()); + writer.writeBooleanField("active", program.isActive()); + writer.writeEndObject(); + } + writer.writeEndArray(); + } } else if (atsObject instanceof IAgileTeam) { IAgileTeam team = (IAgileTeam) atsObject; writer.writeBooleanField("Active", team.isActive()); @@ -192,6 +251,10 @@ public class ConfigJsonWriter implements MessageBodyWriter<IAtsConfigObject> { } public static Long getUuid(IAtsObject atsObject) { - return ((ArtifactReadable) atsObject.getStoreObject()).getUuid(); + long uuid = atsObject.getUuid(); + if (uuid <= 0L) { + uuid = ((ArtifactReadable) atsObject.getStoreObject()).getUuid(); + } + return uuid; } }
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/CountryEndpointImpl.java b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/CountryEndpointImpl.java new file mode 100644 index 00000000000..f9e3a112a47 --- /dev/null +++ b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/CountryEndpointImpl.java @@ -0,0 +1,86 @@ +/******************************************************************************* + * 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 java.net.URI; +import java.util.ArrayList; +import java.util.List; +import javax.ws.rs.core.Response; +import org.eclipse.osee.ats.api.IAtsConfigObject; +import org.eclipse.osee.ats.api.country.CountryEndpointApi; +import org.eclipse.osee.ats.api.country.IAtsCountry; +import org.eclipse.osee.ats.api.country.JaxCountry; +import org.eclipse.osee.ats.api.data.AtsArtifactToken; +import org.eclipse.osee.ats.api.data.AtsArtifactTypes; +import org.eclipse.osee.ats.api.program.ProgramEndpointApi; +import org.eclipse.osee.ats.api.util.IAtsChangeSet; +import org.eclipse.osee.ats.core.users.AtsCoreUsers; +import org.eclipse.osee.ats.impl.IAtsServer; +import org.eclipse.osee.ats.impl.config.BaseConfigEndpointImpl; +import org.eclipse.osee.framework.core.data.ArtifactId; +import org.eclipse.osee.framework.core.enums.CoreAttributeTypes; +import org.eclipse.osee.framework.jdk.core.type.OseeStateException; +import org.eclipse.osee.framework.jdk.core.util.GUID; +import org.eclipse.osee.orcs.data.ArtifactReadable; + +/** + * Donald G. Dunne + */ +public class CountryEndpointImpl extends BaseConfigEndpointImpl<JaxCountry> implements CountryEndpointApi { + + public CountryEndpointImpl(IAtsServer atsServer) { + super(AtsArtifactTypes.Country, AtsArtifactToken.CountryFolder, atsServer); + } + + @Override + public Response update(JaxCountry country) throws Exception { + ArtifactReadable artifact = atsServer.getArtifactByUuid(country.getUuid()); + if (artifact == null) { + throw new OseeStateException("Artifact with uuid %d not found", country.getUuid()); + } + IAtsChangeSet changes = + atsServer.getStoreService().createAtsChangeSet("Create " + artifactType.getName(), AtsCoreUsers.SYSTEM_USER); + ArtifactReadable configArtifact = + (ArtifactReadable) changes.createArtifact(artifactType, country.getName(), GUID.create(), country.getUuid()); + IAtsConfigObject configObject = atsServer.getConfigItemFactory().getConfigObject(configArtifact); + if (!configArtifact.getName().equals(country.getName())) { + changes.setSoleAttributeValue(configObject, CoreAttributeTypes.Name, country.getName()); + } + changes.execute(); + return Response.created(new URI("/" + country.getUuid())).build(); + } + + @Override + public JaxCountry getConfigObject(ArtifactId artifact) { + JaxCountry jaxCountry = new JaxCountry(); + IAtsCountry country = atsServer.getConfigItemFactory().getCountry(artifact); + jaxCountry.setName(country.getName()); + jaxCountry.setUuid(country.getUuid()); + jaxCountry.setActive(country.isActive()); + jaxCountry.setDescription(country.getDescription()); + return jaxCountry; + } + + @Override + public List<JaxCountry> getObjects() { + List<JaxCountry> configs = new ArrayList<JaxCountry>(); + for (ArtifactReadable art : atsServer.getQuery().andIsOfType(artifactType).getResults()) { + configs.add(getConfigObject(art)); + } + return configs; + } + + @Override + public ProgramEndpointApi getProgram(long countryUuid) { + return new ProgramEndpointImpl(atsServer, countryUuid); + } + +} diff --git a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/CountryResource.java b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/CountryResource.java new file mode 100644 index 00000000000..be2394da63e --- /dev/null +++ b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/CountryResource.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("country") +public class CountryResource extends AbstractConfigResource { + + public CountryResource(IAtsServer atsServer) { + super(AtsArtifactTypes.Country, atsServer); + } + +} diff --git a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/InsertionActivityEndpointImpl.java b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/InsertionActivityEndpointImpl.java new file mode 100644 index 00000000000..6f2c0191444 --- /dev/null +++ b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/InsertionActivityEndpointImpl.java @@ -0,0 +1,108 @@ +/******************************************************************************* + * 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 java.net.URI; +import java.util.ArrayList; +import java.util.List; +import javax.ws.rs.PUT; +import javax.ws.rs.core.Response; +import org.eclipse.osee.ats.api.IAtsConfigObject; +import org.eclipse.osee.ats.api.data.AtsArtifactTypes; +import org.eclipse.osee.ats.api.data.AtsRelationTypes; +import org.eclipse.osee.ats.api.insertion.IAtsInsertionActivity; +import org.eclipse.osee.ats.api.insertion.InsertionActivityEndpointApi; +import org.eclipse.osee.ats.api.insertion.JaxInsertionActivity; +import org.eclipse.osee.ats.api.util.IAtsChangeSet; +import org.eclipse.osee.ats.core.users.AtsCoreUsers; +import org.eclipse.osee.ats.impl.IAtsServer; +import org.eclipse.osee.ats.impl.config.BaseConfigEndpointImpl; +import org.eclipse.osee.framework.core.data.ArtifactId; +import org.eclipse.osee.framework.core.enums.CoreAttributeTypes; +import org.eclipse.osee.framework.jdk.core.type.OseeStateException; +import org.eclipse.osee.framework.jdk.core.util.GUID; +import org.eclipse.osee.orcs.data.ArtifactReadable; + +/** + * Donald G. Dunne + */ +public class InsertionActivityEndpointImpl extends BaseConfigEndpointImpl<JaxInsertionActivity> implements InsertionActivityEndpointApi { + + private final long insertionUuid; + + public InsertionActivityEndpointImpl(IAtsServer atsServer) { + this(atsServer, 0L); + } + + public InsertionActivityEndpointImpl(IAtsServer atsServer, long insertionUuid) { + super(AtsArtifactTypes.InsertionActivity, null, atsServer); + this.insertionUuid = insertionUuid; + } + + @PUT + @Override + public Response update(JaxInsertionActivity activity) throws Exception { + ArtifactReadable artifact = atsServer.getArtifactByUuid(activity.getUuid()); + if (artifact == null) { + throw new OseeStateException("Artifact with uuid %d not found", activity.getUuid()); + } + IAtsChangeSet changes = + atsServer.getStoreService().createAtsChangeSet("Create " + artifactType.getName(), AtsCoreUsers.SYSTEM_USER); + ArtifactReadable configArtifact = + (ArtifactReadable) changes.createArtifact(artifactType, activity.getName(), GUID.create(), activity.getUuid()); + IAtsConfigObject configObject = atsServer.getConfigItemFactory().getConfigObject(configArtifact); + if (!configArtifact.getName().equals(activity.getName())) { + changes.setSoleAttributeValue(configObject, CoreAttributeTypes.Name, activity.getName()); + } + changes.execute(); + return Response.created(new URI("/" + activity.getUuid())).build(); + } + + @Override + public JaxInsertionActivity getConfigObject(ArtifactId artifact) { + JaxInsertionActivity jaxInsertion = new JaxInsertionActivity(); + IAtsInsertionActivity insertion = atsServer.getConfigItemFactory().getInsertionActivity(artifact); + jaxInsertion.setName(insertion.getName()); + jaxInsertion.setUuid(insertion.getUuid()); + jaxInsertion.setActive(insertion.isActive()); + jaxInsertion.setDescription(insertion.getDescription()); + return jaxInsertion; + } + + @Override + public List<JaxInsertionActivity> getObjects() { + List<JaxInsertionActivity> insertions = new ArrayList<JaxInsertionActivity>(); + if (insertionUuid == 0L) { + for (ArtifactReadable art : atsServer.getQuery().andIsOfType(artifactType).getResults()) { + insertions.add(getConfigObject(art)); + } + } else { + for (ArtifactReadable activityArt : atsServer.getArtifactByUuid(insertionUuid).getRelated( + AtsRelationTypes.InsertionToInsertionActivity_InsertionActivity)) { + JaxInsertionActivity activity = getConfigObject(activityArt); + activity.setInsertionUuid(insertionUuid); + insertions.add(activity); + } + } + return insertions; + } + + @Override + protected void create(JaxInsertionActivity jaxInsertionActivity, ArtifactId insertionActivityArtId, IAtsChangeSet changes) { + ArtifactReadable insertionActivityArt = (ArtifactReadable) insertionActivityArtId; + if (insertionActivityArt.getRelatedCount(AtsRelationTypes.InsertionToInsertionActivity_Insertion) == 0) { + ArtifactReadable insertionArt = atsServer.getArtifactByUuid(jaxInsertionActivity.getInsertionUuid()); + changes.relate(insertionArt, AtsRelationTypes.InsertionToInsertionActivity_InsertionActivity, + insertionActivityArt); + } + } + +} diff --git a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/InsertionActivityResource.java b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/InsertionActivityResource.java new file mode 100644 index 00000000000..eacfdd21186 --- /dev/null +++ b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/InsertionActivityResource.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("insertionactivity") +public class InsertionActivityResource extends AbstractConfigResource { + + public InsertionActivityResource(IAtsServer atsServer) { + super(AtsArtifactTypes.InsertionActivity, atsServer); + } + +} diff --git a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/InsertionEndpointImpl.java b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/InsertionEndpointImpl.java new file mode 100644 index 00000000000..32cd3ba3d9e --- /dev/null +++ b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/InsertionEndpointImpl.java @@ -0,0 +1,114 @@ +/******************************************************************************* + * 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 java.net.URI; +import java.util.ArrayList; +import java.util.List; +import javax.ws.rs.PUT; +import javax.ws.rs.core.Response; +import org.eclipse.osee.ats.api.IAtsConfigObject; +import org.eclipse.osee.ats.api.data.AtsArtifactTypes; +import org.eclipse.osee.ats.api.data.AtsRelationTypes; +import org.eclipse.osee.ats.api.insertion.IAtsInsertion; +import org.eclipse.osee.ats.api.insertion.InsertionActivityEndpointApi; +import org.eclipse.osee.ats.api.insertion.InsertionEndpointApi; +import org.eclipse.osee.ats.api.insertion.JaxInsertion; +import org.eclipse.osee.ats.api.util.IAtsChangeSet; +import org.eclipse.osee.ats.core.users.AtsCoreUsers; +import org.eclipse.osee.ats.impl.IAtsServer; +import org.eclipse.osee.ats.impl.config.BaseConfigEndpointImpl; +import org.eclipse.osee.framework.core.data.ArtifactId; +import org.eclipse.osee.framework.core.enums.CoreAttributeTypes; +import org.eclipse.osee.framework.jdk.core.type.OseeStateException; +import org.eclipse.osee.framework.jdk.core.util.GUID; +import org.eclipse.osee.orcs.data.ArtifactReadable; + +/** + * Donald G. Dunne + */ +public class InsertionEndpointImpl extends BaseConfigEndpointImpl<JaxInsertion> implements InsertionEndpointApi { + + private final long programUuid; + + public InsertionEndpointImpl(IAtsServer atsServer) { + this(atsServer, 0L); + } + + public InsertionEndpointImpl(IAtsServer atsServer, long programUuid) { + super(AtsArtifactTypes.Insertion, null, atsServer); + this.programUuid = programUuid; + } + + @PUT + @Override + public Response update(JaxInsertion insertion) throws Exception { + ArtifactReadable artifact = atsServer.getArtifactByUuid(insertion.getUuid()); + if (artifact == null) { + throw new OseeStateException("Artifact with uuid %d not found", insertion.getUuid()); + } + IAtsChangeSet changes = + atsServer.getStoreService().createAtsChangeSet("Create " + artifactType.getName(), AtsCoreUsers.SYSTEM_USER); + ArtifactReadable configArtifact = + (ArtifactReadable) changes.createArtifact(artifactType, insertion.getName(), GUID.create(), + insertion.getUuid()); + IAtsConfigObject configObject = atsServer.getConfigItemFactory().getConfigObject(configArtifact); + if (!configArtifact.getName().equals(insertion.getName())) { + changes.setSoleAttributeValue(configObject, CoreAttributeTypes.Name, insertion.getName()); + } + changes.execute(); + return Response.created(new URI("/" + insertion.getUuid())).build(); + } + + @Override + public JaxInsertion getConfigObject(ArtifactId artifact) { + JaxInsertion jaxInsertion = new JaxInsertion(); + IAtsInsertion insertion = atsServer.getConfigItemFactory().getInsertion(artifact); + jaxInsertion.setName(insertion.getName()); + jaxInsertion.setUuid(insertion.getUuid()); + jaxInsertion.setActive(insertion.isActive()); + jaxInsertion.setDescription(insertion.getDescription()); + return jaxInsertion; + } + + @Override + public List<JaxInsertion> getObjects() { + List<JaxInsertion> insertions = new ArrayList<JaxInsertion>(); + if (programUuid == 0L) { + for (ArtifactReadable art : atsServer.getQuery().andIsOfType(artifactType).getResults()) { + insertions.add(getConfigObject(art)); + } + } else { + for (ArtifactReadable insertionArt : atsServer.getArtifactByUuid(programUuid).getRelated( + AtsRelationTypes.ProgramToInsertion_Insertion)) { + JaxInsertion insertion = getConfigObject(insertionArt); + insertion.setProgramUuid(programUuid); + insertions.add(insertion); + } + } + return insertions; + } + + @Override + protected void create(JaxInsertion jaxInsertion, ArtifactId insertionArtId, IAtsChangeSet changes) { + ArtifactReadable insertionArt = (ArtifactReadable) insertionArtId; + if (insertionArt.getRelatedCount(AtsRelationTypes.ProgramToInsertion_Program) == 0) { + ArtifactReadable programArt = atsServer.getArtifactByUuid(jaxInsertion.getProgramUuid()); + changes.relate(programArt, AtsRelationTypes.ProgramToInsertion_Insertion, insertionArt); + } + } + + @Override + public InsertionActivityEndpointApi getInsertionActivity(long insertionUuid) { + return new InsertionActivityEndpointImpl(atsServer, insertionUuid); + } + +} diff --git a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/InsertionResource.java b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/InsertionResource.java new file mode 100644 index 00000000000..de46f4bd4a8 --- /dev/null +++ b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/InsertionResource.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("insertion") +public class InsertionResource extends AbstractConfigResource { + + public InsertionResource(IAtsServer atsServer) { + super(AtsArtifactTypes.Insertion, atsServer); + } + +} diff --git a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/ProgramEndpointImpl.java b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/ProgramEndpointImpl.java new file mode 100644 index 00000000000..2cfc99a033e --- /dev/null +++ b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/ProgramEndpointImpl.java @@ -0,0 +1,112 @@ +/******************************************************************************* + * 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 java.net.URI; +import java.util.ArrayList; +import java.util.List; +import javax.ws.rs.PUT; +import javax.ws.rs.core.Response; +import org.eclipse.osee.ats.api.IAtsConfigObject; +import org.eclipse.osee.ats.api.data.AtsArtifactTypes; +import org.eclipse.osee.ats.api.data.AtsRelationTypes; +import org.eclipse.osee.ats.api.insertion.InsertionEndpointApi; +import org.eclipse.osee.ats.api.program.IAtsProgram; +import org.eclipse.osee.ats.api.program.JaxProgram; +import org.eclipse.osee.ats.api.program.ProgramEndpointApi; +import org.eclipse.osee.ats.api.util.IAtsChangeSet; +import org.eclipse.osee.ats.core.users.AtsCoreUsers; +import org.eclipse.osee.ats.impl.IAtsServer; +import org.eclipse.osee.ats.impl.config.BaseConfigEndpointImpl; +import org.eclipse.osee.framework.core.data.ArtifactId; +import org.eclipse.osee.framework.core.enums.CoreAttributeTypes; +import org.eclipse.osee.framework.jdk.core.type.OseeStateException; +import org.eclipse.osee.framework.jdk.core.util.GUID; +import org.eclipse.osee.orcs.data.ArtifactReadable; + +/** + * Donald G. Dunne + */ +public class ProgramEndpointImpl extends BaseConfigEndpointImpl<JaxProgram> implements ProgramEndpointApi { + + private final long countryUuid; + + public ProgramEndpointImpl(IAtsServer atsServer) { + this(atsServer, 0L); + } + + public ProgramEndpointImpl(IAtsServer atsServer, long countryUuid) { + super(AtsArtifactTypes.Program, null, atsServer); + this.countryUuid = countryUuid; + } + + @PUT + @Override + public Response update(JaxProgram program) throws Exception { + ArtifactReadable artifact = atsServer.getArtifactByUuid(program.getUuid()); + if (artifact == null) { + throw new OseeStateException("Artifact with uuid %d not found", program.getUuid()); + } + IAtsChangeSet changes = + atsServer.getStoreService().createAtsChangeSet("Create " + artifactType.getName(), AtsCoreUsers.SYSTEM_USER); + ArtifactReadable configArtifact = + (ArtifactReadable) changes.createArtifact(artifactType, program.getName(), GUID.create(), program.getUuid()); + IAtsConfigObject configObject = atsServer.getConfigItemFactory().getConfigObject(configArtifact); + if (!configArtifact.getName().equals(program.getName())) { + changes.setSoleAttributeValue(configObject, CoreAttributeTypes.Name, program.getName()); + } + changes.execute(); + return Response.created(new URI("/" + program.getUuid())).build(); + } + + @Override + public JaxProgram getConfigObject(ArtifactId artifact) { + JaxProgram jaxProgram = new JaxProgram(); + IAtsProgram program = atsServer.getConfigItemFactory().getProgram(artifact); + jaxProgram.setName(program.getName()); + jaxProgram.setUuid(program.getUuid()); + jaxProgram.setActive(program.isActive()); + jaxProgram.setDescription(program.getDescription()); + return jaxProgram; + } + + @Override + public List<JaxProgram> getObjects() { + List<JaxProgram> configs = new ArrayList<JaxProgram>(); + if (countryUuid == 0L) { + for (ArtifactReadable art : atsServer.getQuery().andIsOfType(artifactType).getResults()) { + configs.add(getConfigObject(art)); + } + } else { + for (ArtifactReadable art : atsServer.getArtifactByUuid(countryUuid).getRelated( + AtsRelationTypes.CountryToProgram_Program)) { + JaxProgram program = getConfigObject(art); + program.setCountryUuid(countryUuid); + configs.add(program); + } + } + return configs; + } + + @Override + protected void create(JaxProgram jaxProgram, ArtifactId programArtId, IAtsChangeSet changes) { + ArtifactReadable programArt = (ArtifactReadable) programArtId; + if (programArt.getRelatedCount(AtsRelationTypes.CountryToProgram_Country) == 0) { + ArtifactReadable countryArt = atsServer.getArtifactByUuid(jaxProgram.getCountryUuid()); + changes.relate(countryArt, AtsRelationTypes.CountryToProgram_Program, programArt); + } + } + + @Override + public InsertionEndpointApi getInsertion(long programUuid) { + return new InsertionEndpointImpl(atsServer, programUuid); + } +} 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 index 0af25598d39..2a9a614b793 100644 --- 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 @@ -10,49 +10,16 @@ *******************************************************************************/ package org.eclipse.osee.ats.rest.internal.config; -import java.net.URI; -import java.util.LinkedList; -import java.util.List; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.GenericEntity; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.UriBuilder; -import javax.ws.rs.core.UriInfo; -import org.eclipse.osee.ats.api.IAtsConfigObject; import org.eclipse.osee.ats.api.data.AtsArtifactTypes; -import org.eclipse.osee.ats.api.data.AtsRelationTypes; -import org.eclipse.osee.ats.api.insertion.IAtsInsertion; -import org.eclipse.osee.ats.api.insertion.IAtsInsertionActivity; -import org.eclipse.osee.ats.api.insertion.JaxNewInsertion; -import org.eclipse.osee.ats.api.insertion.JaxNewInsertionActivity; import org.eclipse.osee.ats.impl.IAtsServer; import org.eclipse.osee.ats.impl.config.AbstractConfigResource; -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.type.ResultSet; -import org.eclipse.osee.orcs.data.ArtifactReadable; /** - * @author Donald G. Dunne - * @author David W. Miller + * Donald G. Dunne */ @Path("program") public class ProgramResource extends AbstractConfigResource { - @Context - private UriInfo uriInfo; - - public void setUriInfo(UriInfo uriInfo) { - this.uriInfo = uriInfo; - } public ProgramResource(IAtsServer atsServer) { super(AtsArtifactTypes.Program, atsServer); diff --git a/plugins/org.eclipse.osee.ats/images/country.gif b/plugins/org.eclipse.osee.ats/images/country.gif Binary files differnew file mode 100644 index 00000000000..ec6cca4525b --- /dev/null +++ b/plugins/org.eclipse.osee.ats/images/country.gif diff --git a/plugins/org.eclipse.osee.ats/support/OseeTypes_ATS.osee b/plugins/org.eclipse.osee.ats/support/OseeTypes_ATS.osee index 7739224b29a..7f060217909 100644 --- a/plugins/org.eclipse.osee.ats/support/OseeTypes_ATS.osee +++ b/plugins/org.eclipse.osee.ats/support/OseeTypes_ATS.osee @@ -44,6 +44,11 @@ abstract artifactType "ats.Ats Team Definition or AI" extends "ats.Ats Config Ar attribute "ats.Actionable" } +artifactType "Country" extends "ats.Ats Config Artifact" { + uuid 0x44C69E6EBB2D8324 + attribute "ats.Description" +} + artifactType "Program" extends "ats.Ats Config Artifact" { uuid 0x0000BA123443210004 attribute "ats.Team Definition" @@ -1297,6 +1302,16 @@ attributeType "ats.SW Enhancement" extends StringAttribute { mediaType "text/plain" } +relationType "Country To Program" { + uuid 0x2000033300000169 + sideAName "Country" + sideAArtifactType "Country" + sideBName "Program" + sideBArtifactType "Program" + defaultOrderType Unordered + multiplicity ONE_TO_MANY +} + relationType "Work Package" { uuid 0x200000000000017E sideAName "Work Package" diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/Artifact.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/Artifact.java index e8f2dc099ea..9ca3acf852f 100644 --- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/Artifact.java +++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/Artifact.java @@ -87,11 +87,11 @@ import org.eclipse.osee.framework.skynet.core.types.IArtifact; /** * {@link ArtifactTest} - * + * * @author Ryan D. Brooks */ -public class Artifact extends FullyNamedIdentity<String> implements IArtifact, IAdaptable, IBasicGuidArtifact, ArtifactId { +public class Artifact extends FullyNamedIdentity<String>implements IArtifact, IAdaptable, IBasicGuidArtifact, ArtifactId { public static final String UNNAMED = "Unnamed"; public static final String BEFORE_GUID_STRING = "/BeforeGUID/PrePend"; public static final String AFTER_GUID_STRING = "/AfterGUID"; @@ -128,7 +128,7 @@ public class Artifact extends FullyNamedIdentity<String> implements IArtifact, I /** * A historical artifact always corresponds to a fixed revision of an artifact - * + * * @return whether this artifact represents a fixed revision */ public final boolean isHistorical() { @@ -500,7 +500,7 @@ public class Artifact extends FullyNamedIdentity<String> implements IArtifact, I /** * The use of this method is discouraged since it directly returns Attributes. - * + * * @return attributes All attributes of the specified type name including deleted and artifact deleted */ public final List<Attribute<?>> getAllAttributesIncludingHardDeleted(IAttributeType attributeType) throws OseeCoreException { @@ -529,8 +529,8 @@ public class Artifact extends FullyNamedIdentity<String> implements IArtifact, I */ @Deprecated public final <T> List<Attribute<T>> getAttributes(IAttributeType attributeType) throws OseeCoreException { - return Collections.castAll(getAttributesByModificationType(attributeType, - ModificationType.getAllNotHardDeletedTypes())); + return Collections.castAll( + getAttributesByModificationType(attributeType, ModificationType.getAllNotHardDeletedTypes())); } private List<Attribute<?>> getAttributesByModificationType(Set<ModificationType> allowedModTypes) throws OseeCoreException { @@ -600,8 +600,8 @@ public class Artifact extends FullyNamedIdentity<String> implements IArtifact, I private <T> Attribute<T> getOrCreateSoleAttribute(IAttributeType attributeType) throws OseeCoreException { if (!isAttributeTypeValid(attributeType)) { - throw new OseeArgumentException("The attribute type %s is not valid for artifacts of type [%s]", - attributeType, getArtifactTypeName()); + throw new OseeArgumentException("The attribute type %s is not valid for artifacts of type [%s]", attributeType, + getArtifactTypeName()); } Attribute<T> attribute = getSoleAttribute(attributeType); if (attribute == null) { @@ -647,7 +647,7 @@ public class Artifact extends FullyNamedIdentity<String> implements IArtifact, I * defaultReturnValue.<br> * <br> * Used for display purposes where toString() of attribute is to be displayed. - * + * * @param defaultReturnValue return value if attribute instance does not exist * @throws MultipleAttributesExist if multiple attribute instances exist */ @@ -682,7 +682,7 @@ public class Artifact extends FullyNamedIdentity<String> implements IArtifact, I * defaultReturnValue.<br> * <br> * Used for purposes where attribute value of specified type is desired. - * + * * @throws MultipleAttributesExist if multiple attribute instances exist */ public final <T> T getSoleAttributeValue(IAttributeType attributeType, T defaultReturnValue) throws OseeCoreException { @@ -690,9 +690,7 @@ public class Artifact extends FullyNamedIdentity<String> implements IArtifact, I if (soleAttributes.size() == 1) { T value = soleAttributes.iterator().next().getValue(); if (value == null) { - OseeLog.log( - Activator.class, - Level.SEVERE, + OseeLog.log(Activator.class, Level.SEVERE, "Attribute \"" + attributeType + "\" has null value for Artifact " + getGuid() + " \"" + getName() + "\""); return defaultReturnValue; } @@ -1169,7 +1167,7 @@ public class Artifact extends FullyNamedIdentity<String> implements IArtifact, I * silently you are provided a transaction. * <p> * Example: - * + * * <pre> * ... * Artifact artifact = ArtifactTypeManager.addArtifact(CoreArtifactTypes.Folder, ARTIFACT_BRANCH); @@ -1181,7 +1179,6 @@ public class Artifact extends FullyNamedIdentity<String> implements IArtifact, I * <b>transaction.execute();</b> * ... * </pre> - * * </p> */ public final void persist(SkynetTransaction managedTransaction) throws OseeCoreException { @@ -1192,7 +1189,7 @@ public class Artifact extends FullyNamedIdentity<String> implements IArtifact, I * Starting from this artifact, walks down the child hierarchy based on the list of child names provided and returns * the child of the last name provided. ArtifactDoesNotExist exception is thrown ff any child along the path does not * exist. - * + * * @return child at the leaf (bottom) of the specified hierarchy. */ public final Artifact getDescendant(String... names) throws OseeCoreException { @@ -1436,7 +1433,8 @@ public class Artifact extends FullyNamedIdentity<String> implements IArtifact, I private void copyAttributes(Artifact artifact, Collection<IAttributeType> excludeAttributeTypes) throws OseeCoreException { for (Attribute<?> attribute : getAttributes()) { - if (!excludeAttributeTypes.contains(attribute.getAttributeType()) && isCopyAllowed(attribute) && artifact.isAttributeTypeValid(attribute.getAttributeType())) { + if (!excludeAttributeTypes.contains(attribute.getAttributeType()) && isCopyAllowed( + attribute) && artifact.isAttributeTypeValid(attribute.getAttributeType())) { artifact.addAttribute(attribute.getAttributeType(), attribute.getValue()); } } @@ -1449,7 +1447,7 @@ public class Artifact extends FullyNamedIdentity<String> implements IArtifact, I /** * An artifact reflected about its own branch returns itself. Otherwise a new artifact is introduced on the * destinationBranch - * + * * @return the newly created artifact or this artifact if the destinationBranch is this artifact's branch */ public final Artifact reflect(IOseeBranch destinationBranch) throws OseeCoreException { @@ -1457,9 +1455,8 @@ public class Artifact extends FullyNamedIdentity<String> implements IArtifact, I } Artifact introduceShallowArtifact(IOseeBranch destinationBranch) throws OseeCoreException { - Artifact shallowArt = - ArtifactTypeManager.getFactory(artifactType).reflectExisitingArtifact(artId, getGuid(), artifactType, gammaId, - destinationBranch, modType); + Artifact shallowArt = ArtifactTypeManager.getFactory(artifactType).reflectExisitingArtifact(artId, getGuid(), + artifactType, gammaId, destinationBranch, modType); return shallowArt; } @@ -1523,22 +1520,13 @@ public class Artifact extends FullyNamedIdentity<String> implements IArtifact, I } private static final Pattern safeNamePattern = Pattern.compile("[^A-Za-z0-9 ]"); - private static final String[] NUMBER = new String[] { - "Zero", - "One", - "Two", - "Three", - "Four", - "Five", - "Six", - "Seven", - "Eight", - "Nine"}; + private static final String[] NUMBER = + new String[] {"Zero", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine"}; /** * Since artifact names are free text it is important to reformat the name to ensure it is suitable as an element * name - * + * * @return artifact name in a form that is valid as an XML element */ public final String getSafeName() { @@ -1574,7 +1562,7 @@ public class Artifact extends FullyNamedIdentity<String> implements IArtifact, I * Note: Artifact class does not implement the hashCode, but instead uses the one implemented by Identity. It can not * use the branch uuid due to the need for IArtifactTokens to match Artifact instances. In addition, the event system * requires that the DefaultBasicGuidArtifact and Artifact hashcode matches. - * + * * @param obj the reference object with which to compare. * @return <code>true</code> if this artifact has the same GUID and branch <code>false</code> otherwise. */ @@ -1750,4 +1738,14 @@ public class Artifact extends FullyNamedIdentity<String> implements IArtifact, I return getArtId(); } + public Artifact getRelatedArtifactOrNull(IRelationTypeSide relationSide) { + Artifact artifact = null; + try { + artifact = getRelatedArtifact(relationSide); + } catch (ArtifactDoesNotExist ex) { + // do nothing + } + return artifact; + } + } |