diff options
author | Ryan D. Brooks | 2020-10-05 22:15:48 +0000 |
---|---|---|
committer | Ryan D. Brooks | 2023-09-05 16:36:00 +0000 |
commit | f49ba883a305fbfe917c1d173fd1fab18284c8a3 (patch) | |
tree | 478d4c7233104c87fcff856f8edd1fc90c70967d | |
parent | bbc19c369aa54296e1fd245aea1ba9528e140b06 (diff) | |
download | org.eclipse.osee-f49ba883a305fbfe917c1d173fd1fab18284c8a3.tar.gz org.eclipse.osee-f49ba883a305fbfe917c1d173fd1fab18284c8a3.tar.xz org.eclipse.osee-f49ba883a305fbfe917c1d173fd1fab18284c8a3.zip |
feature[TW17133]: Support extended artifact types in artiact creation
Change-Id: Ibab1c8ce9e71fbc4fe18aae8c1c7834022190244
3 files changed, 35 insertions, 9 deletions
diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/OrcsTokenService.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/OrcsTokenService.java index 91f02d00913..fe5730ca666 100644 --- a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/OrcsTokenService.java +++ b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/OrcsTokenService.java @@ -26,6 +26,7 @@ import org.eclipse.osee.framework.core.data.BranchId; import org.eclipse.osee.framework.core.data.BranchToken; import org.eclipse.osee.framework.core.data.RelationTypeJoin; import org.eclipse.osee.framework.core.data.RelationTypeToken; +import org.eclipse.osee.framework.jdk.core.type.OseeStateException; /** * @author Ryan D. Brooks @@ -40,6 +41,13 @@ public interface OrcsTokenService { ArtifactTypeToken getArtifactType(Long id); /** + * @param artifactType + * @return the non-abstract leaf artifact type that extends the given type or the type itself if no such type exists + * @throws OseeStateException when there is more than one artifact type that extends this artifact type + */ + ArtifactTypeToken getArtifactTypeDescendant(ArtifactTypeToken artifactType); + + /** * @return singleton full artifact type token with the given name or throw OseeTypeDoesNotExist if not found */ ArtifactTypeToken getArtifactType(String name); diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/ArtifactTypeToken.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/ArtifactTypeToken.java index d926899a832..314b66c0691 100644 --- a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/ArtifactTypeToken.java +++ b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/ArtifactTypeToken.java @@ -35,7 +35,7 @@ public interface ArtifactTypeToken extends NamedId, ArtifactTypeId { ArtifactTypeToken SENTINEL = valueOf(Id.SENTINEL, Named.SENTINEL); OseeImage image = null; - public static ArtifactTypeToken valueOf(long id, String name, ArtifactTypeToken... superTypes) { + static ArtifactTypeToken valueOf(long id, String name, ArtifactTypeToken... superTypes) { return new AttributeMultiplicity(id, NamespaceToken.OSEE, name, false, Arrays.asList(superTypes)).get(); } @@ -54,8 +54,7 @@ public interface ArtifactTypeToken extends NamedId, ArtifactTypeId { return new AttributeMultiplicity(id, namespace, name, isAbstract, image, superTypes).get(); } - public static ArtifactTypeToken create(Long id, NamespaceToken namespace, String name, boolean isAbstract, - List<ArtifactTypeToken> superTypes) { + public static ArtifactTypeToken create(Long id, NamespaceToken namespace, String name, boolean isAbstract, List<ArtifactTypeToken> superTypes) { return new AttributeMultiplicity(id, namespace, name, isAbstract, superTypes).get(); } @@ -106,15 +105,15 @@ public interface ArtifactTypeToken extends NamedId, ArtifactTypeId { List<ArtifactTypeToken> getSuperTypes(); - public List<AttributeTypeToken> getValidAttributeTypes(); + List<AttributeTypeToken> getValidAttributeTypes(); - public boolean isValidAttributeType(AttributeTypeId attributeType); + boolean isValidAttributeType(AttributeTypeId attributeType); - public int getMin(AttributeTypeToken attributeType); + int getMin(AttributeTypeToken attributeType); - public int getMax(AttributeTypeToken attributeType); + int getMax(AttributeTypeToken attributeType); - public <T extends EnumToken> List<T> getValidEnumValues(AttributeTypeEnum<T> attributeType); + <T extends EnumToken> List<T> getValidEnumValues(AttributeTypeEnum<T> attributeType); public OseeImage getImage(); @@ -270,4 +269,4 @@ public interface ArtifactTypeToken extends NamedId, ArtifactTypeId { } return new ArtifactTypeTokenImpl(id, namespace, name, isAbstract, attributeTypes, image, superTypes); } -} +}
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/OrcsTokenServiceImpl.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/OrcsTokenServiceImpl.java index c9986cf4a0f..d8f881c9e8b 100644 --- a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/OrcsTokenServiceImpl.java +++ b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/OrcsTokenServiceImpl.java @@ -27,6 +27,7 @@ import org.eclipse.osee.framework.core.enums.RelationSide; import org.eclipse.osee.framework.core.exception.OseeTypeDoesNotExist; import org.eclipse.osee.framework.jdk.core.type.NamedId; import org.eclipse.osee.framework.jdk.core.type.OseeArgumentException; +import org.eclipse.osee.framework.jdk.core.type.OseeStateException; /** * @author Ryan D. Brooks @@ -70,6 +71,24 @@ public final class OrcsTokenServiceImpl implements OrcsTokenService { } @Override + public ArtifactTypeToken getArtifactTypeDescendant(ArtifactTypeToken artifactType) { + List<ArtifactTypeToken> descendants = artifactType.getAllDescendantTypes(); + ArtifactTypeToken leafDescendant = artifactType; + for (ArtifactTypeToken descendant : descendants) { + if (!descendant.isAbstract()) { + if (leafDescendant == artifactType) { + leafDescendant = descendant; + } else { + throw new OseeStateException("Artifact type %s has more than one concreate descendant types", + artifactType); + } + } + } + + return leafDescendant; + } + + @Override public ArtifactTypeToken getArtifactType(String name) { for (ArtifactTypeToken artifactType : artifactTypes.values()) { if (artifactType.getName().equals(name)) { |