Search in sources :

Example 11 with ScalarEntity

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

the class EdmmTypeProperties method getDefaultConfiguration.

public static void getDefaultConfiguration(EdmmType edmmType, EntityGraph entityGraph) {
    EntityId e;
    switch(edmmType) {
        case COMPUTE:
            EntityId computeId = EntityGraph.COMPONENT_TYPES.extend(EdmmType.COMPUTE.getValue());
            entityGraph.addEntity(new MappingEntity(computeId, entityGraph));
            entityGraph.addEntity(new ScalarEntity(BASE, computeId.extend(DefaultKeys.EXTENDS), entityGraph));
            break;
        case DATABASE:
            EntityId databaseId = EntityGraph.COMPONENT_TYPES.extend(EdmmType.DATABASE.getValue());
            entityGraph.addEntity(new MappingEntity(databaseId, entityGraph));
            entityGraph.addEntity(new ScalarEntity(BASE, databaseId.extend(DefaultKeys.EXTENDS), entityGraph));
            break;
        case DBMS:
            EntityId dbmsId = EntityGraph.COMPONENT_TYPES.extend(EdmmType.DBMS.getValue());
            entityGraph.addEntity(new MappingEntity(dbmsId, entityGraph));
            entityGraph.addEntity(new ScalarEntity(EdmmType.SOFTWARE_COMPONENT.getValue(), dbmsId.extend(DefaultKeys.EXTENDS), entityGraph));
            getDefaultConfiguration(EdmmType.SOFTWARE_COMPONENT, entityGraph);
            break;
        case MYSQL_DATABASE:
            EntityId mySqlDatabaseId = EntityGraph.COMPONENT_TYPES.extend(EdmmType.MYSQL_DATABASE.getValue());
            entityGraph.addEntity(new MappingEntity(mySqlDatabaseId, entityGraph));
            entityGraph.addEntity(new ScalarEntity(EdmmType.DATABASE.getValue(), mySqlDatabaseId.extend(DefaultKeys.EXTENDS), entityGraph));
            getDefaultConfiguration(EdmmType.DATABASE, entityGraph);
            break;
        case MYSQL_DBMS:
            EntityId mySqlDbmsId = EntityGraph.COMPONENT_TYPES.extend(EdmmType.MYSQL_DBMS.getValue());
            entityGraph.addEntity(new MappingEntity(mySqlDbmsId, entityGraph));
            entityGraph.addEntity(new ScalarEntity(EdmmType.DBMS.getValue(), mySqlDbmsId.extend(DefaultKeys.EXTENDS), entityGraph));
            getDefaultConfiguration(EdmmType.DBMS, entityGraph);
            break;
        case SOFTWARE_COMPONENT:
            EntityId softwareComponent = EntityGraph.COMPONENT_TYPES.extend(EdmmType.SOFTWARE_COMPONENT.getValue());
            entityGraph.addEntity(new MappingEntity(softwareComponent, entityGraph));
            entityGraph.addEntity(new ScalarEntity(BASE, softwareComponent.extend(DefaultKeys.EXTENDS), entityGraph));
            break;
        case TOMCAT:
            EntityId tomcatId = EntityGraph.COMPONENT_TYPES.extend(EdmmType.TOMCAT.getValue());
            entityGraph.addEntity(new MappingEntity(tomcatId, entityGraph));
            entityGraph.addEntity(new ScalarEntity(EdmmType.WEB_SERVER.getValue(), tomcatId.extend(DefaultKeys.EXTENDS), entityGraph));
            getDefaultConfiguration(EdmmType.WEB_SERVER, entityGraph);
            break;
        case WEB_APPLICATION:
            EntityId webApplication = EntityGraph.COMPONENT_TYPES.extend(EdmmType.WEB_APPLICATION.getValue());
            entityGraph.addEntity(new MappingEntity(webApplication, entityGraph));
            entityGraph.addEntity(new ScalarEntity(BASE, webApplication.extend(DefaultKeys.EXTENDS), entityGraph));
            break;
        case WEB_SERVER:
            EntityId webServerId = EntityGraph.COMPONENT_TYPES.extend(EdmmType.WEB_SERVER.getValue());
            entityGraph.addEntity(new MappingEntity(webServerId, entityGraph));
            entityGraph.addEntity(new ScalarEntity(EdmmType.SOFTWARE_COMPONENT.getValue(), webServerId.extend(DefaultKeys.EXTENDS), entityGraph));
            getDefaultConfiguration(EdmmType.SOFTWARE_COMPONENT, entityGraph);
            break;
        case GO:
            EntityId goId = EntityGraph.COMPONENT_TYPES.extend(EdmmType.GO.getValue());
            entityGraph.addEntity(new MappingEntity(goId, entityGraph));
            entityGraph.addEntity(new ScalarEntity(EdmmType.WEB_SERVER.getValue(), goId.extend(DefaultKeys.EXTENDS), entityGraph));
            getDefaultConfiguration(EdmmType.WEB_SERVER, entityGraph);
            break;
        case CONNECTS_TO:
            EntityId connectsToId = EntityGraph.RELATION_TYPES.extend(EdmmType.CONNECTS_TO.getValue());
            entityGraph.addEntity(new MappingEntity(connectsToId, entityGraph));
            entityGraph.addEntity(new ScalarEntity(EdmmType.DEPENDS_ON.getValue(), connectsToId.extend(DefaultKeys.EXTENDS), entityGraph));
            getDefaultConfiguration(EdmmType.DEPENDS_ON, entityGraph);
            break;
        case DEPENDS_ON:
            EntityId dependsOnId = EntityGraph.RELATION_TYPES.extend(EdmmType.DEPENDS_ON.getValue());
            entityGraph.addEntity(new MappingEntity(dependsOnId, entityGraph));
            entityGraph.addEntity(new ScalarEntity(null, dependsOnId.extend(DefaultKeys.EXTENDS), entityGraph));
            break;
        case HOSTED_ON:
            EntityId hostedOnId = EntityGraph.RELATION_TYPES.extend(EdmmType.HOSTED_ON.getValue());
            entityGraph.addEntity(new MappingEntity(hostedOnId, entityGraph));
            entityGraph.addEntity(new ScalarEntity(EdmmType.DEPENDS_ON.getValue(), hostedOnId.extend(DefaultKeys.EXTENDS), entityGraph));
            getDefaultConfiguration(EdmmType.DEPENDS_ON, entityGraph);
            break;
        case PLATFORM:
            e = EntityGraph.COMPONENT_TYPES.extend(EdmmType.PLATFORM.getValue());
            entityGraph.addEntity(new MappingEntity(e, entityGraph));
            entityGraph.addEntity(new ScalarEntity(BASE, e.extend(DefaultKeys.EXTENDS), entityGraph));
            break;
        case PAAS:
            e = EntityGraph.COMPONENT_TYPES.extend(EdmmType.PAAS.getValue());
            entityGraph.addEntity(new MappingEntity(e, entityGraph));
            entityGraph.addEntity(new ScalarEntity(EdmmType.PLATFORM.getValue(), e.extend(DefaultKeys.EXTENDS), entityGraph));
            getDefaultConfiguration(EdmmType.PLATFORM, entityGraph);
            break;
        case DBAAS:
            e = EntityGraph.COMPONENT_TYPES.extend(EdmmType.DBAAS.getValue());
            entityGraph.addEntity(new MappingEntity(e, entityGraph));
            entityGraph.addEntity(new ScalarEntity(EdmmType.PLATFORM.getValue(), e.extend(DefaultKeys.EXTENDS), entityGraph));
            getDefaultConfiguration(EdmmType.PLATFORM, entityGraph);
            break;
        case SAAS:
            e = EntityGraph.COMPONENT_TYPES.extend(EdmmType.SAAS.getValue());
            entityGraph.addEntity(new MappingEntity(e, entityGraph));
            entityGraph.addEntity(new ScalarEntity(EdmmType.PLATFORM.getValue(), e.extend(DefaultKeys.EXTENDS), entityGraph));
            getDefaultConfiguration(EdmmType.PLATFORM, entityGraph);
            break;
        case AWS_BEANSTALK:
            e = EntityGraph.COMPONENT_TYPES.extend(EdmmType.AWS_BEANSTALK.getValue());
            entityGraph.addEntity(new MappingEntity(e, entityGraph));
            entityGraph.addEntity(new ScalarEntity(EdmmType.PAAS.getValue(), e.extend(DefaultKeys.EXTENDS), entityGraph));
            getDefaultConfiguration(EdmmType.PAAS, entityGraph);
            break;
        case AWS_AURORA:
            e = EntityGraph.COMPONENT_TYPES.extend(EdmmType.AWS_AURORA.getValue());
            entityGraph.addEntity(new MappingEntity(e, entityGraph));
            entityGraph.addEntity(new ScalarEntity(EdmmType.DBAAS.getValue(), e.extend(DefaultKeys.EXTENDS), entityGraph));
            getDefaultConfiguration(EdmmType.DBAAS, entityGraph);
            break;
        case AUTH0:
            e = EntityGraph.COMPONENT_TYPES.extend(EdmmType.AUTH0.getValue());
            entityGraph.addEntity(new MappingEntity(e, entityGraph));
            entityGraph.addEntity(new ScalarEntity(EdmmType.SAAS.getValue(), e.extend(DefaultKeys.EXTENDS), entityGraph));
            getDefaultConfiguration(EdmmType.SAAS, entityGraph);
            break;
        case MOM:
            EntityId momId = EntityGraph.COMPONENT_TYPES.extend(EdmmType.MOM.getValue());
            entityGraph.addEntity(new MappingEntity(momId, entityGraph));
            entityGraph.addEntity(new ScalarEntity(EdmmType.SOFTWARE_COMPONENT.getValue(), momId.extend(DefaultKeys.EXTENDS), entityGraph));
            getDefaultConfiguration(EdmmType.SOFTWARE_COMPONENT, entityGraph);
            break;
        case RABBITMQ:
            EntityId rabbitMqId = EntityGraph.COMPONENT_TYPES.extend(EdmmType.RABBITMQ.getValue());
            entityGraph.addEntity(new MappingEntity(rabbitMqId, entityGraph));
            entityGraph.addEntity(new ScalarEntity(EdmmType.MOM.getValue(), rabbitMqId.extend(DefaultKeys.EXTENDS), entityGraph));
            getDefaultConfiguration(EdmmType.MOM, entityGraph);
            break;
        case MONGODB:
            EntityId mongoId = EntityGraph.COMPONENT_TYPES.extend(EdmmType.MONGODB.getValue());
            entityGraph.addEntity(new MappingEntity(mongoId, entityGraph));
            entityGraph.addEntity(new ScalarEntity(EdmmType.DBMS.getValue(), mongoId.extend(DefaultKeys.EXTENDS), entityGraph));
            getDefaultConfiguration(EdmmType.DBMS, entityGraph);
            break;
        case MONGODB_SCHEMA:
            EntityId mongoSchemaId = EntityGraph.COMPONENT_TYPES.extend(EdmmType.MONGODB_SCHEMA.getValue());
            entityGraph.addEntity(new MappingEntity(mongoSchemaId, entityGraph));
            entityGraph.addEntity(new ScalarEntity(EdmmType.DATABASE.getValue(), mongoSchemaId.extend(DefaultKeys.EXTENDS), entityGraph));
            getDefaultConfiguration(EdmmType.DATABASE, entityGraph);
            break;
    }
}
Also used : EntityId(io.github.edmm.core.parser.EntityId) ScalarEntity(io.github.edmm.core.parser.ScalarEntity) MappingEntity(io.github.edmm.core.parser.MappingEntity)

Example 12 with ScalarEntity

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

the class EdmmConverterTest method transformTopologyWithOperations.

@Test
void transformTopologyWithOperations() {
    // region *** build the TopologyTemplate ***
    TTopologyTemplate.Builder topology = new TTopologyTemplate.Builder();
    topology.addNodeTemplate(nodeTemplates.get("test_node_4"));
    // endregion
    TServiceTemplate serviceTemplate = new TServiceTemplate.Builder("testST", topology.build()).build();
    EdmmConverter edmmConverter = new EdmmConverter(nodeTypes, relationshipTypes, nodeTypeImplementations, relationshipTypeImplementations, artifactTemplates, edmmTypeExtendsMapping, edmm1to1Mapping, false);
    EntityGraph transform = edmmConverter.transform(serviceTemplate);
    assertNotNull(transform);
    Optional<Entity> operations = transform.getEntity(Arrays.asList("0", "components", "test_node_4", "operations"));
    assertTrue(operations.isPresent());
    Optional<Entity> start = transform.getEntity(Arrays.asList("0", "components", "test_node_4", "operations", "start"));
    assertTrue(start.isPresent());
    assertTrue(start.get() instanceof ScalarEntity);
    assertEquals("/artifacttemplates/https%3A%2F%2Fex.org%2Ftosca%2Fto%2Fedmm/startTestNode4/files/script.sh", ((ScalarEntity) start.get()).getValue());
    Optional<Entity> stop = transform.getEntity(Arrays.asList("0", "components", "test_node_4", "operations", "stop"));
    assertTrue(stop.isPresent());
    assertTrue(stop.get() instanceof ScalarEntity);
    assertEquals("/artifacttemplates/https%3A%2F%2Fex.org%2Ftosca%2Fto%2Fedmm/startTestNode4/files/script.sh", ((ScalarEntity) stop.get()).getValue());
}
Also used : EntityGraph(io.github.edmm.core.parser.EntityGraph) Entity(io.github.edmm.core.parser.Entity) MappingEntity(io.github.edmm.core.parser.MappingEntity) ScalarEntity(io.github.edmm.core.parser.ScalarEntity) TTopologyTemplate(org.eclipse.winery.model.tosca.TTopologyTemplate) ScalarEntity(io.github.edmm.core.parser.ScalarEntity) TServiceTemplate(org.eclipse.winery.model.tosca.TServiceTemplate) Test(org.junit.jupiter.api.Test) EdmmDependantTest(org.eclipse.winery.edmm.EdmmDependantTest)

Example 13 with ScalarEntity

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

the class EdmmConverterTest method transformDerivedFrom.

@Test
void transformDerivedFrom() {
    // region *** build the TopologyTemplate ***
    TTopologyTemplate.Builder topology = new TTopologyTemplate.Builder();
    topology.addNodeTemplate(nodeTemplates.get("test_node_2"));
    // endregion
    TServiceTemplate serviceTemplate = new TServiceTemplate();
    serviceTemplate.setTopologyTemplate(topology.build());
    EdmmConverter edmmConverter = new EdmmConverter(nodeTypes, relationshipTypes, nodeTypeImplementations, relationshipTypeImplementations, artifactTemplates, edmmTypeExtendsMapping, edmm1to1Mapping);
    EntityGraph transform = edmmConverter.transform(serviceTemplate);
    assertNotNull(transform);
    assertTrue(transform.vertexSet().stream().anyMatch(entity -> entity instanceof ScalarEntity && entity.getName().equals("extends") && ((ScalarEntity) entity).getValue().equals("software_component")));
}
Also used : EntityGraph(io.github.edmm.core.parser.EntityGraph) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) Arrays(java.util.Arrays) StringWriter(java.io.StringWriter) TTopologyTemplate(org.eclipse.winery.model.tosca.TTopologyTemplate) TServiceTemplate(org.eclipse.winery.model.tosca.TServiceTemplate) Test(org.junit.jupiter.api.Test) EdmmDependantTest(org.eclipse.winery.edmm.EdmmDependantTest) Entity(io.github.edmm.core.parser.Entity) MappingEntity(io.github.edmm.core.parser.MappingEntity) Stream(java.util.stream.Stream) EntityGraph(io.github.edmm.core.parser.EntityGraph) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Optional(java.util.Optional) ScalarEntity(io.github.edmm.core.parser.ScalarEntity) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) UnsupportedEncodingException(java.io.UnsupportedEncodingException) TTopologyTemplate(org.eclipse.winery.model.tosca.TTopologyTemplate) ScalarEntity(io.github.edmm.core.parser.ScalarEntity) TServiceTemplate(org.eclipse.winery.model.tosca.TServiceTemplate) Test(org.junit.jupiter.api.Test) EdmmDependantTest(org.eclipse.winery.edmm.EdmmDependantTest)

Example 14 with ScalarEntity

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

the class EdmmConverterTest method transformTopologyWithRelationsAndRelationTypes.

@Test
void transformTopologyWithRelationsAndRelationTypes() {
    // region *** build the TopologyTemplate ***
    TTopologyTemplate.Builder topology = new TTopologyTemplate.Builder();
    topology.addNodeTemplate(nodeTemplates.get("test_node_1"));
    topology.addNodeTemplate(nodeTemplates.get("test_node_2"));
    topology.addNodeTemplate(nodeTemplates.get("test_node_3"));
    topology.addRelationshipTemplate(relationshipTemplates.get("1_hosted_on_3"));
    topology.addRelationshipTemplate(relationshipTemplates.get("2_hosted_on_3"));
    topology.addRelationshipTemplate(relationshipTemplates.get("1_connects_to_2"));
    // endregion
    TServiceTemplate serviceTemplate = new TServiceTemplate();
    serviceTemplate.setTopologyTemplate(topology.build());
    EdmmConverter edmmConverter = new EdmmConverter(nodeTypes, relationshipTypes, nodeTypeImplementations, relationshipTypeImplementations, artifactTemplates, edmmTypeExtendsMapping, edmm1to1Mapping);
    EntityGraph transform = edmmConverter.transform(serviceTemplate);
    assertNotNull(transform);
    assertTrue(transform.vertexSet().stream().anyMatch(entity -> entity instanceof ScalarEntity && entity.getName().equals("hosted_on") && ((ScalarEntity) entity).getValue().equals("test_node_3") && entity.getParent().isPresent() && entity.getParent().get().getName().equals("relations")));
    assertTrue(transform.vertexSet().stream().anyMatch(entity -> entity instanceof ScalarEntity && entity.getName().equals("connects_to") && ((ScalarEntity) entity).getValue().equals("test_node_2") && entity.getParent().isPresent() && entity.getParent().get().getName().equals("relations")));
}
Also used : EntityGraph(io.github.edmm.core.parser.EntityGraph) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) Arrays(java.util.Arrays) StringWriter(java.io.StringWriter) TTopologyTemplate(org.eclipse.winery.model.tosca.TTopologyTemplate) TServiceTemplate(org.eclipse.winery.model.tosca.TServiceTemplate) Test(org.junit.jupiter.api.Test) EdmmDependantTest(org.eclipse.winery.edmm.EdmmDependantTest) Entity(io.github.edmm.core.parser.Entity) MappingEntity(io.github.edmm.core.parser.MappingEntity) Stream(java.util.stream.Stream) EntityGraph(io.github.edmm.core.parser.EntityGraph) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Optional(java.util.Optional) ScalarEntity(io.github.edmm.core.parser.ScalarEntity) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) UnsupportedEncodingException(java.io.UnsupportedEncodingException) TTopologyTemplate(org.eclipse.winery.model.tosca.TTopologyTemplate) ScalarEntity(io.github.edmm.core.parser.ScalarEntity) TServiceTemplate(org.eclipse.winery.model.tosca.TServiceTemplate) Test(org.junit.jupiter.api.Test) EdmmDependantTest(org.eclipse.winery.edmm.EdmmDependantTest)

Aggregations

ScalarEntity (io.github.edmm.core.parser.ScalarEntity)14 MappingEntity (io.github.edmm.core.parser.MappingEntity)12 EntityId (io.github.edmm.core.parser.EntityId)8 Entity (io.github.edmm.core.parser.Entity)5 EntityGraph (io.github.edmm.core.parser.EntityGraph)4 SequenceEntity (io.github.edmm.core.parser.SequenceEntity)4 UnsupportedEncodingException (java.io.UnsupportedEncodingException)4 EdmmDependantTest (org.eclipse.winery.edmm.EdmmDependantTest)4 TServiceTemplate (org.eclipse.winery.model.tosca.TServiceTemplate)4 TTopologyTemplate (org.eclipse.winery.model.tosca.TTopologyTemplate)4 Test (org.junit.jupiter.api.Test)4 StringWriter (java.io.StringWriter)3 Arrays (java.util.Arrays)3 Optional (java.util.Optional)3 Stream (java.util.stream.Stream)3 QName (javax.xml.namespace.QName)3 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)3 Assertions.assertNotNull (org.junit.jupiter.api.Assertions.assertNotNull)3 Assertions.assertTrue (org.junit.jupiter.api.Assertions.assertTrue)3 TNodeTemplate (org.eclipse.winery.model.tosca.TNodeTemplate)2