Implement ends with cps path query to support multiple attributes with 'and' condition
[cps.git] / cps-ri / src / main / java / org / onap / cps / spi / impl / CpsDataPersistenceServiceImpl.java
index ca279f3..fa13c7d 100644 (file)
@@ -2,6 +2,7 @@
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2021 Nordix Foundation
  *  Modifications Copyright (C) 2021 Pantheon.tech
+ *  Modifications Copyright (C) 2020-2021 Bell Canada.
  *  ================================================================================
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -143,6 +144,11 @@ public class CpsDataPersistenceServiceImpl implements CpsDataPersistenceService
             fragmentEntities = fragmentRepository
                 .getByAnchorAndXpathAndLeafAttributes(anchorEntity.getId(), cpsPathQuery.getXpathPrefix(), cpsPathQuery
                     .getLeafName(), cpsPathQuery.getLeafValue());
+        } else if (CpsPathQueryType.XPATH_HAS_DESCENDANT_WITH_LEAF_VALUES.equals(cpsPathQuery.getCpsPathQueryType())) {
+            final String leafDataAsJson = GSON.toJson(cpsPathQuery.getLeavesData());
+            fragmentEntities = fragmentRepository
+                .getByAnchorAndDescendentNameAndLeafValues(anchorEntity.getId(),
+                    cpsPathQuery.getDescendantName(), leafDataAsJson);
         } else {
             fragmentEntities = fragmentRepository
                 .getByAnchorAndXpathEndsInDescendantName(anchorEntity.getId(), cpsPathQuery.getDescendantName());