use of org.eclipse.winery.model.ids.definitions.ArtifactTypeId in project winery by eclipse.
the class DASpecificationTest method getArtifactTypeOfDA.
@Test
public void getArtifactTypeOfDA() throws Exception {
setRevisionTo("af529e513388dc9358a8f700757d8dc59aba3a55");
ServiceTemplateId id = new ServiceTemplateId("http://winery.opentosca.org/test/servicetemplates/ponyuniverse/daspecifier", "DASpecificationTest", false);
TTopologyTemplate topologyTemplate = this.repository.getElement(id).getTopologyTemplate();
assertNotNull(topologyTemplate);
TNodeTemplate nodeTemplateWithAbstractDA = topologyTemplate.getNodeTemplate("shetland_pony");
assertNotNull(nodeTemplateWithAbstractDA);
assertNotNull(nodeTemplateWithAbstractDA.getDeploymentArtifacts());
TDeploymentArtifact deploymentArtifact = nodeTemplateWithAbstractDA.getDeploymentArtifacts().get(0);
QName artifactTypeQName = deploymentArtifact.getArtifactType();
ArtifactTypeId artifactTypeId = new ArtifactTypeId(artifactTypeQName);
TArtifactType artifactType = this.repository.getElement(artifactTypeId);
assertEquals(artifactType.getTargetNamespace(), DASpecification.getArtifactTypeOfDA(nodeTemplateWithAbstractDA.getDeploymentArtifacts().get(0)).getTargetNamespace());
assertEquals(artifactType.getName(), DASpecification.getArtifactTypeOfDA(nodeTemplateWithAbstractDA.getDeploymentArtifacts().get(0)).getName());
}
use of org.eclipse.winery.model.ids.definitions.ArtifactTypeId in project winery by eclipse.
the class DASpecification method getArtifactTypeHierarchy.
public static List<TArtifactType> getArtifactTypeHierarchy(TArtifactType artifactType) {
List<TArtifactType> artifactTypeHierarchy = new ArrayList<>();
TArtifactType basisArtifactType = artifactType;
artifactTypeHierarchy.add(basisArtifactType);
while (basisArtifactType != null) {
if (basisArtifactType.getDerivedFrom() != null) {
QName parentArtifactTypeQName = basisArtifactType.getDerivedFrom().getTypeRef();
ArtifactTypeId parentArtifactTypeId = new ArtifactTypeId(parentArtifactTypeQName);
basisArtifactType = RepositoryFactory.getRepository().getElement(parentArtifactTypeId);
artifactTypeHierarchy.add(basisArtifactType);
} else {
basisArtifactType = null;
}
}
return artifactTypeHierarchy;
}
Aggregations