diff options
Diffstat (limited to 'cps-ri/src')
3 files changed, 7 insertions, 12 deletions
diff --git a/cps-ri/src/main/java/org/onap/cps/spi/entities/FragmentEntity.java b/cps-ri/src/main/java/org/onap/cps/spi/entities/FragmentEntity.java index e696a4064a..62c8c19cb1 100755 --- a/cps-ri/src/main/java/org/onap/cps/spi/entities/FragmentEntity.java +++ b/cps-ri/src/main/java/org/onap/cps/spi/entities/FragmentEntity.java @@ -34,7 +34,6 @@ import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; import javax.persistence.OneToMany; -import javax.persistence.OneToOne; import javax.persistence.Table; import javax.validation.constraints.NotNull; import lombok.AllArgsConstructor; @@ -86,7 +85,7 @@ public class FragmentEntity implements Serializable { @JoinColumn(name = "dataspace_id") private DataspaceEntity dataspace; - @OneToOne(fetch = FetchType.LAZY) + @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "anchor_id") @EqualsAndHashCode.Include private AnchorEntity anchor; 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 16ec270c22..cca5d9c849 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 @@ -343,6 +343,7 @@ public class CpsDataPersistenceServiceImpl implements CpsDataPersistenceService private static boolean canUseRegexQuickFind(final FetchDescendantsOption fetchDescendantsOption, final CpsPathQuery cpsPathQuery) { return fetchDescendantsOption.equals(FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS) + && !cpsPathQuery.hasAncestorAxis() && !cpsPathQuery.hasLeafConditions() && !cpsPathQuery.hasTextFunctionCondition() && !cpsPathQuery.hasContainsFunctionCondition(); @@ -351,17 +352,12 @@ public class CpsDataPersistenceServiceImpl implements CpsDataPersistenceService private List<DataNode> getDataNodesUsingRegexQuickFind(final FetchDescendantsOption fetchDescendantsOption, final AnchorEntity anchorEntity, final CpsPathQuery cpsPathQuery) { - Collection<FragmentEntity> fragmentEntities; final String xpathRegex = FragmentQueryBuilder.getXpathSqlRegexForQuickFindWithDescendants(cpsPathQuery); final List<FragmentExtract> fragmentExtracts = (anchorEntity == ALL_ANCHORS) - ? fragmentRepository.quickFindWithDescendantsAcrossAnchor(xpathRegex) : - fragmentRepository.quickFindWithDescendants(anchorEntity.getId(), xpathRegex); - fragmentEntities = FragmentEntityArranger.toFragmentEntityTrees(anchorEntity, fragmentExtracts); - if (cpsPathQuery.hasAncestorAxis()) { - final Collection<String> ancestorXpaths = processAncestorXpath(fragmentEntities, cpsPathQuery); - fragmentEntities = (anchorEntity == ALL_ANCHORS) ? getAncestorFragmentEntitiesAcrossAnchors(cpsPathQuery, - fragmentEntities) : getFragmentEntities(anchorEntity, ancestorXpaths, fetchDescendantsOption); - } + ? fragmentRepository.quickFindWithDescendantsAcrossAnchors(xpathRegex) + : fragmentRepository.quickFindWithDescendants(anchorEntity.getId(), xpathRegex); + final Collection<FragmentEntity> fragmentEntities = + FragmentEntityArranger.toFragmentEntityTrees(anchorEntity, fragmentExtracts); return createDataNodesFromFragmentEntities(fetchDescendantsOption, fragmentEntities); } diff --git a/cps-ri/src/main/java/org/onap/cps/spi/repository/FragmentRepository.java b/cps-ri/src/main/java/org/onap/cps/spi/repository/FragmentRepository.java index 8114f1055a..f389467a53 100755 --- a/cps-ri/src/main/java/org/onap/cps/spi/repository/FragmentRepository.java +++ b/cps-ri/src/main/java/org/onap/cps/spi/repository/FragmentRepository.java @@ -140,5 +140,5 @@ public interface FragmentRepository extends JpaRepository<FragmentEntity, Long>, + " CAST(attributes AS TEXT) AS attributes"
+ " FROM FRAGMENT WHERE xpath ~ :xpathRegex",
nativeQuery = true)
- List<FragmentExtract> quickFindWithDescendantsAcrossAnchor(@Param("xpathRegex") String xpathRegex);
+ List<FragmentExtract> quickFindWithDescendantsAcrossAnchors(@Param("xpathRegex") String xpathRegex);
}
|