Search in sources :

Example 1 with SequenceEntity

use of io.github.edmm.core.parser.SequenceEntity in project winery by eclipse.

the class EdmmConverter method createArtifact.

private void createArtifact(TNodeTemplate nodeTemplate, EntityId componentNodeId, EntityGraph entityGraph) {
    if (nodeTemplate.getDeploymentArtifacts() != null && nodeTemplate.getDeploymentArtifacts().size() > 0) {
        EntityId artifactsEntityId = componentNodeId.extend(DefaultKeys.ARTIFACTS);
        entityGraph.addEntity(new SequenceEntity(artifactsEntityId, entityGraph));
        for (TDeploymentArtifact artifact : nodeTemplate.getDeploymentArtifacts()) {
            String path = null;
            TArtifactTemplate artifactTemplate = artifactTemplates.get(artifact.getArtifactRef());
            if (artifactTemplate != null && artifactTemplate.getArtifactReferences().size() > 0) {
                path = artifactTemplate.getArtifactReferences().get(0).getReference();
            }
            EntityId artifactEntityId = artifactsEntityId.extend(artifact.getArtifactType().getLocalPart().toLowerCase());
            createPathReferenceEntity(entityGraph, path, artifactEntityId);
        }
    }
}
Also used : EntityId(io.github.edmm.core.parser.EntityId) SequenceEntity(io.github.edmm.core.parser.SequenceEntity) TArtifactTemplate(org.eclipse.winery.model.tosca.TArtifactTemplate) TDeploymentArtifact(org.eclipse.winery.model.tosca.TDeploymentArtifact)

Example 2 with SequenceEntity

use of io.github.edmm.core.parser.SequenceEntity in project winery by eclipse.

the class EdmmConverter method createTechnologyMapping.

private void createTechnologyMapping(List<TNodeTemplate> nodeTemplates, EntityGraph entityGraph) {
    Map<String, List<TNodeTemplate>> deploymentTechnologyMapping = new HashMap<>();
    for (TNodeTemplate nodeTemplate : nodeTemplates) {
        Map<QName, String> attributes = nodeTemplate.getOtherAttributes();
        String key = attributes.get(new QName(TOSCA_WINERY_EXTENSIONS_NAMESPACE, "deployment-technology"));
        if (key != null) {
            deploymentTechnologyMapping.computeIfAbsent(key, k -> new ArrayList<>());
            deploymentTechnologyMapping.get(key).add(nodeTemplate);
        }
    }
    if (!deploymentTechnologyMapping.isEmpty()) {
        entityGraph.addEntity(new MappingEntity(EntityGraph.ORCHESTRATION_TECHNOLOGY, entityGraph));
        deploymentTechnologyMapping.forEach((key, nodes) -> {
            EntityId entity = EntityGraph.ORCHESTRATION_TECHNOLOGY.extend(key);
            entityGraph.addEntity(new SequenceEntity(entity, entityGraph));
            for (TNodeTemplate nodeTemplate : nodes) {
                EntityId valueEntity = entity.extend(nodeTemplate.getId());
                entityGraph.addEntity(new ScalarEntity(nodeTemplate.getId(), valueEntity, entityGraph));
            }
        });
    }
}
Also used : EntityId(io.github.edmm.core.parser.EntityId) SequenceEntity(io.github.edmm.core.parser.SequenceEntity) HashMap(java.util.HashMap) QName(javax.xml.namespace.QName) ScalarEntity(io.github.edmm.core.parser.ScalarEntity) ArrayList(java.util.ArrayList) List(java.util.List) TNodeTemplate(org.eclipse.winery.model.tosca.TNodeTemplate) MappingEntity(io.github.edmm.core.parser.MappingEntity)

Example 3 with SequenceEntity

use of io.github.edmm.core.parser.SequenceEntity in project winery by eclipse.

the class EdmmConverter method createParticipant.

private void createParticipant(OTParticipant participant, List<TNodeTemplate> nodeTemplates, EntityGraph entityGraph) {
    EntityId participantEntity = EntityGraph.PARTICIPANTS.extend(participant.getName());
    entityGraph.addEntity(new MappingEntity(participantEntity, entityGraph));
    EntityId endpointEntityId = participantEntity.extend(DefaultKeys.ENDPOINT);
    entityGraph.addEntity(new ScalarEntity(participant.getUrl(), endpointEntityId, entityGraph));
    EntityId componentsEntityId = participantEntity.extend(DefaultKeys.COMPONENTS);
    entityGraph.addEntity(new SequenceEntity(componentsEntityId, entityGraph));
    for (TNodeTemplate nodeTemplate : nodeTemplates) {
        Map<QName, String> attributes = nodeTemplate.getOtherAttributes();
        String name = attributes.get(new QName(TOSCA_WINERY_EXTENSIONS_NAMESPACE, "participant"));
        if (participant.getName().equals(name)) {
            EntityId valueEntity = componentsEntityId.extend(nodeTemplate.getId());
            entityGraph.addEntity(new ScalarEntity(nodeTemplate.getId(), valueEntity, entityGraph));
        }
    }
}
Also used : EntityId(io.github.edmm.core.parser.EntityId) SequenceEntity(io.github.edmm.core.parser.SequenceEntity) QName(javax.xml.namespace.QName) ScalarEntity(io.github.edmm.core.parser.ScalarEntity) TNodeTemplate(org.eclipse.winery.model.tosca.TNodeTemplate) MappingEntity(io.github.edmm.core.parser.MappingEntity)

Example 4 with SequenceEntity

use of io.github.edmm.core.parser.SequenceEntity in project winery by eclipse.

the class EdmmConverter method createRelation.

private void createRelation(TRelationshipTemplate relationship, EntityGraph entityGraph) {
    EntityId sourceComponentEntityId = EntityGraph.COMPONENTS.extend(relationship.getSourceElement().getRef().getId());
    // the entity will always be in the graph since we first transform the NodeTemplates
    entityGraph.getEntity(sourceComponentEntityId).ifPresent(entity -> {
        EntityId relationTypeEntityId = createType(relationshipTypes.get(relationship.getType()), EntityGraph.RELATION_TYPES, entityGraph);
        EntityId relationsCollectionEntityId = sourceComponentEntityId.extend(DefaultKeys.RELATIONS);
        if (!entityGraph.getEntity(relationsCollectionEntityId).isPresent()) {
            entityGraph.addEntity(new SequenceEntity(relationsCollectionEntityId, entityGraph));
        }
        EntityId relationEntityId = relationsCollectionEntityId.extend(relationTypeEntityId.getName());
        if (Objects.nonNull(relationship.getProperties()) && Objects.nonNull(ModelUtilities.getPropertiesKV(relationship))) {
            entityGraph.addEntity(new MappingEntity(relationEntityId, entityGraph));
            createProperties(relationship, relationEntityId, entityGraph);
        } else {
            String targetComponent = relationship.getTargetElement().getRef().getId();
            entityGraph.addEntity(new ScalarEntity(targetComponent, relationEntityId, entityGraph));
        }
    });
}
Also used : EntityId(io.github.edmm.core.parser.EntityId) SequenceEntity(io.github.edmm.core.parser.SequenceEntity) ScalarEntity(io.github.edmm.core.parser.ScalarEntity) MappingEntity(io.github.edmm.core.parser.MappingEntity)

Aggregations

EntityId (io.github.edmm.core.parser.EntityId)4 SequenceEntity (io.github.edmm.core.parser.SequenceEntity)4 MappingEntity (io.github.edmm.core.parser.MappingEntity)3 ScalarEntity (io.github.edmm.core.parser.ScalarEntity)3 QName (javax.xml.namespace.QName)2 TNodeTemplate (org.eclipse.winery.model.tosca.TNodeTemplate)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 TArtifactTemplate (org.eclipse.winery.model.tosca.TArtifactTemplate)1 TDeploymentArtifact (org.eclipse.winery.model.tosca.TDeploymentArtifact)1