Search in sources :

Example 16 with RelationshipTypeId

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());
}
Also used : RelationshipTypeId(org.eclipse.winery.model.ids.definitions.RelationshipTypeId) DefinitionsChildId(org.eclipse.winery.model.ids.definitions.DefinitionsChildId) WineryVersion(org.eclipse.winery.common.version.WineryVersion) Test(org.junit.jupiter.api.Test)

Example 17 with RelationshipTypeId

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;
}
Also used : RelationshipTypeId(org.eclipse.winery.model.ids.definitions.RelationshipTypeId) DefinitionsChildId(org.eclipse.winery.model.ids.definitions.DefinitionsChildId) TImport(org.eclipse.winery.model.tosca.TImport) TExtensibleElements(org.eclipse.winery.model.tosca.TExtensibleElements) ServiceTemplateId(org.eclipse.winery.model.ids.definitions.ServiceTemplateId) TServiceTemplate(org.eclipse.winery.model.tosca.TServiceTemplate) TNodeType(org.eclipse.winery.model.tosca.TNodeType) TRelationshipType(org.eclipse.winery.model.tosca.TRelationshipType) TDefinitions(org.eclipse.winery.model.tosca.TDefinitions) TServiceTemplate(org.eclipse.winery.model.tosca.TServiceTemplate) YTServiceTemplate(org.eclipse.winery.model.tosca.yaml.YTServiceTemplate)

Example 18 with RelationshipTypeId

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;
}
Also used : TRelationshipType(org.eclipse.winery.model.tosca.TRelationshipType) RelationshipTypeId(org.eclipse.winery.model.ids.definitions.RelationshipTypeId) QName(javax.xml.namespace.QName)

Aggregations

RelationshipTypeId (org.eclipse.winery.model.ids.definitions.RelationshipTypeId)18 NodeTypeId (org.eclipse.winery.model.ids.definitions.NodeTypeId)12 QName (javax.xml.namespace.QName)9 TNodeType (org.eclipse.winery.model.tosca.TNodeType)9 TRelationshipType (org.eclipse.winery.model.tosca.TRelationshipType)9 ArtifactTemplateId (org.eclipse.winery.model.ids.definitions.ArtifactTemplateId)7 CapabilityTypeId (org.eclipse.winery.model.ids.definitions.CapabilityTypeId)7 DefinitionsChildId (org.eclipse.winery.model.ids.definitions.DefinitionsChildId)7 ArrayList (java.util.ArrayList)6 ArtifactTypeId (org.eclipse.winery.model.ids.definitions.ArtifactTypeId)6 NodeTypeImplementationId (org.eclipse.winery.model.ids.definitions.NodeTypeImplementationId)6 PolicyTypeId (org.eclipse.winery.model.ids.definitions.PolicyTypeId)6 RequirementTypeId (org.eclipse.winery.model.ids.definitions.RequirementTypeId)6 ServiceTemplateId (org.eclipse.winery.model.ids.definitions.ServiceTemplateId)6 TNodeTemplate (org.eclipse.winery.model.tosca.TNodeTemplate)6 TServiceTemplate (org.eclipse.winery.model.tosca.TServiceTemplate)6 RelationshipTypeImplementationId (org.eclipse.winery.model.ids.definitions.RelationshipTypeImplementationId)5 TDefinitions (org.eclipse.winery.model.tosca.TDefinitions)5 TRelationshipTemplate (org.eclipse.winery.model.tosca.TRelationshipTemplate)5 HashSet (java.util.HashSet)4