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;
}
}
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());
}
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")));
}
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")));
}
Aggregations