Search in sources :

Example 1 with EdmmManager

use of org.eclipse.winery.edmm.EdmmManager in project winery by eclipse.

the class EdmmResource method getOneToOneMap.

@GET
@Path("one-to-one-map")
@Produces(MediaType.APPLICATION_JSON)
public Response getOneToOneMap() {
    IRepository repository = RepositoryFactory.getRepository();
    EdmmManager edmmManager = EdmmManager.forRepository(repository);
    Map<QName, EdmmType> oneToOneMap = edmmManager.getOneToOneMap();
    Map<String, String> reverseOneToOneMap = new HashMap<>();
    for (Map.Entry<QName, EdmmType> entry : oneToOneMap.entrySet()) {
        EdmmType edmmType = entry.getValue();
        reverseOneToOneMap.put(edmmType.getValue(), entry.getKey().getLocalPart());
    }
    return Response.ok().type(MediaType.APPLICATION_JSON).entity(reverseOneToOneMap).build();
}
Also used : EdmmType(org.eclipse.winery.edmm.model.EdmmType) HashMap(java.util.HashMap) QName(javax.xml.namespace.QName) EdmmManager(org.eclipse.winery.edmm.EdmmManager) IRepository(org.eclipse.winery.repository.backend.IRepository) Map(java.util.Map) HashMap(java.util.HashMap) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 2 with EdmmManager

use of org.eclipse.winery.edmm.EdmmManager in project winery by eclipse.

the class RestUtils method getEdmmEntityGraph.

public static EntityGraph getEdmmEntityGraph(TServiceTemplate element, boolean useAbsolutPaths) {
    IRepository repository = RepositoryFactory.getRepository();
    Map<QName, TNodeType> nodeTypes = repository.getQNameToElementMapping(NodeTypeId.class);
    Map<QName, TRelationshipType> relationshipTypes = repository.getQNameToElementMapping(RelationshipTypeId.class);
    Map<QName, TNodeTypeImplementation> nodeTypeImplementations = repository.getQNameToElementMapping(NodeTypeImplementationId.class);
    Map<QName, TRelationshipTypeImplementation> relationshipTypeImplementations = repository.getQNameToElementMapping(RelationshipTypeImplementationId.class);
    Map<QName, TArtifactTemplate> artifactTemplates = repository.getQNameToElementMapping(ArtifactTemplateId.class);
    EdmmManager edmmManager = EdmmManager.forRepository(repository);
    Map<QName, EdmmType> oneToOneMappings = edmmManager.getOneToOneMap();
    Map<QName, EdmmType> typeMappings = edmmManager.getTypeMap();
    if (nodeTypes.isEmpty()) {
        throw new IllegalStateException("No Node Types defined!");
    } else if (relationshipTypes.isEmpty()) {
        throw new IllegalStateException("No Relationship Types defined!");
    }
    EdmmConverter edmmConverter = new EdmmConverter(nodeTypes, relationshipTypes, nodeTypeImplementations, relationshipTypeImplementations, artifactTemplates, typeMappings, oneToOneMappings, useAbsolutPaths);
    return edmmConverter.transform(element);
}
Also used : QName(javax.xml.namespace.QName) TArtifactTemplate(org.eclipse.winery.model.tosca.TArtifactTemplate) TNodeTypeImplementation(org.eclipse.winery.model.tosca.TNodeTypeImplementation) TNodeType(org.eclipse.winery.model.tosca.TNodeType) TRelationshipType(org.eclipse.winery.model.tosca.TRelationshipType) EdmmType(org.eclipse.winery.edmm.model.EdmmType) TRelationshipTypeImplementation(org.eclipse.winery.model.tosca.TRelationshipTypeImplementation) EdmmConverter(org.eclipse.winery.edmm.model.EdmmConverter) EdmmManager(org.eclipse.winery.edmm.EdmmManager) IRepository(org.eclipse.winery.repository.backend.IRepository)

Aggregations

QName (javax.xml.namespace.QName)2 EdmmManager (org.eclipse.winery.edmm.EdmmManager)2 EdmmType (org.eclipse.winery.edmm.model.EdmmType)2 IRepository (org.eclipse.winery.repository.backend.IRepository)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 EdmmConverter (org.eclipse.winery.edmm.model.EdmmConverter)1 TArtifactTemplate (org.eclipse.winery.model.tosca.TArtifactTemplate)1 TNodeType (org.eclipse.winery.model.tosca.TNodeType)1 TNodeTypeImplementation (org.eclipse.winery.model.tosca.TNodeTypeImplementation)1 TRelationshipType (org.eclipse.winery.model.tosca.TRelationshipType)1 TRelationshipTypeImplementation (org.eclipse.winery.model.tosca.TRelationshipTypeImplementation)1