diff --git a/org.opentosca.container.core/src/main/java/org/opentosca/container/core/next/repository/NodeTemplateInstanceRepository.java b/org.opentosca.container.core/src/main/java/org/opentosca/container/core/next/repository/NodeTemplateInstanceRepository.java index df620cc99..5c99e10a7 100644 --- a/org.opentosca.container.core/src/main/java/org/opentosca/container/core/next/repository/NodeTemplateInstanceRepository.java +++ b/org.opentosca.container.core/src/main/java/org/opentosca/container/core/next/repository/NodeTemplateInstanceRepository.java @@ -26,6 +26,9 @@ public interface NodeTemplateInstanceRepository extends JpaRepository findByServiceTemplateInstanceAndTemplateId(ServiceTemplateInstance serviceTemplateInstance, String templateId); + @EntityGraph(attributePaths = {"properties"}) + Optional findById(Long id); + @EntityGraph(attributePaths = {"properties"}) Optional findWithPropertiesById(Long id); diff --git a/org.opentosca.container.core/src/main/java/org/opentosca/container/core/next/services/instances/ServiceTemplateInstanceService.java b/org.opentosca.container.core/src/main/java/org/opentosca/container/core/next/services/instances/ServiceTemplateInstanceService.java index c4b01928f..efffd5101 100644 --- a/org.opentosca.container.core/src/main/java/org/opentosca/container/core/next/services/instances/ServiceTemplateInstanceService.java +++ b/org.opentosca.container.core/src/main/java/org/opentosca/container/core/next/services/instances/ServiceTemplateInstanceService.java @@ -16,6 +16,7 @@ import org.opentosca.container.core.next.model.ServiceTemplateInstance; import org.opentosca.container.core.next.model.ServiceTemplateInstanceProperty; import org.opentosca.container.core.next.model.ServiceTemplateInstanceState; +import org.opentosca.container.core.next.repository.NodeTemplateInstanceRepository; import org.opentosca.container.core.next.repository.PlanInstanceRepository; import org.opentosca.container.core.next.repository.ServiceTemplateInstanceRepository; import org.opentosca.container.core.next.services.templates.ServiceTemplateService; @@ -37,18 +38,21 @@ public class ServiceTemplateInstanceService { private final PlanInstanceRepository planInstanceRepository; private final PlanInstanceService planInstanceService; + private final NodeTemplateInstanceRepository nodeTemplateInstanceRepository; + private final PropertyMappingsHelper helper; public ServiceTemplateInstanceService(ServiceTemplateInstanceRepository serviceTemplateInstanceRepository, ServiceTemplateService serviceTemplateService, PlanInstanceRepository planInstanceRepository, - PlanInstanceService planInstanceService, CsarStorageService storage) { + PlanInstanceService planInstanceService, NodeTemplateInstanceRepository nodeTemplateInstanceRepository, CsarStorageService storage) { this.serviceTemplateInstanceRepository = serviceTemplateInstanceRepository; this.serviceTemplateService = serviceTemplateService; this.planInstanceRepository = planInstanceRepository; this.planInstanceService = planInstanceService; + this.nodeTemplateInstanceRepository = nodeTemplateInstanceRepository; - helper = new PropertyMappingsHelper(storage); + helper = new PropertyMappingsHelper(storage, this.nodeTemplateInstanceRepository); } /** diff --git a/org.opentosca.container.core/src/main/java/org/opentosca/container/core/next/utils/PropertyMappingsHelper.java b/org.opentosca.container.core/src/main/java/org/opentosca/container/core/next/utils/PropertyMappingsHelper.java index e7be745e4..3c20fe30b 100644 --- a/org.opentosca.container.core/src/main/java/org/opentosca/container/core/next/utils/PropertyMappingsHelper.java +++ b/org.opentosca.container.core/src/main/java/org/opentosca/container/core/next/utils/PropertyMappingsHelper.java @@ -25,6 +25,7 @@ import org.opentosca.container.core.next.model.NodeTemplateInstanceProperty; import org.opentosca.container.core.next.model.ServiceTemplateInstance; import org.opentosca.container.core.next.model.ServiceTemplateInstanceProperty; +import org.opentosca.container.core.next.repository.NodeTemplateInstanceRepository; import org.opentosca.container.core.service.CsarStorageService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -37,8 +38,12 @@ public class PropertyMappingsHelper { private static final Logger logger = LoggerFactory.getLogger(PropertyMappingsHelper.class); private final CsarStorageService storage; - public PropertyMappingsHelper(CsarStorageService storage) { + + private final NodeTemplateInstanceRepository nodeTemplateInstanceRepository; + + public PropertyMappingsHelper(CsarStorageService storage, NodeTemplateInstanceRepository nodeTemplateInstanceRepository) { this.storage = storage; + this.nodeTemplateInstanceRepository = nodeTemplateInstanceRepository; } /** @@ -200,16 +205,12 @@ private String generatePropertyValueFromConcatQuery(final String targetPropertyR if (functionPart.trim().startsWith("'")) { // string function part, just add to list augmentedFunctionParts.add(functionPart.trim()); - } else if (functionPart.trim().split("\\.").length == 3) { + } else if (functionPart.trim().split(".Properties.").length == 2) { // "DSL" Query - final String[] queryParts = functionPart.trim().split("\\."); - // fast check for validity - if (!queryParts[1].equals("Properties")) { - return null; - } + final String[] queryParts = functionPart.trim().split(".Properties."); final String nodeTemplateName = queryParts[0]; - final String propertyName = queryParts[2]; + final String propertyName = queryParts[1]; if (getNodeInstanceWithName(nodeInstance, nodeTemplateName) != null) { @@ -239,7 +240,7 @@ private NodeTemplateInstance getNodeInstanceWithName(final Collection