Search in sources :

Example 1 with ToscaLightChecker

use of org.eclipse.winery.edmm.toscalight.ToscaLightChecker in project winery by eclipse.

the class EdmmUtils method getAllToscaLightCompliantModels.

public static Map<QName, TServiceTemplate> getAllToscaLightCompliantModels() {
    Map<QName, TServiceTemplate> serviceTemplates = RepositoryFactory.getRepository().getQNameToElementMapping(ServiceTemplateId.class);
    ToscaLightChecker toscaLightChecker = EdmmUtils.getToscaLightChecker();
    return serviceTemplates.entrySet().stream().filter(entry -> toscaLightChecker.isToscaLightCompliant(entry.getValue())).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
}
Also used : ServiceTemplateId(org.eclipse.winery.model.ids.definitions.ServiceTemplateId) HashMap(java.util.HashMap) TNodeType(org.eclipse.winery.model.tosca.TNodeType) Collectors(java.util.stream.Collectors) RelationshipTypeId(org.eclipse.winery.model.ids.definitions.RelationshipTypeId) RepositoryFactory(org.eclipse.winery.repository.backend.RepositoryFactory) TServiceTemplate(org.eclipse.winery.model.tosca.TServiceTemplate) EdmmType(org.eclipse.winery.edmm.model.EdmmType) List(java.util.List) IRepository(org.eclipse.winery.repository.backend.IRepository) Map(java.util.Map) TRelationshipType(org.eclipse.winery.model.tosca.TRelationshipType) ToscaLightChecker(org.eclipse.winery.edmm.toscalight.ToscaLightChecker) QName(javax.xml.namespace.QName) NodeTypeId(org.eclipse.winery.model.ids.definitions.NodeTypeId) QName(javax.xml.namespace.QName) HashMap(java.util.HashMap) Map(java.util.Map) TServiceTemplate(org.eclipse.winery.model.tosca.TServiceTemplate) ToscaLightChecker(org.eclipse.winery.edmm.toscalight.ToscaLightChecker)

Example 2 with ToscaLightChecker

use of org.eclipse.winery.edmm.toscalight.ToscaLightChecker in project winery by eclipse.

the class EdmmUtils method checkToscaLightCompatibility.

public static Map<String, Object> checkToscaLightCompatibility(TServiceTemplate serviceTemplate) {
    ToscaLightChecker toscaLightChecker = getToscaLightChecker();
    boolean toscaLightCompliant = toscaLightChecker.isToscaLightCompliant(serviceTemplate);
    Map<QName, List<String>> errorList = toscaLightChecker.getErrorList();
    errorList.entrySet().removeIf(entry -> entry.getValue().isEmpty());
    HashMap<String, Object> map = new HashMap<>();
    map.put("isToscaLightCompatible", toscaLightCompliant);
    map.put("errorList", errorList);
    return map;
}
Also used : HashMap(java.util.HashMap) QName(javax.xml.namespace.QName) List(java.util.List) ToscaLightChecker(org.eclipse.winery.edmm.toscalight.ToscaLightChecker)

Example 3 with ToscaLightChecker

use of org.eclipse.winery.edmm.toscalight.ToscaLightChecker in project winery by eclipse.

the class EdmmUtils method getToscaLightChecker.

public static ToscaLightChecker getToscaLightChecker() {
    IRepository repository = RepositoryFactory.getRepository();
    Map<QName, TRelationshipType> relationshipTypes = repository.getQNameToElementMapping(RelationshipTypeId.class);
    Map<QName, TNodeType> nodeTypes = repository.getQNameToElementMapping(NodeTypeId.class);
    Map<QName, EdmmType> typeMap = EdmmManager.forRepository(repository).getTypeMap();
    Map<QName, EdmmType> oneToOneMap = EdmmManager.forRepository(repository).getOneToOneMap();
    return new ToscaLightChecker(nodeTypes, relationshipTypes, typeMap, oneToOneMap);
}
Also used : TRelationshipType(org.eclipse.winery.model.tosca.TRelationshipType) EdmmType(org.eclipse.winery.edmm.model.EdmmType) QName(javax.xml.namespace.QName) IRepository(org.eclipse.winery.repository.backend.IRepository) TNodeType(org.eclipse.winery.model.tosca.TNodeType) ToscaLightChecker(org.eclipse.winery.edmm.toscalight.ToscaLightChecker)

Aggregations

QName (javax.xml.namespace.QName)3 ToscaLightChecker (org.eclipse.winery.edmm.toscalight.ToscaLightChecker)3 HashMap (java.util.HashMap)2 List (java.util.List)2 EdmmType (org.eclipse.winery.edmm.model.EdmmType)2 TNodeType (org.eclipse.winery.model.tosca.TNodeType)2 TRelationshipType (org.eclipse.winery.model.tosca.TRelationshipType)2 IRepository (org.eclipse.winery.repository.backend.IRepository)2 Map (java.util.Map)1 Collectors (java.util.stream.Collectors)1 NodeTypeId (org.eclipse.winery.model.ids.definitions.NodeTypeId)1 RelationshipTypeId (org.eclipse.winery.model.ids.definitions.RelationshipTypeId)1 ServiceTemplateId (org.eclipse.winery.model.ids.definitions.ServiceTemplateId)1 TServiceTemplate (org.eclipse.winery.model.tosca.TServiceTemplate)1 RepositoryFactory (org.eclipse.winery.repository.backend.RepositoryFactory)1