summaryrefslogtreecommitdiffstats
path: root/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsDataPersistenceServiceImpl.java
diff options
context:
space:
mode:
Diffstat (limited to 'cps-ri/src/main/java/org/onap/cps/spi/impl/CpsDataPersistenceServiceImpl.java')
-rw-r--r--cps-ri/src/main/java/org/onap/cps/spi/impl/CpsDataPersistenceServiceImpl.java17
1 files changed, 13 insertions, 4 deletions
diff --git a/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsDataPersistenceServiceImpl.java b/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsDataPersistenceServiceImpl.java
index b85b30d9d..d2b7273fe 100644
--- a/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsDataPersistenceServiceImpl.java
+++ b/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsDataPersistenceServiceImpl.java
@@ -265,17 +265,26 @@ public class CpsDataPersistenceServiceImpl implements CpsDataPersistenceService
final DataspaceEntity dataspaceEntity = dataspaceRepository.getByName(dataspaceName);
final AnchorEntity anchorEntity = anchorRepository.getByDataspaceAndName(dataspaceEntity, anchorName);
- final Set<String> normalizedXpaths = new HashSet<>(xpaths.size());
- for (final String xpath : xpaths) {
+ final Collection<String> nonRootXpaths = new HashSet<>(xpaths);
+ final boolean haveRootXpath = nonRootXpaths.removeIf(CpsDataPersistenceServiceImpl::isRootXpath);
+
+ final Collection<String> normalizedXpaths = new HashSet<>(nonRootXpaths.size());
+ for (final String xpath : nonRootXpaths) {
try {
normalizedXpaths.add(CpsPathUtil.getNormalizedXpath(xpath));
} catch (final PathParsingException e) {
log.warn("Error parsing xpath \"{}\" in getDataNodes: {}", xpath, e.getMessage());
}
}
+ final Collection<FragmentEntity> fragmentEntities =
+ new HashSet<>(fragmentRepository.findByAnchorAndMultipleCpsPaths(anchorEntity.getId(), normalizedXpaths));
+
+ if (haveRootXpath) {
+ final List<FragmentExtract> fragmentExtracts = fragmentRepository.getTopLevelFragments(dataspaceEntity,
+ anchorEntity);
+ fragmentEntities.addAll(FragmentEntityArranger.toFragmentEntityTrees(anchorEntity, fragmentExtracts));
+ }
- final List<FragmentEntity> fragmentEntities =
- fragmentRepository.findByAnchorAndMultipleCpsPaths(anchorEntity.getId(), normalizedXpaths);
return toDataNodes(fragmentEntities, fetchDescendantsOption);
}