summaryrefslogtreecommitdiffstats
path: root/cps-ri/src
diff options
context:
space:
mode:
authorRuslan Kashapov <ruslan.kashapov@pantheon.tech>2021-01-13 16:45:29 +0200
committerRuslan Kashapov <ruslan.kashapov@pantheon.tech>2021-01-13 16:46:11 +0200
commite08a5ca5c9edcb15a72235bdfd935ff3a3ced8d2 (patch)
tree6735c031d9861c6786c039d4b2dd02d140d3feff /cps-ri/src
parent49fe075361e4f0f3b2a1a561bc01f831983a3efb (diff)
Rename entity artifacts, remove obsolete entities
Issue-ID: CPS-162 Change-Id: I10604e12a01f22930278118830eed53f5a2b159c Signed-off-by: Ruslan Kashapov <ruslan.kashapov@pantheon.tech>
Diffstat (limited to 'cps-ri/src')
-rw-r--r--cps-ri/src/main/java/org/onap/cps/spi/entities/AnchorEntity.java4
-rw-r--r--cps-ri/src/main/java/org/onap/cps/spi/entities/DataspaceEntity.java (renamed from cps-ri/src/main/java/org/onap/cps/spi/entities/Dataspace.java)4
-rwxr-xr-xcps-ri/src/main/java/org/onap/cps/spi/entities/FragmentEntity.java (renamed from cps-ri/src/main/java/org/onap/cps/spi/entities/Fragment.java)164
-rw-r--r--cps-ri/src/main/java/org/onap/cps/spi/entities/JsonDataEntity.java54
-rwxr-xr-xcps-ri/src/main/java/org/onap/cps/spi/entities/Module.java87
-rw-r--r--cps-ri/src/main/java/org/onap/cps/spi/entities/SchemaSetEntity.java (renamed from cps-ri/src/main/java/org/onap/cps/spi/entities/SchemaSet.java)6
-rw-r--r--cps-ri/src/main/java/org/onap/cps/spi/entities/YangResourceEntity.java (renamed from cps-ri/src/main/java/org/onap/cps/spi/entities/YangResource.java)4
-rw-r--r--cps-ri/src/main/java/org/onap/cps/spi/impl/CpsAdminPersistenceServiceImpl.java19
-rw-r--r--cps-ri/src/main/java/org/onap/cps/spi/impl/CpsModulePersistenceServiceImpl.java62
-rw-r--r--cps-ri/src/main/java/org/onap/cps/spi/repository/AnchorRepository.java7
-rwxr-xr-xcps-ri/src/main/java/org/onap/cps/spi/repository/DataspaceRepository.java9
-rwxr-xr-xcps-ri/src/main/java/org/onap/cps/spi/repository/FragmentRepository.java4
-rwxr-xr-xcps-ri/src/main/java/org/onap/cps/spi/repository/ModuleRepository.java55
-rw-r--r--cps-ri/src/main/java/org/onap/cps/spi/repository/SchemaSetRepository.java22
-rw-r--r--cps-ri/src/main/java/org/onap/cps/spi/repository/YangResourceRepository.java6
-rw-r--r--cps-ri/src/test/java/org/onap/cps/spi/impl/CpsAdminPersistenceServiceTest.java14
-rw-r--r--cps-ri/src/test/java/org/onap/cps/spi/impl/CpsModulePersistenceServiceTest.java36
17 files changed, 183 insertions, 374 deletions
diff --git a/cps-ri/src/main/java/org/onap/cps/spi/entities/AnchorEntity.java b/cps-ri/src/main/java/org/onap/cps/spi/entities/AnchorEntity.java
index e7e9c971dd..b893428278 100644
--- a/cps-ri/src/main/java/org/onap/cps/spi/entities/AnchorEntity.java
+++ b/cps-ri/src/main/java/org/onap/cps/spi/entities/AnchorEntity.java
@@ -61,10 +61,10 @@ public class AnchorEntity implements Serializable {
@NotNull
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "schema_set_id")
- private SchemaSet schemaSet;
+ private SchemaSetEntity schemaSet;
@NotNull
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "dataspace_id")
- private Dataspace dataspace;
+ private DataspaceEntity dataspace;
}
diff --git a/cps-ri/src/main/java/org/onap/cps/spi/entities/Dataspace.java b/cps-ri/src/main/java/org/onap/cps/spi/entities/DataspaceEntity.java
index 9f127f432a..45b41dbe81 100644
--- a/cps-ri/src/main/java/org/onap/cps/spi/entities/Dataspace.java
+++ b/cps-ri/src/main/java/org/onap/cps/spi/entities/DataspaceEntity.java
@@ -42,7 +42,7 @@ import lombok.Setter;
@AllArgsConstructor
@NoArgsConstructor
@Table(name = "dataspace")
-public class Dataspace implements Serializable {
+public class DataspaceEntity implements Serializable {
private static final long serialVersionUID = 8395254649813051882L;
@@ -59,7 +59,7 @@ public class Dataspace implements Serializable {
*
* @param name the Dataspace name.
*/
- public Dataspace(final String name) {
+ public DataspaceEntity(final String name) {
this.name = name;
}
} \ No newline at end of file
diff --git a/cps-ri/src/main/java/org/onap/cps/spi/entities/Fragment.java b/cps-ri/src/main/java/org/onap/cps/spi/entities/FragmentEntity.java
index 053a223219..d1557489c3 100755
--- a/cps-ri/src/main/java/org/onap/cps/spi/entities/Fragment.java
+++ b/cps-ri/src/main/java/org/onap/cps/spi/entities/FragmentEntity.java
@@ -1,82 +1,82 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2020 Nordix Foundation. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.cps.spi.entities;
-
-import com.vladmihalcea.hibernate.type.json.JsonBinaryType;
-import java.io.Serializable;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.FetchType;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.JoinColumn;
-import javax.persistence.ManyToOne;
-import javax.persistence.OneToOne;
-import javax.validation.constraints.NotNull;
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Getter;
-import lombok.NoArgsConstructor;
-import lombok.Setter;
-import org.hibernate.annotations.Type;
-import org.hibernate.annotations.TypeDef;
-import org.hibernate.annotations.TypeDefs;
-
-/**
- * Entity to store a fragment.
- */
-@Getter
-@Setter
-@AllArgsConstructor
-@NoArgsConstructor
-@Builder
-@Entity
-@TypeDefs({@TypeDef(name = "jsonb", typeClass = JsonBinaryType.class)})
-public class Fragment implements Serializable {
-
- private static final long serialVersionUID = 7737669789097119667L;
-
- @Id
- @GeneratedValue(strategy = GenerationType.IDENTITY)
- private Long id;
-
- @NotNull
- @Column(columnDefinition = "text")
- private String xpath;
-
- @Type(type = "jsonb")
- @Column(columnDefinition = "jsonb")
- private String attributes;
-
- @NotNull
- @ManyToOne(fetch = FetchType.LAZY)
- @JoinColumn(name = "dataspace_id")
- private Dataspace dataspace;
-
- @OneToOne(fetch = FetchType.LAZY)
- @JoinColumn(name = "anchor_id")
- private AnchorEntity anchor;
-
- @OneToOne(fetch = FetchType.LAZY)
- @JoinColumn(name = "parent_id")
- private Fragment parentFragment;
-}
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix Foundation. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.cps.spi.entities;
+
+import com.vladmihalcea.hibernate.type.json.JsonBinaryType;
+import java.io.Serializable;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.OneToOne;
+import javax.validation.constraints.NotNull;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+import org.hibernate.annotations.Type;
+import org.hibernate.annotations.TypeDef;
+import org.hibernate.annotations.TypeDefs;
+
+/**
+ * Entity to store a fragment.
+ */
+@Getter
+@Setter
+@AllArgsConstructor
+@NoArgsConstructor
+@Builder
+@Entity
+@TypeDefs({@TypeDef(name = "jsonb", typeClass = JsonBinaryType.class)})
+public class FragmentEntity implements Serializable {
+
+ private static final long serialVersionUID = 7737669789097119667L;
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ private Long id;
+
+ @NotNull
+ @Column(columnDefinition = "text")
+ private String xpath;
+
+ @Type(type = "jsonb")
+ @Column(columnDefinition = "jsonb")
+ private String attributes;
+
+ @NotNull
+ @ManyToOne(fetch = FetchType.LAZY)
+ @JoinColumn(name = "dataspace_id")
+ private DataspaceEntity dataspace;
+
+ @OneToOne(fetch = FetchType.LAZY)
+ @JoinColumn(name = "anchor_id")
+ private AnchorEntity anchor;
+
+ @OneToOne(fetch = FetchType.LAZY)
+ @JoinColumn(name = "parent_id")
+ private FragmentEntity parentFragment;
+}
diff --git a/cps-ri/src/main/java/org/onap/cps/spi/entities/JsonDataEntity.java b/cps-ri/src/main/java/org/onap/cps/spi/entities/JsonDataEntity.java
deleted file mode 100644
index bd147bf73c..0000000000
--- a/cps-ri/src/main/java/org/onap/cps/spi/entities/JsonDataEntity.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Copyright (C) 2020 Nordix Foundation
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.cps.spi.entities;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.Table;
-import lombok.AllArgsConstructor;
-import lombok.Getter;
-import lombok.NoArgsConstructor;
-import lombok.Setter;
-
-/**
- * Entity to store a JSON data structure.
- */
-@Getter
-@Setter
-@Entity
-@AllArgsConstructor
-@NoArgsConstructor
-@Table(name = "JsonData")
-public class JsonDataEntity {
-
- @Id
- @GeneratedValue(strategy = GenerationType.IDENTITY)
- private Integer id;
-
- @Column
- private String jsonStructure;
-
- public JsonDataEntity(final String jsonStructure) {
- this.jsonStructure = jsonStructure;
- }
-}
diff --git a/cps-ri/src/main/java/org/onap/cps/spi/entities/Module.java b/cps-ri/src/main/java/org/onap/cps/spi/entities/Module.java
deleted file mode 100755
index 7043c73952..0000000000
--- a/cps-ri/src/main/java/org/onap/cps/spi/entities/Module.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Copyright (C) 2020 Nordix Foundation
- * Modifications Copyright (C) 2020 Bell Canada. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.cps.spi.entities;
-
-import java.io.Serializable;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.FetchType;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.JoinColumn;
-import javax.persistence.ManyToOne;
-import javax.persistence.Table;
-import javax.validation.constraints.NotNull;
-import lombok.AllArgsConstructor;
-import lombok.Getter;
-import lombok.NoArgsConstructor;
-import lombok.Setter;
-
-/**
- * Entity to store a yang module.
- */
-@Getter
-@Setter
-@Entity
-@AllArgsConstructor
-@NoArgsConstructor
-@Table(name = "module")
-public class Module implements Serializable {
-
- private static final long serialVersionUID = -748666970938314895L;
-
- @Id
- @GeneratedValue(strategy = GenerationType.IDENTITY)
- private Integer id;
-
- @NotNull
- @Column
- private String moduleContent;
-
- @NotNull
- @Column
- private String revision;
-
- @ManyToOne(fetch = FetchType.LAZY)
- @JoinColumn(name = "dataspace_id", referencedColumnName = "ID")
- private Dataspace dataspace;
-
- @NotNull
- @Column
- private String namespace;
-
- /**
- * Initialize a module entity.
- *
- * @param namespace the module namespace.
- * @param moduleContent the module content.
- * @param revision the revision number of the module.
- * @param dataspace the dataspace related to the module.
- */
- public Module(final String namespace, final String moduleContent, final String revision,
- final Dataspace dataspace) {
- this.namespace = namespace;
- this.moduleContent = moduleContent;
- this.revision = revision;
- this.dataspace = dataspace;
- }
-} \ No newline at end of file
diff --git a/cps-ri/src/main/java/org/onap/cps/spi/entities/SchemaSet.java b/cps-ri/src/main/java/org/onap/cps/spi/entities/SchemaSetEntity.java
index fe67a6089d..9926dfad1a 100644
--- a/cps-ri/src/main/java/org/onap/cps/spi/entities/SchemaSet.java
+++ b/cps-ri/src/main/java/org/onap/cps/spi/entities/SchemaSetEntity.java
@@ -45,7 +45,7 @@ import lombok.Setter;
@NoArgsConstructor
@Entity
@Table(name = "schema_set")
-public class SchemaSet implements Serializable {
+public class SchemaSetEntity implements Serializable {
private static final long serialVersionUID = 6665056955069047269L;
@@ -60,12 +60,12 @@ public class SchemaSet implements Serializable {
@NotNull
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "dataspace_id", referencedColumnName = "ID")
- private Dataspace dataspace;
+ private DataspaceEntity dataspace;
@NotNull
@ManyToMany(fetch = FetchType.LAZY)
@JoinTable(name = "schema_set_yang_resources",
joinColumns = @JoinColumn(name = "schema_set_id"),
inverseJoinColumns = @JoinColumn(name = "yang_resource_id"))
- private Set<YangResource> yangResources;
+ private Set<YangResourceEntity> yangResources;
}
diff --git a/cps-ri/src/main/java/org/onap/cps/spi/entities/YangResource.java b/cps-ri/src/main/java/org/onap/cps/spi/entities/YangResourceEntity.java
index b8a58d098f..4763d68f6a 100644
--- a/cps-ri/src/main/java/org/onap/cps/spi/entities/YangResource.java
+++ b/cps-ri/src/main/java/org/onap/cps/spi/entities/YangResourceEntity.java
@@ -41,7 +41,7 @@ import lombok.Setter;
@NoArgsConstructor
@Entity
@Table(name = "yang_resource")
-public class YangResource implements Serializable {
+public class YangResourceEntity implements Serializable {
private static final long serialVersionUID = -4496883162142106774L;
@@ -62,6 +62,6 @@ public class YangResource implements Serializable {
private String content;
@ManyToMany(mappedBy = "yangResources")
- private Set<SchemaSet> moduleSets;
+ private Set<SchemaSetEntity> schemaSets;
}
diff --git a/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsAdminPersistenceServiceImpl.java b/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsAdminPersistenceServiceImpl.java
index fdb446c849..dfe3ecc119 100644
--- a/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsAdminPersistenceServiceImpl.java
+++ b/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsAdminPersistenceServiceImpl.java
@@ -25,8 +25,8 @@ import java.util.Collection;
import java.util.stream.Collectors;
import org.onap.cps.spi.CpsAdminPersistenceService;
import org.onap.cps.spi.entities.AnchorEntity;
-import org.onap.cps.spi.entities.Dataspace;
-import org.onap.cps.spi.entities.SchemaSet;
+import org.onap.cps.spi.entities.DataspaceEntity;
+import org.onap.cps.spi.entities.SchemaSetEntity;
import org.onap.cps.spi.exceptions.AnchorAlreadyDefinedException;
import org.onap.cps.spi.exceptions.DataspaceAlreadyDefinedException;
import org.onap.cps.spi.model.Anchor;
@@ -52,7 +52,7 @@ public class CpsAdminPersistenceServiceImpl implements CpsAdminPersistenceServic
@Override
public void createDataspace(final String dataspaceName) {
try {
- dataspaceRepository.save(new Dataspace(dataspaceName));
+ dataspaceRepository.save(new DataspaceEntity(dataspaceName));
} catch (final DataIntegrityViolationException e) {
throw new DataspaceAlreadyDefinedException(dataspaceName, e);
}
@@ -60,12 +60,13 @@ public class CpsAdminPersistenceServiceImpl implements CpsAdminPersistenceServic
@Override
public void createAnchor(final String dataspaceName, final String schemaSetName, final String anchorName) {
- final Dataspace dataspace = dataspaceRepository.getByName(dataspaceName);
- final SchemaSet schemaSet = schemaSetRepository.getByDataspaceAndName(dataspace, schemaSetName);
+ final DataspaceEntity dataspaceEntity = dataspaceRepository.getByName(dataspaceName);
+ final SchemaSetEntity schemaSetEntity =
+ schemaSetRepository.getByDataspaceAndName(dataspaceEntity, schemaSetName);
final AnchorEntity anchorEntity = AnchorEntity.builder()
.name(anchorName)
- .dataspace(dataspace)
- .schemaSet(schemaSet)
+ .dataspace(dataspaceEntity)
+ .schemaSet(schemaSetEntity)
.build();
try {
anchorRepository.save(anchorEntity);
@@ -76,8 +77,8 @@ public class CpsAdminPersistenceServiceImpl implements CpsAdminPersistenceServic
@Override
public Collection<Anchor> getAnchors(final String dataspaceName) {
- final Dataspace dataspace = dataspaceRepository.getByName(dataspaceName);
- final Collection<AnchorEntity> anchorEntities = anchorRepository.findAllByDataspace(dataspace);
+ final DataspaceEntity dataspaceEntity = dataspaceRepository.getByName(dataspaceName);
+ final Collection<AnchorEntity> anchorEntities = anchorRepository.findAllByDataspace(dataspaceEntity);
return anchorEntities.stream().map(CpsAdminPersistenceServiceImpl::toAnchor).collect(Collectors.toList());
}
diff --git a/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsModulePersistenceServiceImpl.java b/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsModulePersistenceServiceImpl.java
index 08329309c0..cbc945da60 100644
--- a/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsModulePersistenceServiceImpl.java
+++ b/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsModulePersistenceServiceImpl.java
@@ -29,9 +29,9 @@ import java.util.Set;
import java.util.stream.Collectors;
import javax.transaction.Transactional;
import org.onap.cps.spi.CpsModulePersistenceService;
-import org.onap.cps.spi.entities.Dataspace;
-import org.onap.cps.spi.entities.SchemaSet;
-import org.onap.cps.spi.entities.YangResource;
+import org.onap.cps.spi.entities.DataspaceEntity;
+import org.onap.cps.spi.entities.SchemaSetEntity;
+import org.onap.cps.spi.entities.YangResourceEntity;
import org.onap.cps.spi.exceptions.SchemaSetAlreadyDefinedException;
import org.onap.cps.spi.repository.DataspaceRepository;
import org.onap.cps.spi.repository.SchemaSetRepository;
@@ -58,53 +58,55 @@ public class CpsModulePersistenceServiceImpl implements CpsModulePersistenceServ
public void storeSchemaSet(final String dataspaceName, final String schemaSetName,
final Map<String, String> yangResourcesNameToContentMap) {
- final Dataspace dataspace = dataspaceRepository.getByName(dataspaceName);
- final Set<YangResource> yangResources = synchronizeYangResources(yangResourcesNameToContentMap);
- final SchemaSet schemaSet = new SchemaSet();
- schemaSet.setName(schemaSetName);
- schemaSet.setDataspace(dataspace);
- schemaSet.setYangResources(yangResources);
+ final DataspaceEntity dataspaceEntity = dataspaceRepository.getByName(dataspaceName);
+ final Set<YangResourceEntity> yangResourceEntities = synchronizeYangResources(yangResourcesNameToContentMap);
+ final SchemaSetEntity schemaSetEntity = new SchemaSetEntity();
+ schemaSetEntity.setName(schemaSetName);
+ schemaSetEntity.setDataspace(dataspaceEntity);
+ schemaSetEntity.setYangResources(yangResourceEntities);
try {
- schemaSetRepository.save(schemaSet);
+ schemaSetRepository.save(schemaSetEntity);
} catch (final DataIntegrityViolationException e) {
throw new SchemaSetAlreadyDefinedException(dataspaceName, schemaSetName, e);
}
}
- private Set<YangResource> synchronizeYangResources(final Map<String, String> yangResourcesNameToContentMap) {
- final Map<String, YangResource> checksumToEntityMap = yangResourcesNameToContentMap.entrySet().stream()
+ private Set<YangResourceEntity> synchronizeYangResources(final Map<String, String> yangResourcesNameToContentMap) {
+ final Map<String, YangResourceEntity> checksumToEntityMap = yangResourcesNameToContentMap.entrySet().stream()
.map(entry -> {
- final YangResource yangResource = new YangResource();
- yangResource.setName(entry.getKey());
- yangResource.setContent(entry.getValue());
- yangResource.setChecksum(DigestUtils.md5DigestAsHex(entry.getValue().getBytes(StandardCharsets.UTF_8)));
- return yangResource;
+ final String checksum = DigestUtils.md5DigestAsHex(entry.getValue().getBytes(StandardCharsets.UTF_8));
+ final YangResourceEntity yangResourceEntity = new YangResourceEntity();
+ yangResourceEntity.setName(entry.getKey());
+ yangResourceEntity.setContent(entry.getValue());
+ yangResourceEntity.setChecksum(checksum);
+ return yangResourceEntity;
})
.collect(Collectors.toMap(
- YangResource::getChecksum,
+ YangResourceEntity::getChecksum,
entity -> entity
));
- final List<YangResource> existingYangResources =
+ final List<YangResourceEntity> existingYangResourceEntities =
yangResourceRepository.findAllByChecksumIn(checksumToEntityMap.keySet());
- existingYangResources.forEach(yangFile -> checksumToEntityMap.remove(yangFile.getChecksum()));
+ existingYangResourceEntities.forEach(yangFile -> checksumToEntityMap.remove(yangFile.getChecksum()));
- final Collection<YangResource> newYangResources = checksumToEntityMap.values();
- if (!newYangResources.isEmpty()) {
- yangResourceRepository.saveAll(newYangResources);
+ final Collection<YangResourceEntity> newYangResourceEntities = checksumToEntityMap.values();
+ if (!newYangResourceEntities.isEmpty()) {
+ yangResourceRepository.saveAll(newYangResourceEntities);
}
- return ImmutableSet.<YangResource>builder()
- .addAll(existingYangResources)
- .addAll(newYangResources)
+ return ImmutableSet.<YangResourceEntity>builder()
+ .addAll(existingYangResourceEntities)
+ .addAll(newYangResourceEntities)
.build();
}
@Override
public Map<String, String> getYangSchemaResources(final String dataspaceName, final String schemaSetName) {
- final Dataspace dataspace = dataspaceRepository.getByName(dataspaceName);
- final SchemaSet schemaSet = schemaSetRepository.getByDataspaceAndName(dataspace, schemaSetName);
- return schemaSet.getYangResources().stream().collect(
- Collectors.toMap(YangResource::getName, YangResource::getContent));
+ final DataspaceEntity dataspaceEntity = dataspaceRepository.getByName(dataspaceName);
+ final SchemaSetEntity schemaSetEntity =
+ schemaSetRepository.getByDataspaceAndName(dataspaceEntity, schemaSetName);
+ return schemaSetEntity.getYangResources().stream().collect(
+ Collectors.toMap(YangResourceEntity::getName, YangResourceEntity::getContent));
}
}
diff --git a/cps-ri/src/main/java/org/onap/cps/spi/repository/AnchorRepository.java b/cps-ri/src/main/java/org/onap/cps/spi/repository/AnchorRepository.java
index df665f931c..318b4daa6b 100644
--- a/cps-ri/src/main/java/org/onap/cps/spi/repository/AnchorRepository.java
+++ b/cps-ri/src/main/java/org/onap/cps/spi/repository/AnchorRepository.java
@@ -23,11 +23,12 @@ import java.util.Collection;
import java.util.Optional;
import javax.validation.constraints.NotNull;
import org.onap.cps.spi.entities.AnchorEntity;
-import org.onap.cps.spi.entities.Dataspace;
+import org.onap.cps.spi.entities.DataspaceEntity;
import org.springframework.data.jpa.repository.JpaRepository;
public interface AnchorRepository extends JpaRepository<AnchorEntity, Integer> {
- Optional<AnchorEntity> findByDataspaceAndName(@NotNull Dataspace dataspace, @NotNull String name);
- Collection<AnchorEntity> findAllByDataspace(@NotNull Dataspace dataspace);
+ Optional<AnchorEntity> findByDataspaceAndName(@NotNull DataspaceEntity dataspaceEntity, @NotNull String name);
+
+ Collection<AnchorEntity> findAllByDataspace(@NotNull DataspaceEntity dataspaceEntity);
}
diff --git a/cps-ri/src/main/java/org/onap/cps/spi/repository/DataspaceRepository.java b/cps-ri/src/main/java/org/onap/cps/spi/repository/DataspaceRepository.java
index ce231c9c51..10c6541d0c 100755
--- a/cps-ri/src/main/java/org/onap/cps/spi/repository/DataspaceRepository.java
+++ b/cps-ri/src/main/java/org/onap/cps/spi/repository/DataspaceRepository.java
@@ -21,16 +21,15 @@ package org.onap.cps.spi.repository;
import java.util.Optional;
import javax.validation.constraints.NotNull;
-import org.onap.cps.spi.entities.Dataspace;
+import org.onap.cps.spi.entities.DataspaceEntity;
import org.onap.cps.spi.exceptions.DataspaceNotFoundException;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
@Repository
-public interface DataspaceRepository extends JpaRepository<Dataspace, Integer> {
- Boolean existsByName(String name); //Checks if there are any records by name()
+public interface DataspaceRepository extends JpaRepository<DataspaceEntity, Integer> {
- Optional<Dataspace> findByName(@NotNull String name);
+ Optional<DataspaceEntity> findByName(@NotNull String name);
/**
* Get a dataspace by name.
@@ -39,7 +38,7 @@ public interface DataspaceRepository extends JpaRepository<Dataspace, Integer> {
* @param name the name of the dataspace
* @return the Dataspace found
*/
- default Dataspace getByName(@NotNull final String name) {
+ default DataspaceEntity getByName(@NotNull final String name) {
return findByName(name).orElseThrow(() -> new DataspaceNotFoundException(name));
}
}
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 4521d091df..28585f8761 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
@@ -21,11 +21,11 @@
package org.onap.cps.spi.repository;
-import org.onap.cps.spi.entities.Fragment;
+import org.onap.cps.spi.entities.FragmentEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
@Repository
-public interface FragmentRepository extends JpaRepository<Fragment, Long> {
+public interface FragmentRepository extends JpaRepository<FragmentEntity, Long> {
} \ No newline at end of file
diff --git a/cps-ri/src/main/java/org/onap/cps/spi/repository/ModuleRepository.java b/cps-ri/src/main/java/org/onap/cps/spi/repository/ModuleRepository.java
deleted file mode 100755
index cab7e19300..0000000000
--- a/cps-ri/src/main/java/org/onap/cps/spi/repository/ModuleRepository.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * Copyright (C) 2020 Nordix Foundation
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.cps.spi.repository;
-
-
-import java.util.Optional;
-import javax.validation.constraints.NotNull;
-import org.onap.cps.spi.entities.Dataspace;
-import org.onap.cps.spi.entities.Module;
-import org.onap.cps.spi.exceptions.NotFoundInDataspaceException;
-import org.springframework.data.jpa.repository.JpaRepository;
-import org.springframework.stereotype.Repository;
-
-@Repository
-public interface ModuleRepository extends JpaRepository<Module, Integer> {
-
- Optional<Module> findByDataspaceAndNamespaceAndRevision(@NotNull Dataspace dataspace,
- @NotNull String namespace,
- @NotNull String revision);
-
- /**
- * This method gets a Module by dataspace, namespace and revision.
- *
- * @param dataspace the dataspace
- * @param namespace the namespace
- * @param revision the revision
- * @return the Module
- * @throws NotFoundInDataspaceException if Module not found
- */
- default Module getByDataspaceAndNamespaceAndRevision(@NotNull final Dataspace dataspace,
- @NotNull final String namespace,
- @NotNull final String revision) {
- return findByDataspaceAndNamespaceAndRevision(dataspace, namespace, revision)
- .orElseThrow(() -> new NotFoundInDataspaceException("Validation Error", String.format(
- "Module with dataspace %s, revision %s does not exist in namespace %s.",
- dataspace.getName(), revision, namespace)));
- }
-}
diff --git a/cps-ri/src/main/java/org/onap/cps/spi/repository/SchemaSetRepository.java b/cps-ri/src/main/java/org/onap/cps/spi/repository/SchemaSetRepository.java
index 9b9d70625c..7b56f9323d 100644
--- a/cps-ri/src/main/java/org/onap/cps/spi/repository/SchemaSetRepository.java
+++ b/cps-ri/src/main/java/org/onap/cps/spi/repository/SchemaSetRepository.java
@@ -22,29 +22,31 @@ package org.onap.cps.spi.repository;
import java.util.List;
import java.util.Optional;
import javax.validation.constraints.NotNull;
-import org.onap.cps.spi.entities.Dataspace;
-import org.onap.cps.spi.entities.SchemaSet;
+import org.onap.cps.spi.entities.DataspaceEntity;
+import org.onap.cps.spi.entities.SchemaSetEntity;
import org.onap.cps.spi.exceptions.SchemaSetNotFoundException;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
@Repository
-public interface SchemaSetRepository extends JpaRepository<SchemaSet, Integer> {
+public interface SchemaSetRepository extends JpaRepository<SchemaSetEntity, Integer> {
- List<SchemaSet> findAllByDataspace(@NotNull Dataspace dataspace);
+ List<SchemaSetEntity> findAllByDataspace(@NotNull DataspaceEntity dataspaceEntity);
- Optional<SchemaSet> findByDataspaceAndName(@NotNull Dataspace dataspace, @NotNull String schemaSetName);
+ Optional<SchemaSetEntity> findByDataspaceAndName(@NotNull DataspaceEntity dataspaceEntity,
+ @NotNull String schemaSetName);
/**
* Gets a schema set by dataspace and schema set name.
*
- * @param dataspace dataspace entity
- * @param schemaSetName schema set name
+ * @param dataspaceEntity dataspace entity
+ * @param schemaSetName schema set name
* @return schema set entity
* @throws SchemaSetNotFoundException if SchemaSet not found
*/
- default SchemaSet getByDataspaceAndName(@NotNull final Dataspace dataspace, @NotNull final String schemaSetName) {
- return findByDataspaceAndName(dataspace, schemaSetName)
- .orElseThrow(() -> new SchemaSetNotFoundException(dataspace.getName(), schemaSetName));
+ default SchemaSetEntity getByDataspaceAndName(@NotNull final DataspaceEntity dataspaceEntity,
+ @NotNull final String schemaSetName) {
+ return findByDataspaceAndName(dataspaceEntity, schemaSetName)
+ .orElseThrow(() -> new SchemaSetNotFoundException(dataspaceEntity.getName(), schemaSetName));
}
}
diff --git a/cps-ri/src/main/java/org/onap/cps/spi/repository/YangResourceRepository.java b/cps-ri/src/main/java/org/onap/cps/spi/repository/YangResourceRepository.java
index 47d3ea32cf..8e57f633f1 100644
--- a/cps-ri/src/main/java/org/onap/cps/spi/repository/YangResourceRepository.java
+++ b/cps-ri/src/main/java/org/onap/cps/spi/repository/YangResourceRepository.java
@@ -22,13 +22,13 @@ package org.onap.cps.spi.repository;
import java.util.List;
import java.util.Set;
import javax.validation.constraints.NotNull;
-import org.onap.cps.spi.entities.YangResource;
+import org.onap.cps.spi.entities.YangResourceEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
@Repository
-public interface YangResourceRepository extends JpaRepository<YangResource, Long> {
+public interface YangResourceRepository extends JpaRepository<YangResourceEntity, Long> {
- List<YangResource> findAllByChecksumIn(@NotNull Set<String> checksum);
+ List<YangResourceEntity> findAllByChecksumIn(@NotNull Set<String> checksum);
}
diff --git a/cps-ri/src/test/java/org/onap/cps/spi/impl/CpsAdminPersistenceServiceTest.java b/cps-ri/src/test/java/org/onap/cps/spi/impl/CpsAdminPersistenceServiceTest.java
index e5aac1eea8..02487078d0 100644
--- a/cps-ri/src/test/java/org/onap/cps/spi/impl/CpsAdminPersistenceServiceTest.java
+++ b/cps-ri/src/test/java/org/onap/cps/spi/impl/CpsAdminPersistenceServiceTest.java
@@ -30,7 +30,7 @@ import org.junit.runner.RunWith;
import org.onap.cps.DatabaseTestContainer;
import org.onap.cps.spi.CpsAdminPersistenceService;
import org.onap.cps.spi.entities.AnchorEntity;
-import org.onap.cps.spi.entities.Dataspace;
+import org.onap.cps.spi.entities.DataspaceEntity;
import org.onap.cps.spi.exceptions.AnchorAlreadyDefinedException;
import org.onap.cps.spi.exceptions.DataspaceAlreadyDefinedException;
import org.onap.cps.spi.exceptions.DataspaceNotFoundException;
@@ -83,10 +83,10 @@ public class CpsAdminPersistenceServiceTest {
final String dataspaceName = "DATASPACE-NEW";
cpsAdminPersistenceService.createDataspace(dataspaceName);
- final Dataspace dataspace = dataspaceRepository.findByName(dataspaceName).orElseThrow();
- assertNotNull(dataspace);
- assertNotNull(dataspace.getId());
- assertEquals(dataspaceName, dataspace.getName());
+ final DataspaceEntity dataspaceEntity = dataspaceRepository.findByName(dataspaceName).orElseThrow();
+ assertNotNull(dataspaceEntity);
+ assertNotNull(dataspaceEntity.getId());
+ assertEquals(dataspaceName, dataspaceEntity.getName());
}
@Test(expected = DataspaceAlreadyDefinedException.class)
@@ -101,9 +101,9 @@ public class CpsAdminPersistenceServiceTest {
cpsAdminPersistenceService.createAnchor(DATASPACE_NAME, SCHEMA_SET_NAME2, ANCHOR_NAME_NEW);
// validate anchor persisted
- final Dataspace dataspace = dataspaceRepository.findByName(DATASPACE_NAME).orElseThrow();
+ final DataspaceEntity dataspaceEntity = dataspaceRepository.findByName(DATASPACE_NAME).orElseThrow();
final AnchorEntity anchorEntity =
- anchorRepository.findByDataspaceAndName(dataspace, ANCHOR_NAME_NEW).orElseThrow();
+ anchorRepository.findByDataspaceAndName(dataspaceEntity, ANCHOR_NAME_NEW).orElseThrow();
assertNotNull(anchorEntity.getId());
assertEquals(ANCHOR_NAME_NEW, anchorEntity.getName());
diff --git a/cps-ri/src/test/java/org/onap/cps/spi/impl/CpsModulePersistenceServiceTest.java b/cps-ri/src/test/java/org/onap/cps/spi/impl/CpsModulePersistenceServiceTest.java
index 77c8003a17..e813d26bf5 100644
--- a/cps-ri/src/test/java/org/onap/cps/spi/impl/CpsModulePersistenceServiceTest.java
+++ b/cps-ri/src/test/java/org/onap/cps/spi/impl/CpsModulePersistenceServiceTest.java
@@ -30,9 +30,9 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.onap.cps.DatabaseTestContainer;
import org.onap.cps.spi.CpsModulePersistenceService;
-import org.onap.cps.spi.entities.Dataspace;
-import org.onap.cps.spi.entities.SchemaSet;
-import org.onap.cps.spi.entities.YangResource;
+import org.onap.cps.spi.entities.DataspaceEntity;
+import org.onap.cps.spi.entities.SchemaSetEntity;
+import org.onap.cps.spi.entities.YangResourceEntity;
import org.onap.cps.spi.exceptions.DataspaceNotFoundException;
import org.onap.cps.spi.exceptions.SchemaSetAlreadyDefinedException;
import org.onap.cps.spi.repository.DataspaceRepository;
@@ -124,33 +124,33 @@ public class CpsModulePersistenceServiceTest {
final String expectedYangResourceChecksum) {
// assert the schema set is persisted
- final SchemaSet schemaSet = getSchemaSetFromDatabase(expectedDataspaceName, expectedSchemaSetName);
- assertEquals(expectedDataspaceName, schemaSet.getDataspace().getName());
- assertEquals(expectedSchemaSetName, schemaSet.getName());
+ final SchemaSetEntity schemaSetEntity = getSchemaSetFromDatabase(expectedDataspaceName, expectedSchemaSetName);
+ assertEquals(expectedDataspaceName, schemaSetEntity.getDataspace().getName());
+ assertEquals(expectedSchemaSetName, schemaSetEntity.getName());
// assert the attached yang resource is persisted
- final Set<YangResource> yangResources = schemaSet.getYangResources();
- assertNotNull(yangResources);
- assertEquals(1, yangResources.size());
+ final Set<YangResourceEntity> yangResourceEntities = schemaSetEntity.getYangResources();
+ assertNotNull(yangResourceEntities);
+ assertEquals(1, yangResourceEntities.size());
// assert the attached yang resource content
- final YangResource yangResource = yangResources.iterator().next();
- assertNotNull(yangResource.getId());
+ final YangResourceEntity yangResourceEntity = yangResourceEntities.iterator().next();
+ assertNotNull(yangResourceEntity.getId());
if (expectedYangResourceId != NEW_RESOURCE_ABSTRACT_ID) {
// existing resource with known id
- assertEquals(expectedYangResourceId, yangResource.getId());
+ assertEquals(expectedYangResourceId, yangResourceEntity.getId());
}
- assertEquals(expectedYangResourceName, yangResource.getName());
- assertEquals(expectedYangResourceContent, yangResource.getContent());
- assertEquals(expectedYangResourceChecksum, yangResource.getChecksum());
+ assertEquals(expectedYangResourceName, yangResourceEntity.getName());
+ assertEquals(expectedYangResourceContent, yangResourceEntity.getContent());
+ assertEquals(expectedYangResourceChecksum, yangResourceEntity.getChecksum());
}
private static Map<String, String> toMap(final String key, final String value) {
return ImmutableMap.<String, String>builder().put(key, value).build();
}
- private SchemaSet getSchemaSetFromDatabase(final String dataspaceName, final String schemaSetName) {
- final Dataspace dataspace = dataspaceRepository.findByName(dataspaceName).orElseThrow();
- return schemaSetRepository.findByDataspaceAndName(dataspace, schemaSetName).orElseThrow();
+ private SchemaSetEntity getSchemaSetFromDatabase(final String dataspaceName, final String schemaSetName) {
+ final DataspaceEntity dataspaceEntity = dataspaceRepository.findByName(dataspaceName).orElseThrow();
+ return schemaSetRepository.findByDataspaceAndName(dataspaceEntity, schemaSetName).orElseThrow();
}
}