From b3d4898d9e8452ea0b8d848c048e712d43b8d9a3 Mon Sep 17 00:00:00 2001 From: Michael Lando Date: Sun, 11 Jun 2017 14:22:02 +0300 Subject: [SDC-29] rebase continue work to align source Change-Id: I218f1c5ee23fb2c8314f1c70921d3ad8682c10f4 Signed-off-by: Michael Lando --- .../org/openecomp/sdc/be/dao/api/ActionStatus.java | 2 +- .../be/dao/cassandra/SdcSchemaFilesAccessor.java | 4 +- .../dao/cassandra/SdcSchemaFilesCassandraDao.java | 36 ++++--- .../sdc/be/dao/jsongraph/types/VertexTypeEnum.java | 4 +- .../be/dao/neo4j/GraphPropertiesDictionary.java | 1 + .../sdc/be/resources/data/AttributeData.java | 12 +-- .../be/resources/data/ComponentMetadataData.java | 2 + .../be/resources/data/ESSdcSchemaFilesData.java | 102 ------------------ .../sdc/be/resources/data/SdcSchemaFilesData.java | 114 +++++++++++++++++++++ 9 files changed, 149 insertions(+), 128 deletions(-) delete mode 100644 catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ESSdcSchemaFilesData.java create mode 100644 catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/SdcSchemaFilesData.java (limited to 'catalog-dao/src') diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/ActionStatus.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/ActionStatus.java index acd8563878..ee74a468fc 100644 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/ActionStatus.java +++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/ActionStatus.java @@ -71,7 +71,7 @@ public enum ActionStatus { GROUP_MEMBER_EMPTY, GROUP_TYPE_ALREADY_EXIST, // CSAR - MISSING_CSAR_UUID, CSAR_INVALID, CSAR_INVALID_FORMAT, CSAR_NOT_FOUND, YAML_NOT_FOUND_IN_CSAR, VSP_ALREADY_EXISTS, RESOURCE_LINKED_TO_DIFFERENT_VSP, RESOURCE_FROM_CSAR_NOT_FOUND, AAI_ARTIFACT_GENERATION_FAILED, ASSET_NOT_FOUND_DURING_CSAR_CREATION, ARTIFACT_PAYLOAD_NOT_FOUND_DURING_CSAR_CREATION, + MISSING_CSAR_UUID, CSAR_INVALID, CSAR_INVALID_FORMAT, CSAR_NOT_FOUND, YAML_NOT_FOUND_IN_CSAR, VSP_ALREADY_EXISTS, RESOURCE_LINKED_TO_DIFFERENT_VSP, RESOURCE_FROM_CSAR_NOT_FOUND, AAI_ARTIFACT_GENERATION_FAILED, ASSET_NOT_FOUND_DURING_CSAR_CREATION, ARTIFACT_PAYLOAD_NOT_FOUND_DURING_CSAR_CREATION, TOSCA_SCHEMA_FILES_NOT_FOUND, // Group GROUP_HAS_CYCLIC_DEPENDENCY, GROUP_ALREADY_EXIST, GROUP_TYPE_IS_INVALID, GROUP_MISSING_GROUP_TYPE, GROUP_INVALID_COMPONENT_INSTANCE, GROUP_INVALID_TOSCA_NAME_OF_COMPONENT_INSTANCE, GROUP_IS_MISSING, GROUP_ARTIFACT_ALREADY_ASSOCIATED, GROUP_ARTIFACT_ALREADY_DISSOCIATED, GROUP_PROPERTY_NOT_FOUND, INVALID_VF_MODULE_NAME, INVALID_VF_MODULE_NAME_MODIFICATION, INVALID_VF_MODULE_TYPE, diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/SdcSchemaFilesAccessor.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/SdcSchemaFilesAccessor.java index e6843eab2f..1168bf4edf 100644 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/SdcSchemaFilesAccessor.java +++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/SdcSchemaFilesAccessor.java @@ -1,6 +1,6 @@ package org.openecomp.sdc.be.dao.cassandra; -import org.openecomp.sdc.be.resources.data.ESSdcSchemaFilesData; +import org.openecomp.sdc.be.resources.data.SdcSchemaFilesData; import com.datastax.driver.mapping.Result; import com.datastax.driver.mapping.annotations.Accessor; @@ -10,5 +10,5 @@ import com.datastax.driver.mapping.annotations.Query; @Accessor public interface SdcSchemaFilesAccessor { @Query("SELECT * FROM sdcartifact.sdcschemafiles WHERE SDCRELEASENUM = :sdcreleasenum AND CONFORMANCELEVEL = :conformancelevel") - Result getSpecificSdcSchemaFiles(@Param("sdcreleasenum") String sdcreleasenum, @Param("conformancelevel") String conformancelevel); + Result getSpecificSdcSchemaFiles(@Param("sdcreleasenum") String sdcreleasenum, @Param("conformancelevel") String conformancelevel); } diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/SdcSchemaFilesCassandraDao.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/SdcSchemaFilesCassandraDao.java index 1bb0f05898..d292c1ddeb 100644 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/SdcSchemaFilesCassandraDao.java +++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/SdcSchemaFilesCassandraDao.java @@ -1,13 +1,11 @@ package org.openecomp.sdc.be.dao.cassandra; -import java.util.LinkedList; import java.util.List; import javax.annotation.PostConstruct; import org.apache.commons.lang3.tuple.ImmutablePair; -import org.openecomp.sdc.be.dao.api.ActionStatus; -import org.openecomp.sdc.be.resources.data.ESSdcSchemaFilesData; +import org.openecomp.sdc.be.resources.data.SdcSchemaFilesData; import org.openecomp.sdc.be.resources.data.auditing.AuditingTypesConstants; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -50,33 +48,41 @@ public class SdcSchemaFilesCassandraDao extends CassandraDao { } } - public CassandraOperationStatus saveArtifact(ESSdcSchemaFilesData artifact) { - return client.save(artifact, ESSdcSchemaFilesData.class, manager); + public CassandraOperationStatus saveSchemaFile(SdcSchemaFilesData schemaFileData) { + return client.save(schemaFileData, SdcSchemaFilesData.class, manager); } - public Either getArtifact(String artifactId) { - return client.getById(artifactId, ESSdcSchemaFilesData.class, manager); + public Either getSchemaFile(String schemaFileId) { + return client.getById(schemaFileId, SdcSchemaFilesData.class, manager); } - public CassandraOperationStatus deleteArtifact(String artifactId) { - return client.delete(artifactId, ESSdcSchemaFilesData.class, manager); + public CassandraOperationStatus deleteSchemaFile(String schemaFileId) { + return client.delete(schemaFileId, SdcSchemaFilesData.class, manager); } - public Either, ActionStatus> getSpecificSchemaFiles(String sdcreleasenum, String conformancelevel) { - Result specificSdcSchemaFiles = sdcSchemaFilesAccessor.getSpecificSdcSchemaFiles(sdcreleasenum, conformancelevel); + public Either, CassandraOperationStatus> getSpecificSchemaFiles(String sdcreleasenum, String conformancelevel) { + + Result specificSdcSchemaFiles = null; + try { + specificSdcSchemaFiles = sdcSchemaFilesAccessor.getSpecificSdcSchemaFiles(sdcreleasenum, conformancelevel); + } catch (Exception e) { + logger.debug("getSpecificSchemaFiles failed with exception {}", e); + return Either.right(CassandraOperationStatus.GENERAL_ERROR); + } if(specificSdcSchemaFiles == null) { logger.debug("not found specific SdcSchemaFiles for sdcreleasenum {}, conformancelevel {}", sdcreleasenum, conformancelevel); - return Either.left(new LinkedList()); + return Either.right(CassandraOperationStatus.NOT_FOUND); } + List list = specificSdcSchemaFiles.all(); if(logger.isDebugEnabled()){ - for (ESSdcSchemaFilesData esSdcSchemaFilesData : specificSdcSchemaFiles) { - logger.debug(esSdcSchemaFilesData.toString()); + for (SdcSchemaFilesData esSdcSchemaFilesData : list) { + logger.trace(esSdcSchemaFilesData.toString()); } } - return Either.left(specificSdcSchemaFiles.all()); + return Either.left(list); } /** diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/types/VertexTypeEnum.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/types/VertexTypeEnum.java index c485b238f4..cb9c7207d2 100644 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/types/VertexTypeEnum.java +++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/types/VertexTypeEnum.java @@ -16,7 +16,7 @@ public enum VertexTypeEnum { CAPABILTIES ("capabilities", ListCapabilityDataDefinition.class), CAPABILITIES_PROPERTIES ("capabilities_properties", MapPropertiesDataDefinition.class), REQUIREMENTS ("requirements", ListRequirementDataDefinition.class), - ATTRIBUTES ("attributes", AttributeDataDefinition.class), + ATTRIBUTES ("attributes", PropertyDataDefinition.class), RESOURCE_CATEGORY ("resourceNewCategory", null), RESOURCE_SUBCATEGORY ("resourceSubcategory", null), SERVICE_CATEGORY ("serviceNewCategory", null), @@ -24,7 +24,7 @@ public enum VertexTypeEnum { USER ("user", null), INPUTS ("inputs", PropertyDataDefinition.class), GROUPS ("groups", GroupDataDefinition.class), - INST_ATTRIBUTES ("instAttributes", MapAttributesDataDefinition.class), + INST_ATTRIBUTES ("instAttributes", MapPropertiesDataDefinition.class), INST_PROPERTIES ("instProperties", MapPropertiesDataDefinition.class), INST_INPUTS ("instInputs", MapPropertiesDataDefinition.class), INST_GROUPS ("instGroups", MapGroupsDataDefinition.class), diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/GraphPropertiesDictionary.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/GraphPropertiesDictionary.java index 3ec9d0d3b9..2ff1567928 100644 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/GraphPropertiesDictionary.java +++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/GraphPropertiesDictionary.java @@ -29,6 +29,7 @@ public enum GraphPropertiesDictionary { CONTACT_ID ("contactId", String.class, false, false), VENDOR_NAME ("vendorName", String.class, false, false), VENDOR_RELEASE ("vendorRelease", String.class, false, false), + CONFORMANCE_LEVEL ("conformanceLevel", String.class, false, false), ICON ("icon", String.class, false, false), TAGS ("tags", String.class, false, false), UUID ("uuid", String.class, false, true), diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/AttributeData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/AttributeData.java index 16a8c8be60..a99529d950 100644 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/AttributeData.java +++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/AttributeData.java @@ -27,21 +27,21 @@ import java.util.Map; import org.openecomp.sdc.be.dao.graph.datatype.GraphNode; import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary; import org.openecomp.sdc.be.dao.utils.Constants; -import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition; import org.openecomp.sdc.be.datatypes.elements.SchemaDefinition; import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum; import com.google.gson.reflect.TypeToken; public class AttributeData extends GraphNode { - AttributeDataDefinition attributeDataDefinition; + PropertyDataDefinition attributeDataDefinition; public AttributeData() { super(NodeTypeEnum.Attribute); - attributeDataDefinition = new AttributeDataDefinition(); + attributeDataDefinition = new PropertyDataDefinition(); } - public AttributeData(AttributeDataDefinition attributeDataDefinition) { + public AttributeData(PropertyDataDefinition attributeDataDefinition) { super(NodeTypeEnum.Attribute); this.attributeDataDefinition = attributeDataDefinition; } @@ -56,11 +56,11 @@ public class AttributeData extends GraphNode { return attributeDataDefinition.getUniqueId(); } - public AttributeDataDefinition getAttributeDataDefinition() { + public PropertyDataDefinition getAttributeDataDefinition() { return attributeDataDefinition; } - public void setAttributeDataDefinition(AttributeDataDefinition attributeDataDefinition) { + public void setAttributeDataDefinition(PropertyDataDefinition attributeDataDefinition) { this.attributeDataDefinition = attributeDataDefinition; } diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ComponentMetadataData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ComponentMetadataData.java index 0ad081832f..7e084eb021 100644 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ComponentMetadataData.java +++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ComponentMetadataData.java @@ -51,6 +51,7 @@ public abstract class ComponentMetadataData extends GraphNode { metadataDataDefinition.setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty())); metadataDataDefinition.setCreationDate((Long) properties.get(GraphPropertiesDictionary.CREATION_DATE.getProperty())); metadataDataDefinition.setDescription((String) properties.get(GraphPropertiesDictionary.DESCRIPTION.getProperty())); + metadataDataDefinition.setConformanceLevel((String) properties.get(GraphPropertiesDictionary.CONFORMANCE_LEVEL.getProperty())); metadataDataDefinition.setIcon((String) properties.get(GraphPropertiesDictionary.ICON.getProperty())); metadataDataDefinition.setHighestVersion((Boolean) properties.get(GraphPropertiesDictionary.IS_HIGHEST_VERSION.getProperty())); metadataDataDefinition.setLastUpdateDate((Long) properties.get(GraphPropertiesDictionary.LAST_UPDATE_DATE.getProperty())); @@ -87,6 +88,7 @@ public abstract class ComponentMetadataData extends GraphNode { addIfExists(map, GraphPropertiesDictionary.VERSION, metadataDataDefinition.getVersion()); addIfExists(map, GraphPropertiesDictionary.CREATION_DATE, metadataDataDefinition.getCreationDate()); addIfExists(map, GraphPropertiesDictionary.DESCRIPTION, metadataDataDefinition.getDescription()); + addIfExists(map, GraphPropertiesDictionary.CONFORMANCE_LEVEL, metadataDataDefinition.getConformanceLevel()); addIfExists(map, GraphPropertiesDictionary.ICON, metadataDataDefinition.getIcon()); addIfExists(map, GraphPropertiesDictionary.IS_HIGHEST_VERSION, metadataDataDefinition.isHighestVersion()); addIfExists(map, GraphPropertiesDictionary.LAST_UPDATE_DATE, metadataDataDefinition.getLastUpdateDate()); diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ESSdcSchemaFilesData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ESSdcSchemaFilesData.java deleted file mode 100644 index c6ab13bb3d..0000000000 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ESSdcSchemaFilesData.java +++ /dev/null @@ -1,102 +0,0 @@ -package org.openecomp.sdc.be.resources.data; - -import java.nio.ByteBuffer; -import java.util.Date; - -import com.datastax.driver.mapping.annotations.Column; -import com.datastax.driver.mapping.annotations.Table; - -@Table(keyspace = "sdcartifact", name = "sdcschemafiles") -public class ESSdcSchemaFilesData { - - @Column(name = "sdcreleasenum") - private String sdcReleaseNum; - - @Column(name = "timestamp") - private Date timestamp; - - @Column(name = "conformanceLevel") - private String conformanceLevel; - - @Column(name = "fileName") - private String fileName; - - @Column(name = "payload") - private ByteBuffer payload; - - @Column(name = "checksum") - private String checksum; - - public ESSdcSchemaFilesData() { - - } - - public ESSdcSchemaFilesData(String sdcReleaseNum, String conformanceLevel, String fileName, byte[] payload){ - this.sdcReleaseNum = sdcReleaseNum; - this.conformanceLevel = conformanceLevel; - this.fileName = fileName; - if(payload != null) { - this.payload = ByteBuffer.wrap(payload.clone()); - } - } - - public String getSdcReleaseNum() { - return sdcReleaseNum; - } - - public void setSdcReleaseNum(String sdcReleaseNum) { - this.sdcReleaseNum = sdcReleaseNum; - } - - public String getConformanceLevel() { - return conformanceLevel; - } - - public void setConformanceLevel(String conformanceLevel) { - this.conformanceLevel = conformanceLevel; - } - - public String getFileName() { - return fileName; - } - - public void setFileName(String fileName) { - this.fileName = fileName; - } - - public ByteBuffer getPayload() { - return payload; - } - - public void setPayload(ByteBuffer payload) { - if(payload != null){ - this.payload = payload.duplicate(); - } - } - - public void setPayloadAsArray(byte[] payload) { - if(payload != null){ - this.payload = ByteBuffer.wrap(payload.clone()); - } - } - - public byte[] getPayloadAsArray() { - return payload != null ? payload.array() : null; - } - - public Date getTimestamp() { - return timestamp; - } - - public void setTimestamp(Date timestamp) { - this.timestamp = timestamp; - } - - public String getChecksum() { - return checksum; - } - - public void setChecksum(String checksum) { - this.checksum = checksum; - } -} diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/SdcSchemaFilesData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/SdcSchemaFilesData.java new file mode 100644 index 0000000000..96ab5aedc8 --- /dev/null +++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/SdcSchemaFilesData.java @@ -0,0 +1,114 @@ +package org.openecomp.sdc.be.resources.data; + +import java.nio.ByteBuffer; +import java.util.Date; + +import com.datastax.driver.mapping.annotations.ClusteringColumn; +import com.datastax.driver.mapping.annotations.Column; +import com.datastax.driver.mapping.annotations.PartitionKey; +import com.datastax.driver.mapping.annotations.Table; + +@Table(keyspace = "sdcartifact", name = "sdcschemafiles") +public class SdcSchemaFilesData { + @PartitionKey(0) + @Column(name = "sdcreleasenum") + private String sdcReleaseNum; + + @ClusteringColumn + @Column(name = "timestamp") + private Date timestamp; + + @PartitionKey(1) + @Column(name = "conformanceLevel") + private String conformanceLevel; + + @Column(name = "fileName") + private String fileName; + + @Column(name = "payload") + private ByteBuffer payload; + + @Column(name = "checksum") + private String checksum; + + public SdcSchemaFilesData() { + + } + + public SdcSchemaFilesData(String sdcReleaseNum, Date timestamp, String conformanceLevel, String fileName, byte[] payload, String checksum){ + this.sdcReleaseNum = sdcReleaseNum; + this.timestamp = timestamp; + this.conformanceLevel = conformanceLevel; + this.fileName = fileName; + if(payload != null) { + this.payload = ByteBuffer.wrap(payload.clone()); + } + this.checksum = checksum; + } + + public String getSdcReleaseNum() { + return sdcReleaseNum; + } + + public void setSdcReleaseNum(String sdcReleaseNum) { + this.sdcReleaseNum = sdcReleaseNum; + } + + public String getConformanceLevel() { + return conformanceLevel; + } + + public void setConformanceLevel(String conformanceLevel) { + this.conformanceLevel = conformanceLevel; + } + + public String getFileName() { + return fileName; + } + + public void setFileName(String fileName) { + this.fileName = fileName; + } + + public ByteBuffer getPayload() { + return payload; + } + + public void setPayload(ByteBuffer payload) { + if(payload != null){ + this.payload = payload.duplicate(); + } + } + + public void setPayloadAsArray(byte[] payload) { + if(payload != null){ + this.payload = ByteBuffer.wrap(payload.clone()); + } + } + + public byte[] getPayloadAsArray() { + return payload != null ? payload.array() : null; + } + + public Date getTimestamp() { + return timestamp; + } + + public void setTimestamp(Date timestamp) { + this.timestamp = timestamp; + } + + public String getChecksum() { + return checksum; + } + + public void setChecksum(String checksum) { + this.checksum = checksum; + } + + @Override + public String toString() { + return "SdcSchemaFilesData [sdcReleaseNum=" + sdcReleaseNum + ", timestamp=" + timestamp + ", conformanceLevel=" + + conformanceLevel + ", fileName=" + fileName + ", checksum=" + checksum + "]"; + } +} -- cgit 1.2.3-korg