use of org.eclipse.winery.model.ids.definitions.RelationshipTypeId in project winery by eclipse.
the class BackendUtilsTestWithGitBackedRepository method getVersionsOfOneDefinitionWithComponentThatDoesNotHaveAVersion.
@Test
public void getVersionsOfOneDefinitionWithComponentThatDoesNotHaveAVersion() throws Exception {
this.setRevisionTo("origin/plain");
DefinitionsChildId id = new RelationshipTypeId("http://plain.winery.opentosca.org/relationshiptypes", "RelationshipTypeWithoutProperties", false);
List<WineryVersion> versions = WineryVersionUtils.getAllVersionsOfOneDefinition(id, repository);
assertEquals(1, versions.size());
assertEquals("", versions.get(0).toString());
}
use of org.eclipse.winery.model.ids.definitions.RelationshipTypeId in project winery by eclipse.
the class YamlCsarImporter method processDefinitionsImport.
@Override
protected Optional<ServiceTemplateId> processDefinitionsImport(TDefinitions defs, TOSCAMetaFile tmf, Path definitionsPath, List<String> errors, CsarImportOptions options) throws IOException {
Optional<ServiceTemplateId> entryServiceTemplate = Optional.empty();
String defaultNamespace = defs.getTargetNamespace();
List<TExtensibleElements> componentInstanceList = defs.getServiceTemplateOrNodeTypeOrNodeTypeImplementation();
for (final TExtensibleElements ci : componentInstanceList) {
if (ci instanceof org.eclipse.winery.model.tosca.TServiceTemplate && Objects.isNull(((org.eclipse.winery.model.tosca.TServiceTemplate) ci).getTopologyTemplate())) {
continue;
}
// Determine & ensure that element has the namespace
String namespace = this.getNamespace(ci, defaultNamespace);
this.setNamespace(ci, namespace);
String id = ModelUtilities.getId(ci);
final DefinitionsChildId wid = determineWineryId(ci, namespace, id);
if (targetRepository.exists(wid)) {
if (options.isOverwrite()) {
targetRepository.forceDelete(wid);
String msg = String.format("Deleted %1$s %2$s to enable replacement", ci.getClass().getName(), wid.getQName().toString());
LOGGER.debug(msg);
} else {
String msg = String.format("Skipped %1$s %2$s, because it already exists", ci.getClass().getName(), wid.getQName().toString());
LOGGER.debug(msg);
// this is not displayed in the UI as we currently do not distinguish between pre-existing types and types created during the import.
continue;
}
}
// Create a fresh definitions object without the other data.
final TDefinitions newDefs = BackendUtils.createWrapperDefinitions(wid, targetRepository);
// add the current TExtensibleElements as the only content to it
newDefs.getServiceTemplateOrNodeTypeOrNodeTypeImplementation().add(ci);
// import license and readme files
importLicenseAndReadme(definitionsPath.getParent().getParent(), wid, tmf, errors);
importArtifacts(definitionsPath.getParent().getParent(), ci, wid, tmf, errors);
if (ci instanceof TNodeType) {
this.adjustNodeType(definitionsPath.getParent().getParent(), (TNodeType) ci, (NodeTypeId) wid, tmf, errors);
} else if (ci instanceof TRelationshipType) {
this.adjustRelationshipType(definitionsPath.getParent().getParent(), (TRelationshipType) ci, (RelationshipTypeId) wid, tmf, errors);
}
storeDefs(wid, newDefs);
}
List<TImport> imports = defs.getImport();
this.importImports(definitionsPath.getParent(), tmf, imports, errors, options);
return entryServiceTemplate;
}
use of org.eclipse.winery.model.ids.definitions.RelationshipTypeId in project winery by eclipse.
the class DASpecification method getBasisRelationshipType.
/**
* method already exists in Splitting. Put into ModelUtilities
*/
private static TRelationshipType getBasisRelationshipType(QName relationshipTypeQName) {
RelationshipTypeId parentRelationshipTypeId = new RelationshipTypeId(relationshipTypeQName);
TRelationshipType parentRelationshipType = RepositoryFactory.getRepository().getElement(parentRelationshipTypeId);
TRelationshipType basisRelationshipType = null;
while (parentRelationshipType != null) {
basisRelationshipType = parentRelationshipType;
if (parentRelationshipType.getDerivedFrom() != null) {
QName tempRelationshipTypeQName = parentRelationshipType.getDerivedFrom().getTypeRef();
parentRelationshipTypeId = new RelationshipTypeId(tempRelationshipTypeQName);
parentRelationshipType = RepositoryFactory.getRepository().getElement(parentRelationshipTypeId);
} else {
parentRelationshipType = null;
}
}
return basisRelationshipType;
}
Aggregations