From 8a1e3c9f90d2111835460fc042b4a63f93b80384 Mon Sep 17 00:00:00 2001 From: Ruslan Kashapov Date: Tue, 24 Nov 2020 11:13:43 +0200 Subject: Associate anchor to schema set - db schema updated - db layer tests provided for ancor create and reading by dataspace - anchor model is removed from rest api as extra - api/spi updated to use string references instead of object Issue-ID: CPS-99 Change-Id: Ideeb83fa9e91ec1816308d8327a6589b999c64c5 Signed-off-by: Ruslan Kashapov --- .../java/org/onap/cps/api/CpsAdminService.java | 13 ++++++++----- .../org/onap/cps/api/impl/CpsAdminServiceImpl.java | 4 ++-- .../onap/cps/spi/CpsAdminPersistenceService.java | 13 +++++++++---- .../main/java/org/onap/cps/spi/model/Anchor.java | 22 ++++++++++------------ 4 files changed, 29 insertions(+), 23 deletions(-) (limited to 'cps-service/src/main/java/org') diff --git a/cps-service/src/main/java/org/onap/cps/api/CpsAdminService.java b/cps-service/src/main/java/org/onap/cps/api/CpsAdminService.java index a2c05bfe5a..5090e3a3c4 100644 --- a/cps-service/src/main/java/org/onap/cps/api/CpsAdminService.java +++ b/cps-service/src/main/java/org/onap/cps/api/CpsAdminService.java @@ -21,6 +21,7 @@ package org.onap.cps.api; import java.util.Collection; +import org.checkerframework.checker.nullness.qual.NonNull; import org.onap.cps.spi.exceptions.CpsException; import org.onap.cps.spi.model.Anchor; @@ -30,13 +31,14 @@ import org.onap.cps.spi.model.Anchor; public interface CpsAdminService { /** - * Create an anchor using provided anchorDetails object. + * Create an Anchor. * - * @param anchor the anchor details object. - * @return the anchor name. + * @param dataspaceName dataspace name + * @param schemaSetName schema set name + * @param anchorName anchor name * @throws CpsException if input data is invalid. */ - String createAnchor(Anchor anchor); + void createAnchor(@NonNull String dataspaceName, @NonNull String schemaSetName, @NonNull String anchorName); /** * Read all anchors in the given a dataspace. @@ -44,5 +46,6 @@ public interface CpsAdminService { * @param dataspaceName dataspace name * @return a collection of anchors */ - Collection getAnchors(String dataspaceName); + @NonNull + Collection getAnchors(@NonNull String dataspaceName); } diff --git a/cps-service/src/main/java/org/onap/cps/api/impl/CpsAdminServiceImpl.java b/cps-service/src/main/java/org/onap/cps/api/impl/CpsAdminServiceImpl.java index 5d9bc015fd..f93a827079 100644 --- a/cps-service/src/main/java/org/onap/cps/api/impl/CpsAdminServiceImpl.java +++ b/cps-service/src/main/java/org/onap/cps/api/impl/CpsAdminServiceImpl.java @@ -34,8 +34,8 @@ public class CpsAdminServiceImpl implements CpsAdminService { private CpsAdminPersistenceService cpsAdminPersistenceService; @Override - public String createAnchor(final Anchor anchor) { - return cpsAdminPersistenceService.createAnchor(anchor); + public void createAnchor(final String dataspaceName, final String schemaSetName, final String anchorName) { + cpsAdminPersistenceService.createAnchor(dataspaceName, schemaSetName, anchorName); } @Override diff --git a/cps-service/src/main/java/org/onap/cps/spi/CpsAdminPersistenceService.java b/cps-service/src/main/java/org/onap/cps/spi/CpsAdminPersistenceService.java index 4e88d49a63..1b7ddb724c 100644 --- a/cps-service/src/main/java/org/onap/cps/spi/CpsAdminPersistenceService.java +++ b/cps-service/src/main/java/org/onap/cps/spi/CpsAdminPersistenceService.java @@ -22,6 +22,7 @@ package org.onap.cps.spi; import java.util.Collection; +import org.checkerframework.checker.nullness.qual.NonNull; import org.onap.cps.spi.model.Anchor; /* @@ -32,10 +33,12 @@ public interface CpsAdminPersistenceService { /** * Create an Anchor. * - * @param anchor the anchorDetails object. - * @return the anchor name. + * @param dataspaceName dataspace name + * @param schemaSetName schema set name + * @param anchorName anchor name */ - String createAnchor(Anchor anchor); + void createAnchor(@NonNull String dataspaceName, @NonNull String schemaSetName, @NonNull String anchorName); + /** * Read all anchors in the given a dataspace. @@ -43,5 +46,7 @@ public interface CpsAdminPersistenceService { * @param dataspaceName dataspace name * @return a collection of anchors */ - Collection getAnchors(String dataspaceName); + @NonNull + Collection getAnchors(@NonNull String dataspaceName); + } diff --git a/cps-service/src/main/java/org/onap/cps/spi/model/Anchor.java b/cps-service/src/main/java/org/onap/cps/spi/model/Anchor.java index cd1c774476..456f733935 100644 --- a/cps-service/src/main/java/org/onap/cps/spi/model/Anchor.java +++ b/cps-service/src/main/java/org/onap/cps/spi/model/Anchor.java @@ -21,23 +21,21 @@ package org.onap.cps.spi.model; import java.io.Serializable; -import java.util.Map; -import lombok.Getter; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; import lombok.NoArgsConstructor; -import lombok.Setter; -@Setter -@Getter +@Data +@Builder @NoArgsConstructor +@AllArgsConstructor public class Anchor implements Serializable { - // anchor will support both a single module and schema set until CPS-99 is complete private static final long serialVersionUID = 1464791260718603291L; - private String anchorName; + + private String name; private String dataspaceName; - private String namespace; - private String revision; - private String moduleSetName; - private Map externalReferences; - private String xpath; + private String schemaSetName; + } \ No newline at end of file -- cgit 1.2.3-korg