aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-dao
diff options
context:
space:
mode:
authorvasraz <vasyl.razinkov@est.tech>2021-03-24 14:37:05 +0000
committerChristophe Closset <christophe.closset@intl.att.com>2021-03-24 17:52:46 +0000
commit908c0f0e5a3d1ae44de93b06d61e54869831415e (patch)
tree754e10398f80ac73fb069a40ea3942cc490e441d /catalog-dao
parentc783eb50e01dbdbd478ec73ae9271da0cb49d9c2 (diff)
Reformat catalog-dao
Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech> Issue-ID: SDC-3449 Change-Id: I2180aed0f50e12a62cf6e55fbb4d3d9647e301ac
Diffstat (limited to 'catalog-dao')
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/Account.java2
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/DAOJanusGraphStrategy.java2
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/JanusGraphClientStrategy.java6
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/ActionStatus.java118
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/IElementDAO.java14
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/IUsersDAO.java14
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/ArtifactAccessor.java7
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/ArtifactCassandraDao.java165
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/AuditAccessor.java70
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/AuditCassandraDao.java682
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/CassandraClient.java359
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/CassandraDao.java62
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/CassandraOperationStatus.java8
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/ComponentCacheAccessor.java28
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/FeatureToggleAccessor.java2
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/FeatureToggleDao.java26
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/OperationalEnvironmentDao.java25
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/OperationalEnvironmentsAccessor.java7
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/SdcSchemaFilesAccessor.java11
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/SdcSchemaFilesCassandraDao.java186
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/ITableDescription.java25
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/SdcSchemaBuilder.java687
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/SdcSchemaUtils.java75
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/Table.java44
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/ArtifactTableDescription.java86
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/AuthEventTableDescription.java99
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/CategoryEventTableDescription.java151
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribBaseEventTableDesc.java18
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribDeployEventTableDesc.java64
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribDownloadEventTableDesc.java52
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribEngineEventTableDesc.java42
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribNotifEventTableDesc.java61
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribStatusEventTableDesc.java80
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/EcompOperationalEnvironmentEventTableDesc.java17
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/ExternalApiEventTableDesc.java109
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/FeatureToggleEventTableDesc.java14
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/GetCatHierEventTableDesc.java99
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/GetUebClusterEventTableDesc.java100
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/GetUsersListEventTableDesc.java99
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/MigrationTasksTableDescription.java23
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/OldExternalApiEventTableDesc.java122
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/OperationalEnvironmentsTableDescription.java19
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/ResAdminEventTableDescription.java169
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/SdcSchemaFilesTableDescription.java100
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/UserAccessEventTableDescription.java83
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/UserAdminEventTableDescription.java144
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/config/DAOSpringConfig.java12
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/config/JanusGraphSpringConfig.java14
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/graph/GraphElementFactory.java431
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/graph/datatype/ActionEnum.java9
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/graph/datatype/AdditionalInformationEnum.java9
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/graph/datatype/GraphEdge.java138
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/graph/datatype/GraphElement.java52
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/graph/datatype/GraphElementTypeEnum.java9
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/graph/datatype/GraphNode.java130
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/graph/datatype/GraphRelation.java178
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/graph/datatype/RelationEndPoint.java139
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/HealingPipelineDao.java34
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/heal/HealGraphDao.java8
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/heal/HealJanusGraphDao.java18
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/heal/HealNodeGraphDao.java11
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/heal/HealVertexGraphDao.java10
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/HealingJanusGraphGenericDao.java18
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/JanusGraphClient.java217
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/JanusGraphGenericDao.java3213
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/JanusGraphOperationStatus.java8
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/JanusGraphUtils.java16
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/QueryType.java9
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/transactions/SimpleJanusGraphTransactionManager.java15
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/GraphVertex.java282
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/HealingJanusGraphDao.java17
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/JanusGraphDao.java390
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/heal/Heal.java4
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/heal/HealConstants.java8
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/heal/HealVersion.java1
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/heal/HealVersionBuilder.java2
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/heal/HealVersionImpl.java8
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/types/EdgeLabelEnum.java3
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/types/EdgePropertyEnum.java6
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/types/JsonParseFlagEnum.java9
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/types/VertexTypeEnum.java23
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/utils/IdBuilderUtils.java38
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/utils/JsonParserUtils.java46
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/model/FetchContext.java17
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/GraphEdgeLabels.java114
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/GraphEdgePropertiesDictionary.java72
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/GraphPropertiesDictionary.java273
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/GraphPropertiesDictionaryExtractor.java18
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/utils/CollectionUtils.java41
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/utils/Constants.java22
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/utils/DaoUtils.java75
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/utils/JsonUtil.java211
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/utils/MapUtil.java51
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/utils/TypeMap.java67
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/utils/UserStatusEnum.java27
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/api/ArtifactDataEnum.java10
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/AdditionalInfoParameterData.java231
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/AnnotationTypeData.java26
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ArtifactData.java247
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/AttributeData.java176
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/AttributeValueData.java215
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/CapabilityData.java278
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/CapabilityInstData.java178
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/CapabilityTypeData.java185
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/CategoryData.java143
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ComponentCacheData.java235
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ComponentInstanceData.java215
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ComponentMetadataData.java198
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ConsumerData.java39
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/DAOArtifactData.java115
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/DataTypeData.java135
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/EntryData.java54
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/GraphNodeLock.java100
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/GroupData.java130
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/GroupInstanceData.java170
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/GroupTypeData.java183
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/HeatParameterData.java273
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/HeatParameterValueData.java118
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/InputValueData.java217
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/InputsData.java214
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/InterfaceData.java117
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/MigrationTaskEntry.java11
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/OperationData.java112
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/OperationalEnvironmentEntry.java29
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/PolicyTypeData.java59
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ProductMetadataData.java80
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/PropertyData.java214
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/PropertyValueData.java233
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/RelationshipInstData.java252
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/RelationshipTypeData.java177
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/RequirementData.java236
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/RequirementImplData.java206
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ResourceCategoryData.java75
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ResourceMetadataData.java68
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/SdcSchemaFilesData.java100
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ServiceCategoryData.java37
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ServiceMetadataData.java64
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/TagData.java69
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/UniqueIdData.java35
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/UserData.java408
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/UserFunctionalMenuData.java129
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/AuditingActionEnum.java36
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/AuditingGenericEvent.java21
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/AuditingGetUebClusterEvent.java28
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/AuditingTypesConstants.java9
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/AuthEvent.java33
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/CategoryEvent.java21
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/ConsumerEvent.java21
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/DistributionDeployEvent.java24
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/DistributionDownloadEvent.java22
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/DistributionEngineEvent.java32
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/DistributionNotificationEvent.java45
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/DistributionStatusEvent.java32
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/EcompOperationalEnvironmentEvent.java22
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/ExternalApiEvent.java70
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/GetCategoryHierarchyEvent.java23
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/GetUsersListEvent.java21
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/ResourceAdminEvent.java51
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/UserAccessEvent.java22
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/UserAdminEvent.java23
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/model/CommonAuditData.java27
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/model/DistributionData.java5
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/model/DistributionTopicData.java15
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/model/OperationalEnvAuditData.java19
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/model/ResourceCommonInfo.java5
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/model/ResourceVersionInfo.java13
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/category/CategoryData.java119
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/category/GroupingData.java74
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/category/SubCategoryData.java105
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/togglz/FeatureToggleEvent.java23
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/exception/DeleteDeployedException.java22
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/resources/exception/InitializationException.java12
172 files changed, 8617 insertions, 10073 deletions
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/Account.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/Account.java
index 6a1e495d51..c32efaea5e 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/Account.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/Account.java
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao;
import com.datastax.driver.mapping.annotations.PartitionKey;
@@ -39,5 +38,4 @@ public class Account {
@PartitionKey
private String email;
private String name;
-
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/DAOJanusGraphStrategy.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/DAOJanusGraphStrategy.java
index 1f7d6b9c7b..ed7a5cd496 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/DAOJanusGraphStrategy.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/DAOJanusGraphStrategy.java
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao;
import org.openecomp.sdc.be.config.ConfigurationManager;
@@ -28,5 +27,4 @@ public class DAOJanusGraphStrategy implements JanusGraphClientStrategy {
public String getConfigFile() {
return ConfigurationManager.getConfigurationManager().getConfiguration().getJanusGraphCfgFile();
}
-
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/JanusGraphClientStrategy.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/JanusGraphClientStrategy.java
index 14e12e9b04..5d7f37340d 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/JanusGraphClientStrategy.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/JanusGraphClientStrategy.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,11 +17,9 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao;
public interface JanusGraphClientStrategy {
String getConfigFile();
-
}
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 ea38b93730..4b2bee920c 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
@@ -18,22 +18,18 @@
* ============LICENSE_END=========================================================
* Modifications copyright (c) 2020 Nokia
*/
-
package org.openecomp.sdc.be.dao.api;
public enum ActionStatus {
- OK, ACCEPTED, CREATED, NO_CONTENT, GENERAL_ERROR, NOT_ALLOWED, MISSING_INFORMATION, RESTRICTED_OPERATION,
- RESTRICTED_ACCESS, INVALID_CONTENT, INVALID_PROPERTY_VALUES,
+ OK, ACCEPTED, CREATED, NO_CONTENT, GENERAL_ERROR, NOT_ALLOWED, MISSING_INFORMATION, RESTRICTED_OPERATION, RESTRICTED_ACCESS, INVALID_CONTENT, INVALID_PROPERTY_VALUES,
// User related
USER_ALREADY_EXIST, USER_INACTIVE, USER_NOT_FOUND, USER_HAS_ACTIVE_ELEMENTS, INVALID_EMAIL_ADDRESS, INVALID_ROLE, DELETE_USER_ADMIN_CONFLICT, UPDATE_USER_ADMIN_CONFLICT, CANNOT_DELETE_USER_WITH_ACTIVE_ELEMENTS, CANNOT_UPDATE_USER_WITH_ACTIVE_ELEMENTS, INVALID_USER_ID, USER_DEFINED,
// CapabilityType related
- CAPABILITY_TYPE_ALREADY_EXIST, MISSING_CAPABILITY_TYPE, MISSING_CAPABILITIES, REQ_CAP_NOT_SATISFIED_BEFORE_CERTIFICATION, IMPORT_DUPLICATE_REQ_CAP_NAME, IMPORT_REQ_CAP_NAME_EXISTS_IN_DERIVED,
- CAPABILITY_OF_INSTANCE_NOT_FOUND_ON_CONTAINER, REQUIREMENT_OF_INSTANCE_NOT_FOUND_ON_CONTAINER, RELATION_NOT_FOUND,
+ CAPABILITY_TYPE_ALREADY_EXIST, MISSING_CAPABILITY_TYPE, MISSING_CAPABILITIES, REQ_CAP_NOT_SATISFIED_BEFORE_CERTIFICATION, IMPORT_DUPLICATE_REQ_CAP_NAME, IMPORT_REQ_CAP_NAME_EXISTS_IN_DERIVED, CAPABILITY_OF_INSTANCE_NOT_FOUND_ON_CONTAINER, REQUIREMENT_OF_INSTANCE_NOT_FOUND_ON_CONTAINER, RELATION_NOT_FOUND,
// Resource related
RESOURCE_NOT_FOUND, MISSING_DERIVED_FROM_TEMPLATE, PARENT_RESOURCE_NOT_FOUND, PARENT_RESOURCE_DOES_NOT_EXTEND, INVALID_DEFAULT_VALUE, INVALID_COMPLEX_DEFAULT_VALUE, MULTIPLE_PARENT_RESOURCE_FOUND, INVALID_RESOURCE_PAYLOAD, INVALID_TOSCA_FILE_EXTENSION, INVALID_YAML_FILE, INVALID_TOSCA_TEMPLATE, NOT_RESOURCE_TOSCA_TEMPLATE, NOT_SINGLE_RESOURCE, INVALID_RESOURCE_NAMESPACE, RESOURCE_ALREADY_EXISTS, INVALID_RESOURCE_CHECKSUM, RESOURCE_CANNOT_CONTAIN_RESOURCE_INSTANCES, NO_ASSETS_FOUND, GENERIC_TYPE_NOT_FOUND, INVALID_RESOURCE_TYPE, TOSCA_PARSE_ERROR, INVALID_PM_DICTIONARY_FILE,
// Service related
- SERVICE_TYPE_EXCEEDS_LIMIT, INVALID_SERVICE_TYPE, SERVICE_ROLE_EXCEEDS_LIMIT, INVALID_SERVICE_ROLE, INVALID_INSTANTIATION_TYPE, NOT_SERVICE_TOSCA_TEMPLATE,NOT_SINGLE_SERVICE,INVALID_SERVICE_CHECKSUM,INVALID_SERVICE_PAYLOAD,INVALID_SERVICE_NAMESPACE,SERVICE_ALREADY_EXISTS,
- UNSUPPORTED_DISTRIBUTION_STATUS, INVALID_NAMING_POLICY, INVALID_ENVIRONMENT_CONTEXT, NAMING_POLICY_EXCEEDS_LIMIT, MISSING_ECOMP_GENERATED_NAMING, PROPERTY_EXCEEDS_LIMIT, INVALID_PROPERY,
+ SERVICE_TYPE_EXCEEDS_LIMIT, INVALID_SERVICE_TYPE, SERVICE_ROLE_EXCEEDS_LIMIT, INVALID_SERVICE_ROLE, INVALID_INSTANTIATION_TYPE, NOT_SERVICE_TOSCA_TEMPLATE, NOT_SINGLE_SERVICE, INVALID_SERVICE_CHECKSUM, INVALID_SERVICE_PAYLOAD, INVALID_SERVICE_NAMESPACE, SERVICE_ALREADY_EXISTS, UNSUPPORTED_DISTRIBUTION_STATUS, INVALID_NAMING_POLICY, INVALID_ENVIRONMENT_CONTEXT, NAMING_POLICY_EXCEEDS_LIMIT, MISSING_ECOMP_GENERATED_NAMING, PROPERTY_EXCEEDS_LIMIT, INVALID_PROPERY,
// Component name related
COMPONENT_NAME_ALREADY_EXIST, COMPONENT_NAME_EXCEEDS_LIMIT, MISSING_COMPONENT_NAME, INVALID_COMPONENT_NAME,
// Component description related
@@ -64,130 +60,56 @@ public enum ActionStatus {
UNKNOWN_HOST, AUTHENTICATION_ERROR, CONNNECTION_ERROR, OBJECT_NOT_FOUND, INVALID_RESPONSE_FROM_PROXY,
// auth
AUTH_FAILED_INVALIDE_HEADER, AUTH_FAILED, AUTH_REQUIRED, CONSUMER_ALREADY_EXISTS, INVALID_LENGTH, ECOMP_USER_NOT_FOUND, INVALID_CONTENT_PARAM, INVALID_FILTER_KEY, SERVICE_DEPLOYMENT_ARTIFACT_NOT_FOUND, VALIDATED_RESOURCE_NOT_FOUND, FOUND_ALREADY_VALIDATED_RESOURCE, FOUND_LIST_VALIDATED_RESOURCES,
-
// product
PRODUCT_NOT_FOUND, INVALID_GROUP_ASSOCIATION, EMPTY_PRODUCT_CONTACTS_LIST, INVALID_PRODUCT_CONTACT, MISSING_ONE_OF_COMPONENT_NAMES, COMPONENT_PARAMETER_CANNOT_BE_CHANGED,
-
// occurrences
EMPTY_OCCURRENCES_LIST, INVALID_OCCURRENCES, NOT_TOPOLOGY_TOSCA_TEMPLATE, INVALID_NODE_TEMPLATE,
-
// Data type related
DATA_TYPE_ALREADY_EXIST, DATA_TYPE_NOR_PROPERTIES_NEITHER_DERIVED_FROM, DATA_TYPE_PROPERTIES_CANNOT_BE_EMPTY, DATA_TYPE_DERIVED_IS_MISSING, DATA_TYPE_PROPERTY_ALREADY_DEFINED_IN_ANCESTOR, DATA_TYPE_DUPLICATE_PROPERTY, DATA_TYPE_PROEPRTY_CANNOT_HAVE_SAME_TYPE_OF_DATA_TYPE, DATA_TYPE_CANNOT_HAVE_PROPERTIES, DATA_TYPE_CANNOT_BE_EMPTY, DATA_TYPE_CANNOT_BE_UPDATED_BAD_REQUEST,
-
// Policy Type related
TARGETS_EMPTY, TARGETS_NON_VALID, POLICY_TYPE_ALREADY_EXIST,
-
// Group Type related
GROUP_MEMBER_EMPTY, GROUP_TYPE_ALREADY_EXIST, GROUP_TYPE_ILLEGAL_PER_COMPONENT,
-
// Annotation Type related
ANNOTATION_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, TOSCA_SCHEMA_FILES_NOT_FOUND, ARTIFACT_NAME_INVALID, ARTIFACT_PAYLOAD_EMPTY,ERROR_DURING_CSAR_CREATION,SERVICE_LINKED_TO_DIFFERENT_VSP,
-
+ 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, ARTIFACT_NAME_INVALID, ARTIFACT_PAYLOAD_EMPTY, ERROR_DURING_CSAR_CREATION, SERVICE_LINKED_TO_DIFFERENT_VSP,
// 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,
-
// Group instance
- GROUP_INSTANCE_NOT_FOUND_ON_COMPONENT_INSTANCE, INVALID_GROUP_MIN_MAX_INSTANCES_PROPERTY_VALUE, INVALID_GROUP_INITIAL_COUNT_PROPERTY_VALUE, INVALID_GROUP_PROPERTY_VALUE_LOWER_HIGHER,
-
- ARTIFACT_NOT_FOUND_IN_CSAR, ARTIFACT_ALREADY_EXIST_IN_DIFFERENT_TYPE_IN_CSAR, FAILED_RETRIVE_ARTIFACTS_TYPES, ARTIFACT_ALRADY_EXIST_IN_MASTER_IN_CSAR, ARTIFACT_NOT_VALID_IN_MASTER, ARTIFACT_NOT_VALID_ENV,
-
+ GROUP_INSTANCE_NOT_FOUND_ON_COMPONENT_INSTANCE, INVALID_GROUP_MIN_MAX_INSTANCES_PROPERTY_VALUE, INVALID_GROUP_INITIAL_COUNT_PROPERTY_VALUE, INVALID_GROUP_PROPERTY_VALUE_LOWER_HIGHER, ARTIFACT_NOT_FOUND_IN_CSAR, ARTIFACT_ALREADY_EXIST_IN_DIFFERENT_TYPE_IN_CSAR, FAILED_RETRIVE_ARTIFACTS_TYPES, ARTIFACT_ALRADY_EXIST_IN_MASTER_IN_CSAR, ARTIFACT_NOT_VALID_IN_MASTER, ARTIFACT_NOT_VALID_ENV,
// cache
CONVERT_COMPONENT_ERROR, COMPONENT_NOT_FOUND,
-
// Inputs
- INPUT_IS_NOT_CHILD_OF_COMPONENT,
- CFVC_LOOP_DETECTED,
- INPUT_ALREADY_EXIST,
-
+ INPUT_IS_NOT_CHILD_OF_COMPONENT, CFVC_LOOP_DETECTED, INPUT_ALREADY_EXIST,
// Outputs
- OUTPUT_IS_NOT_CHILD_OF_COMPONENT,
- OUTPUT_ALREADY_EXIST,
-
+ OUTPUT_IS_NOT_CHILD_OF_COMPONENT, OUTPUT_ALREADY_EXIST,
//Forwarding Path related
- FORWARDING_PATH_NAME_MAXIMUM_LENGTH, FORWARDING_PATH_NAME_ALREADY_IN_USE, FORWARDING_PATH_NAME_EMPTY,
- FORWARDING_PATH_PROTOCOL_MAXIMUM_LENGTH, FORWARDING_PATH_DESTINATION_PORT_MAXIMUM_LENGTH,
- MISSING_OLD_COMPONENT_INSTANCE, MISSING_NEW_COMPONENT_INSTANCE,
+ FORWARDING_PATH_NAME_MAXIMUM_LENGTH, FORWARDING_PATH_NAME_ALREADY_IN_USE, FORWARDING_PATH_NAME_EMPTY, FORWARDING_PATH_PROTOCOL_MAXIMUM_LENGTH, FORWARDING_PATH_DESTINATION_PORT_MAXIMUM_LENGTH, MISSING_OLD_COMPONENT_INSTANCE, MISSING_NEW_COMPONENT_INSTANCE,
//policies
- RESOURCE_CANNOT_CONTAIN_POLICIES,
- POLICY_NOT_FOUND_ON_CONTAINER,
- INVALID_POLICY_NAME,
- POLICY_NAME_ALREADY_EXIST, EXCLUDED_POLICY_TYPE, POLICY_MISSING_POLICY_TYPE, POLICY_TYPE_IS_INVALID,
-
+ RESOURCE_CANNOT_CONTAIN_POLICIES, POLICY_NOT_FOUND_ON_CONTAINER, INVALID_POLICY_NAME, POLICY_NAME_ALREADY_EXIST, EXCLUDED_POLICY_TYPE, POLICY_MISSING_POLICY_TYPE, POLICY_TYPE_IS_INVALID,
//External References Statuses
- EXT_REF_ALREADY_EXIST,
- EXT_REF_NOT_FOUND,
-
- POLICY_TARGET_DOES_NOT_EXIST, POLICY_TARGET_TYPE_DOES_NOT_EXIST, INPUTS_NOT_FOUND,
- RESOURCE_LIFECYCLE_STATE_NOT_VALID,
- COMPONENT_IS_ARCHIVED,
+ EXT_REF_ALREADY_EXIST, EXT_REF_NOT_FOUND, POLICY_TARGET_DOES_NOT_EXIST, POLICY_TARGET_TYPE_DOES_NOT_EXIST, INPUTS_NOT_FOUND, RESOURCE_LIFECYCLE_STATE_NOT_VALID, COMPONENT_IS_ARCHIVED,
//Automated upgrade
- COMPONENT_IS_NOT_HIHGEST_CERTIFIED,
- NO_INSTANCES_TO_UPGRADE,
- ARCHIVED_ORIGINS_FOUND,
- UPDATE_CATALOG_FAILED,
-
+ COMPONENT_IS_NOT_HIHGEST_CERTIFIED, NO_INSTANCES_TO_UPGRADE, ARCHIVED_ORIGINS_FOUND, UPDATE_CATALOG_FAILED,
//Interface
- INTERFACE_NOT_FOUND_IN_COMPONENT,
- INTERFACE_UNKNOWN,
-
+ INTERFACE_NOT_FOUND_IN_COMPONENT, INTERFACE_UNKNOWN,
//InterfaceOperation
- INTERFACE_OPERATION_NOT_FOUND, INTERFACE_OPERATION_NAME_ALREADY_IN_USE, INTERFACE_OPERATION_NAME_MANDATORY,
- INTERFACE_OPERATION_NAME_INVALID, INTERFACE_OPERATION_INPUT_NAME_ALREADY_IN_USE,
- INTERFACE_OPERATION_OUTPUT_NAME_ALREADY_IN_USE, INTERFACE_OPERATION_NOT_DELETED,
- INTERFACE_OPERATION_MAPPED_OUTPUT_MODIFIED, INTERFACE_OPERATION_DELETE_WITH_MAPPED_OUTPUT,
- INTERFACE_OPERATION_INPUT_NAME_MANDATORY, INTERFACE_OPERATION_OUTPUT_NAME_MANDATORY,
- INTERFACE_OPERATION_INPUT_PROPERTY_NOT_FOUND_IN_COMPONENT, INTERFACE_OPERATION_INVALID_FOR_LOCAL_TYPE,
- INTERFACE_OPERATION_INVALID_FOR_GLOBAL_TYPE,
- INTERFACE_OPERATION_NOT_DEFINED,
- PROPERTY_USED_BY_OPERATION, DECLARED_INPUT_USED_BY_OPERATION,
-
- INVALID_CONSUMPTION_TYPE,
+ INTERFACE_OPERATION_NOT_FOUND, INTERFACE_OPERATION_NAME_ALREADY_IN_USE, INTERFACE_OPERATION_NAME_MANDATORY, INTERFACE_OPERATION_NAME_INVALID, INTERFACE_OPERATION_INPUT_NAME_ALREADY_IN_USE, INTERFACE_OPERATION_OUTPUT_NAME_ALREADY_IN_USE, INTERFACE_OPERATION_NOT_DELETED, INTERFACE_OPERATION_MAPPED_OUTPUT_MODIFIED, INTERFACE_OPERATION_DELETE_WITH_MAPPED_OUTPUT, INTERFACE_OPERATION_INPUT_NAME_MANDATORY, INTERFACE_OPERATION_OUTPUT_NAME_MANDATORY, INTERFACE_OPERATION_INPUT_PROPERTY_NOT_FOUND_IN_COMPONENT, INTERFACE_OPERATION_INVALID_FOR_LOCAL_TYPE, INTERFACE_OPERATION_INVALID_FOR_GLOBAL_TYPE, INTERFACE_OPERATION_NOT_DEFINED, PROPERTY_USED_BY_OPERATION, DECLARED_INPUT_USED_BY_OPERATION, INVALID_CONSUMPTION_TYPE,
//NodeFilter
- NODE_FILTER_NOT_FOUND,
- UNSUPPORTED_VALUE_PROVIDED,
- SELECTED_PROPERTY_NOT_PRESENT,
- MAPPED_PROPERTY_NOT_FOUND,
- UNSUPPORTED_OPERATOR_PROVIDED,
- CONSTRAINT_FORMAT_INCORRECT,
- SOURCE_TARGET_PROPERTY_TYPE_MISMATCH,
- SOURCE_TARGET_SCHEMA_MISMATCH,
- UNSUPPORTED_PROPERTY_TYPE,
+ NODE_FILTER_NOT_FOUND, UNSUPPORTED_VALUE_PROVIDED, SELECTED_PROPERTY_NOT_PRESENT, MAPPED_PROPERTY_NOT_FOUND, UNSUPPORTED_OPERATOR_PROVIDED, CONSTRAINT_FORMAT_INCORRECT, SOURCE_TARGET_PROPERTY_TYPE_MISMATCH, SOURCE_TARGET_SCHEMA_MISMATCH, UNSUPPORTED_PROPERTY_TYPE,
//Filter
- SUBSTITUTION_FILTER_NOT_FOUND,
- FILTER_NOT_FOUND,
-
-
+ SUBSTITUTION_FILTER_NOT_FOUND, FILTER_NOT_FOUND,
//InterfaceLifeCycleType
- INTERFACE_LIFECYCLE_TYPES_NOT_FOUND,
-
- INVALID_PROPERTY_NAME,
- INVALID_INPUT_NAME,
-
+ INTERFACE_LIFECYCLE_TYPES_NOT_FOUND, INVALID_PROPERTY_NAME, INVALID_INPUT_NAME,
//Property Constraints
INVALID_PROPERTY_CONSTRAINTS, INVALID_PROPERTY_CONSTRAINTS_FORMAT, CANNOT_DELETE_VALID_VALUES,
-
//Container
- CONTAINER_CANNOT_CONTAIN_COMPONENT_IN_STATE,
- CONTAINER_CANNOT_CONTAIN_INSTANCE,
- MISSING_MANDATORY_PROPERTY,
- MANDATORY_PROPERTY_MISSING_VALUE,
-
+ CONTAINER_CANNOT_CONTAIN_COMPONENT_IN_STATE, CONTAINER_CANNOT_CONTAIN_INSTANCE, MISSING_MANDATORY_PROPERTY, MANDATORY_PROPERTY_MISSING_VALUE,
//Capability related
- CAPABILITY_NOT_FOUND, CAPABILITY_NAME_MANDATORY, CAPABILITY_TYPE_MANDATORY,CAPABILITY_NAME_ALREADY_IN_USE,
- MAX_OCCURRENCES_SHOULD_BE_GREATER_THAN_MIN_OCCURRENCES, CAPABILITY_DELETION_NOT_ALLOWED_USED_IN_COMPOSITION,
- CAPABILITY_UPDATE_NOT_ALLOWED_USED_IN_COMPOSITION,INVALID_CAPABILITY_NAME,
- FAILED_TO_CREATE_OR_UPDATE_CAPABILITY_PROPERTIES, CAPABILITY_PROPERTIES_NOT_FOUND,
-
- RELATIONSHIP_TYPE_ALREADY_EXIST, MISSING_RELATIONSHIP_TYPE, CAPABILITY_TYPE_CANNOT_BE_EMPTY,
-
-
+ CAPABILITY_NOT_FOUND, CAPABILITY_NAME_MANDATORY, CAPABILITY_TYPE_MANDATORY, CAPABILITY_NAME_ALREADY_IN_USE, MAX_OCCURRENCES_SHOULD_BE_GREATER_THAN_MIN_OCCURRENCES, CAPABILITY_DELETION_NOT_ALLOWED_USED_IN_COMPOSITION, CAPABILITY_UPDATE_NOT_ALLOWED_USED_IN_COMPOSITION, INVALID_CAPABILITY_NAME, FAILED_TO_CREATE_OR_UPDATE_CAPABILITY_PROPERTIES, CAPABILITY_PROPERTIES_NOT_FOUND, RELATIONSHIP_TYPE_ALREADY_EXIST, MISSING_RELATIONSHIP_TYPE, CAPABILITY_TYPE_CANNOT_BE_EMPTY,
//Requirement related
- REQUIREMENT_NOT_FOUND, REQUIREMENT_NAME_MANDATORY, REQUIREMENT_CAPABILITY_MANDATORY,REQUIREMENT_NAME_ALREADY_IN_USE,
- REQUIREMENT_DELETION_NOT_ALLOWED_USED_IN_COMPOSITION, REQUIREMENT_UPDATE_NOT_ALLOWED_USED_IN_COMPOSITION, INVALID_REQUIREMENT_NAME,
-
+ REQUIREMENT_NOT_FOUND, REQUIREMENT_NAME_MANDATORY, REQUIREMENT_CAPABILITY_MANDATORY, REQUIREMENT_NAME_ALREADY_IN_USE, REQUIREMENT_DELETION_NOT_ALLOWED_USED_IN_COMPOSITION, REQUIREMENT_UPDATE_NOT_ALLOWED_USED_IN_COMPOSITION, INVALID_REQUIREMENT_NAME,
//Abstract template related
ABSTRACT, NORMAL
- }
+}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/IElementDAO.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/IElementDAO.java
index a5e643b761..14a3b4ac63 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/IElementDAO.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/IElementDAO.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,19 +17,17 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.api;
import fj.data.Either;
-import org.openecomp.sdc.be.dao.graph.datatype.GraphElement;
-
import java.util.List;
+import org.openecomp.sdc.be.dao.graph.datatype.GraphElement;
public interface IElementDAO {
- public Either<List<GraphElement>, ActionStatus> getAllCategories();
+ public Either<List<GraphElement>, ActionStatus> getAllCategories();
- public Either<List<GraphElement>, ActionStatus> getAllTags();
+ public Either<List<GraphElement>, ActionStatus> getAllTags();
- public Either<GraphElement, ActionStatus> getCategory(String name);
+ public Either<GraphElement, ActionStatus> getCategory(String name);
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/IUsersDAO.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/IUsersDAO.java
index cbf844c5f7..34f3fab408 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/IUsersDAO.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/IUsersDAO.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.api;
import fj.data.Either;
@@ -25,12 +24,11 @@ import org.openecomp.sdc.be.resources.data.UserData;
public interface IUsersDAO {
- Either<UserData, ActionStatus> getUserData(String id);
-
- ActionStatus saveUserData(UserData userData);
+ Either<UserData, ActionStatus> getUserData(String id);
- ActionStatus updateUserData(UserData userData);
+ ActionStatus saveUserData(UserData userData);
- ActionStatus deleteUserData(String id);
+ ActionStatus updateUserData(UserData userData);
+ ActionStatus deleteUserData(String id);
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/ArtifactAccessor.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/ArtifactAccessor.java
index 4422e77a13..cc5b544d86 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/ArtifactAccessor.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/ArtifactAccessor.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.cassandra;
import com.datastax.driver.core.ResultSet;
@@ -25,12 +24,12 @@ import com.datastax.driver.mapping.annotations.Accessor;
import com.datastax.driver.mapping.annotations.Param;
import com.datastax.driver.mapping.annotations.Query;
-
/**
* Created by chaya on 7/5/2017.
*/
@Accessor
public interface ArtifactAccessor {
+
// ***** get the number of artifacts with a specific id
@Query("SELECT COUNT(*) FROM sdcartifact.resources WHERE ID = :uniqueId")
ResultSet getNumOfArtifactsById(@Param("uniqueId") String uniqueId);
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/ArtifactCassandraDao.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/ArtifactCassandraDao.java
index c5b48d9a2c..81586a09ab 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/ArtifactCassandraDao.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/ArtifactCassandraDao.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,13 +17,13 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.cassandra;
import com.datastax.driver.core.ResultSet;
import com.datastax.driver.core.Session;
import com.datastax.driver.mapping.MappingManager;
import fj.data.Either;
+import javax.annotation.PostConstruct;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.openecomp.sdc.be.resources.data.DAOArtifactData;
import org.openecomp.sdc.be.resources.data.auditing.AuditingTypesConstants;
@@ -31,91 +31,82 @@ import org.openecomp.sdc.common.log.wrappers.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
-import javax.annotation.PostConstruct;
-
@Component("artifact-cassandra-dao")
public class ArtifactCassandraDao extends CassandraDao {
- private static Logger logger = Logger.getLogger(ArtifactCassandraDao.class.getName());
- private ArtifactAccessor artifactAccessor;
-
-
- @Autowired
- public ArtifactCassandraDao(CassandraClient cassandraClient) {
- super(cassandraClient);
-
- }
-
- @PostConstruct
- public void init() {
- String keyspace = AuditingTypesConstants.ARTIFACT_KEYSPACE;
- if (client.isConnected()) {
- Either<ImmutablePair<Session, MappingManager>, CassandraOperationStatus> result = client.connect(keyspace);
- if (result.isLeft()) {
- session = result.left().value().left;
- manager = result.left().value().right;
- artifactAccessor = manager.createAccessor(ArtifactAccessor.class);
- logger.info("** ArtifactCassandraDao created");
- } else {
- logger.info("** ArtifactCassandraDao failed");
- throw new RuntimeException("Artifact keyspace [" + keyspace + "] failed to connect with error : "
- + result.right().value());
- }
- } else {
- logger.info("** Cassandra client isn't connected");
- logger.info("** ArtifactCassandraDao created, but not connected");
- }
- }
-
- public CassandraOperationStatus saveArtifact(DAOArtifactData artifact) {
- return client.save(artifact, DAOArtifactData.class, manager);
- }
-
- public Either<DAOArtifactData, CassandraOperationStatus> getArtifact(String artifactId) {
- return client.getById(artifactId, DAOArtifactData.class, manager);
- }
-
- public CassandraOperationStatus deleteArtifact(String artifactId) {
- return client.delete(artifactId, DAOArtifactData.class, manager);
- }
-
- /**
- * ---------for use in JUnit only--------------- the method deletes all the
- * tables in the audit keyspace
- *
- * @return the status of the last failed operation or ok if all the deletes
- * were successful
- */
- public CassandraOperationStatus deleteAllArtifacts() {
- logger.info("cleaning all artifacts.");
- String query = "truncate sdcartifact.resources;";
- try {
- session.execute(query);
- } catch (Exception e) {
- logger.debug("Failed to clean artifacts", e);
- return CassandraOperationStatus.GENERAL_ERROR;
- }
- logger.info("cleaning all artifacts finished successfully.");
- return CassandraOperationStatus.OK;
- }
-
- /**
- * the method checks if the given table is empty in the artifact keyspace
- *
- * @param tableName
- * the name of the table we want to check
- * @return true if the table is empty
- */
- public Either<Boolean, CassandraOperationStatus> isTableEmpty(String tableName) {
- return super.isTableEmpty(tableName);
- }
-
- public Either<Long, CassandraOperationStatus> getCountOfArtifactById(String uniqeId) {
- ResultSet artifactCount = artifactAccessor.getNumOfArtifactsById(uniqeId);
- if (artifactCount == null) {
- return Either.right(CassandraOperationStatus.NOT_FOUND);
- }
- return Either.left(artifactCount.one().getLong(0));
- }
-
+ private static Logger logger = Logger.getLogger(ArtifactCassandraDao.class.getName());
+ private ArtifactAccessor artifactAccessor;
+
+ @Autowired
+ public ArtifactCassandraDao(CassandraClient cassandraClient) {
+ super(cassandraClient);
+ }
+
+ @PostConstruct
+ public void init() {
+ String keyspace = AuditingTypesConstants.ARTIFACT_KEYSPACE;
+ if (client.isConnected()) {
+ Either<ImmutablePair<Session, MappingManager>, CassandraOperationStatus> result = client.connect(keyspace);
+ if (result.isLeft()) {
+ session = result.left().value().left;
+ manager = result.left().value().right;
+ artifactAccessor = manager.createAccessor(ArtifactAccessor.class);
+ logger.info("** ArtifactCassandraDao created");
+ } else {
+ logger.info("** ArtifactCassandraDao failed");
+ throw new RuntimeException("Artifact keyspace [" + keyspace + "] failed to connect with error : " + result.right().value());
+ }
+ } else {
+ logger.info("** Cassandra client isn't connected");
+ logger.info("** ArtifactCassandraDao created, but not connected");
+ }
+ }
+
+ public CassandraOperationStatus saveArtifact(DAOArtifactData artifact) {
+ return client.save(artifact, DAOArtifactData.class, manager);
+ }
+
+ public Either<DAOArtifactData, CassandraOperationStatus> getArtifact(String artifactId) {
+ return client.getById(artifactId, DAOArtifactData.class, manager);
+ }
+
+ public CassandraOperationStatus deleteArtifact(String artifactId) {
+ return client.delete(artifactId, DAOArtifactData.class, manager);
+ }
+
+ /**
+ * ---------for use in JUnit only--------------- the method deletes all the tables in the audit keyspace
+ *
+ * @return the status of the last failed operation or ok if all the deletes were successful
+ */
+ public CassandraOperationStatus deleteAllArtifacts() {
+ logger.info("cleaning all artifacts.");
+ String query = "truncate sdcartifact.resources;";
+ try {
+ session.execute(query);
+ } catch (Exception e) {
+ logger.debug("Failed to clean artifacts", e);
+ return CassandraOperationStatus.GENERAL_ERROR;
+ }
+ logger.info("cleaning all artifacts finished successfully.");
+ return CassandraOperationStatus.OK;
+ }
+
+ /**
+ * the method checks if the given table is empty in the artifact keyspace
+ *
+ * @param tableName the name of the table we want to check
+ * @return true if the table is empty
+ */
+ public Either<Boolean, CassandraOperationStatus> isTableEmpty(String tableName) {
+ return super.isTableEmpty(tableName);
+ }
+
+ public Either<Long, CassandraOperationStatus> getCountOfArtifactById(String uniqeId) {
+ ResultSet artifactCount = artifactAccessor.getNumOfArtifactsById(uniqeId);
+ if (artifactCount == null) {
+ return Either.right(CassandraOperationStatus.NOT_FOUND);
+ }
+ return Either.left(artifactCount.one().getLong(0));
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/AuditAccessor.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/AuditAccessor.java
index c713ea9af2..482ece7f10 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/AuditAccessor.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/AuditAccessor.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.cassandra;
import com.datastax.driver.mapping.Result;
@@ -32,49 +31,46 @@ import org.openecomp.sdc.be.resources.data.auditing.ResourceAdminEvent;
@Accessor
public interface AuditAccessor {
- // ***** distributionstatusevent table
- @Query("SELECT * FROM sdcaudit.distributionstatusevent WHERE DID = :did AND ACTION = 'DStatus' ALLOW FILTERING")
- Result<DistributionStatusEvent> getListOfDistributionStatuses(@Param("did") String did);
-
- // ***** resourceadminevent table
- @Query("SELECT * FROM sdcaudit.resourceadminevent WHERE SERVICE_INSTANCE_ID = :serviceInstanceId AND ACTION = 'DRequest' ALLOW FILTERING")
- Result<ResourceAdminEvent> getServiceDistributionStatus(@Param("serviceInstanceId") String serviceInstanceId);
+ // ***** distributionstatusevent table
+ @Query("SELECT * FROM sdcaudit.distributionstatusevent WHERE DID = :did AND ACTION = 'DStatus' ALLOW FILTERING")
+ Result<DistributionStatusEvent> getListOfDistributionStatuses(@Param("did") String did);
- @Query("SELECT * FROM sdcaudit.resourceadminevent WHERE SERVICE_INSTANCE_ID = :serviceInstanceId ")
- Result<ResourceAdminEvent> getByServiceInstanceId(@Param("serviceInstanceId") String serviceInstanceId);
+ // ***** resourceadminevent table
+ @Query("SELECT * FROM sdcaudit.resourceadminevent WHERE SERVICE_INSTANCE_ID = :serviceInstanceId AND ACTION = 'DRequest' ALLOW FILTERING")
+ Result<ResourceAdminEvent> getServiceDistributionStatus(@Param("serviceInstanceId") String serviceInstanceId);
- @Query("SELECT * FROM sdcaudit.resourceadminevent WHERE SERVICE_INSTANCE_ID = :serviceInstanceId AND PREV_VERSION = :prevVersion ALLOW FILTERING")
- Result<ResourceAdminEvent> getAuditByServiceIdAndPrevVersion(@Param("serviceInstanceId") String serviceInstanceId,
- @Param("prevVersion") String prevVersion);
+ @Query("SELECT * FROM sdcaudit.resourceadminevent WHERE SERVICE_INSTANCE_ID = :serviceInstanceId ")
+ Result<ResourceAdminEvent> getByServiceInstanceId(@Param("serviceInstanceId") String serviceInstanceId);
- @Query("SELECT * FROM sdcaudit.resourceadminevent WHERE DID = :did AND ACTION = :action ALLOW FILTERING")
- Result<ResourceAdminEvent> getDistributionRequest(@Param("did") String did, @Param("action") String action);
+ @Query("SELECT * FROM sdcaudit.resourceadminevent WHERE SERVICE_INSTANCE_ID = :serviceInstanceId AND PREV_VERSION = :prevVersion ALLOW FILTERING")
+ Result<ResourceAdminEvent> getAuditByServiceIdAndPrevVersion(@Param("serviceInstanceId") String serviceInstanceId,
+ @Param("prevVersion") String prevVersion);
- @Query("SELECT * FROM sdcaudit.resourceadminevent WHERE SERVICE_INSTANCE_ID = :serviceInstanceId AND CURR_VERSION = :currVersion ALLOW FILTERING")
- Result<ResourceAdminEvent> getAuditByServiceIdAndCurrVersion(@Param("serviceInstanceId") String serviceInstanceId,
- @Param("currVersion") String currVersion);
+ @Query("SELECT * FROM sdcaudit.resourceadminevent WHERE DID = :did AND ACTION = :action ALLOW FILTERING")
+ Result<ResourceAdminEvent> getDistributionRequest(@Param("did") String did, @Param("action") String action);
- @Query("SELECT * FROM sdcaudit.resourceadminevent WHERE SERVICE_INSTANCE_ID = :serviceInstanceId AND ACTION = 'ArchiveComponent' ALLOW FILTERING")
- Result<ResourceAdminEvent> getArchiveAuditByServiceInstanceId(@Param("serviceInstanceId") String serviceInstanceId);
+ @Query("SELECT * FROM sdcaudit.resourceadminevent WHERE SERVICE_INSTANCE_ID = :serviceInstanceId AND CURR_VERSION = :currVersion ALLOW FILTERING")
+ Result<ResourceAdminEvent> getAuditByServiceIdAndCurrVersion(@Param("serviceInstanceId") String serviceInstanceId,
+ @Param("currVersion") String currVersion);
- @Query("SELECT * FROM sdcaudit.resourceadminevent WHERE SERVICE_INSTANCE_ID = :serviceInstanceId AND ACTION = 'RestoreComponent' ALLOW FILTERING")
- Result<ResourceAdminEvent> getRestoreAuditByServiceInstanceId(@Param("serviceInstanceId") String serviceInstanceId);
+ @Query("SELECT * FROM sdcaudit.resourceadminevent WHERE SERVICE_INSTANCE_ID = :serviceInstanceId AND ACTION = 'ArchiveComponent' ALLOW FILTERING")
+ Result<ResourceAdminEvent> getArchiveAuditByServiceInstanceId(@Param("serviceInstanceId") String serviceInstanceId);
- // ***** distributiondeployevent table
- @Query("SELECT * FROM sdcaudit.distributiondeployevent WHERE SERVICE_INSTANCE_ID = :serviceInstanceId AND ACTION = 'DResult' ALLOW FILTERING")
- Result<DistributionDeployEvent> getServiceDistributionDeploy(@Param("serviceInstanceId") String serviceInstanceId);
+ @Query("SELECT * FROM sdcaudit.resourceadminevent WHERE SERVICE_INSTANCE_ID = :serviceInstanceId AND ACTION = 'RestoreComponent' ALLOW FILTERING")
+ Result<ResourceAdminEvent> getRestoreAuditByServiceInstanceId(@Param("serviceInstanceId") String serviceInstanceId);
- @Query("SELECT * FROM sdcaudit.distributiondeployevent WHERE DID = :did AND ACTION = :action AND STATUS = :status ALLOW FILTERING")
- Result<DistributionDeployEvent> getDistributionDeployByStatus(@Param("did") String did,
- @Param("action") String action, @Param("status") String status);
+ // ***** distributiondeployevent table
+ @Query("SELECT * FROM sdcaudit.distributiondeployevent WHERE SERVICE_INSTANCE_ID = :serviceInstanceId AND ACTION = 'DResult' ALLOW FILTERING")
+ Result<DistributionDeployEvent> getServiceDistributionDeploy(@Param("serviceInstanceId") String serviceInstanceId);
- // ***** distributionnotificationevent table
- @Query("SELECT * FROM sdcaudit.distributionnotificationevent WHERE SERVICE_INSTANCE_ID = :serviceInstanceId AND ACTION = 'DNotify' ALLOW FILTERING")
- Result<DistributionNotificationEvent> getServiceDistributionNotify(
- @Param("serviceInstanceId") String serviceInstanceId);
+ @Query("SELECT * FROM sdcaudit.distributiondeployevent WHERE DID = :did AND ACTION = :action AND STATUS = :status ALLOW FILTERING")
+ Result<DistributionDeployEvent> getDistributionDeployByStatus(@Param("did") String did, @Param("action") String action,
+ @Param("status") String status);
- @Query("SELECT * FROM sdcaudit.distributionnotificationevent WHERE DID = :did AND ACTION = :action ALLOW FILTERING")
- Result<DistributionNotificationEvent> getDistributionNotify(@Param("did") String did,
- @Param("action") String action);
+ // ***** distributionnotificationevent table
+ @Query("SELECT * FROM sdcaudit.distributionnotificationevent WHERE SERVICE_INSTANCE_ID = :serviceInstanceId AND ACTION = 'DNotify' ALLOW FILTERING")
+ Result<DistributionNotificationEvent> getServiceDistributionNotify(@Param("serviceInstanceId") String serviceInstanceId);
+ @Query("SELECT * FROM sdcaudit.distributionnotificationevent WHERE DID = :did AND ACTION = :action ALLOW FILTERING")
+ Result<DistributionNotificationEvent> getDistributionNotify(@Param("did") String did, @Param("action") String action);
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/AuditCassandraDao.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/AuditCassandraDao.java
index fe0022dfe5..d1b79a8ade 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/AuditCassandraDao.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/AuditCassandraDao.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,379 +17,341 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.cassandra;
import com.datastax.driver.core.Session;
import com.datastax.driver.mapping.MappingManager;
import com.datastax.driver.mapping.Result;
import fj.data.Either;
+import java.util.ArrayList;
+import java.util.List;
+import javax.annotation.PostConstruct;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.openecomp.sdc.be.config.BeEcompErrorManager;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.dao.cassandra.schema.Table;
-import org.openecomp.sdc.be.resources.data.auditing.*;
+import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum;
+import org.openecomp.sdc.be.resources.data.auditing.AuditingGenericEvent;
+import org.openecomp.sdc.be.resources.data.auditing.AuditingTypesConstants;
+import org.openecomp.sdc.be.resources.data.auditing.DistributionDeployEvent;
+import org.openecomp.sdc.be.resources.data.auditing.DistributionNotificationEvent;
+import org.openecomp.sdc.be.resources.data.auditing.DistributionStatusEvent;
+import org.openecomp.sdc.be.resources.data.auditing.ResourceAdminEvent;
import org.openecomp.sdc.common.log.wrappers.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
-import javax.annotation.PostConstruct;
-import java.util.ArrayList;
-import java.util.List;
-
@Component("audit-cassandra-dao")
public class AuditCassandraDao extends CassandraDao {
- private AuditAccessor auditAccessor;
-
- private static Logger logger = Logger.getLogger(AuditCassandraDao.class.getName());
-
- @Autowired
- public AuditCassandraDao(CassandraClient cassandraClient) {
- super(cassandraClient);
- }
-
- @PostConstruct
- public void init() {
- String keyspace = AuditingTypesConstants.AUDIT_KEYSPACE;
- if (client.isConnected()) {
- Either<ImmutablePair<Session, MappingManager>, CassandraOperationStatus> result = client.connect(keyspace);
- if (result.isLeft()) {
- session = result.left().value().left;
- manager = result.left().value().right;
- auditAccessor = manager.createAccessor(AuditAccessor.class);
- logger.info("** AuditCassandraDao created");
- } else {
- logger.info("** AuditCassandraDao failed");
- throw new RuntimeException(
- "Audit keyspace [" + keyspace + "] failed to connect with error : " + result.right().value());
- }
- } else {
- logger.info("** Cassandra client isn't connected");
- logger.info("** AuditCassandraDao created, but not connected");
- }
-
- }
-
- @SuppressWarnings("unchecked")
- public <T extends AuditingGenericEvent> CassandraOperationStatus saveRecord(T entity) {
- return client.save(entity, (Class<T>) entity.getClass(), manager);
- }
-
- /**
- *
- * @param did
- * @return
- */
- public Either<List<DistributionStatusEvent>, ActionStatus> getListOfDistributionStatuses(String did) {
- List<DistributionStatusEvent> remainingElements = new ArrayList<>();
-
- try {
- Result<DistributionStatusEvent> events = auditAccessor.getListOfDistributionStatuses(did);
- if (events == null) {
- logger.debug("not found distribution statuses for did {}", did);
- return Either.left(remainingElements);
- }
- events.all().forEach(event -> {
- event.fillFields();
- remainingElements.add(event);
- logger.debug(event.toString());
- });
- return Either.left(remainingElements);
- } catch (Exception e) {
- BeEcompErrorManager.getInstance().logBeDaoSystemError("Get DistributionStatuses List");
- logger.debug("failed to get distribution statuses for ", e);
- return Either.right(ActionStatus.GENERAL_ERROR);
- }
- }
-
- public Either<List<DistributionDeployEvent>, ActionStatus> getDistributionDeployByStatus(String did, String action,
- String status) {
- List<DistributionDeployEvent> remainingElements = new ArrayList<>();
-
- try {
- Result<DistributionDeployEvent> events = auditAccessor.getDistributionDeployByStatus(did, action, status);
- if (events == null) {
- logger.debug("not found distribution statuses for did {}", did);
- return Either.left(remainingElements);
- }
- events.all().forEach(event -> {
- event.fillFields();
- remainingElements.add(event);
- logger.debug(event.toString());
- });
-
- return Either.left(remainingElements);
- } catch (Exception e) {
- BeEcompErrorManager.getInstance().logBeDaoSystemError("get Distribution Deploy By Status");
- logger.debug("failed to get distribution deploy by status for ", e);
- return Either.right(ActionStatus.GENERAL_ERROR);
- }
- }
-
- public Either<List<ResourceAdminEvent>, ActionStatus> getDistributionRequest(String did, String action) {
- List<ResourceAdminEvent> remainingElements = new ArrayList<>();
-
- try {
- Result<ResourceAdminEvent> events = auditAccessor.getDistributionRequest(did, action);
- if (events == null) {
- logger.debug("not found distribution requests for did {}", did);
- return Either.left(remainingElements);
- }
- events.all().forEach(event -> {
- event.fillFields();
- remainingElements.add(event);
- logger.debug(event.toString());
- });
- return Either.left(remainingElements);
- } catch (Exception e) {
- BeEcompErrorManager.getInstance().logBeDaoSystemError("get Distribution request");
- logger.debug("failed to get distribution request for ", e);
- return Either.right(ActionStatus.GENERAL_ERROR);
- }
- }
-
- public Either<List<DistributionNotificationEvent>, ActionStatus> getDistributionNotify(String did, String action) {
- List<DistributionNotificationEvent> remainingElements = new ArrayList<>();
-
- try {
- Result<DistributionNotificationEvent> events = auditAccessor.getDistributionNotify(did, action);
- if (events == null) {
- logger.debug("not found distribution notify for did {}", did);
- return Either.left(remainingElements);
- }
- events.all().forEach(event -> {
- event.fillFields();
- remainingElements.add(event);
- logger.debug(event.toString());
- });
-
- return Either.left(remainingElements);
- } catch (Exception e) {
- BeEcompErrorManager.getInstance().logBeDaoSystemError("get Distribution notify");
- logger.debug("failed to get distribution notify for ", e);
- return Either.right(ActionStatus.GENERAL_ERROR);
- }
- }
-
- public Either<List<ResourceAdminEvent>, ActionStatus> getByServiceInstanceId(String serviceInstanceId) {
- List<ResourceAdminEvent> remainingElements = new ArrayList<>();
-
- try {
- Result<ResourceAdminEvent> events = auditAccessor.getByServiceInstanceId(serviceInstanceId);
- if (events == null) {
- logger.debug("not found audit records for serviceInstanceId {}", serviceInstanceId);
- return Either.left(remainingElements);
- }
- events.all().forEach(event -> {
- event.fillFields();
- remainingElements.add(event);
- logger.debug(event.toString());
- });
- return Either.left(remainingElements);
- } catch (Exception e) {
- BeEcompErrorManager.getInstance().logBeDaoSystemError("get Distribution notify");
- logger.debug("failed to get distribution notify for ", e);
- return Either.right(ActionStatus.GENERAL_ERROR);
- }
- }
-
- /**
- *
- * @param serviceInstanceId
- * @return
- */
- public Either<List<? extends AuditingGenericEvent>, ActionStatus> getServiceDistributionStatusesList(
- String serviceInstanceId) {
-
- List<AuditingGenericEvent> resList = new ArrayList<>();
-
- try {
- Result<ResourceAdminEvent> resourceAdminEvents = auditAccessor
- .getServiceDistributionStatus(serviceInstanceId);
-
- if (resourceAdminEvents != null) {
- resourceAdminEvents.all().forEach(event -> {
- event.fillFields();
- resList.add(event);
- logger.debug(event.toString());
- });
- }
-
- } catch (Exception e) {
- BeEcompErrorManager.getInstance().logBeDaoSystemError("Get Service DistributionStatuses List");
- logger.debug("failed to get distribution statuses for action {}",
- AuditingActionEnum.DISTRIBUTION_STATE_CHANGE_REQUEST.getName(), e);
- return Either.right(ActionStatus.GENERAL_ERROR);
- }
- try {
- Result<DistributionDeployEvent> distDeployEvents = auditAccessor
- .getServiceDistributionDeploy(serviceInstanceId);
- if (distDeployEvents != null) {
- distDeployEvents.all().forEach(event -> {
- event.fillFields();
- resList.add(event);
- logger.debug(event.toString());
- });
- }
- } catch (Exception e) {
- BeEcompErrorManager.getInstance().logBeDaoSystemError("Get Service DistributionStatuses List");
- logger.debug("failed to get distribution statuses for action {}",
- AuditingActionEnum.DISTRIBUTION_DEPLOY.getName(), e);
- return Either.right(ActionStatus.GENERAL_ERROR);
- }
- try {
- Result<DistributionNotificationEvent> distNotifEvent = auditAccessor
- .getServiceDistributionNotify(serviceInstanceId);
- if (distNotifEvent != null) {
- distNotifEvent.all().forEach(event -> {
- event.fillFields();
- resList.add(event);
- logger.debug(event.toString());
- });
- }
- } catch (Exception e) {
- BeEcompErrorManager.getInstance().logBeDaoSystemError("Get Service DistributionStatuses List");
- logger.debug("failed to get distribution statuses for action {}",
- AuditingActionEnum.DISTRIBUTION_NOTIFY.getName(), e);
- return Either.right(ActionStatus.GENERAL_ERROR);
- }
-
- return Either.left(resList);
- }
-
- public Either<List<ResourceAdminEvent>, ActionStatus> getAuditByServiceIdAndPrevVersion(String serviceInstanceId,
- String prevVersion) {
- List<ResourceAdminEvent> remainingElements = new ArrayList<>();
-
- try {
- Result<ResourceAdminEvent> events = auditAccessor.getAuditByServiceIdAndPrevVersion(serviceInstanceId,
- prevVersion);
- if (events == null) {
- logger.debug("not found audit records for serviceInstanceId {} andprevVersion {}", serviceInstanceId,
- prevVersion);
- return Either.left(remainingElements);
- }
- events.all().forEach(event -> {
- event.fillFields();
- remainingElements.add(event);
- logger.debug(event.toString());
- });
- return Either.left(remainingElements);
- } catch (Exception e) {
- BeEcompErrorManager.getInstance().logBeDaoSystemError("get Audit By ServiceId And PrevVersion");
- logger.debug("failed to getAuditByServiceIdAndPrevVersion ", e);
- return Either.right(ActionStatus.GENERAL_ERROR);
- }
- }
-
- public Either<List<ResourceAdminEvent>, ActionStatus> getAuditByServiceIdAndCurrVersion(String serviceInstanceId,
- String currVersion) {
- List<ResourceAdminEvent> remainingElements = new ArrayList<>();
-
- try {
- Result<ResourceAdminEvent> events = auditAccessor.getAuditByServiceIdAndCurrVersion(serviceInstanceId,
- currVersion);
- if (events == null) {
- logger.debug("not found audit records for serviceInstanceId {} andprevVersion {}", serviceInstanceId,
- currVersion);
- return Either.left(remainingElements);
- }
- events.all().forEach(event -> {
- event.fillFields();
- remainingElements.add(event);
- logger.debug(event.toString());
- });
- return Either.left(remainingElements);
- } catch (Exception e) {
- BeEcompErrorManager.getInstance().logBeDaoSystemError("get Audit By ServiceId And CurrVersion");
-
- logger.debug("failed to getAuditByServiceIdAndPrevVersion ", e);
- return Either.right(ActionStatus.GENERAL_ERROR);
- }
- }
-
- public Either<List<ResourceAdminEvent>, ActionStatus> getArchiveAuditByServiceInstanceId(String serviceInstanceId) {
- List<ResourceAdminEvent> remainingElements = new ArrayList<>();
-
- try {
- Result<ResourceAdminEvent> events = auditAccessor.getArchiveAuditByServiceInstanceId(serviceInstanceId);
- if (events == null) {
- logger.debug("not found audit records for serviceInstanceId {}", serviceInstanceId);
- return Either.left(remainingElements);
- }
- events.all().forEach(event -> {
- event.fillFields();
- remainingElements.add(event);
- logger.debug(event.toString());
- });
- return Either.left(remainingElements);
- } catch (Exception e) {
- BeEcompErrorManager.getInstance().logBeDaoSystemError("getArchiveAuditByServiceInstanceId");
-
- logger.debug("failed getArchiveAuditByServiceInstanceId ", e);
- return Either.right(ActionStatus.GENERAL_ERROR);
- }
- }
-
- public Either<List<ResourceAdminEvent>, ActionStatus> getRestoreAuditByServiceInstanceId(String serviceInstanceId) {
- List<ResourceAdminEvent> remainingElements = new ArrayList<>();
-
- try {
- Result<ResourceAdminEvent> events = auditAccessor.getRestoreAuditByServiceInstanceId(serviceInstanceId);
- if (events == null) {
- logger.debug("not found audit records for serviceInstanceId {}", serviceInstanceId);
- return Either.left(remainingElements);
- }
- events.all().forEach(event -> {
- event.fillFields();
- remainingElements.add(event);
- logger.debug(event.toString());
- });
- return Either.left(remainingElements);
- } catch (Exception e) {
- BeEcompErrorManager.getInstance().logBeDaoSystemError("getRestoreAuditByServiceInstanceId");
-
- logger.debug("failed getRestoreAuditByServiceInstanceId ", e);
- return Either.right(ActionStatus.GENERAL_ERROR);
- }
- }
-
-
- /**
- * the method checks if the given table is empty in the audit keyspace
- *
- * @param tableName
- * the name of the table we want to check
- * @return true if the table is empty
- */
- public Either<Boolean, CassandraOperationStatus> isTableEmpty(String tableName) {
- return super.isTableEmpty(tableName);
- }
-
- /**
- * ---------for use in JUnit only--------------- the method deletes all the
- * tables in the audit keyspace
- *
- * @return the status of the last failed operation or ok if all the deletes
- * were successful
- */
- public CassandraOperationStatus deleteAllAudit() {
- logger.info("cleaning all audit tables.");
- String query = "truncate " + AuditingTypesConstants.AUDIT_KEYSPACE + ".";
- try {
- for (Table table : Table.values()) {
- if (table.getTableDescription().getKeyspace().equals(AuditingTypesConstants.AUDIT_KEYSPACE)) {
- logger.debug("clean Audit table:{}", table.getTableDescription().getTableName());
- session.execute(query + table.getTableDescription().getTableName() + ";");
- logger.debug("clean Audit table:{} was successful", table.getTableDescription().getTableName());
- }
- }
- } catch (Exception e) {
- logger.error("Failed to clean Audit", e);
- return CassandraOperationStatus.GENERAL_ERROR;
- }
- logger.info("cleaning all audit tables finished successfully.");
- return CassandraOperationStatus.OK;
- }
+ private static Logger logger = Logger.getLogger(AuditCassandraDao.class.getName());
+ private AuditAccessor auditAccessor;
+
+ @Autowired
+ public AuditCassandraDao(CassandraClient cassandraClient) {
+ super(cassandraClient);
+ }
+
+ @PostConstruct
+ public void init() {
+ String keyspace = AuditingTypesConstants.AUDIT_KEYSPACE;
+ if (client.isConnected()) {
+ Either<ImmutablePair<Session, MappingManager>, CassandraOperationStatus> result = client.connect(keyspace);
+ if (result.isLeft()) {
+ session = result.left().value().left;
+ manager = result.left().value().right;
+ auditAccessor = manager.createAccessor(AuditAccessor.class);
+ logger.info("** AuditCassandraDao created");
+ } else {
+ logger.info("** AuditCassandraDao failed");
+ throw new RuntimeException("Audit keyspace [" + keyspace + "] failed to connect with error : " + result.right().value());
+ }
+ } else {
+ logger.info("** Cassandra client isn't connected");
+ logger.info("** AuditCassandraDao created, but not connected");
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T extends AuditingGenericEvent> CassandraOperationStatus saveRecord(T entity) {
+ return client.save(entity, (Class<T>) entity.getClass(), manager);
+ }
+
+ /**
+ * @param did
+ * @return
+ */
+ public Either<List<DistributionStatusEvent>, ActionStatus> getListOfDistributionStatuses(String did) {
+ List<DistributionStatusEvent> remainingElements = new ArrayList<>();
+ try {
+ Result<DistributionStatusEvent> events = auditAccessor.getListOfDistributionStatuses(did);
+ if (events == null) {
+ logger.debug("not found distribution statuses for did {}", did);
+ return Either.left(remainingElements);
+ }
+ events.all().forEach(event -> {
+ event.fillFields();
+ remainingElements.add(event);
+ logger.debug(event.toString());
+ });
+ return Either.left(remainingElements);
+ } catch (Exception e) {
+ BeEcompErrorManager.getInstance().logBeDaoSystemError("Get DistributionStatuses List");
+ logger.debug("failed to get distribution statuses for ", e);
+ return Either.right(ActionStatus.GENERAL_ERROR);
+ }
+ }
+
+ public Either<List<DistributionDeployEvent>, ActionStatus> getDistributionDeployByStatus(String did, String action, String status) {
+ List<DistributionDeployEvent> remainingElements = new ArrayList<>();
+ try {
+ Result<DistributionDeployEvent> events = auditAccessor.getDistributionDeployByStatus(did, action, status);
+ if (events == null) {
+ logger.debug("not found distribution statuses for did {}", did);
+ return Either.left(remainingElements);
+ }
+ events.all().forEach(event -> {
+ event.fillFields();
+ remainingElements.add(event);
+ logger.debug(event.toString());
+ });
+ return Either.left(remainingElements);
+ } catch (Exception e) {
+ BeEcompErrorManager.getInstance().logBeDaoSystemError("get Distribution Deploy By Status");
+ logger.debug("failed to get distribution deploy by status for ", e);
+ return Either.right(ActionStatus.GENERAL_ERROR);
+ }
+ }
+
+ public Either<List<ResourceAdminEvent>, ActionStatus> getDistributionRequest(String did, String action) {
+ List<ResourceAdminEvent> remainingElements = new ArrayList<>();
+ try {
+ Result<ResourceAdminEvent> events = auditAccessor.getDistributionRequest(did, action);
+ if (events == null) {
+ logger.debug("not found distribution requests for did {}", did);
+ return Either.left(remainingElements);
+ }
+ events.all().forEach(event -> {
+ event.fillFields();
+ remainingElements.add(event);
+ logger.debug(event.toString());
+ });
+ return Either.left(remainingElements);
+ } catch (Exception e) {
+ BeEcompErrorManager.getInstance().logBeDaoSystemError("get Distribution request");
+ logger.debug("failed to get distribution request for ", e);
+ return Either.right(ActionStatus.GENERAL_ERROR);
+ }
+ }
+
+ public Either<List<DistributionNotificationEvent>, ActionStatus> getDistributionNotify(String did, String action) {
+ List<DistributionNotificationEvent> remainingElements = new ArrayList<>();
+ try {
+ Result<DistributionNotificationEvent> events = auditAccessor.getDistributionNotify(did, action);
+ if (events == null) {
+ logger.debug("not found distribution notify for did {}", did);
+ return Either.left(remainingElements);
+ }
+ events.all().forEach(event -> {
+ event.fillFields();
+ remainingElements.add(event);
+ logger.debug(event.toString());
+ });
+ return Either.left(remainingElements);
+ } catch (Exception e) {
+ BeEcompErrorManager.getInstance().logBeDaoSystemError("get Distribution notify");
+ logger.debug("failed to get distribution notify for ", e);
+ return Either.right(ActionStatus.GENERAL_ERROR);
+ }
+ }
+
+ public Either<List<ResourceAdminEvent>, ActionStatus> getByServiceInstanceId(String serviceInstanceId) {
+ List<ResourceAdminEvent> remainingElements = new ArrayList<>();
+ try {
+ Result<ResourceAdminEvent> events = auditAccessor.getByServiceInstanceId(serviceInstanceId);
+ if (events == null) {
+ logger.debug("not found audit records for serviceInstanceId {}", serviceInstanceId);
+ return Either.left(remainingElements);
+ }
+ events.all().forEach(event -> {
+ event.fillFields();
+ remainingElements.add(event);
+ logger.debug(event.toString());
+ });
+ return Either.left(remainingElements);
+ } catch (Exception e) {
+ BeEcompErrorManager.getInstance().logBeDaoSystemError("get Distribution notify");
+ logger.debug("failed to get distribution notify for ", e);
+ return Either.right(ActionStatus.GENERAL_ERROR);
+ }
+ }
+
+ /**
+ * @param serviceInstanceId
+ * @return
+ */
+ public Either<List<? extends AuditingGenericEvent>, ActionStatus> getServiceDistributionStatusesList(String serviceInstanceId) {
+ List<AuditingGenericEvent> resList = new ArrayList<>();
+ try {
+ Result<ResourceAdminEvent> resourceAdminEvents = auditAccessor.getServiceDistributionStatus(serviceInstanceId);
+ if (resourceAdminEvents != null) {
+ resourceAdminEvents.all().forEach(event -> {
+ event.fillFields();
+ resList.add(event);
+ logger.debug(event.toString());
+ });
+ }
+ } catch (Exception e) {
+ BeEcompErrorManager.getInstance().logBeDaoSystemError("Get Service DistributionStatuses List");
+ logger.debug("failed to get distribution statuses for action {}", AuditingActionEnum.DISTRIBUTION_STATE_CHANGE_REQUEST.getName(), e);
+ return Either.right(ActionStatus.GENERAL_ERROR);
+ }
+ try {
+ Result<DistributionDeployEvent> distDeployEvents = auditAccessor.getServiceDistributionDeploy(serviceInstanceId);
+ if (distDeployEvents != null) {
+ distDeployEvents.all().forEach(event -> {
+ event.fillFields();
+ resList.add(event);
+ logger.debug(event.toString());
+ });
+ }
+ } catch (Exception e) {
+ BeEcompErrorManager.getInstance().logBeDaoSystemError("Get Service DistributionStatuses List");
+ logger.debug("failed to get distribution statuses for action {}", AuditingActionEnum.DISTRIBUTION_DEPLOY.getName(), e);
+ return Either.right(ActionStatus.GENERAL_ERROR);
+ }
+ try {
+ Result<DistributionNotificationEvent> distNotifEvent = auditAccessor.getServiceDistributionNotify(serviceInstanceId);
+ if (distNotifEvent != null) {
+ distNotifEvent.all().forEach(event -> {
+ event.fillFields();
+ resList.add(event);
+ logger.debug(event.toString());
+ });
+ }
+ } catch (Exception e) {
+ BeEcompErrorManager.getInstance().logBeDaoSystemError("Get Service DistributionStatuses List");
+ logger.debug("failed to get distribution statuses for action {}", AuditingActionEnum.DISTRIBUTION_NOTIFY.getName(), e);
+ return Either.right(ActionStatus.GENERAL_ERROR);
+ }
+ return Either.left(resList);
+ }
+
+ public Either<List<ResourceAdminEvent>, ActionStatus> getAuditByServiceIdAndPrevVersion(String serviceInstanceId, String prevVersion) {
+ List<ResourceAdminEvent> remainingElements = new ArrayList<>();
+ try {
+ Result<ResourceAdminEvent> events = auditAccessor.getAuditByServiceIdAndPrevVersion(serviceInstanceId, prevVersion);
+ if (events == null) {
+ logger.debug("not found audit records for serviceInstanceId {} andprevVersion {}", serviceInstanceId, prevVersion);
+ return Either.left(remainingElements);
+ }
+ events.all().forEach(event -> {
+ event.fillFields();
+ remainingElements.add(event);
+ logger.debug(event.toString());
+ });
+ return Either.left(remainingElements);
+ } catch (Exception e) {
+ BeEcompErrorManager.getInstance().logBeDaoSystemError("get Audit By ServiceId And PrevVersion");
+ logger.debug("failed to getAuditByServiceIdAndPrevVersion ", e);
+ return Either.right(ActionStatus.GENERAL_ERROR);
+ }
+ }
+
+ public Either<List<ResourceAdminEvent>, ActionStatus> getAuditByServiceIdAndCurrVersion(String serviceInstanceId, String currVersion) {
+ List<ResourceAdminEvent> remainingElements = new ArrayList<>();
+ try {
+ Result<ResourceAdminEvent> events = auditAccessor.getAuditByServiceIdAndCurrVersion(serviceInstanceId, currVersion);
+ if (events == null) {
+ logger.debug("not found audit records for serviceInstanceId {} andprevVersion {}", serviceInstanceId, currVersion);
+ return Either.left(remainingElements);
+ }
+ events.all().forEach(event -> {
+ event.fillFields();
+ remainingElements.add(event);
+ logger.debug(event.toString());
+ });
+ return Either.left(remainingElements);
+ } catch (Exception e) {
+ BeEcompErrorManager.getInstance().logBeDaoSystemError("get Audit By ServiceId And CurrVersion");
+ logger.debug("failed to getAuditByServiceIdAndPrevVersion ", e);
+ return Either.right(ActionStatus.GENERAL_ERROR);
+ }
+ }
+
+ public Either<List<ResourceAdminEvent>, ActionStatus> getArchiveAuditByServiceInstanceId(String serviceInstanceId) {
+ List<ResourceAdminEvent> remainingElements = new ArrayList<>();
+ try {
+ Result<ResourceAdminEvent> events = auditAccessor.getArchiveAuditByServiceInstanceId(serviceInstanceId);
+ if (events == null) {
+ logger.debug("not found audit records for serviceInstanceId {}", serviceInstanceId);
+ return Either.left(remainingElements);
+ }
+ events.all().forEach(event -> {
+ event.fillFields();
+ remainingElements.add(event);
+ logger.debug(event.toString());
+ });
+ return Either.left(remainingElements);
+ } catch (Exception e) {
+ BeEcompErrorManager.getInstance().logBeDaoSystemError("getArchiveAuditByServiceInstanceId");
+ logger.debug("failed getArchiveAuditByServiceInstanceId ", e);
+ return Either.right(ActionStatus.GENERAL_ERROR);
+ }
+ }
+
+ public Either<List<ResourceAdminEvent>, ActionStatus> getRestoreAuditByServiceInstanceId(String serviceInstanceId) {
+ List<ResourceAdminEvent> remainingElements = new ArrayList<>();
+ try {
+ Result<ResourceAdminEvent> events = auditAccessor.getRestoreAuditByServiceInstanceId(serviceInstanceId);
+ if (events == null) {
+ logger.debug("not found audit records for serviceInstanceId {}", serviceInstanceId);
+ return Either.left(remainingElements);
+ }
+ events.all().forEach(event -> {
+ event.fillFields();
+ remainingElements.add(event);
+ logger.debug(event.toString());
+ });
+ return Either.left(remainingElements);
+ } catch (Exception e) {
+ BeEcompErrorManager.getInstance().logBeDaoSystemError("getRestoreAuditByServiceInstanceId");
+ logger.debug("failed getRestoreAuditByServiceInstanceId ", e);
+ return Either.right(ActionStatus.GENERAL_ERROR);
+ }
+ }
+
+ /**
+ * the method checks if the given table is empty in the audit keyspace
+ *
+ * @param tableName the name of the table we want to check
+ * @return true if the table is empty
+ */
+ public Either<Boolean, CassandraOperationStatus> isTableEmpty(String tableName) {
+ return super.isTableEmpty(tableName);
+ }
+
+ /**
+ * ---------for use in JUnit only--------------- the method deletes all the tables in the audit keyspace
+ *
+ * @return the status of the last failed operation or ok if all the deletes were successful
+ */
+ public CassandraOperationStatus deleteAllAudit() {
+ logger.info("cleaning all audit tables.");
+ String query = "truncate " + AuditingTypesConstants.AUDIT_KEYSPACE + ".";
+ try {
+ for (Table table : Table.values()) {
+ if (table.getTableDescription().getKeyspace().equals(AuditingTypesConstants.AUDIT_KEYSPACE)) {
+ logger.debug("clean Audit table:{}", table.getTableDescription().getTableName());
+ session.execute(query + table.getTableDescription().getTableName() + ";");
+ logger.debug("clean Audit table:{} was successful", table.getTableDescription().getTableName());
+ }
+ }
+ } catch (Exception e) {
+ logger.error("Failed to clean Audit", e);
+ return CassandraOperationStatus.GENERAL_ERROR;
+ }
+ logger.info("cleaning all audit tables finished successfully.");
+ return CassandraOperationStatus.OK;
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/CassandraClient.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/CassandraClient.java
index 028247d75a..624f9b44f2 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/CassandraClient.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/CassandraClient.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,205 +17,190 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.cassandra;
import com.datastax.driver.core.Cluster;
import com.datastax.driver.core.Session;
import com.datastax.driver.core.SocketOptions;
-import com.datastax.driver.core.policies.*;
+import com.datastax.driver.core.policies.ConstantReconnectionPolicy;
+import com.datastax.driver.core.policies.DCAwareRoundRobinPolicy;
+import com.datastax.driver.core.policies.DefaultRetryPolicy;
+import com.datastax.driver.core.policies.LoadBalancingPolicy;
+import com.datastax.driver.core.policies.TokenAwarePolicy;
import com.datastax.driver.mapping.Mapper;
import com.datastax.driver.mapping.MappingManager;
import fj.data.Either;
+import java.util.List;
+import javax.annotation.PreDestroy;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.openecomp.sdc.be.config.ConfigurationManager;
import org.openecomp.sdc.common.log.wrappers.Logger;
import org.springframework.stereotype.Component;
-import javax.annotation.PreDestroy;
-import java.util.List;
-
@Component("cassandra-client")
public class CassandraClient {
- private static Logger logger = Logger.getLogger(CassandraClient.class.getName());
-
- private Cluster cluster;
- private boolean isConnected;
-
- public CassandraClient() {
- super();
- isConnected = false;
- List<String> cassandraHosts = null;
- try {
- cassandraHosts = ConfigurationManager.getConfigurationManager().getConfiguration().getCassandraConfig()
- .getCassandraHosts();
- Integer cassandraPort = ConfigurationManager.getConfigurationManager().getConfiguration().getCassandraConfig()
- .getCassandraPort();
- Long reconnectTimeout = ConfigurationManager.getConfigurationManager().getConfiguration()
- .getCassandraConfig().getReconnectTimeout();
- logger.debug("creating cluster to hosts:{} port:{} with reconnect timeout:{}", cassandraHosts, cassandraPort, reconnectTimeout);
- Cluster.Builder clusterBuilder = Cluster.builder()
- .withReconnectionPolicy(new ConstantReconnectionPolicy(reconnectTimeout))
- .withRetryPolicy(DefaultRetryPolicy.INSTANCE);
-
- cassandraHosts.forEach(host -> clusterBuilder.addContactPoint(host).withPort(cassandraPort));
- setSocketOptions(clusterBuilder);
- enableAuthentication(clusterBuilder);
- enableSsl(clusterBuilder);
- setLocalDc(clusterBuilder);
-
- cluster = clusterBuilder.build();
- isConnected = true;
- } catch (Exception e) {
- logger.info("** CassandraClient isn't connected to {}", cassandraHosts);
- }
-
- logger.info("** CassandraClient created");
- }
-
- private void setSocketOptions(Cluster.Builder clusterBuilder) {
- SocketOptions socketOptions =new SocketOptions();
- Integer socketConnectTimeout = ConfigurationManager.getConfigurationManager().getConfiguration().getCassandraConfig().getSocketConnectTimeout();
- if( socketConnectTimeout!=null ){
- logger.info("SocketConnectTimeout was provided, setting Cassandra client to use SocketConnectTimeout: {} .",socketConnectTimeout);
- socketOptions.setConnectTimeoutMillis(socketConnectTimeout);
- }
- Integer socketReadTimeout = ConfigurationManager.getConfigurationManager().getConfiguration().getCassandraConfig().getSocketReadTimeout();
- if( socketReadTimeout != null ){
- logger.info("SocketReadTimeout was provided, setting Cassandra client to use SocketReadTimeout: {} .",socketReadTimeout);
- socketOptions.setReadTimeoutMillis(socketReadTimeout);
- }
- clusterBuilder.withSocketOptions(socketOptions);
- }
-
- private void setLocalDc(Cluster.Builder clusterBuilder) {
- String localDataCenter = ConfigurationManager.getConfigurationManager().getConfiguration().getCassandraConfig()
- .getLocalDataCenter();
- if (localDataCenter != null) {
- logger.info("localDatacenter was provided, setting Cassndra clint to use datacenter: {} as local.",
- localDataCenter);
- LoadBalancingPolicy tokenAwarePolicy = new TokenAwarePolicy(
- DCAwareRoundRobinPolicy.builder().withLocalDc(localDataCenter).build());
- clusterBuilder.withLoadBalancingPolicy(tokenAwarePolicy);
- } else {
- logger.info(
- "localDatacenter was provided, the driver will use the datacenter of the first contact point that was reached at initialization");
- }
- }
-
- private void enableSsl(Cluster.Builder clusterBuilder) {
- boolean ssl = ConfigurationManager.getConfigurationManager().getConfiguration().getCassandraConfig().isSsl();
- if (ssl) {
- String truststorePath = ConfigurationManager.getConfigurationManager().getConfiguration()
- .getCassandraConfig().getTruststorePath();
- String truststorePassword = ConfigurationManager.getConfigurationManager().getConfiguration()
- .getCassandraConfig().getTruststorePassword();
- if (truststorePath == null || truststorePassword == null) {
- logger.error("ssl is enabled but truststorePath or truststorePassword were not supplied.");
- } else {
- System.setProperty("javax.net.ssl.trustStore", truststorePath);
- System.setProperty("javax.net.ssl.trustStorePassword", truststorePassword);
- clusterBuilder.withSSL();
- }
-
- }
- }
-
- private void enableAuthentication(Cluster.Builder clusterBuilder) {
- boolean authenticate = ConfigurationManager.getConfigurationManager().getConfiguration().getCassandraConfig()
- .isAuthenticate();
- if (authenticate) {
- String username = ConfigurationManager.getConfigurationManager().getConfiguration().getCassandraConfig()
- .getUsername();
- String password = ConfigurationManager.getConfigurationManager().getConfiguration().getCassandraConfig()
- .getPassword();
- if (username == null || password == null) {
- logger.error("authentication is enabled but username or password were not supplied.");
- } else {
- clusterBuilder.withCredentials(username, password);
- }
-
- }
- }
-
- /**
- *
- * @param keyspace
- * - key space to connect
- * @return
- */
- public Either<ImmutablePair<Session, MappingManager>, CassandraOperationStatus> connect(String keyspace) {
- if (cluster != null) {
- try {
- Session session = cluster.connect(keyspace);
- if (session != null) {
- MappingManager manager = new MappingManager(session);
- return Either.left(new ImmutablePair<>(session, manager));
- } else {
- return Either.right(CassandraOperationStatus.KEYSPACE_NOT_CONNECTED);
- }
- } catch (Throwable e) {
- logger.debug("Failed to connect to keyspace [{}], error :", keyspace, e);
- return Either.right(CassandraOperationStatus.KEYSPACE_NOT_CONNECTED);
- }
- }
- return Either.right(CassandraOperationStatus.CLUSTER_NOT_CONNECTED);
- }
-
- public <T> CassandraOperationStatus save(T entity, Class<T> clazz, MappingManager manager) {
- if (!isConnected) {
- return CassandraOperationStatus.CLUSTER_NOT_CONNECTED;
- }
- try {
- Mapper<T> mapper = manager.mapper(clazz);
- mapper.save(entity);
- } catch (Exception e) {
- logger.debug("Failed to save entity [{}], error :", entity, e);
- return CassandraOperationStatus.GENERAL_ERROR;
- }
- return CassandraOperationStatus.OK;
- }
-
- public <T> Either<T, CassandraOperationStatus> getById(String id, Class<T> clazz, MappingManager manager) {
- if (!isConnected) {
- return Either.right(CassandraOperationStatus.CLUSTER_NOT_CONNECTED);
- }
- try {
- Mapper<T> mapper = manager.mapper(clazz);
- T result = mapper.get(id);
- if (result == null) {
- return Either.right(CassandraOperationStatus.NOT_FOUND);
- }
- return Either.left(result);
- } catch (Exception e) {
- logger.debug("Failed to get by Id [{}], error :", id, e);
- return Either.right(CassandraOperationStatus.GENERAL_ERROR);
- }
- }
-
- public <T> CassandraOperationStatus delete(String id, Class<T> clazz, MappingManager manager) {
- if (!isConnected) {
- return CassandraOperationStatus.CLUSTER_NOT_CONNECTED;
- }
- try {
- Mapper<T> mapper = manager.mapper(clazz);
- mapper.delete(id);
- } catch (Exception e) {
- logger.debug("Failed to delete by id [{}], error :", id, e);
- return CassandraOperationStatus.GENERAL_ERROR;
- }
- return CassandraOperationStatus.OK;
- }
-
- public boolean isConnected() {
- return isConnected;
- }
- @PreDestroy
- public void closeClient() {
- if (isConnected) {
- cluster.close();
- }
- logger.info("** CassandraClient cluster closed");
- }
+ private static Logger logger = Logger.getLogger(CassandraClient.class.getName());
+ private Cluster cluster;
+ private boolean isConnected;
+
+ public CassandraClient() {
+ super();
+ isConnected = false;
+ List<String> cassandraHosts = null;
+ try {
+ cassandraHosts = ConfigurationManager.getConfigurationManager().getConfiguration().getCassandraConfig().getCassandraHosts();
+ Integer cassandraPort = ConfigurationManager.getConfigurationManager().getConfiguration().getCassandraConfig().getCassandraPort();
+ Long reconnectTimeout = ConfigurationManager.getConfigurationManager().getConfiguration().getCassandraConfig().getReconnectTimeout();
+ logger.debug("creating cluster to hosts:{} port:{} with reconnect timeout:{}", cassandraHosts, cassandraPort, reconnectTimeout);
+ Cluster.Builder clusterBuilder = Cluster.builder().withReconnectionPolicy(new ConstantReconnectionPolicy(reconnectTimeout))
+ .withRetryPolicy(DefaultRetryPolicy.INSTANCE);
+ cassandraHosts.forEach(host -> clusterBuilder.addContactPoint(host).withPort(cassandraPort));
+ setSocketOptions(clusterBuilder);
+ enableAuthentication(clusterBuilder);
+ enableSsl(clusterBuilder);
+ setLocalDc(clusterBuilder);
+ cluster = clusterBuilder.build();
+ isConnected = true;
+ } catch (Exception e) {
+ logger.info("** CassandraClient isn't connected to {}", cassandraHosts);
+ }
+ logger.info("** CassandraClient created");
+ }
+
+ private void setSocketOptions(Cluster.Builder clusterBuilder) {
+ SocketOptions socketOptions = new SocketOptions();
+ Integer socketConnectTimeout = ConfigurationManager.getConfigurationManager().getConfiguration().getCassandraConfig()
+ .getSocketConnectTimeout();
+ if (socketConnectTimeout != null) {
+ logger.info("SocketConnectTimeout was provided, setting Cassandra client to use SocketConnectTimeout: {} .", socketConnectTimeout);
+ socketOptions.setConnectTimeoutMillis(socketConnectTimeout);
+ }
+ Integer socketReadTimeout = ConfigurationManager.getConfigurationManager().getConfiguration().getCassandraConfig().getSocketReadTimeout();
+ if (socketReadTimeout != null) {
+ logger.info("SocketReadTimeout was provided, setting Cassandra client to use SocketReadTimeout: {} .", socketReadTimeout);
+ socketOptions.setReadTimeoutMillis(socketReadTimeout);
+ }
+ clusterBuilder.withSocketOptions(socketOptions);
+ }
+
+ private void setLocalDc(Cluster.Builder clusterBuilder) {
+ String localDataCenter = ConfigurationManager.getConfigurationManager().getConfiguration().getCassandraConfig().getLocalDataCenter();
+ if (localDataCenter != null) {
+ logger.info("localDatacenter was provided, setting Cassndra clint to use datacenter: {} as local.", localDataCenter);
+ LoadBalancingPolicy tokenAwarePolicy = new TokenAwarePolicy(DCAwareRoundRobinPolicy.builder().withLocalDc(localDataCenter).build());
+ clusterBuilder.withLoadBalancingPolicy(tokenAwarePolicy);
+ } else {
+ logger.info(
+ "localDatacenter was provided, the driver will use the datacenter of the first contact point that was reached at initialization");
+ }
+ }
+
+ private void enableSsl(Cluster.Builder clusterBuilder) {
+ boolean ssl = ConfigurationManager.getConfigurationManager().getConfiguration().getCassandraConfig().isSsl();
+ if (ssl) {
+ String truststorePath = ConfigurationManager.getConfigurationManager().getConfiguration().getCassandraConfig().getTruststorePath();
+ String truststorePassword = ConfigurationManager.getConfigurationManager().getConfiguration().getCassandraConfig()
+ .getTruststorePassword();
+ if (truststorePath == null || truststorePassword == null) {
+ logger.error("ssl is enabled but truststorePath or truststorePassword were not supplied.");
+ } else {
+ System.setProperty("javax.net.ssl.trustStore", truststorePath);
+ System.setProperty("javax.net.ssl.trustStorePassword", truststorePassword);
+ clusterBuilder.withSSL();
+ }
+ }
+ }
+
+ private void enableAuthentication(Cluster.Builder clusterBuilder) {
+ boolean authenticate = ConfigurationManager.getConfigurationManager().getConfiguration().getCassandraConfig().isAuthenticate();
+ if (authenticate) {
+ String username = ConfigurationManager.getConfigurationManager().getConfiguration().getCassandraConfig().getUsername();
+ String password = ConfigurationManager.getConfigurationManager().getConfiguration().getCassandraConfig().getPassword();
+ if (username == null || password == null) {
+ logger.error("authentication is enabled but username or password were not supplied.");
+ } else {
+ clusterBuilder.withCredentials(username, password);
+ }
+ }
+ }
+
+ /**
+ * @param keyspace - key space to connect
+ * @return
+ */
+ public Either<ImmutablePair<Session, MappingManager>, CassandraOperationStatus> connect(String keyspace) {
+ if (cluster != null) {
+ try {
+ Session session = cluster.connect(keyspace);
+ if (session != null) {
+ MappingManager manager = new MappingManager(session);
+ return Either.left(new ImmutablePair<>(session, manager));
+ } else {
+ return Either.right(CassandraOperationStatus.KEYSPACE_NOT_CONNECTED);
+ }
+ } catch (Throwable e) {
+ logger.debug("Failed to connect to keyspace [{}], error :", keyspace, e);
+ return Either.right(CassandraOperationStatus.KEYSPACE_NOT_CONNECTED);
+ }
+ }
+ return Either.right(CassandraOperationStatus.CLUSTER_NOT_CONNECTED);
+ }
+
+ public <T> CassandraOperationStatus save(T entity, Class<T> clazz, MappingManager manager) {
+ if (!isConnected) {
+ return CassandraOperationStatus.CLUSTER_NOT_CONNECTED;
+ }
+ try {
+ Mapper<T> mapper = manager.mapper(clazz);
+ mapper.save(entity);
+ } catch (Exception e) {
+ logger.debug("Failed to save entity [{}], error :", entity, e);
+ return CassandraOperationStatus.GENERAL_ERROR;
+ }
+ return CassandraOperationStatus.OK;
+ }
+
+ public <T> Either<T, CassandraOperationStatus> getById(String id, Class<T> clazz, MappingManager manager) {
+ if (!isConnected) {
+ return Either.right(CassandraOperationStatus.CLUSTER_NOT_CONNECTED);
+ }
+ try {
+ Mapper<T> mapper = manager.mapper(clazz);
+ T result = mapper.get(id);
+ if (result == null) {
+ return Either.right(CassandraOperationStatus.NOT_FOUND);
+ }
+ return Either.left(result);
+ } catch (Exception e) {
+ logger.debug("Failed to get by Id [{}], error :", id, e);
+ return Either.right(CassandraOperationStatus.GENERAL_ERROR);
+ }
+ }
+
+ public <T> CassandraOperationStatus delete(String id, Class<T> clazz, MappingManager manager) {
+ if (!isConnected) {
+ return CassandraOperationStatus.CLUSTER_NOT_CONNECTED;
+ }
+ try {
+ Mapper<T> mapper = manager.mapper(clazz);
+ mapper.delete(id);
+ } catch (Exception e) {
+ logger.debug("Failed to delete by id [{}], error :", id, e);
+ return CassandraOperationStatus.GENERAL_ERROR;
+ }
+ return CassandraOperationStatus.OK;
+ }
+
+ public boolean isConnected() {
+ return isConnected;
+ }
+
+ @PreDestroy
+ public void closeClient() {
+ if (isConnected) {
+ cluster.close();
+ }
+ logger.info("** CassandraClient cluster closed");
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/CassandraDao.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/CassandraDao.java
index 3eba7ae54a..885d82f5f1 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/CassandraDao.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/CassandraDao.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.cassandra;
import com.datastax.driver.core.ResultSet;
@@ -30,36 +29,29 @@ import org.openecomp.sdc.common.log.wrappers.Logger;
public abstract class CassandraDao {
- private static Logger logger = Logger.getLogger(CassandraDao.class.getName());
-
- protected Session session;
- protected MappingManager manager;
-
- protected CassandraClient client;
-
- public CassandraDao(CassandraClient cassandraClient) {
- this.client = cassandraClient;
- }
-
- /**
- * the method checks if the given table is empty under the keyspace the
- * session was opened to.
- *
- * @param tableName
- * the name of the table we want to check
- * @return returns true if the table was empty
- */
- protected Either<Boolean, CassandraOperationStatus> isTableEmpty(String tableName) {
-
- Statement select = QueryBuilder.select().countAll().from(tableName).limit(10);
- try {
- ResultSet res = session.execute(select);
- return Either.left(res.one().getLong("count") == 0);
-
- } catch (Exception e) {
- logger.debug("Failed check if table is empty", e);
- return Either.right(CassandraOperationStatus.GENERAL_ERROR);
- }
- }
-
+ private static Logger logger = Logger.getLogger(CassandraDao.class.getName());
+ protected Session session;
+ protected MappingManager manager;
+ protected CassandraClient client;
+
+ public CassandraDao(CassandraClient cassandraClient) {
+ this.client = cassandraClient;
+ }
+
+ /**
+ * the method checks if the given table is empty under the keyspace the session was opened to.
+ *
+ * @param tableName the name of the table we want to check
+ * @return returns true if the table was empty
+ */
+ protected Either<Boolean, CassandraOperationStatus> isTableEmpty(String tableName) {
+ Statement select = QueryBuilder.select().countAll().from(tableName).limit(10);
+ try {
+ ResultSet res = session.execute(select);
+ return Either.left(res.one().getLong("count") == 0);
+ } catch (Exception e) {
+ logger.debug("Failed check if table is empty", e);
+ return Either.right(CassandraOperationStatus.GENERAL_ERROR);
+ }
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/CassandraOperationStatus.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/CassandraOperationStatus.java
index 52b71c780b..af5519de13 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/CassandraOperationStatus.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/CassandraOperationStatus.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,10 +17,8 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.cassandra;
public enum CassandraOperationStatus {
- OK, CLUSTER_NOT_CONNECTED, KEYSPACE_NOT_CONNECTED, GENERAL_ERROR, NOT_FOUND
-
+ OK, CLUSTER_NOT_CONNECTED, KEYSPACE_NOT_CONNECTED, GENERAL_ERROR, NOT_FOUND
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/ComponentCacheAccessor.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/ComponentCacheAccessor.java
index a8f21c9922..8a8719cef6 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/ComponentCacheAccessor.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/ComponentCacheAccessor.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,31 +17,29 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.cassandra;
import com.datastax.driver.mapping.Result;
import com.datastax.driver.mapping.annotations.Accessor;
import com.datastax.driver.mapping.annotations.Param;
import com.datastax.driver.mapping.annotations.Query;
-import org.openecomp.sdc.be.resources.data.ComponentCacheData;
-
import java.util.List;
+import org.openecomp.sdc.be.resources.data.ComponentCacheData;
@Accessor
public interface ComponentCacheAccessor {
- @Query("SELECT * FROM sdccomponent.componentcache WHERE id IN :ids ALLOW FILTERING")
- Result<ComponentCacheData> getComponents(@Param("ids") List<String> ids);
+ @Query("SELECT * FROM sdccomponent.componentcache WHERE id IN :ids ALLOW FILTERING")
+ Result<ComponentCacheData> getComponents(@Param("ids") List<String> ids);
- @Query("SELECT * FROM sdccomponent.componentcache WHERE id = :id ALLOW FILTERING")
- Result<ComponentCacheData> getComponent(@Param("id") String id);
+ @Query("SELECT * FROM sdccomponent.componentcache WHERE id = :id ALLOW FILTERING")
+ Result<ComponentCacheData> getComponent(@Param("id") String id);
- @Query("SELECT id,modification_time,type FROM sdccomponent.componentcache ALLOW FILTERING")
- Result<ComponentCacheData> getAllComponentIdTimeAndType();
+ @Query("SELECT id,modification_time,type FROM sdccomponent.componentcache ALLOW FILTERING")
+ Result<ComponentCacheData> getAllComponentIdTimeAndType();
+ // @Query("SELECT * FROM sdcartifact.resources LIMIT 2000")
- // @Query("SELECT * FROM sdcartifact.resources LIMIT 2000")
- // Result<DAOArtifactData> getListOfResources();
+ // Result<DAOArtifactData> getListOfResources();
- // Result<DAOArtifactData> getListOfResources(List<String> dids);
-}
+ // Result<DAOArtifactData> getListOfResources(List<String> dids);
+}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/FeatureToggleAccessor.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/FeatureToggleAccessor.java
index 9c639b6cca..98fdad09b6 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/FeatureToggleAccessor.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/FeatureToggleAccessor.java
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.cassandra;
import com.datastax.driver.mapping.Result;
@@ -27,6 +26,7 @@ import org.openecomp.sdc.be.resources.data.togglz.FeatureToggleEvent;
@Accessor
public interface FeatureToggleAccessor {
+
@Query("SELECT * FROM sdcrepository.featuretogglestate")
Result<FeatureToggleEvent> getAllFeatures();
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/FeatureToggleDao.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/FeatureToggleDao.java
index dae34ae8e7..18e73de7ac 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/FeatureToggleDao.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/FeatureToggleDao.java
@@ -17,33 +17,29 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.cassandra;
import com.datastax.driver.core.Session;
import com.datastax.driver.mapping.MappingManager;
import fj.data.Either;
+import java.util.List;
+import javax.annotation.PostConstruct;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.openecomp.sdc.be.resources.data.auditing.AuditingTypesConstants;
import org.openecomp.sdc.be.resources.data.togglz.FeatureToggleEvent;
import org.openecomp.sdc.common.log.wrappers.Logger;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
-import javax.annotation.PostConstruct;
-import java.util.List;
-
@Component("feature_toggle_dao")
public class FeatureToggleDao extends CassandraDao {
- private FeatureToggleAccessor featureToggleAccessor;
private static Logger logger = Logger.getLogger(FeatureToggleDao.class.getName());
+ private FeatureToggleAccessor featureToggleAccessor;
public FeatureToggleDao(CassandraClient cassandraClient) {
super(cassandraClient);
}
-
@PostConstruct
public void init() {
String keyspace = AuditingTypesConstants.REPO_KEYSPACE;
@@ -56,8 +52,7 @@ public class FeatureToggleDao extends CassandraDao {
logger.info("** FeatureToggleDao created");
} else {
logger.info("** FeatureToggleDao failed");
- throw new RuntimeException(
- "Repo keyspace [" + keyspace + "] failed to connect with error : " + result.right().value());
+ throw new RuntimeException("Repo keyspace [" + keyspace + "] failed to connect with error : " + result.right().value());
}
} else {
logger.info("** Cassandra client isn't connected");
@@ -66,16 +61,14 @@ public class FeatureToggleDao extends CassandraDao {
}
public CassandraOperationStatus save(FeatureToggleEvent featureToggleEvent) {
- return client.save(featureToggleEvent, FeatureToggleEvent.class, manager);
+ return client.save(featureToggleEvent, FeatureToggleEvent.class, manager);
}
public FeatureToggleEvent get(String feature_name) {
- return client.getById(feature_name, FeatureToggleEvent.class, manager)
- .left()
- .on(r -> {
- logger.debug("Failed to retrieve state of feature [{}] due to error {}", feature_name, r.toString());
- return null;
- });
+ return client.getById(feature_name, FeatureToggleEvent.class, manager).left().on(r -> {
+ logger.debug("Failed to retrieve state of feature [{}] due to error {}", feature_name, r.toString());
+ return null;
+ });
}
public CassandraOperationStatus delete(String feature_name) {
@@ -85,5 +78,4 @@ public class FeatureToggleDao extends CassandraDao {
public List<FeatureToggleEvent> getAllFeatures() {
return featureToggleAccessor.getAllFeatures().all();
}
-
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/OperationalEnvironmentDao.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/OperationalEnvironmentDao.java
index 30eb035d7b..9bc2bbd793 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/OperationalEnvironmentDao.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/OperationalEnvironmentDao.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,13 +17,14 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.cassandra;
import com.datastax.driver.core.Session;
import com.datastax.driver.mapping.MappingManager;
import com.datastax.driver.mapping.Result;
import fj.data.Either;
+import java.util.List;
+import javax.annotation.PostConstruct;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.openecomp.sdc.be.datatypes.enums.EnvironmentStatusEnum;
import org.openecomp.sdc.be.resources.data.OperationalEnvironmentEntry;
@@ -33,9 +34,6 @@ import org.openecomp.sdc.common.log.wrappers.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
-import javax.annotation.PostConstruct;
-import java.util.List;
-
@Component("operational-environment-dao")
public class OperationalEnvironmentDao extends CassandraDao {
@@ -58,15 +56,19 @@ public class OperationalEnvironmentDao extends CassandraDao {
operationalEnvironmentsAccessor = manager.createAccessor(OperationalEnvironmentsAccessor.class);
logger.debug("** OperationalEnvironmentDao created");
} else {
- logger.error(EcompLoggerErrorCode.DATA_ERROR, "OperationalEnvironmentDao", "OperationalEnvironmentDao", "** OperationalEnvironmentDao failed");
- throw new RuntimeException("OperationalEnvironment keyspace [" + keyspace + "] failed to connect with error : "
- + result.right().value());
+ logger.error(EcompLoggerErrorCode.DATA_ERROR, "OperationalEnvironmentDao", "OperationalEnvironmentDao",
+ "** OperationalEnvironmentDao failed");
+ throw new RuntimeException(
+ "OperationalEnvironment keyspace [" + keyspace + "] failed to connect with error : " + result.right().value());
}
} else {
- logger.error(EcompLoggerErrorCode.DATA_ERROR, "OperationalEnvironmentDao", "OperationalEnvironmentDao", "** Cassandra client isn't connected");
- logger.error(EcompLoggerErrorCode.DATA_ERROR, "OperationalEnvironmentDao", "OperationalEnvironmentDao", "** OperationalEnvironmentDao created, but not connected");
+ logger.error(EcompLoggerErrorCode.DATA_ERROR, "OperationalEnvironmentDao", "OperationalEnvironmentDao",
+ "** Cassandra client isn't connected");
+ logger.error(EcompLoggerErrorCode.DATA_ERROR, "OperationalEnvironmentDao", "OperationalEnvironmentDao",
+ "** OperationalEnvironmentDao created, but not connected");
}
}
+
public CassandraOperationStatus save(OperationalEnvironmentEntry operationalEnvironmentEntry) {
return client.save(operationalEnvironmentEntry, OperationalEnvironmentEntry.class, manager);
}
@@ -104,5 +106,4 @@ public class OperationalEnvironmentDao extends CassandraDao {
}
return Either.left(operationalEnvironments.all());
}
-
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/OperationalEnvironmentsAccessor.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/OperationalEnvironmentsAccessor.java
index e36711d57a..aadd0f5197 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/OperationalEnvironmentsAccessor.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/OperationalEnvironmentsAccessor.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.cassandra;
import com.datastax.driver.mapping.Result;
@@ -28,7 +27,7 @@ import org.openecomp.sdc.be.resources.data.OperationalEnvironmentEntry;
@Accessor
public interface OperationalEnvironmentsAccessor {
+
@Query("SELECT * FROM sdcrepository.operationalenvironment WHERE status = :envStatus")
Result<OperationalEnvironmentEntry> getByEnvironmentsStatus(@Param("envStatus") String envStatus);
}
-
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 ab1399ab83..297eec8934 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
@@ -7,9 +7,9 @@
* 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.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.cassandra;
import com.datastax.driver.mapping.Result;
@@ -28,6 +27,8 @@ import org.openecomp.sdc.be.resources.data.SdcSchemaFilesData;
@Accessor
public interface SdcSchemaFilesAccessor {
- @Query("SELECT * FROM sdcartifact.sdcschemafiles WHERE SDCRELEASENUM = :sdcreleasenum AND CONFORMANCELEVEL = :conformancelevel ORDER BY timestamp DESC")
- Result<SdcSchemaFilesData> getSpecificSdcSchemaFiles(@Param("sdcreleasenum") String sdcreleasenum, @Param("conformancelevel") String conformancelevel);
+
+ @Query("SELECT * FROM sdcartifact.sdcschemafiles WHERE SDCRELEASENUM = :sdcreleasenum AND CONFORMANCELEVEL = :conformancelevel ORDER BY timestamp DESC")
+ Result<SdcSchemaFilesData> 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 9ca10c91b4..fd1a8818ad 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
@@ -7,9 +7,9 @@
* 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.
@@ -17,13 +17,14 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.cassandra;
import com.datastax.driver.core.Session;
import com.datastax.driver.mapping.MappingManager;
import com.datastax.driver.mapping.Result;
import fj.data.Either;
+import java.util.List;
+import javax.annotation.PostConstruct;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.openecomp.sdc.be.resources.data.SdcSchemaFilesData;
import org.openecomp.sdc.be.resources.data.auditing.AuditingTypesConstants;
@@ -31,106 +32,95 @@ import org.openecomp.sdc.common.log.wrappers.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
-import javax.annotation.PostConstruct;
-import java.util.List;
-
@Component("sdc-schema-files-cassandra-dao")
public class SdcSchemaFilesCassandraDao extends CassandraDao {
-
- private static Logger logger = Logger.getLogger(SdcSchemaFilesCassandraDao.class.getName());
- private SdcSchemaFilesAccessor sdcSchemaFilesAccessor;
- @Autowired
- public SdcSchemaFilesCassandraDao(CassandraClient cassandraClient) {
- super(cassandraClient);
- }
+ private static Logger logger = Logger.getLogger(SdcSchemaFilesCassandraDao.class.getName());
+ private SdcSchemaFilesAccessor sdcSchemaFilesAccessor;
+
+ @Autowired
+ public SdcSchemaFilesCassandraDao(CassandraClient cassandraClient) {
+ super(cassandraClient);
+ }
+
+ @PostConstruct
+ public void init() {
+ String keyspace = AuditingTypesConstants.ARTIFACT_KEYSPACE;
+ if (client.isConnected()) {
+ Either<ImmutablePair<Session, MappingManager>, CassandraOperationStatus> result = client.connect(keyspace);
+ if (result.isLeft()) {
+ session = result.left().value().left;
+ manager = result.left().value().right;
+ sdcSchemaFilesAccessor = manager.createAccessor(SdcSchemaFilesAccessor.class);
+ logger.info("** SdcSchemaFilesCassandraDao created");
+ } else {
+ logger.info("** SdcSchemaFilesCassandraDao failed");
+ throw new RuntimeException("Artifact keyspace [" + keyspace + "] failed to connect with error : " + result.right().value());
+ }
+ } else {
+ logger.info("** Cassandra client isn't connected");
+ logger.info("** SdcSchemaFilesCassandraDao created, but not connected");
+ }
+ }
+
+ public CassandraOperationStatus saveSchemaFile(SdcSchemaFilesData schemaFileData) {
+ return client.save(schemaFileData, SdcSchemaFilesData.class, manager);
+ }
+
+ public Either<SdcSchemaFilesData, CassandraOperationStatus> getSchemaFile(String schemaFileId) {
+ return client.getById(schemaFileId, SdcSchemaFilesData.class, manager);
+ }
- @PostConstruct
- public void init() {
- String keyspace = AuditingTypesConstants.ARTIFACT_KEYSPACE;
- if (client.isConnected()) {
- Either<ImmutablePair<Session, MappingManager>, CassandraOperationStatus> result = client.connect(keyspace);
- if (result.isLeft()) {
- session = result.left().value().left;
- manager = result.left().value().right;
- sdcSchemaFilesAccessor = manager.createAccessor(SdcSchemaFilesAccessor.class);
- logger.info("** SdcSchemaFilesCassandraDao created");
- } else {
- logger.info("** SdcSchemaFilesCassandraDao failed");
- throw new RuntimeException("Artifact keyspace [" + keyspace + "] failed to connect with error : "
- + result.right().value());
- }
- } else {
- logger.info("** Cassandra client isn't connected");
- logger.info("** SdcSchemaFilesCassandraDao created, but not connected");
- }
- }
-
- public CassandraOperationStatus saveSchemaFile(SdcSchemaFilesData schemaFileData) {
- return client.save(schemaFileData, SdcSchemaFilesData.class, manager);
- }
+ public CassandraOperationStatus deleteSchemaFile(String schemaFileId) {
+ return client.delete(schemaFileId, SdcSchemaFilesData.class, manager);
+ }
- public Either<SdcSchemaFilesData, CassandraOperationStatus> getSchemaFile(String schemaFileId) {
- return client.getById(schemaFileId, SdcSchemaFilesData.class, manager);
- }
+ public Either<List<SdcSchemaFilesData>, CassandraOperationStatus> getSpecificSchemaFiles(String sdcreleasenum, String conformancelevel) {
+ Result<SdcSchemaFilesData> 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.right(CassandraOperationStatus.NOT_FOUND);
+ }
+ List<SdcSchemaFilesData> list = specificSdcSchemaFiles.all();
+ if (logger.isDebugEnabled()) {
+ for (SdcSchemaFilesData esSdcSchemaFilesData : list) {
+ logger.trace(esSdcSchemaFilesData.toString());
+ }
+ }
+ return Either.left(list);
+ }
- public CassandraOperationStatus deleteSchemaFile(String schemaFileId) {
- return client.delete(schemaFileId, SdcSchemaFilesData.class, manager);
- }
-
- public Either<List<SdcSchemaFilesData>, CassandraOperationStatus> getSpecificSchemaFiles(String sdcreleasenum, String conformancelevel) {
-
- Result<SdcSchemaFilesData> 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.right(CassandraOperationStatus.NOT_FOUND);
- }
-
- List<SdcSchemaFilesData> list = specificSdcSchemaFiles.all();
- if(logger.isDebugEnabled()){
- for (SdcSchemaFilesData esSdcSchemaFilesData : list) {
- logger.trace(esSdcSchemaFilesData.toString());
- }
- }
-
- return Either.left(list);
- }
-
- /**
- * ---------for use in JUnit only--------------- the method deletes all the
- * tables in the audit keyspace
- *
- * @return the status of the last failed operation or ok if all the deletes
- * were successful
- */
- public CassandraOperationStatus deleteAllArtifacts() {
- logger.info("cleaning all artifacts.");
- String query = "truncate sdcartifact.resources;";
- try {
- session.execute(query);
- } catch (Exception e) {
- logger.debug("Failed to clean artifacts", e);
- return CassandraOperationStatus.GENERAL_ERROR;
- }
- logger.info("cleaning all artifacts finished successfully.");
- return CassandraOperationStatus.OK;
- }
+ /**
+ * ---------for use in JUnit only--------------- the method deletes all the tables in the audit keyspace
+ *
+ * @return the status of the last failed operation or ok if all the deletes were successful
+ */
+ public CassandraOperationStatus deleteAllArtifacts() {
+ logger.info("cleaning all artifacts.");
+ String query = "truncate sdcartifact.resources;";
+ try {
+ session.execute(query);
+ } catch (Exception e) {
+ logger.debug("Failed to clean artifacts", e);
+ return CassandraOperationStatus.GENERAL_ERROR;
+ }
+ logger.info("cleaning all artifacts finished successfully.");
+ return CassandraOperationStatus.OK;
+ }
- /**
- * the method checks if the given table is empty in the artifact keyspace
- *
- * @param tableName
- * the name of the table we want to check
- * @return true if the table is empty
- */
- public Either<Boolean, CassandraOperationStatus> isTableEmpty(String tableName) {
- return super.isTableEmpty(tableName);
- }
+ /**
+ * the method checks if the given table is empty in the artifact keyspace
+ *
+ * @param tableName the name of the table we want to check
+ * @return true if the table is empty
+ */
+ public Either<Boolean, CassandraOperationStatus> isTableEmpty(String tableName) {
+ return super.isTableEmpty(tableName);
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/ITableDescription.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/ITableDescription.java
index 4622b4f1f7..453579cc93 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/ITableDescription.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/ITableDescription.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,29 +17,26 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.cassandra.schema;
import com.datastax.driver.core.DataType;
-import org.apache.commons.lang3.tuple.ImmutablePair;
-
import java.util.List;
import java.util.Map;
+import org.apache.commons.lang3.tuple.ImmutablePair;
public interface ITableDescription {
- public static final String TIMESTAMP_FIELD = "timestamp1";
- public static final String TIMEBASED_UUID_FIELD = "timebaseduuid";
- public static final String ID_FIELD = "id";
-
- public List<ImmutablePair<String, DataType>> primaryKeys();
+ public static final String TIMESTAMP_FIELD = "timestamp1";
+ public static final String TIMEBASED_UUID_FIELD = "timebaseduuid";
+ public static final String ID_FIELD = "id";
- public List<ImmutablePair<String, DataType>> clusteringKeys();
+ public List<ImmutablePair<String, DataType>> primaryKeys();
- public Map<String, ImmutablePair<DataType, Boolean>> getColumnDescription();
+ public List<ImmutablePair<String, DataType>> clusteringKeys();
- public String getKeyspace();
+ public Map<String, ImmutablePair<DataType, Boolean>> getColumnDescription();
- public String getTableName();
+ public String getKeyspace();
+ public String getTableName();
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/SdcSchemaBuilder.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/SdcSchemaBuilder.java
index 503ae856ca..0c6bb453ae 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/SdcSchemaBuilder.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/SdcSchemaBuilder.java
@@ -7,9 +7,9 @@
* 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.
@@ -19,14 +19,25 @@
* Modifications copyright (c) 2018 Nokia
* ================================================================================
*/
-
package org.openecomp.sdc.be.dao.cassandra.schema;
-import com.datastax.driver.core.*;
+import com.datastax.driver.core.AbstractTableMetadata;
+import com.datastax.driver.core.Cluster;
+import com.datastax.driver.core.DataType;
+import com.datastax.driver.core.IndexMetadata;
+import com.datastax.driver.core.KeyspaceMetadata;
+import com.datastax.driver.core.Session;
import com.datastax.driver.core.schemabuilder.Alter;
import com.datastax.driver.core.schemabuilder.Create;
import com.datastax.driver.core.schemabuilder.SchemaBuilder;
import com.datastax.driver.core.schemabuilder.SchemaStatement;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.function.Supplier;
+import java.util.stream.Collectors;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.apache.commons.lang3.tuple.ImmutablePair;
@@ -36,360 +47,328 @@ import org.openecomp.sdc.be.resources.data.auditing.AuditingTypesConstants;
import org.openecomp.sdc.common.log.enums.EcompLoggerErrorCode;
import org.openecomp.sdc.common.log.wrappers.Logger;
-import java.util.*;
-import java.util.stream.Collectors;
-import java.util.function.Supplier;
-
public class SdcSchemaBuilder {
- private SdcSchemaUtils sdcSchemaUtils;
- private Supplier<Configuration.CassandrConfig> cassandraConfigSupplier;
-
- public SdcSchemaBuilder(SdcSchemaUtils sdcSchemaUtils, Supplier<Configuration.CassandrConfig> cassandraConfigSupplier) {
- this.sdcSchemaUtils = sdcSchemaUtils;
- this.cassandraConfigSupplier = cassandraConfigSupplier;
- }
- /**
- * creat key space statment for SimpleStrategy
- */
- private static final String CREATE_KEYSPACE_SIMPLE_STRATEGY = "CREATE KEYSPACE IF NOT EXISTS %s WITH replication = {'class':'SimpleStrategy', %s};";
- /**
- * creat key space statment for NetworkTopologyStrategy
- */
- private static final String CREATE_KEYSPACE_NETWORK_TOPOLOGY_STRATEGY = "CREATE KEYSPACE IF NOT EXISTS %s WITH replication = {'class':'NetworkTopologyStrategy', %s};";
-
- private static Logger log = Logger.getLogger(SdcSchemaBuilder.class.getName());
-
- //TODO remove after 1707_OS migration
- private static void handle1707OSMigration(Map<String, Map<String, List<String>>> cassndraMetadata, Map<String, List<ITableDescription>> schemeData){
- if(cassndraMetadata.containsKey("attaudit")){
- List<ITableDescription> list = new ArrayList<>();
- list.add(new OldExternalApiEventTableDesc());
- schemeData.put("attaudit", list);
- }
-
- }
- /**
- * the method creates all keyspaces, tables and indexes in case they do not
- * already exist. the method can be run multiple times. the method uses the
- * internal enums and external configuration for its operation *
- * @return true if the create operation was successful
- */
- public boolean createSchema() {
- try(Cluster cluster = sdcSchemaUtils.createCluster();
- Session session = cluster.connect()) {
- log.info("creating Schema for Cassandra.");
- List<KeyspaceMetadata> keyspacesMetadateFromCassandra = cluster.getMetadata().getKeyspaces();
- if (keyspacesMetadateFromCassandra == null) {
- log.debug("filed to retrieve a list of keyspaces from cassandra");
- return false;
- }
- log.debug("retrieved Cassandra metadata.");
- Map<String, Map<String, List<String>>> cassndraMetadata = parseKeyspaceMetadata(keyspacesMetadateFromCassandra);
- Map<String, Map<String, List<String>>> metadataTablesStructure = getMetadataTablesStructure(keyspacesMetadateFromCassandra);
- Map<String, List<ITableDescription>> schemeData = getSchemeData();
- //TODO remove after 1707_OS migration
- handle1707OSMigration(cassndraMetadata, schemeData);
- log.info("creating Keyspaces.");
- for (Map.Entry<String, List<ITableDescription>> keyspace : schemeData.entrySet()) {
- if (!createKeyspace(keyspace.getKey(), cassndraMetadata, session)) {
- return false;
- }
- Map<String, List<String>> keyspaceMetadate = cassndraMetadata.get(keyspace.getKey());
- createTables(keyspace.getValue(), keyspaceMetadate, session,metadataTablesStructure.get(keyspace.getKey()));
- }
- return true;
- } catch (Exception e) {
+ /**
+ * creat key space statment for SimpleStrategy
+ */
+ private static final String CREATE_KEYSPACE_SIMPLE_STRATEGY = "CREATE KEYSPACE IF NOT EXISTS %s WITH replication = {'class':'SimpleStrategy', %s};";
+ /**
+ * creat key space statment for NetworkTopologyStrategy
+ */
+ private static final String CREATE_KEYSPACE_NETWORK_TOPOLOGY_STRATEGY = "CREATE KEYSPACE IF NOT EXISTS %s WITH replication = {'class':'NetworkTopologyStrategy', %s};";
+ private static Logger log = Logger.getLogger(SdcSchemaBuilder.class.getName());
+ private SdcSchemaUtils sdcSchemaUtils;
+ private Supplier<Configuration.CassandrConfig> cassandraConfigSupplier;
+ public SdcSchemaBuilder(SdcSchemaUtils sdcSchemaUtils, Supplier<Configuration.CassandrConfig> cassandraConfigSupplier) {
+ this.sdcSchemaUtils = sdcSchemaUtils;
+ this.cassandraConfigSupplier = cassandraConfigSupplier;
+ }
+
+ //TODO remove after 1707_OS migration
+ private static void handle1707OSMigration(Map<String, Map<String, List<String>>> cassndraMetadata,
+ Map<String, List<ITableDescription>> schemeData) {
+ if (cassndraMetadata.containsKey("attaudit")) {
+ List<ITableDescription> list = new ArrayList<>();
+ list.add(new OldExternalApiEventTableDesc());
+ schemeData.put("attaudit", list);
+ }
+ }
+
+ /**
+ * the method prcess the metadata retrieved from the cassandra for the creation of a map conting the names of keyspaces tabls and indexes already
+ * defined in the cassandra keyspacename -> tablename -> list of indexes info
+ *
+ * @param keyspacesMetadata cassndra mmetadata
+ * @return a map of maps of lists holding parsed info
+ */
+ private static Map<String, Map<String, List<String>>> parseKeyspaceMetadata(List<KeyspaceMetadata> keyspacesMetadata) {
+ return keyspacesMetadata.stream().collect(Collectors.toMap(KeyspaceMetadata::getName,
+ keyspaceMetadata -> keyspaceMetadata.getTables().stream().collect(Collectors.toMap(AbstractTableMetadata::getName,
+ tableMetadata -> tableMetadata.getIndexes().stream().map(IndexMetadata::getName).collect(Collectors.toList())))));
+ }
+
+ private static Map<String, Map<String, List<String>>> getMetadataTablesStructure(List<KeyspaceMetadata> keyspacesMetadata) {
+ return keyspacesMetadata.stream().collect(Collectors.toMap(KeyspaceMetadata::getName,
+ keyspaceMetadata -> keyspaceMetadata.getTables().stream().collect(Collectors.toMap(AbstractTableMetadata::getName,
+ tableMetadata -> tableMetadata.getColumns().stream().map(columnMetadata -> columnMetadata.getName().toLowerCase())
+ .collect(Collectors.toList())))));
+ }
+
+ /**
+ * the method builds an index name according to a defined logic
+ * <table>
+ * _<column>_idx
+ *
+ * @param table: table name
+ * @param column: column name
+ * @return string name of the index
+ */
+ private static String createIndexName(String table, String column) {
+ return table + "_" + column + "_idx";
+ }
+
+ /**
+ * the method creats all the tables and indexes thet do not already exist
+ *
+ * @param iTableDescriptions: a list of table description we want to create
+ * @param keyspaceMetadate: the current tables that exist in the cassandra under this keyspace
+ * @param session: the session object used for the execution of the query.
+ * @param existingTablesMetadata the current tables columns that exist in the cassandra under this keyspace
+ */
+ private static void createTables(List<ITableDescription> iTableDescriptions, Map<String, List<String>> keyspaceMetadate, Session session,
+ Map<String, List<String>> existingTablesMetadata) {
+ for (ITableDescription tableDescription : iTableDescriptions) {
+ String tableName = tableDescription.getTableName().toLowerCase();
+ Map<String, ImmutablePair<DataType, Boolean>> columnDescription = tableDescription.getColumnDescription();
+ log.info("creating tables:{}.", tableName);
+ if (keyspaceMetadate == null || !keyspaceMetadate.keySet().contains(tableName)) {
+ Create create = SchemaBuilder.createTable(tableDescription.getKeyspace(), tableDescription.getTableName());
+ for (ImmutablePair<String, DataType> key : tableDescription.primaryKeys()) {
+ create.addPartitionKey(key.getLeft(), key.getRight());
+ }
+ if (tableDescription.clusteringKeys() != null) {
+ for (ImmutablePair<String, DataType> key : tableDescription.clusteringKeys()) {
+ create.addClusteringColumn(key.getLeft(), key.getRight());
+ }
+ }
+ for (Map.Entry<String, ImmutablePair<DataType, Boolean>> entry : columnDescription.entrySet()) {
+ create.addColumn(entry.getKey(), entry.getValue().getLeft());
+ }
+ log.trace("exacuting :{}", create);
+ session.execute(create);
+ log.info("table:{} created successfully.", tableName);
+ } else {
+ log.info("table:{} already exists, skipping.", tableName);
+ alterTable(session, existingTablesMetadata, tableDescription, tableName, columnDescription);
+ }
+ log.info("keyspacemetadata:{}", keyspaceMetadate);
+ List<String> indexNames = (keyspaceMetadate != null && keyspaceMetadate.get(tableName) != null ? keyspaceMetadate.get(tableName)
+ : new ArrayList<>());
+ log.info("table:{} creating indexes.", tableName);
+ for (Map.Entry<String, ImmutablePair<DataType, Boolean>> description : columnDescription.entrySet()) {
+ String indexName = createIndexName(tableName, description.getKey()).toLowerCase();
+ if (description.getValue().getRight()) {
+ if (!indexNames.contains(indexName)) {
+ SchemaStatement creatIndex = SchemaBuilder.createIndex(indexName).onTable(tableDescription.getKeyspace(), tableName)
+ .andColumn(description.getKey());
+ log.info("executing :{}", creatIndex);
+ session.execute(creatIndex);
+ log.info("index:{} created successfully.", indexName);
+ } else {
+ log.info("index:{} already exists, skipping.", indexName);
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * check if there are new columns that were added to definition but don't exist in DB
+ *
+ * @param session
+ * @param existingTablesMetadata
+ * @param tableDescription
+ * @param tableName
+ * @param columnDescription
+ */
+ private static void alterTable(Session session, Map<String, List<String>> existingTablesMetadata, ITableDescription tableDescription,
+ String tableName, Map<String, ImmutablePair<DataType, Boolean>> columnDescription) {
+ List<String> definedTableColumns = existingTablesMetadata.get(tableName);
+ //add column to casandra if was added to table definition
+ for (Map.Entry<String, ImmutablePair<DataType, Boolean>> column : columnDescription.entrySet()) {
+ String columnName = column.getKey();
+ if (!definedTableColumns.contains(columnName.toLowerCase())) {
+ log.info("Adding new column {} to the table {}", columnName, tableName);
+ Alter alter = SchemaBuilder.alterTable(tableDescription.getKeyspace(), tableDescription.getTableName());
+ SchemaStatement addColumn = alter.addColumn(columnName).type(column.getValue().getLeft());
+ log.trace("executing :{}", addColumn);
+ session.execute(addColumn);
+ }
+ }
+ }
+
+ private static boolean createKeyspaceIfNotExists(String keyspace, Session session,
+ List<Configuration.CassandrConfig.KeyspaceConfig> keyspaceConfigList) {
+ Optional<Configuration.CassandrConfig.KeyspaceConfig> keyspaceConfig = keyspaceConfigList.stream()
+ .filter(keyspaceInfo -> keyspace.equalsIgnoreCase(keyspaceInfo.getName())).findFirst();
+ if (keyspaceConfig.isPresent()) {
+ return createKeyspaceWhenConfigExists(keyspace, session, keyspaceConfig.get());
+ }
+ log.info("keyspace:{} not present in configuration, no info on replications is available. Operation failed.", keyspace);
+ return false;
+ }
+
+ private static boolean createKeyspaceWhenConfigExists(String keyspace, Session session,
+ Configuration.CassandrConfig.KeyspaceConfig keyspaceConfig) {
+ String createKeyspaceQuery = createKeyspaceQuereyString(keyspace, keyspaceConfig);
+ if (createKeyspaceQuery != null) {
+ log.trace("executing: {}", createKeyspaceQuery);
+ session.execute(createKeyspaceQuery);
+ log.info("keyspace:{} created.", keyspace);
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * the method retries the schem info from the enums describing the tables
+ *
+ * @return a map of keyspaces to there table info
+ */
+ private static Map<String, List<ITableDescription>> getSchemeData() {
+ Map<String, List<ITableDescription>> tablesByKeyspace = new HashMap<>();
+ Table[] tables = Table.values();
+ for (Table table : tables) {
+ String keyspace = table.getTableDescription().getKeyspace().toLowerCase();
+ List<ITableDescription> list = tablesByKeyspace.get(keyspace);
+ if (list == null) {
+ list = new ArrayList<>();
+ }
+ list.add(table.getTableDescription());
+ tablesByKeyspace.put(keyspace, list);
+ }
+ return tablesByKeyspace;
+ }
+
+ /**
+ * the methoed creates the query string for the given keyspace the methoed valides the given data according the the requirments of the replication
+ * strategy SimpleStrategy: "CREATE KEYSPACE IF NOT EXISTS
+ * <keyspaceName></keyspaceName> WITH replication =
+ * {'class':'SimpleStrategy', 'replication_factor':2};" SimpleStrategy: "CREATE KEYSPACE IF NOT EXISTS <keyspaceName></keyspaceName> WITH
+ * replication = {'class':'NetworkTopologyStrategy', 'dc1' : 2 ,dc2 : 2 };"
+ *
+ * @param keyspace name of the keyspace we want to create
+ * @param keyspaceInfo configuration info regurding the replication of the keyspace
+ * @return a querey string for the creation of the keyspace
+ */
+ private static String createKeyspaceQuereyString(String keyspace, Configuration.CassandrConfig.KeyspaceConfig keyspaceInfo) {
+ String query = null;
+ if (ReplicationStrategy.NETWORK_TOPOLOGY_STRATEGY.getStrategyName().equalsIgnoreCase(keyspaceInfo.getReplicationStrategy())) {
+ query = createNetworkTopologyStrategy(keyspaceInfo, keyspace);
+ } else if (ReplicationStrategy.SIMPLE_STRATEGY.getStrategyName().equalsIgnoreCase(keyspaceInfo.getReplicationStrategy())) {
+ query = createSimpleStrategyQuery(keyspaceInfo, keyspace);
+ } else {
+ log.error("the supplied replication Strategy is invalid; expected {}/{}, received:{}",
+ ReplicationStrategy.NETWORK_TOPOLOGY_STRATEGY.getStrategyName(), ReplicationStrategy.SIMPLE_STRATEGY.getStrategyName(),
+ keyspaceInfo.getReplicationStrategy());
+ }
+ return query;
+ }
+
+ private static String createNetworkTopologyStrategy(Configuration.CassandrConfig.KeyspaceConfig keyspaceInfo, String keyspace) {
+ String query = null;
+ List<String> dcList = keyspaceInfo.getReplicationInfo();
+ if (dcList.size() % 2 != 0) {
+ log.error("the supplied replication info is invalid; expected dc1,2,dc2,2 etc, received:{}", dcList);
+ } else {
+ StringBuilder sb = new StringBuilder();
+ for (int i = 0; i < dcList.size(); i = i + 2) {
+ sb.append("'").append(dcList.get(i)).append("'").append(" : ").append(dcList.get(i + 1));
+ if (i + 2 < dcList.size()) {
+ sb.append(",");
+ }
+ }
+ query = String.format(CREATE_KEYSPACE_NETWORK_TOPOLOGY_STRATEGY, keyspace, sb.toString());
+ }
+ return query;
+ }
+
+ private static String createSimpleStrategyQuery(Configuration.CassandrConfig.KeyspaceConfig keyspaceInfo, String keyspace) {
+ String query = null;
+ List<String> dcList = keyspaceInfo.getReplicationInfo();
+ if (dcList.size() != 1) {
+ log.error("the supplied replication info is invalid; expected <number>, received:{}", dcList);
+ } else {
+ query = String.format(CREATE_KEYSPACE_SIMPLE_STRATEGY, keyspace, "'replication_factor'" + " : " + dcList.get(0));
+ }
+ return query;
+ }
+
+ /**
+ * the method creates all keyspaces, tables and indexes in case they do not already exist. the method can be run multiple times. the method uses
+ * the internal enums and external configuration for its operation *
+ *
+ * @return true if the create operation was successful
+ */
+ public boolean createSchema() {
+ try (Cluster cluster = sdcSchemaUtils.createCluster(); Session session = cluster.connect()) {
+ log.info("creating Schema for Cassandra.");
+ List<KeyspaceMetadata> keyspacesMetadateFromCassandra = cluster.getMetadata().getKeyspaces();
+ if (keyspacesMetadateFromCassandra == null) {
+ log.debug("filed to retrieve a list of keyspaces from cassandra");
+ return false;
+ }
+ log.debug("retrieved Cassandra metadata.");
+ Map<String, Map<String, List<String>>> cassndraMetadata = parseKeyspaceMetadata(keyspacesMetadateFromCassandra);
+ Map<String, Map<String, List<String>>> metadataTablesStructure = getMetadataTablesStructure(keyspacesMetadateFromCassandra);
+ Map<String, List<ITableDescription>> schemeData = getSchemeData();
+ //TODO remove after 1707_OS migration
+ handle1707OSMigration(cassndraMetadata, schemeData);
+ log.info("creating Keyspaces.");
+ for (Map.Entry<String, List<ITableDescription>> keyspace : schemeData.entrySet()) {
+ if (!createKeyspace(keyspace.getKey(), cassndraMetadata, session)) {
+ return false;
+ }
+ Map<String, List<String>> keyspaceMetadate = cassndraMetadata.get(keyspace.getKey());
+ createTables(keyspace.getValue(), keyspaceMetadate, session, metadataTablesStructure.get(keyspace.getKey()));
+ }
+ return true;
+ } catch (Exception e) {
log.error(EcompLoggerErrorCode.SCHEMA_ERROR, "creating Schema for Cassandra", "Cassandra", e.getLocalizedMessage());
return false;
}
- }
-
- public boolean deleteSchema() {
- boolean res = false;
- try(Cluster cluster = sdcSchemaUtils.createCluster();
- Session session = cluster.connect()) {
- log.info("delete Data from Cassandra.");
- List<KeyspaceMetadata> keyspacesMetadateFromCassandra = cluster.getMetadata().getKeyspaces();
- if (keyspacesMetadateFromCassandra == null) {
- log.debug("filed to retrieve a list of keyspaces from cassandra");
- return false;
- }
- log.debug("retrieved Cassandra metadata.");
- Map<String, Map<String, List<String>>> cassndraMetadata = parseKeyspaceMetadata(keyspacesMetadateFromCassandra);
- log.info("Cassandra Metadata: {}" ,cassndraMetadata);
- cassndraMetadata.forEach((k, v) -> {
- if (AuditingTypesConstants.janusGraph_KEYSPACE.equals(k)) {
- // session.execute("")
- } else if (AuditingTypesConstants.ARTIFACT_KEYSPACE.equals(k)) {
-
- } else if (AuditingTypesConstants.AUDIT_KEYSPACE.equals(k)) {
-
- }
- });
-
- System.out.println(cassndraMetadata);
- res = true;
- } catch (Exception e) {
+ }
+
+ public boolean deleteSchema() {
+ boolean res = false;
+ try (Cluster cluster = sdcSchemaUtils.createCluster(); Session session = cluster.connect()) {
+ log.info("delete Data from Cassandra.");
+ List<KeyspaceMetadata> keyspacesMetadateFromCassandra = cluster.getMetadata().getKeyspaces();
+ if (keyspacesMetadateFromCassandra == null) {
+ log.debug("filed to retrieve a list of keyspaces from cassandra");
+ return false;
+ }
+ log.debug("retrieved Cassandra metadata.");
+ Map<String, Map<String, List<String>>> cassndraMetadata = parseKeyspaceMetadata(keyspacesMetadateFromCassandra);
+ log.info("Cassandra Metadata: {}", cassndraMetadata);
+ cassndraMetadata.forEach((k, v) -> {
+ if (AuditingTypesConstants.janusGraph_KEYSPACE.equals(k)) {
+ // session.execute("")
+ } else if (AuditingTypesConstants.ARTIFACT_KEYSPACE.equals(k)) {
+ } else if (AuditingTypesConstants.AUDIT_KEYSPACE.equals(k)) {
+ }
+ });
+ System.out.println(cassndraMetadata);
+ res = true;
+ } catch (Exception e) {
log.error(EcompLoggerErrorCode.SCHEMA_ERROR, "deleting Schema for Cassandra", "Cassandra", e.getLocalizedMessage());
- }
- return res;
- }
-
- /**
- * the method prcess the metadata retrieved from the cassandra for the
- * creation of a map conting the names of keyspaces tabls and indexes
- * already defined in the cassandra keyspacename -> tablename -> list of
- * indexes info
- *
- * @param keyspacesMetadata
- * cassndra mmetadata
- * @return a map of maps of lists holding parsed info
- */
- private static Map<String, Map<String, List<String>>> parseKeyspaceMetadata(List<KeyspaceMetadata> keyspacesMetadata) {
- return keyspacesMetadata.stream()
- .collect(Collectors.toMap(KeyspaceMetadata::getName, keyspaceMetadata -> keyspaceMetadata.getTables()
- .stream()
- .collect(Collectors.toMap(AbstractTableMetadata::getName, tableMetadata -> tableMetadata.getIndexes()
- .stream()
- .map(IndexMetadata::getName)
- .collect(Collectors.toList())))));
- }
-
- private static Map<String, Map<String, List<String>>> getMetadataTablesStructure(
- List<KeyspaceMetadata> keyspacesMetadata) {
- return keyspacesMetadata.stream()
- .collect(Collectors.toMap(KeyspaceMetadata::getName, keyspaceMetadata -> keyspaceMetadata.getTables()
- .stream()
- .collect(Collectors.toMap(AbstractTableMetadata::getName, tableMetadata -> tableMetadata.getColumns()
- .stream()
- .map(columnMetadata -> columnMetadata.getName().toLowerCase())
- .collect(Collectors.toList())))));
- }
-
- /**
- * the method builds an index name according to a defined logic
- * <table>
- * _<column>_idx
- *
- * @param table: table name
- * @param column: column name
- * @return string name of the index
- */
- private static String createIndexName(String table, String column) {
- return table + "_" + column + "_idx";
- }
-
- /**
- * the method creats all the tables and indexes thet do not already exist
- *
- * @param iTableDescriptions: a list of table description we want to create
- * @param keyspaceMetadate: the current tables that exist in the cassandra under this keyspace
- * @param session: the session object used for the execution of the query.
- * @param existingTablesMetadata
- * the current tables columns that exist in the cassandra under this
- * keyspace
- */
- private static void createTables(List<ITableDescription> iTableDescriptions, Map<String, List<String>> keyspaceMetadate, Session session,
- Map<String, List<String>> existingTablesMetadata) {
- for (ITableDescription tableDescription : iTableDescriptions) {
- String tableName = tableDescription.getTableName().toLowerCase();
- Map<String, ImmutablePair<DataType, Boolean>> columnDescription = tableDescription.getColumnDescription();
- log.info("creating tables:{}.", tableName);
- if (keyspaceMetadate == null || !keyspaceMetadate.keySet().contains(tableName)) {
- Create create = SchemaBuilder.createTable(tableDescription.getKeyspace(),tableDescription.getTableName());
- for (ImmutablePair<String, DataType> key : tableDescription.primaryKeys()) {
- create.addPartitionKey(key.getLeft(), key.getRight());
- }
- if (tableDescription.clusteringKeys() != null) {
- for (ImmutablePair<String, DataType> key : tableDescription.clusteringKeys()) {
- create.addClusteringColumn(key.getLeft(), key.getRight());
- }
- }
-
- for (Map.Entry<String, ImmutablePair<DataType, Boolean>> entry : columnDescription.entrySet()) {
- create.addColumn(entry.getKey(), entry.getValue().getLeft());
- }
-
- log.trace("exacuting :{}", create);
- session.execute(create);
- log.info("table:{} created successfully.", tableName);
- } else {
- log.info("table:{} already exists, skipping.", tableName);
- alterTable(session, existingTablesMetadata, tableDescription, tableName, columnDescription);
- }
- log.info("keyspacemetadata:{}",keyspaceMetadate);
- List<String> indexNames = (keyspaceMetadate != null && keyspaceMetadate.get(tableName) != null ? keyspaceMetadate.get(tableName) : new ArrayList<>());
- log.info("table:{} creating indexes.", tableName);
- for (Map.Entry<String, ImmutablePair<DataType, Boolean>> description : columnDescription.entrySet()) {
- String indexName = createIndexName(tableName, description.getKey()).toLowerCase();
- if (description.getValue().getRight()) {
- if (!indexNames.contains(indexName)) {
- SchemaStatement creatIndex = SchemaBuilder.createIndex(indexName)
- .onTable(tableDescription.getKeyspace(), tableName).andColumn(description.getKey());
- log.info("executing :{}", creatIndex);
- session.execute(creatIndex);
- log.info("index:{} created successfully.", indexName);
- } else {
- log.info("index:{} already exists, skipping.", indexName);
- }
- }
- }
-
-
- }
- }
-
- /**
- * check if there are new columns that were added to definition but don't exist in DB
- * @param session
- * @param existingTablesMetadata
- * @param tableDescription
- * @param tableName
- * @param columnDescription
- */
- private static void alterTable(Session session, Map<String, List<String>> existingTablesMetadata,
- ITableDescription tableDescription, String tableName,
- Map<String, ImmutablePair<DataType, Boolean>> columnDescription) {
- List<String> definedTableColumns = existingTablesMetadata.get(tableName);
- //add column to casandra if was added to table definition
- for (Map.Entry<String, ImmutablePair<DataType, Boolean>> column : columnDescription.entrySet()) {
- String columnName = column.getKey();
- if (!definedTableColumns.contains(columnName.toLowerCase())){
- log.info("Adding new column {} to the table {}", columnName,tableName);
- Alter alter = SchemaBuilder.alterTable(tableDescription.getKeyspace(),tableDescription.getTableName());
- SchemaStatement addColumn = alter.addColumn(columnName).type(column.getValue().getLeft());
- log.trace("executing :{}", addColumn);
- session.execute(addColumn);
- }
- }
- }
-
- /**
- * the method create the keyspace in case it does not already exists the
- * method uses configurtion to select the needed replication strategy
- *
- * @param keyspace: name of the keyspace we want to create
- * @param cassndraMetadata: cassndra metadata
- * @param session: the session object used for the execution of the query.
- * @return true in case the operation was successful
- */
- private boolean createKeyspace(String keyspace, Map<String, Map<String, List<String>>> cassndraMetadata, Session session) {
- List<Configuration.CassandrConfig.KeyspaceConfig> keyspaceConfigList = cassandraConfigSupplier.get().getKeySpaces();
- log.info("creating keyspace:{}.", keyspace);
- if (!cassndraMetadata.keySet().contains(keyspace)) {
- return createKeyspaceIfNotExists(keyspace, session, keyspaceConfigList);
- }
- log.info("keyspace:{} already exists, skipping.", keyspace);
- return true;
- }
-
- private static boolean createKeyspaceIfNotExists(String keyspace, Session session, List<Configuration.CassandrConfig.KeyspaceConfig> keyspaceConfigList) {
- Optional<Configuration.CassandrConfig.KeyspaceConfig> keyspaceConfig = keyspaceConfigList.stream().filter(keyspaceInfo -> keyspace.equalsIgnoreCase(keyspaceInfo.getName())).findFirst();
- if (keyspaceConfig.isPresent()) {
- return createKeyspaceWhenConfigExists(keyspace, session, keyspaceConfig.get());
- }
- log.info("keyspace:{} not present in configuration, no info on replications is available. Operation failed.", keyspace);
- return false;
- }
-
- private static boolean createKeyspaceWhenConfigExists(String keyspace, Session session, Configuration.CassandrConfig.KeyspaceConfig keyspaceConfig) {
- String createKeyspaceQuery = createKeyspaceQuereyString(keyspace, keyspaceConfig);
- if (createKeyspaceQuery != null) {
- log.trace("executing: {}", createKeyspaceQuery);
- session.execute(createKeyspaceQuery);
- log.info("keyspace:{} created.", keyspace);
- return true;
- }
- return false;
- }
-
- /**
- * the method retries the schem info from the enums describing the tables
- *
- * @return a map of keyspaces to there table info
- */
- private static Map<String, List<ITableDescription>> getSchemeData() {
- Map<String, List<ITableDescription>> tablesByKeyspace = new HashMap<>();
- Table[] tables = Table.values();
- for (Table table : tables) {
- String keyspace = table.getTableDescription().getKeyspace().toLowerCase();
- List<ITableDescription> list = tablesByKeyspace.get(keyspace);
- if (list == null) {
- list = new ArrayList<>();
- }
- list.add(table.getTableDescription());
- tablesByKeyspace.put(keyspace, list);
- }
- return tablesByKeyspace;
- }
-
- /**
- * the methoed creates the query string for the given keyspace the methoed
- * valides the given data according the the requirments of the replication
- * strategy SimpleStrategy: "CREATE KEYSPACE IF NOT EXISTS
- * <keyspaceName></keyspaceName> WITH replication =
- * {'class':'SimpleStrategy', 'replication_factor':2};" SimpleStrategy:
- * "CREATE KEYSPACE IF NOT EXISTS <keyspaceName></keyspaceName> WITH
- * replication = {'class':'NetworkTopologyStrategy', 'dc1' : 2 ,dc2 : 2 };"
- *
- * @param keyspace
- * name of the keyspace we want to create
- * @param keyspaceInfo
- * configuration info regurding the replication of the keyspace
- * @return a querey string for the creation of the keyspace
- */
- private static String createKeyspaceQuereyString(String keyspace, Configuration.CassandrConfig.KeyspaceConfig keyspaceInfo) {
- String query = null;
- if (ReplicationStrategy.NETWORK_TOPOLOGY_STRATEGY.getStrategyName().equalsIgnoreCase(keyspaceInfo.getReplicationStrategy())) {
- query = createNetworkTopologyStrategy(keyspaceInfo, keyspace);
- } else if (ReplicationStrategy.SIMPLE_STRATEGY.getStrategyName().equalsIgnoreCase(keyspaceInfo.getReplicationStrategy())) {
- query = createSimpleStrategyQuery(keyspaceInfo, keyspace);
- } else {
- log.error("the supplied replication Strategy is invalid; expected {}/{}, received:{}",
- ReplicationStrategy.NETWORK_TOPOLOGY_STRATEGY.getStrategyName(),
- ReplicationStrategy.SIMPLE_STRATEGY.getStrategyName(), keyspaceInfo.getReplicationStrategy());
- }
- return query;
- }
-
- private static String createNetworkTopologyStrategy(Configuration.CassandrConfig.KeyspaceConfig keyspaceInfo, String keyspace) {
- String query = null;
- List<String> dcList = keyspaceInfo.getReplicationInfo();
- if (dcList.size() % 2 != 0) {
- log.error("the supplied replication info is invalid; expected dc1,2,dc2,2 etc, received:{}", dcList);
-
- } else {
- StringBuilder sb = new StringBuilder();
- for (int i = 0; i < dcList.size(); i = i + 2) {
- sb.append("'").append(dcList.get(i)).append("'").append(" : ").append(dcList.get(i + 1));
- if (i + 2 < dcList.size()) {
- sb.append(",");
- }
- }
- query = String.format(CREATE_KEYSPACE_NETWORK_TOPOLOGY_STRATEGY, keyspace, sb.toString());
- }
-
- return query;
- }
- private static String createSimpleStrategyQuery(Configuration.CassandrConfig.KeyspaceConfig keyspaceInfo, String keyspace) {
- String query = null;
- List<String> dcList = keyspaceInfo.getReplicationInfo();
- if (dcList.size() != 1) {
- log.error("the supplied replication info is invalid; expected <number>, received:{}", dcList);
-
- } else {
- query = String.format(CREATE_KEYSPACE_SIMPLE_STRATEGY, keyspace, "'replication_factor'" + " : " + dcList.get(0));
- }
- return query;
- }
-
- @AllArgsConstructor
- public enum ReplicationStrategy {
- NETWORK_TOPOLOGY_STRATEGY("NetworkTopologyStrategy"), SIMPLE_STRATEGY("SimpleStrategy");
-
- @Getter
- private final String strategyName;
- }
-
+ }
+ return res;
+ }
+
+ /**
+ * the method create the keyspace in case it does not already exists the method uses configurtion to select the needed replication strategy
+ *
+ * @param keyspace: name of the keyspace we want to create
+ * @param cassndraMetadata: cassndra metadata
+ * @param session: the session object used for the execution of the query.
+ * @return true in case the operation was successful
+ */
+ private boolean createKeyspace(String keyspace, Map<String, Map<String, List<String>>> cassndraMetadata, Session session) {
+ List<Configuration.CassandrConfig.KeyspaceConfig> keyspaceConfigList = cassandraConfigSupplier.get().getKeySpaces();
+ log.info("creating keyspace:{}.", keyspace);
+ if (!cassndraMetadata.keySet().contains(keyspace)) {
+ return createKeyspaceIfNotExists(keyspace, session, keyspaceConfigList);
+ }
+ log.info("keyspace:{} already exists, skipping.", keyspace);
+ return true;
+ }
+
+ @AllArgsConstructor
+ public enum ReplicationStrategy {
+ NETWORK_TOPOLOGY_STRATEGY("NetworkTopologyStrategy"), SIMPLE_STRATEGY("SimpleStrategy");
+ @Getter
+ private final String strategyName;
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/SdcSchemaUtils.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/SdcSchemaUtils.java
index 862e2adcc0..f6e60ece01 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/SdcSchemaUtils.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/SdcSchemaUtils.java
@@ -7,9 +7,9 @@
* 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.
@@ -28,41 +28,34 @@ import com.datastax.driver.core.SocketOptions;
import com.datastax.driver.core.policies.DCAwareRoundRobinPolicy;
import com.datastax.driver.core.policies.LoadBalancingPolicy;
import com.datastax.driver.core.policies.TokenAwarePolicy;
+import java.util.List;
+import java.util.function.Supplier;
import org.openecomp.sdc.be.config.Configuration;
import org.openecomp.sdc.be.config.ConfigurationManager;
import org.openecomp.sdc.common.log.wrappers.Logger;
-import java.util.List;
-import java.util.function.Supplier;
-
public class SdcSchemaUtils {
private static Logger log = Logger.getLogger(SdcSchemaUtils.class.getName());
private Cluster cluster;
- private boolean isConnected;
-
-
+ private boolean isConnected;
public SdcSchemaUtils() {
super();
try {
isConnected = false;
- cluster = createCluster();
+ cluster = createCluster();
isConnected = true;
} catch (Exception e) {
log.info("** CassandraClient isn't connected. error is", e);
}
-
log.info("** cluster created");
}
/**
- * the method creates the cluster object using the supplied cassandra nodes
- * in the configuration
+ * the method creates the cluster object using the supplied cassandra nodes in the configuration
*
* @return cluster object our null in case of an invalid configuration
- *
- *
*/
public Cluster createCluster() {
final Configuration.CassandrConfig config = getCassandraConfig();
@@ -75,62 +68,53 @@ public class SdcSchemaUtils {
log.info("Connecting to node: {} port: {}.", nodes, cassandraPort);
Cluster.Builder clusterBuilder = Cluster.builder();
nodes.forEach(node -> clusterBuilder.addContactPoint(node).withPort(cassandraPort));
-
log.info("Connection timeout in seconds : {}", config.getMaxWaitSeconds());
clusterBuilder.withMaxSchemaAgreementWaitSeconds(config.getMaxWaitSeconds());
-
setSocketOptions(clusterBuilder, config);
if (!enableAuthentication(clusterBuilder, config)) {
return null;
}
-
if (!enableSsl(clusterBuilder, config)) {
return null;
}
setLocalDc(clusterBuilder, config);
-
return clusterBuilder.build();
}
-
+
/**
- *
* @return
*/
- public Session connect() {
+ public Session connect() {
Session session = null;
if (cluster != null) {
try {
session = cluster.connect();
-
} catch (Throwable e) {
- log.debug("Failed to connect cluster, error :", e);
-
+ log.debug("Failed to connect cluster, error :", e);
}
}
return session;
}
-
- public Metadata getMetadata(){
- if (cluster != null){
+
+ public Metadata getMetadata() {
+ if (cluster != null) {
return cluster.getMetadata();
}
return null;
}
-
+
private void setLocalDc(Cluster.Builder clusterBuilder, Configuration.CassandrConfig config) {
String localDataCenter = config.getLocalDataCenter();
if (localDataCenter != null) {
- log.info("localDatacenter was provided, setting Cassndra clint to use datacenter: {} as local.",
- localDataCenter);
- LoadBalancingPolicy tokenAwarePolicy = new TokenAwarePolicy(
- DCAwareRoundRobinPolicy.builder().withLocalDc(localDataCenter).build());
+ log.info("localDatacenter was provided, setting Cassndra clint to use datacenter: {} as local.", localDataCenter);
+ LoadBalancingPolicy tokenAwarePolicy = new TokenAwarePolicy(DCAwareRoundRobinPolicy.builder().withLocalDc(localDataCenter).build());
clusterBuilder.withLoadBalancingPolicy(tokenAwarePolicy);
} else {
log.info(
- "localDatacenter was provided, the driver will use the datacenter of the first contact point that was reached at initialization");
+ "localDatacenter was provided, the driver will use the datacenter of the first contact point that was reached at initialization");
}
}
-
+
private boolean enableSsl(Cluster.Builder clusterBuilder, Configuration.CassandrConfig config) {
boolean ssl = config.isSsl();
if (ssl) {
@@ -144,7 +128,6 @@ public class SdcSchemaUtils {
System.setProperty("javax.net.ssl.trustStorePassword", truststorePassword);
clusterBuilder.withSSL();
}
-
}
return true;
}
@@ -153,23 +136,19 @@ public class SdcSchemaUtils {
SocketOptions socketOptions = new SocketOptions();
Integer socketConnectTimeout = config.getSocketConnectTimeout();
if (socketConnectTimeout != null) {
- log.info("SocketConnectTimeout was provided, setting Cassandra client to use SocketConnectTimeout: {} .",
- socketConnectTimeout);
+ log.info("SocketConnectTimeout was provided, setting Cassandra client to use SocketConnectTimeout: {} .", socketConnectTimeout);
socketOptions.setConnectTimeoutMillis(socketConnectTimeout);
}
-
Integer socketReadTimeout = config.getSocketReadTimeout();
if (socketReadTimeout != null) {
- log.info("SocketReadTimeout was provided, setting Cassandra client to use SocketReadTimeout: {} .",
- socketReadTimeout);
+ log.info("SocketReadTimeout was provided, setting Cassandra client to use SocketReadTimeout: {} .", socketReadTimeout);
socketOptions.setReadTimeoutMillis(socketReadTimeout);
}
clusterBuilder.withSocketOptions(socketOptions);
}
-
+
private boolean enableAuthentication(Cluster.Builder clusterBuilder, Configuration.CassandrConfig config) {
boolean authenticate = config.isAuthenticate();
-
if (authenticate) {
String username = config.getUsername();
String password = config.getPassword();
@@ -179,7 +158,6 @@ public class SdcSchemaUtils {
} else {
clusterBuilder.withCredentials(username, password);
}
-
}
return true;
}
@@ -188,7 +166,7 @@ public class SdcSchemaUtils {
return executeStatement(this::createCluster, statement);
}
- public boolean executeStatements(String ... statements) {
+ public boolean executeStatements(String... statements) {
return executeStatements(this::createCluster, statements);
}
@@ -196,9 +174,8 @@ public class SdcSchemaUtils {
return executeStatements(clusterSupplier, statement);
}
- boolean executeStatements(Supplier<Cluster> clusterSupplier, String ... statements) {
- try(Cluster cluster = clusterSupplier.get();
- Session session = cluster.connect()) {
+ boolean executeStatements(Supplier<Cluster> clusterSupplier, String... statements) {
+ try (Cluster cluster = clusterSupplier.get(); Session session = cluster.connect()) {
for (String statement : statements) {
session.execute(statement);
}
@@ -212,13 +189,11 @@ public class SdcSchemaUtils {
Configuration.CassandrConfig getCassandraConfig() {
return ConfigurationManager.getConfigurationManager().getConfiguration().getCassandraConfig();
}
-
-
+
public void closeCluster() {
if (isConnected) {
cluster.close();
}
log.info("** CassandraClient cluster closed");
}
-
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/Table.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/Table.java
index a11bcb3881..4c3c8fab2d 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/Table.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/Table.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,13 +17,31 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.cassandra.schema;
-import org.openecomp.sdc.be.dao.cassandra.schema.tables.*;
+import org.openecomp.sdc.be.dao.cassandra.schema.tables.ArtifactTableDescription;
+import org.openecomp.sdc.be.dao.cassandra.schema.tables.AuthEventTableDescription;
+import org.openecomp.sdc.be.dao.cassandra.schema.tables.CategoryEventTableDescription;
+import org.openecomp.sdc.be.dao.cassandra.schema.tables.DistribDeployEventTableDesc;
+import org.openecomp.sdc.be.dao.cassandra.schema.tables.DistribDownloadEventTableDesc;
+import org.openecomp.sdc.be.dao.cassandra.schema.tables.DistribEngineEventTableDesc;
+import org.openecomp.sdc.be.dao.cassandra.schema.tables.DistribNotifEventTableDesc;
+import org.openecomp.sdc.be.dao.cassandra.schema.tables.DistribStatusEventTableDesc;
+import org.openecomp.sdc.be.dao.cassandra.schema.tables.EcompOperationalEnvironmentEventTableDesc;
+import org.openecomp.sdc.be.dao.cassandra.schema.tables.ExternalApiEventTableDesc;
+import org.openecomp.sdc.be.dao.cassandra.schema.tables.FeatureToggleEventTableDesc;
+import org.openecomp.sdc.be.dao.cassandra.schema.tables.GetCatHierEventTableDesc;
+import org.openecomp.sdc.be.dao.cassandra.schema.tables.GetUebClusterEventTableDesc;
+import org.openecomp.sdc.be.dao.cassandra.schema.tables.GetUsersListEventTableDesc;
+import org.openecomp.sdc.be.dao.cassandra.schema.tables.MigrationTasksTableDescription;
+import org.openecomp.sdc.be.dao.cassandra.schema.tables.OperationalEnvironmentsTableDescription;
+import org.openecomp.sdc.be.dao.cassandra.schema.tables.ResAdminEventTableDescription;
+import org.openecomp.sdc.be.dao.cassandra.schema.tables.SdcSchemaFilesTableDescription;
+import org.openecomp.sdc.be.dao.cassandra.schema.tables.UserAccessEventTableDescription;
+import org.openecomp.sdc.be.dao.cassandra.schema.tables.UserAdminEventTableDescription;
public enum Table {
-
+ // @formatter:off
ARTIFACT(new ArtifactTableDescription()),
USER_ADMIN_EVENT(new UserAdminEventTableDescription()),
USER_ACCESS_EVENT(new UserAccessEventTableDescription()),
@@ -44,15 +62,15 @@ public enum Table {
SDC_OPERATIONAL_ENVIRONMENT(new OperationalEnvironmentsTableDescription()),
AUDIT_ECOMP_OPERATIONAL_ENVIRONMENT(new EcompOperationalEnvironmentEventTableDesc()),
FEATURE_TOGGLE_STATE(new FeatureToggleEventTableDesc());
+ // @formatter:on
- ITableDescription tableDescription;
-
- Table(ITableDescription tableDescription) {
- this.tableDescription = tableDescription;
- }
+ ITableDescription tableDescription;
- public ITableDescription getTableDescription() {
- return tableDescription;
- }
+ Table(ITableDescription tableDescription) {
+ this.tableDescription = tableDescription;
+ }
+ public ITableDescription getTableDescription() {
+ return tableDescription;
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/ArtifactTableDescription.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/ArtifactTableDescription.java
index 128fd9db65..eb0aac5626 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/ArtifactTableDescription.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/ArtifactTableDescription.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,64 +17,58 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.cassandra.schema.tables;
import com.datastax.driver.core.DataType;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.openecomp.sdc.be.dao.cassandra.schema.ITableDescription;
import org.openecomp.sdc.be.resources.data.auditing.AuditingTypesConstants;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
public class ArtifactTableDescription implements ITableDescription {
- @Override
- public List<ImmutablePair<String, DataType>> primaryKeys() {
- List<ImmutablePair<String, DataType>> keys = new ArrayList<>();
- keys.add(new ImmutablePair<>(ID_FIELD, DataType.varchar()));
- return keys;
- }
-
- @Override
- public Map<String, ImmutablePair<DataType, Boolean>> getColumnDescription() {
- Map<String, ImmutablePair<DataType, Boolean>> columns = new HashMap<>();
-
- for (ArtifactFieldsDescription field : ArtifactFieldsDescription.values()) {
- columns.put(field.getName(), new ImmutablePair<>(field.type, field.indexed));
- }
-
- return columns;
- }
-
- @Override
- public String getKeyspace() {
- return AuditingTypesConstants.ARTIFACT_KEYSPACE;
- }
+ @Override
+ public List<ImmutablePair<String, DataType>> primaryKeys() {
+ List<ImmutablePair<String, DataType>> keys = new ArrayList<>();
+ keys.add(new ImmutablePair<>(ID_FIELD, DataType.varchar()));
+ return keys;
+ }
- @Override
- public String getTableName() {
- return "resources";
- }
+ @Override
+ public Map<String, ImmutablePair<DataType, Boolean>> getColumnDescription() {
+ Map<String, ImmutablePair<DataType, Boolean>> columns = new HashMap<>();
+ for (ArtifactFieldsDescription field : ArtifactFieldsDescription.values()) {
+ columns.put(field.getName(), new ImmutablePair<>(field.type, field.indexed));
+ }
+ return columns;
+ }
- @Getter
- @AllArgsConstructor
- enum ArtifactFieldsDescription {
- DATA("data", DataType.blob(), false);
+ @Override
+ public String getKeyspace() {
+ return AuditingTypesConstants.ARTIFACT_KEYSPACE;
+ }
- private final String name;
- private final DataType type;
- private final boolean indexed;
+ @Override
+ public String getTableName() {
+ return "resources";
+ }
- }
+ @Override
+ public List<ImmutablePair<String, DataType>> clusteringKeys() {
+ return null;
+ }
- @Override
- public List<ImmutablePair<String, DataType>> clusteringKeys() {
- return null;
- }
+ @Getter
+ @AllArgsConstructor
+ enum ArtifactFieldsDescription {
+ DATA("data", DataType.blob(), false);
+ private final String name;
+ private final DataType type;
+ private final boolean indexed;
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/AuthEventTableDescription.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/AuthEventTableDescription.java
index a2b6534897..db35d864d7 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/AuthEventTableDescription.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/AuthEventTableDescription.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,73 +17,62 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.cassandra.schema.tables;
import com.datastax.driver.core.DataType;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.openecomp.sdc.be.dao.cassandra.schema.ITableDescription;
import org.openecomp.sdc.be.resources.data.auditing.AuditingTypesConstants;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
public class AuthEventTableDescription implements ITableDescription {
- @Override
- public List<ImmutablePair<String, DataType>> primaryKeys() {
- List<ImmutablePair<String, DataType>> keys = new ArrayList<>();
- keys.add(new ImmutablePair<>(TIMEBASED_UUID_FIELD, DataType.timeuuid()));
- return keys;
- }
-
- @Override
- public List<ImmutablePair<String, DataType>> clusteringKeys() {
- List<ImmutablePair<String, DataType>> keys = new ArrayList<>();
- keys.add(new ImmutablePair<>(TIMESTAMP_FIELD, DataType.timestamp()));
- return keys;
- }
-
- @Override
- public Map<String, ImmutablePair<DataType, Boolean>> getColumnDescription() {
- Map<String, ImmutablePair<DataType, Boolean>> columns = new HashMap<>();
-
- for (AEFieldsDescription field : AEFieldsDescription.values()) {
- columns.put(field.getName(), new ImmutablePair<>(field.type, field.indexed));
- }
-
- return columns;
- }
- @Override
- public String getKeyspace() {
- return AuditingTypesConstants.AUDIT_KEYSPACE;
- }
+ @Override
+ public List<ImmutablePair<String, DataType>> primaryKeys() {
+ List<ImmutablePair<String, DataType>> keys = new ArrayList<>();
+ keys.add(new ImmutablePair<>(TIMEBASED_UUID_FIELD, DataType.timeuuid()));
+ return keys;
+ }
- @Override
- public String getTableName() {
- return AuditingTypesConstants.AUTH_EVENT_TYPE;
- }
+ @Override
+ public List<ImmutablePair<String, DataType>> clusteringKeys() {
+ List<ImmutablePair<String, DataType>> keys = new ArrayList<>();
+ keys.add(new ImmutablePair<>(TIMESTAMP_FIELD, DataType.timestamp()));
+ return keys;
+ }
- @Getter
- @AllArgsConstructor
- enum AEFieldsDescription {
- URL("url", DataType.varchar(), false),
- REQUEST_ID("request_id", DataType.varchar(), true),
- USER("user", DataType.varchar(), false),
- AUTH_STATUS("auth_status", DataType.varchar(), false),
- REALM("realm", DataType.varchar(), false),
- ACTION("action", DataType.varchar(), true),
- STATUS("status", DataType.varchar(), false),
- DESC("description", DataType.varchar(), false);
+ @Override
+ public Map<String, ImmutablePair<DataType, Boolean>> getColumnDescription() {
+ Map<String, ImmutablePair<DataType, Boolean>> columns = new HashMap<>();
+ for (AEFieldsDescription field : AEFieldsDescription.values()) {
+ columns.put(field.getName(), new ImmutablePair<>(field.type, field.indexed));
+ }
+ return columns;
+ }
- private final String name;
- private final DataType type;
- private final boolean indexed;
+ @Override
+ public String getKeyspace() {
+ return AuditingTypesConstants.AUDIT_KEYSPACE;
+ }
- }
+ @Override
+ public String getTableName() {
+ return AuditingTypesConstants.AUTH_EVENT_TYPE;
+ }
+ @Getter
+ @AllArgsConstructor
+ enum AEFieldsDescription {
+ URL("url", DataType.varchar(), false), REQUEST_ID("request_id", DataType.varchar(), true), USER("user", DataType.varchar(),
+ false), AUTH_STATUS("auth_status", DataType.varchar(), false), REALM("realm", DataType.varchar(), false), ACTION("action",
+ DataType.varchar(), true), STATUS("status", DataType.varchar(), false), DESC("description", DataType.varchar(), false);
+ private final String name;
+ private final DataType type;
+ private final boolean indexed;
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/CategoryEventTableDescription.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/CategoryEventTableDescription.java
index 63aab3220c..2880f89a63 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/CategoryEventTableDescription.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/CategoryEventTableDescription.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,89 +17,86 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.cassandra.schema.tables;
import com.datastax.driver.core.DataType;
-import org.apache.commons.lang3.tuple.ImmutablePair;
-import org.openecomp.sdc.be.dao.cassandra.schema.ITableDescription;
-import org.openecomp.sdc.be.resources.data.auditing.AuditingTypesConstants;
-
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import org.apache.commons.lang3.tuple.ImmutablePair;
+import org.openecomp.sdc.be.dao.cassandra.schema.ITableDescription;
+import org.openecomp.sdc.be.resources.data.auditing.AuditingTypesConstants;
public class CategoryEventTableDescription implements ITableDescription {
- @Override
- public List<ImmutablePair<String, DataType>> primaryKeys() {
- List<ImmutablePair<String, DataType>> keys = new ArrayList<>();
- keys.add(new ImmutablePair<>(TIMEBASED_UUID_FIELD, DataType.timeuuid()));
- return keys;
- }
-
- @Override
- public List<ImmutablePair<String, DataType>> clusteringKeys() {
- List<ImmutablePair<String, DataType>> keys = new ArrayList<>();
- keys.add(new ImmutablePair<>(TIMESTAMP_FIELD, DataType.timestamp()));
- return keys;
- }
-
- @Override
- public Map<String, ImmutablePair<DataType, Boolean>> getColumnDescription() {
- Map<String, ImmutablePair<DataType, Boolean>> columns = new HashMap<>();
-
- for (CEFieldsDescription field : CEFieldsDescription.values()) {
- columns.put(field.getName(), new ImmutablePair<>(field.type, field.indexed));
- }
-
- return columns;
- }
-
- @Override
- public String getKeyspace() {
- return AuditingTypesConstants.AUDIT_KEYSPACE;
- }
-
- @Override
- public String getTableName() {
- return AuditingTypesConstants.CATEGORY_EVENT_TYPE;
- }
-
- enum CEFieldsDescription {
-
- ACTION("action", DataType.varchar(), true),
- STATUS("status", DataType.varchar(), false),
- DESC("description", DataType.varchar(), false),
- CATEGORY_NAME("category_Name", DataType.varchar(), false),
- SUB_CATEGORY_NAME("sub_Category_Name", DataType.varchar(), false),
- GROUPING_NAME("grouping_name", DataType.varchar(), false),
- MODIFIER("modifier", DataType.varchar(), false),
- REQUEST_ID("request_id", DataType.varchar(), false),
- RESOURCE_TYPE("resource_type", DataType.varchar(), false),
- SERVICE_INSTANCE_ID("service_instance_id", DataType.varchar(), false);
-
- private String name;
- private DataType type;
- private boolean indexed;
-
- CEFieldsDescription(String name, DataType type, boolean indexed) {
- this.name = name;
- this.type = type;
- this.indexed = indexed;
- }
-
- public String getName() {
- return name;
- }
-
- public DataType getType() {
- return type;
- }
-
- public boolean isIndexed() {
- return indexed;
- }
- }
+ @Override
+ public List<ImmutablePair<String, DataType>> primaryKeys() {
+ List<ImmutablePair<String, DataType>> keys = new ArrayList<>();
+ keys.add(new ImmutablePair<>(TIMEBASED_UUID_FIELD, DataType.timeuuid()));
+ return keys;
+ }
+
+ @Override
+ public List<ImmutablePair<String, DataType>> clusteringKeys() {
+ List<ImmutablePair<String, DataType>> keys = new ArrayList<>();
+ keys.add(new ImmutablePair<>(TIMESTAMP_FIELD, DataType.timestamp()));
+ return keys;
+ }
+
+ @Override
+ public Map<String, ImmutablePair<DataType, Boolean>> getColumnDescription() {
+ Map<String, ImmutablePair<DataType, Boolean>> columns = new HashMap<>();
+ for (CEFieldsDescription field : CEFieldsDescription.values()) {
+ columns.put(field.getName(), new ImmutablePair<>(field.type, field.indexed));
+ }
+ return columns;
+ }
+
+ @Override
+ public String getKeyspace() {
+ return AuditingTypesConstants.AUDIT_KEYSPACE;
+ }
+
+ @Override
+ public String getTableName() {
+ return AuditingTypesConstants.CATEGORY_EVENT_TYPE;
+ }
+
+ enum CEFieldsDescription {
+ // @formatter:off
+ ACTION("action", DataType.varchar(), true),
+ STATUS("status", DataType.varchar(), false),
+ DESC("description", DataType.varchar(), false),
+ CATEGORY_NAME("category_Name", DataType.varchar(), false),
+ SUB_CATEGORY_NAME("sub_Category_Name", DataType.varchar(), false),
+ GROUPING_NAME("grouping_name", DataType.varchar(), false),
+ MODIFIER("modifier", DataType.varchar(), false),
+ REQUEST_ID("request_id", DataType.varchar(), false),
+ RESOURCE_TYPE("resource_type", DataType.varchar(), false),
+ SERVICE_INSTANCE_ID("service_instance_id", DataType.varchar(), false);
+ // @formatter:on
+
+ private String name;
+ private DataType type;
+ private boolean indexed;
+
+ CEFieldsDescription(String name, DataType type, boolean indexed) {
+ this.name = name;
+ this.type = type;
+ this.indexed = indexed;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public DataType getType() {
+ return type;
+ }
+
+ public boolean isIndexed() {
+ return indexed;
+ }
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribBaseEventTableDesc.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribBaseEventTableDesc.java
index 68d23731f5..18a7efb966 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribBaseEventTableDesc.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribBaseEventTableDesc.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,22 +17,21 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.cassandra.schema.tables;
import com.datastax.driver.core.DataType;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.openecomp.sdc.be.dao.cassandra.schema.ITableDescription;
import org.openecomp.sdc.be.resources.data.auditing.AuditingTypesConstants;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
public abstract class DistribBaseEventTableDesc implements ITableDescription {
+
@Override
public List<ImmutablePair<String, DataType>> primaryKeys() {
List<ImmutablePair<String, DataType>> keys = new ArrayList<>();
@@ -55,7 +54,6 @@ public abstract class DistribBaseEventTableDesc implements ITableDescription {
@Override
public Map<String, ImmutablePair<DataType, Boolean>> getColumnDescription() {
Map<String, ImmutablePair<DataType, Boolean>> columns = new HashMap<>();
-
for (DistFieldsDescription field : DistFieldsDescription.values()) {
columns.put(field.getName(), new ImmutablePair<>(field.type, field.indexed));
}
@@ -68,11 +66,13 @@ public abstract class DistribBaseEventTableDesc implements ITableDescription {
@Getter
@AllArgsConstructor
enum DistFieldsDescription {
+ // @formatter:off
ACTION("action", DataType.varchar(), true),
STATUS("status", DataType.varchar(), false),
DESCRIPTION("description", DataType.varchar(), false),
REQUEST_ID("request_id", DataType.varchar(), false),
SERVICE_INST_ID("service_instance_id", DataType.varchar(), false);
+ // @formatter:on
private final String name;
private final DataType type;
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribDeployEventTableDesc.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribDeployEventTableDesc.java
index 32e5e490d3..500b0c685a 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribDeployEventTableDesc.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribDeployEventTableDesc.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,50 +17,46 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.cassandra.schema.tables;
import com.datastax.driver.core.DataType;
+import java.util.Map;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.openecomp.sdc.be.resources.data.auditing.AuditingTypesConstants;
-import java.util.Map;
-
public class DistribDeployEventTableDesc extends DistribBaseEventTableDesc {
- @Override
- public String getTableName() {
- return AuditingTypesConstants.DISTRIBUTION_DEPLOY_EVENT_TYPE;
- }
-
- @Override
- protected void updateColumnDistribDescription(Map<String, ImmutablePair<DataType, Boolean>> columns) {
- for (DSEFieldsDescription field : DSEFieldsDescription.values()) {
- columns.put(field.getName(), new ImmutablePair<>(field.type, field.indexed));
- }
- //replace the base indexed flag value with the correct one for a given table:
- columns.put(DistFieldsDescription.STATUS.getName(),
- new ImmutablePair<>(DistFieldsDescription.STATUS.getType(), true));
- columns.put(DistFieldsDescription.SERVICE_INST_ID.getName(),
- new ImmutablePair<>(DistFieldsDescription.SERVICE_INST_ID.getType(), true));
-
+ @Override
+ public String getTableName() {
+ return AuditingTypesConstants.DISTRIBUTION_DEPLOY_EVENT_TYPE;
}
- @Getter
- @AllArgsConstructor
- enum DSEFieldsDescription {
- MODIFIER("modifier", DataType.varchar(), false),
- CURR_VERSION("curr_version", DataType.varchar(), false),
- DID("did", DataType.varchar(), true),
- RESOURCE_NAME("resource_name", DataType.varchar(), false),
- RESOURCE_TYPE("resource_type", DataType.varchar(), false);
-
- private final String name;
- private final DataType type;
- private final boolean indexed;
+ @Override
+ protected void updateColumnDistribDescription(Map<String, ImmutablePair<DataType, Boolean>> columns) {
+ for (DSEFieldsDescription field : DSEFieldsDescription.values()) {
+ columns.put(field.getName(), new ImmutablePair<>(field.type, field.indexed));
+ }
+ //replace the base indexed flag value with the correct one for a given table:
+ columns.put(DistFieldsDescription.STATUS.getName(), new ImmutablePair<>(DistFieldsDescription.STATUS.getType(), true));
+ columns.put(DistFieldsDescription.SERVICE_INST_ID.getName(), new ImmutablePair<>(DistFieldsDescription.SERVICE_INST_ID.getType(), true));
+ }
- }
+ @Getter
+ @AllArgsConstructor
+ enum DSEFieldsDescription {
+ // @formatter:off
+ MODIFIER("modifier", DataType.varchar(), false),
+ CURR_VERSION("curr_version", DataType.varchar(), false),
+ DID("did", DataType.varchar(), true),
+ RESOURCE_NAME("resource_name", DataType.varchar(), false),
+ RESOURCE_TYPE("resource_type", DataType.varchar(), false);
+ // @formatter:on
+
+ private final String name;
+ private final DataType type;
+ private final boolean indexed;
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribDownloadEventTableDesc.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribDownloadEventTableDesc.java
index f59347d919..828b9a6081 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribDownloadEventTableDesc.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribDownloadEventTableDesc.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,41 +17,35 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.cassandra.schema.tables;
import com.datastax.driver.core.DataType;
+import java.util.Map;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.openecomp.sdc.be.resources.data.auditing.AuditingTypesConstants;
-import java.util.Map;
-
public class DistribDownloadEventTableDesc extends DistribBaseEventTableDesc {
- @Override
- protected void updateColumnDistribDescription(Map<String, ImmutablePair<DataType, Boolean>> columns) {
- for (DSEFieldsDescription field : DSEFieldsDescription.values()) {
- columns.put(field.getName(), new ImmutablePair<>(field.type, field.indexed));
- }
- }
-
- @Override
- public String getTableName() {
- return AuditingTypesConstants.DISTRIBUTION_DOWNLOAD_EVENT_TYPE;
- }
-
- @Getter
- @AllArgsConstructor
- enum DSEFieldsDescription {
- CONSUMER_ID("consumer_Id", DataType.varchar(), false),
- RESOURCE_URL("resource_URL", DataType.varchar(), false);
-
- private final String name;
- private final DataType type;
- private final boolean indexed;
-
- }
-
+ @Override
+ protected void updateColumnDistribDescription(Map<String, ImmutablePair<DataType, Boolean>> columns) {
+ for (DSEFieldsDescription field : DSEFieldsDescription.values()) {
+ columns.put(field.getName(), new ImmutablePair<>(field.type, field.indexed));
+ }
+ }
+
+ @Override
+ public String getTableName() {
+ return AuditingTypesConstants.DISTRIBUTION_DOWNLOAD_EVENT_TYPE;
+ }
+
+ @Getter
+ @AllArgsConstructor
+ enum DSEFieldsDescription {
+ CONSUMER_ID("consumer_Id", DataType.varchar(), false), RESOURCE_URL("resource_URL", DataType.varchar(), false);
+ private final String name;
+ private final DataType type;
+ private final boolean indexed;
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribEngineEventTableDesc.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribEngineEventTableDesc.java
index 650aa9b217..0ea99b4b78 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribEngineEventTableDesc.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribEngineEventTableDesc.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,17 +17,15 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.cassandra.schema.tables;
import com.datastax.driver.core.DataType;
+import java.util.Map;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.openecomp.sdc.be.resources.data.auditing.AuditingTypesConstants;
-import java.util.Map;
-
public class DistribEngineEventTableDesc extends DistribBaseEventTableDesc {
@Override
@@ -36,30 +34,28 @@ public class DistribEngineEventTableDesc extends DistribBaseEventTableDesc {
columns.put(field.getName(), new ImmutablePair<>(field.type, field.indexed));
}
//replace the base indexed flag value with the correct one for a given table:
- columns.put(DistFieldsDescription.REQUEST_ID.getName(),
- new ImmutablePair<>(DistFieldsDescription.REQUEST_ID.getType(), true));
+ columns.put(DistFieldsDescription.REQUEST_ID.getName(), new ImmutablePair<>(DistFieldsDescription.REQUEST_ID.getType(), true));
}
-
@Override
- public String getTableName() {
- return AuditingTypesConstants.DISTRIBUTION_ENGINE_EVENT_TYPE;
- }
+ public String getTableName() {
+ return AuditingTypesConstants.DISTRIBUTION_ENGINE_EVENT_TYPE;
+ }
- @Getter
- @AllArgsConstructor
- enum DEEFieldsDescription {
- CONSUMER_ID("consumer_id", DataType.varchar(), false),
+ @Getter
+ @AllArgsConstructor
+ enum DEEFieldsDescription {
+ // @formatter:off
+ CONSUMER_ID("consumer_id", DataType.varchar(), false),
ROLE("role", DataType.varchar(), false),
- D_ENV("d_env", DataType.varchar(), false),
+ D_ENV("d_env", DataType.varchar(), false),
API_KEY("api_key", DataType.varchar(), false),
- DSTATUS_TOPIC("dstatus_topic", DataType.varchar(), false),
+ DSTATUS_TOPIC("dstatus_topic", DataType.varchar(), false),
DNOTIF_TOPIC("dnotif_topic", DataType.varchar(), false);
+ // @formatter:on
- private final String name;
- private final DataType type;
- private final boolean indexed;
-
- }
-
+ private final String name;
+ private final DataType type;
+ private final boolean indexed;
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribNotifEventTableDesc.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribNotifEventTableDesc.java
index 612a0b5741..6e752329c9 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribNotifEventTableDesc.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribNotifEventTableDesc.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,52 +17,49 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.cassandra.schema.tables;
import com.datastax.driver.core.DataType;
+import java.util.Map;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.openecomp.sdc.be.resources.data.auditing.AuditingTypesConstants;
-import java.util.Map;
-
public class DistribNotifEventTableDesc extends DistribBaseEventTableDesc {
- @Override
- protected void updateColumnDistribDescription(Map<String, ImmutablePair<DataType, Boolean>> columns) {
- for (DNEFieldsDescription field : DNEFieldsDescription.values()) {
- columns.put(field.getName(), new ImmutablePair<>(field.type, field.indexed));
- }
+ @Override
+ protected void updateColumnDistribDescription(Map<String, ImmutablePair<DataType, Boolean>> columns) {
+ for (DNEFieldsDescription field : DNEFieldsDescription.values()) {
+ columns.put(field.getName(), new ImmutablePair<>(field.type, field.indexed));
+ }
//replace the base indexed flag value with the correct one for a given table:
- columns.put(DistFieldsDescription.SERVICE_INST_ID.getName(),
- new ImmutablePair<>(DistFieldsDescription.SERVICE_INST_ID.getType(), true));
- }
+ columns.put(DistFieldsDescription.SERVICE_INST_ID.getName(), new ImmutablePair<>(DistFieldsDescription.SERVICE_INST_ID.getType(), true));
+ }
- @Override
- public String getTableName() {
- return AuditingTypesConstants.DISTRIBUTION_NOTIFICATION_EVENT_TYPE;
- }
+ @Override
+ public String getTableName() {
+ return AuditingTypesConstants.DISTRIBUTION_NOTIFICATION_EVENT_TYPE;
+ }
- @Getter
- @AllArgsConstructor
- enum DNEFieldsDescription {
- TOPIC_NAME("topic_name", DataType.varchar(), false),
- MODIFIER("modifier", DataType.varchar(), false),
- CURR_STATE("curr_state", DataType.varchar(), false),
- CURR_VERSION("curr_version", DataType.varchar(), false),
- DID("did", DataType.varchar(), true),
- RESOURCE_NAME("resource_name", DataType.varchar(), false),
+ @Getter
+ @AllArgsConstructor
+ enum DNEFieldsDescription {
+ // @formatter:off
+ TOPIC_NAME("topic_name", DataType.varchar(), false),
+ MODIFIER("modifier", DataType.varchar(), false),
+ CURR_STATE("curr_state", DataType.varchar(), false),
+ CURR_VERSION("curr_version", DataType.varchar(), false),
+ DID("did", DataType.varchar(), true),
+ RESOURCE_NAME("resource_name", DataType.varchar(), false),
RESOURCE_TYPE("resource_type", DataType.varchar(), false),
ENV_ID("env_id", DataType.varchar(), false),
VNF_WORKLOAD_CONTEXT("vnf_workload_context", DataType.varchar(), false),
TENANT("tenant", DataType.varchar(), false);
+ // @formatter:on
- private final String name;
- private final DataType type;
- private final boolean indexed;
-
- }
-
+ private final String name;
+ private final DataType type;
+ private final boolean indexed;
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribStatusEventTableDesc.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribStatusEventTableDesc.java
index def5fe2bc1..7e64605228 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribStatusEventTableDesc.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/DistribStatusEventTableDesc.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,56 +17,56 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.cassandra.schema.tables;
import com.datastax.driver.core.DataType;
+import java.util.Map;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.openecomp.sdc.be.resources.data.auditing.AuditingTypesConstants;
-import java.util.Map;
-
-public class DistribStatusEventTableDesc extends DistribBaseEventTableDesc{
+public class DistribStatusEventTableDesc extends DistribBaseEventTableDesc {
- @Override
- protected void updateColumnDistribDescription(Map<String, ImmutablePair<DataType, Boolean>> columns) {
- for (DSEFieldsDescription field : DSEFieldsDescription.values()) {
- columns.put(field.getName(), new ImmutablePair<>(field.type, field.indexed));
- }
- }
+ @Override
+ protected void updateColumnDistribDescription(Map<String, ImmutablePair<DataType, Boolean>> columns) {
+ for (DSEFieldsDescription field : DSEFieldsDescription.values()) {
+ columns.put(field.getName(), new ImmutablePair<>(field.type, field.indexed));
+ }
+ }
- @Override
- public String getTableName() {
- return AuditingTypesConstants.DISTRIBUTION_STATUS_EVENT_TYPE;
- }
+ @Override
+ public String getTableName() {
+ return AuditingTypesConstants.DISTRIBUTION_STATUS_EVENT_TYPE;
+ }
- enum DSEFieldsDescription {
- DID("did", DataType.varchar(), true),
- CONSUMER_ID("consumer_id", DataType.varchar(), false),
- RESOURCE_URL("resoure_URL", DataType.varchar(), false),
- TOPIC_NAME("topic_name", DataType.varchar(), false),
- STATUS_TIME("status_time", DataType.varchar(), false);
+ enum DSEFieldsDescription {
+ // @formatter:off
+ DID("did", DataType.varchar(), true),
+ CONSUMER_ID("consumer_id", DataType.varchar(), false),
+ RESOURCE_URL("resoure_URL", DataType.varchar(), false),
+ TOPIC_NAME("topic_name", DataType.varchar(), false),
+ STATUS_TIME("status_time", DataType.varchar(), false);
+ // @formatter:on
- private String name;
- private DataType type;
- private boolean indexed;
+ private String name;
+ private DataType type;
+ private boolean indexed;
- DSEFieldsDescription(String name, DataType type, boolean indexed) {
- this.name = name;
- this.type = type;
- this.indexed = indexed;
- }
+ DSEFieldsDescription(String name, DataType type, boolean indexed) {
+ this.name = name;
+ this.type = type;
+ this.indexed = indexed;
+ }
- public String getName() {
- return name;
- }
+ public String getName() {
+ return name;
+ }
- public DataType getType() {
- return type;
- }
+ public DataType getType() {
+ return type;
+ }
- public boolean isIndexed() {
- return indexed;
- }
- }
+ public boolean isIndexed() {
+ return indexed;
+ }
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/EcompOperationalEnvironmentEventTableDesc.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/EcompOperationalEnvironmentEventTableDesc.java
index eac2a704a6..9ea284db33 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/EcompOperationalEnvironmentEventTableDesc.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/EcompOperationalEnvironmentEventTableDesc.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,18 +17,20 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.cassandra.schema.tables;
import com.datastax.driver.core.DataType;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.openecomp.sdc.be.dao.cassandra.schema.ITableDescription;
import org.openecomp.sdc.be.resources.data.auditing.AuditingTypesConstants;
-import java.util.*;
-
public class EcompOperationalEnvironmentEventTableDesc implements ITableDescription {
private static final String OPERATIONAL_ENVIRONMENT_ID = "operational_environment_id";
@@ -55,9 +57,8 @@ public class EcompOperationalEnvironmentEventTableDesc implements ITableDescript
@Override
public Map<String, ImmutablePair<DataType, Boolean>> getColumnDescription() {
Map<String, ImmutablePair<DataType, Boolean>> columns = new HashMap<>();
-
Arrays.stream(EcompOpEnvFieldsDescription.values())
- .forEach(column -> columns.put(column.getName(), ImmutablePair.of(column.getType(), column.isIndexed())));
+ .forEach(column -> columns.put(column.getName(), ImmutablePair.of(column.getType(), column.isIndexed())));
return columns;
}
@@ -69,11 +70,13 @@ public class EcompOperationalEnvironmentEventTableDesc implements ITableDescript
@Getter
@AllArgsConstructor
enum EcompOpEnvFieldsDescription {
+ // @formatter:off
ACTION("action", DataType.varchar(), false),
OPERATIONAL_ENVIRONMENT_NAME("operational_environment_name", DataType.varchar(), false),
OPERATIONAL_ENVIRONMENT_TYPE("operational_environment_type", DataType.varchar(), false),
OPERATIONAL_ENVIRONMENT_ACTION("operational_environment_action", DataType.varchar(), false),
TENANT_CONTEXT("tenant_context", DataType.varchar(), false);
+ // @formatter:on
private final String name;
private final DataType type;
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/ExternalApiEventTableDesc.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/ExternalApiEventTableDesc.java
index 659bec7436..b247d50dae 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/ExternalApiEventTableDesc.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/ExternalApiEventTableDesc.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,82 +17,79 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.cassandra.schema.tables;
import com.datastax.driver.core.DataType;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.openecomp.sdc.be.dao.cassandra.schema.ITableDescription;
import org.openecomp.sdc.be.resources.data.auditing.AuditingTypesConstants;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
public class ExternalApiEventTableDesc implements ITableDescription {
- @Override
- public List<ImmutablePair<String, DataType>> primaryKeys() {
- List<ImmutablePair<String, DataType>> keys = new ArrayList<>();
- keys.add(new ImmutablePair<>(TIMEBASED_UUID_FIELD, DataType.timeuuid()));
- return keys;
- }
- @Override
- public List<ImmutablePair<String, DataType>> clusteringKeys() {
- List<ImmutablePair<String, DataType>> keys = new ArrayList<>();
- keys.add(new ImmutablePair<>(TIMESTAMP_FIELD, DataType.timestamp()));
- return keys;
- }
+ @Override
+ public List<ImmutablePair<String, DataType>> primaryKeys() {
+ List<ImmutablePair<String, DataType>> keys = new ArrayList<>();
+ keys.add(new ImmutablePair<>(TIMEBASED_UUID_FIELD, DataType.timeuuid()));
+ return keys;
+ }
- @Override
- public Map<String, ImmutablePair<DataType, Boolean>> getColumnDescription() {
- Map<String, ImmutablePair<DataType, Boolean>> columns = new HashMap<>();
+ @Override
+ public List<ImmutablePair<String, DataType>> clusteringKeys() {
+ List<ImmutablePair<String, DataType>> keys = new ArrayList<>();
+ keys.add(new ImmutablePair<>(TIMESTAMP_FIELD, DataType.timestamp()));
+ return keys;
+ }
- for (EGAEFieldsDescription field : EGAEFieldsDescription.values()) {
- columns.put(field.getName(), new ImmutablePair<>(field.type, field.indexed));
- }
+ @Override
+ public Map<String, ImmutablePair<DataType, Boolean>> getColumnDescription() {
+ Map<String, ImmutablePair<DataType, Boolean>> columns = new HashMap<>();
+ for (EGAEFieldsDescription field : EGAEFieldsDescription.values()) {
+ columns.put(field.getName(), new ImmutablePair<>(field.type, field.indexed));
+ }
+ return columns;
+ }
- return columns;
- }
+ @Override
+ public String getKeyspace() {
+ return AuditingTypesConstants.AUDIT_KEYSPACE;
+ }
- @Override
- public String getKeyspace() {
- return AuditingTypesConstants.AUDIT_KEYSPACE;
- }
+ @Override
+ public String getTableName() {
+ return AuditingTypesConstants.EXTERNAL_API_EVENT_TYPE;
+ }
- @Override
- public String getTableName() {
- return AuditingTypesConstants.EXTERNAL_API_EVENT_TYPE;
- }
-
- @Getter
- @AllArgsConstructor
- enum EGAEFieldsDescription {
- ACTION("action", DataType.varchar(), true),
- STATUS("status", DataType.varchar(), false),
- DESCRIPTION( "description", DataType.varchar(), false),
- CONSUMER_ID("consumer_id", DataType.varchar(), false),
- RESOURCE_URL("resource_URL", DataType.varchar(), false),
+ @Getter
+ @AllArgsConstructor
+ enum EGAEFieldsDescription {
+ // @formatter:off
+ ACTION("action", DataType.varchar(), true),
+ STATUS("status", DataType.varchar(), false),
+ DESCRIPTION( "description", DataType.varchar(), false),
+ CONSUMER_ID("consumer_id", DataType.varchar(), false),
+ RESOURCE_URL("resource_URL", DataType.varchar(), false),
RESOURCE_NAME("resource_name", DataType.varchar(), false),
- RESOURCE_TYPE("resource_type", DataType.varchar(), false),
+ RESOURCE_TYPE("resource_type", DataType.varchar(), false),
SERVICE_INST_ID( "service_instance_id", DataType.varchar(), true),
INVARIANT_UUID("invariant_uuid", DataType.varchar(), true),
- MODIFIER("modifier", DataType.varchar(), false),
- PREV_VERSION( "prev_version", DataType.varchar(), false),
+ MODIFIER("modifier", DataType.varchar(), false),
+ PREV_VERSION( "prev_version", DataType.varchar(), false),
CURR_VERSION("curr_version", DataType.varchar(), false),
- PREV_STATE("prev_state", DataType.varchar(), false),
- CURR_STATE( "curr_state", DataType.varchar(), false),
+ PREV_STATE("prev_state", DataType.varchar(), false),
+ CURR_STATE( "curr_state", DataType.varchar(), false),
PREV_ARTIFACT_UUID( "prev_artifact_uuid", DataType.varchar(), false),
CURR_ARTIFACT_UUID( "curr_artifact_uuid", DataType.varchar(), false),
ARTIFACT_DATA( "artifact_data", DataType.varchar(), false);
+ // @formatter:on
- private final String name;
- private final DataType type;
- private final boolean indexed;
-
- }
-
+ private final String name;
+ private final DataType type;
+ private final boolean indexed;
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/FeatureToggleEventTableDesc.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/FeatureToggleEventTableDesc.java
index ed79f4bd2f..9a431f27df 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/FeatureToggleEventTableDesc.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/FeatureToggleEventTableDesc.java
@@ -17,22 +17,20 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.cassandra.schema.tables;
import com.datastax.driver.core.DataType;
import com.google.common.collect.Lists;
-import lombok.AllArgsConstructor;
-import lombok.Getter;
-import org.apache.commons.lang3.tuple.ImmutablePair;
-import org.openecomp.sdc.be.dao.cassandra.schema.ITableDescription;
-import org.openecomp.sdc.be.resources.data.auditing.AuditingTypesConstants;
-
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import org.apache.commons.lang3.tuple.ImmutablePair;
+import org.openecomp.sdc.be.dao.cassandra.schema.ITableDescription;
+import org.openecomp.sdc.be.resources.data.auditing.AuditingTypesConstants;
public class FeatureToggleEventTableDesc implements ITableDescription {
@@ -54,7 +52,7 @@ public class FeatureToggleEventTableDesc implements ITableDescription {
public Map<String, ImmutablePair<DataType, Boolean>> getColumnDescription() {
Map<String, ImmutablePair<DataType, Boolean>> columns = new HashMap<>();
Arrays.stream(FeatureToggleEventFieldsDescription.values())
- .forEach(column -> columns.put(column.getName(), ImmutablePair.of(column.getType(), column.isIndexed())));
+ .forEach(column -> columns.put(column.getName(), ImmutablePair.of(column.getType(), column.isIndexed())));
return columns;
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/GetCatHierEventTableDesc.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/GetCatHierEventTableDesc.java
index 5765cb5912..3cf5503bb2 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/GetCatHierEventTableDesc.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/GetCatHierEventTableDesc.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,71 +17,68 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.cassandra.schema.tables;
import com.datastax.driver.core.DataType;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.openecomp.sdc.be.dao.cassandra.schema.ITableDescription;
import org.openecomp.sdc.be.resources.data.auditing.AuditingTypesConstants;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
public class GetCatHierEventTableDesc implements ITableDescription {
- @Override
- public List<ImmutablePair<String, DataType>> primaryKeys() {
- List<ImmutablePair<String, DataType>> keys = new ArrayList<>();
- keys.add(new ImmutablePair<>(TIMEBASED_UUID_FIELD, DataType.timeuuid()));
- return keys;
- }
- @Override
- public List<ImmutablePair<String, DataType>> clusteringKeys() {
- List<ImmutablePair<String, DataType>> keys = new ArrayList<>();
- keys.add(new ImmutablePair<>(TIMESTAMP_FIELD, DataType.timestamp()));
- return keys;
- }
+ @Override
+ public List<ImmutablePair<String, DataType>> primaryKeys() {
+ List<ImmutablePair<String, DataType>> keys = new ArrayList<>();
+ keys.add(new ImmutablePair<>(TIMEBASED_UUID_FIELD, DataType.timeuuid()));
+ return keys;
+ }
- @Override
- public Map<String, ImmutablePair<DataType, Boolean>> getColumnDescription() {
- Map<String, ImmutablePair<DataType, Boolean>> columns = new HashMap<>();
+ @Override
+ public List<ImmutablePair<String, DataType>> clusteringKeys() {
+ List<ImmutablePair<String, DataType>> keys = new ArrayList<>();
+ keys.add(new ImmutablePair<>(TIMESTAMP_FIELD, DataType.timestamp()));
+ return keys;
+ }
- for (DEEFieldsDescription field : DEEFieldsDescription.values()) {
- columns.put(field.getName(), new ImmutablePair<>(field.type, field.indexed));
- }
+ @Override
+ public Map<String, ImmutablePair<DataType, Boolean>> getColumnDescription() {
+ Map<String, ImmutablePair<DataType, Boolean>> columns = new HashMap<>();
+ for (DEEFieldsDescription field : DEEFieldsDescription.values()) {
+ columns.put(field.getName(), new ImmutablePair<>(field.type, field.indexed));
+ }
+ return columns;
+ }
- return columns;
- }
+ @Override
+ public String getKeyspace() {
+ return AuditingTypesConstants.AUDIT_KEYSPACE;
+ }
- @Override
- public String getKeyspace() {
- return AuditingTypesConstants.AUDIT_KEYSPACE;
- }
+ @Override
+ public String getTableName() {
+ return AuditingTypesConstants.GET_CATEGORY_HIERARCHY_EVENT_TYPE;
+ }
- @Override
- public String getTableName() {
- return AuditingTypesConstants.GET_CATEGORY_HIERARCHY_EVENT_TYPE;
- }
-
- @Getter
- @AllArgsConstructor
- enum DEEFieldsDescription {
- ACTION("action", DataType.varchar(), true),
- STATUS("status", DataType.varchar(), false),
- DESCRIPTION("description", DataType.varchar(), false),
- DETAILS("details", DataType.varchar(), false),
- REQUEST_ID("request_id", DataType.varchar(), false),
+ @Getter
+ @AllArgsConstructor
+ enum DEEFieldsDescription {
+ // @formatter:off
+ ACTION("action", DataType.varchar(), true),
+ STATUS("status", DataType.varchar(), false),
+ DESCRIPTION("description", DataType.varchar(), false),
+ DETAILS("details", DataType.varchar(), false),
+ REQUEST_ID("request_id", DataType.varchar(), false),
MODIFIER("modifier", DataType.varchar(), false);
+ // @formatter:on
- private final String name;
- private final DataType type;
- private final boolean indexed;
-
- }
-
+ private final String name;
+ private final DataType type;
+ private final boolean indexed;
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/GetUebClusterEventTableDesc.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/GetUebClusterEventTableDesc.java
index ce2a8e9633..2b6ee28072 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/GetUebClusterEventTableDesc.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/GetUebClusterEventTableDesc.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,72 +17,68 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.cassandra.schema.tables;
import com.datastax.driver.core.DataType;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.openecomp.sdc.be.dao.cassandra.schema.ITableDescription;
import org.openecomp.sdc.be.resources.data.auditing.AuditingTypesConstants;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
public class GetUebClusterEventTableDesc implements ITableDescription {
- @Override
- public List<ImmutablePair<String, DataType>> primaryKeys() {
- List<ImmutablePair<String, DataType>> keys = new ArrayList<>();
- keys.add(new ImmutablePair<>(TIMEBASED_UUID_FIELD, DataType.timeuuid()));
- return keys;
- }
-
- @Override
- public List<ImmutablePair<String, DataType>> clusteringKeys() {
- List<ImmutablePair<String, DataType>> keys = new ArrayList<>();
- keys.add(new ImmutablePair<>(TIMESTAMP_FIELD, DataType.timestamp()));
- return keys;
- }
+ @Override
+ public List<ImmutablePair<String, DataType>> primaryKeys() {
+ List<ImmutablePair<String, DataType>> keys = new ArrayList<>();
+ keys.add(new ImmutablePair<>(TIMEBASED_UUID_FIELD, DataType.timeuuid()));
+ return keys;
+ }
- @Override
- public Map<String, ImmutablePair<DataType, Boolean>> getColumnDescription() {
- Map<String, ImmutablePair<DataType, Boolean>> columns = new HashMap<>();
+ @Override
+ public List<ImmutablePair<String, DataType>> clusteringKeys() {
+ List<ImmutablePair<String, DataType>> keys = new ArrayList<>();
+ keys.add(new ImmutablePair<>(TIMESTAMP_FIELD, DataType.timestamp()));
+ return keys;
+ }
- for (DEEFieldsDescription field : DEEFieldsDescription.values()) {
- columns.put(field.getName(), new ImmutablePair<>(field.type, field.indexed));
- }
+ @Override
+ public Map<String, ImmutablePair<DataType, Boolean>> getColumnDescription() {
+ Map<String, ImmutablePair<DataType, Boolean>> columns = new HashMap<>();
+ for (DEEFieldsDescription field : DEEFieldsDescription.values()) {
+ columns.put(field.getName(), new ImmutablePair<>(field.type, field.indexed));
+ }
+ return columns;
+ }
- return columns;
- }
+ @Override
+ public String getKeyspace() {
+ return AuditingTypesConstants.AUDIT_KEYSPACE;
+ }
- @Override
- public String getKeyspace() {
- return AuditingTypesConstants.AUDIT_KEYSPACE;
- }
+ @Override
+ public String getTableName() {
+ return AuditingTypesConstants.DISTRIBUTION_GET_UEB_CLUSTER_EVENT_TYPE;
+ }
- @Override
- public String getTableName() {
- return AuditingTypesConstants.DISTRIBUTION_GET_UEB_CLUSTER_EVENT_TYPE;
- }
-
- @Getter
- @AllArgsConstructor
- enum DEEFieldsDescription {
- ACTION("action", DataType.varchar(), true),
- STATUS("status", DataType.varchar(), false),
- DESCRIPTION("description", DataType.varchar(), false),
- CONSUMER_ID("consumer_Id", DataType.varchar(), false),
- REQUEST_ID("request_Id", DataType.varchar(), false),
+ @Getter
+ @AllArgsConstructor
+ enum DEEFieldsDescription {
+ // @formatter:off
+ ACTION("action", DataType.varchar(), true),
+ STATUS("status", DataType.varchar(), false),
+ DESCRIPTION("description", DataType.varchar(), false),
+ CONSUMER_ID("consumer_Id", DataType.varchar(), false),
+ REQUEST_ID("request_Id", DataType.varchar(), false),
SERVICE_INST_ID("service_Instance_Id", DataType.varchar(), false);
+ // @formatter:on
- private final String name;
- private final DataType type;
- private final boolean indexed;
-
- }
-
+ private final String name;
+ private final DataType type;
+ private final boolean indexed;
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/GetUsersListEventTableDesc.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/GetUsersListEventTableDesc.java
index 3c3ebe7e3e..167aa0cb9e 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/GetUsersListEventTableDesc.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/GetUsersListEventTableDesc.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,71 +17,68 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.cassandra.schema.tables;
import com.datastax.driver.core.DataType;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.openecomp.sdc.be.dao.cassandra.schema.ITableDescription;
import org.openecomp.sdc.be.resources.data.auditing.AuditingTypesConstants;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
public class GetUsersListEventTableDesc implements ITableDescription {
- @Override
- public List<ImmutablePair<String, DataType>> primaryKeys() {
- List<ImmutablePair<String, DataType>> keys = new ArrayList<>();
- keys.add(new ImmutablePair<>(TIMEBASED_UUID_FIELD, DataType.timeuuid()));
- return keys;
- }
- @Override
- public List<ImmutablePair<String, DataType>> clusteringKeys() {
- List<ImmutablePair<String, DataType>> keys = new ArrayList<>();
- keys.add(new ImmutablePair<>(TIMESTAMP_FIELD, DataType.timestamp()));
- return keys;
- }
+ @Override
+ public List<ImmutablePair<String, DataType>> primaryKeys() {
+ List<ImmutablePair<String, DataType>> keys = new ArrayList<>();
+ keys.add(new ImmutablePair<>(TIMEBASED_UUID_FIELD, DataType.timeuuid()));
+ return keys;
+ }
- @Override
- public Map<String, ImmutablePair<DataType, Boolean>> getColumnDescription() {
- Map<String, ImmutablePair<DataType, Boolean>> columns = new HashMap<>();
+ @Override
+ public List<ImmutablePair<String, DataType>> clusteringKeys() {
+ List<ImmutablePair<String, DataType>> keys = new ArrayList<>();
+ keys.add(new ImmutablePair<>(TIMESTAMP_FIELD, DataType.timestamp()));
+ return keys;
+ }
- for (DEEFieldsDescription field : DEEFieldsDescription.values()) {
- columns.put(field.getName(), new ImmutablePair<>(field.type, field.indexed));
- }
+ @Override
+ public Map<String, ImmutablePair<DataType, Boolean>> getColumnDescription() {
+ Map<String, ImmutablePair<DataType, Boolean>> columns = new HashMap<>();
+ for (DEEFieldsDescription field : DEEFieldsDescription.values()) {
+ columns.put(field.getName(), new ImmutablePair<>(field.type, field.indexed));
+ }
+ return columns;
+ }
- return columns;
- }
+ @Override
+ public String getKeyspace() {
+ return AuditingTypesConstants.AUDIT_KEYSPACE;
+ }
- @Override
- public String getKeyspace() {
- return AuditingTypesConstants.AUDIT_KEYSPACE;
- }
+ @Override
+ public String getTableName() {
+ return AuditingTypesConstants.GET_USERS_LIST_EVENT_TYPE;
+ }
- @Override
- public String getTableName() {
- return AuditingTypesConstants.GET_USERS_LIST_EVENT_TYPE;
- }
-
- @Getter
- @AllArgsConstructor
- enum DEEFieldsDescription {
- ACTION("action", DataType.varchar(), true),
- STATUS("status", DataType.varchar(), false),
- DESCRIPTION("description", DataType.varchar(), false),
- DETAILS("details", DataType.varchar(), false),
- REQUEST_ID("request_id", DataType.varchar(), false),
+ @Getter
+ @AllArgsConstructor
+ enum DEEFieldsDescription {
+ // @formatter:off
+ ACTION("action", DataType.varchar(), true),
+ STATUS("status", DataType.varchar(), false),
+ DESCRIPTION("description", DataType.varchar(), false),
+ DETAILS("details", DataType.varchar(), false),
+ REQUEST_ID("request_id", DataType.varchar(), false),
MODIFIER("modifier", DataType.varchar(), false);
+ // @formatter:on
- private final String name;
- private final DataType type;
- private final boolean indexed;
-
- }
-
+ private final String name;
+ private final DataType type;
+ private final boolean indexed;
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/MigrationTasksTableDescription.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/MigrationTasksTableDescription.java
index 54656cbe19..2d03e67b4b 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/MigrationTasksTableDescription.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/MigrationTasksTableDescription.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,21 +17,23 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.cassandra.schema.tables;
+import static org.openecomp.sdc.be.dao.cassandra.schema.tables.MigrationTasksTableDescription.SdcRepoFieldsDescription.MAJOR_VERSION;
+import static org.openecomp.sdc.be.dao.cassandra.schema.tables.MigrationTasksTableDescription.SdcRepoFieldsDescription.MINOR_VERSION;
+
import com.datastax.driver.core.DataType;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.openecomp.sdc.be.dao.cassandra.schema.ITableDescription;
import org.openecomp.sdc.be.resources.data.auditing.AuditingTypesConstants;
-import java.util.*;
-
-import static org.openecomp.sdc.be.dao.cassandra.schema.tables.MigrationTasksTableDescription.SdcRepoFieldsDescription.MAJOR_VERSION;
-import static org.openecomp.sdc.be.dao.cassandra.schema.tables.MigrationTasksTableDescription.SdcRepoFieldsDescription.MINOR_VERSION;
-
public class MigrationTasksTableDescription implements ITableDescription {
private static final String MIGRATION_TASKS_TABLE = "migrationTasks";
@@ -49,9 +51,8 @@ public class MigrationTasksTableDescription implements ITableDescription {
@Override
public Map<String, ImmutablePair<DataType, Boolean>> getColumnDescription() {
Map<String, ImmutablePair<DataType, Boolean>> columns = new HashMap<>();
- Arrays.stream(SdcRepoFieldsDescription.values())
- .filter(column -> !column.equals(MAJOR_VERSION) && !column.equals(MINOR_VERSION))
- .forEach(column -> columns.put(column.getFieldName(), ImmutablePair.of(column.getFieldType(), column.isIndexed())));
+ Arrays.stream(SdcRepoFieldsDescription.values()).filter(column -> !column.equals(MAJOR_VERSION) && !column.equals(MINOR_VERSION))
+ .forEach(column -> columns.put(column.getFieldName(), ImmutablePair.of(column.getFieldType(), column.isIndexed())));
return columns;
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/OldExternalApiEventTableDesc.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/OldExternalApiEventTableDesc.java
index f69b3ce44e..847c3d5b68 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/OldExternalApiEventTableDesc.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/OldExternalApiEventTableDesc.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,85 +17,79 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.cassandra.schema.tables;
import com.datastax.driver.core.DataType;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.openecomp.sdc.be.dao.cassandra.schema.ITableDescription;
import org.openecomp.sdc.be.resources.data.auditing.AuditingTypesConstants;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
public class OldExternalApiEventTableDesc implements ITableDescription {
- @Override
- public List<ImmutablePair<String, DataType>> primaryKeys() {
- List<ImmutablePair<String, DataType>> keys = new ArrayList<>();
- keys.add(new ImmutablePair<>(TIMEBASED_UUID_FIELD, DataType.timeuuid()));
- return keys;
- }
- @Override
- public List<ImmutablePair<String, DataType>> clusteringKeys() {
- List<ImmutablePair<String, DataType>> keys = new ArrayList<>();
- keys.add(new ImmutablePair<>(TIMESTAMP_FIELD, DataType.timestamp()));
- return keys;
- }
-
- @Override
- public Map<String, ImmutablePair<DataType, Boolean>> getColumnDescription() {
- Map<String, ImmutablePair<DataType, Boolean>> columns = new HashMap<>();
-
- for (EGAEFieldsDescription field : EGAEFieldsDescription.values()) {
- columns.put(field.getName(), new ImmutablePair<>(field.type, field.indexed));
- }
-
- return columns;
- }
-
- @Override
- public String getKeyspace() {
- return AuditingTypesConstants.AUDIT_KEYSPACE.replace("sdc", "att");
- }
-
-
-
- @Override
- public String getTableName() {
- return AuditingTypesConstants.EXTERNAL_API_EVENT_TYPE;
- }
-
- @Getter
- @AllArgsConstructor
- enum EGAEFieldsDescription {
- ACTION("action", DataType.varchar(), true),
- STATUS("status", DataType.varchar(), false),
- DESCRIPTION( "description", DataType.varchar(), false),
- CONSUMER_ID("consumer_id", DataType.varchar(), false),
- RESOURCE_URL("resource_URL", DataType.varchar(), false),
+ @Override
+ public List<ImmutablePair<String, DataType>> primaryKeys() {
+ List<ImmutablePair<String, DataType>> keys = new ArrayList<>();
+ keys.add(new ImmutablePair<>(TIMEBASED_UUID_FIELD, DataType.timeuuid()));
+ return keys;
+ }
+
+ @Override
+ public List<ImmutablePair<String, DataType>> clusteringKeys() {
+ List<ImmutablePair<String, DataType>> keys = new ArrayList<>();
+ keys.add(new ImmutablePair<>(TIMESTAMP_FIELD, DataType.timestamp()));
+ return keys;
+ }
+
+ @Override
+ public Map<String, ImmutablePair<DataType, Boolean>> getColumnDescription() {
+ Map<String, ImmutablePair<DataType, Boolean>> columns = new HashMap<>();
+ for (EGAEFieldsDescription field : EGAEFieldsDescription.values()) {
+ columns.put(field.getName(), new ImmutablePair<>(field.type, field.indexed));
+ }
+ return columns;
+ }
+
+ @Override
+ public String getKeyspace() {
+ return AuditingTypesConstants.AUDIT_KEYSPACE.replace("sdc", "att");
+ }
+
+ @Override
+ public String getTableName() {
+ return AuditingTypesConstants.EXTERNAL_API_EVENT_TYPE;
+ }
+
+ @Getter
+ @AllArgsConstructor
+ enum EGAEFieldsDescription {
+ // @formatter:off
+ ACTION("action", DataType.varchar(), true),
+ STATUS("status", DataType.varchar(), false),
+ DESCRIPTION( "description", DataType.varchar(), false),
+ CONSUMER_ID("consumer_id", DataType.varchar(), false),
+ RESOURCE_URL("resource_URL", DataType.varchar(), false),
RESOURCE_NAME("resource_name", DataType.varchar(), false),
- RESOURCE_TYPE("resource_type", DataType.varchar(), false),
+ RESOURCE_TYPE("resource_type", DataType.varchar(), false),
SERVICE_INST_ID( "service_instance_id", DataType.varchar(), true),
INVARIANT_UUID("invariant_uuid", DataType.varchar(), true),
- MODIFIER("modifier", DataType.varchar(), false),
- PREV_VERSION( "prev_version", DataType.varchar(), false),
+ MODIFIER("modifier", DataType.varchar(), false),
+ PREV_VERSION( "prev_version", DataType.varchar(), false),
CURR_VERSION("curr_version", DataType.varchar(), false),
- PREV_STATE("prev_state", DataType.varchar(), false),
- CURR_STATE( "curr_state", DataType.varchar(), false),
+ PREV_STATE("prev_state", DataType.varchar(), false),
+ CURR_STATE( "curr_state", DataType.varchar(), false),
PREV_ARTIFACT_UUID( "prev_artifact_uuid", DataType.varchar(), false),
CURR_ARTIFACT_UUID( "curr_artifact_uuid", DataType.varchar(), false),
ARTIFACT_DATA( "artifact_data", DataType.varchar(), false);
+ // @formatter:on
- private final String name;
- private final DataType type;
- private final boolean indexed;
-
- }
-
+ private final String name;
+ private final DataType type;
+ private final boolean indexed;
+ }
}
-
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/OperationalEnvironmentsTableDescription.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/OperationalEnvironmentsTableDescription.java
index f924d17de5..11209400af 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/OperationalEnvironmentsTableDescription.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/OperationalEnvironmentsTableDescription.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,19 +17,21 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.cassandra.schema.tables;
import com.datastax.driver.core.DataType;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.openecomp.sdc.be.dao.cassandra.schema.ITableDescription;
import org.openecomp.sdc.be.resources.data.auditing.AuditingTypesConstants;
-import java.util.*;
-
-
public class OperationalEnvironmentsTableDescription implements ITableDescription {
private static final String OPERATIONAL_ENVIRONMENT_TABLE = "operationalEnvironment";
@@ -51,7 +53,7 @@ public class OperationalEnvironmentsTableDescription implements ITableDescriptio
public Map<String, ImmutablePair<DataType, Boolean>> getColumnDescription() {
Map<String, ImmutablePair<DataType, Boolean>> columns = new HashMap<>();
Arrays.stream(SdcOperationalEnvironmentFieldsDescription.values())
- .forEach(column -> columns.put(column.getFieldName(), ImmutablePair.of(column.getFieldType(), column.isIndexed())));
+ .forEach(column -> columns.put(column.getFieldName(), ImmutablePair.of(column.getFieldType(), column.isIndexed())));
return columns;
}
@@ -69,6 +71,7 @@ public class OperationalEnvironmentsTableDescription implements ITableDescriptio
@AllArgsConstructor
enum SdcOperationalEnvironmentFieldsDescription {
//there is also PK field "environmentID"
+ // @formatter:off
TENANT("tenant", DataType.varchar(), false),
IS_PRODUCTION("is_production", DataType.cboolean(), false),
ECOMP_WORKLOAD_CONTEXT("ecomp_workload_context", DataType.varchar(), false),
@@ -77,10 +80,10 @@ public class OperationalEnvironmentsTableDescription implements ITableDescriptio
UEB_SECRET_KEY("ueb_secret_key",DataType.varchar(), false),
STATUS("status",DataType.varchar() ,true),
LAST_MODIFIED("last_modified",DataType.timestamp() ,false);
+ // @formatter:on
private final String fieldName;
private final DataType fieldType;
private final boolean isIndexed;
-
}
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/ResAdminEventTableDescription.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/ResAdminEventTableDescription.java
index 75762a39ed..668d353d38 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/ResAdminEventTableDescription.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/ResAdminEventTableDescription.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,100 +17,97 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.cassandra.schema.tables;
import com.datastax.driver.core.DataType;
-import org.apache.commons.lang3.tuple.ImmutablePair;
-import org.openecomp.sdc.be.dao.cassandra.schema.ITableDescription;
-import org.openecomp.sdc.be.resources.data.auditing.AuditingTypesConstants;
-
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import org.apache.commons.lang3.tuple.ImmutablePair;
+import org.openecomp.sdc.be.dao.cassandra.schema.ITableDescription;
+import org.openecomp.sdc.be.resources.data.auditing.AuditingTypesConstants;
public class ResAdminEventTableDescription implements ITableDescription {
- @Override
- public List<ImmutablePair<String, DataType>> primaryKeys() {
- List<ImmutablePair<String, DataType>> keys = new ArrayList<>();
- keys.add(new ImmutablePair<>(TIMEBASED_UUID_FIELD, DataType.timeuuid()));
- return keys;
- }
-
- @Override
- public List<ImmutablePair<String, DataType>> clusteringKeys() {
- List<ImmutablePair<String, DataType>> keys = new ArrayList<>();
- keys.add(new ImmutablePair<>(TIMESTAMP_FIELD, DataType.timestamp()));
- return keys;
- }
-
- @Override
- public Map<String, ImmutablePair<DataType, Boolean>> getColumnDescription() {
- Map<String, ImmutablePair<DataType, Boolean>> columns = new HashMap<>();
-
- for (AEFieldsDescription field : AEFieldsDescription.values()) {
- columns.put(field.getName(), new ImmutablePair<>(field.type, field.indexed));
- }
-
- return columns;
- }
-
- @Override
- public String getKeyspace() {
- return AuditingTypesConstants.AUDIT_KEYSPACE;
- }
-
- @Override
- public String getTableName() {
- return AuditingTypesConstants.RESOURCE_ADMIN_EVENT_TYPE;
- }
-
- enum AEFieldsDescription {
- REQUEST_ID("request_id", DataType.varchar(), false),
- SERVICE_INST_ID("service_instance_id", DataType.varchar(), true),
- INVARIANT_UUID("invariant_UUID", DataType.varchar(), true),
- ACTION("action", DataType.varchar(), true),
+ @Override
+ public List<ImmutablePair<String, DataType>> primaryKeys() {
+ List<ImmutablePair<String, DataType>> keys = new ArrayList<>();
+ keys.add(new ImmutablePair<>(TIMEBASED_UUID_FIELD, DataType.timeuuid()));
+ return keys;
+ }
+
+ @Override
+ public List<ImmutablePair<String, DataType>> clusteringKeys() {
+ List<ImmutablePair<String, DataType>> keys = new ArrayList<>();
+ keys.add(new ImmutablePair<>(TIMESTAMP_FIELD, DataType.timestamp()));
+ return keys;
+ }
+
+ @Override
+ public Map<String, ImmutablePair<DataType, Boolean>> getColumnDescription() {
+ Map<String, ImmutablePair<DataType, Boolean>> columns = new HashMap<>();
+ for (AEFieldsDescription field : AEFieldsDescription.values()) {
+ columns.put(field.getName(), new ImmutablePair<>(field.type, field.indexed));
+ }
+ return columns;
+ }
+
+ @Override
+ public String getKeyspace() {
+ return AuditingTypesConstants.AUDIT_KEYSPACE;
+ }
+
+ @Override
+ public String getTableName() {
+ return AuditingTypesConstants.RESOURCE_ADMIN_EVENT_TYPE;
+ }
+
+ enum AEFieldsDescription {
+ // @formatter:off
+ REQUEST_ID("request_id", DataType.varchar(), false),
+ SERVICE_INST_ID("service_instance_id", DataType.varchar(), true),
+ INVARIANT_UUID("invariant_UUID", DataType.varchar(), true),
+ ACTION("action", DataType.varchar(), true),
STATUS("status", DataType.varchar(), false),
- DESCRIPTION("description",DataType.varchar(), false),
- RESOURCE_TYPE("resource_type", DataType.varchar(), false),
- PREV_VERSION( "prev_version", DataType.varchar(), true),
- PREV_STATE("prev_state", DataType.varchar(), true),
- CURR_STATE("curr_state", DataType.varchar(), false),
- RESOURCE_NAME("resource_name", DataType.varchar(), false),
- CURR_VERSION("curr_version", DataType.varchar(), true),
- MODIFIER("modifier", DataType.varchar(), false),
- PREV_ARTIFACT_UUID("prev_artifact_UUID", DataType.varchar(), false),
- CURR__ARTIFACT_UUID("curr_artifact_UUID", DataType.varchar(), false),
- ARTIFACT_DATA("artifact_data", DataType.varchar(), false),
- DID("did", DataType.varchar(), true),
- DPREV_STATUS("dprev_status", DataType.varchar(), false),
- DCURR_STATUS("dcurr_status", DataType.varchar(), false),
- TOSCA_NODE_TYPE("tosca_node_type", DataType.varchar(), false),
+ DESCRIPTION("description",DataType.varchar(), false),
+ RESOURCE_TYPE("resource_type", DataType.varchar(), false),
+ PREV_VERSION( "prev_version", DataType.varchar(), true),
+ PREV_STATE("prev_state", DataType.varchar(), true),
+ CURR_STATE("curr_state", DataType.varchar(), false),
+ RESOURCE_NAME("resource_name", DataType.varchar(), false),
+ CURR_VERSION("curr_version", DataType.varchar(), true),
+ MODIFIER("modifier", DataType.varchar(), false),
+ PREV_ARTIFACT_UUID("prev_artifact_UUID", DataType.varchar(), false),
+ CURR__ARTIFACT_UUID("curr_artifact_UUID", DataType.varchar(), false),
+ ARTIFACT_DATA("artifact_data", DataType.varchar(), false),
+ DID("did", DataType.varchar(), true),
+ DPREV_STATUS("dprev_status", DataType.varchar(), false),
+ DCURR_STATUS("dcurr_status", DataType.varchar(), false),
+ TOSCA_NODE_TYPE("tosca_node_type", DataType.varchar(), false),
COMMENT("comment", DataType.varchar(), false);
-
- private String name;
- private DataType type;
- private boolean indexed;
-
- AEFieldsDescription(String name, DataType type, boolean indexed) {
- this.name = name;
- this.type = type;
- this.indexed = indexed;
- }
-
- public String getName() {
- return name;
- }
-
- public DataType getType() {
- return type;
- }
-
- public boolean isIndexed() {
- return indexed;
- }
- }
-
+ // @formatter:on
+
+ private String name;
+ private DataType type;
+ private boolean indexed;
+
+ AEFieldsDescription(String name, DataType type, boolean indexed) {
+ this.name = name;
+ this.type = type;
+ this.indexed = indexed;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public DataType getType() {
+ return type;
+ }
+
+ public boolean isIndexed() {
+ return indexed;
+ }
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/SdcSchemaFilesTableDescription.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/SdcSchemaFilesTableDescription.java
index b2fd87a5a4..c8621a1400 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/SdcSchemaFilesTableDescription.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/SdcSchemaFilesTableDescription.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,73 +17,65 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.cassandra.schema.tables;
import com.datastax.driver.core.DataType;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.openecomp.sdc.be.dao.cassandra.schema.ITableDescription;
import org.openecomp.sdc.be.resources.data.auditing.AuditingTypesConstants;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
public class SdcSchemaFilesTableDescription implements ITableDescription {
-
- private static final String SDC_RELEASE_NUM = "sdcReleaseNum";
- private static final String TIMESTAMP = "timestamp";
- private static final String CONFORMANCE_LEVEL = "conformanceLevel";
-
- @Override
- public List<ImmutablePair<String, DataType>> primaryKeys() {
- List<ImmutablePair<String, DataType>> keys = new ArrayList<>();
- keys.add(new ImmutablePair<>(SDC_RELEASE_NUM, DataType.varchar()));
- keys.add(new ImmutablePair<>(CONFORMANCE_LEVEL, DataType.varchar()));
- return keys;
- }
-
- @Override
- public List<ImmutablePair<String, DataType>> clusteringKeys() {
- List<ImmutablePair<String, DataType>> keys = new ArrayList<>();
- keys.add(new ImmutablePair<>(TIMESTAMP, DataType.timestamp()));
- return keys;
- }
-
- @Override
- public Map<String, ImmutablePair<DataType, Boolean>> getColumnDescription() {
- Map<String, ImmutablePair<DataType, Boolean>> columns = new HashMap<>();
- for (SdcSchemaFilesFieldsDescription field : SdcSchemaFilesFieldsDescription.values()) {
- columns.put(field.getName(), new ImmutablePair<>(field.type, field.indexed));
- }
+ private static final String SDC_RELEASE_NUM = "sdcReleaseNum";
+ private static final String TIMESTAMP = "timestamp";
+ private static final String CONFORMANCE_LEVEL = "conformanceLevel";
- return columns;
- }
+ @Override
+ public List<ImmutablePair<String, DataType>> primaryKeys() {
+ List<ImmutablePair<String, DataType>> keys = new ArrayList<>();
+ keys.add(new ImmutablePair<>(SDC_RELEASE_NUM, DataType.varchar()));
+ keys.add(new ImmutablePair<>(CONFORMANCE_LEVEL, DataType.varchar()));
+ return keys;
+ }
- @Override
- public String getKeyspace() {
- return AuditingTypesConstants.ARTIFACT_KEYSPACE;
- }
+ @Override
+ public List<ImmutablePair<String, DataType>> clusteringKeys() {
+ List<ImmutablePair<String, DataType>> keys = new ArrayList<>();
+ keys.add(new ImmutablePair<>(TIMESTAMP, DataType.timestamp()));
+ return keys;
+ }
- @Override
- public String getTableName() {
- return "sdcSchemaFiles";
- }
+ @Override
+ public Map<String, ImmutablePair<DataType, Boolean>> getColumnDescription() {
+ Map<String, ImmutablePair<DataType, Boolean>> columns = new HashMap<>();
+ for (SdcSchemaFilesFieldsDescription field : SdcSchemaFilesFieldsDescription.values()) {
+ columns.put(field.getName(), new ImmutablePair<>(field.type, field.indexed));
+ }
+ return columns;
+ }
- @Getter
- @AllArgsConstructor
- enum SdcSchemaFilesFieldsDescription {
- FILE_NAME("fileName", DataType.varchar(), false),
- PAYLOAD("payload", DataType.blob(), false),
- CHECKSUM("checksum", DataType.varchar(), false);
+ @Override
+ public String getKeyspace() {
+ return AuditingTypesConstants.ARTIFACT_KEYSPACE;
+ }
- private final String name;
- private final DataType type;
- private final boolean indexed;
+ @Override
+ public String getTableName() {
+ return "sdcSchemaFiles";
+ }
- }
+ @Getter
+ @AllArgsConstructor
+ enum SdcSchemaFilesFieldsDescription {
+ FILE_NAME("fileName", DataType.varchar(), false), PAYLOAD("payload", DataType.blob(), false), CHECKSUM("checksum", DataType.varchar(), false);
+ private final String name;
+ private final DataType type;
+ private final boolean indexed;
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/UserAccessEventTableDescription.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/UserAccessEventTableDescription.java
index 5186c7eef9..384dc1a161 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/UserAccessEventTableDescription.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/UserAccessEventTableDescription.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,11 +17,9 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.cassandra.schema.tables;
import com.datastax.driver.core.DataType;
-import com.datastax.driver.mapping.annotations.Column;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -33,55 +31,54 @@ import org.openecomp.sdc.be.dao.cassandra.schema.ITableDescription;
import org.openecomp.sdc.be.resources.data.auditing.AuditingTypesConstants;
public class UserAccessEventTableDescription implements ITableDescription {
- @Override
- public List<ImmutablePair<String, DataType>> primaryKeys() {
- List<ImmutablePair<String, DataType>> keys = new ArrayList<>();
- keys.add(new ImmutablePair<>(TIMEBASED_UUID_FIELD, DataType.timeuuid()));
- return keys;
- }
-
- @Override
- public List<ImmutablePair<String, DataType>> clusteringKeys() {
- List<ImmutablePair<String, DataType>> keys = new ArrayList<>();
- keys.add(new ImmutablePair<>(TIMESTAMP_FIELD, DataType.timestamp()));
- return keys;
- }
- @Override
- public Map<String, ImmutablePair<DataType, Boolean>> getColumnDescription() {
- Map<String, ImmutablePair<DataType, Boolean>> columns = new HashMap<>();
+ @Override
+ public List<ImmutablePair<String, DataType>> primaryKeys() {
+ List<ImmutablePair<String, DataType>> keys = new ArrayList<>();
+ keys.add(new ImmutablePair<>(TIMEBASED_UUID_FIELD, DataType.timeuuid()));
+ return keys;
+ }
- for (UAEFieldsDescription field : UAEFieldsDescription.values()) {
- columns.put(field.getName(), new ImmutablePair<>(field.type, field.indexed));
- }
+ @Override
+ public List<ImmutablePair<String, DataType>> clusteringKeys() {
+ List<ImmutablePair<String, DataType>> keys = new ArrayList<>();
+ keys.add(new ImmutablePair<>(TIMESTAMP_FIELD, DataType.timestamp()));
+ return keys;
+ }
- return columns;
- }
+ @Override
+ public Map<String, ImmutablePair<DataType, Boolean>> getColumnDescription() {
+ Map<String, ImmutablePair<DataType, Boolean>> columns = new HashMap<>();
+ for (UAEFieldsDescription field : UAEFieldsDescription.values()) {
+ columns.put(field.getName(), new ImmutablePair<>(field.type, field.indexed));
+ }
+ return columns;
+ }
- @Override
- public String getKeyspace() {
- return AuditingTypesConstants.AUDIT_KEYSPACE;
- }
+ @Override
+ public String getKeyspace() {
+ return AuditingTypesConstants.AUDIT_KEYSPACE;
+ }
- @Override
- public String getTableName() {
- return AuditingTypesConstants.USER_ACCESS_EVENT_TYPE;
- }
+ @Override
+ public String getTableName() {
+ return AuditingTypesConstants.USER_ACCESS_EVENT_TYPE;
+ }
- @Getter
- @AllArgsConstructor
- enum UAEFieldsDescription {
- REQUEST_ID("request_Id", DataType.varchar(), false),
+ @Getter
+ @AllArgsConstructor
+ enum UAEFieldsDescription {
+ // @formatter:off
+ REQUEST_ID("request_Id", DataType.varchar(), false),
USER("USER", DataType.varchar(), false),
ACTION("action", DataType.varchar(), true),
STATUS("status", DataType.varchar(), false),
DESCRIPTION("description", DataType.varchar(), false),
SERVICE_INSTANCE_ID("service_instance_id", DataType.varchar(), false);
+ // @formatter:on
- private final String name;
- private final DataType type;
- private final boolean indexed;
-
- }
-
+ private final String name;
+ private final DataType type;
+ private final boolean indexed;
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/UserAdminEventTableDescription.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/UserAdminEventTableDescription.java
index 9dc8243a21..8a5ab44031 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/UserAdminEventTableDescription.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/schema/tables/UserAdminEventTableDescription.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,84 +17,84 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.cassandra.schema.tables;
import com.datastax.driver.core.DataType;
-import org.apache.commons.lang3.tuple.ImmutablePair;
-import org.openecomp.sdc.be.dao.cassandra.schema.ITableDescription;
-import org.openecomp.sdc.be.resources.data.auditing.AuditingTypesConstants;
-
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import org.apache.commons.lang3.tuple.ImmutablePair;
+import org.openecomp.sdc.be.dao.cassandra.schema.ITableDescription;
+import org.openecomp.sdc.be.resources.data.auditing.AuditingTypesConstants;
public class UserAdminEventTableDescription implements ITableDescription {
- @Override
- public List<ImmutablePair<String, DataType>> primaryKeys() {
- List<ImmutablePair<String, DataType>> keys = new ArrayList<>();
- keys.add(new ImmutablePair<>(TIMEBASED_UUID_FIELD, DataType.timeuuid()));
- return keys;
- }
-
- @Override
- public List<ImmutablePair<String, DataType>> clusteringKeys() {
- List<ImmutablePair<String, DataType>> keys = new ArrayList<>();
- keys.add(new ImmutablePair<>(TIMESTAMP_FIELD, DataType.timestamp()));
- return keys;
- }
-
- @Override
- public Map<String, ImmutablePair<DataType, Boolean>> getColumnDescription() {
- Map<String, ImmutablePair<DataType, Boolean>> columns = new HashMap<>();
-
- for (UAEFieldsDescription field : UAEFieldsDescription.values()) {
- columns.put(field.getName(), new ImmutablePair<>(field.type, field.indexed));
- }
-
- return columns;
- }
-
- @Override
- public String getKeyspace() {
- return AuditingTypesConstants.AUDIT_KEYSPACE;
- }
-
- @Override
- public String getTableName() {
- return AuditingTypesConstants.USER_ADMIN_EVENT_TYPE;
- }
-
- enum UAEFieldsDescription {
- REQUEST_ID("request_id", DataType.varchar(), false), SERVICE_INST_ID("service_instance_id", DataType.varchar(),
- false), ACTION("action", DataType.varchar(), true), STATUS("status", DataType.varchar(),
- false), DESCRIPTION("description", DataType.varchar(), false), MODIFIER("modifier",
- DataType.varchar(), false), USER_BEFORE("user_before", DataType.varchar(),
- false), USER_AFTER("user_after", DataType.varchar(), false);
-
- private String name;
- private DataType type;
- private boolean indexed;
-
- UAEFieldsDescription(String name, DataType type, boolean indexed) {
- this.name = name;
- this.type = type;
- this.indexed = indexed;
- }
-
- public String getName() {
- return name;
- }
-
- public DataType getType() {
- return type;
- }
-
- public boolean isIndexed() {
- return indexed;
- }
- }
-
+ @Override
+ public List<ImmutablePair<String, DataType>> primaryKeys() {
+ List<ImmutablePair<String, DataType>> keys = new ArrayList<>();
+ keys.add(new ImmutablePair<>(TIMEBASED_UUID_FIELD, DataType.timeuuid()));
+ return keys;
+ }
+
+ @Override
+ public List<ImmutablePair<String, DataType>> clusteringKeys() {
+ List<ImmutablePair<String, DataType>> keys = new ArrayList<>();
+ keys.add(new ImmutablePair<>(TIMESTAMP_FIELD, DataType.timestamp()));
+ return keys;
+ }
+
+ @Override
+ public Map<String, ImmutablePair<DataType, Boolean>> getColumnDescription() {
+ Map<String, ImmutablePair<DataType, Boolean>> columns = new HashMap<>();
+ for (UAEFieldsDescription field : UAEFieldsDescription.values()) {
+ columns.put(field.getName(), new ImmutablePair<>(field.type, field.indexed));
+ }
+ return columns;
+ }
+
+ @Override
+ public String getKeyspace() {
+ return AuditingTypesConstants.AUDIT_KEYSPACE;
+ }
+
+ @Override
+ public String getTableName() {
+ return AuditingTypesConstants.USER_ADMIN_EVENT_TYPE;
+ }
+
+ enum UAEFieldsDescription {
+ // @formatter:off
+ REQUEST_ID("request_id", DataType.varchar(), false),
+ SERVICE_INST_ID("service_instance_id", DataType.varchar(), false),
+ ACTION("action", DataType.varchar(), true),
+ STATUS("status", DataType.varchar(), false),
+ DESCRIPTION("description", DataType.varchar(), false),
+ MODIFIER("modifier", DataType.varchar(), false),
+ USER_BEFORE("user_before", DataType.varchar(), false),
+ USER_AFTER("user_after", DataType.varchar(), false);
+ // @formatter:on
+
+ private String name;
+ private DataType type;
+ private boolean indexed;
+
+ UAEFieldsDescription(String name, DataType type, boolean indexed) {
+ this.name = name;
+ this.type = type;
+ this.indexed = indexed;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public DataType getType() {
+ return type;
+ }
+
+ public boolean isIndexed() {
+ return indexed;
+ }
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/config/DAOSpringConfig.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/config/DAOSpringConfig.java
index d57ae29b1b..68852d272f 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/config/DAOSpringConfig.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/config/DAOSpringConfig.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.config;
import org.springframework.context.annotation.ComponentScan;
@@ -28,10 +27,9 @@ import org.springframework.context.annotation.PropertySource;
@Configuration
@Import({JanusGraphSpringConfig.class})
@ComponentScan({
- "org.openecomp.sdc.be.dao.cassandra",
- "org.openecomp.sdc.be.dao.neo4j",
- "org.openecomp.sdc.be.dao.impl"
- })
+ "org.openecomp.sdc.be.dao.cassandra",
+ "org.openecomp.sdc.be.dao.neo4j",
+ "org.openecomp.sdc.be.dao.impl"})
@PropertySource("classpath:dao.properties")
public class DAOSpringConfig {
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/config/JanusGraphSpringConfig.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/config/JanusGraphSpringConfig.java
index 5601a79af1..5f6c237085 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/config/JanusGraphSpringConfig.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/config/JanusGraphSpringConfig.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.config;
import org.openecomp.sdc.be.dao.DAOJanusGraphStrategy;
@@ -35,9 +34,7 @@ import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;
@Configuration
-@ComponentScan({
- "org.openecomp.sdc.be.dao.jsongraph",
-})
+@ComponentScan({"org.openecomp.sdc.be.dao.jsongraph",})
@EnableTransactionManagement
public class JanusGraphSpringConfig {
@@ -49,8 +46,7 @@ public class JanusGraphSpringConfig {
@Bean(name = "janusgraph-client", initMethod = "createGraph")
@Primary
- public JanusGraphClient janusGraphClient(@Qualifier("dao-client-strategy")
- JanusGraphClientStrategy janusGraphClientStrategy) {
+ public JanusGraphClient janusGraphClient(@Qualifier("dao-client-strategy") JanusGraphClientStrategy janusGraphClientStrategy) {
return new JanusGraphClient(janusGraphClientStrategy);
}
@@ -65,7 +61,7 @@ public class JanusGraphSpringConfig {
}
@Bean(name = "healingPipelineDao")
- public HealingPipelineDao healingPipeline(){
+ public HealingPipelineDao healingPipeline() {
HealingPipelineDao healingPipelineDao = new HealingPipelineDao();
healingPipelineDao.setHealVersion(1);
healingPipelineDao.initHealVersion();
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/graph/GraphElementFactory.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/graph/GraphElementFactory.java
index 3a0a42c2cd..c3c5e9f704 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/graph/GraphElementFactory.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/graph/GraphElementFactory.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,223 +17,248 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.graph;
+import java.util.Map;
import org.openecomp.sdc.be.dao.graph.datatype.GraphElementTypeEnum;
import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
import org.openecomp.sdc.be.dao.graph.datatype.GraphRelation;
import org.openecomp.sdc.be.dao.graph.datatype.RelationEndPoint;
import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionaryExtractor;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import org.openecomp.sdc.be.resources.data.*;
+import org.openecomp.sdc.be.resources.data.AdditionalInfoParameterData;
+import org.openecomp.sdc.be.resources.data.AnnotationTypeData;
+import org.openecomp.sdc.be.resources.data.ArtifactData;
+import org.openecomp.sdc.be.resources.data.AttributeData;
+import org.openecomp.sdc.be.resources.data.AttributeValueData;
+import org.openecomp.sdc.be.resources.data.CapabilityData;
+import org.openecomp.sdc.be.resources.data.CapabilityInstData;
+import org.openecomp.sdc.be.resources.data.CapabilityTypeData;
+import org.openecomp.sdc.be.resources.data.ComponentInstanceData;
+import org.openecomp.sdc.be.resources.data.ConsumerData;
+import org.openecomp.sdc.be.resources.data.DataTypeData;
+import org.openecomp.sdc.be.resources.data.GraphNodeLock;
+import org.openecomp.sdc.be.resources.data.GroupData;
+import org.openecomp.sdc.be.resources.data.GroupInstanceData;
+import org.openecomp.sdc.be.resources.data.GroupTypeData;
+import org.openecomp.sdc.be.resources.data.HeatParameterData;
+import org.openecomp.sdc.be.resources.data.HeatParameterValueData;
+import org.openecomp.sdc.be.resources.data.InputValueData;
+import org.openecomp.sdc.be.resources.data.InputsData;
+import org.openecomp.sdc.be.resources.data.InterfaceData;
+import org.openecomp.sdc.be.resources.data.OperationData;
+import org.openecomp.sdc.be.resources.data.PolicyTypeData;
+import org.openecomp.sdc.be.resources.data.ProductMetadataData;
+import org.openecomp.sdc.be.resources.data.PropertyData;
+import org.openecomp.sdc.be.resources.data.PropertyValueData;
+import org.openecomp.sdc.be.resources.data.RelationshipInstData;
+import org.openecomp.sdc.be.resources.data.RelationshipTypeData;
+import org.openecomp.sdc.be.resources.data.RequirementData;
+import org.openecomp.sdc.be.resources.data.RequirementImplData;
+import org.openecomp.sdc.be.resources.data.ResourceCategoryData;
+import org.openecomp.sdc.be.resources.data.ResourceMetadataData;
+import org.openecomp.sdc.be.resources.data.ServiceCategoryData;
+import org.openecomp.sdc.be.resources.data.ServiceMetadataData;
+import org.openecomp.sdc.be.resources.data.TagData;
+import org.openecomp.sdc.be.resources.data.UserData;
+import org.openecomp.sdc.be.resources.data.UserFunctionalMenuData;
import org.openecomp.sdc.be.resources.data.category.CategoryData;
import org.openecomp.sdc.be.resources.data.category.GroupingData;
import org.openecomp.sdc.be.resources.data.category.SubCategoryData;
-import java.util.Map;
-
public class GraphElementFactory {
- public static <T extends GraphNode> T createElement(String label, GraphElementTypeEnum type,
- Map<String, Object> properties, Class<T> clazz) {
- T element = null;
-
- if (type.equals(GraphElementTypeEnum.Node)) {
- element = createNode(label, properties, clazz);
- }
- return element;
- }
-
- public static GraphNode createElement(String label, GraphElementTypeEnum type, Map<String, Object> properties) {
- GraphNode element = null;
-
- if (type.equals(GraphElementTypeEnum.Node)) {
- element = createNode(label, properties);
- }
- return element;
- }
-
- public static GraphRelation createRelation(String type, Map<String, Object> properties, GraphNode from,
- GraphNode to) {
- GraphRelation element = new GraphRelation(type);
- RelationEndPoint endPOintFrom = new RelationEndPoint(NodeTypeEnum.getByName(from.getLabel()),
- from.getUniqueIdKey(), from.getUniqueId());
- RelationEndPoint endPOintTo = new RelationEndPoint(NodeTypeEnum.getByName(to.getLabel()), to.getUniqueIdKey(),
- to.getUniqueId());
- element.setFrom(endPOintFrom);
- element.setTo(endPOintTo);
- element.addPropertis(properties);
- return element;
- }
+ public static <T extends GraphNode> T createElement(String label, GraphElementTypeEnum type, Map<String, Object> properties, Class<T> clazz) {
+ T element = null;
+ if (type.equals(GraphElementTypeEnum.Node)) {
+ element = createNode(label, properties, clazz);
+ }
+ return element;
+ }
- private static GraphNode createNode(String label, Map<String, Object> properties) {
- GraphNode element = null;
- NodeTypeEnum type = NodeTypeEnum.getByName(label);
- if (type != null) {
- switch (type) {
- case User:
- element = new UserData(properties);
- break;
- case ResourceCategory:
- element = new ResourceCategoryData(properties);
- break;
- case ServiceCategory:
- element = new ServiceCategoryData(properties);
- break;
- case Tag:
- element = new TagData(properties);
- break;
- case Service:
- element = new ServiceMetadataData(new GraphPropertiesDictionaryExtractor(properties));
- break;
- case Resource:
- element = new ResourceMetadataData(new GraphPropertiesDictionaryExtractor(properties));
- break;
- case Property:
- element = new PropertyData(properties);
- break;
- case HeatParameter:
- element = new HeatParameterData(properties);
- break;
- case HeatParameterValue:
- element = new HeatParameterValueData(properties);
- break;
- }
- }
- return element;
- }
+ public static GraphNode createElement(String label, GraphElementTypeEnum type, Map<String, Object> properties) {
+ GraphNode element = null;
+ if (type.equals(GraphElementTypeEnum.Node)) {
+ element = createNode(label, properties);
+ }
+ return element;
+ }
- private static <T extends GraphNode> T createNode(String label, Map<String, Object> properties, Class<T> clazz) {
- T element = null;
- NodeTypeEnum type = NodeTypeEnum.getByName(label);
- if (type != null) {
- switch (type) {
- case User:
- element = clazz.cast(new UserData(properties));
- break;
- case ResourceCategory:
- element = clazz.cast(new ResourceCategoryData(properties));
- break;
- case ServiceCategory:
- element = clazz.cast(new ServiceCategoryData(properties));
- break;
- case ResourceNewCategory:
- case ServiceNewCategory:
- case ProductCategory:
- element = clazz.cast(new CategoryData(properties));
- break;
- case ResourceSubcategory:
- case ProductSubcategory:
- element = clazz.cast(new SubCategoryData(properties));
- break;
- case ProductGrouping:
- element = clazz.cast(new GroupingData(properties));
- break;
- case Tag:
- element = clazz.cast(new TagData(properties));
- break;
- case Service:
- element = clazz.cast(new ServiceMetadataData(new GraphPropertiesDictionaryExtractor(properties)));
- break;
- case Product:
- element = clazz.cast(new ProductMetadataData(new GraphPropertiesDictionaryExtractor(properties)));
- break;
- case Resource:
- element = clazz.cast(new ResourceMetadataData(new GraphPropertiesDictionaryExtractor(properties)));
- break;
- case Attribute:
- element = clazz.cast(new AttributeData(properties));
- break;
- case Property:
- element = clazz.cast(new PropertyData(properties));
- break;
- case CapabilityType:
- element = clazz.cast(new CapabilityTypeData(properties));
- break;
- case Requirement:
- element = clazz.cast(new RequirementData(properties));
- break;
- case RequirementImpl:
- element = clazz.cast(new RequirementImplData(properties));
- break;
- case Capability:
- element = clazz.cast(new CapabilityData(properties));
- break;
- case CapabilityInst:
- element = clazz.cast(new CapabilityInstData(properties));
- break;
- case PropertyValue:
- element = clazz.cast(new PropertyValueData(properties));
- break;
- case AttributeValue:
- element = clazz.cast(new AttributeValueData(properties));
- break;
- case InputValue:
- element = clazz.cast(new InputValueData(properties));
- break;
- case RelationshipType:
- element = clazz.cast(new RelationshipTypeData(properties));
- break;
- case LockNode:
- element = clazz.cast(new GraphNodeLock(properties));
- break;
- case ArtifactRef:
- element = clazz.cast(new ArtifactData(properties));
- break;
- case Interface:
- element = clazz.cast(new InterfaceData(properties));
- break;
- case InterfaceOperation:
- element = clazz.cast(new OperationData(properties));
- break;
- case Input:
- element = clazz.cast(new InputsData(properties));
- break;
- case ResourceInstance:
- element = clazz.cast(new ComponentInstanceData(properties));
- break;
- case RelationshipInst:
- element = clazz.cast(new RelationshipInstData(properties));
- break;
- case AdditionalInfoParameters:
- element = clazz.cast(new AdditionalInfoParameterData(properties));
- break;
- case ConsumerCredentials:
- element = clazz.cast(new ConsumerData(properties));
- break;
- case HeatParameter:
- element = clazz.cast(new HeatParameterData(properties));
- break;
- case HeatParameterValue:
- element = clazz.cast(new HeatParameterValueData(properties));
- break;
- case DataType:
- element = clazz.cast(new DataTypeData(properties));
- break;
- case Group:
- element = clazz.cast(new GroupData(properties));
- break;
- case GroupType:
- element = clazz.cast(new GroupTypeData(properties));
- break;
- case UserFunctionalMenu:
- element = clazz.cast(new UserFunctionalMenuData(properties));
- break;
- case PolicyType:
- element = clazz.cast(new PolicyTypeData(properties));
- break;
- case GroupInstance:
- element = clazz.cast(new GroupInstanceData(properties));
- break;
- case AnnotationType:
- element = clazz.cast(new AnnotationTypeData(properties));
- default:
- break;
- }
+ public static GraphRelation createRelation(String type, Map<String, Object> properties, GraphNode from, GraphNode to) {
+ GraphRelation element = new GraphRelation(type);
+ RelationEndPoint endPOintFrom = new RelationEndPoint(NodeTypeEnum.getByName(from.getLabel()), from.getUniqueIdKey(), from.getUniqueId());
+ RelationEndPoint endPOintTo = new RelationEndPoint(NodeTypeEnum.getByName(to.getLabel()), to.getUniqueIdKey(), to.getUniqueId());
+ element.setFrom(endPOintFrom);
+ element.setTo(endPOintTo);
+ element.addPropertis(properties);
+ return element;
+ }
- }
- return element;
- }
+ private static GraphNode createNode(String label, Map<String, Object> properties) {
+ GraphNode element = null;
+ NodeTypeEnum type = NodeTypeEnum.getByName(label);
+ if (type != null) {
+ switch (type) {
+ case User:
+ element = new UserData(properties);
+ break;
+ case ResourceCategory:
+ element = new ResourceCategoryData(properties);
+ break;
+ case ServiceCategory:
+ element = new ServiceCategoryData(properties);
+ break;
+ case Tag:
+ element = new TagData(properties);
+ break;
+ case Service:
+ element = new ServiceMetadataData(new GraphPropertiesDictionaryExtractor(properties));
+ break;
+ case Resource:
+ element = new ResourceMetadataData(new GraphPropertiesDictionaryExtractor(properties));
+ break;
+ case Property:
+ element = new PropertyData(properties);
+ break;
+ case HeatParameter:
+ element = new HeatParameterData(properties);
+ break;
+ case HeatParameterValue:
+ element = new HeatParameterValueData(properties);
+ break;
+ }
+ }
+ return element;
+ }
+ private static <T extends GraphNode> T createNode(String label, Map<String, Object> properties, Class<T> clazz) {
+ T element = null;
+ NodeTypeEnum type = NodeTypeEnum.getByName(label);
+ if (type != null) {
+ switch (type) {
+ case User:
+ element = clazz.cast(new UserData(properties));
+ break;
+ case ResourceCategory:
+ element = clazz.cast(new ResourceCategoryData(properties));
+ break;
+ case ServiceCategory:
+ element = clazz.cast(new ServiceCategoryData(properties));
+ break;
+ case ResourceNewCategory:
+ case ServiceNewCategory:
+ case ProductCategory:
+ element = clazz.cast(new CategoryData(properties));
+ break;
+ case ResourceSubcategory:
+ case ProductSubcategory:
+ element = clazz.cast(new SubCategoryData(properties));
+ break;
+ case ProductGrouping:
+ element = clazz.cast(new GroupingData(properties));
+ break;
+ case Tag:
+ element = clazz.cast(new TagData(properties));
+ break;
+ case Service:
+ element = clazz.cast(new ServiceMetadataData(new GraphPropertiesDictionaryExtractor(properties)));
+ break;
+ case Product:
+ element = clazz.cast(new ProductMetadataData(new GraphPropertiesDictionaryExtractor(properties)));
+ break;
+ case Resource:
+ element = clazz.cast(new ResourceMetadataData(new GraphPropertiesDictionaryExtractor(properties)));
+ break;
+ case Attribute:
+ element = clazz.cast(new AttributeData(properties));
+ break;
+ case Property:
+ element = clazz.cast(new PropertyData(properties));
+ break;
+ case CapabilityType:
+ element = clazz.cast(new CapabilityTypeData(properties));
+ break;
+ case Requirement:
+ element = clazz.cast(new RequirementData(properties));
+ break;
+ case RequirementImpl:
+ element = clazz.cast(new RequirementImplData(properties));
+ break;
+ case Capability:
+ element = clazz.cast(new CapabilityData(properties));
+ break;
+ case CapabilityInst:
+ element = clazz.cast(new CapabilityInstData(properties));
+ break;
+ case PropertyValue:
+ element = clazz.cast(new PropertyValueData(properties));
+ break;
+ case AttributeValue:
+ element = clazz.cast(new AttributeValueData(properties));
+ break;
+ case InputValue:
+ element = clazz.cast(new InputValueData(properties));
+ break;
+ case RelationshipType:
+ element = clazz.cast(new RelationshipTypeData(properties));
+ break;
+ case LockNode:
+ element = clazz.cast(new GraphNodeLock(properties));
+ break;
+ case ArtifactRef:
+ element = clazz.cast(new ArtifactData(properties));
+ break;
+ case Interface:
+ element = clazz.cast(new InterfaceData(properties));
+ break;
+ case InterfaceOperation:
+ element = clazz.cast(new OperationData(properties));
+ break;
+ case Input:
+ element = clazz.cast(new InputsData(properties));
+ break;
+ case ResourceInstance:
+ element = clazz.cast(new ComponentInstanceData(properties));
+ break;
+ case RelationshipInst:
+ element = clazz.cast(new RelationshipInstData(properties));
+ break;
+ case AdditionalInfoParameters:
+ element = clazz.cast(new AdditionalInfoParameterData(properties));
+ break;
+ case ConsumerCredentials:
+ element = clazz.cast(new ConsumerData(properties));
+ break;
+ case HeatParameter:
+ element = clazz.cast(new HeatParameterData(properties));
+ break;
+ case HeatParameterValue:
+ element = clazz.cast(new HeatParameterValueData(properties));
+ break;
+ case DataType:
+ element = clazz.cast(new DataTypeData(properties));
+ break;
+ case Group:
+ element = clazz.cast(new GroupData(properties));
+ break;
+ case GroupType:
+ element = clazz.cast(new GroupTypeData(properties));
+ break;
+ case UserFunctionalMenu:
+ element = clazz.cast(new UserFunctionalMenuData(properties));
+ break;
+ case PolicyType:
+ element = clazz.cast(new PolicyTypeData(properties));
+ break;
+ case GroupInstance:
+ element = clazz.cast(new GroupInstanceData(properties));
+ break;
+ case AnnotationType:
+ element = clazz.cast(new AnnotationTypeData(properties));
+ default:
+ break;
+ }
+ }
+ return element;
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/graph/datatype/ActionEnum.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/graph/datatype/ActionEnum.java
index 13ef58ddf5..79c930d1b9 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/graph/datatype/ActionEnum.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/graph/datatype/ActionEnum.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,9 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.graph.datatype;
-public enum ActionEnum {
- Create, Update, Delete, NoAction
-}
+public enum ActionEnum {Create, Update, Delete, NoAction}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/graph/datatype/AdditionalInformationEnum.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/graph/datatype/AdditionalInformationEnum.java
index ea59ef81ac..bbfe00bafa 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/graph/datatype/AdditionalInformationEnum.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/graph/datatype/AdditionalInformationEnum.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,9 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.graph.datatype;
-public enum AdditionalInformationEnum {
- Label, Value, None;
-}
+public enum AdditionalInformationEnum {Label, Value, None;}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/graph/datatype/GraphEdge.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/graph/datatype/GraphEdge.java
index 6afecc4e0a..d204e80225 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/graph/datatype/GraphEdge.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/graph/datatype/GraphEdge.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,76 +17,78 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.graph.datatype;
-import org.openecomp.sdc.be.dao.neo4j.GraphEdgeLabels;
-
import java.util.Map;
+import org.openecomp.sdc.be.dao.neo4j.GraphEdgeLabels;
public class GraphEdge {
- private GraphEdgeLabels edgeType;
-
- private Map<String, Object> properties;
-
- public GraphEdge() {
- super();
- }
-
- public GraphEdge(GraphEdgeLabels edgeType, Map<String, Object> properties) {
- super();
- this.edgeType = edgeType;
- this.properties = properties;
- }
-
- public GraphEdgeLabels getEdgeType() {
- return edgeType;
- }
-
- public void setEdgeType(GraphEdgeLabels edgeType) {
- this.edgeType = edgeType;
- }
-
- public Map<String, Object> getProperties() {
- return properties;
- }
-
- public void setProperties(Map<String, Object> properties) {
- this.properties = properties;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((edgeType == null) ? 0 : edgeType.hashCode());
- result = prime * result + ((properties == null) ? 0 : properties.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- GraphEdge other = (GraphEdge) obj;
- if (edgeType != other.edgeType)
- return false;
- if (properties == null) {
- if (other.properties != null)
- return false;
- } else if (!properties.equals(other.properties))
- return false;
- return true;
- }
-
- @Override
- public String toString() {
- return "GraphEdge [edgeType=" + edgeType + ", properties=" + properties + "]";
- }
-
+ private GraphEdgeLabels edgeType;
+ private Map<String, Object> properties;
+
+ public GraphEdge() {
+ super();
+ }
+
+ public GraphEdge(GraphEdgeLabels edgeType, Map<String, Object> properties) {
+ super();
+ this.edgeType = edgeType;
+ this.properties = properties;
+ }
+
+ public GraphEdgeLabels getEdgeType() {
+ return edgeType;
+ }
+
+ public void setEdgeType(GraphEdgeLabels edgeType) {
+ this.edgeType = edgeType;
+ }
+
+ public Map<String, Object> getProperties() {
+ return properties;
+ }
+
+ public void setProperties(Map<String, Object> properties) {
+ this.properties = properties;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((edgeType == null) ? 0 : edgeType.hashCode());
+ result = prime * result + ((properties == null) ? 0 : properties.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ GraphEdge other = (GraphEdge) obj;
+ if (edgeType != other.edgeType) {
+ return false;
+ }
+ if (properties == null) {
+ if (other.properties != null) {
+ return false;
+ }
+ } else if (!properties.equals(other.properties)) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return "GraphEdge [edgeType=" + edgeType + ", properties=" + properties + "]";
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/graph/datatype/GraphElement.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/graph/datatype/GraphElement.java
index 660e28c674..029cda7c81 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/graph/datatype/GraphElement.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/graph/datatype/GraphElement.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,42 +17,40 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.graph.datatype;
import java.util.Map;
public abstract class GraphElement {
- private GraphElementTypeEnum elementType;
- private ActionEnum action;
-
- protected GraphElement(GraphElementTypeEnum elementType) {
- this.elementType = elementType;
- this.action = ActionEnum.NoAction;
- }
+ private GraphElementTypeEnum elementType;
+ private ActionEnum action;
- public GraphElementTypeEnum getElementType() {
- return elementType;
- }
+ protected GraphElement(GraphElementTypeEnum elementType) {
+ this.elementType = elementType;
+ this.action = ActionEnum.NoAction;
+ }
- public ActionEnum getAction() {
- return action;
- }
+ public GraphElementTypeEnum getElementType() {
+ return elementType;
+ }
- public void setAction(ActionEnum action) {
- this.action = action;
- }
+ public void setElementType(GraphElementTypeEnum elementType) {
+ this.elementType = elementType;
+ }
- public void setElementType(GraphElementTypeEnum elementType) {
- this.elementType = elementType;
- }
+ public ActionEnum getAction() {
+ return action;
+ }
- public abstract Map<String, Object> toGraphMap();
+ public void setAction(ActionEnum action) {
+ this.action = action;
+ }
- @Override
- public String toString() {
- return "GraphElement [elementType=" + elementType + ", action=" + action + "]";
- }
+ public abstract Map<String, Object> toGraphMap();
+ @Override
+ public String toString() {
+ return "GraphElement [elementType=" + elementType + ", action=" + action + "]";
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/graph/datatype/GraphElementTypeEnum.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/graph/datatype/GraphElementTypeEnum.java
index 0d39b3e39e..1a5b5b3c13 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/graph/datatype/GraphElementTypeEnum.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/graph/datatype/GraphElementTypeEnum.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,9 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.graph.datatype;
-public enum GraphElementTypeEnum {
- Node, Relationship
-}
+public enum GraphElementTypeEnum {Node, Relationship}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/graph/datatype/GraphNode.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/graph/datatype/GraphNode.java
index 174416281b..477e4f9b50 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/graph/datatype/GraphNode.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/graph/datatype/GraphNode.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.graph.datatype;
import com.google.gson.Gson;
@@ -31,75 +30,68 @@ import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
public abstract class GraphNode extends GraphElement {
- private static final Gson gson = new Gson();
-
- private NodeTypeEnum label;
-
- protected Gson getGson() {
- return gson;
- }
+ private static final Gson gson = new Gson();
+ private NodeTypeEnum label;
- protected GraphNode(NodeTypeEnum label) {
- super(GraphElementTypeEnum.Node);
+ protected GraphNode(NodeTypeEnum label) {
+ super(GraphElementTypeEnum.Node);
+ this.label = label;
+ }
- this.label = label;
- }
+ protected Gson getGson() {
+ return gson;
+ }
- public String getLabel() {
- return label.getName();
- }
+ public String getLabel() {
+ return label.getName();
+ }
- public ImmutablePair<String, Object> getKeyValueId() {
+ public ImmutablePair<String, Object> getKeyValueId() {
return new ImmutablePair<>(getUniqueIdKey(), getUniqueId());
- }
-
-
- public ImmutablePair<String, Object> getKeyValueIdForLog() {
- return getKeyValueId();
- }
-
- protected void addIfExists(Map<String, Object> map, GraphPropertiesDictionary property, Object value) {
- if (value != null) {
- if (value instanceof List || value instanceof Map) {
- value = getGson().toJson(value);
- }
- map.put(property.getProperty(), value);
- }
- }
-
-
-
- public abstract String getUniqueId();
-
-
- public String getUniqueIdKey() {
- return GraphPropertiesDictionary.UNIQUE_ID.getProperty();
- }
-
- public String getHealingVersionKey() {
- return GraphPropertyEnum.HEALING_VERSION.getProperty();
- }
-
- /**
- * Must be overridden in implelemting classes
- * @return current heal version. Default heal version if function not implemented.
- */
- public Integer getHealingVersion(){
- return HealConstants.DEFAULT_HEAL_VERSION;
- }
-
- /**
- * Must be overriden in implementing classes
- * @param version healing version number
- */
- public void setHealingVersion(Integer version){
-
- }
-
- @Override
- public String toString() {
- return "GraphNode [label=" + label + ", parent: " + super.toString() + "]";
- }
-
-
+ }
+
+ public ImmutablePair<String, Object> getKeyValueIdForLog() {
+ return getKeyValueId();
+ }
+
+ protected void addIfExists(Map<String, Object> map, GraphPropertiesDictionary property, Object value) {
+ if (value != null) {
+ if (value instanceof List || value instanceof Map) {
+ value = getGson().toJson(value);
+ }
+ map.put(property.getProperty(), value);
+ }
+ }
+
+ public abstract String getUniqueId();
+
+ public String getUniqueIdKey() {
+ return GraphPropertiesDictionary.UNIQUE_ID.getProperty();
+ }
+
+ public String getHealingVersionKey() {
+ return GraphPropertyEnum.HEALING_VERSION.getProperty();
+ }
+
+ /**
+ * Must be overridden in implelemting classes
+ *
+ * @return current heal version. Default heal version if function not implemented.
+ */
+ public Integer getHealingVersion() {
+ return HealConstants.DEFAULT_HEAL_VERSION;
+ }
+
+ /**
+ * Must be overriden in implementing classes
+ *
+ * @param version healing version number
+ */
+ public void setHealingVersion(Integer version) {
+ }
+
+ @Override
+ public String toString() {
+ return "GraphNode [label=" + label + ", parent: " + super.toString() + "]";
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/graph/datatype/GraphRelation.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/graph/datatype/GraphRelation.java
index 3249f37b31..5989ec4b27 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/graph/datatype/GraphRelation.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/graph/datatype/GraphRelation.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.graph.datatype;
import java.util.HashMap;
@@ -26,101 +25,100 @@ import org.apache.commons.lang3.builder.EqualsBuilder;
public class GraphRelation extends GraphElement {
- private RelationEndPoint from;
- private RelationEndPoint to;
- private String type;
- private Map<String, Object> properties;
-
- public GraphRelation() {
- super(GraphElementTypeEnum.Relationship);
- properties = new HashMap<>();
- }
-
- public GraphRelation(String type) {
- super(GraphElementTypeEnum.Relationship);
- properties = new HashMap<>();
- setType(type);
- }
-
- public RelationEndPoint getFrom() {
- return from;
- }
-
- public void setFrom(RelationEndPoint from) {
- this.from = from;
- }
-
- public RelationEndPoint getTo() {
- return to;
- }
-
- public void setTo(RelationEndPoint to) {
- this.to = to;
- }
-
- public String getType() {
- return type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
- public void addProperty(String property, Object value) {
- if (property != null && !property.isEmpty() && value != null) {
- properties.put(property, value);
- }
- }
-
- public void addPropertis(Map<String, Object> props) {
- if(props != null) {
- properties.putAll(props);
- }
- }
-
- public void overwritePropertis(Map<String, Object> props) {
- properties = props;
- }
-
- public Object getProperty(String property) {
- return properties.get(property);
- }
-
- @Override
- public Map<String, Object> toGraphMap() {
- return properties;
- }
-
- @Override
- public String toString() {
- return "GraphRelation [from=" + from + ", to=" + to + ", type=" + type + ", properties=" + properties + "]";
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((from == null) ? 0 : from.hashCode());
- result = prime * result + ((properties == null) ? 0 : properties.hashCode());
- result = prime * result + ((to == null) ? 0 : to.hashCode());
- result = prime * result + ((type == null) ? 0 : type.hashCode());
- return result;
- }
+ private RelationEndPoint from;
+ private RelationEndPoint to;
+ private String type;
+ private Map<String, Object> properties;
+
+ public GraphRelation() {
+ super(GraphElementTypeEnum.Relationship);
+ properties = new HashMap<>();
+ }
+
+ public GraphRelation(String type) {
+ super(GraphElementTypeEnum.Relationship);
+ properties = new HashMap<>();
+ setType(type);
+ }
+
+ public RelationEndPoint getFrom() {
+ return from;
+ }
+
+ public void setFrom(RelationEndPoint from) {
+ this.from = from;
+ }
+
+ public RelationEndPoint getTo() {
+ return to;
+ }
+
+ public void setTo(RelationEndPoint to) {
+ this.to = to;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public void addProperty(String property, Object value) {
+ if (property != null && !property.isEmpty() && value != null) {
+ properties.put(property, value);
+ }
+ }
+
+ public void addPropertis(Map<String, Object> props) {
+ if (props != null) {
+ properties.putAll(props);
+ }
+ }
+
+ public void overwritePropertis(Map<String, Object> props) {
+ properties = props;
+ }
+
+ public Object getProperty(String property) {
+ return properties.get(property);
+ }
+
+ @Override
+ public Map<String, Object> toGraphMap() {
+ return properties;
+ }
+
+ @Override
+ public String toString() {
+ return "GraphRelation [from=" + from + ", to=" + to + ", type=" + type + ", properties=" + properties + "]";
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((from == null) ? 0 : from.hashCode());
+ result = prime * result + ((properties == null) ? 0 : properties.hashCode());
+ result = prime * result + ((to == null) ? 0 : to.hashCode());
+ result = prime * result + ((type == null) ? 0 : type.hashCode());
+ return result;
+ }
@Override
public boolean equals(Object obj) {
- if (this == obj)
+ if (this == obj) {
return true;
-
- if (obj == null)
+ }
+ if (obj == null) {
return false;
-
+ }
if (!(obj instanceof GraphRelation)) {
return false;
}
-
GraphRelation other = (GraphRelation) obj;
-
- return new EqualsBuilder().append(from, other.from).append(properties, other.properties).append(to, other.to).append(type, other.type).isEquals();
+ return new EqualsBuilder().append(from, other.from).append(properties, other.properties).append(to, other.to).append(type, other.type)
+ .isEquals();
}
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/graph/datatype/RelationEndPoint.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/graph/datatype/RelationEndPoint.java
index 9d72717b8e..9f4735b594 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/graph/datatype/RelationEndPoint.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/graph/datatype/RelationEndPoint.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,84 +17,91 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.graph.datatype;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
public class RelationEndPoint {
- NodeTypeEnum label;
- String idName;
- Object idValue;
- public RelationEndPoint(NodeTypeEnum label, String idName, Object idValue) {
- super();
- this.label = label;
- this.idName = idName;
- this.idValue = idValue;
- }
+ NodeTypeEnum label;
+ String idName;
+ Object idValue;
- public NodeTypeEnum getLabel() {
- return label;
- }
+ public RelationEndPoint(NodeTypeEnum label, String idName, Object idValue) {
+ super();
+ this.label = label;
+ this.idName = idName;
+ this.idValue = idValue;
+ }
- public void setLabel(NodeTypeEnum label) {
- this.label = label;
- }
+ public NodeTypeEnum getLabel() {
+ return label;
+ }
- public String getIdName() {
- return idName;
- }
+ public void setLabel(NodeTypeEnum label) {
+ this.label = label;
+ }
- public void setIdName(String idName) {
- this.idName = idName;
- }
+ public String getIdName() {
+ return idName;
+ }
- public Object getIdValue() {
- return idValue;
- }
+ public void setIdName(String idName) {
+ this.idName = idName;
+ }
- public void setIdValue(Object idValue) {
- this.idValue = idValue;
- }
+ public Object getIdValue() {
+ return idValue;
+ }
- @Override
- public String toString() {
- return "RelationEndPoint [label=" + label + ", idName=" + idName + ", idValue=" + idValue + "]";
- }
+ public void setIdValue(Object idValue) {
+ this.idValue = idValue;
+ }
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((idName == null) ? 0 : idName.hashCode());
- result = prime * result + ((idValue == null) ? 0 : idValue.hashCode());
- result = prime * result + ((label == null) ? 0 : label.hashCode());
- return result;
- }
+ @Override
+ public String toString() {
+ return "RelationEndPoint [label=" + label + ", idName=" + idName + ", idValue=" + idValue + "]";
+ }
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- RelationEndPoint other = (RelationEndPoint) obj;
- if (idName == null) {
- if (other.idName != null)
- return false;
- } else if (!idName.equals(other.idName))
- return false;
- if (idValue == null) {
- if (other.idValue != null)
- return false;
- } else if (!idValue.equals(other.idValue))
- return false;
- if (label != other.label)
- return false;
- return true;
- }
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((idName == null) ? 0 : idName.hashCode());
+ result = prime * result + ((idValue == null) ? 0 : idValue.hashCode());
+ result = prime * result + ((label == null) ? 0 : label.hashCode());
+ return result;
+ }
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ RelationEndPoint other = (RelationEndPoint) obj;
+ if (idName == null) {
+ if (other.idName != null) {
+ return false;
+ }
+ } else if (!idName.equals(other.idName)) {
+ return false;
+ }
+ if (idValue == null) {
+ if (other.idValue != null) {
+ return false;
+ }
+ } else if (!idValue.equals(other.idValue)) {
+ return false;
+ }
+ if (label != other.label) {
+ return false;
+ }
+ return true;
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/HealingPipelineDao.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/HealingPipelineDao.java
index f757b58455..6fb20f92e5 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/HealingPipelineDao.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/HealingPipelineDao.java
@@ -13,14 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.sdc.be.dao.impl;
import static java.util.stream.Collectors.joining;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableListMultimap;
-import org.janusgraph.core.JanusGraphVertex;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
@@ -29,11 +27,12 @@ import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
import javax.annotation.PostConstruct;
+import org.janusgraph.core.JanusGraphVertex;
import org.openecomp.sdc.be.dao.graph.datatype.GraphElement;
import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
import org.openecomp.sdc.be.dao.impl.heal.HealGraphDao;
-import org.openecomp.sdc.be.dao.impl.heal.HealNodeGraphDao;
import org.openecomp.sdc.be.dao.impl.heal.HealJanusGraphDao;
+import org.openecomp.sdc.be.dao.impl.heal.HealNodeGraphDao;
import org.openecomp.sdc.be.dao.impl.heal.HealVertexGraphDao;
import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
import org.openecomp.sdc.be.dao.jsongraph.heal.Heal;
@@ -48,14 +47,10 @@ import org.springframework.stereotype.Component;
public class HealingPipelineDao {
private static Logger logger = Logger.getLogger(HealingPipelineDao.class.getName());
-
private HealVersion<Integer> currentHealVersion;
-
@Value("${current.heal.version}")
private Integer healVersion;
-
private ImmutableListMultimap<String, Heal> healingPipeline;
-
private HealGraphDao healNodeGraphDao;
private HealGraphDao healVertexGraphDao;
private HealGraphDao healJanusGraphVertexGraphDao;
@@ -77,7 +72,6 @@ public class HealingPipelineDao {
healJanusGraphVertexGraphDao = new HealJanusGraphDao(this);
}
-
private HealGraphDao supplyHealer(Object graphNode) {
if (graphNode instanceof GraphVertex) {
return healVertexGraphDao;
@@ -88,15 +82,18 @@ public class HealingPipelineDao {
if (graphNode instanceof JanusGraphVertex) {
return healJanusGraphVertexGraphDao;
}
-
return null;
}
-
public ImmutableListMultimap<String, Heal> getHealingPipeline() {
return healingPipeline;
}
+ public void setHealingPipeline(ImmutableListMultimap<String, Heal> healingPipeline) {
+ checkValidation(healingPipeline);
+ this.healingPipeline = healingPipeline;
+ }
+
public boolean shouldHeal(HealVersion<Integer> healerVersion, HealVersion<Integer> vertexVersion) {
Objects.requireNonNull(healerVersion);
Objects.requireNonNull(vertexVersion);
@@ -110,7 +107,6 @@ public class HealingPipelineDao {
this.healVersion = healVersion;
}
-
public ImmutableList<Heal> getHealersForVertex(String edgeLabelEnum, HealVersion<Integer> vertexVersion) {
final ImmutableList<Heal> vertexHeals = getHealingPipeline().get(edgeLabelEnum);
List<Heal> list = new ArrayList<>();
@@ -122,13 +118,6 @@ public class HealingPipelineDao {
return ImmutableList.copyOf(list);
}
-
- public void setHealingPipeline(ImmutableListMultimap<String, Heal> healingPipeline) {
- checkValidation(healingPipeline);
- this.healingPipeline = healingPipeline;
- }
-
-
public void setHealingVersion(final GraphVertex graphVertex) {
graphVertex.addMetadataProperty(GraphPropertyEnum.HEALING_VERSION, currentHealVersion.getVersion());
}
@@ -157,16 +146,17 @@ public class HealingPipelineDao {
/**
* prevent duplicated healing version for same edge label.
*/
- private void checkValidation(ImmutableListMultimap<String, Heal> listMultimap) {
+ private void checkValidation(ImmutableListMultimap<String, Heal> listMultimap) {
listMultimap.keySet().forEach(key -> this.validNoDuplicates(key, listMultimap.get(key)));
}
private void validNoDuplicates(String key, List<Heal> heals) {
Set<Integer> duplicatedVersionSet = new HashSet<>();
- Set<Integer> duplicatedNumbersSet = heals.stream().map(heal -> ((HealVersion<Integer>) heal.fromVersion()).getVersion()).filter(n -> !duplicatedVersionSet.add(n)).collect(Collectors.toSet());
+ Set<Integer> duplicatedNumbersSet = heals.stream().map(heal -> ((HealVersion<Integer>) heal.fromVersion()).getVersion())
+ .filter(n -> !duplicatedVersionSet.add(n)).collect(Collectors.toSet());
if (!duplicatedNumbersSet.isEmpty()) {
- throw new IllegalStateException(String.format("Edge label %s , contains multiple healing with same version %s", key, duplicatedNumbersSet.stream().map(Object::toString).collect(joining(" , ", "[ ", " ]"))));
+ throw new IllegalStateException(String.format("Edge label %s , contains multiple healing with same version %s", key,
+ duplicatedNumbersSet.stream().map(Object::toString).collect(joining(" , ", "[ ", " ]"))));
}
}
-
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/heal/HealGraphDao.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/heal/HealGraphDao.java
index 5dd3aabe30..a99ce48b9c 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/heal/HealGraphDao.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/heal/HealGraphDao.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,10 +17,10 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.impl.heal;
@FunctionalInterface
-public interface HealGraphDao<G,L> {
+public interface HealGraphDao<G, L> {
+
G performGraphReadHealing(G childVertex, L edgeLabelEnum);
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/heal/HealJanusGraphDao.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/heal/HealJanusGraphDao.java
index c0a066346d..5d96d8fb99 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/heal/HealJanusGraphDao.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/heal/HealJanusGraphDao.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.impl.heal;
import org.janusgraph.core.JanusGraphVertex;
@@ -40,19 +39,16 @@ public class HealJanusGraphDao implements HealGraphDao<JanusGraphVertex, GraphEd
@Override
public JanusGraphVertex performGraphReadHealing(JanusGraphVertex childVertex, GraphEdgeLabels graphEdgeLabels) {
- final Integer healingVersionInt = (Integer) childVertex.property(GraphPropertyEnum.HEALING_VERSION.getProperty()).orElse(HealConstants.DEFAULT_HEAL_VERSION);
+ final Integer healingVersionInt = (Integer) childVertex.property(GraphPropertyEnum.HEALING_VERSION.getProperty())
+ .orElse(HealConstants.DEFAULT_HEAL_VERSION);
HealVersion<Integer> healingVersion = HealVersionBuilder.build(healingVersionInt);
- healingPipelineDao.getHealersForVertex(graphEdgeLabels.name(), healingVersion)
- .forEach(heal -> healGraphVertex(childVertex, heal));
- childVertex.property(GraphPropertyEnum.HEALING_VERSION.getProperty(),
- healingPipelineDao.getCurrentHealVersion().getVersion());
-
+ healingPipelineDao.getHealersForVertex(graphEdgeLabels.name(), healingVersion).forEach(heal -> healGraphVertex(childVertex, heal));
+ childVertex.property(GraphPropertyEnum.HEALING_VERSION.getProperty(), healingPipelineDao.getCurrentHealVersion().getVersion());
return childVertex;
}
-
private JanusGraphVertex healGraphVertex(JanusGraphVertex childVertex, Heal<JanusGraphVertex> heal) {
- if(ToggleableFeature.HEALING.isActive()) {
+ if (ToggleableFeature.HEALING.isActive()) {
heal.healData(childVertex);
final HealVersion<Integer> healVersion = heal.fromVersion();
HealVersion<Integer> newerVersion = HealVersionBuilder.build(healVersion.getVersion() + 1);
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/heal/HealNodeGraphDao.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/heal/HealNodeGraphDao.java
index 4184307259..d047ac0033 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/heal/HealNodeGraphDao.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/heal/HealNodeGraphDao.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.impl.heal;
import org.openecomp.sdc.be.dao.graph.datatype.GraphEdge;
@@ -31,16 +30,16 @@ public class HealNodeGraphDao implements HealGraphDao<GraphNode, GraphEdge> {
private HealingPipelineDao healingPipelineDao;
-
public HealNodeGraphDao(HealingPipelineDao healingPipelineDao) {
this.healingPipelineDao = healingPipelineDao;
}
@Override
public GraphNode performGraphReadHealing(GraphNode childVertex, GraphEdge graphEdge) {
- Integer healingVersionInt = childVertex.getHealingVersion();
+ Integer healingVersionInt = childVertex.getHealingVersion();
HealVersion<Integer> healingVersion = HealVersionBuilder.build(healingVersionInt);
- healingPipelineDao.getHealersForVertex(graphEdge.getEdgeType().getProperty(), healingVersion).forEach(heal -> healJanusGraphVertex(childVertex, heal));
+ healingPipelineDao.getHealersForVertex(graphEdge.getEdgeType().getProperty(), healingVersion)
+ .forEach(heal -> healJanusGraphVertex(childVertex, heal));
childVertex.setHealingVersion(healingPipelineDao.getCurrentHealVersion().getVersion());
return childVertex;
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/heal/HealVertexGraphDao.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/heal/HealVertexGraphDao.java
index 229e42bd00..f87f0443d9 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/heal/HealVertexGraphDao.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/heal/HealVertexGraphDao.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.impl.heal;
import org.openecomp.sdc.be.dao.impl.HealingPipelineDao;
@@ -38,16 +37,15 @@ public class HealVertexGraphDao implements HealGraphDao<GraphVertex, EdgeLabelEn
}
@Override
- public GraphVertex performGraphReadHealing( GraphVertex childVertex, EdgeLabelEnum edgeLabelEnum) {
+ public GraphVertex performGraphReadHealing(GraphVertex childVertex, EdgeLabelEnum edgeLabelEnum) {
final Integer healingVersionInt = (Integer) childVertex.getMetadataProperties()
- .getOrDefault(GraphPropertyEnum.HEALING_VERSION, HealConstants.DEFAULT_HEAL_VERSION);
+ .getOrDefault(GraphPropertyEnum.HEALING_VERSION, HealConstants.DEFAULT_HEAL_VERSION);
HealVersion<Integer> healingVersion = HealVersionBuilder.build(healingVersionInt);
healingPipelineDao.getHealersForVertex(edgeLabelEnum.name(), healingVersion).forEach(heal -> healGraphVertex(childVertex, heal));
childVertex.addMetadataProperty(GraphPropertyEnum.HEALING_VERSION, healingPipelineDao.getCurrentHealVersion().getVersion());
return childVertex;
}
-
private GraphVertex healGraphVertex(GraphVertex childVertex, Heal<GraphVertex> heal) {
heal.healData(childVertex);
final HealVersion<Integer> healVersion = heal.fromVersion();
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/HealingJanusGraphGenericDao.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/HealingJanusGraphGenericDao.java
index bcd36e82f1..b1bcceaf26 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/HealingJanusGraphGenericDao.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/HealingJanusGraphGenericDao.java
@@ -15,13 +15,13 @@
*/
package org.openecomp.sdc.be.dao.janusgraph;
-import org.janusgraph.core.JanusGraphVertex;
import fj.data.Either;
import java.util.List;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.tinkerpop.gremlin.structure.Edge;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.apache.tinkerpop.gremlin.structure.VertexProperty;
+import org.janusgraph.core.JanusGraphVertex;
import org.openecomp.sdc.be.dao.graph.datatype.GraphEdge;
import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
import org.openecomp.sdc.be.dao.impl.HealingPipelineDao;
@@ -53,8 +53,13 @@ public class HealingJanusGraphGenericDao extends JanusGraphGenericDao {
}
@Override
- public <T extends GraphNode> Either<List<ImmutablePair<T, GraphEdge>>, JanusGraphOperationStatus> getChildrenNodes(String key, String uniqueId, GraphEdgeLabels edgeType, NodeTypeEnum nodeTypeEnum, Class<T> clazz, boolean withEdges) {
- Either<List<ImmutablePair<T, GraphEdge>>, JanusGraphOperationStatus> either = super.getChildrenNodes(key, uniqueId, edgeType, nodeTypeEnum, clazz, withEdges);
+ public <T extends GraphNode> Either<List<ImmutablePair<T, GraphEdge>>, JanusGraphOperationStatus> getChildrenNodes(String key, String uniqueId,
+ GraphEdgeLabels edgeType,
+ NodeTypeEnum nodeTypeEnum,
+ Class<T> clazz,
+ boolean withEdges) {
+ Either<List<ImmutablePair<T, GraphEdge>>, JanusGraphOperationStatus> either = super
+ .getChildrenNodes(key, uniqueId, edgeType, nodeTypeEnum, clazz, withEdges);
if (either.isRight()) {
return either;
}
@@ -64,7 +69,9 @@ public class HealingJanusGraphGenericDao extends JanusGraphGenericDao {
}
@Override
- public <T extends GraphNode> Either<ImmutablePair<T, GraphEdge>, JanusGraphOperationStatus> getChild(String key, String uniqueId, GraphEdgeLabels edgeType, NodeTypeEnum nodeTypeEnum, Class<T> clazz) {
+ public <T extends GraphNode> Either<ImmutablePair<T, GraphEdge>, JanusGraphOperationStatus> getChild(String key, String uniqueId,
+ GraphEdgeLabels edgeType,
+ NodeTypeEnum nodeTypeEnum, Class<T> clazz) {
Either<ImmutablePair<T, GraphEdge>, JanusGraphOperationStatus> eitherChild = super.getChild(key, uniqueId, edgeType, nodeTypeEnum, clazz);
if (eitherChild.isRight()) {
return eitherChild;
@@ -87,7 +94,8 @@ public class HealingJanusGraphGenericDao extends JanusGraphGenericDao {
}
@Override
- public Either<List<ImmutablePair<JanusGraphVertex, Edge>>, JanusGraphOperationStatus> getChildrenVertecies(String key, String uniqueId, GraphEdgeLabels edgeType) {
+ public Either<List<ImmutablePair<JanusGraphVertex, Edge>>, JanusGraphOperationStatus> getChildrenVertecies(String key, String uniqueId,
+ GraphEdgeLabels edgeType) {
Either<List<ImmutablePair<JanusGraphVertex, Edge>>, JanusGraphOperationStatus> either = super.getChildrenVertecies(key, uniqueId, edgeType);
if (either.isRight()) {
return either;
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/JanusGraphClient.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/JanusGraphClient.java
index 66a2ba02ad..73f41a3e87 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/JanusGraphClient.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/JanusGraphClient.java
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.janusgraph;
import fj.data.Either;
@@ -60,72 +59,23 @@ import org.springframework.stereotype.Component;
@Component("janusgraph-client")
public class JanusGraphClient {
- private static Logger logger = LoggerFactory.getLogger(JanusGraphClient.class.getName());
- private static Logger healthLogger = LoggerFactory.getLogger("janusgraph.healthcheck");
private static final String HEALTH_CHECK = GraphPropertiesDictionary.HEALTH_CHECK.getProperty();
private static final String OK = "GOOD";
-
- public JanusGraphClient() {
- }
-
- @PreDestroy
- public void closeSession() {
- if (graph.isOpen()) {
- graph.close();
- logger.info("** JanusGraphClient session closed");
- }
- }
-
- private class HealthCheckTask implements Callable<Vertex> {
- @Override
- public Vertex call() {
- JanusGraphVertex vertex =
- (JanusGraphVertex) graph.query().has(HEALTH_CHECK, OK).vertices().iterator().next();
- healthLogger.trace("Health Check Node Found...{}", vertex.property(HEALTH_CHECK));
- graph.tx().commit();
- return vertex;
- }
- }
-
- private class HealthCheckScheduledTask implements Runnable {
- @Override
- public void run() {
- healthLogger.trace("Executing janusGraph Health Check Task - Start");
- boolean healthStatus = isGraphOpen();
- healthLogger.trace("Executing janusGraph Health Check Task - Status = {}", healthStatus);
- if (healthStatus != lastHealthState) {
- logger.trace("janusGraph Health State Changed to {}. Issuing alarm / recovery alarm...", healthStatus);
- lastHealthState = healthStatus;
- logAlarm();
- }
- }
- }
-
- private class ReconnectTask implements Runnable {
- @Override
- public void run() {
- logger.trace("Trying to reconnect to JanusGraph...");
- if (graph == null) {
- createGraph(janusGraphCfgFile);
- }
- }
- }
-
- private JanusGraph graph;
-
- // Health Check Variables
-
+ private static final String JANUSGRAPH_HEALTH_CHECK = "janusgraphHealthCheck";
+ private static Logger logger = LoggerFactory.getLogger(JanusGraphClient.class.getName());
+ private static Logger healthLogger = LoggerFactory.getLogger("janusgraph.healthcheck");
/**
* This executor will execute the health check task on a callable task that can be executed with a timeout.
*/
- ExecutorService healthCheckExecutor = Executors.newSingleThreadExecutor(
- runnable -> new Thread(runnable, "JanusGraph-Health-Check-Thread"));
- private long healthCheckReadTimeout = 2;
+ ExecutorService healthCheckExecutor = Executors.newSingleThreadExecutor(runnable -> new Thread(runnable, "JanusGraph-Health-Check-Thread"));
HealthCheckTask healthCallableTask = new HealthCheckTask();
HealthCheckScheduledTask healthCheckScheduledTask = new HealthCheckScheduledTask();
boolean lastHealthState = false;
-
+ JanusGraphClientStrategy janusGraphClientStrategy;
+ // Health Check Variables
+ private JanusGraph graph;
+ private long healthCheckReadTimeout = 2;
// Reconnection variables
private ScheduledExecutorService reconnectScheduler = null;
private ScheduledExecutorService healthCheckScheduler = null;
@@ -133,31 +83,62 @@ public class JanusGraphClient {
private long reconnectInterval = 3;
@SuppressWarnings("rawtypes")
private Future reconnectFuture;
-
private String janusGraphCfgFile = null;
- JanusGraphClientStrategy janusGraphClientStrategy;
-
+ public JanusGraphClient() {
+ }
public JanusGraphClient(JanusGraphClientStrategy janusGraphClientStrategy) {
super();
this.janusGraphClientStrategy = janusGraphClientStrategy;
-
// Initialize a single threaded scheduler for health-check
- this.healthCheckScheduler = Executors.newSingleThreadScheduledExecutor(
- runnable -> new Thread(runnable, "JanusGraph-Health-Check-Task"));
+ this.healthCheckScheduler = Executors.newSingleThreadScheduledExecutor(runnable -> new Thread(runnable, "JanusGraph-Health-Check-Task"));
+ healthCheckReadTimeout = ConfigurationManager.getConfigurationManager().getConfiguration().getJanusGraphHealthCheckReadTimeout(2);
+ reconnectInterval = ConfigurationManager.getConfigurationManager().getConfiguration().getJanusGraphReconnectIntervalInSeconds(3);
+ logger.info("** JanusGraphClient created");
+ }
- healthCheckReadTimeout = ConfigurationManager.getConfigurationManager().getConfiguration()
- .getJanusGraphHealthCheckReadTimeout(2);
- reconnectInterval = ConfigurationManager.getConfigurationManager().getConfiguration()
- .getJanusGraphReconnectIntervalInSeconds(3);
+ public static JanusGraphOperationStatus handleJanusGraphException(Exception e) {
+ if (e instanceof JanusGraphConfigurationException) {
+ return JanusGraphOperationStatus.JANUSGRAPH_CONFIGURATION;
+ }
+ if (e instanceof SchemaViolationException) {
+ return JanusGraphOperationStatus.JANUSGRAPH_SCHEMA_VIOLATION;
+ }
+ if (e instanceof PermanentLockingException) {
+ return JanusGraphOperationStatus.JANUSGRAPH_SCHEMA_VIOLATION;
+ }
+ if (e instanceof IDPoolExhaustedException) {
+ return JanusGraphOperationStatus.GENERAL_ERROR;
+ }
+ if (e instanceof InvalidElementException) {
+ return JanusGraphOperationStatus.INVALID_ELEMENT;
+ }
+ if (e instanceof InvalidIDException) {
+ return JanusGraphOperationStatus.INVALID_ID;
+ }
+ if (e instanceof QueryException) {
+ return JanusGraphOperationStatus.INVALID_QUERY;
+ }
+ if (e instanceof ResourceUnavailableException) {
+ return JanusGraphOperationStatus.RESOURCE_UNAVAILABLE;
+ }
+ if (e instanceof IllegalArgumentException) {
+ // TODO check the error message??
+ return JanusGraphOperationStatus.ILLEGAL_ARGUMENT;
+ }
+ return JanusGraphOperationStatus.GENERAL_ERROR;
+ }
- logger.info("** JanusGraphClient created");
+ @PreDestroy
+ public void closeSession() {
+ if (graph.isOpen()) {
+ graph.close();
+ logger.info("** JanusGraphClient session closed");
+ }
}
@PostConstruct
public JanusGraphOperationStatus createGraph() {
-
logger.info("** createGraph started **");
-
if (ConfigurationManager.getConfigurationManager().getConfiguration().getJanusGraphInMemoryGraph()) {
BaseConfiguration conf = new BaseConfiguration();
conf.setProperty("storage.backend", "inmemory");
@@ -170,16 +151,16 @@ public class JanusGraphClient {
if (janusGraphCfgFile == null || janusGraphCfgFile.isEmpty()) {
janusGraphCfgFile = "config/janusgraph.properties";
}
-
// yavivi
+
// In case connection failed on init time, schedule a reconnect task
+
// in the BG
JanusGraphOperationStatus status = createGraph(janusGraphCfgFile);
logger.debug("Create JanusGraph graph status {}", status);
if (status != JanusGraphOperationStatus.OK) {
this.startReconnectTask();
}
-
return status;
}
}
@@ -194,12 +175,9 @@ public class JanusGraphClient {
private void startReconnectTask() {
this.reconnectTask = new ReconnectTask();
// Initialize a single threaded scheduler
- this.reconnectScheduler = Executors.newSingleThreadScheduledExecutor(
- runnable -> new Thread(runnable, "JanusGraph-Reconnect-Task"));
-
+ this.reconnectScheduler = Executors.newSingleThreadScheduledExecutor(runnable -> new Thread(runnable, "JanusGraph-Reconnect-Task"));
logger.info("Scheduling reconnect task {} with interval of {} seconds", reconnectTask, reconnectInterval);
- reconnectFuture = this.reconnectScheduler
- .scheduleAtFixedRate(this.reconnectTask, 0, this.reconnectInterval, TimeUnit.SECONDS);
+ reconnectFuture = this.reconnectScheduler.scheduleAtFixedRate(this.reconnectTask, 0, this.reconnectInterval, TimeUnit.SECONDS);
}
public void cleanupGraph() {
@@ -218,7 +196,6 @@ public class JanusGraphClient {
return graphMgmt.containsPropertyKey(HEALTH_CHECK) && graphMgmt.containsGraphIndex(HEALTH_CHECK);
}
-
public JanusGraphOperationStatus createGraph(String janusGraphCfgFile) {
logger.info("** open graph with {} started", janusGraphCfgFile);
try {
@@ -228,19 +205,15 @@ public class JanusGraphClient {
logger.error("janusgraph graph was not initialized");
return JanusGraphOperationStatus.NOT_CREATED;
}
-
} catch (Exception e) {
this.graph = null;
logger.info("createGraph : failed to open JanusGraph graph with configuration file: {}", janusGraphCfgFile);
logger.debug("createGraph : failed with exception.", e);
return JanusGraphOperationStatus.NOT_CONNECTED;
}
-
logger.info("** JanusGraph graph created ");
-
// Do some post creation actions
this.onGraphOpened();
-
return JanusGraphOperationStatus.OK;
}
@@ -250,7 +223,6 @@ public class JanusGraphClient {
logger.info("** Cancelling JanusGraph reconnect task");
reconnectFuture.cancel(true);
}
-
// create health-check node
if (!graph.query().has(HEALTH_CHECK, OK).vertices().iterator().hasNext()) {
logger.trace("Healthcheck Singleton node does not exist, Creating healthcheck node...");
@@ -264,7 +236,6 @@ public class JanusGraphClient {
this.startHealthCheckTask();
}
-
public Either<JanusGraph, JanusGraphOperationStatus> getGraph() {
if (graph != null) {
return Either.left(graph);
@@ -299,39 +270,6 @@ public class JanusGraphClient {
}
}
- public static JanusGraphOperationStatus handleJanusGraphException(Exception e) {
- if (e instanceof JanusGraphConfigurationException) {
- return JanusGraphOperationStatus.JANUSGRAPH_CONFIGURATION;
- }
- if (e instanceof SchemaViolationException) {
- return JanusGraphOperationStatus.JANUSGRAPH_SCHEMA_VIOLATION;
- }
- if (e instanceof PermanentLockingException) {
- return JanusGraphOperationStatus.JANUSGRAPH_SCHEMA_VIOLATION;
- }
- if (e instanceof IDPoolExhaustedException) {
- return JanusGraphOperationStatus.GENERAL_ERROR;
- }
- if (e instanceof InvalidElementException) {
- return JanusGraphOperationStatus.INVALID_ELEMENT;
- }
- if (e instanceof InvalidIDException) {
- return JanusGraphOperationStatus.INVALID_ID;
- }
- if (e instanceof QueryException) {
- return JanusGraphOperationStatus.INVALID_QUERY;
- }
- if (e instanceof ResourceUnavailableException) {
- return JanusGraphOperationStatus.RESOURCE_UNAVAILABLE;
- }
- if (e instanceof IllegalArgumentException) {
- // TODO check the error message??
- return JanusGraphOperationStatus.ILLEGAL_ARGUMENT;
- }
-
- return JanusGraphOperationStatus.GENERAL_ERROR;
- }
-
public boolean getHealth() {
return this.lastHealthState;
}
@@ -359,8 +297,6 @@ public class JanusGraphClient {
}
}
- private static final String JANUSGRAPH_HEALTH_CHECK = "janusgraphHealthCheck";
-
private void logAlarm() {
if (lastHealthState) {
BeEcompErrorManager.getInstance().logBeHealthCheckJanusGraphRecovery(JANUSGRAPH_HEALTH_CHECK);
@@ -370,7 +306,6 @@ public class JanusGraphClient {
}
private void createJanusGraphSchema() {
-
JanusGraphManagement graphMgt = graph.openManagement();
JanusGraphIndex index = null;
for (GraphPropertiesDictionary prop : GraphPropertiesDictionary.values()) {
@@ -385,13 +320,11 @@ public class JanusGraphClient {
}
if (prop.isIndexed() && !graphMgt.containsGraphIndex(prop.getProperty())) {
if (prop.isUnique()) {
- index = graphMgt.buildIndex(prop.getProperty(), Vertex.class).addKey(propKey).unique()
- .buildCompositeIndex();
+ index = graphMgt.buildIndex(prop.getProperty(), Vertex.class).addKey(propKey).unique().buildCompositeIndex();
// Ensures only one name per vertex
graphMgt.setConsistency(propKey, ConsistencyModifier.LOCK);
// Ensures name uniqueness in the graph
graphMgt.setConsistency(index, ConsistencyModifier.LOCK);
-
} else {
graphMgt.buildIndex(prop.getProperty(), Vertex.class).addKey(propKey).buildCompositeIndex();
}
@@ -400,4 +333,40 @@ public class JanusGraphClient {
graphMgt.commit();
}
+ private class HealthCheckTask implements Callable<Vertex> {
+
+ @Override
+ public Vertex call() {
+ JanusGraphVertex vertex = (JanusGraphVertex) graph.query().has(HEALTH_CHECK, OK).vertices().iterator().next();
+ healthLogger.trace("Health Check Node Found...{}", vertex.property(HEALTH_CHECK));
+ graph.tx().commit();
+ return vertex;
+ }
+ }
+
+ private class HealthCheckScheduledTask implements Runnable {
+
+ @Override
+ public void run() {
+ healthLogger.trace("Executing janusGraph Health Check Task - Start");
+ boolean healthStatus = isGraphOpen();
+ healthLogger.trace("Executing janusGraph Health Check Task - Status = {}", healthStatus);
+ if (healthStatus != lastHealthState) {
+ logger.trace("janusGraph Health State Changed to {}. Issuing alarm / recovery alarm...", healthStatus);
+ lastHealthState = healthStatus;
+ logAlarm();
+ }
+ }
+ }
+
+ private class ReconnectTask implements Runnable {
+
+ @Override
+ public void run() {
+ logger.trace("Trying to reconnect to JanusGraph...");
+ if (graph == null) {
+ createGraph(janusGraphCfgFile);
+ }
+ }
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/JanusGraphGenericDao.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/JanusGraphGenericDao.java
index 8d2f24e6fa..0b2a8e11b9 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/JanusGraphGenericDao.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/JanusGraphGenericDao.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,16 +17,8 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.janusgraph;
-import org.janusgraph.core.PropertyKey;
-import org.janusgraph.core.JanusGraphEdge;
-import org.janusgraph.core.JanusGraph;
-import org.janusgraph.core.JanusGraphQuery;
-import org.janusgraph.core.JanusGraphVertex;
-import org.janusgraph.core.JanusGraphVertexQuery;
-import org.janusgraph.graphdb.query.JanusGraphPredicate;
import fj.data.Either;
import java.util.ArrayList;
import java.util.HashMap;
@@ -36,6 +28,7 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
+import javax.validation.constraints.NotNull;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.ImmutableTriple;
import org.apache.tinkerpop.gremlin.structure.Direction;
@@ -44,6 +37,13 @@ import org.apache.tinkerpop.gremlin.structure.Element;
import org.apache.tinkerpop.gremlin.structure.Property;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.apache.tinkerpop.gremlin.structure.util.ElementHelper;
+import org.janusgraph.core.JanusGraph;
+import org.janusgraph.core.JanusGraphEdge;
+import org.janusgraph.core.JanusGraphQuery;
+import org.janusgraph.core.JanusGraphVertex;
+import org.janusgraph.core.JanusGraphVertexQuery;
+import org.janusgraph.core.PropertyKey;
+import org.janusgraph.graphdb.query.JanusGraphPredicate;
import org.openecomp.sdc.be.config.ConfigurationManager;
import org.openecomp.sdc.be.dao.graph.GraphElementFactory;
import org.openecomp.sdc.be.dao.graph.datatype.GraphEdge;
@@ -58,1706 +58,1515 @@ import org.openecomp.sdc.be.resources.data.GraphNodeLock;
import org.openecomp.sdc.common.log.wrappers.Logger;
import org.springframework.beans.factory.annotation.Qualifier;
-import javax.validation.constraints.NotNull;
public class JanusGraphGenericDao {
- private JanusGraphClient janusGraphClient;
- private static Logger log = Logger.getLogger(JanusGraphGenericDao.class.getName());
- private static final String LOCK_NODE_PREFIX = "lock_";
-
- public JanusGraphGenericDao(@Qualifier("janusgraph-client") JanusGraphClient janusGraphClient) {
- this.janusGraphClient = janusGraphClient;
- log.info("** JanusGraphGenericDao created");
- }
-
- public JanusGraphOperationStatus commit() {
- log.debug("doing commit.");
- return janusGraphClient.commit();
- }
-
- public JanusGraphOperationStatus rollback() {
- log.error("Going to execute rollback on graph.");
- return janusGraphClient.rollback();
- }
-
- public <T, TStatus> void handleTransactionCommitRollback(boolean inTransaction, Either<T, TStatus> result) {
- if (!inTransaction) {
- if (result == null || result.isRight()) {
- rollback();
- } else {
- commit();
- }
- }
- }
-
- public Either<JanusGraph, JanusGraphOperationStatus> getGraph() {
- return janusGraphClient.getGraph();
- }
-
- // For healthCheck
- public boolean isGraphOpen() {
- return janusGraphClient.getHealth();
- }
-
- /**
- *
- * @param node
- * @param clazz
- * @return
- */
- public <T extends GraphNode> Either<T, JanusGraphOperationStatus> createNode(T node, Class<T> clazz) {
- log.debug("try to create node for ID [{}]", node.getKeyValueIdForLog());
- Either<JanusGraph, JanusGraphOperationStatus> graph = janusGraphClient.getGraph();
- if (graph.isLeft()) {
- T newNode;
- try {
- JanusGraph tGraph = graph.left().value();
-
- Vertex vertex = tGraph.addVertex();
-
- vertex.property(GraphPropertiesDictionary.LABEL.getProperty(), node.getLabel());
-
- Map<String, Object> properties = node.toGraphMap();
- if (properties != null) {
- setProperties(vertex, properties);
- }
- Map<String, Object> newProps = getProperties(vertex);
- newNode = GraphElementFactory.createElement(node.getLabel(), GraphElementTypeEnum.Node, newProps, clazz);
- log.debug("created node for props : {}", newProps);
- log.debug("Node was created for ID [{}]", node.getKeyValueIdForLog());
- return Either.left(newNode);
-
- } catch (Exception e) {
- log.debug("Failed to create Node for ID [{}]", node.getKeyValueId(), e);
- return Either.right(JanusGraphClient.handleJanusGraphException(e));
- }
-
- } else {
- log.debug("Failed to create Node for ID [{}] {}", node.getKeyValueIdForLog(), graph.right().value());
- return Either.right(graph.right().value());
- }
- }
-
- public Either<JanusGraphVertex, JanusGraphOperationStatus> createNode(GraphNode node) {
- log.debug("try to create node for ID [{}]", node.getKeyValueId());
- Either<JanusGraph, JanusGraphOperationStatus> graph = janusGraphClient.getGraph();
- if (graph.isLeft()) {
- try {
- JanusGraph tGraph = graph.left().value();
-
- JanusGraphVertex vertex = tGraph.addVertex();
-
- vertex.property(GraphPropertiesDictionary.LABEL.getProperty(), node.getLabel());
-
- Map<String, Object> properties = node.toGraphMap();
- if (properties != null) {
- setProperties(vertex, properties);
- }
- log.debug("Node was created for ID [{}]", node.getKeyValueId());
- return Either.left(vertex);
-
- } catch (Exception e) {
- log.debug("Failed to create Node for ID [{}]", node.getKeyValueId(), e);
- return Either.right(JanusGraphClient.handleJanusGraphException(e));
- }
-
- } else {
- log.debug("Failed to create Node for ID [{}] {}", node.getKeyValueId(), graph.right().value());
- return Either.right(graph.right().value());
- }
- }
-
- /**
- *
- * @param relation
- * @return
- */
- public Either<GraphRelation, JanusGraphOperationStatus> createRelation(GraphRelation relation) {
- log.debug("try to create relation from [{}] to [{}] ", relation.getFrom(), relation.getTo());
-
- RelationEndPoint from = relation.getFrom();
- RelationEndPoint to = relation.getTo();
- ImmutablePair<String, Object> fromKeyId = new ImmutablePair<>(from.getIdName(), from.getIdValue());
- ImmutablePair<String, Object> toKeyId = new ImmutablePair<>(to.getIdName(), to.getIdValue());
-
- return createEdge(relation.getType(), fromKeyId, toKeyId, from.getLabel().getName(), to.getLabel().getName(), relation.toGraphMap());
-
- }
-
- private Either<GraphRelation, JanusGraphOperationStatus> createEdge(String type, ImmutablePair<String, Object> from, ImmutablePair<String, Object> to, String fromLabel, String toLabel, Map<String, Object> properties) {
- Either<JanusGraph, JanusGraphOperationStatus> graph = janusGraphClient.getGraph();
-
- if (graph.isLeft()) {
- try {
- Either<Vertex, JanusGraphOperationStatus> fromV = getVertexByPropertyAndLabel(from.getKey(), from.getValue(), fromLabel);
- if (fromV.isRight()) {
- JanusGraphOperationStatus error = fromV.right().value();
- if (JanusGraphOperationStatus.NOT_FOUND.equals(error)) {
- return Either.right(JanusGraphOperationStatus.INVALID_ID);
- } else {
- return Either.right(error);
- }
- }
- Either<Vertex, JanusGraphOperationStatus> toV = getVertexByPropertyAndLabel(to.getKey(), to.getValue(), toLabel);
- if (toV.isRight()) {
- JanusGraphOperationStatus error = toV.right().value();
- if (JanusGraphOperationStatus.NOT_FOUND.equals(error)) {
- return Either.right(JanusGraphOperationStatus.INVALID_ID);
- } else {
- return Either.right(error);
- }
- }
-
- Vertex fromVertex = fromV.left().value();
- Vertex toVertex = toV.left().value();
- Edge edge = fromVertex.addEdge(type, toVertex);
-
- if (properties != null) {
-
- setProperties(edge, properties);
- }
-
- Vertex vertexOut = edge.outVertex();
- Vertex vertexIn = edge.inVertex();
-
- GraphNode nodeOut = GraphElementFactory.createElement(fromLabel, GraphElementTypeEnum.Node, getProperties(vertexOut), GraphNode.class);
- GraphNode nodeIn = GraphElementFactory.createElement(toLabel, GraphElementTypeEnum.Node, getProperties(vertexIn), GraphNode.class);
-
- GraphRelation newRelation = GraphElementFactory.createRelation(edge.label(), getProperties(edge), nodeOut, nodeIn);
-
- return Either.left(newRelation);
- } catch (Exception e) {
- log.debug("Failed to create edge from [{}] to [{}]", from, to, e);
- return Either.right(janusGraphClient.handleJanusGraphException(e));
- }
- } else {
- log.debug("Failed to create edge from [{}] to [{}] {}", from, to, graph.right().value());
- return Either.right(graph.right().value());
- }
- }
-
- public JanusGraphOperationStatus createEdge(Vertex vertexOut, Vertex vertexIn, GraphEdgeLabels type, Map<String, Object> properties) {
- try {
- Edge edge = addEdge(vertexOut, vertexIn, type, properties);
- } catch (Exception e) {
- log.debug("Failed to create edge from [{}] to [{}]", vertexOut, vertexIn, e);
- return janusGraphClient.handleJanusGraphException(e);
- }
- return JanusGraphOperationStatus.OK;
-
- }
-
- private Edge addEdge(Vertex vertexOut, Vertex vertexIn, GraphEdgeLabels type, Map<String, Object> properties) {
- Edge edge = vertexOut.addEdge(type.getProperty(), vertexIn);
-
- if (properties != null) {
+ private static final String LOCK_NODE_PREFIX = "lock_";
+ private static Logger log = Logger.getLogger(JanusGraphGenericDao.class.getName());
+ private JanusGraphClient janusGraphClient;
+
+ public JanusGraphGenericDao(@Qualifier("janusgraph-client") JanusGraphClient janusGraphClient) {
+ this.janusGraphClient = janusGraphClient;
+ log.info("** JanusGraphGenericDao created");
+ }
+
+ public JanusGraphOperationStatus commit() {
+ log.debug("doing commit.");
+ return janusGraphClient.commit();
+ }
+
+ public JanusGraphOperationStatus rollback() {
+ log.error("Going to execute rollback on graph.");
+ return janusGraphClient.rollback();
+ }
+
+ public <T, TStatus> void handleTransactionCommitRollback(boolean inTransaction, Either<T, TStatus> result) {
+ if (!inTransaction) {
+ if (result == null || result.isRight()) {
+ rollback();
+ } else {
+ commit();
+ }
+ }
+ }
+
+ public Either<JanusGraph, JanusGraphOperationStatus> getGraph() {
+ return janusGraphClient.getGraph();
+ }
+
+ // For healthCheck
+ public boolean isGraphOpen() {
+ return janusGraphClient.getHealth();
+ }
+
+ /**
+ * @param node
+ * @param clazz
+ * @return
+ */
+ public <T extends GraphNode> Either<T, JanusGraphOperationStatus> createNode(T node, Class<T> clazz) {
+ log.debug("try to create node for ID [{}]", node.getKeyValueIdForLog());
+ Either<JanusGraph, JanusGraphOperationStatus> graph = janusGraphClient.getGraph();
+ if (graph.isLeft()) {
+ T newNode;
+ try {
+ JanusGraph tGraph = graph.left().value();
+ Vertex vertex = tGraph.addVertex();
+ vertex.property(GraphPropertiesDictionary.LABEL.getProperty(), node.getLabel());
+ Map<String, Object> properties = node.toGraphMap();
+ if (properties != null) {
+ setProperties(vertex, properties);
+ }
+ Map<String, Object> newProps = getProperties(vertex);
+ newNode = GraphElementFactory.createElement(node.getLabel(), GraphElementTypeEnum.Node, newProps, clazz);
+ log.debug("created node for props : {}", newProps);
+ log.debug("Node was created for ID [{}]", node.getKeyValueIdForLog());
+ return Either.left(newNode);
+ } catch (Exception e) {
+ log.debug("Failed to create Node for ID [{}]", node.getKeyValueId(), e);
+ return Either.right(JanusGraphClient.handleJanusGraphException(e));
+ }
+ } else {
+ log.debug("Failed to create Node for ID [{}] {}", node.getKeyValueIdForLog(), graph.right().value());
+ return Either.right(graph.right().value());
+ }
+ }
+
+ public Either<JanusGraphVertex, JanusGraphOperationStatus> createNode(GraphNode node) {
+ log.debug("try to create node for ID [{}]", node.getKeyValueId());
+ Either<JanusGraph, JanusGraphOperationStatus> graph = janusGraphClient.getGraph();
+ if (graph.isLeft()) {
+ try {
+ JanusGraph tGraph = graph.left().value();
+ JanusGraphVertex vertex = tGraph.addVertex();
+ vertex.property(GraphPropertiesDictionary.LABEL.getProperty(), node.getLabel());
+ Map<String, Object> properties = node.toGraphMap();
+ if (properties != null) {
+ setProperties(vertex, properties);
+ }
+ log.debug("Node was created for ID [{}]", node.getKeyValueId());
+ return Either.left(vertex);
+ } catch (Exception e) {
+ log.debug("Failed to create Node for ID [{}]", node.getKeyValueId(), e);
+ return Either.right(JanusGraphClient.handleJanusGraphException(e));
+ }
+ } else {
+ log.debug("Failed to create Node for ID [{}] {}", node.getKeyValueId(), graph.right().value());
+ return Either.right(graph.right().value());
+ }
+ }
+
+ /**
+ * @param relation
+ * @return
+ */
+ public Either<GraphRelation, JanusGraphOperationStatus> createRelation(GraphRelation relation) {
+ log.debug("try to create relation from [{}] to [{}] ", relation.getFrom(), relation.getTo());
+ RelationEndPoint from = relation.getFrom();
+ RelationEndPoint to = relation.getTo();
+ ImmutablePair<String, Object> fromKeyId = new ImmutablePair<>(from.getIdName(), from.getIdValue());
+ ImmutablePair<String, Object> toKeyId = new ImmutablePair<>(to.getIdName(), to.getIdValue());
+ return createEdge(relation.getType(), fromKeyId, toKeyId, from.getLabel().getName(), to.getLabel().getName(), relation.toGraphMap());
+ }
+
+ private Either<GraphRelation, JanusGraphOperationStatus> createEdge(String type, ImmutablePair<String, Object> from,
+ ImmutablePair<String, Object> to, String fromLabel, String toLabel,
+ Map<String, Object> properties) {
+ Either<JanusGraph, JanusGraphOperationStatus> graph = janusGraphClient.getGraph();
+ if (graph.isLeft()) {
+ try {
+ Either<Vertex, JanusGraphOperationStatus> fromV = getVertexByPropertyAndLabel(from.getKey(), from.getValue(), fromLabel);
+ if (fromV.isRight()) {
+ JanusGraphOperationStatus error = fromV.right().value();
+ if (JanusGraphOperationStatus.NOT_FOUND.equals(error)) {
+ return Either.right(JanusGraphOperationStatus.INVALID_ID);
+ } else {
+ return Either.right(error);
+ }
+ }
+ Either<Vertex, JanusGraphOperationStatus> toV = getVertexByPropertyAndLabel(to.getKey(), to.getValue(), toLabel);
+ if (toV.isRight()) {
+ JanusGraphOperationStatus error = toV.right().value();
+ if (JanusGraphOperationStatus.NOT_FOUND.equals(error)) {
+ return Either.right(JanusGraphOperationStatus.INVALID_ID);
+ } else {
+ return Either.right(error);
+ }
+ }
+ Vertex fromVertex = fromV.left().value();
+ Vertex toVertex = toV.left().value();
+ Edge edge = fromVertex.addEdge(type, toVertex);
+ if (properties != null) {
+ setProperties(edge, properties);
+ }
+ Vertex vertexOut = edge.outVertex();
+ Vertex vertexIn = edge.inVertex();
+ GraphNode nodeOut = GraphElementFactory
+ .createElement(fromLabel, GraphElementTypeEnum.Node, getProperties(vertexOut), GraphNode.class);
+ GraphNode nodeIn = GraphElementFactory.createElement(toLabel, GraphElementTypeEnum.Node, getProperties(vertexIn), GraphNode.class);
+ GraphRelation newRelation = GraphElementFactory.createRelation(edge.label(), getProperties(edge), nodeOut, nodeIn);
+ return Either.left(newRelation);
+ } catch (Exception e) {
+ log.debug("Failed to create edge from [{}] to [{}]", from, to, e);
+ return Either.right(janusGraphClient.handleJanusGraphException(e));
+ }
+ } else {
+ log.debug("Failed to create edge from [{}] to [{}] {}", from, to, graph.right().value());
+ return Either.right(graph.right().value());
+ }
+ }
+
+ public JanusGraphOperationStatus createEdge(Vertex vertexOut, Vertex vertexIn, GraphEdgeLabels type, Map<String, Object> properties) {
+ try {
+ Edge edge = addEdge(vertexOut, vertexIn, type, properties);
+ } catch (Exception e) {
+ log.debug("Failed to create edge from [{}] to [{}]", vertexOut, vertexIn, e);
+ return janusGraphClient.handleJanusGraphException(e);
+ }
+ return JanusGraphOperationStatus.OK;
+ }
+ private Edge addEdge(Vertex vertexOut, Vertex vertexIn, GraphEdgeLabels type, Map<String, Object> properties) {
+ Edge edge = vertexOut.addEdge(type.getProperty(), vertexIn);
+ if (properties != null) {
setProperties(edge, properties);
}
- return edge;
- }
-
- /**
- * creates an identical edge in the graph
- * @param edge
- * @return the copy operation status
- */
- public Either<Edge, JanusGraphOperationStatus> copyEdge(Vertex out, Vertex in, Edge edge) {
- GraphEdgeLabels byName = GraphEdgeLabels.getByName(edge.label());
- return this.saveEdge(out, in, byName, edgePropertiesToMap(edge));
- }
-
- private <V> Map<String, Object> edgePropertiesToMap(Edge edge) {
- Iterable<Property<Object>> propertiesIterable = edge::properties;
- return StreamSupport.stream(propertiesIterable.spliterator(), false).collect(Collectors.toMap(Property::key, Property::value));
- }
-
- public Either<Edge, JanusGraphOperationStatus> saveEdge(Vertex vertexOut, Vertex vertexIn, GraphEdgeLabels type, Map<String, Object> properties) {
- try {
- Edge edge = addEdge(vertexOut, vertexIn, type, properties);
- return Either.left(edge);
- } catch (Exception e) {
- log.debug("Failed to create edge from [{}] to [{}]", vertexOut, vertexIn, e);
- return Either.right(janusGraphClient.handleJanusGraphException(e));
- }
-
- }
-
- public JanusGraphOperationStatus createEdge(JanusGraphVertex vertexOut, GraphNode to, GraphEdgeLabels type, Map<String, Object> properties) {
-
- JanusGraphVertex vertexIn;
- Either<Vertex, JanusGraphOperationStatus> toV = getVertexByPropertyAndLabel(to.getUniqueIdKey(), to.getUniqueId(), to.getLabel());
- if (toV.isRight()) {
- JanusGraphOperationStatus error = toV.right().value();
- if (JanusGraphOperationStatus.NOT_FOUND.equals(error)) {
- return JanusGraphOperationStatus.INVALID_ID;
- } else {
- return error;
- }
- }
- vertexIn = (JanusGraphVertex) toV.left().value();
- return createEdge(vertexOut, vertexIn, type, properties);
- }
-
- /**
- *
- * @param from
- * @param to
- * @param label
- * @param properties
- * @return
- */
- public Either<GraphRelation, JanusGraphOperationStatus> createRelation(GraphNode from, GraphNode to, GraphEdgeLabels label, Map<String, Object> properties) {
- log.debug("try to create relation from [{}] to [{}]", from.getKeyValueId(), to.getKeyValueId());
- return createEdge(label.getProperty(), from.getKeyValueId(), to.getKeyValueId(), from.getLabel(), to.getLabel(), properties);
- }
-
- public Either<GraphRelation, JanusGraphOperationStatus> replaceRelationLabel(GraphNode from, GraphNode to, GraphEdgeLabels label, GraphEdgeLabels newLabel) {
-
- log.debug("try to replace relation {} to {} from [{}] to [{}]", label.name(), newLabel.name(), from.getKeyValueId(), to.getKeyValueId());
- Either<GraphRelation, JanusGraphOperationStatus> getRelationResult = getRelation(from, to, label);
- if (getRelationResult.isRight()) {
- return getRelationResult;
- }
-
- GraphRelation origRelation = getRelationResult.left().value();
- Either<GraphRelation, JanusGraphOperationStatus> createRelationResult = createRelation(from, to, newLabel, origRelation.toGraphMap());
- if (createRelationResult.isRight()) {
- return createRelationResult;
- }
-
- Either<GraphRelation, JanusGraphOperationStatus> deleteRelationResult = deleteRelation(origRelation);
- if (deleteRelationResult.isRight()) {
- return deleteRelationResult;
- }
- return Either.left(createRelationResult.left().value());
- }
-
- /**
- *
- * @param keyName
- * @param keyValue
- * @param clazz
- * @return
- */
- public <T extends GraphNode> Either<T, JanusGraphOperationStatus> getNode(String keyName, Object keyValue, Class<T> clazz) {
-
- log.debug("Try to get node for key [{}] with value [{}] ", keyName, keyValue);
-
- Either<JanusGraphVertex, JanusGraphOperationStatus> vertexByProperty = getVertexByProperty(keyName, keyValue);
-
- if (vertexByProperty.isLeft()) {
- try {
- Vertex vertex = vertexByProperty.left().value();
- Map<String, Object> properties = getProperties(vertex);
- T node = GraphElementFactory.createElement((String) properties.get(GraphPropertiesDictionary.LABEL.getProperty()), GraphElementTypeEnum.Node, properties, clazz);
- return Either.left(node);
- } catch (Exception e) {
- log.debug("Failed to get node for key [{}] with value [{}] ", keyName, keyValue, e);
- return Either.right(JanusGraphClient.handleJanusGraphException(e));
- }
- } else {
- log.debug("Failed to get node for key [{}] with value [{}] ", keyName, keyValue, vertexByProperty.right().value());
- return Either.right(vertexByProperty.right().value());
- }
- }
-
- /**
- *
- * @param from
- * @param to
- * @param label
- * @return
- */
- public Either<GraphRelation, JanusGraphOperationStatus> getRelation(GraphNode from, GraphNode to, GraphEdgeLabels label) {
- log.debug("try to get relation from [{}] to [{}]", from.getKeyValueId(), to.getKeyValueId());
-
- Either<Edge, JanusGraphOperationStatus> edge = getEdgeByNodes(from, to, label);
-
- if (edge.isLeft()) {
- try {
- Map<String, Object> properties = getProperties(edge.left().value());
- GraphRelation relation = GraphElementFactory.createRelation(label.getProperty(), properties, from, to);
- return Either.left(relation);
- } catch (Exception e) {
- log.debug("Failed to get get relation from [{}] to [{}]", from.getKeyValueId(), to.getKeyValueId(), e);
- return Either.right(JanusGraphClient.handleJanusGraphException(e));
- }
- } else {
- log.debug("Failed to get get relation from [{}] to [{}] {}", from.getKeyValueId(), to.getKeyValueId(), edge.right().value());
- return Either.right(edge.right().value());
- }
- }
-
- public Either<Edge, JanusGraphOperationStatus> getEdgeByNodes(GraphNode from, GraphNode to, GraphEdgeLabels label) {
- ImmutablePair<String, Object> keyValueIdFrom = from.getKeyValueId();
- ImmutablePair<String, Object> keyValueIdTo = to.getKeyValueId();
-
- return getEdgeByVerticies(keyValueIdFrom.getKey(), keyValueIdFrom.getValue(), keyValueIdTo.getKey(), keyValueIdTo.getValue(), label.getProperty());
- }
-
- public Either<GraphRelation, JanusGraphOperationStatus> deleteIncomingRelationByCriteria(GraphNode to, GraphEdgeLabels label, Map<String, Object> props) {
-
- Either<Edge, JanusGraphOperationStatus> edgeByCriteria = getIncomingEdgeByCriteria(to, label, props);
- if (edgeByCriteria.isLeft()) {
- Either<JanusGraph, JanusGraphOperationStatus> graph = getGraph();
- if (graph.isLeft()) {
- Edge edge = edgeByCriteria.left().value();
- log.debug("delete edge {} to {} ", label.getProperty(), to.getUniqueId());
- edge.remove();
- Map<String, Object> properties = getProperties(edge);
- Vertex fromVertex = edge.outVertex();
- String fromLabel = fromVertex.value(GraphPropertiesDictionary.LABEL.getProperty());
- GraphNode nodeFrom = GraphElementFactory.createElement(fromLabel, GraphElementTypeEnum.Node, getProperties(fromVertex), GraphNode.class);
- GraphRelation relation = GraphElementFactory.createRelation(label.getProperty(), properties, nodeFrom, to);
- return Either.left(relation);
- } else {
- log.debug("failed to get graph");
- return Either.right(graph.right().value());
- }
-
- } else {
- log.debug("failed to find edge {} to {}", label.getProperty(), to.getUniqueId());
- return Either.right(edgeByCriteria.right().value());
- }
-
- }
-
- public Either<GraphRelation, JanusGraphOperationStatus> getIncomingRelationByCriteria(GraphNode to, GraphEdgeLabels label, Map<String, Object> props) {
-
- Either<Edge, JanusGraphOperationStatus> edgeByCriteria = getIncomingEdgeByCriteria(to, label, props);
- if (edgeByCriteria.isLeft()) {
- Either<JanusGraph, JanusGraphOperationStatus> graph = getGraph();
- if (graph.isLeft()) {
- Edge edge = edgeByCriteria.left().value();
- Map<String, Object> properties = getProperties(edge);
- Vertex fromVertex = edge.outVertex();
- String fromLabel = fromVertex.value(GraphPropertiesDictionary.LABEL.getProperty());
- GraphNode nodeFrom = GraphElementFactory.createElement(fromLabel, GraphElementTypeEnum.Node, getProperties(fromVertex), GraphNode.class);
- GraphRelation relation = GraphElementFactory.createRelation(label.getProperty(), properties, nodeFrom, to);
- return Either.left(relation);
- } else {
- log.debug("failed to get graph");
- return Either.right(graph.right().value());
- }
-
- } else {
- log.debug("failed to find edge {} to {}", label.getProperty(), to.getUniqueId());
- return Either.right(edgeByCriteria.right().value());
- }
-
- }
-
- public Either<Edge, JanusGraphOperationStatus> getIncomingEdgeByCriteria(GraphNode to, GraphEdgeLabels label, Map<String, Object> props) {
-
- ImmutablePair<String, Object> keyValueIdTo = to.getKeyValueId();
-
- Either<JanusGraphVertex, JanusGraphOperationStatus> vertexFrom = getVertexByProperty(keyValueIdTo.getKey(), keyValueIdTo.getValue());
- if (vertexFrom.isRight()) {
- return Either.right(vertexFrom.right().value());
- }
- Vertex vertex = vertexFrom.left().value();
- JanusGraphVertex janusGraphVertex = (JanusGraphVertex) vertex;
- JanusGraphVertexQuery<?> query = janusGraphVertex.query();
- query = query.labels(label.getProperty());
-
- if (props != null && !props.isEmpty()) {
- for (Map.Entry<String, Object> entry : props.entrySet()) {
- query = query.has(entry.getKey(), entry.getValue());
- }
- }
- Edge matchingEdge = null;
- Iterable<JanusGraphEdge> edges = query.edges();
- if (edges == null) {
- log.debug("No edges in graph for criteria");
- return Either.right(JanusGraphOperationStatus.NOT_FOUND);
- }
- Iterator<JanusGraphEdge> eIter = edges.iterator();
- if (eIter.hasNext()) {
- matchingEdge = eIter.next();
- }
-
- if (matchingEdge == null) {
- log.debug("No edges in graph for criteria");
- return Either.right(JanusGraphOperationStatus.NOT_FOUND);
- }
- return Either.left(matchingEdge);
- }
-
- public Either<Edge, JanusGraphOperationStatus> getEdgeByVerticies(String keyNameFrom, Object keyValueFrom, String keyNameTo, Object keyValueTo, String label) {
- Either<JanusGraph, JanusGraphOperationStatus> graph = janusGraphClient.getGraph();
-
- if (graph.isLeft()) {
- try {
- Either<JanusGraphVertex, JanusGraphOperationStatus> vertexFrom = getVertexByProperty(keyNameFrom, keyValueFrom);
- if (vertexFrom.isRight()) {
- return Either.right(vertexFrom.right().value());
- }
- Iterable<JanusGraphEdge> edges = ((JanusGraphVertex) vertexFrom.left().value()).query().labels(label).edges();
- Iterator<JanusGraphEdge> eIter = edges.iterator();
- while (eIter.hasNext()) {
- Edge edge = eIter.next();
- Vertex vertexIn = edge.inVertex();
- if (vertexIn.value(keyNameTo) != null && vertexIn.value(keyNameTo).equals(keyValueTo) && label.equals(edge.label())) {
- return Either.left(edge);
- }
- }
- log.debug("No relation in graph from [{}={}] to [{}={}]", keyNameFrom, keyValueFrom, keyNameTo, keyValueTo);
- return Either.right(JanusGraphOperationStatus.NOT_FOUND);
- } catch (Exception e) {
- log.debug("Failed to get get relation from [{}={}] to [{}={}]", keyNameFrom, keyValueFrom, keyNameTo, keyValueTo, e);
- return Either.right(JanusGraphClient.handleJanusGraphException(e));
- }
- } else {
- return Either.right(graph.right().value());
- }
- }
-
- public Either<List<Edge>, JanusGraphOperationStatus> getEdgesForNode(GraphNode node, Direction requestedDirection) {
-
- Either<List<Edge>, JanusGraphOperationStatus> result;
-
- ImmutablePair<String, Object> keyValueId = node.getKeyValueId();
- Either<JanusGraphVertex, JanusGraphOperationStatus> eitherVertex = getVertexByProperty(keyValueId.getKey(), keyValueId.getValue());
-
- if (eitherVertex.isLeft()) {
- List<Edge> edges = prepareEdgesList(eitherVertex.left().value(), requestedDirection);
-
- result = Either.left(edges);
- } else {
- result = Either.right(eitherVertex.right().value());
- }
- return result;
- }
-
- private List<Edge> prepareEdgesList(Vertex vertex, Direction requestedDirection) {
- List<Edge> edges = new ArrayList<>();
- Iterator<JanusGraphEdge> edgesItr = ((JanusGraphVertex) vertex).query().edges().iterator();
- while (edgesItr.hasNext()) {
- Edge edge = edgesItr.next();
- Direction currEdgeDirection = getEdgeDirection(vertex, edge);
- if (currEdgeDirection == requestedDirection || requestedDirection == Direction.BOTH) {
- edges.add(edge);
- }
-
- }
- return edges;
- }
-
- private Direction getEdgeDirection(Vertex vertex, Edge edge) {
- Direction result;
- Vertex vertexOut = edge.outVertex();
- if (vertexOut.equals(vertex)) {
- result = Direction.OUT;
- } else {
- result = Direction.IN;
-
- }
- return result;
- }
-
- /**
- *
- * @param from
- * @param to
- * @param label
- * @param properties
- * @return
- */
- public Either<GraphRelation, JanusGraphOperationStatus> updateRelation(GraphNode from, GraphNode to, GraphEdgeLabels label, Map<String, Object> properties) {
- log.debug("try to update relation from [{}] to [{}]", from.getKeyValueId(), to.getKeyValueId());
- return updateEdge(label.getProperty(), from.getKeyValueId(), to.getKeyValueId(), from.getLabel(), to.getLabel(), properties);
- }
-
- private Either<GraphRelation, JanusGraphOperationStatus> updateEdge(String type, ImmutablePair<String, Object> from, ImmutablePair<String, Object> to, String fromLabel, String toLabel, Map<String, Object> properties) {
-
- Either<Edge, JanusGraphOperationStatus> edgeS = getEdgeByVerticies(from.getKey(), from.getValue(), to.getKey(), to.getValue(), type);
- if (edgeS.isLeft()) {
-
- try {
- Edge edge = edgeS.left().value();
- if (properties != null) {
- setProperties(edge, properties);
- }
-
- Vertex vertexOut = edge.outVertex();
- Vertex vertexIn = edge.inVertex();
-
- GraphNode nodeOut = GraphElementFactory.createElement(fromLabel, GraphElementTypeEnum.Node, getProperties(vertexOut), GraphNode.class);
- GraphNode nodeIn = GraphElementFactory.createElement(toLabel, GraphElementTypeEnum.Node, getProperties(vertexIn), GraphNode.class);
-
- GraphRelation newRelation = GraphElementFactory.createRelation(edge.label(), getProperties(edge), nodeOut, nodeIn);
- if (log.isDebugEnabled()) {
- log.debug("Relation was updated from [{}] to [{}] ", from, to);
- }
- return Either.left(newRelation);
- } catch (Exception e) {
- if (log.isDebugEnabled()) {
- log.debug("Failed to update relation from [{}] to [{}] ", from, to, e);
- }
- return Either.right(JanusGraphClient.handleJanusGraphException(e));
- }
- } else {
- if (log.isDebugEnabled()) {
- log.debug("Failed to update relation from [{}] to [{}] {}", from, to, edgeS.right().value());
- }
- return Either.right(edgeS.right().value());
- }
- }
-
- /**
- *
- * @param relation
- * @return
- */
- public Either<GraphRelation, JanusGraphOperationStatus> updateRelation(GraphRelation relation) {
- log.debug("try to update relation from [{}] to [{}]", relation.getFrom(), relation.getTo());
- RelationEndPoint from = relation.getFrom();
- RelationEndPoint to = relation.getTo();
- ImmutablePair<String, Object> fromKeyId = new ImmutablePair<>(from.getIdName(), from.getIdValue());
- ImmutablePair<String, Object> toKeyId = new ImmutablePair<>(to.getIdName(), to.getIdValue());
-
- return updateEdge(relation.getType(), fromKeyId, toKeyId, from.getLabel().getName(), to.getLabel().getName(), relation.toGraphMap());
-
- }
-
- private Either<Vertex, JanusGraphOperationStatus> getVertexByPropertyAndLabel(String name, Object value, String label) {
-
- Either<JanusGraph, JanusGraphOperationStatus> graph = janusGraphClient.getGraph();
- if (graph.isLeft()) {
- try {
- JanusGraph tGraph = graph.left().value();
-
- @SuppressWarnings("unchecked")
- Iterable<JanusGraphVertex> vertecies = tGraph.query().has(name, value).has(GraphPropertiesDictionary.LABEL.getProperty(), label).vertices();
-
- java.util.Iterator<JanusGraphVertex> iterator = vertecies.iterator();
- if (iterator.hasNext()) {
- Vertex vertex = iterator.next();
- return Either.left(vertex);
- }
- if (log.isDebugEnabled()) {
- log.debug("No vertex in graph for key =" + name + " and value = " + value + " label = " + label);
- }
- return Either.right(JanusGraphOperationStatus.NOT_FOUND);
- } catch (Exception e) {
- if (log.isDebugEnabled()) {
- log.debug("Failed to get vertex in graph for key ={} and value = {} label = {}",name,value,label);
- }
- return Either.right(JanusGraphClient.handleJanusGraphException(e));
- }
-
- } else {
- if (log.isDebugEnabled()) {
- log.debug("No vertex in graph for key ={} and value = {} label = {} error : {}",name,value,label,graph.right().value());
- }
- return Either.right(graph.right().value());
- }
- }
-
- public Either<JanusGraphVertex, JanusGraphOperationStatus> getVertexByProperty(String name, Object value) {
-
- Either<JanusGraph, JanusGraphOperationStatus> graph = janusGraphClient.getGraph();
- if (value == null) {
- if (log.isDebugEnabled()) {
- log.debug("No vertex in graph for key = {} and value = {}", name, value);
- }
- return Either.right(JanusGraphOperationStatus.NOT_FOUND);
- }
- if (graph.isLeft()) {
- try {
- JanusGraph tGraph = graph.left().value();
-
- @SuppressWarnings("unchecked")
- Iterable<JanusGraphVertex> vertecies = tGraph.query().has(name, value).vertices();
-
- java.util.Iterator<JanusGraphVertex> iterator = vertecies.iterator();
- if (iterator.hasNext()) {
- JanusGraphVertex vertex = iterator.next();
- return Either.left(vertex);
- } else {
- if (log.isDebugEnabled()) {
- log.debug("No vertex in graph for key ={} and value = {}", name, value);
- }
- return Either.right(JanusGraphOperationStatus.NOT_FOUND);
- }
- } catch (Exception e) {
- if (log.isDebugEnabled()) {
- log.debug("Failed to get vertex in graph for key = {} and value = ", name, value);
- }
- return Either.right(JanusGraphClient.handleJanusGraphException(e));
- }
- } else {
- if (log.isDebugEnabled()) {
- log.debug("No vertex in graph for key = {} and value = {} error : {}", name, value, graph.right().value());
- }
- return Either.right(graph.right().value());
- }
- }
-
- public <T extends GraphNode> Either<List<T>, JanusGraphOperationStatus> getByCriteria(NodeTypeEnum type, Map<String, Object> hasProps, Map<String, Object> hasNotProps, Class<T> clazz) {
- Either<JanusGraph, JanusGraphOperationStatus> graph = janusGraphClient.getGraph();
- if (graph.isLeft()) {
- try {
- JanusGraph tGraph = graph.left().value();
-
- JanusGraphQuery<? extends JanusGraphQuery> query = tGraph.query();
- query = query.has(GraphPropertiesDictionary.LABEL.getProperty(), type.getName());
-
- if (hasProps != null && !hasProps.isEmpty()) {
- for (Map.Entry<String, Object> entry : hasProps.entrySet()) {
- query = query.has(entry.getKey(), entry.getValue());
- }
- }
- if (hasNotProps != null && !hasNotProps.isEmpty()) {
- for (Map.Entry<String, Object> entry : hasNotProps.entrySet()) {
- query = query.hasNot(entry.getKey(), entry.getValue());
- }
- }
- Iterable<JanusGraphVertex> vertices = query.vertices();
- if (vertices == null) {
- return Either.right(JanusGraphOperationStatus.NOT_FOUND);
- }
-
- Iterator<JanusGraphVertex> iterator = vertices.iterator();
- List<T> result = new ArrayList<>();
-
- while (iterator.hasNext()) {
- Vertex vertex = iterator.next();
-
- Map<String, Object> newProp = getProperties(vertex);
-
- T element = GraphElementFactory.createElement(type.getName(), GraphElementTypeEnum.Node, newProp, clazz);
- result.add(element);
- }
- if (log.isDebugEnabled()) {
- log.debug("Number of fetced nodes in graph for criteria : from type = {} and properties has = {}, properties hasNot = {} is {}", type, hasProps, hasNotProps, result.size());
- }
- if (result.size() == 0) {
- return Either.right(JanusGraphOperationStatus.NOT_FOUND);
- }
-
- return Either.left(result);
- } catch (Exception e) {
- if (log.isDebugEnabled()) {
- log.debug("Failed get by criteria for type = {}", type, e);
- }
- return Either.right(JanusGraphClient.handleJanusGraphException(e));
- }
-
- } else {
- if (log.isDebugEnabled()) {
- log.debug("Failed get by criteria for type ={} error : {}", type, graph.right().value());
- }
- return Either.right(graph.right().value());
- }
- }
-
- public <T extends GraphNode> Either<List<T>, JanusGraphOperationStatus> getByCriteria(NodeTypeEnum type, Class<T> clazz, List<ImmutableTriple<QueryType, String, Object>> props) {
- Either<JanusGraph, JanusGraphOperationStatus> graph = janusGraphClient.getGraph();
- if (graph.isLeft()) {
- try {
- JanusGraph tGraph = graph.left().value();
-
- JanusGraphQuery<? extends JanusGraphQuery> query = tGraph.query();
- query = query.has(GraphPropertiesDictionary.LABEL.getProperty(), type.getName());
- for (ImmutableTriple<QueryType, String, Object> prop : props) {
- if (QueryType.HAS.equals(prop.getLeft())) {
- query = query.has(prop.getMiddle(), prop.getRight());
- } else {
- query = query.hasNot(prop.getMiddle(), prop.getRight());
- }
- }
- Iterable<JanusGraphVertex> vertices = query.vertices();
- if (vertices == null) {
- return Either.right(JanusGraphOperationStatus.NOT_FOUND);
- }
-
- Iterator<JanusGraphVertex> iterator = vertices.iterator();
- List<T> result = new ArrayList<>();
-
- while (iterator.hasNext()) {
- Vertex vertex = iterator.next();
-
- Map<String, Object> newProp = getProperties(vertex);
-
- T element = GraphElementFactory.createElement(type.getName(), GraphElementTypeEnum.Node, newProp, clazz);
- result.add(element);
- }
- if (result.size() == 0) {
- return Either.right(JanusGraphOperationStatus.NOT_FOUND);
- }
-
- return Either.left(result);
- } catch (Exception e) {
- if (log.isDebugEnabled()) {
- log.debug("Failed get by criteria for type = {}", type, e);
- }
- return Either.right(JanusGraphClient.handleJanusGraphException(e));
- }
-
- } else {
- if (log.isDebugEnabled()) {
- log.debug("Failed get by criteria for type ={} error : {}", type, graph.right().value());
- }
- return Either.right(graph.right().value());
- }
- }
-
- public <T extends GraphNode> Either<List<T>, JanusGraphOperationStatus> getByCriteria(NodeTypeEnum type, Map<String, Object> props, Class<T> clazz) {
- Either<JanusGraph, JanusGraphOperationStatus> graph = janusGraphClient.getGraph();
- if (graph.isLeft()) {
- try {
- JanusGraph tGraph = graph.left().value();
-
- JanusGraphQuery<? extends JanusGraphQuery> query = tGraph.query();
- query = query.has(GraphPropertiesDictionary.LABEL.getProperty(), type.getName());
-
- if (props != null && !props.isEmpty()) {
- for (Map.Entry<String, Object> entry : props.entrySet()) {
- query = query.has(entry.getKey(), entry.getValue());
- }
- }
- Iterable<JanusGraphVertex> vertices = query.vertices();
- if (vertices == null) {
- return Either.right(JanusGraphOperationStatus.NOT_FOUND);
- }
-
- Iterator<JanusGraphVertex> iterator = vertices.iterator();
- List<T> result = new ArrayList<>();
-
- while (iterator.hasNext()) {
- Vertex vertex = iterator.next();
-
- Map<String, Object> newProp = getProperties(vertex);
-
- T element = GraphElementFactory.createElement(type.getName(), GraphElementTypeEnum.Node, newProp, clazz);
- result.add(element);
- }
- if (log.isDebugEnabled()) {
- log.debug("Number of fetced nodes in graph for criteria : from type = {} and properties = {} is {}", type, props, result.size());
- }
- if (result.size() == 0) {
- return Either.right(JanusGraphOperationStatus.NOT_FOUND);
- }
-
- return Either.left(result);
- } catch (Exception e) {
- if (log.isDebugEnabled()) {
- log.debug("Failed get by criteria for type = {} and properties = {}", type, props, e);
- }
- return Either.right(JanusGraphClient.handleJanusGraphException(e));
- }
-
- } else {
- if (log.isDebugEnabled()) {
- log.debug("Failed get by criteria for type ={} and properties = {} error : {}", type, props, graph.right().value());
- }
- return Either.right(graph.right().value());
- }
- }
-
- public <T extends GraphNode> Either<List<T>, JanusGraphOperationStatus> getByCriteriaWithPredicate(NodeTypeEnum type, Map<String, Entry<JanusGraphPredicate, Object>> props, Class<T> clazz) {
- Either<JanusGraph, JanusGraphOperationStatus> graph = janusGraphClient.getGraph();
- if (graph.isLeft()) {
- try {
- JanusGraph tGraph = graph.left().value();
-
- JanusGraphQuery<? extends JanusGraphQuery> query = tGraph.query();
- query = query.has(GraphPropertiesDictionary.LABEL.getProperty(), type.getName());
-
- if (props != null && !props.isEmpty()) {
- JanusGraphPredicate predicate = null;
- Object object = null;
- for (Map.Entry<String, Entry<JanusGraphPredicate, Object>> entry : props.entrySet()) {
- predicate = entry.getValue().getKey();
- object = entry.getValue().getValue();
- query = query.has(entry.getKey(), predicate, object);
- }
- }
- Iterable<JanusGraphVertex> vertices = query.vertices();
- if (vertices == null) {
- return Either.right(JanusGraphOperationStatus.NOT_FOUND);
- }
-
- Iterator<JanusGraphVertex> iterator = vertices.iterator();
- List<T> result = new ArrayList<>();
-
- while (iterator.hasNext()) {
- Vertex vertex = iterator.next();
-
- Map<String, Object> newProp = getProperties(vertex);
- T element = GraphElementFactory.createElement(type.getName(), GraphElementTypeEnum.Node, newProp, clazz);
- result.add(element);
- }
- if (result.size() == 0) {
- return Either.right(JanusGraphOperationStatus.NOT_FOUND);
- }
- if (log.isDebugEnabled()) {
- log.debug("No nodes in graph for criteria : from type = {} and properties = {}", type, props);
- }
- return Either.left(result);
- } catch (Exception e) {
- if (log.isDebugEnabled()) {
- log.debug("Failed get by criteria for type = {} and properties = {}", type, props, e);
- }
- return Either.right(JanusGraphClient.handleJanusGraphException(e));
- }
-
- } else {
- if (log.isDebugEnabled()) {
- log.debug("Failed get by criteria for type = {} and properties = {} error : {}", type, props, graph.right().value());
- }
- return Either.right(graph.right().value());
- }
- }
-
- public <T extends GraphNode> Either<List<T>, JanusGraphOperationStatus> getAll(NodeTypeEnum type, Class<T> clazz) {
- return getByCriteria(type, null, clazz);
- }
-
- /**
- *
- * @param node
- * @param clazz
- * @return
- */
- public <T extends GraphNode> Either<T, JanusGraphOperationStatus> updateNode(GraphNode node, Class<T> clazz) {
- log.debug("Try to update node for {}", node.getKeyValueIdForLog());
-
- ImmutablePair<String, Object> keyValueId = node.getKeyValueId();
- Either<Vertex, JanusGraphOperationStatus> vertexByProperty = getVertexByPropertyAndLabel(keyValueId.getKey(), keyValueId.getValue(), node.getLabel());
-
- if (vertexByProperty.isLeft()) {
- try {
- Vertex vertex = vertexByProperty.left().value();
-
- Map<String, Object> mapProps = node.toGraphMap();
-
- for (Map.Entry<String, Object> entry : mapProps.entrySet()) {
- if (!entry.getKey().equals(node.getUniqueIdKey())) {
- vertex.property(entry.getKey(), entry.getValue());
- }
- }
-
- Either<Vertex, JanusGraphOperationStatus> vertexByPropertyAndLabel = getVertexByPropertyAndLabel(keyValueId.getKey(), keyValueId.getValue(), node.getLabel());
- if (vertexByPropertyAndLabel.isRight()) {
- return Either.right(vertexByPropertyAndLabel.right().value());
- } else {
- Map<String, Object> newProp = getProperties(vertexByPropertyAndLabel.left().value());
- T updateNode = GraphElementFactory.createElement(node.getLabel(), GraphElementTypeEnum.Node, newProp, clazz);
- return Either.left(updateNode);
- }
- } catch (Exception e) {
- if (log.isDebugEnabled()) {
- log.debug("Failed to update node for {}", node.getKeyValueId(), e);
- }
- return Either.right(JanusGraphClient.handleJanusGraphException(e));
- }
- } else {
- if (log.isDebugEnabled()) {
- log.debug("Failed to update node for {} error :{}", node.getKeyValueIdForLog(), vertexByProperty.right().value());
- }
- return Either.right(vertexByProperty.right().value());
- }
-
- }
-
- public JanusGraphOperationStatus updateVertex(GraphNode node, Vertex vertex) {
- log.debug("Try to update node for {}", node.getKeyValueId());
- try {
-
- Map<String, Object> mapProps = node.toGraphMap();
-
- for (Map.Entry<String, Object> entry : mapProps.entrySet()) {
- if (!entry.getKey().equals(node.getUniqueIdKey())) {
- vertex.property(entry.getKey(), entry.getValue());
- }
- }
-
- } catch (Exception e) {
- if (log.isDebugEnabled()) {
- log.debug("Failed to update node for {}", node.getKeyValueId(), e);
- }
- return JanusGraphClient.handleJanusGraphException(e);
- }
- return JanusGraphOperationStatus.OK;
-
- }
-
- /**
- *
- * @param node
- * @param clazz
- * @return
- */
- public <T extends GraphNode> Either<T, JanusGraphOperationStatus> deleteNode(GraphNode node, Class<T> clazz) {
- log.debug("Try to delete node for {}", node.getKeyValueId());
- ImmutablePair<String, Object> keyValueId = node.getKeyValueId();
- return deleteNode(keyValueId.getKey(), keyValueId.getValue(), clazz);
- }
-
- /**
- *
- * @param keyName
- * @param keyValue
- * @param clazz
- * @return
- */
- public <T extends GraphNode> Either<T, JanusGraphOperationStatus> deleteNode(String keyName, Object keyValue, Class<T> clazz) {
- Either<JanusGraphVertex, JanusGraphOperationStatus> vertexByProperty = getVertexByProperty(keyName, keyValue);
-
- if (vertexByProperty.isLeft()) {
- try {
- Vertex vertex = vertexByProperty.left().value();
-
- Map<String, Object> properties = getProperties(vertex);
- if (properties != null) {
- String label = (String) properties.get(GraphPropertiesDictionary.LABEL.getProperty());
-
- T node = GraphElementFactory.createElement(label, GraphElementTypeEnum.Node, properties, clazz);
- if (node != null) {
- Either<JanusGraph, JanusGraphOperationStatus> graph = janusGraphClient.getGraph();
- if (graph.isLeft()) {
- JanusGraph tGraph = graph.left().value();
- vertex.remove();
- } else {
- return Either.right(graph.right().value());
- }
- return Either.left(node);
- } else {
- if (log.isDebugEnabled()) {
- log.debug("Failed to delete node for {} = {} Missing label property on node", keyName, keyValue);
- }
- return Either.right(JanusGraphOperationStatus.MISSING_NODE_LABEL);
- }
- } else {
- if (log.isDebugEnabled()) {
- log.debug("Failed to delete node for {} = {} Missing label property on node", keyName, keyValue);
- }
- return Either.right(JanusGraphOperationStatus.MISSING_NODE_LABEL);
- }
- } catch (Exception e) {
- if (log.isDebugEnabled()) {
- log.debug("Failed to delete node for {} = {}", keyName, keyValue, e);
- }
- return Either.right(JanusGraphClient.handleJanusGraphException(e));
- }
-
- } else {
- return Either.right(vertexByProperty.right().value());
- }
- }
-
- public Either<GraphRelation, JanusGraphOperationStatus> deleteRelation(GraphRelation relation) {
- log.debug("try to delete relation from [{}] to [{}]", relation.getFrom(), relation.getTo());
- RelationEndPoint from = relation.getFrom();
- RelationEndPoint to = relation.getTo();
- ImmutablePair<String, Object> fromKeyId = new ImmutablePair<>(from.getIdName(), from.getIdValue());
- ImmutablePair<String, Object> toKeyId = new ImmutablePair<>(to.getIdName(), to.getIdValue());
-
- return deleteEdge(relation.getType(), fromKeyId, toKeyId, from.getLabel().getName(), to.getLabel().getName());
-
- }
-
- public Either<Boolean, JanusGraphOperationStatus> isRelationExist(GraphNode from, GraphNode to, GraphEdgeLabels edgeLabel) {
- return getEdgeByNodes(from, to, edgeLabel)
- .left()
- .map(edge -> true)
- .right()
- .bind(err -> err == JanusGraphOperationStatus.NOT_FOUND ? Either.left(false): Either.right(err));
- }
-
- public Either<GraphRelation, JanusGraphOperationStatus> deleteRelation(GraphNode from, GraphNode to, GraphEdgeLabels label) {
- log.debug("try to delete relation from [{}] to [{}]", from.getKeyValueId(), to.getKeyValueId());
- return deleteEdge(label.getProperty(), from.getKeyValueId(), to.getKeyValueId(), from.getLabel(), to.getLabel());
- }
-
- private Either<GraphRelation, JanusGraphOperationStatus> deleteEdge(String type, ImmutablePair<String, Object> fromKeyId, ImmutablePair<String, Object> toKeyId, String fromLabel, String toLabel) {
- Either<Edge, JanusGraphOperationStatus> edgeS = getEdgeByVerticies(fromKeyId.getKey(), fromKeyId.getValue(), toKeyId.getKey(), toKeyId.getValue(), type);
- if (edgeS.isLeft()) {
- try {
- Edge edge = edgeS.left().value();
-
- Vertex vertexOut = edge.outVertex();
- Vertex vertexIn = edge.inVertex();
-
- GraphNode nodeOut = GraphElementFactory.createElement(fromLabel, GraphElementTypeEnum.Node, getProperties(vertexOut), GraphNode.class);
- GraphNode nodeIn = GraphElementFactory.createElement(toLabel, GraphElementTypeEnum.Node, getProperties(vertexIn), GraphNode.class);
-
- GraphRelation newRelation = GraphElementFactory.createRelation(edge.label(), getProperties(edge), nodeOut, nodeIn);
-
- Either<JanusGraph, JanusGraphOperationStatus> graph = janusGraphClient.getGraph();
-
- if (graph.isLeft()) {
- edge.remove();
- ;
- } else {
- if (log.isDebugEnabled()) {
- log.debug("Failed to delete relation {} from {} to {} error : {}",type,fromKeyId,toKeyId,graph.right().value());
- }
- return Either.right(graph.right().value());
- }
- return Either.left(newRelation);
- } catch (Exception e) {
- if (log.isDebugEnabled()) {
- log.debug("Failed to delete relation {} from {} to {}", type, fromKeyId, toKeyId, e);
- }
- return Either.right(JanusGraphClient.handleJanusGraphException(e));
- }
- } else {
- if (log.isDebugEnabled()) {
- log.debug("Failed to delete relation {} from {} to {} error : {}", type, fromKeyId, toKeyId, edgeS.right().value());
- }
- return Either.right(edgeS.right().value());
- }
- }
-
- public void setJanusGraphClient(JanusGraphClient janusGraphClient) {
- this.janusGraphClient = janusGraphClient;
- }
-
- public Either<GraphRelation, JanusGraphOperationStatus> deleteIncomingRelation(GraphRelation relation) {
-
- RelationEndPoint to = relation.getTo();
- ImmutablePair<String, Object> toKeyId = new ImmutablePair<>(to.getIdName(), to.getIdValue());
-
- return deleteIncomingEdge(relation.getType(), toKeyId);
-
- }
-
- private Either<GraphRelation, JanusGraphOperationStatus> deleteIncomingEdge(String type, ImmutablePair<String, Object> toKeyId) {
-
- Either<JanusGraph, JanusGraphOperationStatus> graph = janusGraphClient.getGraph();
-
- if (graph.isLeft()) {
- Either<JanusGraphVertex, JanusGraphOperationStatus> rootVertexResult = getVertexByProperty(toKeyId.getKey(), toKeyId.getValue());
- if (rootVertexResult.isLeft()) {
- Vertex rootVertex = rootVertexResult.left().value();
- Iterator<Edge> edgesIterator = rootVertex.edges(Direction.IN, type);
- if (edgesIterator != null) {
-
- Edge edge = null;
-
- if (edgesIterator.hasNext()) {
- edge = edgesIterator.next();
- if (edgesIterator.hasNext()) {
- return Either.right(JanusGraphOperationStatus.MULTIPLE_EDGES_WITH_SAME_LABEL);
- }
- } else {
- return Either.right(JanusGraphOperationStatus.NOT_FOUND);
- }
-
- log.debug("Find the tail vertex of the edge of type {} to vertex {}", type, toKeyId);
- Vertex vertexOut = edge.outVertex();
- String fromLabel = vertexOut.value(GraphPropertiesDictionary.LABEL.getProperty());
- String toLabel = rootVertex.value(GraphPropertiesDictionary.LABEL.getProperty());
- log.debug("The label of the outgoing vertex is {}", fromLabel);
- GraphNode nodeOut = GraphElementFactory.createElement(fromLabel, GraphElementTypeEnum.Node, getProperties(vertexOut), GraphNode.class);
-
- GraphNode nodeIn = GraphElementFactory.createElement(toLabel, GraphElementTypeEnum.Node, getProperties(rootVertex), GraphNode.class);
-
- GraphRelation newRelation = GraphElementFactory.createRelation(edge.label(), getProperties(edge), nodeOut, nodeIn);
-
- edge.remove();
-
- return Either.left(newRelation);
-
- } else {
- return Either.right(JanusGraphOperationStatus.NOT_FOUND);
- }
-
- } else {
- return Either.right(graph.right().value());
- }
-
- } else {
- return Either.right(graph.right().value());
- }
-
- }
-
- public Either<GraphRelation, JanusGraphOperationStatus> deleteOutgoingRelation(GraphRelation relation) {
-
- RelationEndPoint from = relation.getFrom();
- ImmutablePair<String, Object> fromKeyId = new ImmutablePair<>(from.getIdName(), from.getIdValue());
-
- return deleteOutgoingEdge(relation.getType(), fromKeyId);
-
- }
-
- private Either<GraphRelation, JanusGraphOperationStatus> deleteOutgoingEdge(String type, ImmutablePair<String, Object> toKeyId) {
-
- Either<JanusGraph, JanusGraphOperationStatus> graph = janusGraphClient.getGraph();
-
- if (graph.isLeft()) {
- Either<JanusGraphVertex, JanusGraphOperationStatus> rootVertexResult = getVertexByProperty(toKeyId.getKey(), toKeyId.getValue());
- if (rootVertexResult.isLeft()) {
- Vertex rootVertex = rootVertexResult.left().value();
- Iterator<Edge> edgesIterator = rootVertex.edges(Direction.OUT, type);
- if (edgesIterator != null) {
-
- Edge edge = null;
-
- if (edgesIterator.hasNext()) {
- edge = edgesIterator.next();
- if (edgesIterator.hasNext()) {
- return Either.right(JanusGraphOperationStatus.MULTIPLE_EDGES_WITH_SAME_LABEL);
- }
- } else {
- return Either.right(JanusGraphOperationStatus.NOT_FOUND);
- }
-
- log.debug("Find the tail vertex of the edge of type {} to vertex ", type, toKeyId);
- Vertex vertexIn = edge.inVertex();
- String toLabel = vertexIn.value(GraphPropertiesDictionary.LABEL.getProperty());
- String fromLabel = rootVertex.value(GraphPropertiesDictionary.LABEL.getProperty());
- log.debug("The label of the tail vertex is {}", toLabel);
- GraphNode nodeFrom = GraphElementFactory.createElement(fromLabel, GraphElementTypeEnum.Node, getProperties(rootVertex), GraphNode.class);
-
- GraphNode nodeTo = GraphElementFactory.createElement(toLabel, GraphElementTypeEnum.Node, getProperties(vertexIn), GraphNode.class);
-
- GraphRelation newRelation = GraphElementFactory.createRelation(edge.label(), getProperties(edge), nodeFrom, nodeTo);
-
- edge.remove();
-
- return Either.left(newRelation);
-
- } else {
- return Either.right(JanusGraphOperationStatus.NOT_FOUND);
- }
-
- } else {
- return Either.right(graph.right().value());
- }
-
- } else {
- return Either.right(graph.right().value());
- }
- }
-
- /**
- *
- * @param id
- * @return
- */
-
- public JanusGraphOperationStatus lockElement(String id, NodeTypeEnum type) {
-
- StringBuilder lockId = new StringBuilder(LOCK_NODE_PREFIX);
- lockId.append(type.getName()).append("_").append(id);
- return lockNode(lockId.toString());
- }
-
- public JanusGraphOperationStatus lockElement(GraphNode node) {
-
- String lockId = createLockElementId(node);
-
- return lockNode(lockId);
- }
-
- private JanusGraphOperationStatus lockNode(String lockId) {
- GraphNodeLock lockNode = new GraphNodeLock(lockId);
-
- Either<GraphNodeLock, JanusGraphOperationStatus> lockNodeNew = createNode(lockNode, GraphNodeLock.class);
- if (lockNodeNew.isLeft()) {
- log.debug("before commit, Lock node created for {}", lockId);
- return janusGraphClient.commit();
- } else {
- Either<JanusGraph, JanusGraphOperationStatus> graph = janusGraphClient.getGraph();
- if (graph.isLeft()) {
- JanusGraph tGraph = graph.left().value();
- Either<JanusGraphVertex, JanusGraphOperationStatus> vertex = getVertexByProperty(lockNode.getUniqueIdKey(), lockNode.getUniqueId());
- if (vertex.isLeft()) {
- return relockNode(lockNode, lockNodeNew, tGraph, vertex);
- } else {
- return vertex.right().value();
- }
- } else {
- return graph.right().value();
- }
- }
- }
-
- private JanusGraphOperationStatus relockNode(GraphNodeLock lockNode, Either<GraphNodeLock, JanusGraphOperationStatus> lockNodeNew, JanusGraph tGraph, Either<JanusGraphVertex, JanusGraphOperationStatus> vertex) {
- Long time = vertex.left().value().value(GraphPropertiesDictionary.CREATION_DATE.getProperty());
- Long lockTimeout = ConfigurationManager.getConfigurationManager().getConfiguration().getJanusGraphLockTimeout();
- if (time + lockTimeout * 1000 < System.currentTimeMillis()) {
- log.debug("Found not released lock node with id {}", lockNode.getUniqueId());
- vertex.left().value().remove();
- lockNodeNew = createNode(lockNode, GraphNodeLock.class);
- if (lockNodeNew.isLeft()) {
- log.debug("Lock node created for {}", lockNode.getUniqueIdKey());
- return janusGraphClient.commit();
- } else {
- log.debug("Failed Lock node for {} . Commit transacton for deleted previous vertex .", lockNode.getUniqueIdKey());
- janusGraphClient.commit();
- return checkLockError(lockNode.getUniqueIdKey(), lockNodeNew);
- }
- } else {
- log.debug("Failed Lock node for {} rollback transacton", lockNode.getUniqueIdKey());
- janusGraphClient.rollback();
- return checkLockError(lockNode.getUniqueIdKey(), lockNodeNew);
- }
- }
-
- public <T extends GraphNode> Either<List<ImmutablePair<T, GraphEdge>>, JanusGraphOperationStatus> getChildrenNodes(String key, String uniqueId, GraphEdgeLabels edgeType, NodeTypeEnum nodeTypeEnum, Class<T> clazz, boolean withEdges) {
-
- List<ImmutablePair<T, GraphEdge>> immutablePairs = new ArrayList<>();
-
- Either<JanusGraph, JanusGraphOperationStatus> graphRes = janusGraphClient.getGraph();
- if (graphRes.isRight()) {
- log.error("Failed to retrieve graph. status is {}", graphRes);
- return Either.right(graphRes.right().value());
- }
-
- JanusGraph janusGraph = graphRes.left().value();
- @SuppressWarnings("unchecked")
- Iterable<JanusGraphVertex> vertices = janusGraph.query().has(key, uniqueId).vertices();
- if (vertices == null || !vertices.iterator().hasNext()) {
- return Either.right(JanusGraphOperationStatus.INVALID_ID);
- }
-
- Vertex rootVertex = vertices.iterator().next();
-
- Iterator<Edge> edgesCreatorIterator = rootVertex.edges(Direction.OUT, edgeType.getProperty());
- if (edgesCreatorIterator != null) {
- while (edgesCreatorIterator.hasNext()) {
- Edge edge = edgesCreatorIterator.next();
- GraphEdge graphEdge = null;
-
- if (withEdges) {
- Map<String, Object> edgeProps = getProperties(edge);
- GraphEdgeLabels edgeTypeFromGraph = GraphEdgeLabels.getByName(edge.label());
- graphEdge = new GraphEdge(edgeTypeFromGraph, edgeProps);
- }
-
- Vertex outgoingVertex = edge.inVertex();
- Map<String, Object> properties = getProperties(outgoingVertex);
- T data = GraphElementFactory.createElement(nodeTypeEnum.getName(), GraphElementTypeEnum.Node, properties, clazz);
-
- ImmutablePair<T, GraphEdge> immutablePair = new ImmutablePair<>(clazz.cast(data), graphEdge);
- immutablePairs.add(immutablePair);
- }
- }
-
- if (immutablePairs.isEmpty()) {
- return Either.right(JanusGraphOperationStatus.NOT_FOUND);
- }
-
- return Either.left(immutablePairs);
-
- }
-
- public Either<List<ImmutablePair<JanusGraphVertex, Edge>>, JanusGraphOperationStatus> getChildrenVertecies(String key, String uniqueId, GraphEdgeLabels edgeType) {
-
- List<ImmutablePair<JanusGraphVertex, Edge>> immutablePairs = new ArrayList<>();
-
- Either<JanusGraph, JanusGraphOperationStatus> graphRes = janusGraphClient.getGraph();
- if (graphRes.isRight()) {
- log.error("Failed to retrieve graph. status is {}", graphRes);
- return Either.right(graphRes.right().value());
- }
-
- JanusGraph janusGraph = graphRes.left().value();
- @SuppressWarnings("unchecked")
- Iterable<JanusGraphVertex> vertices = janusGraph.query().has(key, uniqueId).vertices();
- if (vertices == null || !vertices.iterator().hasNext()) {
- return Either.right(JanusGraphOperationStatus.INVALID_ID);
- }
-
- Vertex rootVertex = vertices.iterator().next();
-
- Iterator<Edge> edgesCreatorIterator = rootVertex.edges(Direction.OUT, edgeType.getProperty());
- if (edgesCreatorIterator != null) {
- while (edgesCreatorIterator.hasNext()) {
- Edge edge = edgesCreatorIterator.next();
- JanusGraphVertex vertex = (JanusGraphVertex) edge.inVertex();
-
- ImmutablePair<JanusGraphVertex, Edge> immutablePair = new ImmutablePair<>(vertex, edge);
- immutablePairs.add(immutablePair);
- }
- }
- if (immutablePairs.isEmpty()) {
- return Either.right(JanusGraphOperationStatus.NOT_FOUND);
- }
-
- return Either.left(immutablePairs);
-
- }
-
- public <T extends GraphNode> Either<List<ImmutablePair<T, GraphEdge>>, JanusGraphOperationStatus> getChildrenNodes(String key, String uniqueId, GraphEdgeLabels edgeType, NodeTypeEnum nodeTypeEnum, Class<T> clazz) {
- return this.getChildrenNodes(key, uniqueId, edgeType, nodeTypeEnum, clazz, true);
- }
-
- private JanusGraphOperationStatus checkLockError(String lockId, Either<GraphNodeLock, JanusGraphOperationStatus> lockNodeNew) {
- JanusGraphOperationStatus status;
- JanusGraphOperationStatus error = lockNodeNew.right().value();
- log.debug("Failed to Lock node for {} error = {}", lockId, error);
- if (error.equals(JanusGraphOperationStatus.JANUSGRAPH_SCHEMA_VIOLATION) || error.equals(
- JanusGraphOperationStatus.ILLEGAL_ARGUMENT)) {
- status = JanusGraphOperationStatus.ALREADY_LOCKED;
- } else {
- status = error;
- }
- return status;
- }
-
- /**
- *
- * @param node
- * @return
- */
- public JanusGraphOperationStatus releaseElement(GraphNode node) {
- String lockId = createLockElementId(node);
-
- return unlockNode(lockId);
- }
-
- private JanusGraphOperationStatus unlockNode(String lockId) {
- GraphNodeLock lockNode = new GraphNodeLock(lockId.toString());
-
- Either<GraphNodeLock, JanusGraphOperationStatus> lockNodeNew = deleteNode(lockNode, GraphNodeLock.class);
- if (lockNodeNew.isLeft()) {
- log.debug("Lock node released for lock id = {}", lockId);
- return janusGraphClient.commit();
- } else {
- janusGraphClient.rollback();
- JanusGraphOperationStatus error = lockNodeNew.right().value();
- log.debug("Failed to Release node for lock id {} error = {}", lockId, error);
- return error;
- }
- }
-
- public JanusGraphOperationStatus releaseElement(String id, NodeTypeEnum type) {
- StringBuilder lockId = new StringBuilder(LOCK_NODE_PREFIX);
- lockId.append(type.getName()).append("_").append(id);
- return unlockNode(lockId.toString());
- }
-
- private String createLockElementId(GraphNode node) {
- StringBuilder lockId = new StringBuilder(LOCK_NODE_PREFIX);
- lockId.append(node.getLabel()).append("_").append(node.getUniqueId());
- return lockId.toString();
- }
-
- public <T extends GraphNode> Either<ImmutablePair<T, GraphEdge>, JanusGraphOperationStatus> getChild(String key, String uniqueId, GraphEdgeLabels edgeType, NodeTypeEnum nodeTypeEnum, Class<T> clazz) {
-
- Either<List<ImmutablePair<T, GraphEdge>>, JanusGraphOperationStatus> childrenNodes = getChildrenNodes(key, uniqueId, edgeType, nodeTypeEnum, clazz);
-
- if (childrenNodes.isRight()) {
- return Either.right(childrenNodes.right().value());
- }
-
- List<ImmutablePair<T, GraphEdge>> value = childrenNodes.left().value();
-
- if (value.size() > 1) {
- return Either.right(JanusGraphOperationStatus.MULTIPLE_CHILDS_WITH_SAME_EDGE);
- }
-
- return Either.left(value.get(0));
-
- }
-
- public ImmutablePair<JanusGraphVertex, Edge> getChildVertex(JanusGraphVertex vertex, GraphEdgeLabels edgeType) {
-
- ImmutablePair<JanusGraphVertex, Edge> pair = null;
- Iterator<Edge> edges = vertex.edges(Direction.OUT, edgeType.getProperty());
- if (edges.hasNext()) {
- // get only first edge
- Edge edge = edges.next();
- pair = new ImmutablePair<>((JanusGraphVertex) edge.inVertex(), edge);
- }
- return pair;
- }
-
- public <T extends GraphNode> Either<List<ImmutablePair<T, GraphEdge>>, JanusGraphOperationStatus> getParentNodes(String key, String uniqueId, GraphEdgeLabels edgeType, NodeTypeEnum nodeTypeEnum, Class<T> clazz) {
-
- List<ImmutablePair<T, GraphEdge>> immutablePairs = new ArrayList<>();
-
- T data = null;
- GraphEdge graphEdge = null;
-
- Either<JanusGraph, JanusGraphOperationStatus> graphRes = janusGraphClient.getGraph();
- if (graphRes.isRight()) {
- log.error("Failed to retrieve graph. status is {}", graphRes);
- return Either.right(graphRes.right().value());
- }
-
- JanusGraph janusGraph = graphRes.left().value();
- @SuppressWarnings("unchecked")
- Iterable<JanusGraphVertex> vertices = janusGraph.query().has(key, uniqueId).vertices();
- if (vertices == null || !vertices.iterator().hasNext()) {
- return Either.right(JanusGraphOperationStatus.INVALID_ID);
- }
-
- Vertex rootVertex = vertices.iterator().next();
-
- Iterator<Edge> edgesCreatorIterator = rootVertex.edges(Direction.IN, edgeType.name());
- if (edgesCreatorIterator != null) {
- while (edgesCreatorIterator.hasNext()) {
- Edge edge = edgesCreatorIterator.next();
- Map<String, Object> edgeProps = getProperties(edge);
- GraphEdgeLabels edgeTypeFromGraph = GraphEdgeLabels.getByName(edge.label());
- graphEdge = new GraphEdge(edgeTypeFromGraph, edgeProps);
-
- Vertex outgoingVertex = edge.outVertex();
- Map<String, Object> properties = getProperties(outgoingVertex);
- data = GraphElementFactory.createElement(nodeTypeEnum.getName(), GraphElementTypeEnum.Node, properties, clazz);
-
- ImmutablePair<T, GraphEdge> immutablePair = new ImmutablePair<>(clazz.cast(data), graphEdge);
- immutablePairs.add(immutablePair);
- }
- }
-
- if (immutablePairs.isEmpty()) {
- return Either.right(JanusGraphOperationStatus.NOT_FOUND);
- }
-
- return Either.left(immutablePairs);
-
- }
-
- public <T extends GraphNode> Either<ImmutablePair<T, GraphEdge>, JanusGraphOperationStatus> getParentNode(String key, String uniqueId, GraphEdgeLabels edgeType, NodeTypeEnum nodeTypeEnum, Class<T> clazz) {
-
- Either<List<ImmutablePair<T, GraphEdge>>, JanusGraphOperationStatus> parentNodesRes = this.getParentNodes(key, uniqueId, edgeType, nodeTypeEnum, clazz);
-
- if (parentNodesRes.isRight()) {
- log.debug("failed to get edge key:{} uniqueId:{} edgeType {} nodeTypeEnum: {}, reason:{}", key, uniqueId, edgeType, nodeTypeEnum, parentNodesRes.right().value());
- return Either.right(parentNodesRes.right().value());
- }
-
- List<ImmutablePair<T, GraphEdge>> value = parentNodesRes.left().value();
-
- if (value.size() > 1) {
- return Either.right(JanusGraphOperationStatus.MULTIPLE_CHILDS_WITH_SAME_EDGE);
- }
-
- return Either.left(value.get(0));
- }
-
- public <T extends GraphNode> Either<ImmutablePair<T, GraphEdge>, JanusGraphOperationStatus> getChildByEdgeCriteria(String key, String uniqueId, GraphEdgeLabels edgeType, NodeTypeEnum nodeTypeEnum, Class<T> clazz, Map<String, Object> edgeProperties) {
-
- Either<Edge, JanusGraphOperationStatus> outgoingEdgeByCriteria = getOutgoingEdgeByCriteria(key, uniqueId, edgeType, edgeProperties);
- if (outgoingEdgeByCriteria.isRight()) {
- JanusGraphOperationStatus status = outgoingEdgeByCriteria.right().value();
- log.debug("Cannot find outgoing edge from vertex {} with label {} and properties {}" + uniqueId, edgeType, edgeProperties);
- return Either.right(status);
- }
-
- Edge edge = outgoingEdgeByCriteria.left().value();
- Map<String, Object> edgeProps = getProperties(edge);
- GraphEdgeLabels edgeTypeFromGraph = GraphEdgeLabels.getByName(edge.label());
- GraphEdge graphEdge = new GraphEdge(edgeTypeFromGraph, edgeProps);
-
- Vertex outgoingVertex = edge.inVertex();
- Map<String, Object> properties = getProperties(outgoingVertex);
- T data = GraphElementFactory.createElement(nodeTypeEnum.getName(), GraphElementTypeEnum.Node, properties, clazz);
-
- ImmutablePair<T, GraphEdge> immutablePair = new ImmutablePair<>(clazz.cast(data), graphEdge);
-
- return Either.left(immutablePair);
- }
-
- public Either<ImmutablePair<JanusGraphVertex, Edge>, JanusGraphOperationStatus> getChildByEdgeCriteria(JanusGraphVertex vertex, GraphEdgeLabels edgeType, Map<String, Object> edgeProperties) {
-
- Either<Edge, JanusGraphOperationStatus> outgoingEdgeByCriteria = getOutgoingEdgeByCriteria(vertex, edgeType, edgeProperties);
- if (outgoingEdgeByCriteria.isRight()) {
- JanusGraphOperationStatus status = outgoingEdgeByCriteria.right().value();
- log.debug("Cannot find outgoing edge from vertex {} with label {} and properties {}", vertex, edgeType, edgeProperties);
- return Either.right(status);
- }
- Edge edge = outgoingEdgeByCriteria.left().value();
-
- JanusGraphVertex outgoingVertex = (JanusGraphVertex) edge.inVertex();
-
- ImmutablePair<JanusGraphVertex, Edge> immutablePair = new ImmutablePair<>(outgoingVertex, edge);
-
- return Either.left(immutablePair);
- }
-
- public Either<Edge, JanusGraphOperationStatus> getOutgoingEdgeByCriteria(String key, String value, GraphEdgeLabels label, Map<String, Object> props) {
-
- Either<JanusGraphVertex, JanusGraphOperationStatus> vertexFrom = getVertexByProperty(key, value);
- if (vertexFrom.isRight()) {
- JanusGraphOperationStatus status = vertexFrom.right().value();
- if (status == JanusGraphOperationStatus.NOT_FOUND) {
- return Either.right(JanusGraphOperationStatus.INVALID_ID);
- }
- return Either.right(status);
- }
-
- return getOutgoingEdgeByCriteria(vertexFrom.left().value(), label, props);
- }
-
- public Either<Edge, JanusGraphOperationStatus> getOutgoingEdgeByCriteria(JanusGraphVertex vertex, GraphEdgeLabels label, Map<String, Object> props) {
-
- JanusGraphVertexQuery<?> query = vertex.query();
- query = query.direction(Direction.OUT).labels(label.getProperty());
+ return edge;
+ }
+
+ /**
+ * creates an identical edge in the graph
+ *
+ * @param edge
+ * @return the copy operation status
+ */
+ public Either<Edge, JanusGraphOperationStatus> copyEdge(Vertex out, Vertex in, Edge edge) {
+ GraphEdgeLabels byName = GraphEdgeLabels.getByName(edge.label());
+ return this.saveEdge(out, in, byName, edgePropertiesToMap(edge));
+ }
+
+ private <V> Map<String, Object> edgePropertiesToMap(Edge edge) {
+ Iterable<Property<Object>> propertiesIterable = edge::properties;
+ return StreamSupport.stream(propertiesIterable.spliterator(), false).collect(Collectors.toMap(Property::key, Property::value));
+ }
+
+ public Either<Edge, JanusGraphOperationStatus> saveEdge(Vertex vertexOut, Vertex vertexIn, GraphEdgeLabels type, Map<String, Object> properties) {
+ try {
+ Edge edge = addEdge(vertexOut, vertexIn, type, properties);
+ return Either.left(edge);
+ } catch (Exception e) {
+ log.debug("Failed to create edge from [{}] to [{}]", vertexOut, vertexIn, e);
+ return Either.right(janusGraphClient.handleJanusGraphException(e));
+ }
+ }
+
+ public JanusGraphOperationStatus createEdge(JanusGraphVertex vertexOut, GraphNode to, GraphEdgeLabels type, Map<String, Object> properties) {
+ JanusGraphVertex vertexIn;
+ Either<Vertex, JanusGraphOperationStatus> toV = getVertexByPropertyAndLabel(to.getUniqueIdKey(), to.getUniqueId(), to.getLabel());
+ if (toV.isRight()) {
+ JanusGraphOperationStatus error = toV.right().value();
+ if (JanusGraphOperationStatus.NOT_FOUND.equals(error)) {
+ return JanusGraphOperationStatus.INVALID_ID;
+ } else {
+ return error;
+ }
+ }
+ vertexIn = (JanusGraphVertex) toV.left().value();
+ return createEdge(vertexOut, vertexIn, type, properties);
+ }
+
+ /**
+ * @param from
+ * @param to
+ * @param label
+ * @param properties
+ * @return
+ */
+ public Either<GraphRelation, JanusGraphOperationStatus> createRelation(GraphNode from, GraphNode to, GraphEdgeLabels label,
+ Map<String, Object> properties) {
+ log.debug("try to create relation from [{}] to [{}]", from.getKeyValueId(), to.getKeyValueId());
+ return createEdge(label.getProperty(), from.getKeyValueId(), to.getKeyValueId(), from.getLabel(), to.getLabel(), properties);
+ }
+
+ public Either<GraphRelation, JanusGraphOperationStatus> replaceRelationLabel(GraphNode from, GraphNode to, GraphEdgeLabels label,
+ GraphEdgeLabels newLabel) {
+ log.debug("try to replace relation {} to {} from [{}] to [{}]", label.name(), newLabel.name(), from.getKeyValueId(), to.getKeyValueId());
+ Either<GraphRelation, JanusGraphOperationStatus> getRelationResult = getRelation(from, to, label);
+ if (getRelationResult.isRight()) {
+ return getRelationResult;
+ }
+ GraphRelation origRelation = getRelationResult.left().value();
+ Either<GraphRelation, JanusGraphOperationStatus> createRelationResult = createRelation(from, to, newLabel, origRelation.toGraphMap());
+ if (createRelationResult.isRight()) {
+ return createRelationResult;
+ }
+ Either<GraphRelation, JanusGraphOperationStatus> deleteRelationResult = deleteRelation(origRelation);
+ if (deleteRelationResult.isRight()) {
+ return deleteRelationResult;
+ }
+ return Either.left(createRelationResult.left().value());
+ }
+
+ /**
+ * @param keyName
+ * @param keyValue
+ * @param clazz
+ * @return
+ */
+ public <T extends GraphNode> Either<T, JanusGraphOperationStatus> getNode(String keyName, Object keyValue, Class<T> clazz) {
+ log.debug("Try to get node for key [{}] with value [{}] ", keyName, keyValue);
+ Either<JanusGraphVertex, JanusGraphOperationStatus> vertexByProperty = getVertexByProperty(keyName, keyValue);
+ if (vertexByProperty.isLeft()) {
+ try {
+ Vertex vertex = vertexByProperty.left().value();
+ Map<String, Object> properties = getProperties(vertex);
+ T node = GraphElementFactory
+ .createElement((String) properties.get(GraphPropertiesDictionary.LABEL.getProperty()), GraphElementTypeEnum.Node, properties,
+ clazz);
+ return Either.left(node);
+ } catch (Exception e) {
+ log.debug("Failed to get node for key [{}] with value [{}] ", keyName, keyValue, e);
+ return Either.right(JanusGraphClient.handleJanusGraphException(e));
+ }
+ } else {
+ log.debug("Failed to get node for key [{}] with value [{}] ", keyName, keyValue, vertexByProperty.right().value());
+ return Either.right(vertexByProperty.right().value());
+ }
+ }
+
+ /**
+ * @param from
+ * @param to
+ * @param label
+ * @return
+ */
+ public Either<GraphRelation, JanusGraphOperationStatus> getRelation(GraphNode from, GraphNode to, GraphEdgeLabels label) {
+ log.debug("try to get relation from [{}] to [{}]", from.getKeyValueId(), to.getKeyValueId());
+ Either<Edge, JanusGraphOperationStatus> edge = getEdgeByNodes(from, to, label);
+ if (edge.isLeft()) {
+ try {
+ Map<String, Object> properties = getProperties(edge.left().value());
+ GraphRelation relation = GraphElementFactory.createRelation(label.getProperty(), properties, from, to);
+ return Either.left(relation);
+ } catch (Exception e) {
+ log.debug("Failed to get get relation from [{}] to [{}]", from.getKeyValueId(), to.getKeyValueId(), e);
+ return Either.right(JanusGraphClient.handleJanusGraphException(e));
+ }
+ } else {
+ log.debug("Failed to get get relation from [{}] to [{}] {}", from.getKeyValueId(), to.getKeyValueId(), edge.right().value());
+ return Either.right(edge.right().value());
+ }
+ }
+
+ public Either<Edge, JanusGraphOperationStatus> getEdgeByNodes(GraphNode from, GraphNode to, GraphEdgeLabels label) {
+ ImmutablePair<String, Object> keyValueIdFrom = from.getKeyValueId();
+ ImmutablePair<String, Object> keyValueIdTo = to.getKeyValueId();
+ return getEdgeByVerticies(keyValueIdFrom.getKey(), keyValueIdFrom.getValue(), keyValueIdTo.getKey(), keyValueIdTo.getValue(),
+ label.getProperty());
+ }
+
+ public Either<GraphRelation, JanusGraphOperationStatus> deleteIncomingRelationByCriteria(GraphNode to, GraphEdgeLabels label,
+ Map<String, Object> props) {
+ Either<Edge, JanusGraphOperationStatus> edgeByCriteria = getIncomingEdgeByCriteria(to, label, props);
+ if (edgeByCriteria.isLeft()) {
+ Either<JanusGraph, JanusGraphOperationStatus> graph = getGraph();
+ if (graph.isLeft()) {
+ Edge edge = edgeByCriteria.left().value();
+ log.debug("delete edge {} to {} ", label.getProperty(), to.getUniqueId());
+ edge.remove();
+ Map<String, Object> properties = getProperties(edge);
+ Vertex fromVertex = edge.outVertex();
+ String fromLabel = fromVertex.value(GraphPropertiesDictionary.LABEL.getProperty());
+ GraphNode nodeFrom = GraphElementFactory
+ .createElement(fromLabel, GraphElementTypeEnum.Node, getProperties(fromVertex), GraphNode.class);
+ GraphRelation relation = GraphElementFactory.createRelation(label.getProperty(), properties, nodeFrom, to);
+ return Either.left(relation);
+ } else {
+ log.debug("failed to get graph");
+ return Either.right(graph.right().value());
+ }
+ } else {
+ log.debug("failed to find edge {} to {}", label.getProperty(), to.getUniqueId());
+ return Either.right(edgeByCriteria.right().value());
+ }
+ }
+
+ public Either<GraphRelation, JanusGraphOperationStatus> getIncomingRelationByCriteria(GraphNode to, GraphEdgeLabels label,
+ Map<String, Object> props) {
+ Either<Edge, JanusGraphOperationStatus> edgeByCriteria = getIncomingEdgeByCriteria(to, label, props);
+ if (edgeByCriteria.isLeft()) {
+ Either<JanusGraph, JanusGraphOperationStatus> graph = getGraph();
+ if (graph.isLeft()) {
+ Edge edge = edgeByCriteria.left().value();
+ Map<String, Object> properties = getProperties(edge);
+ Vertex fromVertex = edge.outVertex();
+ String fromLabel = fromVertex.value(GraphPropertiesDictionary.LABEL.getProperty());
+ GraphNode nodeFrom = GraphElementFactory
+ .createElement(fromLabel, GraphElementTypeEnum.Node, getProperties(fromVertex), GraphNode.class);
+ GraphRelation relation = GraphElementFactory.createRelation(label.getProperty(), properties, nodeFrom, to);
+ return Either.left(relation);
+ } else {
+ log.debug("failed to get graph");
+ return Either.right(graph.right().value());
+ }
+ } else {
+ log.debug("failed to find edge {} to {}", label.getProperty(), to.getUniqueId());
+ return Either.right(edgeByCriteria.right().value());
+ }
+ }
- if (props != null && !props.isEmpty()) {
- for (Map.Entry<String, Object> entry : props.entrySet()) {
- query = query.has(entry.getKey(), entry.getValue());
- }
- }
- Edge matchingEdge = null;
- Iterable<JanusGraphEdge> edges = query.edges();
- if (edges == null) {
- log.debug("No edges in graph for criteria");
- return Either.right(JanusGraphOperationStatus.NOT_FOUND);
- }
- Iterator<JanusGraphEdge> eIter = edges.iterator();
- if (eIter.hasNext()) {
+ public Either<Edge, JanusGraphOperationStatus> getIncomingEdgeByCriteria(GraphNode to, GraphEdgeLabels label, Map<String, Object> props) {
+ ImmutablePair<String, Object> keyValueIdTo = to.getKeyValueId();
+ Either<JanusGraphVertex, JanusGraphOperationStatus> vertexFrom = getVertexByProperty(keyValueIdTo.getKey(), keyValueIdTo.getValue());
+ if (vertexFrom.isRight()) {
+ return Either.right(vertexFrom.right().value());
+ }
+ Vertex vertex = vertexFrom.left().value();
+ JanusGraphVertex janusGraphVertex = (JanusGraphVertex) vertex;
+ JanusGraphVertexQuery<?> query = janusGraphVertex.query();
+ query = query.labels(label.getProperty());
+ if (props != null && !props.isEmpty()) {
+ for (Map.Entry<String, Object> entry : props.entrySet()) {
+ query = query.has(entry.getKey(), entry.getValue());
+ }
+ }
+ Edge matchingEdge = null;
+ Iterable<JanusGraphEdge> edges = query.edges();
+ if (edges == null) {
+ log.debug("No edges in graph for criteria");
+ return Either.right(JanusGraphOperationStatus.NOT_FOUND);
+ }
+ Iterator<JanusGraphEdge> eIter = edges.iterator();
+ if (eIter.hasNext()) {
matchingEdge = eIter.next();
- }
-
- if (matchingEdge == null) {
- log.debug("No edges in graph for criteria");
- return Either.right(JanusGraphOperationStatus.NOT_FOUND);
- }
- return Either.left(matchingEdge);
- }
-
- public <T extends GraphNode> Either<List<ImmutablePair<T, GraphEdge>>, JanusGraphOperationStatus> deleteChildrenNodes(String key, String uniqueId, GraphEdgeLabels edgeType, NodeTypeEnum nodeTypeEnum, Class<T> clazz) {
-
- List<ImmutablePair<T, GraphEdge>> result = new ArrayList<>();
-
- Either<List<ImmutablePair<T, GraphEdge>>, JanusGraphOperationStatus> childrenNodesRes = getChildrenNodes(key, uniqueId, edgeType, nodeTypeEnum, clazz);
-
- if (childrenNodesRes.isRight()) {
- JanusGraphOperationStatus status = childrenNodesRes.right().value();
- return Either.right(status);
- }
-
- List<ImmutablePair<T, GraphEdge>> list = childrenNodesRes.left().value();
- for (ImmutablePair<T, GraphEdge> pair : list) {
- T node = pair.getKey();
- Either<T, JanusGraphOperationStatus> deleteNodeRes = this.deleteNode(node, clazz);
- if (deleteNodeRes.isRight()) {
- JanusGraphOperationStatus status = deleteNodeRes.right().value();
- log.error("Failed to delete node {} . status is {}", node, status);
- return Either.right(status);
- }
- ImmutablePair<T, GraphEdge> deletedPair = new ImmutablePair<>(node, pair.getValue());
- result.add(deletedPair);
- }
-
- return Either.left(result);
-
- }
-
- public void setProperties(Element element, Map<String, Object> properties) {
-
- if (properties != null && !properties.isEmpty()) {
-
- Object[] propertyKeyValues = new Object[properties.size() * 2];
- int i = 0;
- for (Entry<String, Object> entry : properties.entrySet()) {
- propertyKeyValues[i++] = entry.getKey();
- propertyKeyValues[i++] = entry.getValue();
- }
-
- ElementHelper.attachProperties(element, propertyKeyValues);
-
- }
-
- }
-
- public Map<String, Object> getProperties(Element element) {
-
- Map<String, Object> result = new HashMap<>();
-
- if (element != null && element.keys() != null && element.keys().size() > 0) {
- Map<String, Property> propertyMap = ElementHelper.propertyMap(element, element.keys().toArray(new String[element.keys().size()]));
-
- for (Entry<String, Property> entry : propertyMap.entrySet()) {
- String key = entry.getKey();
- Object value = entry.getValue().value();
-
- result.put(key, value);
- }
- }
- return result;
- }
+ }
+ if (matchingEdge == null) {
+ log.debug("No edges in graph for criteria");
+ return Either.right(JanusGraphOperationStatus.NOT_FOUND);
+ }
+ return Either.left(matchingEdge);
+ }
+
+ public Either<Edge, JanusGraphOperationStatus> getEdgeByVerticies(String keyNameFrom, Object keyValueFrom, String keyNameTo, Object keyValueTo,
+ String label) {
+ Either<JanusGraph, JanusGraphOperationStatus> graph = janusGraphClient.getGraph();
+ if (graph.isLeft()) {
+ try {
+ Either<JanusGraphVertex, JanusGraphOperationStatus> vertexFrom = getVertexByProperty(keyNameFrom, keyValueFrom);
+ if (vertexFrom.isRight()) {
+ return Either.right(vertexFrom.right().value());
+ }
+ Iterable<JanusGraphEdge> edges = ((JanusGraphVertex) vertexFrom.left().value()).query().labels(label).edges();
+ Iterator<JanusGraphEdge> eIter = edges.iterator();
+ while (eIter.hasNext()) {
+ Edge edge = eIter.next();
+ Vertex vertexIn = edge.inVertex();
+ if (vertexIn.value(keyNameTo) != null && vertexIn.value(keyNameTo).equals(keyValueTo) && label.equals(edge.label())) {
+ return Either.left(edge);
+ }
+ }
+ log.debug("No relation in graph from [{}={}] to [{}={}]", keyNameFrom, keyValueFrom, keyNameTo, keyValueTo);
+ return Either.right(JanusGraphOperationStatus.NOT_FOUND);
+ } catch (Exception e) {
+ log.debug("Failed to get get relation from [{}={}] to [{}={}]", keyNameFrom, keyValueFrom, keyNameTo, keyValueTo, e);
+ return Either.right(JanusGraphClient.handleJanusGraphException(e));
+ }
+ } else {
+ return Either.right(graph.right().value());
+ }
+ }
+
+ public Either<List<Edge>, JanusGraphOperationStatus> getEdgesForNode(GraphNode node, Direction requestedDirection) {
+ Either<List<Edge>, JanusGraphOperationStatus> result;
+ ImmutablePair<String, Object> keyValueId = node.getKeyValueId();
+ Either<JanusGraphVertex, JanusGraphOperationStatus> eitherVertex = getVertexByProperty(keyValueId.getKey(), keyValueId.getValue());
+ if (eitherVertex.isLeft()) {
+ List<Edge> edges = prepareEdgesList(eitherVertex.left().value(), requestedDirection);
+ result = Either.left(edges);
+ } else {
+ result = Either.right(eitherVertex.right().value());
+ }
+ return result;
+ }
+
+ private List<Edge> prepareEdgesList(Vertex vertex, Direction requestedDirection) {
+ List<Edge> edges = new ArrayList<>();
+ Iterator<JanusGraphEdge> edgesItr = ((JanusGraphVertex) vertex).query().edges().iterator();
+ while (edgesItr.hasNext()) {
+ Edge edge = edgesItr.next();
+ Direction currEdgeDirection = getEdgeDirection(vertex, edge);
+ if (currEdgeDirection == requestedDirection || requestedDirection == Direction.BOTH) {
+ edges.add(edge);
+ }
+ }
+ return edges;
+ }
+
+ private Direction getEdgeDirection(Vertex vertex, Edge edge) {
+ Direction result;
+ Vertex vertexOut = edge.outVertex();
+ if (vertexOut.equals(vertex)) {
+ result = Direction.OUT;
+ } else {
+ result = Direction.IN;
+ }
+ return result;
+ }
+
+ /**
+ * @param from
+ * @param to
+ * @param label
+ * @param properties
+ * @return
+ */
+ public Either<GraphRelation, JanusGraphOperationStatus> updateRelation(GraphNode from, GraphNode to, GraphEdgeLabels label,
+ Map<String, Object> properties) {
+ log.debug("try to update relation from [{}] to [{}]", from.getKeyValueId(), to.getKeyValueId());
+ return updateEdge(label.getProperty(), from.getKeyValueId(), to.getKeyValueId(), from.getLabel(), to.getLabel(), properties);
+ }
+
+ private Either<GraphRelation, JanusGraphOperationStatus> updateEdge(String type, ImmutablePair<String, Object> from,
+ ImmutablePair<String, Object> to, String fromLabel, String toLabel,
+ Map<String, Object> properties) {
+ Either<Edge, JanusGraphOperationStatus> edgeS = getEdgeByVerticies(from.getKey(), from.getValue(), to.getKey(), to.getValue(), type);
+ if (edgeS.isLeft()) {
+ try {
+ Edge edge = edgeS.left().value();
+ if (properties != null) {
+ setProperties(edge, properties);
+ }
+ Vertex vertexOut = edge.outVertex();
+ Vertex vertexIn = edge.inVertex();
+ GraphNode nodeOut = GraphElementFactory
+ .createElement(fromLabel, GraphElementTypeEnum.Node, getProperties(vertexOut), GraphNode.class);
+ GraphNode nodeIn = GraphElementFactory.createElement(toLabel, GraphElementTypeEnum.Node, getProperties(vertexIn), GraphNode.class);
+ GraphRelation newRelation = GraphElementFactory.createRelation(edge.label(), getProperties(edge), nodeOut, nodeIn);
+ if (log.isDebugEnabled()) {
+ log.debug("Relation was updated from [{}] to [{}] ", from, to);
+ }
+ return Either.left(newRelation);
+ } catch (Exception e) {
+ if (log.isDebugEnabled()) {
+ log.debug("Failed to update relation from [{}] to [{}] ", from, to, e);
+ }
+ return Either.right(JanusGraphClient.handleJanusGraphException(e));
+ }
+ } else {
+ if (log.isDebugEnabled()) {
+ log.debug("Failed to update relation from [{}] to [{}] {}", from, to, edgeS.right().value());
+ }
+ return Either.right(edgeS.right().value());
+ }
+ }
+
+ /**
+ * @param relation
+ * @return
+ */
+ public Either<GraphRelation, JanusGraphOperationStatus> updateRelation(GraphRelation relation) {
+ log.debug("try to update relation from [{}] to [{}]", relation.getFrom(), relation.getTo());
+ RelationEndPoint from = relation.getFrom();
+ RelationEndPoint to = relation.getTo();
+ ImmutablePair<String, Object> fromKeyId = new ImmutablePair<>(from.getIdName(), from.getIdValue());
+ ImmutablePair<String, Object> toKeyId = new ImmutablePair<>(to.getIdName(), to.getIdValue());
+ return updateEdge(relation.getType(), fromKeyId, toKeyId, from.getLabel().getName(), to.getLabel().getName(), relation.toGraphMap());
+ }
+
+ private Either<Vertex, JanusGraphOperationStatus> getVertexByPropertyAndLabel(String name, Object value, String label) {
+ Either<JanusGraph, JanusGraphOperationStatus> graph = janusGraphClient.getGraph();
+ if (graph.isLeft()) {
+ try {
+ JanusGraph tGraph = graph.left().value();
+ @SuppressWarnings("unchecked") Iterable<JanusGraphVertex> vertecies = tGraph.query().has(name, value)
+ .has(GraphPropertiesDictionary.LABEL.getProperty(), label).vertices();
+ java.util.Iterator<JanusGraphVertex> iterator = vertecies.iterator();
+ if (iterator.hasNext()) {
+ Vertex vertex = iterator.next();
+ return Either.left(vertex);
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("No vertex in graph for key =" + name + " and value = " + value + " label = " + label);
+ }
+ return Either.right(JanusGraphOperationStatus.NOT_FOUND);
+ } catch (Exception e) {
+ if (log.isDebugEnabled()) {
+ log.debug("Failed to get vertex in graph for key ={} and value = {} label = {}", name, value, label);
+ }
+ return Either.right(JanusGraphClient.handleJanusGraphException(e));
+ }
+ } else {
+ if (log.isDebugEnabled()) {
+ log.debug("No vertex in graph for key ={} and value = {} label = {} error : {}", name, value, label, graph.right().value());
+ }
+ return Either.right(graph.right().value());
+ }
+ }
+
+ public Either<JanusGraphVertex, JanusGraphOperationStatus> getVertexByProperty(String name, Object value) {
+ Either<JanusGraph, JanusGraphOperationStatus> graph = janusGraphClient.getGraph();
+ if (value == null) {
+ if (log.isDebugEnabled()) {
+ log.debug("No vertex in graph for key = {} and value = {}", name, value);
+ }
+ return Either.right(JanusGraphOperationStatus.NOT_FOUND);
+ }
+ if (graph.isLeft()) {
+ try {
+ JanusGraph tGraph = graph.left().value();
+ @SuppressWarnings("unchecked") Iterable<JanusGraphVertex> vertecies = tGraph.query().has(name, value).vertices();
+ java.util.Iterator<JanusGraphVertex> iterator = vertecies.iterator();
+ if (iterator.hasNext()) {
+ JanusGraphVertex vertex = iterator.next();
+ return Either.left(vertex);
+ } else {
+ if (log.isDebugEnabled()) {
+ log.debug("No vertex in graph for key ={} and value = {}", name, value);
+ }
+ return Either.right(JanusGraphOperationStatus.NOT_FOUND);
+ }
+ } catch (Exception e) {
+ if (log.isDebugEnabled()) {
+ log.debug("Failed to get vertex in graph for key = {} and value = ", name, value);
+ }
+ return Either.right(JanusGraphClient.handleJanusGraphException(e));
+ }
+ } else {
+ if (log.isDebugEnabled()) {
+ log.debug("No vertex in graph for key = {} and value = {} error : {}", name, value, graph.right().value());
+ }
+ return Either.right(graph.right().value());
+ }
+ }
+
+ public <T extends GraphNode> Either<List<T>, JanusGraphOperationStatus> getByCriteria(NodeTypeEnum type, Map<String, Object> hasProps,
+ Map<String, Object> hasNotProps, Class<T> clazz) {
+ Either<JanusGraph, JanusGraphOperationStatus> graph = janusGraphClient.getGraph();
+ if (graph.isLeft()) {
+ try {
+ JanusGraph tGraph = graph.left().value();
+ JanusGraphQuery<? extends JanusGraphQuery> query = tGraph.query();
+ query = query.has(GraphPropertiesDictionary.LABEL.getProperty(), type.getName());
+ if (hasProps != null && !hasProps.isEmpty()) {
+ for (Map.Entry<String, Object> entry : hasProps.entrySet()) {
+ query = query.has(entry.getKey(), entry.getValue());
+ }
+ }
+ if (hasNotProps != null && !hasNotProps.isEmpty()) {
+ for (Map.Entry<String, Object> entry : hasNotProps.entrySet()) {
+ query = query.hasNot(entry.getKey(), entry.getValue());
+ }
+ }
+ Iterable<JanusGraphVertex> vertices = query.vertices();
+ if (vertices == null) {
+ return Either.right(JanusGraphOperationStatus.NOT_FOUND);
+ }
+ Iterator<JanusGraphVertex> iterator = vertices.iterator();
+ List<T> result = new ArrayList<>();
+ while (iterator.hasNext()) {
+ Vertex vertex = iterator.next();
+ Map<String, Object> newProp = getProperties(vertex);
+ T element = GraphElementFactory.createElement(type.getName(), GraphElementTypeEnum.Node, newProp, clazz);
+ result.add(element);
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("Number of fetced nodes in graph for criteria : from type = {} and properties has = {}, properties hasNot = {} is {}",
+ type, hasProps, hasNotProps, result.size());
+ }
+ if (result.size() == 0) {
+ return Either.right(JanusGraphOperationStatus.NOT_FOUND);
+ }
+ return Either.left(result);
+ } catch (Exception e) {
+ if (log.isDebugEnabled()) {
+ log.debug("Failed get by criteria for type = {}", type, e);
+ }
+ return Either.right(JanusGraphClient.handleJanusGraphException(e));
+ }
+ } else {
+ if (log.isDebugEnabled()) {
+ log.debug("Failed get by criteria for type ={} error : {}", type, graph.right().value());
+ }
+ return Either.right(graph.right().value());
+ }
+ }
+
+ public <T extends GraphNode> Either<List<T>, JanusGraphOperationStatus> getByCriteria(NodeTypeEnum type, Class<T> clazz,
+ List<ImmutableTriple<QueryType, String, Object>> props) {
+ Either<JanusGraph, JanusGraphOperationStatus> graph = janusGraphClient.getGraph();
+ if (graph.isLeft()) {
+ try {
+ JanusGraph tGraph = graph.left().value();
+ JanusGraphQuery<? extends JanusGraphQuery> query = tGraph.query();
+ query = query.has(GraphPropertiesDictionary.LABEL.getProperty(), type.getName());
+ for (ImmutableTriple<QueryType, String, Object> prop : props) {
+ if (QueryType.HAS.equals(prop.getLeft())) {
+ query = query.has(prop.getMiddle(), prop.getRight());
+ } else {
+ query = query.hasNot(prop.getMiddle(), prop.getRight());
+ }
+ }
+ Iterable<JanusGraphVertex> vertices = query.vertices();
+ if (vertices == null) {
+ return Either.right(JanusGraphOperationStatus.NOT_FOUND);
+ }
+ Iterator<JanusGraphVertex> iterator = vertices.iterator();
+ List<T> result = new ArrayList<>();
+ while (iterator.hasNext()) {
+ Vertex vertex = iterator.next();
+ Map<String, Object> newProp = getProperties(vertex);
+ T element = GraphElementFactory.createElement(type.getName(), GraphElementTypeEnum.Node, newProp, clazz);
+ result.add(element);
+ }
+ if (result.size() == 0) {
+ return Either.right(JanusGraphOperationStatus.NOT_FOUND);
+ }
+ return Either.left(result);
+ } catch (Exception e) {
+ if (log.isDebugEnabled()) {
+ log.debug("Failed get by criteria for type = {}", type, e);
+ }
+ return Either.right(JanusGraphClient.handleJanusGraphException(e));
+ }
+ } else {
+ if (log.isDebugEnabled()) {
+ log.debug("Failed get by criteria for type ={} error : {}", type, graph.right().value());
+ }
+ return Either.right(graph.right().value());
+ }
+ }
+
+ public <T extends GraphNode> Either<List<T>, JanusGraphOperationStatus> getByCriteria(NodeTypeEnum type, Map<String, Object> props,
+ Class<T> clazz) {
+ Either<JanusGraph, JanusGraphOperationStatus> graph = janusGraphClient.getGraph();
+ if (graph.isLeft()) {
+ try {
+ JanusGraph tGraph = graph.left().value();
+ JanusGraphQuery<? extends JanusGraphQuery> query = tGraph.query();
+ query = query.has(GraphPropertiesDictionary.LABEL.getProperty(), type.getName());
+ if (props != null && !props.isEmpty()) {
+ for (Map.Entry<String, Object> entry : props.entrySet()) {
+ query = query.has(entry.getKey(), entry.getValue());
+ }
+ }
+ Iterable<JanusGraphVertex> vertices = query.vertices();
+ if (vertices == null) {
+ return Either.right(JanusGraphOperationStatus.NOT_FOUND);
+ }
+ Iterator<JanusGraphVertex> iterator = vertices.iterator();
+ List<T> result = new ArrayList<>();
+ while (iterator.hasNext()) {
+ Vertex vertex = iterator.next();
+ Map<String, Object> newProp = getProperties(vertex);
+ T element = GraphElementFactory.createElement(type.getName(), GraphElementTypeEnum.Node, newProp, clazz);
+ result.add(element);
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("Number of fetced nodes in graph for criteria : from type = {} and properties = {} is {}", type, props, result.size());
+ }
+ if (result.size() == 0) {
+ return Either.right(JanusGraphOperationStatus.NOT_FOUND);
+ }
+ return Either.left(result);
+ } catch (Exception e) {
+ if (log.isDebugEnabled()) {
+ log.debug("Failed get by criteria for type = {} and properties = {}", type, props, e);
+ }
+ return Either.right(JanusGraphClient.handleJanusGraphException(e));
+ }
+ } else {
+ if (log.isDebugEnabled()) {
+ log.debug("Failed get by criteria for type ={} and properties = {} error : {}", type, props, graph.right().value());
+ }
+ return Either.right(graph.right().value());
+ }
+ }
+
+ public <T extends GraphNode> Either<List<T>, JanusGraphOperationStatus> getByCriteriaWithPredicate(NodeTypeEnum type,
+ Map<String, Entry<JanusGraphPredicate, Object>> props,
+ Class<T> clazz) {
+ Either<JanusGraph, JanusGraphOperationStatus> graph = janusGraphClient.getGraph();
+ if (graph.isLeft()) {
+ try {
+ JanusGraph tGraph = graph.left().value();
+ JanusGraphQuery<? extends JanusGraphQuery> query = tGraph.query();
+ query = query.has(GraphPropertiesDictionary.LABEL.getProperty(), type.getName());
+ if (props != null && !props.isEmpty()) {
+ JanusGraphPredicate predicate = null;
+ Object object = null;
+ for (Map.Entry<String, Entry<JanusGraphPredicate, Object>> entry : props.entrySet()) {
+ predicate = entry.getValue().getKey();
+ object = entry.getValue().getValue();
+ query = query.has(entry.getKey(), predicate, object);
+ }
+ }
+ Iterable<JanusGraphVertex> vertices = query.vertices();
+ if (vertices == null) {
+ return Either.right(JanusGraphOperationStatus.NOT_FOUND);
+ }
+ Iterator<JanusGraphVertex> iterator = vertices.iterator();
+ List<T> result = new ArrayList<>();
+ while (iterator.hasNext()) {
+ Vertex vertex = iterator.next();
+ Map<String, Object> newProp = getProperties(vertex);
+ T element = GraphElementFactory.createElement(type.getName(), GraphElementTypeEnum.Node, newProp, clazz);
+ result.add(element);
+ }
+ if (result.size() == 0) {
+ return Either.right(JanusGraphOperationStatus.NOT_FOUND);
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("No nodes in graph for criteria : from type = {} and properties = {}", type, props);
+ }
+ return Either.left(result);
+ } catch (Exception e) {
+ if (log.isDebugEnabled()) {
+ log.debug("Failed get by criteria for type = {} and properties = {}", type, props, e);
+ }
+ return Either.right(JanusGraphClient.handleJanusGraphException(e));
+ }
+ } else {
+ if (log.isDebugEnabled()) {
+ log.debug("Failed get by criteria for type = {} and properties = {} error : {}", type, props, graph.right().value());
+ }
+ return Either.right(graph.right().value());
+ }
+ }
+
+ public <T extends GraphNode> Either<List<T>, JanusGraphOperationStatus> getAll(NodeTypeEnum type, Class<T> clazz) {
+ return getByCriteria(type, null, clazz);
+ }
+
+ /**
+ * @param node
+ * @param clazz
+ * @return
+ */
+ public <T extends GraphNode> Either<T, JanusGraphOperationStatus> updateNode(GraphNode node, Class<T> clazz) {
+ log.debug("Try to update node for {}", node.getKeyValueIdForLog());
+ ImmutablePair<String, Object> keyValueId = node.getKeyValueId();
+ Either<Vertex, JanusGraphOperationStatus> vertexByProperty = getVertexByPropertyAndLabel(keyValueId.getKey(), keyValueId.getValue(),
+ node.getLabel());
+ if (vertexByProperty.isLeft()) {
+ try {
+ Vertex vertex = vertexByProperty.left().value();
+ Map<String, Object> mapProps = node.toGraphMap();
+ for (Map.Entry<String, Object> entry : mapProps.entrySet()) {
+ if (!entry.getKey().equals(node.getUniqueIdKey())) {
+ vertex.property(entry.getKey(), entry.getValue());
+ }
+ }
+ Either<Vertex, JanusGraphOperationStatus> vertexByPropertyAndLabel = getVertexByPropertyAndLabel(keyValueId.getKey(),
+ keyValueId.getValue(), node.getLabel());
+ if (vertexByPropertyAndLabel.isRight()) {
+ return Either.right(vertexByPropertyAndLabel.right().value());
+ } else {
+ Map<String, Object> newProp = getProperties(vertexByPropertyAndLabel.left().value());
+ T updateNode = GraphElementFactory.createElement(node.getLabel(), GraphElementTypeEnum.Node, newProp, clazz);
+ return Either.left(updateNode);
+ }
+ } catch (Exception e) {
+ if (log.isDebugEnabled()) {
+ log.debug("Failed to update node for {}", node.getKeyValueId(), e);
+ }
+ return Either.right(JanusGraphClient.handleJanusGraphException(e));
+ }
+ } else {
+ if (log.isDebugEnabled()) {
+ log.debug("Failed to update node for {} error :{}", node.getKeyValueIdForLog(), vertexByProperty.right().value());
+ }
+ return Either.right(vertexByProperty.right().value());
+ }
+ }
+
+ public JanusGraphOperationStatus updateVertex(GraphNode node, Vertex vertex) {
+ log.debug("Try to update node for {}", node.getKeyValueId());
+ try {
+ Map<String, Object> mapProps = node.toGraphMap();
+ for (Map.Entry<String, Object> entry : mapProps.entrySet()) {
+ if (!entry.getKey().equals(node.getUniqueIdKey())) {
+ vertex.property(entry.getKey(), entry.getValue());
+ }
+ }
+ } catch (Exception e) {
+ if (log.isDebugEnabled()) {
+ log.debug("Failed to update node for {}", node.getKeyValueId(), e);
+ }
+ return JanusGraphClient.handleJanusGraphException(e);
+ }
+ return JanusGraphOperationStatus.OK;
+ }
+
+ /**
+ * @param node
+ * @param clazz
+ * @return
+ */
+ public <T extends GraphNode> Either<T, JanusGraphOperationStatus> deleteNode(GraphNode node, Class<T> clazz) {
+ log.debug("Try to delete node for {}", node.getKeyValueId());
+ ImmutablePair<String, Object> keyValueId = node.getKeyValueId();
+ return deleteNode(keyValueId.getKey(), keyValueId.getValue(), clazz);
+ }
+
+ /**
+ * @param keyName
+ * @param keyValue
+ * @param clazz
+ * @return
+ */
+ public <T extends GraphNode> Either<T, JanusGraphOperationStatus> deleteNode(String keyName, Object keyValue, Class<T> clazz) {
+ Either<JanusGraphVertex, JanusGraphOperationStatus> vertexByProperty = getVertexByProperty(keyName, keyValue);
+ if (vertexByProperty.isLeft()) {
+ try {
+ Vertex vertex = vertexByProperty.left().value();
+ Map<String, Object> properties = getProperties(vertex);
+ if (properties != null) {
+ String label = (String) properties.get(GraphPropertiesDictionary.LABEL.getProperty());
+ T node = GraphElementFactory.createElement(label, GraphElementTypeEnum.Node, properties, clazz);
+ if (node != null) {
+ Either<JanusGraph, JanusGraphOperationStatus> graph = janusGraphClient.getGraph();
+ if (graph.isLeft()) {
+ JanusGraph tGraph = graph.left().value();
+ vertex.remove();
+ } else {
+ return Either.right(graph.right().value());
+ }
+ return Either.left(node);
+ } else {
+ if (log.isDebugEnabled()) {
+ log.debug("Failed to delete node for {} = {} Missing label property on node", keyName, keyValue);
+ }
+ return Either.right(JanusGraphOperationStatus.MISSING_NODE_LABEL);
+ }
+ } else {
+ if (log.isDebugEnabled()) {
+ log.debug("Failed to delete node for {} = {} Missing label property on node", keyName, keyValue);
+ }
+ return Either.right(JanusGraphOperationStatus.MISSING_NODE_LABEL);
+ }
+ } catch (Exception e) {
+ if (log.isDebugEnabled()) {
+ log.debug("Failed to delete node for {} = {}", keyName, keyValue, e);
+ }
+ return Either.right(JanusGraphClient.handleJanusGraphException(e));
+ }
+ } else {
+ return Either.right(vertexByProperty.right().value());
+ }
+ }
+
+ public Either<GraphRelation, JanusGraphOperationStatus> deleteRelation(GraphRelation relation) {
+ log.debug("try to delete relation from [{}] to [{}]", relation.getFrom(), relation.getTo());
+ RelationEndPoint from = relation.getFrom();
+ RelationEndPoint to = relation.getTo();
+ ImmutablePair<String, Object> fromKeyId = new ImmutablePair<>(from.getIdName(), from.getIdValue());
+ ImmutablePair<String, Object> toKeyId = new ImmutablePair<>(to.getIdName(), to.getIdValue());
+ return deleteEdge(relation.getType(), fromKeyId, toKeyId, from.getLabel().getName(), to.getLabel().getName());
+ }
+
+ public Either<Boolean, JanusGraphOperationStatus> isRelationExist(GraphNode from, GraphNode to, GraphEdgeLabels edgeLabel) {
+ return getEdgeByNodes(from, to, edgeLabel).left().map(edge -> true).right()
+ .bind(err -> err == JanusGraphOperationStatus.NOT_FOUND ? Either.left(false) : Either.right(err));
+ }
+
+ public Either<GraphRelation, JanusGraphOperationStatus> deleteRelation(GraphNode from, GraphNode to, GraphEdgeLabels label) {
+ log.debug("try to delete relation from [{}] to [{}]", from.getKeyValueId(), to.getKeyValueId());
+ return deleteEdge(label.getProperty(), from.getKeyValueId(), to.getKeyValueId(), from.getLabel(), to.getLabel());
+ }
+
+ private Either<GraphRelation, JanusGraphOperationStatus> deleteEdge(String type, ImmutablePair<String, Object> fromKeyId,
+ ImmutablePair<String, Object> toKeyId, String fromLabel, String toLabel) {
+ Either<Edge, JanusGraphOperationStatus> edgeS = getEdgeByVerticies(fromKeyId.getKey(), fromKeyId.getValue(), toKeyId.getKey(),
+ toKeyId.getValue(), type);
+ if (edgeS.isLeft()) {
+ try {
+ Edge edge = edgeS.left().value();
+ Vertex vertexOut = edge.outVertex();
+ Vertex vertexIn = edge.inVertex();
+ GraphNode nodeOut = GraphElementFactory
+ .createElement(fromLabel, GraphElementTypeEnum.Node, getProperties(vertexOut), GraphNode.class);
+ GraphNode nodeIn = GraphElementFactory.createElement(toLabel, GraphElementTypeEnum.Node, getProperties(vertexIn), GraphNode.class);
+ GraphRelation newRelation = GraphElementFactory.createRelation(edge.label(), getProperties(edge), nodeOut, nodeIn);
+ Either<JanusGraph, JanusGraphOperationStatus> graph = janusGraphClient.getGraph();
+ if (graph.isLeft()) {
+ edge.remove();
+ ;
+ } else {
+ if (log.isDebugEnabled()) {
+ log.debug("Failed to delete relation {} from {} to {} error : {}", type, fromKeyId, toKeyId, graph.right().value());
+ }
+ return Either.right(graph.right().value());
+ }
+ return Either.left(newRelation);
+ } catch (Exception e) {
+ if (log.isDebugEnabled()) {
+ log.debug("Failed to delete relation {} from {} to {}", type, fromKeyId, toKeyId, e);
+ }
+ return Either.right(JanusGraphClient.handleJanusGraphException(e));
+ }
+ } else {
+ if (log.isDebugEnabled()) {
+ log.debug("Failed to delete relation {} from {} to {} error : {}", type, fromKeyId, toKeyId, edgeS.right().value());
+ }
+ return Either.right(edgeS.right().value());
+ }
+ }
+
+ public void setJanusGraphClient(JanusGraphClient janusGraphClient) {
+ this.janusGraphClient = janusGraphClient;
+ }
+
+ public Either<GraphRelation, JanusGraphOperationStatus> deleteIncomingRelation(GraphRelation relation) {
+ RelationEndPoint to = relation.getTo();
+ ImmutablePair<String, Object> toKeyId = new ImmutablePair<>(to.getIdName(), to.getIdValue());
+ return deleteIncomingEdge(relation.getType(), toKeyId);
+ }
+
+ private Either<GraphRelation, JanusGraphOperationStatus> deleteIncomingEdge(String type, ImmutablePair<String, Object> toKeyId) {
+ Either<JanusGraph, JanusGraphOperationStatus> graph = janusGraphClient.getGraph();
+ if (graph.isLeft()) {
+ Either<JanusGraphVertex, JanusGraphOperationStatus> rootVertexResult = getVertexByProperty(toKeyId.getKey(), toKeyId.getValue());
+ if (rootVertexResult.isLeft()) {
+ Vertex rootVertex = rootVertexResult.left().value();
+ Iterator<Edge> edgesIterator = rootVertex.edges(Direction.IN, type);
+ if (edgesIterator != null) {
+ Edge edge = null;
+ if (edgesIterator.hasNext()) {
+ edge = edgesIterator.next();
+ if (edgesIterator.hasNext()) {
+ return Either.right(JanusGraphOperationStatus.MULTIPLE_EDGES_WITH_SAME_LABEL);
+ }
+ } else {
+ return Either.right(JanusGraphOperationStatus.NOT_FOUND);
+ }
+ log.debug("Find the tail vertex of the edge of type {} to vertex {}", type, toKeyId);
+ Vertex vertexOut = edge.outVertex();
+ String fromLabel = vertexOut.value(GraphPropertiesDictionary.LABEL.getProperty());
+ String toLabel = rootVertex.value(GraphPropertiesDictionary.LABEL.getProperty());
+ log.debug("The label of the outgoing vertex is {}", fromLabel);
+ GraphNode nodeOut = GraphElementFactory
+ .createElement(fromLabel, GraphElementTypeEnum.Node, getProperties(vertexOut), GraphNode.class);
+ GraphNode nodeIn = GraphElementFactory
+ .createElement(toLabel, GraphElementTypeEnum.Node, getProperties(rootVertex), GraphNode.class);
+ GraphRelation newRelation = GraphElementFactory.createRelation(edge.label(), getProperties(edge), nodeOut, nodeIn);
+ edge.remove();
+ return Either.left(newRelation);
+ } else {
+ return Either.right(JanusGraphOperationStatus.NOT_FOUND);
+ }
+ } else {
+ return Either.right(graph.right().value());
+ }
+ } else {
+ return Either.right(graph.right().value());
+ }
+ }
+
+ public Either<GraphRelation, JanusGraphOperationStatus> deleteOutgoingRelation(GraphRelation relation) {
+ RelationEndPoint from = relation.getFrom();
+ ImmutablePair<String, Object> fromKeyId = new ImmutablePair<>(from.getIdName(), from.getIdValue());
+ return deleteOutgoingEdge(relation.getType(), fromKeyId);
+ }
+
+ private Either<GraphRelation, JanusGraphOperationStatus> deleteOutgoingEdge(String type, ImmutablePair<String, Object> toKeyId) {
+ Either<JanusGraph, JanusGraphOperationStatus> graph = janusGraphClient.getGraph();
+ if (graph.isLeft()) {
+ Either<JanusGraphVertex, JanusGraphOperationStatus> rootVertexResult = getVertexByProperty(toKeyId.getKey(), toKeyId.getValue());
+ if (rootVertexResult.isLeft()) {
+ Vertex rootVertex = rootVertexResult.left().value();
+ Iterator<Edge> edgesIterator = rootVertex.edges(Direction.OUT, type);
+ if (edgesIterator != null) {
+ Edge edge = null;
+ if (edgesIterator.hasNext()) {
+ edge = edgesIterator.next();
+ if (edgesIterator.hasNext()) {
+ return Either.right(JanusGraphOperationStatus.MULTIPLE_EDGES_WITH_SAME_LABEL);
+ }
+ } else {
+ return Either.right(JanusGraphOperationStatus.NOT_FOUND);
+ }
+ log.debug("Find the tail vertex of the edge of type {} to vertex ", type, toKeyId);
+ Vertex vertexIn = edge.inVertex();
+ String toLabel = vertexIn.value(GraphPropertiesDictionary.LABEL.getProperty());
+ String fromLabel = rootVertex.value(GraphPropertiesDictionary.LABEL.getProperty());
+ log.debug("The label of the tail vertex is {}", toLabel);
+ GraphNode nodeFrom = GraphElementFactory
+ .createElement(fromLabel, GraphElementTypeEnum.Node, getProperties(rootVertex), GraphNode.class);
+ GraphNode nodeTo = GraphElementFactory
+ .createElement(toLabel, GraphElementTypeEnum.Node, getProperties(vertexIn), GraphNode.class);
+ GraphRelation newRelation = GraphElementFactory.createRelation(edge.label(), getProperties(edge), nodeFrom, nodeTo);
+ edge.remove();
+ return Either.left(newRelation);
+ } else {
+ return Either.right(JanusGraphOperationStatus.NOT_FOUND);
+ }
+ } else {
+ return Either.right(graph.right().value());
+ }
+ } else {
+ return Either.right(graph.right().value());
+ }
+ }
+
+ /**
+ * @param id
+ * @return
+ */
+ public JanusGraphOperationStatus lockElement(String id, NodeTypeEnum type) {
+ StringBuilder lockId = new StringBuilder(LOCK_NODE_PREFIX);
+ lockId.append(type.getName()).append("_").append(id);
+ return lockNode(lockId.toString());
+ }
+
+ public JanusGraphOperationStatus lockElement(GraphNode node) {
+ String lockId = createLockElementId(node);
+ return lockNode(lockId);
+ }
+
+ private JanusGraphOperationStatus lockNode(String lockId) {
+ GraphNodeLock lockNode = new GraphNodeLock(lockId);
+ Either<GraphNodeLock, JanusGraphOperationStatus> lockNodeNew = createNode(lockNode, GraphNodeLock.class);
+ if (lockNodeNew.isLeft()) {
+ log.debug("before commit, Lock node created for {}", lockId);
+ return janusGraphClient.commit();
+ } else {
+ Either<JanusGraph, JanusGraphOperationStatus> graph = janusGraphClient.getGraph();
+ if (graph.isLeft()) {
+ JanusGraph tGraph = graph.left().value();
+ Either<JanusGraphVertex, JanusGraphOperationStatus> vertex = getVertexByProperty(lockNode.getUniqueIdKey(), lockNode.getUniqueId());
+ if (vertex.isLeft()) {
+ return relockNode(lockNode, lockNodeNew, tGraph, vertex);
+ } else {
+ return vertex.right().value();
+ }
+ } else {
+ return graph.right().value();
+ }
+ }
+ }
+
+ private JanusGraphOperationStatus relockNode(GraphNodeLock lockNode, Either<GraphNodeLock, JanusGraphOperationStatus> lockNodeNew,
+ JanusGraph tGraph, Either<JanusGraphVertex, JanusGraphOperationStatus> vertex) {
+ Long time = vertex.left().value().value(GraphPropertiesDictionary.CREATION_DATE.getProperty());
+ Long lockTimeout = ConfigurationManager.getConfigurationManager().getConfiguration().getJanusGraphLockTimeout();
+ if (time + lockTimeout * 1000 < System.currentTimeMillis()) {
+ log.debug("Found not released lock node with id {}", lockNode.getUniqueId());
+ vertex.left().value().remove();
+ lockNodeNew = createNode(lockNode, GraphNodeLock.class);
+ if (lockNodeNew.isLeft()) {
+ log.debug("Lock node created for {}", lockNode.getUniqueIdKey());
+ return janusGraphClient.commit();
+ } else {
+ log.debug("Failed Lock node for {} . Commit transacton for deleted previous vertex .", lockNode.getUniqueIdKey());
+ janusGraphClient.commit();
+ return checkLockError(lockNode.getUniqueIdKey(), lockNodeNew);
+ }
+ } else {
+ log.debug("Failed Lock node for {} rollback transacton", lockNode.getUniqueIdKey());
+ janusGraphClient.rollback();
+ return checkLockError(lockNode.getUniqueIdKey(), lockNodeNew);
+ }
+ }
+
+ public <T extends GraphNode> Either<List<ImmutablePair<T, GraphEdge>>, JanusGraphOperationStatus> getChildrenNodes(String key, String uniqueId,
+ GraphEdgeLabels edgeType,
+ NodeTypeEnum nodeTypeEnum,
+ Class<T> clazz,
+ boolean withEdges) {
+ List<ImmutablePair<T, GraphEdge>> immutablePairs = new ArrayList<>();
+ Either<JanusGraph, JanusGraphOperationStatus> graphRes = janusGraphClient.getGraph();
+ if (graphRes.isRight()) {
+ log.error("Failed to retrieve graph. status is {}", graphRes);
+ return Either.right(graphRes.right().value());
+ }
+ JanusGraph janusGraph = graphRes.left().value();
+ @SuppressWarnings("unchecked") Iterable<JanusGraphVertex> vertices = janusGraph.query().has(key, uniqueId).vertices();
+ if (vertices == null || !vertices.iterator().hasNext()) {
+ return Either.right(JanusGraphOperationStatus.INVALID_ID);
+ }
+ Vertex rootVertex = vertices.iterator().next();
+ Iterator<Edge> edgesCreatorIterator = rootVertex.edges(Direction.OUT, edgeType.getProperty());
+ if (edgesCreatorIterator != null) {
+ while (edgesCreatorIterator.hasNext()) {
+ Edge edge = edgesCreatorIterator.next();
+ GraphEdge graphEdge = null;
+ if (withEdges) {
+ Map<String, Object> edgeProps = getProperties(edge);
+ GraphEdgeLabels edgeTypeFromGraph = GraphEdgeLabels.getByName(edge.label());
+ graphEdge = new GraphEdge(edgeTypeFromGraph, edgeProps);
+ }
+ Vertex outgoingVertex = edge.inVertex();
+ Map<String, Object> properties = getProperties(outgoingVertex);
+ T data = GraphElementFactory.createElement(nodeTypeEnum.getName(), GraphElementTypeEnum.Node, properties, clazz);
+ ImmutablePair<T, GraphEdge> immutablePair = new ImmutablePair<>(clazz.cast(data), graphEdge);
+ immutablePairs.add(immutablePair);
+ }
+ }
+ if (immutablePairs.isEmpty()) {
+ return Either.right(JanusGraphOperationStatus.NOT_FOUND);
+ }
+ return Either.left(immutablePairs);
+ }
+
+ public Either<List<ImmutablePair<JanusGraphVertex, Edge>>, JanusGraphOperationStatus> getChildrenVertecies(String key, String uniqueId,
+ GraphEdgeLabels edgeType) {
+ List<ImmutablePair<JanusGraphVertex, Edge>> immutablePairs = new ArrayList<>();
+ Either<JanusGraph, JanusGraphOperationStatus> graphRes = janusGraphClient.getGraph();
+ if (graphRes.isRight()) {
+ log.error("Failed to retrieve graph. status is {}", graphRes);
+ return Either.right(graphRes.right().value());
+ }
+ JanusGraph janusGraph = graphRes.left().value();
+ @SuppressWarnings("unchecked") Iterable<JanusGraphVertex> vertices = janusGraph.query().has(key, uniqueId).vertices();
+ if (vertices == null || !vertices.iterator().hasNext()) {
+ return Either.right(JanusGraphOperationStatus.INVALID_ID);
+ }
+ Vertex rootVertex = vertices.iterator().next();
+ Iterator<Edge> edgesCreatorIterator = rootVertex.edges(Direction.OUT, edgeType.getProperty());
+ if (edgesCreatorIterator != null) {
+ while (edgesCreatorIterator.hasNext()) {
+ Edge edge = edgesCreatorIterator.next();
+ JanusGraphVertex vertex = (JanusGraphVertex) edge.inVertex();
+ ImmutablePair<JanusGraphVertex, Edge> immutablePair = new ImmutablePair<>(vertex, edge);
+ immutablePairs.add(immutablePair);
+ }
+ }
+ if (immutablePairs.isEmpty()) {
+ return Either.right(JanusGraphOperationStatus.NOT_FOUND);
+ }
+ return Either.left(immutablePairs);
+ }
+
+ public <T extends GraphNode> Either<List<ImmutablePair<T, GraphEdge>>, JanusGraphOperationStatus> getChildrenNodes(String key, String uniqueId,
+ GraphEdgeLabels edgeType,
+ NodeTypeEnum nodeTypeEnum,
+ Class<T> clazz) {
+ return this.getChildrenNodes(key, uniqueId, edgeType, nodeTypeEnum, clazz, true);
+ }
+
+ private JanusGraphOperationStatus checkLockError(String lockId, Either<GraphNodeLock, JanusGraphOperationStatus> lockNodeNew) {
+ JanusGraphOperationStatus status;
+ JanusGraphOperationStatus error = lockNodeNew.right().value();
+ log.debug("Failed to Lock node for {} error = {}", lockId, error);
+ if (error.equals(JanusGraphOperationStatus.JANUSGRAPH_SCHEMA_VIOLATION) || error.equals(JanusGraphOperationStatus.ILLEGAL_ARGUMENT)) {
+ status = JanusGraphOperationStatus.ALREADY_LOCKED;
+ } else {
+ status = error;
+ }
+ return status;
+ }
+
+ /**
+ * @param node
+ * @return
+ */
+ public JanusGraphOperationStatus releaseElement(GraphNode node) {
+ String lockId = createLockElementId(node);
+ return unlockNode(lockId);
+ }
+
+ private JanusGraphOperationStatus unlockNode(String lockId) {
+ GraphNodeLock lockNode = new GraphNodeLock(lockId.toString());
+ Either<GraphNodeLock, JanusGraphOperationStatus> lockNodeNew = deleteNode(lockNode, GraphNodeLock.class);
+ if (lockNodeNew.isLeft()) {
+ log.debug("Lock node released for lock id = {}", lockId);
+ return janusGraphClient.commit();
+ } else {
+ janusGraphClient.rollback();
+ JanusGraphOperationStatus error = lockNodeNew.right().value();
+ log.debug("Failed to Release node for lock id {} error = {}", lockId, error);
+ return error;
+ }
+ }
+
+ public JanusGraphOperationStatus releaseElement(String id, NodeTypeEnum type) {
+ StringBuilder lockId = new StringBuilder(LOCK_NODE_PREFIX);
+ lockId.append(type.getName()).append("_").append(id);
+ return unlockNode(lockId.toString());
+ }
+
+ private String createLockElementId(GraphNode node) {
+ StringBuilder lockId = new StringBuilder(LOCK_NODE_PREFIX);
+ lockId.append(node.getLabel()).append("_").append(node.getUniqueId());
+ return lockId.toString();
+ }
+
+ public <T extends GraphNode> Either<ImmutablePair<T, GraphEdge>, JanusGraphOperationStatus> getChild(String key, String uniqueId,
+ GraphEdgeLabels edgeType,
+ NodeTypeEnum nodeTypeEnum, Class<T> clazz) {
+ Either<List<ImmutablePair<T, GraphEdge>>, JanusGraphOperationStatus> childrenNodes = getChildrenNodes(key, uniqueId, edgeType, nodeTypeEnum,
+ clazz);
+ if (childrenNodes.isRight()) {
+ return Either.right(childrenNodes.right().value());
+ }
+ List<ImmutablePair<T, GraphEdge>> value = childrenNodes.left().value();
+ if (value.size() > 1) {
+ return Either.right(JanusGraphOperationStatus.MULTIPLE_CHILDS_WITH_SAME_EDGE);
+ }
+ return Either.left(value.get(0));
+ }
+
+ public ImmutablePair<JanusGraphVertex, Edge> getChildVertex(JanusGraphVertex vertex, GraphEdgeLabels edgeType) {
+ ImmutablePair<JanusGraphVertex, Edge> pair = null;
+ Iterator<Edge> edges = vertex.edges(Direction.OUT, edgeType.getProperty());
+ if (edges.hasNext()) {
+ // get only first edge
+ Edge edge = edges.next();
+ pair = new ImmutablePair<>((JanusGraphVertex) edge.inVertex(), edge);
+ }
+ return pair;
+ }
+
+ public <T extends GraphNode> Either<List<ImmutablePair<T, GraphEdge>>, JanusGraphOperationStatus> getParentNodes(String key, String uniqueId,
+ GraphEdgeLabels edgeType,
+ NodeTypeEnum nodeTypeEnum,
+ Class<T> clazz) {
+ List<ImmutablePair<T, GraphEdge>> immutablePairs = new ArrayList<>();
+ T data = null;
+ GraphEdge graphEdge = null;
+ Either<JanusGraph, JanusGraphOperationStatus> graphRes = janusGraphClient.getGraph();
+ if (graphRes.isRight()) {
+ log.error("Failed to retrieve graph. status is {}", graphRes);
+ return Either.right(graphRes.right().value());
+ }
+ JanusGraph janusGraph = graphRes.left().value();
+ @SuppressWarnings("unchecked") Iterable<JanusGraphVertex> vertices = janusGraph.query().has(key, uniqueId).vertices();
+ if (vertices == null || !vertices.iterator().hasNext()) {
+ return Either.right(JanusGraphOperationStatus.INVALID_ID);
+ }
+ Vertex rootVertex = vertices.iterator().next();
+ Iterator<Edge> edgesCreatorIterator = rootVertex.edges(Direction.IN, edgeType.name());
+ if (edgesCreatorIterator != null) {
+ while (edgesCreatorIterator.hasNext()) {
+ Edge edge = edgesCreatorIterator.next();
+ Map<String, Object> edgeProps = getProperties(edge);
+ GraphEdgeLabels edgeTypeFromGraph = GraphEdgeLabels.getByName(edge.label());
+ graphEdge = new GraphEdge(edgeTypeFromGraph, edgeProps);
+ Vertex outgoingVertex = edge.outVertex();
+ Map<String, Object> properties = getProperties(outgoingVertex);
+ data = GraphElementFactory.createElement(nodeTypeEnum.getName(), GraphElementTypeEnum.Node, properties, clazz);
+ ImmutablePair<T, GraphEdge> immutablePair = new ImmutablePair<>(clazz.cast(data), graphEdge);
+ immutablePairs.add(immutablePair);
+ }
+ }
+ if (immutablePairs.isEmpty()) {
+ return Either.right(JanusGraphOperationStatus.NOT_FOUND);
+ }
+ return Either.left(immutablePairs);
+ }
+
+ public <T extends GraphNode> Either<ImmutablePair<T, GraphEdge>, JanusGraphOperationStatus> getParentNode(String key, String uniqueId,
+ GraphEdgeLabels edgeType,
+ NodeTypeEnum nodeTypeEnum,
+ Class<T> clazz) {
+ Either<List<ImmutablePair<T, GraphEdge>>, JanusGraphOperationStatus> parentNodesRes = this
+ .getParentNodes(key, uniqueId, edgeType, nodeTypeEnum, clazz);
+ if (parentNodesRes.isRight()) {
+ log.debug("failed to get edge key:{} uniqueId:{} edgeType {} nodeTypeEnum: {}, reason:{}", key, uniqueId, edgeType, nodeTypeEnum,
+ parentNodesRes.right().value());
+ return Either.right(parentNodesRes.right().value());
+ }
+ List<ImmutablePair<T, GraphEdge>> value = parentNodesRes.left().value();
+ if (value.size() > 1) {
+ return Either.right(JanusGraphOperationStatus.MULTIPLE_CHILDS_WITH_SAME_EDGE);
+ }
+ return Either.left(value.get(0));
+ }
+
+ public <T extends GraphNode> Either<ImmutablePair<T, GraphEdge>, JanusGraphOperationStatus> getChildByEdgeCriteria(String key, String uniqueId,
+ GraphEdgeLabels edgeType,
+ NodeTypeEnum nodeTypeEnum,
+ Class<T> clazz,
+ Map<String, Object> edgeProperties) {
+ Either<Edge, JanusGraphOperationStatus> outgoingEdgeByCriteria = getOutgoingEdgeByCriteria(key, uniqueId, edgeType, edgeProperties);
+ if (outgoingEdgeByCriteria.isRight()) {
+ JanusGraphOperationStatus status = outgoingEdgeByCriteria.right().value();
+ log.debug("Cannot find outgoing edge from vertex {} with label {} and properties {}" + uniqueId, edgeType, edgeProperties);
+ return Either.right(status);
+ }
+ Edge edge = outgoingEdgeByCriteria.left().value();
+ Map<String, Object> edgeProps = getProperties(edge);
+ GraphEdgeLabels edgeTypeFromGraph = GraphEdgeLabels.getByName(edge.label());
+ GraphEdge graphEdge = new GraphEdge(edgeTypeFromGraph, edgeProps);
+ Vertex outgoingVertex = edge.inVertex();
+ Map<String, Object> properties = getProperties(outgoingVertex);
+ T data = GraphElementFactory.createElement(nodeTypeEnum.getName(), GraphElementTypeEnum.Node, properties, clazz);
+ ImmutablePair<T, GraphEdge> immutablePair = new ImmutablePair<>(clazz.cast(data), graphEdge);
+ return Either.left(immutablePair);
+ }
+
+ public Either<ImmutablePair<JanusGraphVertex, Edge>, JanusGraphOperationStatus> getChildByEdgeCriteria(JanusGraphVertex vertex,
+ GraphEdgeLabels edgeType,
+ Map<String, Object> edgeProperties) {
+ Either<Edge, JanusGraphOperationStatus> outgoingEdgeByCriteria = getOutgoingEdgeByCriteria(vertex, edgeType, edgeProperties);
+ if (outgoingEdgeByCriteria.isRight()) {
+ JanusGraphOperationStatus status = outgoingEdgeByCriteria.right().value();
+ log.debug("Cannot find outgoing edge from vertex {} with label {} and properties {}", vertex, edgeType, edgeProperties);
+ return Either.right(status);
+ }
+ Edge edge = outgoingEdgeByCriteria.left().value();
+ JanusGraphVertex outgoingVertex = (JanusGraphVertex) edge.inVertex();
+ ImmutablePair<JanusGraphVertex, Edge> immutablePair = new ImmutablePair<>(outgoingVertex, edge);
+ return Either.left(immutablePair);
+ }
+
+ public Either<Edge, JanusGraphOperationStatus> getOutgoingEdgeByCriteria(String key, String value, GraphEdgeLabels label,
+ Map<String, Object> props) {
+ Either<JanusGraphVertex, JanusGraphOperationStatus> vertexFrom = getVertexByProperty(key, value);
+ if (vertexFrom.isRight()) {
+ JanusGraphOperationStatus status = vertexFrom.right().value();
+ if (status == JanusGraphOperationStatus.NOT_FOUND) {
+ return Either.right(JanusGraphOperationStatus.INVALID_ID);
+ }
+ return Either.right(status);
+ }
+ return getOutgoingEdgeByCriteria(vertexFrom.left().value(), label, props);
+ }
+
+ public Either<Edge, JanusGraphOperationStatus> getOutgoingEdgeByCriteria(JanusGraphVertex vertex, GraphEdgeLabels label,
+ Map<String, Object> props) {
+ JanusGraphVertexQuery<?> query = vertex.query();
+ query = query.direction(Direction.OUT).labels(label.getProperty());
+ if (props != null && !props.isEmpty()) {
+ for (Map.Entry<String, Object> entry : props.entrySet()) {
+ query = query.has(entry.getKey(), entry.getValue());
+ }
+ }
+ Edge matchingEdge = null;
+ Iterable<JanusGraphEdge> edges = query.edges();
+ if (edges == null) {
+ log.debug("No edges in graph for criteria");
+ return Either.right(JanusGraphOperationStatus.NOT_FOUND);
+ }
+ Iterator<JanusGraphEdge> eIter = edges.iterator();
+ if (eIter.hasNext()) {
+ matchingEdge = eIter.next();
+ }
+ if (matchingEdge == null) {
+ log.debug("No edges in graph for criteria");
+ return Either.right(JanusGraphOperationStatus.NOT_FOUND);
+ }
+ return Either.left(matchingEdge);
+ }
+
+ public <T extends GraphNode> Either<List<ImmutablePair<T, GraphEdge>>, JanusGraphOperationStatus> deleteChildrenNodes(String key, String uniqueId,
+ GraphEdgeLabels edgeType,
+ NodeTypeEnum nodeTypeEnum,
+ Class<T> clazz) {
+ List<ImmutablePair<T, GraphEdge>> result = new ArrayList<>();
+ Either<List<ImmutablePair<T, GraphEdge>>, JanusGraphOperationStatus> childrenNodesRes = getChildrenNodes(key, uniqueId, edgeType,
+ nodeTypeEnum, clazz);
+ if (childrenNodesRes.isRight()) {
+ JanusGraphOperationStatus status = childrenNodesRes.right().value();
+ return Either.right(status);
+ }
+ List<ImmutablePair<T, GraphEdge>> list = childrenNodesRes.left().value();
+ for (ImmutablePair<T, GraphEdge> pair : list) {
+ T node = pair.getKey();
+ Either<T, JanusGraphOperationStatus> deleteNodeRes = this.deleteNode(node, clazz);
+ if (deleteNodeRes.isRight()) {
+ JanusGraphOperationStatus status = deleteNodeRes.right().value();
+ log.error("Failed to delete node {} . status is {}", node, status);
+ return Either.right(status);
+ }
+ ImmutablePair<T, GraphEdge> deletedPair = new ImmutablePair<>(node, pair.getValue());
+ result.add(deletedPair);
+ }
+ return Either.left(result);
+ }
+
+ public void setProperties(Element element, Map<String, Object> properties) {
+ if (properties != null && !properties.isEmpty()) {
+ Object[] propertyKeyValues = new Object[properties.size() * 2];
+ int i = 0;
+ for (Entry<String, Object> entry : properties.entrySet()) {
+ propertyKeyValues[i++] = entry.getKey();
+ propertyKeyValues[i++] = entry.getValue();
+ }
+ ElementHelper.attachProperties(element, propertyKeyValues);
+ }
+ }
+
+ public Map<String, Object> getProperties(Element element) {
+ Map<String, Object> result = new HashMap<>();
+ if (element != null && element.keys() != null && element.keys().size() > 0) {
+ Map<String, Property> propertyMap = ElementHelper.propertyMap(element, element.keys().toArray(new String[element.keys().size()]));
+ for (Entry<String, Property> entry : propertyMap.entrySet()) {
+ String key = entry.getKey();
+ Object value = entry.getValue().value();
+ result.put(key, value);
+ }
+ }
+ return result;
+ }
- public Object getProperty(JanusGraphVertex vertex, String key) {
- PropertyKey propertyKey = janusGraphClient.getGraph().left().value().getPropertyKey(key);
+ public Object getProperty(JanusGraphVertex vertex, String key) {
+ PropertyKey propertyKey = janusGraphClient.getGraph().left().value().getPropertyKey(key);
return vertex.valueOrNull(propertyKey);
- }
-
- public Object getProperty(Edge edge, String key) {
- Object value = null;
- Property<Object> property = edge.property(key);
- if (property != null) {
- return property.orElse(null);
- }
- return value;
- }
-
- public <T extends GraphNode> Either<List<ImmutablePair<T, GraphEdge>>, JanusGraphOperationStatus> getChildrenByEdgeCriteria(Vertex vertex, String vertexUniqueId, GraphEdgeLabels edgeType, NodeTypeEnum nodeTypeEnum, Class<T> clazz,
- Map<String, Object> edgeProperties) {
-
- List<ImmutablePair<T, GraphEdge>> result = new ArrayList<>();
-
- Either<List<Edge>, JanusGraphOperationStatus> outgoingEdgeByCriteria = getOutgoingEdgesByCriteria(vertex, edgeType, edgeProperties);
- if (outgoingEdgeByCriteria.isRight()) {
- JanusGraphOperationStatus status = outgoingEdgeByCriteria.right().value();
- log.debug("Cannot find outgoing edge from vertex {} with label {} and properties {}", vertexUniqueId, edgeType, edgeProperties);
- return Either.right(status);
- }
-
- List<Edge> edges = outgoingEdgeByCriteria.left().value();
- if (edges != null) {
- for (Edge edge : edges) {
- Map<String, Object> edgeProps = getProperties(edge);
- GraphEdgeLabels edgeTypeFromGraph = GraphEdgeLabels.getByName(edge.label());
- GraphEdge graphEdge = new GraphEdge(edgeTypeFromGraph, edgeProps);
-
- Vertex outgoingVertex = edge.inVertex();
- Map<String, Object> properties = getProperties(outgoingVertex);
- T data = GraphElementFactory.createElement(nodeTypeEnum.getName(), GraphElementTypeEnum.Node, properties, clazz);
-
- ImmutablePair<T, GraphEdge> immutablePair = new ImmutablePair<>(clazz.cast(data), graphEdge);
- result.add(immutablePair);
- }
- }
-
- return Either.left(result);
- }
-
- public @NotNull Either<List<Edge>, JanusGraphOperationStatus> getOutgoingEdgesByCriteria(Vertex vertexFrom, GraphEdgeLabels label, Map<String, Object> props) {
-
- List<Edge> edgesResult = new ArrayList<>();
-
- JanusGraphVertex janusGraphVertex = (JanusGraphVertex) vertexFrom;
- JanusGraphVertexQuery<?> query = janusGraphVertex.query();
-
- query = query.direction(Direction.OUT).labels(label.getProperty());
-
- if (props != null && !props.isEmpty()) {
- for (Map.Entry<String, Object> entry : props.entrySet()) {
- query = query.has(entry.getKey(), entry.getValue());
- }
- }
-
- Iterable<JanusGraphEdge> edges = query.edges();
- Iterator<JanusGraphEdge> eIter = edges.iterator();
- if (!eIter.hasNext()) {
- log.debug("No edges found in graph for criteria (label = {} properties={})", label.getProperty(), props);
- return Either.left(edgesResult);
- }
-
- while (eIter.hasNext()) {
- Edge edge = eIter.next();
- edgesResult.add(edge);
- }
-
- if (edgesResult.isEmpty()) {
- log.debug("No edges found in graph for criteria (label = {} properties={})", label.getProperty(), props);
- return Either.right(JanusGraphOperationStatus.NOT_FOUND);
- }
- return Either.left(edgesResult);
-
- }
+ }
+ public Object getProperty(Edge edge, String key) {
+ Object value = null;
+ Property<Object> property = edge.property(key);
+ if (property != null) {
+ return property.orElse(null);
+ }
+ return value;
+ }
+
+ public <T extends GraphNode> Either<List<ImmutablePair<T, GraphEdge>>, JanusGraphOperationStatus> getChildrenByEdgeCriteria(Vertex vertex,
+ String vertexUniqueId,
+ GraphEdgeLabels edgeType,
+ NodeTypeEnum nodeTypeEnum,
+ Class<T> clazz,
+ Map<String, Object> edgeProperties) {
+ List<ImmutablePair<T, GraphEdge>> result = new ArrayList<>();
+ Either<List<Edge>, JanusGraphOperationStatus> outgoingEdgeByCriteria = getOutgoingEdgesByCriteria(vertex, edgeType, edgeProperties);
+ if (outgoingEdgeByCriteria.isRight()) {
+ JanusGraphOperationStatus status = outgoingEdgeByCriteria.right().value();
+ log.debug("Cannot find outgoing edge from vertex {} with label {} and properties {}", vertexUniqueId, edgeType, edgeProperties);
+ return Either.right(status);
+ }
+ List<Edge> edges = outgoingEdgeByCriteria.left().value();
+ if (edges != null) {
+ for (Edge edge : edges) {
+ Map<String, Object> edgeProps = getProperties(edge);
+ GraphEdgeLabels edgeTypeFromGraph = GraphEdgeLabels.getByName(edge.label());
+ GraphEdge graphEdge = new GraphEdge(edgeTypeFromGraph, edgeProps);
+ Vertex outgoingVertex = edge.inVertex();
+ Map<String, Object> properties = getProperties(outgoingVertex);
+ T data = GraphElementFactory.createElement(nodeTypeEnum.getName(), GraphElementTypeEnum.Node, properties, clazz);
+ ImmutablePair<T, GraphEdge> immutablePair = new ImmutablePair<>(clazz.cast(data), graphEdge);
+ result.add(immutablePair);
+ }
+ }
+ return Either.left(result);
+ }
+
+ public @NotNull
+ Either<List<Edge>, JanusGraphOperationStatus> getOutgoingEdgesByCriteria(Vertex vertexFrom, GraphEdgeLabels label, Map<String, Object> props) {
+ List<Edge> edgesResult = new ArrayList<>();
+ JanusGraphVertex janusGraphVertex = (JanusGraphVertex) vertexFrom;
+ JanusGraphVertexQuery<?> query = janusGraphVertex.query();
+ query = query.direction(Direction.OUT).labels(label.getProperty());
+ if (props != null && !props.isEmpty()) {
+ for (Map.Entry<String, Object> entry : props.entrySet()) {
+ query = query.has(entry.getKey(), entry.getValue());
+ }
+ }
+ Iterable<JanusGraphEdge> edges = query.edges();
+ Iterator<JanusGraphEdge> eIter = edges.iterator();
+ if (!eIter.hasNext()) {
+ log.debug("No edges found in graph for criteria (label = {} properties={})", label.getProperty(), props);
+ return Either.left(edgesResult);
+ }
+ while (eIter.hasNext()) {
+ Edge edge = eIter.next();
+ edgesResult.add(edge);
+ }
+ if (edgesResult.isEmpty()) {
+ log.debug("No edges found in graph for criteria (label = {} properties={})", label.getProperty(), props);
+ return Either.right(JanusGraphOperationStatus.NOT_FOUND);
+ }
+ return Either.left(edgesResult);
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/JanusGraphOperationStatus.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/JanusGraphOperationStatus.java
index a4ebcf79e0..f7c4ff2ddc 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/JanusGraphOperationStatus.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/JanusGraphOperationStatus.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,10 +17,8 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.janusgraph;
public enum JanusGraphOperationStatus {
- OK, NOT_CONNECTED, NOT_CREATED, INDEX_CANNOT_BE_CHANGED, NOT_FOUND, MISSING_UNIQUE_ID, MISSING_NODE_LABEL, MULTIPLE_EDGES_WITH_SAME_LABEL, CANNOT_DELETE_NON_LEAF_NODE, MULTIPLE_NODES_WITH_SAME_ID, GRAPH_IS_NOT_AVAILABLE, JANUSGRAPH_CONFIGURATION, JANUSGRAPH_SCHEMA_VIOLATION, INVALID_ELEMENT, INVALID_QUERY, INVALID_ID, RESOURCE_UNAVAILABLE, ILLEGAL_ARGUMENT, ALREADY_LOCKED, ALREADY_EXIST, MULTIPLE_CHILDS_WITH_SAME_EDGE, GENERAL_ERROR, MATCH_NOT_FOUND, INVALID_TYPE, PROPERTY_NAME_ALREADY_EXISTS, INVALID_PROPERTY,
-
+ OK, NOT_CONNECTED, NOT_CREATED, INDEX_CANNOT_BE_CHANGED, NOT_FOUND, MISSING_UNIQUE_ID, MISSING_NODE_LABEL, MULTIPLE_EDGES_WITH_SAME_LABEL, CANNOT_DELETE_NON_LEAF_NODE, MULTIPLE_NODES_WITH_SAME_ID, GRAPH_IS_NOT_AVAILABLE, JANUSGRAPH_CONFIGURATION, JANUSGRAPH_SCHEMA_VIOLATION, INVALID_ELEMENT, INVALID_QUERY, INVALID_ID, RESOURCE_UNAVAILABLE, ILLEGAL_ARGUMENT, ALREADY_LOCKED, ALREADY_EXIST, MULTIPLE_CHILDS_WITH_SAME_EDGE, GENERAL_ERROR, MATCH_NOT_FOUND, INVALID_TYPE, PROPERTY_NAME_ALREADY_EXISTS, INVALID_PROPERTY,
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/JanusGraphUtils.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/JanusGraphUtils.java
index d0c765cd8d..1e62a952cf 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/JanusGraphUtils.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/JanusGraphUtils.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,19 +17,17 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.janusgraph;
-import org.janusgraph.graphdb.query.JanusGraphPredicate;
+import static java.util.Collections.emptyMap;
+import static org.apache.commons.collections.CollectionUtils.isEmpty;
+import static org.janusgraph.core.attribute.Contain.NOT_IN;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
-
-import static org.janusgraph.core.attribute.Contain.NOT_IN;
-import static java.util.Collections.emptyMap;
-import static org.apache.commons.collections.CollectionUtils.isEmpty;
+import org.janusgraph.graphdb.query.JanusGraphPredicate;
public class JanusGraphUtils {
@@ -40,7 +38,7 @@ public class JanusGraphUtils {
if (isEmpty(notInCollection)) {
return emptyMap();
}
- Map<String, Entry<JanusGraphPredicate, Object>> predicateCriteria = new HashMap<>();
+ Map<String, Entry<JanusGraphPredicate, Object>> predicateCriteria = new HashMap<>();
predicateCriteria.put(propKey, new HashMap.SimpleEntry<>(NOT_IN, notInCollection));
return predicateCriteria;
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/QueryType.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/QueryType.java
index fc2f2d0643..3a9ce3e884 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/QueryType.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/QueryType.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,12 +17,9 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.janusgraph;
/**
* Created by mlando on 9/21/2016.
*/
-public enum QueryType {
- HAS, HAS_NOT
-}
+public enum QueryType {HAS, HAS_NOT}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/transactions/SimpleJanusGraphTransactionManager.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/transactions/SimpleJanusGraphTransactionManager.java
index 9648f62564..2101e8e970 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/transactions/SimpleJanusGraphTransactionManager.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/transactions/SimpleJanusGraphTransactionManager.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,11 +17,11 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.janusgraph.transactions;
-import org.janusgraph.core.JanusGraphException;
+import javax.annotation.PostConstruct;
import org.janusgraph.core.JanusGraph;
+import org.janusgraph.core.JanusGraphException;
import org.openecomp.sdc.be.dao.janusgraph.JanusGraphClient;
import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
import org.openecomp.sdc.common.log.wrappers.Logger;
@@ -32,11 +32,9 @@ import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.TransactionSystemException;
import org.springframework.transaction.support.SimpleTransactionStatus;
-import javax.annotation.PostConstruct;
-
/**
- * Simple transaction manager for the janusgraph database.
- * This manager does not deal with transactions propagation and relies on the fact that transactions are automatically created with the first operation on the graph
+ * Simple transaction manager for the janusgraph database. This manager does not deal with transactions propagation and relies on the fact that
+ * transactions are automatically created with the first operation on the graph
*/
@Component
public class SimpleJanusGraphTransactionManager implements PlatformTransactionManager {
@@ -86,5 +84,4 @@ public class SimpleJanusGraphTransactionManager implements PlatformTransactionMa
log.debug("#onFailingToStartJanusGraph - could not open janusgraph client");
throw new IllegalStateException("janusgraph could not be initialized: " + err);
}
-
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/GraphVertex.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/GraphVertex.java
index f3e64b11c6..f4624b6db1 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/GraphVertex.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/GraphVertex.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,13 +17,15 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.jsongraph;
-import org.janusgraph.core.JanusGraphVertex;
import com.google.common.base.Strings;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang.StringUtils;
+import org.janusgraph.core.JanusGraphVertex;
import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
@@ -31,144 +33,137 @@ import org.openecomp.sdc.be.datatypes.enums.InstantiationTypes;
import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-
public class GraphVertex {
- private String uniqueId;
- private JanusGraphVertex vertex;
- private VertexTypeEnum label;
+ private String uniqueId;
+ private JanusGraphVertex vertex;
+ private VertexTypeEnum label;
+ private Map<String, ? extends ToscaDataDefinition> json;
+ private Map<String, Object> metadataJson;
+ private Map<GraphPropertyEnum, Object> metadataProperties;
- private Map<String, ? extends ToscaDataDefinition> json;
- private Map<String, Object> metadataJson;
- private Map<GraphPropertyEnum, Object> metadataProperties;
+ public GraphVertex() {
+ }
- public GraphVertex() {
+ public GraphVertex(VertexTypeEnum label) {
+ super();
+ this.label = label;
+ }
- }
+ public String getUniqueId() {
+ return uniqueId;
+ }
- public GraphVertex(VertexTypeEnum label) {
- super();
- this.label = label;
- }
+ public void setUniqueId(String uniqueId) {
+ this.uniqueId = uniqueId;
+ addMetadataProperty(GraphPropertyEnum.UNIQUE_ID, uniqueId);
+ }
- public String getUniqueId() {
- return uniqueId;
- }
+ public Map<String, ? extends ToscaDataDefinition> getJson() {
+ return json;
+ }
- public void setUniqueId(String uniqueId) {
- this.uniqueId = uniqueId;
- addMetadataProperty(GraphPropertyEnum.UNIQUE_ID, uniqueId);
- }
+ public void setJson(Map<String, ? extends ToscaDataDefinition> json) {
+ this.json = json;
+ }
- public Map<String, ? extends ToscaDataDefinition> getJson() {
- return json;
- }
+ public JanusGraphVertex getVertex() {
+ return vertex;
+ }
- public void setJson(Map<String, ? extends ToscaDataDefinition> json) {
- this.json = json;
- }
+ public void setVertex(JanusGraphVertex vertex) {
+ this.vertex = vertex;
+ }
- public JanusGraphVertex getVertex() {
- return vertex;
- }
+ public VertexTypeEnum getLabel() {
+ return label;
+ }
- public void setVertex(JanusGraphVertex vertex) {
- this.vertex = vertex;
- }
+ public void setLabel(VertexTypeEnum label) {
+ this.label = label;
+ }
- public VertexTypeEnum getLabel() {
- return label;
- }
+ public ComponentTypeEnum getType() {
+ if (getMetadataProperty(GraphPropertyEnum.COMPONENT_TYPE) == null) {
+ if (getMetadataProperty(GraphPropertyEnum.RESOURCE_TYPE) != null) {
+ return ComponentTypeEnum.RESOURCE;
+ }
+ return null;
+ }
+ return ComponentTypeEnum.valueOf((String) getMetadataProperty(GraphPropertyEnum.COMPONENT_TYPE));
+ }
- public void setLabel(VertexTypeEnum label) {
- this.label = label;
- }
+ public void setType(ComponentTypeEnum type) {
+ addMetadataProperty(GraphPropertyEnum.COMPONENT_TYPE, type.name());
+ }
- public ComponentTypeEnum getType() {
- if(getMetadataProperty(GraphPropertyEnum.COMPONENT_TYPE) == null) {
- if (getMetadataProperty(GraphPropertyEnum.RESOURCE_TYPE) != null) {
- return ComponentTypeEnum.RESOURCE;
- }
- return null;
- }
+ public void addMetadataProperty(GraphPropertyEnum propName, Object propValue) {
+ if (metadataProperties == null) {
+ metadataProperties = new HashMap<>();
+ }
+ if (propValue != null) {
+ metadataProperties.put(propName, propValue);
+ }
+ }
- return ComponentTypeEnum.valueOf((String) getMetadataProperty(GraphPropertyEnum.COMPONENT_TYPE));
- }
-
- public void setType(ComponentTypeEnum type) {
- addMetadataProperty(GraphPropertyEnum.COMPONENT_TYPE, type.name());
- }
-
- public void addMetadataProperty(GraphPropertyEnum propName, Object propValue) {
- if (metadataProperties == null) {
- metadataProperties = new HashMap<>();
- }
- if (propValue != null) {
- metadataProperties.put(propName, propValue);
- }
- }
-
- public Object getMetadataProperty(GraphPropertyEnum metadataProperty) {
- if (metadataProperties != null) {
- return metadataProperties.get(metadataProperty);
- }
- return null;
- }
-
- public Map<GraphPropertyEnum, Object> getMetadataProperties() {
- return metadataProperties;
- }
-
- public void setMetadataProperties(Map<GraphPropertyEnum, Object> metadataProperties) {
- this.metadataProperties = metadataProperties;
- }
-
- public void getOrSetDefaultInstantiationTypeForToscaElementJson(){
- String toscaVertexJsonInstantiationType;
- toscaVertexJsonInstantiationType = (String)(this.getJsonMetadataField(JsonPresentationFields.INSTANTIATION_TYPE));
- if (Strings.isNullOrEmpty(toscaVertexJsonInstantiationType)) {
- this.setJsonMetadataField(JsonPresentationFields.INSTANTIATION_TYPE, InstantiationTypes.A_LA_CARTE.getValue());
- };
- };
-
- public Map<String, Object> getMetadataJson() {
- return metadataJson;
- }
-
- public void setMetadataJson(Map<String, Object> metadataJson) {
- this.metadataJson = metadataJson;
- }
-
- /**
- * used for clone vertex in case of copy on update
- *
- * @param other
- */
- public void cloneData(GraphVertex other) {
- // need to be deep copy???
- json = other.getJson();
- metadataJson = other.getMetadataJson();
- metadataProperties = other.getMetadataProperties();
- }
-
- public void setJsonMetadataField(JsonPresentationFields field, Object value) {
- if (metadataJson == null) {
- metadataJson = new HashMap<>();
- }
- metadataJson.put(field.getPresentation(), value);
- }
-
- public Object getJsonMetadataField(JsonPresentationFields field) {
- if (metadataJson != null) {
- return metadataJson.get(field.getPresentation());
- }
- return null;
- }
-
- public void setJsonMetadataField(String field, Object value) {
+ public Object getMetadataProperty(GraphPropertyEnum metadataProperty) {
+ if (metadataProperties != null) {
+ return metadataProperties.get(metadataProperty);
+ }
+ return null;
+ }
+
+ public Map<GraphPropertyEnum, Object> getMetadataProperties() {
+ return metadataProperties;
+ }
+
+ public void setMetadataProperties(Map<GraphPropertyEnum, Object> metadataProperties) {
+ this.metadataProperties = metadataProperties;
+ }
+
+ public void getOrSetDefaultInstantiationTypeForToscaElementJson() {
+ String toscaVertexJsonInstantiationType;
+ toscaVertexJsonInstantiationType = (String) (this.getJsonMetadataField(JsonPresentationFields.INSTANTIATION_TYPE));
+ if (Strings.isNullOrEmpty(toscaVertexJsonInstantiationType)) {
+ this.setJsonMetadataField(JsonPresentationFields.INSTANTIATION_TYPE, InstantiationTypes.A_LA_CARTE.getValue());
+ }
+ }
+
+ public Map<String, Object> getMetadataJson() {
+ return metadataJson;
+ }
+
+ public void setMetadataJson(Map<String, Object> metadataJson) {
+ this.metadataJson = metadataJson;
+ }
+
+ /**
+ * used for clone vertex in case of copy on update
+ *
+ * @param other
+ */
+ public void cloneData(GraphVertex other) {
+ // need to be deep copy???
+ json = other.getJson();
+ metadataJson = other.getMetadataJson();
+ metadataProperties = other.getMetadataProperties();
+ }
+
+ public void setJsonMetadataField(JsonPresentationFields field, Object value) {
+ if (metadataJson == null) {
+ metadataJson = new HashMap<>();
+ }
+ metadataJson.put(field.getPresentation(), value);
+ }
+
+ public Object getJsonMetadataField(JsonPresentationFields field) {
+ if (metadataJson != null) {
+ return metadataJson.get(field.getPresentation());
+ }
+ return null;
+ }
+
+ public void setJsonMetadataField(String field, Object value) {
if (metadataJson == null) {
metadataJson = new HashMap<>();
}
@@ -182,21 +177,22 @@ public class GraphVertex {
return null;
}
- /**
- * Updates metadata json with current metadataProperties. Note that already existing property containing in metadata json can be overrided by new value if metadataProperties contains the same property (by key). Note that metadata json can contain
- * a property that is not presented in metadataProperties. In such case the property will be put in metadata json.
- */
- public void updateMetadataJsonWithCurrentMetadataProperties() {
- if (!MapUtils.isEmpty(metadataProperties)) {
- if (metadataJson == null) {
- metadataJson = new HashMap<>();
- }
- for (Entry<GraphPropertyEnum, Object> entry : metadataProperties.entrySet()) {
- String propertyName = JsonPresentationFields.getPresentationByGraphProperty(entry.getKey());
- if (StringUtils.isNotEmpty(propertyName) && entry.getValue() != null) {
- metadataJson.put(propertyName, entry.getValue());
- }
- }
- }
- }
+ /**
+ * Updates metadata json with current metadataProperties. Note that already existing property containing in metadata json can be overrided by new
+ * value if metadataProperties contains the same property (by key). Note that metadata json can contain a property that is not presented in
+ * metadataProperties. In such case the property will be put in metadata json.
+ */
+ public void updateMetadataJsonWithCurrentMetadataProperties() {
+ if (!MapUtils.isEmpty(metadataProperties)) {
+ if (metadataJson == null) {
+ metadataJson = new HashMap<>();
+ }
+ for (Entry<GraphPropertyEnum, Object> entry : metadataProperties.entrySet()) {
+ String propertyName = JsonPresentationFields.getPresentationByGraphProperty(entry.getKey());
+ if (StringUtils.isNotEmpty(propertyName) && entry.getValue() != null) {
+ metadataJson.put(propertyName, entry.getValue());
+ }
+ }
+ }
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/HealingJanusGraphDao.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/HealingJanusGraphDao.java
index 510accdd12..38a86985e4 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/HealingJanusGraphDao.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/HealingJanusGraphDao.java
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.sdc.be.dao.jsongraph;
import fj.data.Either;
@@ -22,9 +21,9 @@ import java.util.Optional;
import java.util.stream.Collectors;
import org.openecomp.sdc.be.dao.impl.HealingPipelineDao;
import org.openecomp.sdc.be.dao.janusgraph.JanusGraphClient;
+import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
import org.openecomp.sdc.be.dao.jsongraph.types.EdgeLabelEnum;
import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum;
-import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@@ -33,7 +32,6 @@ public class HealingJanusGraphDao extends JanusGraphDao {
private HealingPipelineDao healingPipelineDao;
-
@Autowired
public HealingJanusGraphDao(HealingPipelineDao healingPipelineDao, JanusGraphClient janusGraphClient) {
super(janusGraphClient);
@@ -41,14 +39,11 @@ public class HealingJanusGraphDao extends JanusGraphDao {
}
@Override
- public Either<List<GraphVertex>, JanusGraphOperationStatus> getChildrenVertices(GraphVertex parentVertex,
- EdgeLabelEnum edgeLabel, JsonParseFlagEnum parseFlag) {
- Either<List<GraphVertex>, JanusGraphOperationStatus> childrenVertecies =
- super.getChildrenVertices(parentVertex, edgeLabel, parseFlag);
+ public Either<List<GraphVertex>, JanusGraphOperationStatus> getChildrenVertices(GraphVertex parentVertex, EdgeLabelEnum edgeLabel,
+ JsonParseFlagEnum parseFlag) {
+ Either<List<GraphVertex>, JanusGraphOperationStatus> childrenVertecies = super.getChildrenVertices(parentVertex, edgeLabel, parseFlag);
return Either.iif(childrenVertecies.isRight(), () -> childrenVertecies.right().value(),
- () -> childrenVertecies.left().value().stream()
- .map(graphVertex -> transformVertex(graphVertex, edgeLabel))
- .collect(Collectors.toList()));
+ () -> childrenVertecies.left().value().stream().map(graphVertex -> transformVertex(graphVertex, edgeLabel)).collect(Collectors.toList()));
}
private GraphVertex transformVertex(GraphVertex graphVertex, EdgeLabelEnum edgeLabelEnum) {
@@ -56,9 +51,7 @@ public class HealingJanusGraphDao extends JanusGraphDao {
return optional.orElse(graphVertex);
}
-
public void setHealingPipelineDao(HealingPipelineDao healingPipelineDao) {
this.healingPipelineDao = healingPipelineDao;
}
-
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/JanusGraphDao.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/JanusGraphDao.java
index bda3709d7d..3e10c7941d 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/JanusGraphDao.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/JanusGraphDao.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,16 +17,34 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.jsongraph;
-import org.janusgraph.core.*;
-import org.janusgraph.graphdb.query.JanusGraphPredicate;
+import static org.apache.commons.collections.CollectionUtils.isEmpty;
+
import fj.data.Either;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Optional;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.tuple.ImmutablePair;
-import org.apache.tinkerpop.gremlin.structure.*;
+import org.apache.tinkerpop.gremlin.structure.Direction;
+import org.apache.tinkerpop.gremlin.structure.Edge;
+import org.apache.tinkerpop.gremlin.structure.Element;
+import org.apache.tinkerpop.gremlin.structure.Property;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.apache.tinkerpop.gremlin.structure.util.ElementHelper;
+import org.janusgraph.core.JanusGraph;
+import org.janusgraph.core.JanusGraphEdge;
+import org.janusgraph.core.JanusGraphQuery;
+import org.janusgraph.core.JanusGraphVertex;
+import org.janusgraph.core.JanusGraphVertexQuery;
+import org.janusgraph.core.PropertyKey;
+import org.janusgraph.graphdb.query.JanusGraphPredicate;
import org.openecomp.sdc.be.dao.janusgraph.JanusGraphClient;
import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
import org.openecomp.sdc.be.dao.jsongraph.types.EdgeLabelEnum;
@@ -43,17 +61,10 @@ import org.openecomp.sdc.common.log.enums.EcompLoggerErrorCode;
import org.openecomp.sdc.common.log.wrappers.Logger;
import org.springframework.beans.factory.annotation.Qualifier;
-import java.io.IOException;
-import java.util.*;
-import java.util.Map.Entry;
-
-import static org.apache.commons.collections.CollectionUtils.isEmpty;
-
-
public class JanusGraphDao {
- JanusGraphClient janusGraphClient;
private static Logger logger = Logger.getLogger(JanusGraphDao.class.getName());
+ JanusGraphClient janusGraphClient;
public JanusGraphDao(@Qualifier("janusgraph-client") JanusGraphClient janusGraphClient) {
this.janusGraphClient = janusGraphClient;
@@ -75,7 +86,6 @@ public class JanusGraphDao {
}
/**
- *
* @param graphVertex
* @return
*/
@@ -85,18 +95,14 @@ public class JanusGraphDao {
if (graph.isLeft()) {
try {
JanusGraph tGraph = graph.left().value();
-
JanusGraphVertex vertex = tGraph.addVertex();
-
setVertexProperties(vertex, graphVertex);
-
graphVertex.setVertex(vertex);
-
return Either.left(graphVertex);
-
} catch (Exception e) {
- logger.error(EcompLoggerErrorCode.DATA_ERROR, "JanusGraphDao",
- "Failed to create Node for ID '{}'", (Object) graphVertex.getUniqueId(), e);
+ logger
+ .error(EcompLoggerErrorCode.DATA_ERROR, "JanusGraphDao", "Failed to create Node for ID '{}'", (Object) graphVertex.getUniqueId(),
+ e);
return Either.right(JanusGraphClient.handleJanusGraphException(e));
}
} else {
@@ -106,7 +112,6 @@ public class JanusGraphDao {
}
/**
- *
* @param name
* @param value
* @param label
@@ -117,7 +122,8 @@ public class JanusGraphDao {
}
public Either<GraphVertex, JanusGraphOperationStatus> getVertexByLabel(VertexTypeEnum label) {
- return janusGraphClient.getGraph().left().map(graph -> graph.query().has(GraphPropertyEnum.LABEL.getProperty(), label.getName()).vertices()).left().bind(janusGraphVertices -> getFirstFoundVertex(JsonParseFlagEnum.NoParse, janusGraphVertices));
+ return janusGraphClient.getGraph().left().map(graph -> graph.query().has(GraphPropertyEnum.LABEL.getProperty(), label.getName()).vertices())
+ .left().bind(janusGraphVertices -> getFirstFoundVertex(JsonParseFlagEnum.NoParse, janusGraphVertices));
}
private Either<GraphVertex, JanusGraphOperationStatus> getFirstFoundVertex(JsonParseFlagEnum parseFlag, Iterable<JanusGraphVertex> vertices) {
@@ -125,35 +131,30 @@ public class JanusGraphDao {
if (iterator.hasNext()) {
JanusGraphVertex vertex = iterator.next();
GraphVertex graphVertex = createAndFill(vertex, parseFlag);
-
return Either.left(graphVertex);
}
return Either.right(JanusGraphOperationStatus.NOT_FOUND);
}
/**
- *
* @param name
* @param value
* @param label
* @param parseFlag
* @return
*/
- public Either<GraphVertex, JanusGraphOperationStatus> getVertexByPropertyAndLabel(GraphPropertyEnum name, Object value, VertexTypeEnum label, JsonParseFlagEnum parseFlag) {
-
+ public Either<GraphVertex, JanusGraphOperationStatus> getVertexByPropertyAndLabel(GraphPropertyEnum name, Object value, VertexTypeEnum label,
+ JsonParseFlagEnum parseFlag) {
Either<JanusGraph, JanusGraphOperationStatus> graph = janusGraphClient.getGraph();
if (graph.isLeft()) {
try {
JanusGraph tGraph = graph.left().value();
-
- @SuppressWarnings("unchecked")
- Iterable<JanusGraphVertex> vertecies = tGraph.query().has(name.getProperty(), value).has(GraphPropertyEnum.LABEL.getProperty(), label.getName()).vertices();
-
+ @SuppressWarnings("unchecked") Iterable<JanusGraphVertex> vertecies = tGraph.query().has(name.getProperty(), value)
+ .has(GraphPropertyEnum.LABEL.getProperty(), label.getName()).vertices();
java.util.Iterator<JanusGraphVertex> iterator = vertecies.iterator();
if (iterator.hasNext()) {
JanusGraphVertex vertex = iterator.next();
GraphVertex graphVertex = createAndFill(vertex, parseFlag);
-
return Either.left(graphVertex);
}
if (logger.isDebugEnabled()) {
@@ -166,7 +167,6 @@ public class JanusGraphDao {
}
return Either.right(JanusGraphClient.handleJanusGraphException(e));
}
-
} else {
if (logger.isDebugEnabled()) {
logger.debug("No vertex in graph for key ={} and value = {} label = {} error :{}", name, value, label, graph.right().value());
@@ -176,7 +176,6 @@ public class JanusGraphDao {
}
/**
- *
* @param id
* @return
*/
@@ -185,13 +184,11 @@ public class JanusGraphDao {
}
/**
- *
* @param id
* @param parseFlag
* @return
*/
public Either<GraphVertex, JanusGraphOperationStatus> getVertexById(String id, JsonParseFlagEnum parseFlag) {
-
Either<JanusGraph, JanusGraphOperationStatus> graph = janusGraphClient.getGraph();
if (id == null) {
if (logger.isDebugEnabled()) {
@@ -202,10 +199,8 @@ public class JanusGraphDao {
if (graph.isLeft()) {
try {
JanusGraph tGraph = graph.left().value();
-
- @SuppressWarnings("unchecked")
- Iterable<JanusGraphVertex> vertecies = tGraph.query().has(GraphPropertyEnum.UNIQUE_ID.getProperty(), id).vertices();
-
+ @SuppressWarnings("unchecked") Iterable<JanusGraphVertex> vertecies = tGraph.query()
+ .has(GraphPropertyEnum.UNIQUE_ID.getProperty(), id).vertices();
java.util.Iterator<JanusGraphVertex> iterator = vertecies.iterator();
if (iterator.hasNext()) {
JanusGraphVertex vertex = iterator.next();
@@ -232,7 +227,6 @@ public class JanusGraphDao {
}
private void setVertexProperties(JanusGraphVertex vertex, GraphVertex graphVertex) throws IOException {
-
if (graphVertex.getMetadataProperties() != null) {
for (Map.Entry<GraphPropertyEnum, Object> entry : graphVertex.getMetadataProperties().entrySet()) {
if (entry.getValue() != null) {
@@ -241,12 +235,10 @@ public class JanusGraphDao {
}
}
vertex.property(GraphPropertyEnum.LABEL.getProperty(), graphVertex.getLabel().getName());
-
Map<String, ? extends ToscaDataDefinition> json = graphVertex.getJson();
if (json != null) {
String jsonStr = JsonParserUtils.toJson(json);
vertex.property(GraphPropertyEnum.JSON.getProperty(), jsonStr);
-
}
Map<String, Object> jsonMetadata = graphVertex.getMetadataJson();
if (jsonMetadata != null) {
@@ -277,35 +269,35 @@ public class JanusGraphDao {
for (Map.Entry<GraphPropertyEnum, Object> entry : properties.entrySet()) {
GraphPropertyEnum key = entry.getKey();
switch (key) {
- case UNIQUE_ID:
- graphVertex.setUniqueId((String) entry.getValue());
- break;
- case LABEL:
- graphVertex.setLabel(VertexTypeEnum.getByName((String) entry.getValue()));
- break;
- case COMPONENT_TYPE:
- String type = (String) entry.getValue();
- if (type != null) {
- graphVertex.setType(ComponentTypeEnum.valueOf(type));
- }
- break;
- case JSON:
- if (parseFlag == JsonParseFlagEnum.ParseAll || parseFlag == JsonParseFlagEnum.ParseJson) {
- String json = (String) entry.getValue();
- Map<String, ? extends ToscaDataDefinition> jsonObj = JsonParserUtils.toMap(json, label.getClassOfJson());
- graphVertex.setJson(jsonObj);
- }
- break;
- case METADATA:
- if (parseFlag == JsonParseFlagEnum.ParseAll || parseFlag == JsonParseFlagEnum.ParseMetadata) {
- String json = (String) entry.getValue();
- Map<String, Object> metadatObj = JsonParserUtils.toMap(json);
- graphVertex.setMetadataJson(metadatObj);
- }
- break;
- default:
- graphVertex.addMetadataProperty(key, entry.getValue());
- break;
+ case UNIQUE_ID:
+ graphVertex.setUniqueId((String) entry.getValue());
+ break;
+ case LABEL:
+ graphVertex.setLabel(VertexTypeEnum.getByName((String) entry.getValue()));
+ break;
+ case COMPONENT_TYPE:
+ String type = (String) entry.getValue();
+ if (type != null) {
+ graphVertex.setType(ComponentTypeEnum.valueOf(type));
+ }
+ break;
+ case JSON:
+ if (parseFlag == JsonParseFlagEnum.ParseAll || parseFlag == JsonParseFlagEnum.ParseJson) {
+ String json = (String) entry.getValue();
+ Map<String, ? extends ToscaDataDefinition> jsonObj = JsonParserUtils.toMap(json, label.getClassOfJson());
+ graphVertex.setJson(jsonObj);
+ }
+ break;
+ case METADATA:
+ if (parseFlag == JsonParseFlagEnum.ParseAll || parseFlag == JsonParseFlagEnum.ParseMetadata) {
+ String json = (String) entry.getValue();
+ Map<String, Object> metadatObj = JsonParserUtils.toMap(json);
+ graphVertex.setMetadataJson(metadatObj);
+ }
+ break;
+ default:
+ graphVertex.addMetadataProperty(key, entry.getValue());
+ break;
}
}
}
@@ -317,13 +309,13 @@ public class JanusGraphDao {
public JanusGraphOperationStatus createEdge(Vertex from, Vertex to, EdgeLabelEnum label, Map<EdgePropertyEnum, Object> properties) {
if (logger.isTraceEnabled()) {
logger.trace("Try to connect {} with {} label {} properties {}",
- from == null ? "NULL" : from.property(GraphPropertyEnum.UNIQUE_ID.getProperty()),
- to == null ? "NULL" : to.property(GraphPropertyEnum.UNIQUE_ID.getProperty()), label, properties);
+ from == null ? "NULL" : from.property(GraphPropertyEnum.UNIQUE_ID.getProperty()),
+ to == null ? "NULL" : to.property(GraphPropertyEnum.UNIQUE_ID.getProperty()), label, properties);
}
if (from == null || to == null) {
logger.trace("No JanusGraph vertex for id from {} or id to {}",
- from == null ? "NULL" : from.property(GraphPropertyEnum.UNIQUE_ID.getProperty()),
- to == null ? "NULL" : to.property(GraphPropertyEnum.UNIQUE_ID.getProperty()));
+ from == null ? "NULL" : from.property(GraphPropertyEnum.UNIQUE_ID.getProperty()),
+ to == null ? "NULL" : to.property(GraphPropertyEnum.UNIQUE_ID.getProperty()));
return JanusGraphOperationStatus.NOT_FOUND;
}
Edge edge = from.addEdge(label.name(), to);
@@ -332,24 +324,19 @@ public class JanusGraphDao {
setEdgeProperties(edge, properties);
status = JanusGraphOperationStatus.OK;
} catch (IOException e) {
- logger.error(EcompLoggerErrorCode.DATA_ERROR, "JanusGraphDao",
- "Failed to set properties on edge properties [{}]", properties, e);
+ logger.error(EcompLoggerErrorCode.DATA_ERROR, "JanusGraphDao", "Failed to set properties on edge properties [{}]", properties, e);
status = JanusGraphOperationStatus.GENERAL_ERROR;
}
return status;
}
public Map<GraphPropertyEnum, Object> getVertexProperties(Element element) {
-
Map<GraphPropertyEnum, Object> result = new HashMap<>();
-
if (element != null && element.keys() != null && element.keys().size() > 0) {
Map<String, Property> propertyMap = ElementHelper.propertyMap(element, element.keys().toArray(new String[element.keys().size()]));
-
for (Entry<String, Property> entry : propertyMap.entrySet()) {
String key = entry.getKey();
Object value = entry.getValue().value();
-
GraphPropertyEnum valueOf = GraphPropertyEnum.getByProperty(key);
if (valueOf != null) {
result.put(valueOf, value);
@@ -361,16 +348,12 @@ public class JanusGraphDao {
}
public Map<EdgePropertyEnum, Object> getEdgeProperties(Element element) {
-
Map<EdgePropertyEnum, Object> result = new HashMap<>();
-
if (element != null && element.keys() != null && element.keys().size() > 0) {
Map<String, Property> propertyMap = ElementHelper.propertyMap(element, element.keys().toArray(new String[element.keys().size()]));
-
for (Entry<String, Property> entry : propertyMap.entrySet()) {
String key = entry.getKey();
Object value = entry.getValue().value();
-
EdgePropertyEnum valueOf = EdgePropertyEnum.getByProperty(key);
if (valueOf != null) {
if (valueOf == EdgePropertyEnum.INSTANCES) {
@@ -386,9 +369,7 @@ public class JanusGraphDao {
}
public void setEdgeProperties(Element element, Map<EdgePropertyEnum, Object> properties) throws IOException {
-
if (properties != null && !properties.isEmpty()) {
-
Object[] propertyKeyValues = new Object[properties.size() * 2];
int i = 0;
for (Entry<EdgePropertyEnum, Object> entry : properties.entrySet()) {
@@ -409,17 +390,16 @@ public class JanusGraphDao {
return getByCriteria(type, props, JsonParseFlagEnum.ParseAll);
}
- public Either<List<GraphVertex>, JanusGraphOperationStatus> getByCriteria(VertexTypeEnum type, Map<GraphPropertyEnum, Object> props, JsonParseFlagEnum parseFlag) {
+ public Either<List<GraphVertex>, JanusGraphOperationStatus> getByCriteria(VertexTypeEnum type, Map<GraphPropertyEnum, Object> props,
+ JsonParseFlagEnum parseFlag) {
Either<JanusGraph, JanusGraphOperationStatus> graph = janusGraphClient.getGraph();
if (graph.isLeft()) {
try {
JanusGraph tGraph = graph.left().value();
-
JanusGraphQuery<? extends JanusGraphQuery> query = tGraph.query();
if (type != null) {
query = query.has(GraphPropertyEnum.LABEL.getProperty(), type.getName());
}
-
if (props != null && !props.isEmpty()) {
for (Map.Entry<GraphPropertyEnum, Object> entry : props.entrySet()) {
query = query.has(entry.getKey().getProperty(), entry.getValue());
@@ -429,25 +409,21 @@ public class JanusGraphDao {
if (vertices == null) {
return Either.right(JanusGraphOperationStatus.NOT_FOUND);
}
-
Iterator<JanusGraphVertex> iterator = vertices.iterator();
List<GraphVertex> result = new ArrayList<>();
-
while (iterator.hasNext()) {
JanusGraphVertex vertex = iterator.next();
-
Map<GraphPropertyEnum, Object> newProp = getVertexProperties(vertex);
GraphVertex graphVertex = createAndFill(vertex, parseFlag);
-
result.add(graphVertex);
}
if (logger.isDebugEnabled()) {
- logger.debug("Number of fetced nodes in graph for criteria : from type = {} and properties = {} is {}", type, props, result.size());
+ logger
+ .debug("Number of fetced nodes in graph for criteria : from type = {} and properties = {} is {}", type, props, result.size());
}
if (result.size() == 0) {
return Either.right(JanusGraphOperationStatus.NOT_FOUND);
}
-
return Either.left(result);
} catch (Exception e) {
if (logger.isDebugEnabled()) {
@@ -455,7 +431,6 @@ public class JanusGraphDao {
}
return Either.right(JanusGraphClient.handleJanusGraphException(e));
}
-
} else {
if (logger.isDebugEnabled()) {
logger.debug("Failed get by criteria for type ={} and properties = {} error : {}", type, props, graph.right().value());
@@ -464,23 +439,25 @@ public class JanusGraphDao {
}
}
- public Either<List<GraphVertex>, JanusGraphOperationStatus> getByCriteria(VertexTypeEnum type, Map<GraphPropertyEnum, Object> props, Map<GraphPropertyEnum, Object> hasNotProps, JsonParseFlagEnum parseFlag) {
+ public Either<List<GraphVertex>, JanusGraphOperationStatus> getByCriteria(VertexTypeEnum type, Map<GraphPropertyEnum, Object> props,
+ Map<GraphPropertyEnum, Object> hasNotProps,
+ JsonParseFlagEnum parseFlag) {
return getByCriteria(type, props, hasNotProps, null, parseFlag);
}
-
+
public Either<List<GraphVertex>, JanusGraphOperationStatus> getByCriteria(final VertexTypeEnum type,
- final Map<GraphPropertyEnum, Object> hasProps, final Map<GraphPropertyEnum, Object> hasNotProps,
- final Map<String, Entry<JanusGraphPredicate, Object>> predicates, final JsonParseFlagEnum parseFlag) {
+ final Map<GraphPropertyEnum, Object> hasProps,
+ final Map<GraphPropertyEnum, Object> hasNotProps,
+ final Map<String, Entry<JanusGraphPredicate, Object>> predicates,
+ final JsonParseFlagEnum parseFlag) {
Either<JanusGraph, JanusGraphOperationStatus> graph = janusGraphClient.getGraph();
if (graph.isLeft()) {
try {
JanusGraph tGraph = graph.left().value();
-
JanusGraphQuery<? extends JanusGraphQuery> query = tGraph.query();
if (type != null) {
query = query.has(GraphPropertyEnum.LABEL.getProperty(), type.getName());
}
-
if (hasProps != null && !hasProps.isEmpty()) {
for (Map.Entry<GraphPropertyEnum, Object> entry : hasProps.entrySet()) {
query = query.has(entry.getKey().getProperty(), entry.getValue());
@@ -506,14 +483,12 @@ public class JanusGraphDao {
if (vertices == null || !vertices.iterator().hasNext()) {
return Either.right(JanusGraphOperationStatus.NOT_FOUND);
}
-
List<GraphVertex> result = new ArrayList<>();
vertices.forEach(vertex -> result.add(createAndFill(vertex, parseFlag)));
-
if (logger.isDebugEnabled()) {
- logger.debug("Number of fetched nodes in graph for criteria : from type '{}' and properties '{}' is '{}'", type, hasProps, result.size());
+ logger.debug("Number of fetched nodes in graph for criteria : from type '{}' and properties '{}' is '{}'", type, hasProps,
+ result.size());
}
-
return Either.left(result);
} catch (Exception e) {
if (logger.isDebugEnabled()) {
@@ -521,7 +496,6 @@ public class JanusGraphDao {
}
return Either.right(JanusGraphClient.handleJanusGraphException(e));
}
-
} else {
if (logger.isDebugEnabled()) {
logger.debug("Failed to get by criteria for type '{}' and properties '{}'. Error : '{}'", type, hasProps, graph.right().value());
@@ -535,7 +509,6 @@ public class JanusGraphDao {
if (graph.isLeft()) {
try {
JanusGraph tGraph = graph.left().value();
-
String name = isCatalog ? VertexTypeEnum.CATALOG_ROOT.getName() : VertexTypeEnum.ARCHIVE_ROOT.getName();
Iterable<JanusGraphVertex> vCatalogIter = tGraph.query().has(GraphPropertyEnum.LABEL.getProperty(), name).vertices();
if (vCatalogIter == null) {
@@ -549,7 +522,6 @@ public class JanusGraphDao {
}
String edgeLabel = isCatalog ? EdgeLabelEnum.CATALOG_ELEMENT.name() : EdgeLabelEnum.ARCHIVE_ELEMENT.name();
Iterator<Vertex> vertices = catalogV.vertices(Direction.OUT, edgeLabel);
-
return Either.left(vertices);
} catch (Exception e) {
if (logger.isDebugEnabled()) {
@@ -557,7 +529,6 @@ public class JanusGraphDao {
}
return Either.right(JanusGraphClient.handleJanusGraphException(e));
}
-
} else {
if (logger.isDebugEnabled()) {
logger.debug("Failed get by criteria : ", graph.right().value());
@@ -574,13 +545,13 @@ public class JanusGraphDao {
}
/**
- *
* @param parentVertex
* @param edgeLabel
* @param parseFlag
* @return
*/
- public Either<GraphVertex, JanusGraphOperationStatus> getChildVertex(GraphVertex parentVertex, EdgeLabelEnum edgeLabel, JsonParseFlagEnum parseFlag) {
+ public Either<GraphVertex, JanusGraphOperationStatus> getChildVertex(GraphVertex parentVertex, EdgeLabelEnum edgeLabel,
+ JsonParseFlagEnum parseFlag) {
Either<List<GraphVertex>, JanusGraphOperationStatus> childrenVertecies = getChildrenVertices(parentVertex, edgeLabel, parseFlag);
if (childrenVertecies.isRight()) {
return Either.right(childrenVertecies.right().value());
@@ -589,7 +560,6 @@ public class JanusGraphDao {
}
/**
- *
* @param parentVertex
* @param edgeLabel
* @param parseFlag
@@ -603,12 +573,13 @@ public class JanusGraphDao {
return Either.left(childrenVertecies.left().value().get(0));
}
- public Either<GraphVertex, JanusGraphOperationStatus> getParentVertex(GraphVertex parentVertex, EdgeLabelEnum edgeLabel, JsonParseFlagEnum parseFlag) {
+ public Either<GraphVertex, JanusGraphOperationStatus> getParentVertex(GraphVertex parentVertex, EdgeLabelEnum edgeLabel,
+ JsonParseFlagEnum parseFlag) {
Either<List<GraphVertex>, JanusGraphOperationStatus> childrenVertecies = getParentVertices(parentVertex, edgeLabel, parseFlag);
if (childrenVertecies.isRight()) {
return Either.right(childrenVertecies.right().value());
}
- if (isEmpty(childrenVertecies.left().value())){
+ if (isEmpty(childrenVertecies.left().value())) {
return Either.right(JanusGraphOperationStatus.NOT_FOUND);
}
return Either.left(childrenVertecies.left().value().get(0));
@@ -616,35 +587,38 @@ public class JanusGraphDao {
public Either<Vertex, JanusGraphOperationStatus> getParentVertex(Vertex parentVertex, EdgeLabelEnum edgeLabel, JsonParseFlagEnum parseFlag) {
Either<List<Vertex>, JanusGraphOperationStatus> childrenVertecies = getParentVertices(parentVertex, edgeLabel, parseFlag);
- if (childrenVertecies.isRight() ) {
+ if (childrenVertecies.isRight()) {
return Either.right(childrenVertecies.right().value());
}
- if (isEmpty(childrenVertecies.left().value())){
+ if (isEmpty(childrenVertecies.left().value())) {
return Either.right(JanusGraphOperationStatus.NOT_FOUND);
}
return Either.left(childrenVertecies.left().value().get(0));
}
/**
- *
* @param parentVertex
* @param edgeLabel
* @param parseFlag
* @return
*/
- public Either<List<GraphVertex>, JanusGraphOperationStatus> getChildrenVertices(GraphVertex parentVertex, EdgeLabelEnum edgeLabel, JsonParseFlagEnum parseFlag) {
+ public Either<List<GraphVertex>, JanusGraphOperationStatus> getChildrenVertices(GraphVertex parentVertex, EdgeLabelEnum edgeLabel,
+ JsonParseFlagEnum parseFlag) {
return getAdjacentVertices(parentVertex, edgeLabel, parseFlag, Direction.OUT);
}
- public Either<List<GraphVertex>, JanusGraphOperationStatus> getParentVertices(GraphVertex parentVertex, EdgeLabelEnum edgeLabel, JsonParseFlagEnum parseFlag) {
+ public Either<List<GraphVertex>, JanusGraphOperationStatus> getParentVertices(GraphVertex parentVertex, EdgeLabelEnum edgeLabel,
+ JsonParseFlagEnum parseFlag) {
return getAdjacentVertices(parentVertex, edgeLabel, parseFlag, Direction.IN);
}
- public Either<List<Vertex>, JanusGraphOperationStatus> getParentVertices(Vertex parentVertex, EdgeLabelEnum edgeLabel, JsonParseFlagEnum parseFlag) {
+ public Either<List<Vertex>, JanusGraphOperationStatus> getParentVertices(Vertex parentVertex, EdgeLabelEnum edgeLabel,
+ JsonParseFlagEnum parseFlag) {
return getAdjacentVertices(parentVertex, edgeLabel, parseFlag, Direction.IN);
}
- private Either<List<Vertex>, JanusGraphOperationStatus> getAdjacentVertices(Vertex parentVertex, EdgeLabelEnum edgeLabel, JsonParseFlagEnum parseFlag, Direction direction) {
+ private Either<List<Vertex>, JanusGraphOperationStatus> getAdjacentVertices(Vertex parentVertex, EdgeLabelEnum edgeLabel,
+ JsonParseFlagEnum parseFlag, Direction direction) {
List<Vertex> list = new ArrayList<>();
try {
Either<JanusGraph, JanusGraphOperationStatus> graphRes = janusGraphClient.getGraph();
@@ -663,7 +637,6 @@ public class JanusGraphDao {
vertex = (JanusGraphVertex) edge.inVertex();
}
// GraphVertex graphVertex = createAndFill(vertex, parseFlag);
-
list.add(vertex);
}
}
@@ -674,57 +647,54 @@ public class JanusGraphDao {
logger.error("Failed to perform graph operation ", e);
Either.right(JanusGraphClient.handleJanusGraphException(e));
}
-
return Either.left(list);
}
/**
- *
* @param parentVertex
* @param edgeLabel
* @param parseFlag
* @return
*/
- public Either<List<Vertex>, JanusGraphOperationStatus> getChildrenVertices(Vertex parentVertex, EdgeLabelEnum edgeLabel, JsonParseFlagEnum parseFlag) {
+ public Either<List<Vertex>, JanusGraphOperationStatus> getChildrenVertices(Vertex parentVertex, EdgeLabelEnum edgeLabel,
+ JsonParseFlagEnum parseFlag) {
return getAdjacentVertices(parentVertex, edgeLabel, parseFlag, Direction.OUT);
}
- private Either<List<GraphVertex>, JanusGraphOperationStatus> getAdjacentVertices(GraphVertex parentVertex, EdgeLabelEnum edgeLabel, JsonParseFlagEnum parseFlag, Direction direction) {
+ private Either<List<GraphVertex>, JanusGraphOperationStatus> getAdjacentVertices(GraphVertex parentVertex, EdgeLabelEnum edgeLabel,
+ JsonParseFlagEnum parseFlag, Direction direction) {
List<GraphVertex> list = new ArrayList<>();
-
- Either<List<Vertex>, JanusGraphOperationStatus> adjacentVerticies = getAdjacentVertices(parentVertex.getVertex(), edgeLabel, parseFlag, direction);
+ Either<List<Vertex>, JanusGraphOperationStatus> adjacentVerticies = getAdjacentVertices(parentVertex.getVertex(), edgeLabel, parseFlag,
+ direction);
if (adjacentVerticies.isRight()) {
return Either.right(adjacentVerticies.right().value());
}
adjacentVerticies.left().value().stream().forEach(vertex -> {
list.add(createAndFill((JanusGraphVertex) vertex, parseFlag));
});
-
return Either.left(list);
}
/**
* Searches Edge by received label and criteria
- *
+ *
* @param vertex
* @param label
* @param properties
* @return found edge or JanusGraphOperationStatus
*/
- public Either<Edge, JanusGraphOperationStatus> getBelongingEdgeByCriteria(GraphVertex vertex, EdgeLabelEnum label, Map<GraphPropertyEnum, Object> properties) {
-
+ public Either<Edge, JanusGraphOperationStatus> getBelongingEdgeByCriteria(GraphVertex vertex, EdgeLabelEnum label,
+ Map<GraphPropertyEnum, Object> properties) {
Either<Edge, JanusGraphOperationStatus> result = null;
Edge matchingEdge = null;
String notFoundMsg = "No edges in graph for criteria";
try {
JanusGraphVertexQuery<?> query = vertex.getVertex().query().labels(label.name());
-
if (properties != null && !properties.isEmpty()) {
for (Map.Entry<GraphPropertyEnum, Object> entry : properties.entrySet()) {
query = query.has(entry.getKey().getProperty(), entry.getValue());
}
}
-
Iterable<JanusGraphEdge> edges = query.edges();
if (edges == null) {
CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, notFoundMsg);
@@ -742,24 +712,26 @@ public class JanusGraphDao {
result = Either.left(matchingEdge);
}
} catch (Exception e) {
- CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Exception occured during getting edge by criteria for component with id {}. {}", vertex.getUniqueId(), e);
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Exception occured during getting edge by criteria for component with id {}. {}",
+ vertex.getUniqueId(), e);
return Either.right(JanusGraphClient.handleJanusGraphException(e));
}
return result;
}
- public Either<Edge, JanusGraphOperationStatus> getEdgeByChildrenVertexProperties(GraphVertex vertex, EdgeLabelEnum label, Map<GraphPropertyEnum, Object> properties) {
+ public Either<Edge, JanusGraphOperationStatus> getEdgeByChildrenVertexProperties(GraphVertex vertex, EdgeLabelEnum label,
+ Map<GraphPropertyEnum, Object> properties) {
Either<Edge, JanusGraphOperationStatus> result = null;
Edge matchingEdge = null;
String notFoundMsg = "No edges in graph for criteria";
try {
-
Iterator<Edge> edges = vertex.getVertex().edges(Direction.OUT, label.name());
while (edges.hasNext()) {
matchingEdge = edges.next();
Vertex childV = matchingEdge.inVertex();
Map<GraphPropertyEnum, Object> vertexProperties = getVertexProperties(childV);
- Optional<Entry<GraphPropertyEnum, Object>> findNotMatch = properties.entrySet().stream().filter(e -> vertexProperties.get(e.getKey()) == null || !vertexProperties.get(e.getKey()).equals(e.getValue())).findFirst();
+ Optional<Entry<GraphPropertyEnum, Object>> findNotMatch = properties.entrySet().stream()
+ .filter(e -> vertexProperties.get(e.getKey()) == null || !vertexProperties.get(e.getKey()).equals(e.getValue())).findFirst();
if (!findNotMatch.isPresent()) {
result = Either.left(matchingEdge);
}
@@ -770,7 +742,8 @@ public class JanusGraphDao {
result = Either.right(JanusGraphOperationStatus.NOT_FOUND);
}
} catch (Exception e) {
- CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Exception occured during getting edge by criteria for component with id {}. {}", vertex.getUniqueId(), e);
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Exception occured during getting edge by criteria for component with id {}. {}",
+ vertex.getUniqueId(), e);
return Either.right(JanusGraphClient.handleJanusGraphException(e));
}
return result;
@@ -778,26 +751,33 @@ public class JanusGraphDao {
/**
* Deletes Edge by received label and criteria
- *
+ *
* @param vertex
* @param label
* @param properties
* @return
*/
- public Either<Edge, JanusGraphOperationStatus> deleteBelongingEdgeByCriteria(GraphVertex vertex, EdgeLabelEnum label, Map<GraphPropertyEnum, Object> properties) {
+ public Either<Edge, JanusGraphOperationStatus> deleteBelongingEdgeByCriteria(GraphVertex vertex, EdgeLabelEnum label,
+ Map<GraphPropertyEnum, Object> properties) {
Either<Edge, JanusGraphOperationStatus> result = null;
try {
result = getBelongingEdgeByCriteria(vertex, label, properties);
if (result.isLeft()) {
Edge edge = result.left().value();
- CommonUtility.addRecordToLog(logger, LogLevelEnum.TRACE, "Going to delete an edge with the label {} belonging to the vertex {} ", label.name(), vertex.getUniqueId());
+ CommonUtility
+ .addRecordToLog(logger, LogLevelEnum.TRACE, "Going to delete an edge with the label {} belonging to the vertex {} ", label.name(),
+ vertex.getUniqueId());
edge.remove();
result = Either.left(edge);
} else {
- CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to find an edge with the label {} belonging to the vertex {} ", label.name(), vertex.getUniqueId());
+ CommonUtility
+ .addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to find an edge with the label {} belonging to the vertex {} ", label.name(),
+ vertex.getUniqueId());
}
} catch (Exception e) {
- CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Exception occured during deleting an edge by criteria for the component with id {}. {}", vertex == null ? "NULL" : vertex.getUniqueId(), e);
+ CommonUtility
+ .addRecordToLog(logger, LogLevelEnum.DEBUG, "Exception occured during deleting an edge by criteria for the component with id {}. {}",
+ vertex == null ? "NULL" : vertex.getUniqueId(), e);
return Either.right(JanusGraphClient.handleJanusGraphException(e));
}
return result;
@@ -806,13 +786,12 @@ public class JanusGraphDao {
@SuppressWarnings("unchecked")
/**
* Deletes an edge between vertices fromVertex and toVertex according to received label
- *
+ *
* @param fromVertex
* @param toVertex
* @param label
* @return
*/
-
public Either<Edge, JanusGraphOperationStatus> deleteEdge(GraphVertex fromVertex, GraphVertex toVertex, EdgeLabelEnum label) {
return deleteEdge(fromVertex.getVertex(), toVertex.getVertex(), label, fromVertex.getUniqueId(), toVertex.getUniqueId(), false);
}
@@ -821,7 +800,8 @@ public class JanusGraphDao {
return deleteEdge(fromVertex.getVertex(), toVertex.getVertex(), label, fromVertex.getUniqueId(), toVertex.getUniqueId(), true);
}
- public Either<Edge, JanusGraphOperationStatus> deleteEdge(JanusGraphVertex fromVertex, JanusGraphVertex toVertex, EdgeLabelEnum label, String uniqueIdFrom, String uniqueIdTo, boolean deleteAll) {
+ public Either<Edge, JanusGraphOperationStatus> deleteEdge(JanusGraphVertex fromVertex, JanusGraphVertex toVertex, EdgeLabelEnum label,
+ String uniqueIdFrom, String uniqueIdTo, boolean deleteAll) {
Either<Edge, JanusGraphOperationStatus> result = null;
Vertex problemV = null;
try {
@@ -833,37 +813,38 @@ public class JanusGraphDao {
String currVertexUniqueId = null;
try {
currVertexUniqueId = edge.inVertex().value(GraphPropertyEnum.UNIQUE_ID.getProperty());
- }catch (Exception e){
+ } catch (Exception e) {
// AutoHealing procedure
- logger.info( "Corrupted vertex and edge were found and deleted {}",e);
- if ( problemV != null ) {
+ logger.info("Corrupted vertex and edge were found and deleted {}", e);
+ if (problemV != null) {
Map<GraphPropertyEnum, Object> props = getVertexProperties(problemV);
- logger.debug( "problematic Vertex properties:");
- logger.debug( "props size: {}", props.size());
+ logger.debug("problematic Vertex properties:");
+ logger.debug("props size: {}", props.size());
for (Map.Entry<GraphPropertyEnum, Object> entry : props.entrySet()) {
- logger.debug( "{}{}",entry.getKey() + ":" + entry.getValue());
+ logger.debug("{}{}", entry.getKey() + ":" + entry.getValue());
}
- Either<List<Vertex>, JanusGraphOperationStatus> childrenVertices = getChildrenVertices(problemV, EdgeLabelEnum.VERSION, JsonParseFlagEnum.NoParse);
- if(childrenVertices.isLeft()){
+ Either<List<Vertex>, JanusGraphOperationStatus> childrenVertices = getChildrenVertices(problemV, EdgeLabelEnum.VERSION,
+ JsonParseFlagEnum.NoParse);
+ if (childrenVertices.isLeft()) {
childrenVertices.left().value().size();
- logger.debug( "number of children that problematic Vertex has: {}", props.size());
+ logger.debug("number of children that problematic Vertex has: {}", props.size());
}
try {
edge.remove();
- }catch (Exception e1){
- logger.debug( "failed to remove problematic edge. {}", e1);
+ } catch (Exception e1) {
+ logger.debug("failed to remove problematic edge. {}", e1);
}
try {
problemV.remove();
- }catch (Exception e2){
- logger.debug( "failed to remove problematic vertex . {}", e2);
+ } catch (Exception e2) {
+ logger.debug("failed to remove problematic vertex . {}", e2);
}
}
continue;
}
-
if (currVertexUniqueId != null && currVertexUniqueId.equals(uniqueIdTo)) {
- CommonUtility.addRecordToLog(logger, LogLevelEnum.TRACE, "Going to delete an edge with the label {} between vertices {} and {}. ", label.name(), uniqueIdFrom, uniqueIdTo);
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.TRACE, "Going to delete an edge with the label {} between vertices {} and {}. ",
+ label.name(), uniqueIdFrom, uniqueIdTo);
edge.remove();
result = Either.left(edge);
if (!deleteAll) {
@@ -872,12 +853,14 @@ public class JanusGraphDao {
}
}
if (result == null) {
- CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to delete an edge with the label {} between vertices {} and {}. ", label.name(), uniqueIdFrom, uniqueIdTo);
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to delete an edge with the label {} between vertices {} and {}. ",
+ label.name(), uniqueIdFrom, uniqueIdTo);
result = Either.right(JanusGraphOperationStatus.NOT_FOUND);
}
} catch (Exception e) {
-
- CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Exception occured during deleting an edge with the label {} between vertices {} and {}. {}", label.name(), uniqueIdFrom, uniqueIdTo, e);
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG,
+ "Exception occured during deleting an edge with the label {} between vertices {} and {}. {}", label.name(), uniqueIdFrom, uniqueIdTo,
+ e);
return Either.right(JanusGraphClient.handleJanusGraphException(e));
}
return result;
@@ -886,7 +869,6 @@ public class JanusGraphDao {
public JanusGraphOperationStatus deleteEdgeByDirection(GraphVertex fromVertex, Direction direction, EdgeLabelEnum label) {
try {
Iterator<Edge> edges = fromVertex.getVertex().edges(direction, label.name());
-
while (edges.hasNext()) {
Edge edge = edges.next();
edge.remove();
@@ -900,7 +882,7 @@ public class JanusGraphDao {
/**
* Updates vertex properties. Note that graphVertex argument should contain updated data
- *
+ *
* @param graphVertex
* @return
*/
@@ -909,9 +891,9 @@ public class JanusGraphDao {
try {
graphVertex.updateMetadataJsonWithCurrentMetadataProperties();
setVertexProperties(graphVertex.getVertex(), graphVertex);
-
} catch (Exception e) {
- CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to update metadata of vertex with uniqueId {}. ", graphVertex.getUniqueId(), e);
+ CommonUtility
+ .addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to update metadata of vertex with uniqueId {}. ", graphVertex.getUniqueId(), e);
return Either.right(JanusGraphClient.handleJanusGraphException(e));
}
return Either.left(graphVertex);
@@ -919,12 +901,12 @@ public class JanusGraphDao {
/**
* Fetches vertices by uniqueId according to received parse flag
- *
+ *
* @param verticesToGet
* @return
*/
- public Either<Map<String, GraphVertex>, JanusGraphOperationStatus> getVerticesByUniqueIdAndParseFlag(Map<String, ImmutablePair<GraphPropertyEnum, JsonParseFlagEnum>> verticesToGet) {
-
+ public Either<Map<String, GraphVertex>, JanusGraphOperationStatus> getVerticesByUniqueIdAndParseFlag(
+ Map<String, ImmutablePair<GraphPropertyEnum, JsonParseFlagEnum>> verticesToGet) {
Either<Map<String, GraphVertex>, JanusGraphOperationStatus> result = null;
Map<String, GraphVertex> vertices = new HashMap<>();
JanusGraphOperationStatus titatStatus;
@@ -933,16 +915,20 @@ public class JanusGraphDao {
if (entry.getValue().getKey() == GraphPropertyEnum.UNIQUE_ID) {
getVertexRes = getVertexById(entry.getKey(), entry.getValue().getValue());
} else if (entry.getValue().getKey() == GraphPropertyEnum.USERID) {
- getVertexRes = getVertexByPropertyAndLabel(entry.getValue().getKey(), entry.getKey(), VertexTypeEnum.USER, entry.getValue().getValue());
+ getVertexRes = getVertexByPropertyAndLabel(entry.getValue().getKey(), entry.getKey(), VertexTypeEnum.USER,
+ entry.getValue().getValue());
}
if (getVertexRes == null) {
titatStatus = JanusGraphOperationStatus.ILLEGAL_ARGUMENT;
- CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Invalid vertex type label {} has been received. ", entry.getValue().getKey(), titatStatus);
+ CommonUtility
+ .addRecordToLog(logger, LogLevelEnum.DEBUG, "Invalid vertex type label {} has been received. ", entry.getValue().getKey(),
+ titatStatus);
return Either.right(titatStatus);
}
if (getVertexRes.isRight()) {
titatStatus = getVertexRes.right().value();
- CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to get vertex by id {} . Status is {}. ", entry.getKey(), titatStatus);
+ CommonUtility
+ .addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to get vertex by id {} . Status is {}. ", entry.getKey(), titatStatus);
result = Either.right(titatStatus);
break;
} else {
@@ -957,7 +943,7 @@ public class JanusGraphDao {
/**
* Creates edge between "from" and "to" vertices with specified label and properties extracted from received edge
- *
+ *
* @param from
* @param to
* @param label
@@ -968,10 +954,12 @@ public class JanusGraphDao {
return createEdge(from, to, label, getEdgeProperties(edgeToCopy));
}
- public JanusGraphOperationStatus replaceEdgeLabel(Vertex fromVertex, Vertex toVertex, Edge prevEdge, EdgeLabelEnum prevLabel, EdgeLabelEnum newLabel) {
- CommonUtility.addRecordToLog(logger, LogLevelEnum.TRACE, "Going to replace edge with label {} to {} between vertices {} and {}", prevLabel, newLabel, fromVertex!=null ? fromVertex.property(GraphPropertyEnum.UNIQUE_ID.getProperty()) : "NULL",
- toVertex!=null ? toVertex.property(GraphPropertyEnum.UNIQUE_ID.getProperty()) : "NULL");
-
+ public JanusGraphOperationStatus replaceEdgeLabel(Vertex fromVertex, Vertex toVertex, Edge prevEdge, EdgeLabelEnum prevLabel,
+ EdgeLabelEnum newLabel) {
+ CommonUtility
+ .addRecordToLog(logger, LogLevelEnum.TRACE, "Going to replace edge with label {} to {} between vertices {} and {}", prevLabel, newLabel,
+ fromVertex != null ? fromVertex.property(GraphPropertyEnum.UNIQUE_ID.getProperty()) : "NULL",
+ toVertex != null ? toVertex.property(GraphPropertyEnum.UNIQUE_ID.getProperty()) : "NULL");
JanusGraphOperationStatus result = createEdge(fromVertex, toVertex, newLabel, prevEdge);
if (result == JanusGraphOperationStatus.OK) {
prevEdge.remove();
@@ -981,22 +969,20 @@ public class JanusGraphDao {
/**
* Replaces previous label of edge with new label
- *
+ *
* @param fromVertex
* @param toVertex
* @param prevLabel
* @param newLabel
* @return
*/
- public JanusGraphOperationStatus replaceEdgeLabel(Vertex fromVertex, Vertex toVertex, EdgeLabelEnum prevLabel,
- EdgeLabelEnum newLabel) {
-
+ public JanusGraphOperationStatus replaceEdgeLabel(Vertex fromVertex, Vertex toVertex, EdgeLabelEnum prevLabel, EdgeLabelEnum newLabel) {
Iterator<Edge> prevEdgeIter = toVertex.edges(Direction.IN, prevLabel.name());
if (prevEdgeIter == null || !prevEdgeIter.hasNext()) {
- CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG,
- "Failed to replace edge with label {} to {} between vertices {} and {}", prevLabel, newLabel,
- fromVertex.property(GraphPropertyEnum.UNIQUE_ID.getProperty()),
- toVertex.property(GraphPropertyEnum.UNIQUE_ID.getProperty()));
+ CommonUtility
+ .addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to replace edge with label {} to {} between vertices {} and {}", prevLabel,
+ newLabel, fromVertex.property(GraphPropertyEnum.UNIQUE_ID.getProperty()),
+ toVertex.property(GraphPropertyEnum.UNIQUE_ID.getProperty()));
return JanusGraphOperationStatus.NOT_FOUND;
} else {
return replaceEdgeLabel(fromVertex, toVertex, prevEdgeIter.next(), prevLabel, newLabel);
@@ -1005,8 +991,7 @@ public class JanusGraphDao {
/**
* Updates metadata properties of vertex on graph. Json metadata property of the vertex will be updated with received properties too.
- *
- *
+ *
* @param vertex
* @param properties
* @return
@@ -1023,7 +1008,8 @@ public class JanusGraphDao {
vertex.property(GraphPropertyEnum.METADATA.getProperty(), JsonParserUtils.toJson(jsonMetadataMap));
}
} catch (Exception e) {
- CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Exception occurred during update vertex metadata properties with json{}. {}", vertex.property(GraphPropertyEnum.UNIQUE_ID.getProperty()), e.getMessage());
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Exception occurred during update vertex metadata properties with json{}. {}",
+ vertex.property(GraphPropertyEnum.UNIQUE_ID.getProperty()), e.getMessage());
return JanusGraphClient.handleJanusGraphException(e);
}
return JanusGraphOperationStatus.OK;
@@ -1032,7 +1018,6 @@ public class JanusGraphDao {
public JanusGraphOperationStatus disassociateAndDeleteLast(GraphVertex vertex, Direction direction, EdgeLabelEnum label) {
try {
Iterator<Edge> edges = vertex.getVertex().edges(direction, label.name());
-
while (edges.hasNext()) {
Edge edge = edges.next();
Vertex secondVertex;
@@ -1045,8 +1030,8 @@ public class JanusGraphDao {
reverseDirection = Direction.IN;
}
edge.remove();
- CommonUtility.addRecordToLog(logger, LogLevelEnum.TRACE, "Edge {} with direction {} was removed from {}", label.name(), direction, vertex.getVertex());
-
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.TRACE, "Edge {} with direction {} was removed from {}", label.name(), direction,
+ vertex.getVertex());
Iterator<Edge> restOfEdges = secondVertex.edges(reverseDirection, label.name());
if (!restOfEdges.hasNext()) {
secondVertex.remove();
@@ -1054,7 +1039,9 @@ public class JanusGraphDao {
}
}
} catch (Exception e) {
- CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Exception occured during deleting an edge with the label {} direction {} from vertex {}. {}", label.name(), direction, vertex.getUniqueId(), e);
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG,
+ "Exception occured during deleting an edge with the label {} direction {} from vertex {}. {}", label.name(), direction,
+ vertex.getUniqueId(), e);
return JanusGraphClient.handleJanusGraphException(e);
}
return JanusGraphOperationStatus.OK;
@@ -1077,13 +1064,11 @@ public class JanusGraphDao {
return value;
}
} catch (Exception e) {
-
}
return value;
}
/**
- *
* @param vertexA
* @param vertexB
* @param label
@@ -1108,7 +1093,8 @@ public class JanusGraphDao {
return JanusGraphOperationStatus.OK;
}
- public Either<Edge, JanusGraphOperationStatus> getBelongingEdgeByCriteria(String parentId, EdgeLabelEnum label, Map<GraphPropertyEnum, Object> properties) {
+ public Either<Edge, JanusGraphOperationStatus> getBelongingEdgeByCriteria(String parentId, EdgeLabelEnum label,
+ Map<GraphPropertyEnum, Object> properties) {
Either<GraphVertex, JanusGraphOperationStatus> getVertexRes = getVertexById(parentId, JsonParseFlagEnum.NoParse);
if (getVertexRes.isRight()) {
return Either.right(getVertexRes.right().value());
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/heal/Heal.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/heal/Heal.java
index 6c60772e8a..2ab8a9b71e 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/heal/Heal.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/heal/Heal.java
@@ -17,11 +17,7 @@ package org.openecomp.sdc.be.dao.jsongraph.heal;
public interface Heal<V> {
-
HealVersion fromVersion();
void healData(V parentV);
-
-
-
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/heal/HealConstants.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/heal/HealConstants.java
index 8f30d609e9..1932184927 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/heal/HealConstants.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/heal/HealConstants.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,14 +17,12 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.jsongraph.heal;
public class HealConstants {
public static final Integer DEFAULT_HEAL_VERSION = 0;
+
private HealConstants() {
}
-
-
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/heal/HealVersion.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/heal/HealVersion.java
index 55d3f43c79..1dd72bbe7d 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/heal/HealVersion.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/heal/HealVersion.java
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.sdc.be.dao.jsongraph.heal;
public interface HealVersion<T> extends Comparable<HealVersion> {
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/heal/HealVersionBuilder.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/heal/HealVersionBuilder.java
index 3a7b0645c1..1836453276 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/heal/HealVersionBuilder.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/heal/HealVersionBuilder.java
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.sdc.be.dao.jsongraph.heal;
public class HealVersionBuilder {
@@ -24,5 +23,4 @@ public class HealVersionBuilder {
public static HealVersion<Integer> build(Integer version) {
return new HealVersionImpl(version);
}
-
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/heal/HealVersionImpl.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/heal/HealVersionImpl.java
index 4ce28debc1..2d3a9d1708 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/heal/HealVersionImpl.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/heal/HealVersionImpl.java
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.sdc.be.dao.jsongraph.heal;
import com.google.common.base.MoreObjects;
@@ -34,25 +33,20 @@ class HealVersionImpl<T extends Comparable> implements HealVersion<T> {
return version;
}
-
@Override
public int compareTo(HealVersion o) {
- return this.version.compareTo( o.getVersion());
+ return this.version.compareTo(o.getVersion());
}
-
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
-
if (!(o instanceof HealVersionImpl)) {
return false;
}
-
HealVersionImpl that = (HealVersionImpl) o;
-
return new EqualsBuilder().append(getVersion(), that.getVersion()).isEquals();
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/types/EdgeLabelEnum.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/types/EdgeLabelEnum.java
index 67d44067fc..33a4391c9f 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/types/EdgeLabelEnum.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/types/EdgeLabelEnum.java
@@ -17,10 +17,10 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.jsongraph.types;
public enum EdgeLabelEnum {
+ // @formatter:off
ARTIFACTS,
DEPLOYMENT_ARTIFACTS,
INST_DEPLOYMENT_ARTIFACTS,
@@ -70,6 +70,7 @@ public enum EdgeLabelEnum {
NODE_FILTER_TEMPLATE,
SUBSTITUTION_FILTER_TEMPLATE,
DATA_TYPES;
+ // @formatter:on
/**
* Returns EdgeLabelEnum according received name
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/types/EdgePropertyEnum.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/types/EdgePropertyEnum.java
index d2f6d09908..5b2e85b99f 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/types/EdgePropertyEnum.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/types/EdgePropertyEnum.java
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.jsongraph.types;
import lombok.AllArgsConstructor;
@@ -26,10 +25,7 @@ import lombok.Getter;
@Getter
@AllArgsConstructor
public enum EdgePropertyEnum {
-
- STATE("state"),
- INSTANCES("instances");
-
+ STATE("state"), INSTANCES("instances");
private final String property;
public static EdgePropertyEnum getByProperty(String property) {
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/types/JsonParseFlagEnum.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/types/JsonParseFlagEnum.java
index ac0ceeb09b..4c722608e2 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/types/JsonParseFlagEnum.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/types/JsonParseFlagEnum.java
@@ -17,13 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.jsongraph.types;
-public enum JsonParseFlagEnum {
-
- NoParse,
- ParseAll,
- ParseJson,
- ParseMetadata
-}
+public enum JsonParseFlagEnum {NoParse, ParseAll, ParseJson, ParseMetadata}
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 9868eb83e5..cc8c8bcd87 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
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.jsongraph.types;
import lombok.AllArgsConstructor;
@@ -50,6 +49,7 @@ import org.openecomp.sdc.be.datatypes.elements.SubstitutionFilterDataDefinition;
@Getter
@AllArgsConstructor
public enum VertexTypeEnum {
+ // @formatter:off
NODE_TYPE ("node_type", null),
TOPOLOGY_TEMPLATE ("topology_template", CompositionDataDefinition.class),
ARTIFACTS ("artifacts", ArtifactDataDefinition.class),
@@ -93,16 +93,17 @@ public enum VertexTypeEnum {
SUBSTITUTION_FILTER_TEMPLATE ("substitution_mapping", SubstitutionFilterDataDefinition.class),
INST_INTERFACES ("InstInterfaces", MapInterfaceDataDefinition.class),
DATA_TYPES ("data_types", DataTypeDataDefinition.class);
+ // @formatter:on
- private final String name;
- private final Class classOfJson;
+ private final String name;
+ private final Class classOfJson;
- public static VertexTypeEnum getByName(String name){
- for ( VertexTypeEnum inst : VertexTypeEnum.values() ){
- if ( inst.getName().equals(name) ){
- return inst;
- }
- }
- return null;
- }
+ public static VertexTypeEnum getByName(String name) {
+ for (VertexTypeEnum inst : VertexTypeEnum.values()) {
+ if (inst.getName().equals(name)) {
+ return inst;
+ }
+ }
+ return null;
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/utils/IdBuilderUtils.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/utils/IdBuilderUtils.java
index acd6969a71..ff28ee8394 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/utils/IdBuilderUtils.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/utils/IdBuilderUtils.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,28 +17,26 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.jsongraph.utils;
-import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
-
import java.util.UUID;
+import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
public class IdBuilderUtils {
- private static String DOT = ".";
-
- public static String generateChildId(String componentId, VertexTypeEnum type){
- StringBuilder sb = new StringBuilder(componentId);
- sb.append(DOT).append(type.getName());
- return sb.toString();
- }
-
- public static String generateUUID(){
- return UUID.randomUUID().toString();
- }
-
- public static String generateUniqueId(){
- return UUID.randomUUID().toString();
- }
+ private static String DOT = ".";
+
+ public static String generateChildId(String componentId, VertexTypeEnum type) {
+ StringBuilder sb = new StringBuilder(componentId);
+ sb.append(DOT).append(type.getName());
+ return sb.toString();
+ }
+
+ public static String generateUUID() {
+ return UUID.randomUUID().toString();
+ }
+
+ public static String generateUniqueId() {
+ return UUID.randomUUID().toString();
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/utils/JsonParserUtils.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/utils/JsonParserUtils.java
index 9a6e70b4d8..85f4df6d53 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/utils/JsonParserUtils.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/utils/JsonParserUtils.java
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.jsongraph.utils;
import com.fasterxml.jackson.annotation.JsonInclude;
@@ -27,46 +26,40 @@ import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.google.common.base.Strings;
-import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
-import org.openecomp.sdc.common.log.wrappers.Logger;
-
import java.io.IOException;
import java.util.List;
import java.util.Map;
+import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
+import org.openecomp.sdc.common.log.wrappers.Logger;
public class JsonParserUtils {
- private static Logger log = Logger.getLogger(JsonParserUtils.class.getName());
+
private static final ObjectMapper mapper = buildObjectMapper();
+ private static Logger log = Logger.getLogger(JsonParserUtils.class.getName());
private JsonParserUtils() {
// No instances allowed
}
private static ObjectMapper buildObjectMapper() {
- return new ObjectMapper()
- .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
- .disable(SerializationFeature.FAIL_ON_EMPTY_BEANS)
- .setSerializationInclusion(JsonInclude.Include.NON_NULL);
+ return new ObjectMapper().disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES).disable(SerializationFeature.FAIL_ON_EMPTY_BEANS)
+ .setSerializationInclusion(JsonInclude.Include.NON_NULL);
}
public static <T> String toJson(T object) throws IOException {
- return mapper.writer()
- .writeValueAsString(object);
+ return mapper.writer().writeValueAsString(object);
}
public static Map<String, Object> toMap(String json) {
if (Strings.isNullOrEmpty(json)) {
return null;
}
-
Map<String, Object> object = null;
try {
TypeReference<Map<String, Object>> typeRef = new TypeReference<Map<String, Object>>() {
};
- object = mapper.readerFor(typeRef)
- .readValue(json);
- }
- catch (Exception e) {
+ object = mapper.readerFor(typeRef).readValue(json);
+ } catch (Exception e) {
log.debug("Failed to parse json {}", json, e);
}
return object;
@@ -76,32 +69,25 @@ public class JsonParserUtils {
if (Strings.isNullOrEmpty(json)) {
return null;
}
-
Map<String, T> object = null;
try {
- JavaType type = mapper.getTypeFactory()
- .constructMapType(Map.class, String.class, clazz);
- object = mapper.readerFor(type)
- .readValue(json);
- }
- catch (Exception e) {
+ JavaType type = mapper.getTypeFactory().constructMapType(Map.class, String.class, clazz);
+ object = mapper.readerFor(type).readValue(json);
+ } catch (Exception e) {
log.debug("Failed to parse json {} to map", json, e);
}
return object;
}
+
public static <T> List<T> toList(String json, Class<T> clazz) {
if (Strings.isNullOrEmpty(json)) {
return null;
}
List<T> object = null;
try {
- JavaType type = mapper.getTypeFactory()
- .constructCollectionType(List.class, clazz);
-
- object = mapper.readerFor(type)
- .readValue(json);
- }
- catch (Exception e) {
+ JavaType type = mapper.getTypeFactory().constructCollectionType(List.class, clazz);
+ object = mapper.readerFor(type).readValue(json);
+ } catch (Exception e) {
log.debug("Failed to parse json {} to list", json, e);
}
return object;
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/model/FetchContext.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/model/FetchContext.java
index a02c38cf0c..45b0e5068f 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/model/FetchContext.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/model/FetchContext.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,16 +17,15 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.model;
public final class FetchContext {
- public static final String QUICK_SEARCH = "quick_search";
- public static final String TAG_SUGGESTION = "tag_suggestion";
- public static final String COMPONENT_SUMMARY = "component_summary";
- public static final String DEPLOYMENT = "deployment";
+ public static final String QUICK_SEARCH = "quick_search";
+ public static final String TAG_SUGGESTION = "tag_suggestion";
+ public static final String COMPONENT_SUMMARY = "component_summary";
+ public static final String DEPLOYMENT = "deployment";
- private FetchContext() {
- }
+ private FetchContext() {
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/GraphEdgeLabels.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/GraphEdgeLabels.java
index fc30a7e8f3..2ebfbe0060 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/GraphEdgeLabels.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/GraphEdgeLabels.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.neo4j;
import java.util.ArrayList;
@@ -28,42 +27,87 @@ import lombok.Getter;
@AllArgsConstructor
public enum GraphEdgeLabels {
- // field name
- //
- STATE("STATE"), LAST_STATE("LAST_STATE"), CREATOR("CREATOR"), LAST_MODIFIER("LAST_MODIFIER"), ATTRIBUTE("EDGE_ATTRIBUTE"), PROPERTY("EDGE_PROPERTY"), CATEGORY("CATEGORY"), DERIVED_FROM("DERIVED_FROM"), REQUIREMENT("REQUIREMENT"),
- CAPABILITY_TYPE("CAPABILITY_TYPE"), RELATIONSHIP_TYPE("RELATIONSHIP_TYPE"), CAPABILITY("CAPABILITY"), CAPABILITY_IMPL("CAPABILITY_IMPL"),
- INSTANCE_OF("INSTANCE_OF"), INTERFACE("INTERFACE"), INTERFACE_OPERATION("INTERFACE_OPERATION"), ARTIFACT_REF("ARTIFACT_REF"),
- INPUTS("INPUTS"), REQUIREMENT_IMPL("REQUIREMENT_IMPL"), NODE_IMPL("NODE_IMPL"), IMPLEMENTATION_OF("IMPLEMENTATION_OF"), ATTRIBUTE_VALUE("ATTRIBUTE_VALUE"), INPUT_VALUE("INPUT_VALUE"), PROPERTY_VALUE("PROPERTY_VALUE"),
- CAPABILITY_INST("CAPABILITY_INST"), TYPE_OF("TYPE_OF"), RESOURCE_INST("RESOURCE_INST"), RELATIONSHIP_INST("RELATIONSHIP_INST"), CAPABILITY_NODE("CAPABILITY_NODE"), LAST_DISTRIBUTION_STATE_MODIFAIER("LAST_DISTRIBUTION_STATE_MODIFAIER"),
- ATTRIBUTE_IMPL("ATTRIBUTE_IMPL"), INPUT_IMPL("INPUT_IMPL"), PROPERTY_IMPL("PROPERTY_IMPL"), ADDITIONAL_INFORMATION("ADDITIONAL_INFORMATION"), HEAT_PARAMETER("HEAT_PARAMETER"), SUB_CATEGORY("SUB_CATEGORY"), GROUPING("GROUPING"),
- CATEGORIZED_TO("CATEGORIZED_TO"), GENERATED_FROM("GENERATED_FROM"), PARAMETER_VALUE("PARAMETER_VALUE"), PARAMETER_IMPL("PARAMETER_IMPL"),
- // VF additions
- CALCULATED_REQUIREMENT("CALCULATED_REQUIREMENT"), CALCULATED_CAPABILITY("CALCULATED_CAPABILITY"), RELATIONSHIP_ORIGIN("RELATIONSHIP_ORIGIN"), CAPABILITY_ORIGIN("CAPABILITY_ORIGIN"),
- CALCULATED_REQUIREMENT_FULLFILLED("CALCULATED_REQUIREMENT_FULLFILLED"), CALCULATED_CAPABILITY_FULLFILLED("CALCULATED_CAPABILITY_FULLFILLED"),
- // Group
- GROUP("GROUP"), GROUP_ARTIFACT_REF("GROUP_ARTIFACT_REF"), GROUP_MEMBER("GROUP_MEMBER"), INPUT("EDGE_INPUT"), GET_INPUT("GET_INPUT"), GROUP_INST("GROUP_INST"),
- GROUP_TYPE_CAPABILITY_TYPE("GROUP_TYPE_CAPABILITY_TYPE"), GROUP_TYPE_CAPABILITY("GROUP_TYPE_CAPABILITY");
+ // field name
+ // @formatter:off
+ STATE("STATE"),
+ LAST_STATE("LAST_STATE"),
+ CREATOR("CREATOR"),
+ LAST_MODIFIER("LAST_MODIFIER"),
+ ATTRIBUTE("EDGE_ATTRIBUTE"),
+ PROPERTY("EDGE_PROPERTY"),
+ CATEGORY("CATEGORY"),
+ DERIVED_FROM("DERIVED_FROM"),
+ REQUIREMENT("REQUIREMENT"),
+ CAPABILITY_TYPE("CAPABILITY_TYPE"),
+ RELATIONSHIP_TYPE("RELATIONSHIP_TYPE"),
+ CAPABILITY("CAPABILITY"),
+ CAPABILITY_IMPL("CAPABILITY_IMPL"),
+ INSTANCE_OF("INSTANCE_OF"),
+ INTERFACE("INTERFACE"),
+ INTERFACE_OPERATION("INTERFACE_OPERATION"),
+ ARTIFACT_REF("ARTIFACT_REF"),
+ INPUTS("INPUTS"),
+ REQUIREMENT_IMPL("REQUIREMENT_IMPL"),
+ NODE_IMPL("NODE_IMPL"),
+ IMPLEMENTATION_OF("IMPLEMENTATION_OF"),
+ ATTRIBUTE_VALUE("ATTRIBUTE_VALUE"),
+ INPUT_VALUE("INPUT_VALUE"),
+ PROPERTY_VALUE("PROPERTY_VALUE"),
+ CAPABILITY_INST("CAPABILITY_INST"),
+ TYPE_OF("TYPE_OF"),
+ RESOURCE_INST("RESOURCE_INST"),
+ RELATIONSHIP_INST("RELATIONSHIP_INST"),
+ CAPABILITY_NODE("CAPABILITY_NODE"),
+ LAST_DISTRIBUTION_STATE_MODIFAIER("LAST_DISTRIBUTION_STATE_MODIFAIER"),
+ ATTRIBUTE_IMPL("ATTRIBUTE_IMPL"),
+ INPUT_IMPL("INPUT_IMPL"),
+ PROPERTY_IMPL("PROPERTY_IMPL"),
+ ADDITIONAL_INFORMATION("ADDITIONAL_INFORMATION"),
+ HEAT_PARAMETER("HEAT_PARAMETER"),
+ SUB_CATEGORY("SUB_CATEGORY"),
+ GROUPING("GROUPING"),
+ CATEGORIZED_TO("CATEGORIZED_TO"),
+ GENERATED_FROM("GENERATED_FROM"),
+ PARAMETER_VALUE("PARAMETER_VALUE"),
+ PARAMETER_IMPL("PARAMETER_IMPL"),
+ // VF additions
+ CALCULATED_REQUIREMENT("CALCULATED_REQUIREMENT"),
+ CALCULATED_CAPABILITY("CALCULATED_CAPABILITY"),
+ RELATIONSHIP_ORIGIN("RELATIONSHIP_ORIGIN"),
+ CAPABILITY_ORIGIN("CAPABILITY_ORIGIN"),
+ CALCULATED_REQUIREMENT_FULLFILLED("CALCULATED_REQUIREMENT_FULLFILLED"),
+ CALCULATED_CAPABILITY_FULLFILLED("CALCULATED_CAPABILITY_FULLFILLED"),
+ // Group
+ GROUP("GROUP"),
+ GROUP_ARTIFACT_REF("GROUP_ARTIFACT_REF"),
+ GROUP_MEMBER("GROUP_MEMBER"),
+ INPUT("EDGE_INPUT"),
+ GET_INPUT("GET_INPUT"),
+ GROUP_INST("GROUP_INST"),
+ GROUP_TYPE_CAPABILITY_TYPE("GROUP_TYPE_CAPABILITY_TYPE"),
+ GROUP_TYPE_CAPABILITY("GROUP_TYPE_CAPABILITY");
+ // @formatter:on
- @Getter
- private final String property;
+ @Getter
+ private final String property;
- public static List<String> getAllProperties() {
+ public static List<String> getAllProperties() {
- List<String> arrayList = new ArrayList<>();
+ List<String> arrayList = new ArrayList<>();
- for (GraphEdgeLabels graphProperty : GraphEdgeLabels.values()) {
- arrayList.add(graphProperty.getProperty());
- }
+ for (GraphEdgeLabels graphProperty : GraphEdgeLabels.values()) {
+ arrayList.add(graphProperty.getProperty());
+ }
- return arrayList;
- }
+ return arrayList;
+ }
- public static GraphEdgeLabels getByName(String property) {
- for (GraphEdgeLabels inst : GraphEdgeLabels.values()) {
- if (inst.getProperty().equals(property)) {
- return inst;
- }
- }
- return null;
- }
+ public static GraphEdgeLabels getByName(String property) {
+ for (GraphEdgeLabels inst : GraphEdgeLabels.values()) {
+ if (inst.getProperty().equals(property)) {
+ return inst;
+ }
+ }
+ return null;
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/GraphEdgePropertiesDictionary.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/GraphEdgePropertiesDictionary.java
index b8209e8d03..4e9b808e9f 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/GraphEdgePropertiesDictionary.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/GraphEdgePropertiesDictionary.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.neo4j;
import java.util.ArrayList;
@@ -28,38 +27,37 @@ import lombok.Getter;
@AllArgsConstructor
@Getter
public enum GraphEdgePropertiesDictionary {
-
- // field name class type
- // stored in graph
- STATE("state", String.class),
- NAME("name", String.class),
- GROUP_TYPE("groupType", String.class),
- SOURCE("source", String.class),
- OWNER_ID("ownerId", String.class),
- REQUIRED_OCCURRENCES("requiredOccurrences", String.class),
- LEFT_OCCURRENCES("leftOccurrences", String.class),
- GET_INPUT_INDEX("get_input_index", String.class);
-
- private final String property;
- private final Class<?> clazz;
-
- public static List<String> getAllProperties() {
-
- List<String> arrayList = new ArrayList<>();
-
- for (GraphEdgePropertiesDictionary graphProperty : GraphEdgePropertiesDictionary.values()) {
- arrayList.add(graphProperty.getProperty());
- }
-
- return arrayList;
- }
-
- public static GraphEdgePropertiesDictionary getByName(String property) {
- for (GraphEdgePropertiesDictionary inst : GraphEdgePropertiesDictionary.values()) {
- if (inst.getProperty().equals(property)) {
- return inst;
- }
- }
- return null;
- }
+ // field name class type
+
+ // stored in graph
+ // @formatter:off
+ STATE("state", String.class),
+ NAME("name", String.class),
+ GROUP_TYPE("groupType", String.class),
+ SOURCE("source", String.class),
+ OWNER_ID("ownerId", String.class),
+ REQUIRED_OCCURRENCES("requiredOccurrences", String.class),
+ LEFT_OCCURRENCES("leftOccurrences", String.class),
+ GET_INPUT_INDEX("get_input_index", String.class);
+ // @formatter:on
+
+ private final String property;
+ private final Class<?> clazz;
+
+ public static List<String> getAllProperties() {
+ List<String> arrayList = new ArrayList<>();
+ for (GraphEdgePropertiesDictionary graphProperty : GraphEdgePropertiesDictionary.values()) {
+ arrayList.add(graphProperty.getProperty());
+ }
+ return arrayList;
+ }
+
+ public static GraphEdgePropertiesDictionary getByName(String property) {
+ for (GraphEdgePropertiesDictionary inst : GraphEdgePropertiesDictionary.values()) {
+ if (inst.getProperty().equals(property)) {
+ return inst;
+ }
+ }
+ return null;
+ }
}
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 8581895681..a940c8d3f0 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
@@ -7,9 +7,9 @@
* 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.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.neo4j;
import lombok.AllArgsConstructor;
@@ -26,140 +25,142 @@ import lombok.Getter;
@AllArgsConstructor
@Getter
public enum GraphPropertiesDictionary {
-// field name class type unique indexed
-// stored in graph index
- // Common
- LABEL ("nodeLabel", String.class, false, true),
- HEALTH_CHECK ("healthcheckis", String.class, true, true),
- // Resource
- NAME ("name", String.class, false, true),
- TOSCA_RESOURCE_NAME ("toscaResourceName", String.class, false, true),
- CATEGORY_NAME ("categoryName", String.class, false, true),
- VERSION ("version", String.class, false, true),
- CREATION_DATE ("creationDate", Long.class, false, false),
- LAST_UPDATE_DATE ("modificationDate", Long.class, false, false),
- IS_HIGHEST_VERSION ("highestVersion", Boolean.class, false, true),
- IS_ABSTRACT ("abstract", Boolean.class, false, true),
- DESCRIPTION ("description", String.class, false, false),
- UNIQUE_ID ("uid", String.class, true, true),
- STATE ("state", String.class, false, true),
- TYPE ("type", String.class, false, true),
- REQUIRED ("required", Boolean.class, false, false),
- DEFAULT_VALUE ("defaultValue", String.class, false, false),
- CONSTRAINTS ("constraints", String.class, false, false),
- 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),
- COST ("cost", String.class, false, false),
- LICENSE_TYPE ("licenseType", String.class, false, false),
- NORMALIZED_NAME ("normalizedName", String.class, false, true),
- SYSTEM_NAME ("systemName", String.class, false, true),
- IS_DELETED ("deleted", Boolean.class, false, true),
- RESOURCE_TYPE ("resourceType", String.class, false, true),
- ENTRY_SCHEMA ("entry_schema", String.class, false, false),
- CSAR_UUID ("csarUuid", String.class, false, true),
- CSAR_VERSION ("csarVersion", String.class, false, true),
- IMPORTED_TOSCA_CHECKSUM ("importedToscaChecksum", String.class, false, true),
- GENERATED ("generated", Boolean.class, false, false),
- // User
- USERID ("userId", String.class, true, true),
- EMAIL ("email", String.class, false, false),
- FIRST_NAME ("firstName", String.class, false, false),
- LAST_NAME ("lastName", String.class, false, false),
- ROLE ("role", String.class, false, true),
- USER_STATUS ("status", String.class, false, true),
- VALID_SOURCE_TYPES ("validSourceTypes", String.class, false, false),
+ // @formatter:off
+ // field name class type unique indexed
+ // stored in graph index
+ // Common
+ LABEL ("nodeLabel", String.class, false, true),
+ HEALTH_CHECK ("healthcheckis", String.class, true, true),
+ // Resource
+ NAME ("name", String.class, false, true),
+ TOSCA_RESOURCE_NAME ("toscaResourceName", String.class, false, true),
+ CATEGORY_NAME ("categoryName", String.class, false, true),
+ VERSION ("version", String.class, false, true),
+ CREATION_DATE ("creationDate", Long.class, false, false),
+ LAST_UPDATE_DATE ("modificationDate", Long.class, false, false),
+ IS_HIGHEST_VERSION ("highestVersion", Boolean.class, false, true),
+ IS_ABSTRACT ("abstract", Boolean.class, false, true),
+ DESCRIPTION ("description", String.class, false, false),
+ UNIQUE_ID ("uid", String.class, true, true),
+ STATE ("state", String.class, false, true),
+ TYPE ("type", String.class, false, true),
+ REQUIRED ("required", Boolean.class, false, false),
+ DEFAULT_VALUE ("defaultValue", String.class, false, false),
+ CONSTRAINTS ("constraints", String.class, false, false),
+ 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),
+ COST ("cost", String.class, false, false),
+ LICENSE_TYPE ("licenseType", String.class, false, false),
+ NORMALIZED_NAME ("normalizedName", String.class, false, true),
+ SYSTEM_NAME ("systemName", String.class, false, true),
+ IS_DELETED ("deleted", Boolean.class, false, true),
+ RESOURCE_TYPE ("resourceType", String.class, false, true),
+ ENTRY_SCHEMA ("entry_schema", String.class, false, false),
+ CSAR_UUID ("csarUuid", String.class, false, true),
+ CSAR_VERSION ("csarVersion", String.class, false, true),
+ IMPORTED_TOSCA_CHECKSUM ("importedToscaChecksum", String.class, false, true),
+ GENERATED ("generated", Boolean.class, false, false),
+ // User
+ USERID ("userId", String.class, true, true),
+ EMAIL ("email", String.class, false, false),
+ FIRST_NAME ("firstName", String.class, false, false),
+ LAST_NAME ("lastName", String.class, false, false),
+ ROLE ("role", String.class, false, true),
+ USER_STATUS ("status", String.class, false, true),
+ VALID_SOURCE_TYPES ("validSourceTypes", String.class, false, false),
VALID_TARGET_TYPES ("validTargetTypes", String.class, false, false),
NODE ("node", String.class, false, false),
- VALUE ("value", String.class, false, false),
- HIDDEN ("Hidden", Boolean.class, false, false),
- PROPERTIES ("properties", String.class, false, false),
- POSITION_X ("positionX", String.class, false, false),
- POSITION_Y ("positionY", String.class, false, false),
- RELATIONSHIP_TYPE ("relationshipType", String.class, false, false),
- ARTIFACT_TYPE ("artifactType", String.class, false, true),
- ARTIFACT_REF ("artifactRef", String.class, false, false),
- ARTIFACT_REPOSITORY ("artifactRepository", String.class, false, false),
- ARTIFACT_CHECKSUM ("artifactChecksum", String.class, false, false),
- CREATOR ("creator", String.class, false, false),
- CREATOR_ID ("creatorId", String.class, false, false),
- LAST_UPDATER ("lastUpdater", String.class, false, false),
- CREATOR_FULL_NAME ("creatorFullName", String.class, false, false),
- UPDATER_FULL_NAME ("updaterFullName", String.class, false, false),
- ES_ID ("esId", String.class, false, false),
- ARTIFACT_LABEL ("artifactLabel", String.class, false, true),
- ARTIFACT_DISPLAY_NAME("artifactDisplayName", String.class, false, true),
- INSTANCE_COUNTER ("instanceCounter", Integer.class, false, false),
- PROJECT_CODE ("projectCode", String.class, false, false),
- DISTRIBUTION_STATUS ("distributionStatus", String.class, false, false),
- IS_VNF ("isVNF", Boolean.class, false, false),
- LAST_LOGIN_TIME ("lastLoginTime", Long.class, false, true),
- ATTRIBUTE_COUNTER ("attributeCounter", Integer.class, false, false),
- INPUT_COUNTER ("inputCounter", Integer.class, false, false),
- PROPERTY_COUNTER ("propertyCounter", Integer.class, false, false),
- API_URL ("apiUrl", String.class, false, false),
- SERVICE_API ("serviceApi", Boolean.class, false, true),
- ADDITIONAL_INFO_PARAMS ("additionalInfo", String.class, false, false),
- ADDITIONAL_INFO_ID_TO_KEY ("idToKey", String.class, false, false),
- ARTIFACT_GROUP_TYPE ("artifactGroupType", String.class, false, true),
- ARTIFACT_TIMEOUT ("timeout", Integer.class, false, false),
- IS_ACTIVE ("isActive", Boolean.class, false, true),
- PROPERTY_VALUE_RULES ("propertyValueRules", String.class, false, false),
- //authantication
- CONSUMER_NAME ("consumerName", String.class, true, true),
- CONSUMER_PASSWORD ("consumerPassword", String.class, false, false),
- CONSUMER_SALT ("consumerSalt", String.class, false, false),
- CONSUMER_LAST_AUTHENTICATION_TIME ("consumerLastAuthenticationTime", Long.class, false, false),
- CONSUMER_DETAILS_LAST_UPDATED_TIME ("consumerDetailsLastupdatedtime", Long.class, false, false),
- LAST_MODIFIER_USER_ID("lastModfierUserId", String.class, false, false),
- ARTIFACT_VERSION ("artifactVersion", String.class, false, false),
- ARTIFACT_UUID ("artifactUUID", String.class, false, false),
- PAYLOAD_UPDATE_DATE ("payloadUpdateDate", Long.class, false, false),
- HEAT_PARAMS_UPDATE_DATE ("heatParamsUpdateDate",Long.class, false, false),
- //product
- FULL_NAME ("fullName", String.class, false, true),
- //was changed as part of migration from 1602 to 1602 ( in 1602 was defined as unique. it's problem to reconfigure the index )
- CONSTANT_UUID ("constantUuidNew", String.class, false, true),
- CONTACTS ("contacts", String.class, false, false),
- //categorys
- ICONS ("icons", String.class, false, false),
- METADATA_KEYS ("metadataKeys", String.class, false, false),
- USE_SERVICE_SUBSTITUTION_FOR_NESTED_SERVICES ("useServiceSubstitutionForNestedServices", Boolean.class, false, false),
- //relation
- CAPABILITY_OWNER_ID ("capOwnerId", String.class, false, false),
- REQUIREMENT_OWNER_ID ("reqOwnerId", String.class, false, false),
- CAPABILITY_ID ("capabiltyId", String.class, false, false),
- REQUIREMENT_ID ("requirementId", String.class, false, false),
- PROPERTY_ID ("propertyId", String.class, false, false),
- PROPERTY_NAME ("propertyName", String.class, false, false),
- //component instance
- ORIGIN_TYPE ("originType", String.class, false, false),
- //requirement & capabilty
- MIN_OCCURRENCES ("minOccurrences", String.class, false, false),
- MAX_OCCURRENCES ("maxOccurrences", String.class, false, false),
- //Data type
- DERIVED_FROM ("derivedFrom", String.class, false, false),
- MEMBERS ("members", String.class, false, false),
- TARGETS ("targets ", String.class, false, false),
- METADATA ("metadata", String.class, false, false),
- INVARIANT_UUID ("invariantUuid", String.class, false, true),
- IS_BASE ("isBase", Boolean.class, false, true),
- GROUP_UUID ("groupUuid", String.class, false, true),
- STATUS ("status", String.class, false, false),
- FUNCTIONAL_MENU ("functionalMenu", String.class, false, false),
- REQUIRED_ARTIFACTS ("requiredArtifacts", String.class, false, false),
- CUSTOMIZATION_UUID ("customizationUUID", String.class, false, false),
- IS_ARCHIVED ("isArchived", Boolean.class, false, true),
- IS_VSP_ARCHIVED ("isVspArchived", Boolean.class, false, true),
- ARCHIVE_TIME ("archiveTime", Long.class, false, true);
+ VALUE ("value", String.class, false, false),
+ HIDDEN ("Hidden", Boolean.class, false, false),
+ PROPERTIES ("properties", String.class, false, false),
+ POSITION_X ("positionX", String.class, false, false),
+ POSITION_Y ("positionY", String.class, false, false),
+ RELATIONSHIP_TYPE ("relationshipType", String.class, false, false),
+ ARTIFACT_TYPE ("artifactType", String.class, false, true),
+ ARTIFACT_REF ("artifactRef", String.class, false, false),
+ ARTIFACT_REPOSITORY ("artifactRepository", String.class, false, false),
+ ARTIFACT_CHECKSUM ("artifactChecksum", String.class, false, false),
+ CREATOR ("creator", String.class, false, false),
+ CREATOR_ID ("creatorId", String.class, false, false),
+ LAST_UPDATER ("lastUpdater", String.class, false, false),
+ CREATOR_FULL_NAME ("creatorFullName", String.class, false, false),
+ UPDATER_FULL_NAME ("updaterFullName", String.class, false, false),
+ ES_ID ("esId", String.class, false, false),
+ ARTIFACT_LABEL ("artifactLabel", String.class, false, true),
+ ARTIFACT_DISPLAY_NAME("artifactDisplayName", String.class, false, true),
+ INSTANCE_COUNTER ("instanceCounter", Integer.class, false, false),
+ PROJECT_CODE ("projectCode", String.class, false, false),
+ DISTRIBUTION_STATUS ("distributionStatus", String.class, false, false),
+ IS_VNF ("isVNF", Boolean.class, false, false),
+ LAST_LOGIN_TIME ("lastLoginTime", Long.class, false, true),
+ ATTRIBUTE_COUNTER ("attributeCounter", Integer.class, false, false),
+ INPUT_COUNTER ("inputCounter", Integer.class, false, false),
+ PROPERTY_COUNTER ("propertyCounter", Integer.class, false, false),
+ API_URL ("apiUrl", String.class, false, false),
+ SERVICE_API ("serviceApi", Boolean.class, false, true),
+ ADDITIONAL_INFO_PARAMS ("additionalInfo", String.class, false, false),
+ ADDITIONAL_INFO_ID_TO_KEY ("idToKey", String.class, false, false),
+ ARTIFACT_GROUP_TYPE ("artifactGroupType", String.class, false, true),
+ ARTIFACT_TIMEOUT ("timeout", Integer.class, false, false),
+ IS_ACTIVE ("isActive", Boolean.class, false, true),
+ PROPERTY_VALUE_RULES ("propertyValueRules", String.class, false, false),
+ //authantication
+ CONSUMER_NAME ("consumerName", String.class, true, true),
+ CONSUMER_PASSWORD ("consumerPassword", String.class, false, false),
+ CONSUMER_SALT ("consumerSalt", String.class, false, false),
+ CONSUMER_LAST_AUTHENTICATION_TIME ("consumerLastAuthenticationTime", Long.class, false, false),
+ CONSUMER_DETAILS_LAST_UPDATED_TIME ("consumerDetailsLastupdatedtime", Long.class, false, false),
+ LAST_MODIFIER_USER_ID("lastModfierUserId", String.class, false, false),
+ ARTIFACT_VERSION ("artifactVersion", String.class, false, false),
+ ARTIFACT_UUID ("artifactUUID", String.class, false, false),
+ PAYLOAD_UPDATE_DATE ("payloadUpdateDate", Long.class, false, false),
+ HEAT_PARAMS_UPDATE_DATE ("heatParamsUpdateDate",Long.class, false, false),
+ //product
+ FULL_NAME ("fullName", String.class, false, true),
+ //was changed as part of migration from 1602 to 1602 ( in 1602 was defined as unique. it's problem to reconfigure the index )
+ CONSTANT_UUID ("constantUuidNew", String.class, false, true),
+ CONTACTS ("contacts", String.class, false, false),
+ //categorys
+ ICONS ("icons", String.class, false, false),
+ METADATA_KEYS ("metadataKeys", String.class, false, false),
+ USE_SERVICE_SUBSTITUTION_FOR_NESTED_SERVICES ("useServiceSubstitutionForNestedServices", Boolean.class, false, false),
+ //relation
+ CAPABILITY_OWNER_ID ("capOwnerId", String.class, false, false),
+ REQUIREMENT_OWNER_ID ("reqOwnerId", String.class, false, false),
+ CAPABILITY_ID ("capabiltyId", String.class, false, false),
+ REQUIREMENT_ID ("requirementId", String.class, false, false),
+ PROPERTY_ID ("propertyId", String.class, false, false),
+ PROPERTY_NAME ("propertyName", String.class, false, false),
+ //component instance
+ ORIGIN_TYPE ("originType", String.class, false, false),
+ //requirement & capabilty
+ MIN_OCCURRENCES ("minOccurrences", String.class, false, false),
+ MAX_OCCURRENCES ("maxOccurrences", String.class, false, false),
+ //Data type
+ DERIVED_FROM ("derivedFrom", String.class, false, false),
+ MEMBERS ("members", String.class, false, false),
+ TARGETS ("targets ", String.class, false, false),
+ METADATA ("metadata", String.class, false, false),
+ INVARIANT_UUID ("invariantUuid", String.class, false, true),
+ IS_BASE ("isBase", Boolean.class, false, true),
+ GROUP_UUID ("groupUuid", String.class, false, true),
+ STATUS ("status", String.class, false, false),
+ FUNCTIONAL_MENU ("functionalMenu", String.class, false, false),
+ REQUIRED_ARTIFACTS ("requiredArtifacts", String.class, false, false),
+ CUSTOMIZATION_UUID ("customizationUUID", String.class, false, false),
+ IS_ARCHIVED ("isArchived", Boolean.class, false, true),
+ IS_VSP_ARCHIVED ("isVspArchived", Boolean.class, false, true),
+ ARCHIVE_TIME ("archiveTime", Long.class, false, true);
+ // @formatter:on
+
+ private final String property;
+ private final Class<?> clazz;
+ private final boolean unique;
+ private final boolean indexed;
- private final String property;
- private final Class<?> clazz;
- private final boolean unique;
- private final boolean indexed;
-
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/GraphPropertiesDictionaryExtractor.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/GraphPropertiesDictionaryExtractor.java
index 1a7ff29298..0701da5ad4 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/GraphPropertiesDictionaryExtractor.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/GraphPropertiesDictionaryExtractor.java
@@ -17,23 +17,18 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.neo4j;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
-import org.openecomp.sdc.be.datatypes.components.ResourceMetadataDataDefinition;
-import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
-import org.springframework.beans.factory.annotation.Autowired;
-
import java.lang.reflect.Type;
import java.util.List;
import java.util.Map;
+import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
public class GraphPropertiesDictionaryExtractor {
private Map<String, Object> properties;
-
private Gson gson = new Gson();
public GraphPropertiesDictionaryExtractor(Map<String, Object> properties) {
@@ -75,10 +70,11 @@ public class GraphPropertiesDictionaryExtractor {
@SuppressWarnings("unchecked")
public List<String> getTags() {
List<String> tagsFromJson;
- if(properties.get(GraphPropertiesDictionary.TAGS.getProperty()) instanceof List<?>){
+ if (properties.get(GraphPropertiesDictionary.TAGS.getProperty()) instanceof List<?>) {
tagsFromJson = (List<String>) properties.get(GraphPropertiesDictionary.TAGS.getProperty());
} else {
- Type listType = new TypeToken<List<String>>() {}.getType();
+ Type listType = new TypeToken<List<String>>() {
+ }.getType();
tagsFromJson = gson.fromJson((String) properties.get(GraphPropertiesDictionary.TAGS.getProperty()), listType);
}
return tagsFromJson;
@@ -146,7 +142,7 @@ public class GraphPropertiesDictionaryExtractor {
public ResourceTypeEnum getResourceType() {
if (properties.get(GraphPropertiesDictionary.RESOURCE_TYPE.getProperty()) != null) {
- return ResourceTypeEnum.valueOf((String) properties.get(GraphPropertiesDictionary.RESOURCE_TYPE.getProperty()));
+ return ResourceTypeEnum.valueOf((String) properties.get(GraphPropertiesDictionary.RESOURCE_TYPE.getProperty()));
} else {
return null;
}
@@ -177,12 +173,12 @@ public class GraphPropertiesDictionaryExtractor {
}
public List<String> getContacts() {
- Type listType = new TypeToken<List<String>>() {}.getType();
+ Type listType = new TypeToken<List<String>>() {
+ }.getType();
return gson.fromJson((String) properties.get(GraphPropertiesDictionary.CONTACTS.getProperty()), listType);
}
public Boolean isActive() {
return (Boolean) properties.get(GraphPropertiesDictionary.IS_ACTIVE.getProperty());
}
-
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/utils/CollectionUtils.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/utils/CollectionUtils.java
index 15bef3b23b..1a6017c582 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/utils/CollectionUtils.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/utils/CollectionUtils.java
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.utils;
import java.util.ArrayList;
@@ -30,6 +29,7 @@ import java.util.Map.Entry;
import java.util.Set;
public final class CollectionUtils {
+
private CollectionUtils() {
}
@@ -38,18 +38,14 @@ public final class CollectionUtils {
}
/**
- * Add the content of the 'source' Set to the 'target' set and return the
- * union set.
+ * Add the content of the 'source' Set to the 'target' set and return the union set.
* <p>
- * If 'source' is null then a new set is created and returned. If 'target'
- * is null then no content is added to the 'source' Set or newly created
+ * If 'source' is null then a new set is created and returned. If 'target' is null then no content is added to the 'source' Set or newly created
* set.
*
* @param source The Set to merge in the target Set.
- * @param target The Set in which the source set will be merged (through
- * addAll).
- * @return The target Set with addition of source Set elements, or a new Set
- * (including content of source set) if target was null.
+ * @param target The Set in which the source set will be merged (through addAll).
+ * @return The target Set with addition of source Set elements, or a new Set (including content of source set) if target was null.
*/
public static <T> Set<T> merge(Set<T> source, Set<T> target) {
Set<T> merged = new HashSet<>();
@@ -64,28 +60,22 @@ public final class CollectionUtils {
/**
* <p>
- * Add the content of the 'source' Map to the 'target' set and return the
- * union Map.
+ * Add the content of the 'source' Map to the 'target' set and return the union Map.
* </p>
* <p>
- * If 'source' is null then a new Map is created and returned. If 'target'
- * is null then no content is added to the 'source' Map or newly created
+ * If 'source' is null then a new Map is created and returned. If 'target' is null then no content is added to the 'source' Map or newly created
* Map.
* </p>
*
* @param source The Map to merge in the target Map.
- * @param target The Map in which the source Map will be merged (through
- * addAll).
- * @param override If an key from the source map already exists in the target
- * map, should it override (true) or not (false) the value.
- * @return The target Map with addition of source Map elements, or a new Map
- * (including content of source set) if target was null.
+ * @param target The Map in which the source Map will be merged (through addAll).
+ * @param override If an key from the source map already exists in the target map, should it override (true) or not (false) the value.
+ * @return The target Map with addition of source Map elements, or a new Map (including content of source set) if target was null.
*/
public static <T, V> Map<T, V> merge(Map<T, ? extends V> source, Map<T, V> target, boolean override) {
if (target == null) {
target = new HashMap();
}
-
if (source != null) {
for (Entry<T, ? extends V> entry : source.entrySet()) {
if (override || !target.containsKey(entry.getKey())) {
@@ -97,8 +87,7 @@ public final class CollectionUtils {
}
/**
- * Merge two lists, the merge is performed based on the contains method so
- * elements presents both in source and target are not added twice to the
+ * Merge two lists, the merge is performed based on the contains method so elements presents both in source and target are not added twice to the
* list.
*
* @param source The source list.
@@ -107,24 +96,20 @@ public final class CollectionUtils {
*/
public static <T> List<T> merge(List<T> source, List<T> target) {
List<T> merged = target == null ? new ArrayList<>() : target;
-
if (source == null) {
return merged;
}
-
for (T t : source) {
if (!merged.contains(t)) {
merged.add(t);
}
}
-
return merged;
}
/**
- * Returns a new list containing the second list appended to the
- * first list. The {@link List#addAll(Collection)} operation is
- * used to append the two given lists into a new list.
+ * Returns a new list containing the second list appended to the first list. The {@link List#addAll(Collection)} operation is used to append the
+ * two given lists into a new list.
*
* @param list1 the first list
* @param list2 the second list
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/utils/Constants.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/utils/Constants.java
index 4487e51a55..50bdfb4301 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/utils/Constants.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/utils/Constants.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,22 +17,20 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.utils;
/**
* Holds constants to use in ALIEN.
*/
public final class Constants {
- public static final int DEFAULT_ES_SEARCH_SIZE = 50;
- public static final int MAX_ES_SEARCH_SIZE = 100;
-
- public static final String ALIEN_INTERNAL_TAG = "icon";
- public static final String DEFAULT_CAPABILITY_FIELD_NAME = "defaultCapabilities";
- public static final String GROUP_NAME_ALL_USERS = "ALL_USERS";
- public static final String GRAPH_EMPTY_VALUE = "__NANANA__";
+ public static final int DEFAULT_ES_SEARCH_SIZE = 50;
+ public static final int MAX_ES_SEARCH_SIZE = 100;
+ public static final String ALIEN_INTERNAL_TAG = "icon";
+ public static final String DEFAULT_CAPABILITY_FIELD_NAME = "defaultCapabilities";
+ public static final String GROUP_NAME_ALL_USERS = "ALL_USERS";
+ public static final String GRAPH_EMPTY_VALUE = "__NANANA__";
- private Constants() {
- }
+ private Constants() {
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/utils/DaoUtils.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/utils/DaoUtils.java
index 35941dea89..6c9e43c8b7 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/utils/DaoUtils.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/utils/DaoUtils.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,51 +17,48 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.utils;
import com.google.gson.Gson;
/**
- *
* @author Evgenia Alberstein
- *
- * Utility class for convertation to/from JSON string
+ * <p>
+ * Utility class for convertation to/from JSON string
*/
public class DaoUtils {
-
- private DaoUtils() {
-
- }
-
- /**
- * Convert from Object to Json string
- *
- * @param object
- * @return json string
- */
- public static String convertToJson(Object object) {
- if (object == null) {
- throw new RuntimeException("The object cannot be NULL!!!");
- }
- Gson gson = new Gson(); // Or use new GsonBuilder().create();
- return gson.toJson(object); // serializes target to Json
- }
- /**
- * Convert from Json string to object
- *
- * @param clazz
- * @param json
- * @return object
- */
- public static <T> T convertFromJson(Class<T> clazz, String json) {
- if (clazz == null) {
- throw new RuntimeException("The Class cannot be NULL!!!");
- }
-
- Gson gson = new Gson(); // Or use new GsonBuilder().create();
- return gson.fromJson(json, clazz); // deserializes json into target2
- }
+ private DaoUtils() {
+ }
+
+ /**
+ * Convert from Object to Json string
+ *
+ * @param object
+ * @return json string
+ */
+ public static String convertToJson(Object object) {
+ if (object == null) {
+ throw new RuntimeException("The object cannot be NULL!!!");
+ }
+ Gson gson = new Gson(); // Or use new GsonBuilder().create();
+
+ return gson.toJson(object); // serializes target to Json
+ }
+
+ /**
+ * Convert from Json string to object
+ *
+ * @param clazz
+ * @param json
+ * @return object
+ */
+ public static <T> T convertFromJson(Class<T> clazz, String json) {
+ if (clazz == null) {
+ throw new RuntimeException("The Class cannot be NULL!!!");
+ }
+ Gson gson = new Gson(); // Or use new GsonBuilder().create();
+ return gson.fromJson(json, clazz); // deserializes json into target2
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/utils/JsonUtil.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/utils/JsonUtil.java
index 92ba61bcc7..ebcb1d5271 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/utils/JsonUtil.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/utils/JsonUtil.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.utils;
import com.fasterxml.jackson.annotation.JsonInclude;
@@ -27,7 +26,6 @@ import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
-
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
@@ -38,118 +36,113 @@ import java.util.Map;
* Simple utility for JSon processing.
*/
public final class JsonUtil {
- private static ObjectMapper getOneObjectMapper() {
- ObjectMapper mapper = new ObjectMapper();
- mapper.enable(SerializationFeature.INDENT_OUTPUT);
- mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
- mapper.configure(SerializationFeature.WRITE_NULL_MAP_VALUES, false);
- return mapper;
- }
- private JsonUtil() {
- // No instances allowed
- }
+ private JsonUtil() {
+ // No instances allowed
+ }
+
+ private static ObjectMapper getOneObjectMapper() {
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.enable(SerializationFeature.INDENT_OUTPUT);
+ mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
+ mapper.configure(SerializationFeature.WRITE_NULL_MAP_VALUES, false);
+ return mapper;
+ }
- /**
- * Deserialize json text to object
- *
- * @param objectText
- * @param objectClass
- * @return
- * @throws JsonParseException
- * @throws JsonMappingException
- * @throws IOException
- */
- public static <T> T readObject(String objectText, Class<T> objectClass) throws IOException {
- return getOneObjectMapper().readValue(objectText, objectClass);
- }
+ /**
+ * Deserialize json text to object
+ *
+ * @param objectText
+ * @param objectClass
+ * @return
+ * @throws JsonParseException
+ * @throws JsonMappingException
+ * @throws IOException
+ */
+ public static <T> T readObject(String objectText, Class<T> objectClass) throws IOException {
+ return getOneObjectMapper().readValue(objectText, objectClass);
+ }
- /**
- * Deserialize json stream to object
- *
- * @param jsonStream
- * @param objectClass
- * @return
- * @throws JsonParseException
- * @throws JsonMappingException
- * @throws IOException
- */
- public static <T> T readObject(InputStream jsonStream, Class<T> objectClass) throws IOException {
- return getOneObjectMapper().readValue(jsonStream, objectClass);
- }
+ /**
+ * Deserialize json stream to object
+ *
+ * @param jsonStream
+ * @param objectClass
+ * @return
+ * @throws JsonParseException
+ * @throws JsonMappingException
+ * @throws IOException
+ */
+ public static <T> T readObject(InputStream jsonStream, Class<T> objectClass) throws IOException {
+ return getOneObjectMapper().readValue(jsonStream, objectClass);
+ }
- /**
- * Deserialize json text to object
- *
- * @param objectText
- * @return
- * @throws JsonParseException
- * @throws JsonMappingException
- * @throws IOException
- */
- public static <T> T readObject(String objectText) throws IOException {
- TypeReference<T> typeRef = new TypeReference<T>() {
- };
- return getOneObjectMapper().readValue(objectText, typeRef);
- }
+ /**
+ * Deserialize json text to object
+ *
+ * @param objectText
+ * @return
+ * @throws JsonParseException
+ * @throws JsonMappingException
+ * @throws IOException
+ */
+ public static <T> T readObject(String objectText) throws IOException {
+ TypeReference<T> typeRef = new TypeReference<T>() {
+ };
+ return getOneObjectMapper().readValue(objectText, typeRef);
+ }
- /**
- * Deserialize the given json string to a map
- *
- * @param json
- * json text
- * @return map object
- * @throws IOException
- */
- public static Map<String, Object> toMap(String json) throws IOException {
- ObjectMapper mapper = getOneObjectMapper();
- JavaType mapStringObjectType = mapper.getTypeFactory().constructParametricType(HashMap.class, String.class,
- Object.class);
- return mapper.readValue(json, mapStringObjectType);
- }
+ /**
+ * Deserialize the given json string to a map
+ *
+ * @param json json text
+ * @return map object
+ * @throws IOException
+ */
+ public static Map<String, Object> toMap(String json) throws IOException {
+ ObjectMapper mapper = getOneObjectMapper();
+ JavaType mapStringObjectType = mapper.getTypeFactory().constructParametricType(HashMap.class, String.class, Object.class);
+ return mapper.readValue(json, mapStringObjectType);
+ }
- /**
- * Deserialize the given json string to a map
- *
- * @param json
- * @param keyTypeClass
- * @param valueTypeClass
- * @return
- * @throws IOException
- */
- public static <K, V> Map<K, V> toMap(String json, Class<K> keyTypeClass, Class<V> valueTypeClass)
- throws IOException {
- ObjectMapper mapper = getOneObjectMapper();
- JavaType mapStringObjectType = mapper.getTypeFactory().constructParametricType(HashMap.class, keyTypeClass,
- valueTypeClass);
- return mapper.readValue(json, mapStringObjectType);
- }
+ /**
+ * Deserialize the given json string to a map
+ *
+ * @param json
+ * @param keyTypeClass
+ * @param valueTypeClass
+ * @return
+ * @throws IOException
+ */
+ public static <K, V> Map<K, V> toMap(String json, Class<K> keyTypeClass, Class<V> valueTypeClass) throws IOException {
+ ObjectMapper mapper = getOneObjectMapper();
+ JavaType mapStringObjectType = mapper.getTypeFactory().constructParametricType(HashMap.class, keyTypeClass, valueTypeClass);
+ return mapper.readValue(json, mapStringObjectType);
+ }
- public static <V> V[] toArray(String json, Class<V> valueTypeClass) throws IOException {
- ObjectMapper mapper = getOneObjectMapper();
- JavaType arrayStringObjectType = mapper.getTypeFactory().constructArrayType(valueTypeClass);
- return mapper.readValue(json, arrayStringObjectType);
- }
+ public static <V> V[] toArray(String json, Class<V> valueTypeClass) throws IOException {
+ ObjectMapper mapper = getOneObjectMapper();
+ JavaType arrayStringObjectType = mapper.getTypeFactory().constructArrayType(valueTypeClass);
+ return mapper.readValue(json, arrayStringObjectType);
+ }
- /**
- * Deserialize the given json string to a list
- *
- * @param json
- * json text
- * @return list object
- * @throws IOException
- */
- public static <T> List<T> toList(String json, Class<T> clazz) throws IOException {
- ObjectMapper mapper = getOneObjectMapper();
- JavaType type = mapper.getTypeFactory().constructCollectionType(List.class, clazz);
- return mapper.readValue(json, type);
- }
+ /**
+ * Deserialize the given json string to a list
+ *
+ * @param json json text
+ * @return list object
+ * @throws IOException
+ */
+ public static <T> List<T> toList(String json, Class<T> clazz) throws IOException {
+ ObjectMapper mapper = getOneObjectMapper();
+ JavaType type = mapper.getTypeFactory().constructCollectionType(List.class, clazz);
+ return mapper.readValue(json, type);
+ }
- public static <T> List<T> toList(String json, Class<T> elementClass, Class<?> elementGenericClass)
- throws IOException {
- ObjectMapper mapper = getOneObjectMapper();
- JavaType elementType = mapper.getTypeFactory().constructParametricType(elementClass, elementGenericClass);
- JavaType listType = mapper.getTypeFactory().constructCollectionType(List.class, elementType);
- return mapper.readValue(json, listType);
- }
+ public static <T> List<T> toList(String json, Class<T> elementClass, Class<?> elementGenericClass) throws IOException {
+ ObjectMapper mapper = getOneObjectMapper();
+ JavaType elementType = mapper.getTypeFactory().constructParametricType(elementClass, elementGenericClass);
+ JavaType listType = mapper.getTypeFactory().constructCollectionType(List.class, elementType);
+ return mapper.readValue(json, listType);
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/utils/MapUtil.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/utils/MapUtil.java
index 5b0ad9cc24..027d3f77a1 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/utils/MapUtil.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/utils/MapUtil.java
@@ -17,26 +17,30 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.utils;
-import java.util.*;
+import static java.util.stream.Collectors.toList;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import java.util.function.BinaryOperator;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
-import static java.util.stream.Collectors.toList;
/**
* Utility class to ease map manipulation.
*/
public final class MapUtil {
+
private MapUtil() {
}
/**
- * Try to get a value following a path in the map. For example :
- * MapUtil.get(map, "a.b.c") correspond to: map.get(a).get(b).get(c)
+ * Try to get a value following a path in the map. For example : MapUtil.get(map, "a.b.c") correspond to: map.get(a).get(b).get(c)
*
* @param map the map to search for path
* @param path keys in the map separated by '.'
@@ -51,8 +55,7 @@ public final class MapUtil {
if (!(value instanceof Map)) {
return null;
} else {
- @SuppressWarnings("unchecked")
- Map<String, Object> nested = (Map<String, Object>) value;
+ @SuppressWarnings("unchecked") Map<String, Object> nested = (Map<String, Object>) value;
if (nested.containsKey(token)) {
value = nested.get(token);
} else {
@@ -81,12 +84,11 @@ public final class MapUtil {
public static <K, V> Map<K, V> toMap(Collection<V> valuesToMap, Function<V, K> mappingFunction) {
return toMap(valuesToMap, mappingFunction, throwingMerger());
}
-
+
public static <K, V> Map<K, V> toMap(Collection<V> valuesToMap, Function<V, K> mappingFunction, BinaryOperator<V> mergeFunction) {
return streamOfNullable(valuesToMap).collect(Collectors.toMap(mappingFunction, Function.identity(), mergeFunction));
}
-
/**
* merge two maps. if a key exists in both maps, takes the value from {@code first}
*
@@ -122,19 +124,15 @@ public final class MapUtil {
* @return a map with converted keys.
*/
public static <K, U, V> Map<U, List<V>> convertMapKeys(Map<K, List<V>> map, Function<K, U> keyMappingFunction) {
- return map.entrySet().stream()
- .collect(Collectors.toMap(entry -> keyMappingFunction.apply(entry.getKey()),
- Map.Entry::getValue));
+ return map.entrySet().stream().collect(Collectors.toMap(entry -> keyMappingFunction.apply(entry.getKey()), Map.Entry::getValue));
}
/**
- * Create a new hash map and fills it from the given keys and values
- * (keys[index] -> values[index].
+ * Create a new hash map and fills it from the given keys and values (keys[index] -> values[index].
*
* @param keys The array of keys.
* @param values The array of values.
- * @return A map that contains for each key element in the keys array a
- * value from the values array at the same index.
+ * @return A map that contains for each key element in the keys array a value from the values array at the same index.
*/
public static <K, V> Map<K, V> newHashMap(K[] keys, V[] values) {
Map<K, V> map = new HashMap<>();
@@ -146,27 +144,26 @@ public final class MapUtil {
}
return map;
}
-
-
+
/**
- * Returns a merge function, suitable for use in
- * {@link Map#merge(Object, Object, BiFunction) Map.merge()} or
- * {@link #toMap(Function, Function, BinaryOperator) toMap()}, which always
- * throws {@code IllegalStateException}. This can be used to enforce the
- * assumption that the elements being collected are distinct.
+ * Returns a merge function, suitable for use in {@link Map#merge(Object, Object, BiFunction) Map.merge()} or {@link #toMap(Function, Function,
+ * BinaryOperator) toMap()}, which always throws {@code IllegalStateException}. This can be used to enforce the assumption that the elements
+ * being collected are distinct.
*
* @param <T> the type of input arguments to the merge function
* @return a merge function which always throw {@code IllegalStateException}
*/
private static <T> BinaryOperator<T> throwingMerger() {
- return (u,v) -> { throw new IllegalStateException(String.format("Duplicate key %s", u)); };
+ return (u, v) -> {
+ throw new IllegalStateException(String.format("Duplicate key %s", u));
+ };
}
public static <V> Stream<V> streamOfNullable(Collection<V> collection) {
- return collection == null? Stream.empty(): collection.stream();
+ return collection == null ? Stream.empty() : collection.stream();
}
-
- public static<T> Stream<T> streamOfNullable(T t) {
+
+ public static <T> Stream<T> streamOfNullable(T t) {
return t == null ? Stream.empty() : Stream.of(t);
}
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/utils/TypeMap.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/utils/TypeMap.java
index 6c860dd269..b1caa0a25d 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/utils/TypeMap.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/utils/TypeMap.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,47 +17,42 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.utils;
import java.util.HashMap;
import java.util.Map;
public class TypeMap {
- private Map<Class<? extends Object>, Map<String, Object>> cacheMap = new HashMap<>();
- private Map<String, Object> getMap(Class<? extends Object> clazz) {
- Map<String, Object> map = cacheMap.get(clazz);
- if (map == null) {
- cacheMap.put(clazz, new HashMap<>());
- }
- return cacheMap.get(clazz);
- }
+ private Map<Class<? extends Object>, Map<String, Object>> cacheMap = new HashMap<>();
+
+ private Map<String, Object> getMap(Class<? extends Object> clazz) {
+ Map<String, Object> map = cacheMap.get(clazz);
+ if (map == null) {
+ cacheMap.put(clazz, new HashMap<>());
+ }
+ return cacheMap.get(clazz);
+ }
- /**
- * put an object (value) in it's type map using the given key.
- *
- * @param key
- * The key inside the type map.
- * @param value
- * The object to insert (based on it's type and the given key).
- */
- public void put(String key, Object value) {
- getMap(value.getClass()).put(key, value);
- }
+ /**
+ * put an object (value) in it's type map using the given key.
+ *
+ * @param key The key inside the type map.
+ * @param value The object to insert (based on it's type and the given key).
+ */
+ public void put(String key, Object value) {
+ getMap(value.getClass()).put(key, value);
+ }
- /**
- * Get the cached object based on it's type and key.
- *
- * @param clazz
- * The object's type.
- * @param key
- * The object key.
- * @return The object that match the given type and key or null if none
- * matches.
- */
- @SuppressWarnings("unchecked")
- public <T> T get(Class<T> clazz, String key) {
- return (T) (cacheMap.get(clazz) == null ? null : cacheMap.get(clazz).get(key));
- }
+ /**
+ * Get the cached object based on it's type and key.
+ *
+ * @param clazz The object's type.
+ * @param key The object key.
+ * @return The object that match the given type and key or null if none matches.
+ */
+ @SuppressWarnings("unchecked")
+ public <T> T get(Class<T> clazz, String key) {
+ return (T) (cacheMap.get(clazz) == null ? null : cacheMap.get(clazz).get(key));
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/utils/UserStatusEnum.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/utils/UserStatusEnum.java
index f66914eb9e..1772e543f8 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/utils/UserStatusEnum.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/utils/UserStatusEnum.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,23 +17,22 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.dao.utils;
import fj.data.Either;
import org.openecomp.sdc.common.util.MethodActivationStatusEnum;
public enum UserStatusEnum {
- ACTIVE, INACTIVE;
+ ACTIVE, INACTIVE;
- public static Either<UserStatusEnum, MethodActivationStatusEnum> findByName(String name) {
- Either<UserStatusEnum, MethodActivationStatusEnum> result = Either.right(MethodActivationStatusEnum.NOT_FOUND);
- for (UserStatusEnum status : UserStatusEnum.values()) {
- if (status.name().equals(name)) {
- result = Either.left(status);
- break;
- }
- }
- return result;
- }
+ public static Either<UserStatusEnum, MethodActivationStatusEnum> findByName(String name) {
+ Either<UserStatusEnum, MethodActivationStatusEnum> result = Either.right(MethodActivationStatusEnum.NOT_FOUND);
+ for (UserStatusEnum status : UserStatusEnum.values()) {
+ if (status.name().equals(name)) {
+ result = Either.left(status);
+ break;
+ }
+ }
+ return result;
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/api/ArtifactDataEnum.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/api/ArtifactDataEnum.java
index 39c023dc00..d7177d970a 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/api/ArtifactDataEnum.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/api/ArtifactDataEnum.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,10 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.resources.api;
-public enum ArtifactDataEnum {
- SERVICE_ARTIFACT, COMPONENT_ARTIFACT
-
-}
+public enum ArtifactDataEnum {SERVICE_ARTIFACT, COMPONENT_ARTIFACT}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/AdditionalInfoParameterData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/AdditionalInfoParameterData.java
index 41bdad9e5b..6b32cde98e 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/AdditionalInfoParameterData.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/AdditionalInfoParameterData.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,138 +17,117 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.resources.data;
import com.google.gson.reflect.TypeToken;
+import java.lang.reflect.Type;
+import java.util.HashMap;
+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.datatypes.elements.AdditionalInfoParameterDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import java.lang.reflect.Type;
-import java.util.HashMap;
-import java.util.Map;
-
public class AdditionalInfoParameterData extends GraphNode {
- AdditionalInfoParameterDataDefinition additionalInfoParameterDataDefinition;
-
- private Map<String, String> parameters;
-
- private Map<String, String> idToKey;
-
- public AdditionalInfoParameterData() {
- super(NodeTypeEnum.AdditionalInfoParameters);
- additionalInfoParameterDataDefinition = new AdditionalInfoParameterDataDefinition();
- }
-
- public AdditionalInfoParameterData(AdditionalInfoParameterDataDefinition additionalInfoParameterDataDefinition,
- Map<String, String> parameters, Map<String, String> idToKey) {
- super(NodeTypeEnum.AdditionalInfoParameters);
- this.additionalInfoParameterDataDefinition = additionalInfoParameterDataDefinition;
- this.parameters = parameters;
- this.idToKey = idToKey;
- }
-
- public AdditionalInfoParameterData(Map<String, Object> properties) {
-
- this();
-
- additionalInfoParameterDataDefinition
- .setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
-
- additionalInfoParameterDataDefinition
- .setCreationTime((Long) properties.get(GraphPropertiesDictionary.CREATION_DATE.getProperty()));
-
- additionalInfoParameterDataDefinition
- .setModificationTime((Long) properties.get(GraphPropertiesDictionary.LAST_UPDATE_DATE.getProperty()));
-
- additionalInfoParameterDataDefinition.setLastCreatedCounter(
- (Integer) properties.get(GraphPropertiesDictionary.PROPERTY_COUNTER.getProperty()));
- Type mapType = new TypeToken<HashMap<String, String>>() {
- }.getType();
- HashMap<String, String> prametersfromJson = getGson().fromJson(
- (String) properties.get(GraphPropertiesDictionary.ADDITIONAL_INFO_PARAMS.getProperty()), mapType);
-
- this.setParameters(prametersfromJson);
-
- // this.setParameters((HashMap<String, String>) properties
- // .get(GraphPropertiesDictionary.ADDITIONAL_INFO_PARAMS
- // .getProperty()));
-
- HashMap<String, String> idToKeyfromJson = getGson().fromJson(
- (String) properties.get(GraphPropertiesDictionary.ADDITIONAL_INFO_ID_TO_KEY.getProperty()), mapType);
-
- this.setIdToKey(idToKeyfromJson);
- // this.setIdToKey((HashMap<String, String>) properties
- // .get(GraphPropertiesDictionary.ADDITIONAL_INFO_ID_TO_KEY
- // .getProperty()));
- }
-
- @Override
- public Map<String, Object> toGraphMap() {
-
- Map<String, Object> map = new HashMap<>();
-
- addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, additionalInfoParameterDataDefinition.getUniqueId());
-
- // String parametersToJson = getGson().toJson(getParameters());
-
- // addIfExists(map, GraphPropertiesDictionary.ADDITIONAL_INFO_PARAMS,
- // parametersToJson);
- addIfExists(map, GraphPropertiesDictionary.ADDITIONAL_INFO_PARAMS, getParameters());
-
- // String idToKeyToJson = getGson().toJson(getIdToKey());
- // addIfExists(map, GraphPropertiesDictionary.ADDITIONAL_INFO_ID_TO_KEY,
- // idToKeyToJson);
- addIfExists(map, GraphPropertiesDictionary.ADDITIONAL_INFO_ID_TO_KEY, getIdToKey());
-
- addIfExists(map, GraphPropertiesDictionary.CREATION_DATE,
- additionalInfoParameterDataDefinition.getCreationTime());
-
- addIfExists(map, GraphPropertiesDictionary.LAST_UPDATE_DATE,
- additionalInfoParameterDataDefinition.getModificationTime());
-
- addIfExists(map, GraphPropertiesDictionary.PROPERTY_COUNTER,
- additionalInfoParameterDataDefinition.getLastCreatedCounter());
-
- return map;
- }
-
- @Override
- public String getUniqueId() {
- return additionalInfoParameterDataDefinition.getUniqueId();
- }
-
- public AdditionalInfoParameterDataDefinition getAdditionalInfoParameterDataDefinition() {
- return additionalInfoParameterDataDefinition;
- }
-
- public void setAdditionalInfoParameterDataDefinition(
- AdditionalInfoParameterDataDefinition additionalInfoParameterDataDefinition) {
- this.additionalInfoParameterDataDefinition = additionalInfoParameterDataDefinition;
- }
-
- public Map<String, String> getParameters() {
- return parameters;
- }
-
- public void setParameters(Map<String, String> parameters) {
- this.parameters = parameters;
- }
-
- public Map<String, String> getIdToKey() {
- return idToKey;
- }
-
- public void setIdToKey(Map<String, String> idToKey) {
- this.idToKey = idToKey;
- }
-
- @Override
- public String toString() {
- return "PropertyData [parameters= " + parameters + " idToKey= " + idToKey
- + ", additionalInfoParameterDataDefinition=" + additionalInfoParameterDataDefinition + "]";
- }
+ AdditionalInfoParameterDataDefinition additionalInfoParameterDataDefinition;
+ private Map<String, String> parameters;
+ private Map<String, String> idToKey;
+
+ public AdditionalInfoParameterData() {
+ super(NodeTypeEnum.AdditionalInfoParameters);
+ additionalInfoParameterDataDefinition = new AdditionalInfoParameterDataDefinition();
+ }
+
+ public AdditionalInfoParameterData(AdditionalInfoParameterDataDefinition additionalInfoParameterDataDefinition, Map<String, String> parameters,
+ Map<String, String> idToKey) {
+ super(NodeTypeEnum.AdditionalInfoParameters);
+ this.additionalInfoParameterDataDefinition = additionalInfoParameterDataDefinition;
+ this.parameters = parameters;
+ this.idToKey = idToKey;
+ }
+
+ public AdditionalInfoParameterData(Map<String, Object> properties) {
+ this();
+ additionalInfoParameterDataDefinition.setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
+ additionalInfoParameterDataDefinition.setCreationTime((Long) properties.get(GraphPropertiesDictionary.CREATION_DATE.getProperty()));
+ additionalInfoParameterDataDefinition.setModificationTime((Long) properties.get(GraphPropertiesDictionary.LAST_UPDATE_DATE.getProperty()));
+ additionalInfoParameterDataDefinition
+ .setLastCreatedCounter((Integer) properties.get(GraphPropertiesDictionary.PROPERTY_COUNTER.getProperty()));
+ Type mapType = new TypeToken<HashMap<String, String>>() {
+ }.getType();
+ HashMap<String, String> prametersfromJson = getGson()
+ .fromJson((String) properties.get(GraphPropertiesDictionary.ADDITIONAL_INFO_PARAMS.getProperty()), mapType);
+ this.setParameters(prametersfromJson);
+ // this.setParameters((HashMap<String, String>) properties
+
+ // .get(GraphPropertiesDictionary.ADDITIONAL_INFO_PARAMS
+
+ // .getProperty()));
+ HashMap<String, String> idToKeyfromJson = getGson()
+ .fromJson((String) properties.get(GraphPropertiesDictionary.ADDITIONAL_INFO_ID_TO_KEY.getProperty()), mapType);
+ this.setIdToKey(idToKeyfromJson);
+ // this.setIdToKey((HashMap<String, String>) properties
+
+ // .get(GraphPropertiesDictionary.ADDITIONAL_INFO_ID_TO_KEY
+
+ // .getProperty()));
+ }
+
+ @Override
+ public Map<String, Object> toGraphMap() {
+ Map<String, Object> map = new HashMap<>();
+ addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, additionalInfoParameterDataDefinition.getUniqueId());
+ // String parametersToJson = getGson().toJson(getParameters());
+
+ // addIfExists(map, GraphPropertiesDictionary.ADDITIONAL_INFO_PARAMS,
+
+ // parametersToJson);
+ addIfExists(map, GraphPropertiesDictionary.ADDITIONAL_INFO_PARAMS, getParameters());
+ // String idToKeyToJson = getGson().toJson(getIdToKey());
+
+ // addIfExists(map, GraphPropertiesDictionary.ADDITIONAL_INFO_ID_TO_KEY,
+
+ // idToKeyToJson);
+ addIfExists(map, GraphPropertiesDictionary.ADDITIONAL_INFO_ID_TO_KEY, getIdToKey());
+ addIfExists(map, GraphPropertiesDictionary.CREATION_DATE, additionalInfoParameterDataDefinition.getCreationTime());
+ addIfExists(map, GraphPropertiesDictionary.LAST_UPDATE_DATE, additionalInfoParameterDataDefinition.getModificationTime());
+ addIfExists(map, GraphPropertiesDictionary.PROPERTY_COUNTER, additionalInfoParameterDataDefinition.getLastCreatedCounter());
+ return map;
+ }
+
+ @Override
+ public String getUniqueId() {
+ return additionalInfoParameterDataDefinition.getUniqueId();
+ }
+
+ public AdditionalInfoParameterDataDefinition getAdditionalInfoParameterDataDefinition() {
+ return additionalInfoParameterDataDefinition;
+ }
+
+ public void setAdditionalInfoParameterDataDefinition(AdditionalInfoParameterDataDefinition additionalInfoParameterDataDefinition) {
+ this.additionalInfoParameterDataDefinition = additionalInfoParameterDataDefinition;
+ }
+
+ public Map<String, String> getParameters() {
+ return parameters;
+ }
+
+ public void setParameters(Map<String, String> parameters) {
+ this.parameters = parameters;
+ }
+
+ public Map<String, String> getIdToKey() {
+ return idToKey;
+ }
+
+ public void setIdToKey(Map<String, String> idToKey) {
+ this.idToKey = idToKey;
+ }
+
+ @Override
+ public String toString() {
+ return "PropertyData [parameters= " + parameters + " idToKey= " + idToKey + ", additionalInfoParameterDataDefinition="
+ + additionalInfoParameterDataDefinition + "]";
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/AnnotationTypeData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/AnnotationTypeData.java
index 995bece49d..25ac2a9c3d 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/AnnotationTypeData.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/AnnotationTypeData.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,17 +17,15 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.resources.data;
+import java.util.HashMap;
+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.datatypes.elements.AnnotationTypeDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import java.util.HashMap;
-import java.util.Map;
-
public class AnnotationTypeData extends GraphNode {
private AnnotationTypeDataDefinition annotationTypeDataDefinition;
@@ -44,18 +42,13 @@ public class AnnotationTypeData extends GraphNode {
public AnnotationTypeData(Map<String, Object> properties) {
this();
- annotationTypeDataDefinition
- .setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
+ annotationTypeDataDefinition.setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
annotationTypeDataDefinition.setType((String) properties.get(GraphPropertiesDictionary.TYPE.getProperty()));
- annotationTypeDataDefinition
- .setDescription((String) properties.get(GraphPropertiesDictionary.DESCRIPTION.getProperty()));
- annotationTypeDataDefinition.setHighestVersion(
- (boolean) properties.get(GraphPropertiesDictionary.IS_HIGHEST_VERSION.getProperty()));
+ annotationTypeDataDefinition.setDescription((String) properties.get(GraphPropertiesDictionary.DESCRIPTION.getProperty()));
+ annotationTypeDataDefinition.setHighestVersion((boolean) properties.get(GraphPropertiesDictionary.IS_HIGHEST_VERSION.getProperty()));
annotationTypeDataDefinition.setVersion((String) properties.get(GraphPropertiesDictionary.VERSION.getProperty()));
- annotationTypeDataDefinition
- .setCreationTime((Long) properties.get(GraphPropertiesDictionary.CREATION_DATE.getProperty()));
- annotationTypeDataDefinition
- .setModificationTime((Long) properties.get(GraphPropertiesDictionary.LAST_UPDATE_DATE.getProperty()));
+ annotationTypeDataDefinition.setCreationTime((Long) properties.get(GraphPropertiesDictionary.CREATION_DATE.getProperty()));
+ annotationTypeDataDefinition.setModificationTime((Long) properties.get(GraphPropertiesDictionary.LAST_UPDATE_DATE.getProperty()));
}
@Override
@@ -100,5 +93,4 @@ public class AnnotationTypeData extends GraphNode {
public String toString() {
return "AnnotationTypeData [annotationTypeDataDefinition=" + annotationTypeDataDefinition + "]";
}
-
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ArtifactData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ArtifactData.java
index 9781f572eb..040cc496d8 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ArtifactData.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ArtifactData.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,142 +17,131 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.resources.data;
import com.google.gson.reflect.TypeToken;
+import java.lang.reflect.Type;
+import java.util.HashMap;
+import java.util.List;
+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.datatypes.elements.ArtifactDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum;
-import java.lang.reflect.Type;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
public class ArtifactData extends GraphNode {
- private ArtifactDataDefinition artifactDataDefinition;
-
- public ArtifactData() {
- super(NodeTypeEnum.ArtifactRef);
- artifactDataDefinition = new ArtifactDataDefinition();
- }
-
- public ArtifactData(ArtifactDataDefinition artifactDataDefinition) {
- super(NodeTypeEnum.ArtifactRef);
- this.artifactDataDefinition = artifactDataDefinition;
-
- }
-
- public ArtifactData(Map<String, Object> properties) {
- this();
- artifactDataDefinition.setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
- artifactDataDefinition.setArtifactType((String) properties.get(GraphPropertiesDictionary.ARTIFACT_TYPE.getProperty()));
- artifactDataDefinition.setArtifactRef((String) properties.get(GraphPropertiesDictionary.ARTIFACT_REF.getProperty()));
- artifactDataDefinition.setArtifactName((String) properties.get(GraphPropertiesDictionary.NAME.getProperty()));
- artifactDataDefinition.setArtifactRepository((String) properties.get(GraphPropertiesDictionary.ARTIFACT_REPOSITORY.getProperty()));
- artifactDataDefinition.setArtifactChecksum((String) properties.get(GraphPropertiesDictionary.ARTIFACT_CHECKSUM.getProperty()));
- artifactDataDefinition.setArtifactCreator((String) properties.get(GraphPropertiesDictionary.CREATOR.getProperty()));
- artifactDataDefinition.setUserIdCreator((String) properties.get(GraphPropertiesDictionary.CREATOR_ID.getProperty()));
- artifactDataDefinition.setUserIdLastUpdater((String) properties.get(GraphPropertiesDictionary.LAST_UPDATER.getProperty()));
- artifactDataDefinition.setCreatorFullName((String) properties.get(GraphPropertiesDictionary.CREATOR_FULL_NAME.getProperty()));
- artifactDataDefinition.setUpdaterFullName((String) properties.get(GraphPropertiesDictionary.UPDATER_FULL_NAME.getProperty()));
- artifactDataDefinition.setCreationDate((Long) properties.get(GraphPropertiesDictionary.CREATION_DATE.getProperty()));
- artifactDataDefinition.setLastUpdateDate((Long) properties.get(GraphPropertiesDictionary.LAST_UPDATE_DATE.getProperty()));
- artifactDataDefinition.setDescription((String) properties.get(GraphPropertiesDictionary.DESCRIPTION.getProperty()));
- artifactDataDefinition.setEsId((String) properties.get(GraphPropertiesDictionary.ES_ID.getProperty()));
- artifactDataDefinition.setArtifactLabel((String) properties.get(GraphPropertiesDictionary.ARTIFACT_LABEL.getProperty()));
- artifactDataDefinition.setMandatory((Boolean) properties.get(GraphPropertiesDictionary.IS_ABSTRACT.getProperty()));
- artifactDataDefinition.setArtifactChecksum((String) properties.get(GraphPropertiesDictionary.ARTIFACT_CHECKSUM.getProperty()));
- artifactDataDefinition.setArtifactDisplayName((String) properties.get(GraphPropertiesDictionary.ARTIFACT_DISPLAY_NAME.getProperty()));
- artifactDataDefinition.setApiUrl((String) properties.get(GraphPropertiesDictionary.API_URL.getProperty()));
- artifactDataDefinition.setServiceApi((Boolean) properties.get(GraphPropertiesDictionary.SERVICE_API.getProperty()));
- artifactDataDefinition.setArtifactVersion((String) properties.get(GraphPropertiesDictionary.ARTIFACT_VERSION.getProperty()));
- artifactDataDefinition.setArtifactUUID((String) properties.get(GraphPropertiesDictionary.ARTIFACT_UUID.getProperty()));
- artifactDataDefinition.setPayloadUpdateDate((Long) properties.get(GraphPropertiesDictionary.PAYLOAD_UPDATE_DATE.getProperty()));
- artifactDataDefinition.setHeatParamsUpdateDate((Long) properties.get(GraphPropertiesDictionary.HEAT_PARAMS_UPDATE_DATE.getProperty()));
- artifactDataDefinition.setGenerated((Boolean) properties.get(GraphPropertiesDictionary.GENERATED.getProperty()));
- Type listType = new TypeToken<List<String>>() {
- }.getType();
- List<String> requiredArtifactsfromJson = getGson().fromJson((String) properties.get(GraphPropertiesDictionary.REQUIRED_ARTIFACTS.getProperty()), listType);
- artifactDataDefinition.setRequiredArtifacts(requiredArtifactsfromJson);
-
- String groupType = (String) properties.get(GraphPropertiesDictionary.ARTIFACT_GROUP_TYPE.getProperty());
- if (groupType != null && !groupType.isEmpty()) {
-
- artifactDataDefinition.setArtifactGroupType(ArtifactGroupTypeEnum.findType(groupType));
- }
-
- Integer timeout = (Integer) properties.get(GraphPropertiesDictionary.ARTIFACT_TIMEOUT.getProperty());
- if (timeout != null) {
-
- artifactDataDefinition.setTimeout(timeout);
- }
-
- }
-
- public ArtifactDataDefinition getArtifactDataDefinition() {
- return artifactDataDefinition;
- }
-
- public void setArtifactDataDefinition(ArtifactDataDefinition artifactDataDefinition) {
- this.artifactDataDefinition = artifactDataDefinition;
- }
-
- @Override
- public String getUniqueId() {
- return artifactDataDefinition.getUniqueId();
- }
-
- @Override
- public Map<String, Object> toGraphMap() {
- Map<String, Object> map = new HashMap<>();
-
- addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, artifactDataDefinition.getUniqueId());
- addIfExists(map, GraphPropertiesDictionary.ARTIFACT_TYPE, artifactDataDefinition.getArtifactType());
- addIfExists(map, GraphPropertiesDictionary.ARTIFACT_REF, artifactDataDefinition.getArtifactRef());
- addIfExists(map, GraphPropertiesDictionary.NAME, artifactDataDefinition.getArtifactName());
- addIfExists(map, GraphPropertiesDictionary.ARTIFACT_REPOSITORY, artifactDataDefinition.getArtifactRepository());
- addIfExists(map, GraphPropertiesDictionary.ARTIFACT_CHECKSUM, artifactDataDefinition.getArtifactChecksum());
- addIfExists(map, GraphPropertiesDictionary.CREATOR, artifactDataDefinition.getArtifactCreator());
- addIfExists(map, GraphPropertiesDictionary.CREATOR_ID, artifactDataDefinition.getUserIdCreator());
- addIfExists(map, GraphPropertiesDictionary.LAST_UPDATER, artifactDataDefinition.getUserIdLastUpdater());
- addIfExists(map, GraphPropertiesDictionary.CREATOR_FULL_NAME, artifactDataDefinition.getCreatorFullName());
- addIfExists(map, GraphPropertiesDictionary.UPDATER_FULL_NAME, artifactDataDefinition.getUpdaterFullName());
- addIfExists(map, GraphPropertiesDictionary.CREATION_DATE, artifactDataDefinition.getCreationDate());
- addIfExists(map, GraphPropertiesDictionary.LAST_UPDATE_DATE, artifactDataDefinition.getLastUpdateDate());
- addIfExists(map, GraphPropertiesDictionary.DESCRIPTION, artifactDataDefinition.getDescription());
- addIfExists(map, GraphPropertiesDictionary.ES_ID, artifactDataDefinition.getEsId());
- addIfExists(map, GraphPropertiesDictionary.ARTIFACT_LABEL, artifactDataDefinition.getArtifactLabel());
- addIfExists(map, GraphPropertiesDictionary.IS_ABSTRACT, artifactDataDefinition.getMandatory());
- addIfExists(map, GraphPropertiesDictionary.ARTIFACT_CHECKSUM, artifactDataDefinition.getArtifactChecksum());
- addIfExists(map, GraphPropertiesDictionary.ARTIFACT_DISPLAY_NAME, artifactDataDefinition.getArtifactDisplayName());
- addIfExists(map, GraphPropertiesDictionary.API_URL, artifactDataDefinition.getApiUrl());
- addIfExists(map, GraphPropertiesDictionary.SERVICE_API, artifactDataDefinition.getServiceApi());
- addIfExists(map, GraphPropertiesDictionary.ARTIFACT_TIMEOUT, artifactDataDefinition.getTimeout());
- addIfExists(map, GraphPropertiesDictionary.ARTIFACT_VERSION, artifactDataDefinition.getArtifactVersion());
- addIfExists(map, GraphPropertiesDictionary.ARTIFACT_UUID, artifactDataDefinition.getArtifactUUID());
- addIfExists(map, GraphPropertiesDictionary.PAYLOAD_UPDATE_DATE, artifactDataDefinition.getPayloadUpdateDate());
- addIfExists(map, GraphPropertiesDictionary.HEAT_PARAMS_UPDATE_DATE, artifactDataDefinition.getHeatParamsUpdateDate());
- addIfExists(map, GraphPropertiesDictionary.REQUIRED_ARTIFACTS, artifactDataDefinition.getRequiredArtifacts());
- addIfExists(map, GraphPropertiesDictionary.GENERATED, artifactDataDefinition.getGenerated());
-
- String groupType = null;
- ArtifactGroupTypeEnum groupTypeEnum = artifactDataDefinition.getArtifactGroupType();
- if (groupTypeEnum != null) {
- groupType = groupTypeEnum.getType();
- }
- addIfExists(map, GraphPropertiesDictionary.ARTIFACT_GROUP_TYPE, groupType);
-
- return map;
- }
-
- @Override
- public String toString() {
- return "ArtifactData [artifactDataDefinition=" + artifactDataDefinition + "]";
- }
-
+ private ArtifactDataDefinition artifactDataDefinition;
+
+ public ArtifactData() {
+ super(NodeTypeEnum.ArtifactRef);
+ artifactDataDefinition = new ArtifactDataDefinition();
+ }
+
+ public ArtifactData(ArtifactDataDefinition artifactDataDefinition) {
+ super(NodeTypeEnum.ArtifactRef);
+ this.artifactDataDefinition = artifactDataDefinition;
+ }
+
+ public ArtifactData(Map<String, Object> properties) {
+ this();
+ artifactDataDefinition.setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
+ artifactDataDefinition.setArtifactType((String) properties.get(GraphPropertiesDictionary.ARTIFACT_TYPE.getProperty()));
+ artifactDataDefinition.setArtifactRef((String) properties.get(GraphPropertiesDictionary.ARTIFACT_REF.getProperty()));
+ artifactDataDefinition.setArtifactName((String) properties.get(GraphPropertiesDictionary.NAME.getProperty()));
+ artifactDataDefinition.setArtifactRepository((String) properties.get(GraphPropertiesDictionary.ARTIFACT_REPOSITORY.getProperty()));
+ artifactDataDefinition.setArtifactChecksum((String) properties.get(GraphPropertiesDictionary.ARTIFACT_CHECKSUM.getProperty()));
+ artifactDataDefinition.setArtifactCreator((String) properties.get(GraphPropertiesDictionary.CREATOR.getProperty()));
+ artifactDataDefinition.setUserIdCreator((String) properties.get(GraphPropertiesDictionary.CREATOR_ID.getProperty()));
+ artifactDataDefinition.setUserIdLastUpdater((String) properties.get(GraphPropertiesDictionary.LAST_UPDATER.getProperty()));
+ artifactDataDefinition.setCreatorFullName((String) properties.get(GraphPropertiesDictionary.CREATOR_FULL_NAME.getProperty()));
+ artifactDataDefinition.setUpdaterFullName((String) properties.get(GraphPropertiesDictionary.UPDATER_FULL_NAME.getProperty()));
+ artifactDataDefinition.setCreationDate((Long) properties.get(GraphPropertiesDictionary.CREATION_DATE.getProperty()));
+ artifactDataDefinition.setLastUpdateDate((Long) properties.get(GraphPropertiesDictionary.LAST_UPDATE_DATE.getProperty()));
+ artifactDataDefinition.setDescription((String) properties.get(GraphPropertiesDictionary.DESCRIPTION.getProperty()));
+ artifactDataDefinition.setEsId((String) properties.get(GraphPropertiesDictionary.ES_ID.getProperty()));
+ artifactDataDefinition.setArtifactLabel((String) properties.get(GraphPropertiesDictionary.ARTIFACT_LABEL.getProperty()));
+ artifactDataDefinition.setMandatory((Boolean) properties.get(GraphPropertiesDictionary.IS_ABSTRACT.getProperty()));
+ artifactDataDefinition.setArtifactChecksum((String) properties.get(GraphPropertiesDictionary.ARTIFACT_CHECKSUM.getProperty()));
+ artifactDataDefinition.setArtifactDisplayName((String) properties.get(GraphPropertiesDictionary.ARTIFACT_DISPLAY_NAME.getProperty()));
+ artifactDataDefinition.setApiUrl((String) properties.get(GraphPropertiesDictionary.API_URL.getProperty()));
+ artifactDataDefinition.setServiceApi((Boolean) properties.get(GraphPropertiesDictionary.SERVICE_API.getProperty()));
+ artifactDataDefinition.setArtifactVersion((String) properties.get(GraphPropertiesDictionary.ARTIFACT_VERSION.getProperty()));
+ artifactDataDefinition.setArtifactUUID((String) properties.get(GraphPropertiesDictionary.ARTIFACT_UUID.getProperty()));
+ artifactDataDefinition.setPayloadUpdateDate((Long) properties.get(GraphPropertiesDictionary.PAYLOAD_UPDATE_DATE.getProperty()));
+ artifactDataDefinition.setHeatParamsUpdateDate((Long) properties.get(GraphPropertiesDictionary.HEAT_PARAMS_UPDATE_DATE.getProperty()));
+ artifactDataDefinition.setGenerated((Boolean) properties.get(GraphPropertiesDictionary.GENERATED.getProperty()));
+ Type listType = new TypeToken<List<String>>() {
+ }.getType();
+ List<String> requiredArtifactsfromJson = getGson()
+ .fromJson((String) properties.get(GraphPropertiesDictionary.REQUIRED_ARTIFACTS.getProperty()), listType);
+ artifactDataDefinition.setRequiredArtifacts(requiredArtifactsfromJson);
+ String groupType = (String) properties.get(GraphPropertiesDictionary.ARTIFACT_GROUP_TYPE.getProperty());
+ if (groupType != null && !groupType.isEmpty()) {
+ artifactDataDefinition.setArtifactGroupType(ArtifactGroupTypeEnum.findType(groupType));
+ }
+ Integer timeout = (Integer) properties.get(GraphPropertiesDictionary.ARTIFACT_TIMEOUT.getProperty());
+ if (timeout != null) {
+ artifactDataDefinition.setTimeout(timeout);
+ }
+ }
+
+ public ArtifactDataDefinition getArtifactDataDefinition() {
+ return artifactDataDefinition;
+ }
+
+ public void setArtifactDataDefinition(ArtifactDataDefinition artifactDataDefinition) {
+ this.artifactDataDefinition = artifactDataDefinition;
+ }
+
+ @Override
+ public String getUniqueId() {
+ return artifactDataDefinition.getUniqueId();
+ }
+
+ @Override
+ public Map<String, Object> toGraphMap() {
+ Map<String, Object> map = new HashMap<>();
+ addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, artifactDataDefinition.getUniqueId());
+ addIfExists(map, GraphPropertiesDictionary.ARTIFACT_TYPE, artifactDataDefinition.getArtifactType());
+ addIfExists(map, GraphPropertiesDictionary.ARTIFACT_REF, artifactDataDefinition.getArtifactRef());
+ addIfExists(map, GraphPropertiesDictionary.NAME, artifactDataDefinition.getArtifactName());
+ addIfExists(map, GraphPropertiesDictionary.ARTIFACT_REPOSITORY, artifactDataDefinition.getArtifactRepository());
+ addIfExists(map, GraphPropertiesDictionary.ARTIFACT_CHECKSUM, artifactDataDefinition.getArtifactChecksum());
+ addIfExists(map, GraphPropertiesDictionary.CREATOR, artifactDataDefinition.getArtifactCreator());
+ addIfExists(map, GraphPropertiesDictionary.CREATOR_ID, artifactDataDefinition.getUserIdCreator());
+ addIfExists(map, GraphPropertiesDictionary.LAST_UPDATER, artifactDataDefinition.getUserIdLastUpdater());
+ addIfExists(map, GraphPropertiesDictionary.CREATOR_FULL_NAME, artifactDataDefinition.getCreatorFullName());
+ addIfExists(map, GraphPropertiesDictionary.UPDATER_FULL_NAME, artifactDataDefinition.getUpdaterFullName());
+ addIfExists(map, GraphPropertiesDictionary.CREATION_DATE, artifactDataDefinition.getCreationDate());
+ addIfExists(map, GraphPropertiesDictionary.LAST_UPDATE_DATE, artifactDataDefinition.getLastUpdateDate());
+ addIfExists(map, GraphPropertiesDictionary.DESCRIPTION, artifactDataDefinition.getDescription());
+ addIfExists(map, GraphPropertiesDictionary.ES_ID, artifactDataDefinition.getEsId());
+ addIfExists(map, GraphPropertiesDictionary.ARTIFACT_LABEL, artifactDataDefinition.getArtifactLabel());
+ addIfExists(map, GraphPropertiesDictionary.IS_ABSTRACT, artifactDataDefinition.getMandatory());
+ addIfExists(map, GraphPropertiesDictionary.ARTIFACT_CHECKSUM, artifactDataDefinition.getArtifactChecksum());
+ addIfExists(map, GraphPropertiesDictionary.ARTIFACT_DISPLAY_NAME, artifactDataDefinition.getArtifactDisplayName());
+ addIfExists(map, GraphPropertiesDictionary.API_URL, artifactDataDefinition.getApiUrl());
+ addIfExists(map, GraphPropertiesDictionary.SERVICE_API, artifactDataDefinition.getServiceApi());
+ addIfExists(map, GraphPropertiesDictionary.ARTIFACT_TIMEOUT, artifactDataDefinition.getTimeout());
+ addIfExists(map, GraphPropertiesDictionary.ARTIFACT_VERSION, artifactDataDefinition.getArtifactVersion());
+ addIfExists(map, GraphPropertiesDictionary.ARTIFACT_UUID, artifactDataDefinition.getArtifactUUID());
+ addIfExists(map, GraphPropertiesDictionary.PAYLOAD_UPDATE_DATE, artifactDataDefinition.getPayloadUpdateDate());
+ addIfExists(map, GraphPropertiesDictionary.HEAT_PARAMS_UPDATE_DATE, artifactDataDefinition.getHeatParamsUpdateDate());
+ addIfExists(map, GraphPropertiesDictionary.REQUIRED_ARTIFACTS, artifactDataDefinition.getRequiredArtifacts());
+ addIfExists(map, GraphPropertiesDictionary.GENERATED, artifactDataDefinition.getGenerated());
+ String groupType = null;
+ ArtifactGroupTypeEnum groupTypeEnum = artifactDataDefinition.getArtifactGroupType();
+ if (groupTypeEnum != null) {
+ groupType = groupTypeEnum.getType();
+ }
+ addIfExists(map, GraphPropertiesDictionary.ARTIFACT_GROUP_TYPE, groupType);
+ return map;
+ }
+
+ @Override
+ public String toString() {
+ return "ArtifactData [artifactDataDefinition=" + artifactDataDefinition + "]";
+ }
}
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 bb23f7434c..b9cac83079 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
@@ -7,9 +7,9 @@
* 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.
@@ -17,10 +17,12 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.resources.data;
import com.google.gson.reflect.TypeToken;
+import java.lang.reflect.Type;
+import java.util.HashMap;
+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;
@@ -28,103 +30,77 @@ 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 java.lang.reflect.Type;
-import java.util.HashMap;
-import java.util.Map;
-
public class AttributeData extends GraphNode {
- PropertyDataDefinition attributeDataDefinition;
-
- public AttributeData() {
- super(NodeTypeEnum.Attribute);
- attributeDataDefinition = new PropertyDataDefinition();
- }
-
- public AttributeData(PropertyDataDefinition attributeDataDefinition) {
- super(NodeTypeEnum.Attribute);
- this.attributeDataDefinition = attributeDataDefinition;
- }
-
- @Override
- public String toString() {
- return "AttributeData [attributeDataDefinition=" + attributeDataDefinition + "]";
- }
-
- @Override
- public String getUniqueId() {
- return attributeDataDefinition.getUniqueId();
- }
-
- public PropertyDataDefinition getAttributeDataDefinition() {
- return attributeDataDefinition;
- }
-
- public void setAttributeDataDefinition(PropertyDataDefinition attributeDataDefinition) {
- this.attributeDataDefinition = attributeDataDefinition;
- }
-
- public AttributeData(Map<String, Object> properties) {
-
- this();
-
- attributeDataDefinition.setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
-
- attributeDataDefinition.setType((String) properties.get(GraphPropertiesDictionary.TYPE.getProperty()));
-
- attributeDataDefinition
- .setDescription((String) properties.get(GraphPropertiesDictionary.DESCRIPTION.getProperty()));
-
- String defaultValue = (String) properties.get(GraphPropertiesDictionary.DEFAULT_VALUE.getProperty());
- if (Constants.GRAPH_EMPTY_VALUE.equals(defaultValue)) {
- attributeDataDefinition.setDefaultValue(null);
- } else {
- attributeDataDefinition.setDefaultValue(defaultValue);
- }
-
- attributeDataDefinition.setStatus((String) properties.get(GraphPropertiesDictionary.STATUS.getProperty()));
-
- attributeDataDefinition.setName((String) properties.get(GraphPropertiesDictionary.NAME.getProperty()));
-
- attributeDataDefinition.setValue((String) properties.get(GraphPropertiesDictionary.VALUE.getProperty()));
-
- Type schemaType = new TypeToken<SchemaDefinition>() {
- }.getType();
- SchemaDefinition schema = getGson()
- .fromJson((String) properties.get(GraphPropertiesDictionary.ENTRY_SCHEMA.getProperty()), schemaType);
- attributeDataDefinition.setSchema(schema);
- }
-
- @Override
- public Map<String, Object> toGraphMap() {
-
- Map<String, Object> map = new HashMap<>();
-
- addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, attributeDataDefinition.getUniqueId());
-
- addIfExists(map, GraphPropertiesDictionary.TYPE, attributeDataDefinition.getType());
-
- addIfExists(map, GraphPropertiesDictionary.DESCRIPTION, attributeDataDefinition.getDescription());
-
- String defaultValue = attributeDataDefinition.getDefaultValue();
- if (defaultValue == null) {
- defaultValue = Constants.GRAPH_EMPTY_VALUE;
- }
-
- addIfExists(map, GraphPropertiesDictionary.DEFAULT_VALUE, defaultValue);
-
- addIfExists(map, GraphPropertiesDictionary.STATUS, attributeDataDefinition.getStatus());
-
- addIfExists(map, GraphPropertiesDictionary.NAME, attributeDataDefinition.getName());
-
- addIfExists(map, GraphPropertiesDictionary.VALUE, attributeDataDefinition.getValue());
-
- SchemaDefinition entrySchema = attributeDataDefinition.getSchema();
- if (entrySchema != null) {
- String entrySchemaStr = getGson().toJson(entrySchema);
- addIfExists(map, GraphPropertiesDictionary.ENTRY_SCHEMA, entrySchemaStr);
- }
-
- return map;
- }
+ PropertyDataDefinition attributeDataDefinition;
+
+ public AttributeData() {
+ super(NodeTypeEnum.Attribute);
+ attributeDataDefinition = new PropertyDataDefinition();
+ }
+
+ public AttributeData(PropertyDataDefinition attributeDataDefinition) {
+ super(NodeTypeEnum.Attribute);
+ this.attributeDataDefinition = attributeDataDefinition;
+ }
+
+ public AttributeData(Map<String, Object> properties) {
+ this();
+ attributeDataDefinition.setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
+ attributeDataDefinition.setType((String) properties.get(GraphPropertiesDictionary.TYPE.getProperty()));
+ attributeDataDefinition.setDescription((String) properties.get(GraphPropertiesDictionary.DESCRIPTION.getProperty()));
+ String defaultValue = (String) properties.get(GraphPropertiesDictionary.DEFAULT_VALUE.getProperty());
+ if (Constants.GRAPH_EMPTY_VALUE.equals(defaultValue)) {
+ attributeDataDefinition.setDefaultValue(null);
+ } else {
+ attributeDataDefinition.setDefaultValue(defaultValue);
+ }
+ attributeDataDefinition.setStatus((String) properties.get(GraphPropertiesDictionary.STATUS.getProperty()));
+ attributeDataDefinition.setName((String) properties.get(GraphPropertiesDictionary.NAME.getProperty()));
+ attributeDataDefinition.setValue((String) properties.get(GraphPropertiesDictionary.VALUE.getProperty()));
+ Type schemaType = new TypeToken<SchemaDefinition>() {
+ }.getType();
+ SchemaDefinition schema = getGson().fromJson((String) properties.get(GraphPropertiesDictionary.ENTRY_SCHEMA.getProperty()), schemaType);
+ attributeDataDefinition.setSchema(schema);
+ }
+
+ @Override
+ public String toString() {
+ return "AttributeData [attributeDataDefinition=" + attributeDataDefinition + "]";
+ }
+
+ @Override
+ public String getUniqueId() {
+ return attributeDataDefinition.getUniqueId();
+ }
+
+ public PropertyDataDefinition getAttributeDataDefinition() {
+ return attributeDataDefinition;
+ }
+
+ public void setAttributeDataDefinition(PropertyDataDefinition attributeDataDefinition) {
+ this.attributeDataDefinition = attributeDataDefinition;
+ }
+
+ @Override
+ public Map<String, Object> toGraphMap() {
+ Map<String, Object> map = new HashMap<>();
+ addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, attributeDataDefinition.getUniqueId());
+ addIfExists(map, GraphPropertiesDictionary.TYPE, attributeDataDefinition.getType());
+ addIfExists(map, GraphPropertiesDictionary.DESCRIPTION, attributeDataDefinition.getDescription());
+ String defaultValue = attributeDataDefinition.getDefaultValue();
+ if (defaultValue == null) {
+ defaultValue = Constants.GRAPH_EMPTY_VALUE;
+ }
+ addIfExists(map, GraphPropertiesDictionary.DEFAULT_VALUE, defaultValue);
+ addIfExists(map, GraphPropertiesDictionary.STATUS, attributeDataDefinition.getStatus());
+ addIfExists(map, GraphPropertiesDictionary.NAME, attributeDataDefinition.getName());
+ addIfExists(map, GraphPropertiesDictionary.VALUE, attributeDataDefinition.getValue());
+ SchemaDefinition entrySchema = attributeDataDefinition.getSchema();
+ if (entrySchema != null) {
+ String entrySchemaStr = getGson().toJson(entrySchema);
+ addIfExists(map, GraphPropertiesDictionary.ENTRY_SCHEMA, entrySchemaStr);
+ }
+ return map;
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/AttributeValueData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/AttributeValueData.java
index 7826862cba..8b05a99922 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/AttributeValueData.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/AttributeValueData.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,129 +17,108 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.resources.data;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
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.enums.NodeTypeEnum;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Objects;
-
public class AttributeValueData extends GraphNode {
- private String uniqueId;
-
- private String value;
-
- private String type;
-
- private Boolean hidden;
-
- private Long creationTime;
-
- private Long modificationTime;
-
- public AttributeValueData() {
- super(NodeTypeEnum.AttributeValue);
- }
-
- public AttributeValueData(Map<String, Object> properties) {
- this();
-
- this.setType((String) properties.get(GraphPropertiesDictionary.TYPE.getProperty()));
-
- String updatedValue = (String) properties.get(GraphPropertiesDictionary.VALUE.getProperty());
- if (Constants.GRAPH_EMPTY_VALUE.equals(updatedValue)) {
- this.setValue(null);
- } else {
- this.setValue(updatedValue);
- }
-
- this.setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
-
- this.setHidden((Boolean) properties.get(GraphPropertiesDictionary.HIDDEN.getProperty()));
-
- this.setCreationTime((Long) properties.get(GraphPropertiesDictionary.CREATION_DATE.getProperty()));
-
- this.setModificationTime((Long) properties.get(GraphPropertiesDictionary.LAST_UPDATE_DATE.getProperty()));
-
- }
-
- public String getUniqueId() {
- return uniqueId;
- }
-
- public void setUniqueId(String uniqueId) {
- this.uniqueId = uniqueId;
- }
-
- public Long getCreationTime() {
- return creationTime;
- }
-
- public void setCreationTime(Long creationTime) {
- this.creationTime = creationTime;
- }
-
- public Long getModificationTime() {
- return modificationTime;
- }
-
- public void setModificationTime(Long modificationTime) {
- this.modificationTime = modificationTime;
- }
-
- @Override
- public Map<String, Object> toGraphMap() {
-
- Map<String, Object> map = new HashMap<>();
-
- addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, uniqueId);
-
- addIfExists(map, GraphPropertiesDictionary.TYPE, type);
-
- addIfExists(map, GraphPropertiesDictionary.HIDDEN, hidden);
-
- addIfExists(map, GraphPropertiesDictionary.CREATION_DATE, creationTime);
-
- addIfExists(map, GraphPropertiesDictionary.LAST_UPDATE_DATE, modificationTime);
-
- String updatedValue = Objects.isNull(value) ? Constants.GRAPH_EMPTY_VALUE : value;
- addIfExists(map, GraphPropertiesDictionary.VALUE, updatedValue);
- return map;
- }
-
- @Override
- public String toString() {
- return "AttributeValueData [uniqueId=" + uniqueId + ", hidden=" + hidden + ", type=" + type + ", creationTime="
- + creationTime + ", value=" + value + ", modificationTime=" + modificationTime + "]";
- }
-
- public Boolean isHidden() {
- return hidden;
- }
-
- public void setHidden(Boolean hidden) {
- this.hidden = hidden;
- }
-
- public String getType() {
- return type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
- public String getValue() {
- return value;
- }
-
- public void setValue(String value) {
- this.value = value;
- }
+ private String uniqueId;
+ private String value;
+ private String type;
+ private Boolean hidden;
+ private Long creationTime;
+ private Long modificationTime;
+
+ public AttributeValueData() {
+ super(NodeTypeEnum.AttributeValue);
+ }
+
+ public AttributeValueData(Map<String, Object> properties) {
+ this();
+ this.setType((String) properties.get(GraphPropertiesDictionary.TYPE.getProperty()));
+ String updatedValue = (String) properties.get(GraphPropertiesDictionary.VALUE.getProperty());
+ if (Constants.GRAPH_EMPTY_VALUE.equals(updatedValue)) {
+ this.setValue(null);
+ } else {
+ this.setValue(updatedValue);
+ }
+ this.setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
+ this.setHidden((Boolean) properties.get(GraphPropertiesDictionary.HIDDEN.getProperty()));
+ this.setCreationTime((Long) properties.get(GraphPropertiesDictionary.CREATION_DATE.getProperty()));
+ this.setModificationTime((Long) properties.get(GraphPropertiesDictionary.LAST_UPDATE_DATE.getProperty()));
+ }
+
+ public String getUniqueId() {
+ return uniqueId;
+ }
+
+ public void setUniqueId(String uniqueId) {
+ this.uniqueId = uniqueId;
+ }
+
+ public Long getCreationTime() {
+ return creationTime;
+ }
+
+ public void setCreationTime(Long creationTime) {
+ this.creationTime = creationTime;
+ }
+
+ public Long getModificationTime() {
+ return modificationTime;
+ }
+
+ public void setModificationTime(Long modificationTime) {
+ this.modificationTime = modificationTime;
+ }
+
+ @Override
+ public Map<String, Object> toGraphMap() {
+ Map<String, Object> map = new HashMap<>();
+ addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, uniqueId);
+ addIfExists(map, GraphPropertiesDictionary.TYPE, type);
+ addIfExists(map, GraphPropertiesDictionary.HIDDEN, hidden);
+ addIfExists(map, GraphPropertiesDictionary.CREATION_DATE, creationTime);
+ addIfExists(map, GraphPropertiesDictionary.LAST_UPDATE_DATE, modificationTime);
+ String updatedValue = Objects.isNull(value) ? Constants.GRAPH_EMPTY_VALUE : value;
+ addIfExists(map, GraphPropertiesDictionary.VALUE, updatedValue);
+ return map;
+ }
+
+ @Override
+ public String toString() {
+ return "AttributeValueData [uniqueId=" + uniqueId + ", hidden=" + hidden + ", type=" + type + ", creationTime=" + creationTime + ", value="
+ + value + ", modificationTime=" + modificationTime + "]";
+ }
+
+ public Boolean isHidden() {
+ return hidden;
+ }
+
+ public void setHidden(Boolean hidden) {
+ this.hidden = hidden;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/CapabilityData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/CapabilityData.java
index 16357f557e..32a7dccb16 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/CapabilityData.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/CapabilityData.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,166 +17,148 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.resources.data;
import com.google.gson.reflect.TypeToken;
-import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
-import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
-import org.openecomp.sdc.be.datatypes.elements.CapabilityDataDefinition;
-import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-
import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.List;
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.datatypes.elements.CapabilityDataDefinition;
+import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
public class CapabilityData extends GraphNode {
- private CapabilityDataDefinition capabilityDataDefiniton;
-
- public CapabilityData() {
- this(new CapabilityDataDefinition());
- }
-
- public CapabilityData(CapabilityDataDefinition capabilityDataDefiniton) {
- super(NodeTypeEnum.Capability);
- this.capabilityDataDefiniton = capabilityDataDefiniton;
- }
-
- public CapabilityData(Map<String, Object> properties) {
- this();
-
- capabilityDataDefiniton.setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
- capabilityDataDefiniton.setType((String) properties.get(GraphPropertiesDictionary.TYPE.getProperty()));
-
- Type listType = new TypeToken<List<String>>() {
- }.getType();
- List<String> validSourceTypesfromJson = getGson().fromJson(
- (String) properties.get(GraphPropertiesDictionary.VALID_SOURCE_TYPES.getProperty()), listType);
-
- capabilityDataDefiniton.setValidSourceTypes(validSourceTypesfromJson);
-
- this.setCreationTime((Long) properties.get(GraphPropertiesDictionary.CREATION_DATE.getProperty()));
-
- this.setModificationTime((Long) properties.get(GraphPropertiesDictionary.LAST_UPDATE_DATE.getProperty()));
-
- capabilityDataDefiniton.setDescription((String) properties.get(GraphPropertiesDictionary.DESCRIPTION.getProperty()));
- capabilityDataDefiniton.setMinOccurrences((String) properties.get(GraphPropertiesDictionary.MIN_OCCURRENCES.getProperty()));
- capabilityDataDefiniton.setMaxOccurrences((String) properties.get(GraphPropertiesDictionary.MAX_OCCURRENCES.getProperty()));
- }
-
- private Long creationTime;
-
- private Long modificationTime;
-
- @Override
- public String getUniqueId() {
- return capabilityDataDefiniton.getUniqueId();
- }
-
-
- public CapabilityDataDefinition getCapabilityDataDefinition() {
- return capabilityDataDefiniton;
- }
-
- public void setUniqueId(String uniqueId) {
- capabilityDataDefiniton.setUniqueId(uniqueId);
- }
- public String getDescription() {
- return capabilityDataDefiniton.getDescription();
- }
+ private CapabilityDataDefinition capabilityDataDefiniton;
+ private Long creationTime;
+ private Long modificationTime;
- public void setDescription(String description) {
- capabilityDataDefiniton.setDescription(description);
- }
+ public CapabilityData() {
+ this(new CapabilityDataDefinition());
+ }
- /**
- * Get the type of the capability
- * @return
- */
- public String getType() {
- return capabilityDataDefiniton.getType();
- }
+ public CapabilityData(CapabilityDataDefinition capabilityDataDefiniton) {
+ super(NodeTypeEnum.Capability);
+ this.capabilityDataDefiniton = capabilityDataDefiniton;
+ }
+ public CapabilityData(Map<String, Object> properties) {
+ this();
+ capabilityDataDefiniton.setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
+ capabilityDataDefiniton.setType((String) properties.get(GraphPropertiesDictionary.TYPE.getProperty()));
+ Type listType = new TypeToken<List<String>>() {
+ }.getType();
+ List<String> validSourceTypesfromJson = getGson()
+ .fromJson((String) properties.get(GraphPropertiesDictionary.VALID_SOURCE_TYPES.getProperty()), listType);
+ capabilityDataDefiniton.setValidSourceTypes(validSourceTypesfromJson);
+ this.setCreationTime((Long) properties.get(GraphPropertiesDictionary.CREATION_DATE.getProperty()));
+ this.setModificationTime((Long) properties.get(GraphPropertiesDictionary.LAST_UPDATE_DATE.getProperty()));
+ capabilityDataDefiniton.setDescription((String) properties.get(GraphPropertiesDictionary.DESCRIPTION.getProperty()));
+ capabilityDataDefiniton.setMinOccurrences((String) properties.get(GraphPropertiesDictionary.MIN_OCCURRENCES.getProperty()));
+ capabilityDataDefiniton.setMaxOccurrences((String) properties.get(GraphPropertiesDictionary.MAX_OCCURRENCES.getProperty()));
+ }
+
+ @Override
+ public String getUniqueId() {
+ return capabilityDataDefiniton.getUniqueId();
+ }
+
+ public void setUniqueId(String uniqueId) {
+ capabilityDataDefiniton.setUniqueId(uniqueId);
+ }
+
+ public CapabilityDataDefinition getCapabilityDataDefinition() {
+ return capabilityDataDefiniton;
+ }
+
+ public String getDescription() {
+ return capabilityDataDefiniton.getDescription();
+ }
+
+ public void setDescription(String description) {
+ capabilityDataDefiniton.setDescription(description);
+ }
+
+ /**
+ * Get the type of the capability
+ *
+ * @return
+ */
+ public String getType() {
+ return capabilityDataDefiniton.getType();
+ }
- /**
+ /**
* Set the type of the capability
+ *
* @return
*/
- public void setType(String type) {
- capabilityDataDefiniton.setType(type);
- }
-
- public List<String> getValidSourceTypes() {
- return capabilityDataDefiniton.getValidSourceTypes();
- }
-
- public void setValidSourceTypes(List<String> validSourceTypes) {
- capabilityDataDefiniton.setValidSourceTypes(validSourceTypes);
- }
-
- public Long getCreationTime() {
- return creationTime;
- }
-
- public void setCreationTime(Long creationTime) {
- this.creationTime = creationTime;
- }
-
- public Long getModificationTime() {
- return modificationTime;
- }
-
- public void setModificationTime(Long modificationTime) {
- this.modificationTime = modificationTime;
- }
-
- public String getMinOccurrences() {
- return capabilityDataDefiniton.getMinOccurrences();
- }
-
- public void setMinOccurrences(String minOccurrences) {
- if (minOccurrences != null) {
- capabilityDataDefiniton.setMinOccurrences(minOccurrences);
- }
- }
-
- public String getMaxOccurrences() {
- return capabilityDataDefiniton.getMaxOccurrences();
- }
-
- public void setMaxOccurrences(String maxOccurrences) {
- if (maxOccurrences != null) {
- capabilityDataDefiniton.setMaxOccurrences(maxOccurrences);
- }
- }
-
- @Override
- public Map<String, Object> toGraphMap() {
-
- Map<String, Object> map = new HashMap<>();
-
- addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, capabilityDataDefiniton.getUniqueId());
-
- addIfExists(map, GraphPropertiesDictionary.VALID_SOURCE_TYPES, capabilityDataDefiniton.getValidSourceTypes());
-
- addIfExists(map, GraphPropertiesDictionary.TYPE, capabilityDataDefiniton.getType());
-
- addIfExists(map, GraphPropertiesDictionary.CREATION_DATE, creationTime);
-
- addIfExists(map, GraphPropertiesDictionary.LAST_UPDATE_DATE, modificationTime);
-
- addIfExists(map, GraphPropertiesDictionary.DESCRIPTION, capabilityDataDefiniton.getDescription());
- addIfExists(map, GraphPropertiesDictionary.MIN_OCCURRENCES, capabilityDataDefiniton.getMinOccurrences());
- addIfExists(map, GraphPropertiesDictionary.MAX_OCCURRENCES, capabilityDataDefiniton.getMaxOccurrences());
-
- return map;
- }
-
- @Override
- public String toString() {
- return "CapabilityData [capabilityDataDefiniton=" + capabilityDataDefiniton
- + ", creationTime=" + creationTime + ", modificationTime=" + modificationTime + "]";
- }
-
+ public void setType(String type) {
+ capabilityDataDefiniton.setType(type);
+ }
+
+ public List<String> getValidSourceTypes() {
+ return capabilityDataDefiniton.getValidSourceTypes();
+ }
+
+ public void setValidSourceTypes(List<String> validSourceTypes) {
+ capabilityDataDefiniton.setValidSourceTypes(validSourceTypes);
+ }
+
+ public Long getCreationTime() {
+ return creationTime;
+ }
+
+ public void setCreationTime(Long creationTime) {
+ this.creationTime = creationTime;
+ }
+
+ public Long getModificationTime() {
+ return modificationTime;
+ }
+
+ public void setModificationTime(Long modificationTime) {
+ this.modificationTime = modificationTime;
+ }
+
+ public String getMinOccurrences() {
+ return capabilityDataDefiniton.getMinOccurrences();
+ }
+
+ public void setMinOccurrences(String minOccurrences) {
+ if (minOccurrences != null) {
+ capabilityDataDefiniton.setMinOccurrences(minOccurrences);
+ }
+ }
+
+ public String getMaxOccurrences() {
+ return capabilityDataDefiniton.getMaxOccurrences();
+ }
+
+ public void setMaxOccurrences(String maxOccurrences) {
+ if (maxOccurrences != null) {
+ capabilityDataDefiniton.setMaxOccurrences(maxOccurrences);
+ }
+ }
+
+ @Override
+ public Map<String, Object> toGraphMap() {
+ Map<String, Object> map = new HashMap<>();
+ addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, capabilityDataDefiniton.getUniqueId());
+ addIfExists(map, GraphPropertiesDictionary.VALID_SOURCE_TYPES, capabilityDataDefiniton.getValidSourceTypes());
+ addIfExists(map, GraphPropertiesDictionary.TYPE, capabilityDataDefiniton.getType());
+ addIfExists(map, GraphPropertiesDictionary.CREATION_DATE, creationTime);
+ addIfExists(map, GraphPropertiesDictionary.LAST_UPDATE_DATE, modificationTime);
+ addIfExists(map, GraphPropertiesDictionary.DESCRIPTION, capabilityDataDefiniton.getDescription());
+ addIfExists(map, GraphPropertiesDictionary.MIN_OCCURRENCES, capabilityDataDefiniton.getMinOccurrences());
+ addIfExists(map, GraphPropertiesDictionary.MAX_OCCURRENCES, capabilityDataDefiniton.getMaxOccurrences());
+ return map;
+ }
+
+ @Override
+ public String toString() {
+ return "CapabilityData [capabilityDataDefiniton=" + capabilityDataDefiniton + ", creationTime=" + creationTime + ", modificationTime="
+ + modificationTime + "]";
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/CapabilityInstData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/CapabilityInstData.java
index e85a670aa0..2781950fe4 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/CapabilityInstData.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/CapabilityInstData.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,111 +17,91 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.resources.data;
import com.google.gson.reflect.TypeToken;
-import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
-import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
-import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-
import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.List;
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.datatypes.enums.NodeTypeEnum;
public class CapabilityInstData extends GraphNode {
- public CapabilityInstData() {
- super(NodeTypeEnum.CapabilityInst);
- }
-
- public CapabilityInstData(Map<String, Object> properties) {
- this();
-
- this.setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
-
- Type listType = new TypeToken<List<String>>() {
- }.getType();
- List<String> propertiesfromJson = getGson()
- .fromJson((String) properties.get(GraphPropertiesDictionary.PROPERTIES.getProperty()), listType);
-
- this.setProperties(propertiesfromJson);
-
- // this.setProperties((ArrayList<String>) properties
- // .get(GraphPropertiesDictionary.PROPERTIES.getProperty()));
-
- this.setCreationTime((Long) properties.get(GraphPropertiesDictionary.CREATION_DATE.getProperty()));
-
- this.setModificationTime((Long) properties.get(GraphPropertiesDictionary.LAST_UPDATE_DATE.getProperty()));
- }
-
- private String uniqueId;
-
- private List<String> properties;
-
- private Long creationTime;
-
- private Long modificationTime;
-
- @Override
- public String getUniqueId() {
- return uniqueId;
- }
-
- public void setUniqueId(String uniqueId) {
- this.uniqueId = uniqueId;
- }
-
- public Long getCreationTime() {
- return creationTime;
- }
-
- public void setCreationTime(Long creationTime) {
- this.creationTime = creationTime;
- }
-
- public Long getModificationTime() {
- return modificationTime;
- }
-
- public void setModificationTime(Long modificationTime) {
- this.modificationTime = modificationTime;
- }
-
- public List<String> getProperties() {
- return properties;
- }
-
- public void setProperties(List<String> properties) {
- this.properties = properties;
- }
-
- @Override
- public Map<String, Object> toGraphMap() {
-
- Map<String, Object> map = new HashMap<>();
-
- addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, uniqueId);
-
- // String propertiesToJson = getGson().toJson(properties);
-
- // addIfExists(map, GraphPropertiesDictionary.PROPERTIES,
- // propertiesToJson);
-
- addIfExists(map, GraphPropertiesDictionary.PROPERTIES, properties);
-
- addIfExists(map, GraphPropertiesDictionary.CREATION_DATE, creationTime);
-
- addIfExists(map, GraphPropertiesDictionary.LAST_UPDATE_DATE, modificationTime);
-
- return map;
- }
-
- @Override
- public String toString() {
- return "CapabilityInstData [uniqueId=" + uniqueId + ", properties=" + properties + ", creationTime="
- + creationTime + ", modificationTime=" + modificationTime + "]";
- }
-
+ private String uniqueId;
+ private List<String> properties;
+ private Long creationTime;
+ private Long modificationTime;
+ public CapabilityInstData() {
+ super(NodeTypeEnum.CapabilityInst);
+ }
+ public CapabilityInstData(Map<String, Object> properties) {
+ this();
+ this.setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
+ Type listType = new TypeToken<List<String>>() {
+ }.getType();
+ List<String> propertiesfromJson = getGson().fromJson((String) properties.get(GraphPropertiesDictionary.PROPERTIES.getProperty()), listType);
+ this.setProperties(propertiesfromJson);
+ // this.setProperties((ArrayList<String>) properties
+
+ // .get(GraphPropertiesDictionary.PROPERTIES.getProperty()));
+ this.setCreationTime((Long) properties.get(GraphPropertiesDictionary.CREATION_DATE.getProperty()));
+ this.setModificationTime((Long) properties.get(GraphPropertiesDictionary.LAST_UPDATE_DATE.getProperty()));
+ }
+
+ @Override
+ public String getUniqueId() {
+ return uniqueId;
+ }
+
+ public void setUniqueId(String uniqueId) {
+ this.uniqueId = uniqueId;
+ }
+
+ public Long getCreationTime() {
+ return creationTime;
+ }
+
+ public void setCreationTime(Long creationTime) {
+ this.creationTime = creationTime;
+ }
+
+ public Long getModificationTime() {
+ return modificationTime;
+ }
+
+ public void setModificationTime(Long modificationTime) {
+ this.modificationTime = modificationTime;
+ }
+
+ public List<String> getProperties() {
+ return properties;
+ }
+
+ public void setProperties(List<String> properties) {
+ this.properties = properties;
+ }
+
+ @Override
+ public Map<String, Object> toGraphMap() {
+ Map<String, Object> map = new HashMap<>();
+ addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, uniqueId);
+ // String propertiesToJson = getGson().toJson(properties);
+
+ // addIfExists(map, GraphPropertiesDictionary.PROPERTIES,
+
+ // propertiesToJson);
+ addIfExists(map, GraphPropertiesDictionary.PROPERTIES, properties);
+ addIfExists(map, GraphPropertiesDictionary.CREATION_DATE, creationTime);
+ addIfExists(map, GraphPropertiesDictionary.LAST_UPDATE_DATE, modificationTime);
+ return map;
+ }
+
+ @Override
+ public String toString() {
+ return "CapabilityInstData [uniqueId=" + uniqueId + ", properties=" + properties + ", creationTime=" + creationTime + ", modificationTime="
+ + modificationTime + "]";
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/CapabilityTypeData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/CapabilityTypeData.java
index 67929953bc..8e72e67617 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/CapabilityTypeData.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/CapabilityTypeData.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,119 +17,90 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.resources.data;
import com.google.gson.reflect.TypeToken;
-import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
-import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
-import org.openecomp.sdc.be.datatypes.elements.CapabilityTypeDataDefinition;
-import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-
import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.List;
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.datatypes.elements.CapabilityTypeDataDefinition;
+import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
public class CapabilityTypeData extends GraphNode {
- CapabilityTypeDataDefinition capabilityTypeDataDefinition;
-
- // private List<String> constraints;
-
- public CapabilityTypeData() {
- super(NodeTypeEnum.CapabilityType);
- capabilityTypeDataDefinition = new CapabilityTypeDataDefinition();
- }
-
- public CapabilityTypeData(CapabilityTypeDataDefinition capabilityTypeDataDefinition) {
- super(NodeTypeEnum.CapabilityType);
- this.capabilityTypeDataDefinition = capabilityTypeDataDefinition;
- // this.constraints = constraints;
- }
-
- public CapabilityTypeData(Map<String, Object> properties) {
-
- this();
-
- capabilityTypeDataDefinition
- .setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
-
- capabilityTypeDataDefinition.setType((String) properties.get(GraphPropertiesDictionary.TYPE.getProperty()));
-
- capabilityTypeDataDefinition
- .setDescription((String) properties.get(GraphPropertiesDictionary.DESCRIPTION.getProperty()));
-
- capabilityTypeDataDefinition
- .setVersion((String) properties.get(GraphPropertiesDictionary.VERSION.getProperty()));
-
- Type listType = new TypeToken<List<String>>() {
- }.getType();
- List<String> validSourceTypesfromJson = getGson().fromJson(
- (String) properties.get(GraphPropertiesDictionary.VALID_SOURCE_TYPES.getProperty()), listType);
-
- capabilityTypeDataDefinition.setValidSourceTypes(validSourceTypesfromJson);
-
- // capabilityTypeDataDefinition.setValidSourceTypes((List<String>)
- // properties.get(GraphPropertiesDictionary.VALID_SOURCE_TYPES
- // .getProperty()));
-
- capabilityTypeDataDefinition
- .setCreationTime((Long) properties.get(GraphPropertiesDictionary.CREATION_DATE.getProperty()));
-
- capabilityTypeDataDefinition
- .setModificationTime((Long) properties.get(GraphPropertiesDictionary.LAST_UPDATE_DATE.getProperty()));
-
- // capabilityTypeDataDefinition.setVersion(version);
-
- }
-
- @Override
- public Map<String, Object> toGraphMap() {
-
- Map<String, Object> map = new HashMap<>();
-
- addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, capabilityTypeDataDefinition.getUniqueId());
-
- addIfExists(map, GraphPropertiesDictionary.TYPE, capabilityTypeDataDefinition.getType());
-
- addIfExists(map, GraphPropertiesDictionary.DESCRIPTION, capabilityTypeDataDefinition.getDescription());
-
- addIfExists(map, GraphPropertiesDictionary.VERSION, capabilityTypeDataDefinition.getVersion());
-
- // String validSourceTypesToJson =
- // getGson().toJson(capabilityTypeDataDefinition.getValidSourceTypes());
-
- // addIfExists(map, GraphPropertiesDictionary.VALID_SOURCE_TYPES,
- // validSourceTypesToJson);
-
- addIfExists(map, GraphPropertiesDictionary.VALID_SOURCE_TYPES,
- capabilityTypeDataDefinition.getValidSourceTypes());
-
- addIfExists(map, GraphPropertiesDictionary.CREATION_DATE, capabilityTypeDataDefinition.getCreationTime());
-
- addIfExists(map, GraphPropertiesDictionary.LAST_UPDATE_DATE,
- capabilityTypeDataDefinition.getModificationTime());
-
- return map;
- }
-
- public CapabilityTypeDataDefinition getCapabilityTypeDataDefinition() {
- return capabilityTypeDataDefinition;
- }
-
- public void setCapabilityTypeDataDefinition(CapabilityTypeDataDefinition capabilityTypeDataDefinition) {
- this.capabilityTypeDataDefinition = capabilityTypeDataDefinition;
- }
-
- @Override
- public String toString() {
- return "CapabilityTypeData [capabilityTypeDataDefinition=" + capabilityTypeDataDefinition + "]";
- }
-
- @Override
- public String getUniqueId() {
- return this.capabilityTypeDataDefinition.getUniqueId();
- }
-
+ CapabilityTypeDataDefinition capabilityTypeDataDefinition;
+
+ // private List<String> constraints;
+ public CapabilityTypeData() {
+ super(NodeTypeEnum.CapabilityType);
+ capabilityTypeDataDefinition = new CapabilityTypeDataDefinition();
+ }
+
+ public CapabilityTypeData(CapabilityTypeDataDefinition capabilityTypeDataDefinition) {
+ super(NodeTypeEnum.CapabilityType);
+ this.capabilityTypeDataDefinition = capabilityTypeDataDefinition;
+ // this.constraints = constraints;
+ }
+
+ public CapabilityTypeData(Map<String, Object> properties) {
+ this();
+ capabilityTypeDataDefinition.setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
+ capabilityTypeDataDefinition.setType((String) properties.get(GraphPropertiesDictionary.TYPE.getProperty()));
+ capabilityTypeDataDefinition.setDescription((String) properties.get(GraphPropertiesDictionary.DESCRIPTION.getProperty()));
+ capabilityTypeDataDefinition.setVersion((String) properties.get(GraphPropertiesDictionary.VERSION.getProperty()));
+ Type listType = new TypeToken<List<String>>() {
+ }.getType();
+ List<String> validSourceTypesfromJson = getGson()
+ .fromJson((String) properties.get(GraphPropertiesDictionary.VALID_SOURCE_TYPES.getProperty()), listType);
+ capabilityTypeDataDefinition.setValidSourceTypes(validSourceTypesfromJson);
+ // capabilityTypeDataDefinition.setValidSourceTypes((List<String>)
+
+ // properties.get(GraphPropertiesDictionary.VALID_SOURCE_TYPES
+
+ // .getProperty()));
+ capabilityTypeDataDefinition.setCreationTime((Long) properties.get(GraphPropertiesDictionary.CREATION_DATE.getProperty()));
+ capabilityTypeDataDefinition.setModificationTime((Long) properties.get(GraphPropertiesDictionary.LAST_UPDATE_DATE.getProperty()));
+ // capabilityTypeDataDefinition.setVersion(version);
+ }
+
+ @Override
+ public Map<String, Object> toGraphMap() {
+ Map<String, Object> map = new HashMap<>();
+ addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, capabilityTypeDataDefinition.getUniqueId());
+ addIfExists(map, GraphPropertiesDictionary.TYPE, capabilityTypeDataDefinition.getType());
+ addIfExists(map, GraphPropertiesDictionary.DESCRIPTION, capabilityTypeDataDefinition.getDescription());
+ addIfExists(map, GraphPropertiesDictionary.VERSION, capabilityTypeDataDefinition.getVersion());
+ // String validSourceTypesToJson =
+
+ // getGson().toJson(capabilityTypeDataDefinition.getValidSourceTypes());
+
+ // addIfExists(map, GraphPropertiesDictionary.VALID_SOURCE_TYPES,
+
+ // validSourceTypesToJson);
+ addIfExists(map, GraphPropertiesDictionary.VALID_SOURCE_TYPES, capabilityTypeDataDefinition.getValidSourceTypes());
+ addIfExists(map, GraphPropertiesDictionary.CREATION_DATE, capabilityTypeDataDefinition.getCreationTime());
+ addIfExists(map, GraphPropertiesDictionary.LAST_UPDATE_DATE, capabilityTypeDataDefinition.getModificationTime());
+ return map;
+ }
+
+ public CapabilityTypeDataDefinition getCapabilityTypeDataDefinition() {
+ return capabilityTypeDataDefinition;
+ }
+
+ public void setCapabilityTypeDataDefinition(CapabilityTypeDataDefinition capabilityTypeDataDefinition) {
+ this.capabilityTypeDataDefinition = capabilityTypeDataDefinition;
+ }
+
+ @Override
+ public String toString() {
+ return "CapabilityTypeData [capabilityTypeDataDefinition=" + capabilityTypeDataDefinition + "]";
+ }
+
+ @Override
+ public String getUniqueId() {
+ return this.capabilityTypeDataDefinition.getUniqueId();
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/CategoryData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/CategoryData.java
index f5ec18ac61..229d774222 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/CategoryData.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/CategoryData.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,83 +17,80 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.resources.data;
+import java.util.HashMap;
+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.datatypes.enums.NodeTypeEnum;
-import java.util.HashMap;
-import java.util.Map;
-
public abstract class CategoryData extends GraphNode {
- private String name;
- private String normalizedName;
- private String uniqueId;
-
- protected abstract void createUniqueId();
-
- protected CategoryData(NodeTypeEnum label) {
- super(label);
- }
-
- protected CategoryData(String name, String normalizedName, NodeTypeEnum label) {
- super(label);
- this.name = name;
- this.normalizedName = normalizedName;
- }
-
- protected CategoryData(Map<String, Object> properties, NodeTypeEnum label) {
- super(label);
- setName((String) properties.get(GraphPropertiesDictionary.NAME.getProperty()));
- setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
- setNormalizedName((String) properties.get(GraphPropertiesDictionary.NORMALIZED_NAME.getProperty()));
- }
-
- @Override
- public Map<String, Object> toGraphMap() {
- Map<String, Object> map = new HashMap<>();
- addIfExists(map, GraphPropertiesDictionary.NAME, name);
- addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, uniqueId);
- addIfExists(map, GraphPropertiesDictionary.NORMALIZED_NAME, normalizedName);
- return map;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getNormalizedName() {
- return normalizedName;
- }
-
- public void setNormalizedName(String normalizedName) {
- this.normalizedName = normalizedName;
- }
-
- public void setUniqueId(String uniqueId) {
- this.uniqueId = uniqueId;
- }
-
- @Override
- public String toString() {
- return "CategoryData [name=" + name + ", normalizedName=" + normalizedName + "uniqueId=" + uniqueId + "]";
- }
-
- @Override
- public String getUniqueIdKey() {
- return GraphPropertiesDictionary.UNIQUE_ID.getProperty();
- }
-
- @Override
- public String getUniqueId() {
- return uniqueId;
- }
-
+ private String name;
+ private String normalizedName;
+ private String uniqueId;
+
+ protected CategoryData(NodeTypeEnum label) {
+ super(label);
+ }
+
+ protected CategoryData(String name, String normalizedName, NodeTypeEnum label) {
+ super(label);
+ this.name = name;
+ this.normalizedName = normalizedName;
+ }
+
+ protected CategoryData(Map<String, Object> properties, NodeTypeEnum label) {
+ super(label);
+ setName((String) properties.get(GraphPropertiesDictionary.NAME.getProperty()));
+ setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
+ setNormalizedName((String) properties.get(GraphPropertiesDictionary.NORMALIZED_NAME.getProperty()));
+ }
+
+ protected abstract void createUniqueId();
+
+ @Override
+ public Map<String, Object> toGraphMap() {
+ Map<String, Object> map = new HashMap<>();
+ addIfExists(map, GraphPropertiesDictionary.NAME, name);
+ addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, uniqueId);
+ addIfExists(map, GraphPropertiesDictionary.NORMALIZED_NAME, normalizedName);
+ return map;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getNormalizedName() {
+ return normalizedName;
+ }
+
+ public void setNormalizedName(String normalizedName) {
+ this.normalizedName = normalizedName;
+ }
+
+ @Override
+ public String toString() {
+ return "CategoryData [name=" + name + ", normalizedName=" + normalizedName + "uniqueId=" + uniqueId + "]";
+ }
+
+ @Override
+ public String getUniqueIdKey() {
+ return GraphPropertiesDictionary.UNIQUE_ID.getProperty();
+ }
+
+ @Override
+ public String getUniqueId() {
+ return uniqueId;
+ }
+
+ public void setUniqueId(String uniqueId) {
+ this.uniqueId = uniqueId;
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ComponentCacheData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ComponentCacheData.java
index 7c960ae06e..6f7084b555 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ComponentCacheData.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ComponentCacheData.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,137 +17,124 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.resources.data;
import com.datastax.driver.mapping.annotations.Column;
import com.datastax.driver.mapping.annotations.PartitionKey;
import com.datastax.driver.mapping.annotations.Table;
-
import java.nio.ByteBuffer;
import java.util.Date;
@Table(keyspace = "sdccomponent", name = "componentcache")
public class ComponentCacheData {
- public static final String RESOURCE_ID_FIELD = "resourceId";
-
- public static final String SERVICE_NAME_FIELD = "serviceName";
- public static final String SERVICE_VERSION_FIELD = "serviceVersion";
- public static final String ARTIFACT_NAME_FIELD = "artifactName";
-
- public static final String delim = ":";
-
- @PartitionKey
- @Column(name = "id")
- private String id;
-
- @Column
- private ByteBuffer data;
-
- @Column(name = "modification_time")
- private Date modificationTime;
-
- @Column
- private String type;
-
- @Column(name = "is_dirty")
- private boolean isDirty;
-
- @Column(name = "is_zipped")
- private boolean isZipped;
-
- public ComponentCacheData() {
-
- }
-
- public ComponentCacheData(String id, byte[] data, Date modificationTime, String type, boolean isDirty,
- boolean isZipped) {
- super();
- this.id = id;
- if (data != null) {
- this.data = ByteBuffer.wrap(data.clone());
- }
- this.modificationTime = modificationTime;
- this.type = type;
- this.isDirty = isDirty;
- this.isZipped = isZipped;
- }
-
- public ComponentCacheData(String id) {
-
- this.id = id;
- }
-
- public ComponentCacheData(String artifactId, byte[] data) {
- super();
- this.id = artifactId;
- if (data != null) {
- this.data = ByteBuffer.wrap(data.clone());
- // this.data = data.clone();
- }
- }
-
- public byte[] getDataAsArray() {
- if (data != null) {
- return data.array();
- }
- return null;
- }
-
- public void setDataAsArray(byte[] data) {
- if (data != null) {
- this.data = ByteBuffer.wrap(data.clone());
- }
- }
-
- public ByteBuffer getData() {
- return data;
- }
-
- public void setData(ByteBuffer data) {
- if (data != null) {
- this.data = data.duplicate();
- }
- }
-
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public Date getModificationTime() {
- return modificationTime;
- }
-
- public void setModificationTime(Date modificationTime) {
- this.modificationTime = modificationTime;
- }
-
- public String getType() {
- return type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
- public boolean getIsDirty() {
- return isDirty;
- }
-
- public void setIsDirty(boolean isDirty) {
- this.isDirty = isDirty;
- }
-
- public boolean getIsZipped() {
- return isZipped;
- }
-
- public void setIsZipped(boolean isZipped) {
- this.isZipped = isZipped;
- }
+ public static final String RESOURCE_ID_FIELD = "resourceId";
+ public static final String SERVICE_NAME_FIELD = "serviceName";
+ public static final String SERVICE_VERSION_FIELD = "serviceVersion";
+ public static final String ARTIFACT_NAME_FIELD = "artifactName";
+ public static final String delim = ":";
+ @PartitionKey
+ @Column(name = "id")
+ private String id;
+ @Column
+ private ByteBuffer data;
+ @Column(name = "modification_time")
+ private Date modificationTime;
+ @Column
+ private String type;
+ @Column(name = "is_dirty")
+ private boolean isDirty;
+ @Column(name = "is_zipped")
+ private boolean isZipped;
+
+ public ComponentCacheData() {
+ }
+
+ public ComponentCacheData(String id, byte[] data, Date modificationTime, String type, boolean isDirty, boolean isZipped) {
+ super();
+ this.id = id;
+ if (data != null) {
+ this.data = ByteBuffer.wrap(data.clone());
+ }
+ this.modificationTime = modificationTime;
+ this.type = type;
+ this.isDirty = isDirty;
+ this.isZipped = isZipped;
+ }
+
+ public ComponentCacheData(String id) {
+ this.id = id;
+ }
+
+ public ComponentCacheData(String artifactId, byte[] data) {
+ super();
+ this.id = artifactId;
+ if (data != null) {
+ this.data = ByteBuffer.wrap(data.clone());
+ // this.data = data.clone();
+ }
+ }
+
+ public byte[] getDataAsArray() {
+ if (data != null) {
+ return data.array();
+ }
+ return null;
+ }
+
+ public void setDataAsArray(byte[] data) {
+ if (data != null) {
+ this.data = ByteBuffer.wrap(data.clone());
+ }
+ }
+
+ public ByteBuffer getData() {
+ return data;
+ }
+
+ public void setData(ByteBuffer data) {
+ if (data != null) {
+ this.data = data.duplicate();
+ }
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public Date getModificationTime() {
+ return modificationTime;
+ }
+
+ public void setModificationTime(Date modificationTime) {
+ this.modificationTime = modificationTime;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public boolean getIsDirty() {
+ return isDirty;
+ }
+
+ public void setIsDirty(boolean isDirty) {
+ this.isDirty = isDirty;
+ }
+
+ public boolean getIsZipped() {
+ return isZipped;
+ }
+
+ public void setIsZipped(boolean isZipped) {
+ this.isZipped = isZipped;
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ComponentInstanceData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ComponentInstanceData.java
index 315bf83e2a..da4a65e762 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ComponentInstanceData.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ComponentInstanceData.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,123 +17,116 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.resources.data;
+import java.util.HashMap;
+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.datatypes.elements.ComponentInstanceDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.OriginTypeEnum;
-import java.util.HashMap;
-import java.util.Map;
-
public class ComponentInstanceData extends GraphNode {
- ComponentInstanceDataDefinition componentInstDataDefinition;
- protected Integer groupInstanceCounter;
-
- public ComponentInstanceData() {
- super(NodeTypeEnum.ResourceInstance);
- this.componentInstDataDefinition = new ComponentInstanceDataDefinition();
- this.groupInstanceCounter = 0;
- }
-
- public ComponentInstanceData(ComponentInstanceDataDefinition componentInstDataDefinition) {
- super(NodeTypeEnum.ResourceInstance);
- this.componentInstDataDefinition = componentInstDataDefinition;
- this.groupInstanceCounter = 0;
- }
-
- public ComponentInstanceData(ComponentInstanceDataDefinition componentInstDataDefinition, Integer groupInstanceCounter) {
- super(NodeTypeEnum.ResourceInstance);
- this.componentInstDataDefinition = componentInstDataDefinition;
- this.groupInstanceCounter = groupInstanceCounter;
- }
-
- public ComponentInstanceData(Map<String, Object> properties) {
-
- this();
-
- componentInstDataDefinition.setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
- componentInstDataDefinition.setComponentUid((String) properties.get(GraphPropertiesDictionary.TYPE.getProperty()));
- componentInstDataDefinition.setCreationTime((Long) properties.get(GraphPropertiesDictionary.CREATION_DATE.getProperty()));
- componentInstDataDefinition.setModificationTime((Long) properties.get(GraphPropertiesDictionary.LAST_UPDATE_DATE.getProperty()));
- componentInstDataDefinition.setDescription((String) properties.get(GraphPropertiesDictionary.DESCRIPTION.getProperty()));
- componentInstDataDefinition.setPosX((String) properties.get(GraphPropertiesDictionary.POSITION_X.getProperty()));
- componentInstDataDefinition.setPosY((String) properties.get(GraphPropertiesDictionary.POSITION_Y.getProperty()));
- componentInstDataDefinition.setName((String) properties.get(GraphPropertiesDictionary.NAME.getProperty()));
- componentInstDataDefinition.setPropertyValueCounter((Integer) properties.get(GraphPropertiesDictionary.PROPERTY_COUNTER.getProperty()));
- componentInstDataDefinition.setAttributeValueCounter((Integer) properties.get(GraphPropertiesDictionary.ATTRIBUTE_COUNTER.getProperty()));
- componentInstDataDefinition.setNormalizedName((String) properties.get(GraphPropertiesDictionary.NORMALIZED_NAME.getProperty()));
- componentInstDataDefinition.setOriginType(OriginTypeEnum.findByValue((String) properties.get(GraphPropertiesDictionary.ORIGIN_TYPE.getProperty())));
- componentInstDataDefinition.setCustomizationUUID((String) properties.get(GraphPropertiesDictionary.CUSTOMIZATION_UUID.getProperty()));
- groupInstanceCounter = (Integer) properties.get(GraphPropertiesDictionary.INSTANCE_COUNTER.getProperty());
- }
-
- @Override
- public Map<String, Object> toGraphMap() {
-
- Map<String, Object> map = new HashMap<>();
-
- addIfExists(map, GraphPropertiesDictionary.TYPE, componentInstDataDefinition.getComponentUid());
- addIfExists(map, GraphPropertiesDictionary.CREATION_DATE, componentInstDataDefinition.getCreationTime());
- addIfExists(map, GraphPropertiesDictionary.LAST_UPDATE_DATE, componentInstDataDefinition.getModificationTime());
- addIfExists(map, GraphPropertiesDictionary.DESCRIPTION, componentInstDataDefinition.getDescription());
- addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, componentInstDataDefinition.getUniqueId());
- addIfExists(map, GraphPropertiesDictionary.POSITION_X, componentInstDataDefinition.getPosX());
- addIfExists(map, GraphPropertiesDictionary.POSITION_Y, componentInstDataDefinition.getPosY());
- addIfExists(map, GraphPropertiesDictionary.NAME, componentInstDataDefinition.getName());
- addIfExists(map, GraphPropertiesDictionary.PROPERTY_COUNTER, componentInstDataDefinition.getPropertyValueCounter());
- addIfExists(map, GraphPropertiesDictionary.ATTRIBUTE_COUNTER, componentInstDataDefinition.getAttributeValueCounter());
- addIfExists(map, GraphPropertiesDictionary.INSTANCE_COUNTER, groupInstanceCounter);
- addIfExists(map, GraphPropertiesDictionary.NORMALIZED_NAME, componentInstDataDefinition.getNormalizedName());
- if (componentInstDataDefinition.getOriginType() != null) {
- addIfExists(map, GraphPropertiesDictionary.ORIGIN_TYPE, componentInstDataDefinition.getOriginType().getValue());
- }
- addIfExists(map, GraphPropertiesDictionary.CUSTOMIZATION_UUID, componentInstDataDefinition.getCustomizationUUID());
-
- return map;
- }
-
- @Override
- public String getUniqueId() {
- return componentInstDataDefinition.getUniqueId();
- }
-
- public String getName() {
- return componentInstDataDefinition.getName();
- }
-
- @Override
- public String getUniqueIdKey() {
- return GraphPropertiesDictionary.UNIQUE_ID.getProperty();
- }
-
- public ComponentInstanceDataDefinition getComponentInstDataDefinition() {
- return componentInstDataDefinition;
- }
-
- public void setComponentInstDataDefinition(ComponentInstanceDataDefinition componentInstDataDefinition) {
- this.componentInstDataDefinition = componentInstDataDefinition;
- }
-
- @Override
- public String toString() {
- return "ComponentInstanceData [componentInstDataDefinition=" + componentInstDataDefinition + "]";
- }
-
- public Integer getGroupInstanceCounter() {
- return groupInstanceCounter;
- }
-
- public void setGroupInstanceCounter(Integer componentInstanceCounter) {
- this.groupInstanceCounter = componentInstanceCounter;
- }
-
- public Integer increaseAndGetGroupInstanceCounter() {
- return ++groupInstanceCounter;
- }
-
+ protected Integer groupInstanceCounter;
+ ComponentInstanceDataDefinition componentInstDataDefinition;
+
+ public ComponentInstanceData() {
+ super(NodeTypeEnum.ResourceInstance);
+ this.componentInstDataDefinition = new ComponentInstanceDataDefinition();
+ this.groupInstanceCounter = 0;
+ }
+
+ public ComponentInstanceData(ComponentInstanceDataDefinition componentInstDataDefinition) {
+ super(NodeTypeEnum.ResourceInstance);
+ this.componentInstDataDefinition = componentInstDataDefinition;
+ this.groupInstanceCounter = 0;
+ }
+
+ public ComponentInstanceData(ComponentInstanceDataDefinition componentInstDataDefinition, Integer groupInstanceCounter) {
+ super(NodeTypeEnum.ResourceInstance);
+ this.componentInstDataDefinition = componentInstDataDefinition;
+ this.groupInstanceCounter = groupInstanceCounter;
+ }
+
+ public ComponentInstanceData(Map<String, Object> properties) {
+ this();
+ componentInstDataDefinition.setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
+ componentInstDataDefinition.setComponentUid((String) properties.get(GraphPropertiesDictionary.TYPE.getProperty()));
+ componentInstDataDefinition.setCreationTime((Long) properties.get(GraphPropertiesDictionary.CREATION_DATE.getProperty()));
+ componentInstDataDefinition.setModificationTime((Long) properties.get(GraphPropertiesDictionary.LAST_UPDATE_DATE.getProperty()));
+ componentInstDataDefinition.setDescription((String) properties.get(GraphPropertiesDictionary.DESCRIPTION.getProperty()));
+ componentInstDataDefinition.setPosX((String) properties.get(GraphPropertiesDictionary.POSITION_X.getProperty()));
+ componentInstDataDefinition.setPosY((String) properties.get(GraphPropertiesDictionary.POSITION_Y.getProperty()));
+ componentInstDataDefinition.setName((String) properties.get(GraphPropertiesDictionary.NAME.getProperty()));
+ componentInstDataDefinition.setPropertyValueCounter((Integer) properties.get(GraphPropertiesDictionary.PROPERTY_COUNTER.getProperty()));
+ componentInstDataDefinition.setAttributeValueCounter((Integer) properties.get(GraphPropertiesDictionary.ATTRIBUTE_COUNTER.getProperty()));
+ componentInstDataDefinition.setNormalizedName((String) properties.get(GraphPropertiesDictionary.NORMALIZED_NAME.getProperty()));
+ componentInstDataDefinition
+ .setOriginType(OriginTypeEnum.findByValue((String) properties.get(GraphPropertiesDictionary.ORIGIN_TYPE.getProperty())));
+ componentInstDataDefinition.setCustomizationUUID((String) properties.get(GraphPropertiesDictionary.CUSTOMIZATION_UUID.getProperty()));
+ groupInstanceCounter = (Integer) properties.get(GraphPropertiesDictionary.INSTANCE_COUNTER.getProperty());
+ }
+
+ @Override
+ public Map<String, Object> toGraphMap() {
+ Map<String, Object> map = new HashMap<>();
+ addIfExists(map, GraphPropertiesDictionary.TYPE, componentInstDataDefinition.getComponentUid());
+ addIfExists(map, GraphPropertiesDictionary.CREATION_DATE, componentInstDataDefinition.getCreationTime());
+ addIfExists(map, GraphPropertiesDictionary.LAST_UPDATE_DATE, componentInstDataDefinition.getModificationTime());
+ addIfExists(map, GraphPropertiesDictionary.DESCRIPTION, componentInstDataDefinition.getDescription());
+ addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, componentInstDataDefinition.getUniqueId());
+ addIfExists(map, GraphPropertiesDictionary.POSITION_X, componentInstDataDefinition.getPosX());
+ addIfExists(map, GraphPropertiesDictionary.POSITION_Y, componentInstDataDefinition.getPosY());
+ addIfExists(map, GraphPropertiesDictionary.NAME, componentInstDataDefinition.getName());
+ addIfExists(map, GraphPropertiesDictionary.PROPERTY_COUNTER, componentInstDataDefinition.getPropertyValueCounter());
+ addIfExists(map, GraphPropertiesDictionary.ATTRIBUTE_COUNTER, componentInstDataDefinition.getAttributeValueCounter());
+ addIfExists(map, GraphPropertiesDictionary.INSTANCE_COUNTER, groupInstanceCounter);
+ addIfExists(map, GraphPropertiesDictionary.NORMALIZED_NAME, componentInstDataDefinition.getNormalizedName());
+ if (componentInstDataDefinition.getOriginType() != null) {
+ addIfExists(map, GraphPropertiesDictionary.ORIGIN_TYPE, componentInstDataDefinition.getOriginType().getValue());
+ }
+ addIfExists(map, GraphPropertiesDictionary.CUSTOMIZATION_UUID, componentInstDataDefinition.getCustomizationUUID());
+ return map;
+ }
+
+ @Override
+ public String getUniqueId() {
+ return componentInstDataDefinition.getUniqueId();
+ }
+
+ public String getName() {
+ return componentInstDataDefinition.getName();
+ }
+
+ @Override
+ public String getUniqueIdKey() {
+ return GraphPropertiesDictionary.UNIQUE_ID.getProperty();
+ }
+
+ public ComponentInstanceDataDefinition getComponentInstDataDefinition() {
+ return componentInstDataDefinition;
+ }
+
+ public void setComponentInstDataDefinition(ComponentInstanceDataDefinition componentInstDataDefinition) {
+ this.componentInstDataDefinition = componentInstDataDefinition;
+ }
+
+ @Override
+ public String toString() {
+ return "ComponentInstanceData [componentInstDataDefinition=" + componentInstDataDefinition + "]";
+ }
+
+ public Integer getGroupInstanceCounter() {
+ return groupInstanceCounter;
+ }
+
+ public void setGroupInstanceCounter(Integer componentInstanceCounter) {
+ this.groupInstanceCounter = componentInstanceCounter;
+ }
+
+ public Integer increaseAndGetGroupInstanceCounter() {
+ return ++groupInstanceCounter;
+ }
}
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 d2612b9db7..0341be73f6 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
@@ -7,9 +7,9 @@
* 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.
@@ -17,112 +17,110 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.resources.data;
+import java.util.HashMap;
+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.neo4j.GraphPropertiesDictionaryExtractor;
import org.openecomp.sdc.be.datatypes.components.ComponentMetadataDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import java.util.HashMap;
-import java.util.Map;
-
public abstract class ComponentMetadataData extends GraphNode {
- protected ComponentMetadataDataDefinition metadataDataDefinition;
- protected Integer componentInstanceCounter;
-
- public ComponentMetadataData(NodeTypeEnum label, ComponentMetadataDataDefinition metadataDataDefinition) {
- super(label);
- this.metadataDataDefinition = metadataDataDefinition;
- this.componentInstanceCounter = 0;
- }
-
- public ComponentMetadataData(NodeTypeEnum label, ComponentMetadataDataDefinition metadataDataDefinition, GraphPropertiesDictionaryExtractor extractor) {
- this(label, metadataDataDefinition);
- metadataDataDefinition.setUniqueId(extractor.getUniqueId());
- metadataDataDefinition.setCreationDate(extractor.getCreationDate());
- metadataDataDefinition.setDescription(extractor.getDescription());
- metadataDataDefinition.setConformanceLevel(extractor.getConformanceLevel());
- metadataDataDefinition.setIcon(extractor.getIcon());
- metadataDataDefinition.setHighestVersion(extractor.isHighestVersion());
- metadataDataDefinition.setLastUpdateDate(extractor.getLastUpdateDate());
- metadataDataDefinition.setName(extractor.getName());
- metadataDataDefinition.setState(extractor.getState());
- metadataDataDefinition.setTags(extractor.getTags());
- metadataDataDefinition.setVersion(extractor.getVersion());
- metadataDataDefinition.setContactId(extractor.getContactId());
- metadataDataDefinition.setUUID(extractor.getUUID());
- metadataDataDefinition.setNormalizedName(extractor.getNormalizedName());
- metadataDataDefinition.setSystemName(extractor.getSystemName());
- metadataDataDefinition.setIsDeleted(extractor.isDeleted());
- metadataDataDefinition.setProjectCode(extractor.getProjectCode());
- metadataDataDefinition.setCsarUUID(extractor.getCsarUuid());
- metadataDataDefinition.setCsarVersion(extractor.getCsarVersion());
- metadataDataDefinition.setImportedToscaChecksum(extractor.getImportedToscaChecksum());
- metadataDataDefinition.setInvariantUUID(extractor.getInvariantUuid());
- componentInstanceCounter = extractor.getInstanceCounter();
- }
-
- @Override
- public Map<String, Object> toGraphMap() {
- Map<String, Object> map = new HashMap<>();
-
- addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, metadataDataDefinition.getUniqueId());
- 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());
- addIfExists(map, GraphPropertiesDictionary.STATE, metadataDataDefinition.getState());
- addIfExists(map, GraphPropertiesDictionary.TAGS, metadataDataDefinition.getTags());
- addIfExists(map, GraphPropertiesDictionary.CONTACT_ID, metadataDataDefinition.getContactId());
- addIfExists(map, GraphPropertiesDictionary.NAME, metadataDataDefinition.getName());
- addIfExists(map, GraphPropertiesDictionary.UUID, metadataDataDefinition.getUUID());
- addIfExists(map, GraphPropertiesDictionary.NORMALIZED_NAME, metadataDataDefinition.getNormalizedName());
- addIfExists(map, GraphPropertiesDictionary.SYSTEM_NAME, metadataDataDefinition.getSystemName());
- addIfExists(map, GraphPropertiesDictionary.IS_DELETED, metadataDataDefinition.isDeleted());
- addIfExists(map, GraphPropertiesDictionary.INSTANCE_COUNTER, componentInstanceCounter);
- addIfExists(map, GraphPropertiesDictionary.PROJECT_CODE, metadataDataDefinition.getProjectCode());
- addIfExists(map, GraphPropertiesDictionary.CSAR_UUID, metadataDataDefinition.getCsarUUID());
- addIfExists(map, GraphPropertiesDictionary.CSAR_VERSION, metadataDataDefinition.getCsarVersion());
- addIfExists(map, GraphPropertiesDictionary.IMPORTED_TOSCA_CHECKSUM, metadataDataDefinition.getImportedToscaChecksum());
- addIfExists(map, GraphPropertiesDictionary.INVARIANT_UUID, metadataDataDefinition.getInvariantUUID());
- return map;
- }
-
- @Override
- public String getUniqueId() {
- return metadataDataDefinition.getUniqueId();
- }
-
- public ComponentMetadataDataDefinition getMetadataDataDefinition() {
- return metadataDataDefinition;
- }
-
- public void setMetadataDataDefinition(ComponentMetadataDataDefinition metadataDataDefinition) {
- this.metadataDataDefinition = metadataDataDefinition;
- }
-
- public Integer getComponentInstanceCounter() {
- return componentInstanceCounter;
- }
-
- public void setComponentInstanceCounter(Integer componentInstanceCounter) {
- this.componentInstanceCounter = componentInstanceCounter;
- }
-
- public Integer increaseAndGetComponentInstanceCounter() {
- return ++componentInstanceCounter;
- }
-
- @Override
- public String toString() {
- return "ComponentMetadataData [metadataDataDefinition=" + metadataDataDefinition + ", componentInstanceCounter=" + componentInstanceCounter + "]";
- }
-
+ protected ComponentMetadataDataDefinition metadataDataDefinition;
+ protected Integer componentInstanceCounter;
+
+ public ComponentMetadataData(NodeTypeEnum label, ComponentMetadataDataDefinition metadataDataDefinition) {
+ super(label);
+ this.metadataDataDefinition = metadataDataDefinition;
+ this.componentInstanceCounter = 0;
+ }
+
+ public ComponentMetadataData(NodeTypeEnum label, ComponentMetadataDataDefinition metadataDataDefinition,
+ GraphPropertiesDictionaryExtractor extractor) {
+ this(label, metadataDataDefinition);
+ metadataDataDefinition.setUniqueId(extractor.getUniqueId());
+ metadataDataDefinition.setCreationDate(extractor.getCreationDate());
+ metadataDataDefinition.setDescription(extractor.getDescription());
+ metadataDataDefinition.setConformanceLevel(extractor.getConformanceLevel());
+ metadataDataDefinition.setIcon(extractor.getIcon());
+ metadataDataDefinition.setHighestVersion(extractor.isHighestVersion());
+ metadataDataDefinition.setLastUpdateDate(extractor.getLastUpdateDate());
+ metadataDataDefinition.setName(extractor.getName());
+ metadataDataDefinition.setState(extractor.getState());
+ metadataDataDefinition.setTags(extractor.getTags());
+ metadataDataDefinition.setVersion(extractor.getVersion());
+ metadataDataDefinition.setContactId(extractor.getContactId());
+ metadataDataDefinition.setUUID(extractor.getUUID());
+ metadataDataDefinition.setNormalizedName(extractor.getNormalizedName());
+ metadataDataDefinition.setSystemName(extractor.getSystemName());
+ metadataDataDefinition.setIsDeleted(extractor.isDeleted());
+ metadataDataDefinition.setProjectCode(extractor.getProjectCode());
+ metadataDataDefinition.setCsarUUID(extractor.getCsarUuid());
+ metadataDataDefinition.setCsarVersion(extractor.getCsarVersion());
+ metadataDataDefinition.setImportedToscaChecksum(extractor.getImportedToscaChecksum());
+ metadataDataDefinition.setInvariantUUID(extractor.getInvariantUuid());
+ componentInstanceCounter = extractor.getInstanceCounter();
+ }
+
+ @Override
+ public Map<String, Object> toGraphMap() {
+ Map<String, Object> map = new HashMap<>();
+ addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, metadataDataDefinition.getUniqueId());
+ 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());
+ addIfExists(map, GraphPropertiesDictionary.STATE, metadataDataDefinition.getState());
+ addIfExists(map, GraphPropertiesDictionary.TAGS, metadataDataDefinition.getTags());
+ addIfExists(map, GraphPropertiesDictionary.CONTACT_ID, metadataDataDefinition.getContactId());
+ addIfExists(map, GraphPropertiesDictionary.NAME, metadataDataDefinition.getName());
+ addIfExists(map, GraphPropertiesDictionary.UUID, metadataDataDefinition.getUUID());
+ addIfExists(map, GraphPropertiesDictionary.NORMALIZED_NAME, metadataDataDefinition.getNormalizedName());
+ addIfExists(map, GraphPropertiesDictionary.SYSTEM_NAME, metadataDataDefinition.getSystemName());
+ addIfExists(map, GraphPropertiesDictionary.IS_DELETED, metadataDataDefinition.isDeleted());
+ addIfExists(map, GraphPropertiesDictionary.INSTANCE_COUNTER, componentInstanceCounter);
+ addIfExists(map, GraphPropertiesDictionary.PROJECT_CODE, metadataDataDefinition.getProjectCode());
+ addIfExists(map, GraphPropertiesDictionary.CSAR_UUID, metadataDataDefinition.getCsarUUID());
+ addIfExists(map, GraphPropertiesDictionary.CSAR_VERSION, metadataDataDefinition.getCsarVersion());
+ addIfExists(map, GraphPropertiesDictionary.IMPORTED_TOSCA_CHECKSUM, metadataDataDefinition.getImportedToscaChecksum());
+ addIfExists(map, GraphPropertiesDictionary.INVARIANT_UUID, metadataDataDefinition.getInvariantUUID());
+ return map;
+ }
+
+ @Override
+ public String getUniqueId() {
+ return metadataDataDefinition.getUniqueId();
+ }
+
+ public ComponentMetadataDataDefinition getMetadataDataDefinition() {
+ return metadataDataDefinition;
+ }
+
+ public void setMetadataDataDefinition(ComponentMetadataDataDefinition metadataDataDefinition) {
+ this.metadataDataDefinition = metadataDataDefinition;
+ }
+
+ public Integer getComponentInstanceCounter() {
+ return componentInstanceCounter;
+ }
+
+ public void setComponentInstanceCounter(Integer componentInstanceCounter) {
+ this.componentInstanceCounter = componentInstanceCounter;
+ }
+
+ public Integer increaseAndGetComponentInstanceCounter() {
+ return ++componentInstanceCounter;
+ }
+
+ @Override
+ public String toString() {
+ return "ComponentMetadataData [metadataDataDefinition=" + metadataDataDefinition + ", componentInstanceCounter=" + componentInstanceCounter
+ + "]";
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ConsumerData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ConsumerData.java
index e23b134f44..fb514b8948 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ConsumerData.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ConsumerData.java
@@ -1,5 +1,4 @@
-package org.openecomp.sdc.be.resources.data;
-/*-
+package org.openecomp.sdc.be.resources.data; /*-
* ============LICENSE_START=======================================================
* SDC
* ================================================================================
@@ -19,15 +18,14 @@ package org.openecomp.sdc.be.resources.data;
* ============LICENSE_END=========================================================
*/
+import java.util.HashMap;
+import java.util.Map;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
import org.openecomp.sdc.be.datatypes.elements.ConsumerDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import java.util.HashMap;
-import java.util.Map;
-
public class ConsumerData extends GraphNode {
private ConsumerDataDefinition consumerDataDefinition;
@@ -40,25 +38,19 @@ public class ConsumerData extends GraphNode {
public ConsumerData(ConsumerDataDefinition consumerDataDefinition) {
super(NodeTypeEnum.ConsumerCredentials);
this.consumerDataDefinition = consumerDataDefinition;
-
}
public ConsumerData(Map<String, Object> properties) {
super(NodeTypeEnum.ConsumerCredentials);
consumerDataDefinition = new ConsumerDataDefinition();
- consumerDataDefinition.setConsumerDetailsLastupdatedtime(
- (Long) properties.get(GraphPropertiesDictionary.CONSUMER_DETAILS_LAST_UPDATED_TIME.getProperty()));
- consumerDataDefinition.setConsumerLastAuthenticationTime(
- (Long) properties.get(GraphPropertiesDictionary.CONSUMER_LAST_AUTHENTICATION_TIME.getProperty()));
consumerDataDefinition
- .setConsumerName((String) properties.get(GraphPropertiesDictionary.CONSUMER_NAME.getProperty()));
- consumerDataDefinition.setConsumerPassword(
- (String) properties.get(GraphPropertiesDictionary.CONSUMER_PASSWORD.getProperty()));
+ .setConsumerDetailsLastupdatedtime((Long) properties.get(GraphPropertiesDictionary.CONSUMER_DETAILS_LAST_UPDATED_TIME.getProperty()));
consumerDataDefinition
- .setConsumerSalt((String) properties.get(GraphPropertiesDictionary.CONSUMER_SALT.getProperty()));
- consumerDataDefinition.setLastModfierAtuid(
- (String) properties.get(GraphPropertiesDictionary.LAST_MODIFIER_USER_ID.getProperty()));
-
+ .setConsumerLastAuthenticationTime((Long) properties.get(GraphPropertiesDictionary.CONSUMER_LAST_AUTHENTICATION_TIME.getProperty()));
+ consumerDataDefinition.setConsumerName((String) properties.get(GraphPropertiesDictionary.CONSUMER_NAME.getProperty()));
+ consumerDataDefinition.setConsumerPassword((String) properties.get(GraphPropertiesDictionary.CONSUMER_PASSWORD.getProperty()));
+ consumerDataDefinition.setConsumerSalt((String) properties.get(GraphPropertiesDictionary.CONSUMER_SALT.getProperty()));
+ consumerDataDefinition.setLastModfierAtuid((String) properties.get(GraphPropertiesDictionary.LAST_MODIFIER_USER_ID.getProperty()));
}
@Override
@@ -79,16 +71,13 @@ public class ConsumerData extends GraphNode {
public Map<String, Object> toGraphMap() {
Map<String, Object> map = new HashMap<>();
addIfExists(map, GraphPropertiesDictionary.CONSUMER_NAME, this.consumerDataDefinition.getConsumerName());
- addIfExists(map, GraphPropertiesDictionary.CONSUMER_PASSWORD,
- this.consumerDataDefinition.getConsumerPassword());
+ addIfExists(map, GraphPropertiesDictionary.CONSUMER_PASSWORD, this.consumerDataDefinition.getConsumerPassword());
addIfExists(map, GraphPropertiesDictionary.CONSUMER_SALT, this.consumerDataDefinition.getConsumerSalt());
addIfExists(map, GraphPropertiesDictionary.CONSUMER_LAST_AUTHENTICATION_TIME,
- this.consumerDataDefinition.getConsumerLastAuthenticationTime());
+ this.consumerDataDefinition.getConsumerLastAuthenticationTime());
addIfExists(map, GraphPropertiesDictionary.CONSUMER_DETAILS_LAST_UPDATED_TIME,
- this.consumerDataDefinition.getConsumerDetailsLastupdatedtime());
- addIfExists(map, GraphPropertiesDictionary.LAST_MODIFIER_USER_ID,
- this.consumerDataDefinition.getLastModfierAtuid());
-
+ this.consumerDataDefinition.getConsumerDetailsLastupdatedtime());
+ addIfExists(map, GraphPropertiesDictionary.LAST_MODIFIER_USER_ID, this.consumerDataDefinition.getLastModfierAtuid());
return map;
}
@@ -103,5 +92,3 @@ public class ConsumerData extends GraphNode {
return "ConsumerData [consumerDataDefinition=" + consumerDataDefinition + "]";
}
}
-
-
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/DAOArtifactData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/DAOArtifactData.java
index 2b79c2d79f..87bae33a1c 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/DAOArtifactData.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/DAOArtifactData.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,79 +17,70 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.resources.data;
import com.datastax.driver.mapping.annotations.Column;
import com.datastax.driver.mapping.annotations.PartitionKey;
import com.datastax.driver.mapping.annotations.Table;
import com.datastax.driver.mapping.annotations.Transient;
+import java.nio.ByteBuffer;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
-import java.nio.ByteBuffer;
-
@Getter
@NoArgsConstructor
@Table(keyspace = "sdcartifact", name = "resources")
public class DAOArtifactData {
- public static final String RRESOURCE_ID_FIELD = "resourceId";
-
- public static final String SERVICE_NAME_FIELD = "serviceName";
- public static final String SERVICE_VERSION_FIELD = "serviceVersion";
- public static final String ARTIFACT_NAME_FIELD = "artifactName";
-
- public static final String delim = ":";
-
- @PartitionKey
- @Column(name = "id")
- @Setter
- private String id;
-
- /*
- * Base64 encoded Artifact file data
- */
-
- @Column
- private ByteBuffer data;
-
-
- public DAOArtifactData(String id) {
-
- this.id = id;
- }
-
- public DAOArtifactData(String artifactId, byte[] data) {
- super();
- this.id = artifactId;
- if (data != null) {
- this.data = ByteBuffer.wrap(data.clone());
- // this.data = data.clone();
- }
-
- }
-
- @Transient
- public byte[] getDataAsArray() {
- // return data;
- if (data != null) {
- return data.array();
- }
- return null;
- }
-
- public void setDataAsArray(byte[] data) {
- if (data != null) {
- // this.data = data.clone();
- this.data = ByteBuffer.wrap(data.clone());
- }
- }
- public void setData(ByteBuffer data) {
- if (data != null) {
- // this.data = data.clone();
- this.data = data.duplicate();
- }
- }
+ public static final String RRESOURCE_ID_FIELD = "resourceId";
+ public static final String SERVICE_NAME_FIELD = "serviceName";
+ public static final String SERVICE_VERSION_FIELD = "serviceVersion";
+ public static final String ARTIFACT_NAME_FIELD = "artifactName";
+ public static final String delim = ":";
+ @PartitionKey
+ @Column(name = "id")
+ @Setter
+ private String id;
+ /*
+ * Base64 encoded Artifact file data
+ */
+ @Column
+ private ByteBuffer data;
+
+ public DAOArtifactData(String id) {
+ this.id = id;
+ }
+
+ public DAOArtifactData(String artifactId, byte[] data) {
+ super();
+ this.id = artifactId;
+ if (data != null) {
+ this.data = ByteBuffer.wrap(data.clone());
+ // this.data = data.clone();
+ }
+ }
+
+ @Transient
+ public byte[] getDataAsArray() {
+ // return data;
+ if (data != null) {
+ return data.array();
+ }
+ return null;
+ }
+
+ public void setDataAsArray(byte[] data) {
+ if (data != null) {
+ // this.data = data.clone();
+ this.data = ByteBuffer.wrap(data.clone());
+ }
+ }
+
+ public void setData(ByteBuffer data) {
+ if (data != null) {
+ // this.data = data.clone();
+ this.data = data.duplicate();
+ }
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/DataTypeData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/DataTypeData.java
index 897c24ff5b..95b22a8ac3 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/DataTypeData.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/DataTypeData.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,90 +17,67 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.resources.data;
+import java.util.HashMap;
+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.datatypes.elements.DataTypeDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import java.util.HashMap;
-import java.util.Map;
-
public class DataTypeData extends GraphNode {
- DataTypeDataDefinition dataTypeDataDefinition;
-
- public DataTypeData() {
- super(NodeTypeEnum.DataType);
- dataTypeDataDefinition = new DataTypeDataDefinition();
- }
-
- public DataTypeData(DataTypeDataDefinition dataTypeDataDefinition) {
- super(NodeTypeEnum.DataType);
- this.dataTypeDataDefinition = dataTypeDataDefinition;
- // this.constraints = constraints;
- }
-
- public DataTypeData(Map<String, Object> properties) {
-
- this();
-
- dataTypeDataDefinition.setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
-
- dataTypeDataDefinition.setName((String) properties.get(GraphPropertiesDictionary.NAME.getProperty()));
-
- dataTypeDataDefinition
- .setDescription((String) properties.get(GraphPropertiesDictionary.DESCRIPTION.getProperty()));
-
- dataTypeDataDefinition
- .setDerivedFromName((String) properties.get(GraphPropertiesDictionary.DERIVED_FROM.getProperty()));
-
- dataTypeDataDefinition
- .setCreationTime((Long) properties.get(GraphPropertiesDictionary.CREATION_DATE.getProperty()));
-
- dataTypeDataDefinition
- .setModificationTime((Long) properties.get(GraphPropertiesDictionary.LAST_UPDATE_DATE.getProperty()));
-
- }
-
- @Override
- public Map<String, Object> toGraphMap() {
-
- Map<String, Object> map = new HashMap<>();
-
- addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, dataTypeDataDefinition.getUniqueId());
-
- addIfExists(map, GraphPropertiesDictionary.NAME, dataTypeDataDefinition.getName());
-
- addIfExists(map, GraphPropertiesDictionary.DESCRIPTION, dataTypeDataDefinition.getDescription());
-
- addIfExists(map, GraphPropertiesDictionary.DERIVED_FROM, dataTypeDataDefinition.getDerivedFromName());
-
- addIfExists(map, GraphPropertiesDictionary.CREATION_DATE, dataTypeDataDefinition.getCreationTime());
-
- addIfExists(map, GraphPropertiesDictionary.LAST_UPDATE_DATE, dataTypeDataDefinition.getModificationTime());
-
- return map;
- }
-
- public DataTypeDataDefinition getDataTypeDataDefinition() {
- return dataTypeDataDefinition;
- }
-
- public void setDataTypeDataDefinition(DataTypeDataDefinition dataTypeDataDefinition) {
- this.dataTypeDataDefinition = dataTypeDataDefinition;
- }
-
- @Override
- public String toString() {
- return "DataTypeData [dataTypeDataDefinition=" + dataTypeDataDefinition + "]";
- }
-
- @Override
- public String getUniqueId() {
- return this.dataTypeDataDefinition.getUniqueId();
- }
-
+ DataTypeDataDefinition dataTypeDataDefinition;
+
+ public DataTypeData() {
+ super(NodeTypeEnum.DataType);
+ dataTypeDataDefinition = new DataTypeDataDefinition();
+ }
+
+ public DataTypeData(DataTypeDataDefinition dataTypeDataDefinition) {
+ super(NodeTypeEnum.DataType);
+ this.dataTypeDataDefinition = dataTypeDataDefinition;
+ // this.constraints = constraints;
+ }
+
+ public DataTypeData(Map<String, Object> properties) {
+ this();
+ dataTypeDataDefinition.setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
+ dataTypeDataDefinition.setName((String) properties.get(GraphPropertiesDictionary.NAME.getProperty()));
+ dataTypeDataDefinition.setDescription((String) properties.get(GraphPropertiesDictionary.DESCRIPTION.getProperty()));
+ dataTypeDataDefinition.setDerivedFromName((String) properties.get(GraphPropertiesDictionary.DERIVED_FROM.getProperty()));
+ dataTypeDataDefinition.setCreationTime((Long) properties.get(GraphPropertiesDictionary.CREATION_DATE.getProperty()));
+ dataTypeDataDefinition.setModificationTime((Long) properties.get(GraphPropertiesDictionary.LAST_UPDATE_DATE.getProperty()));
+ }
+
+ @Override
+ public Map<String, Object> toGraphMap() {
+ Map<String, Object> map = new HashMap<>();
+ addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, dataTypeDataDefinition.getUniqueId());
+ addIfExists(map, GraphPropertiesDictionary.NAME, dataTypeDataDefinition.getName());
+ addIfExists(map, GraphPropertiesDictionary.DESCRIPTION, dataTypeDataDefinition.getDescription());
+ addIfExists(map, GraphPropertiesDictionary.DERIVED_FROM, dataTypeDataDefinition.getDerivedFromName());
+ addIfExists(map, GraphPropertiesDictionary.CREATION_DATE, dataTypeDataDefinition.getCreationTime());
+ addIfExists(map, GraphPropertiesDictionary.LAST_UPDATE_DATE, dataTypeDataDefinition.getModificationTime());
+ return map;
+ }
+
+ public DataTypeDataDefinition getDataTypeDataDefinition() {
+ return dataTypeDataDefinition;
+ }
+
+ public void setDataTypeDataDefinition(DataTypeDataDefinition dataTypeDataDefinition) {
+ this.dataTypeDataDefinition = dataTypeDataDefinition;
+ }
+
+ @Override
+ public String toString() {
+ return "DataTypeData [dataTypeDataDefinition=" + dataTypeDataDefinition + "]";
+ }
+
+ @Override
+ public String getUniqueId() {
+ return this.dataTypeDataDefinition.getUniqueId();
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/EntryData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/EntryData.java
index a3229bf88a..7df9545b67 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/EntryData.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/EntryData.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,36 +17,34 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.resources.data;
import java.util.Map;
public class EntryData<K, V> implements Map.Entry<K, V> {
- private final K key;
- private V value;
-
- public EntryData(K key, V value) {
- this.key = key;
- this.value = value;
- }
-
- @Override
- public K getKey() {
- return key;
- }
-
- @Override
- public V getValue() {
- return value;
- }
-
- @Override
- public V setValue(V value) {
- V old = this.value;
- this.value = value;
- return old;
- }
-
+ private final K key;
+ private V value;
+
+ public EntryData(K key, V value) {
+ this.key = key;
+ this.value = value;
+ }
+
+ @Override
+ public K getKey() {
+ return key;
+ }
+
+ @Override
+ public V getValue() {
+ return value;
+ }
+
+ @Override
+ public V setValue(V value) {
+ V old = this.value;
+ this.value = value;
+ return old;
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/GraphNodeLock.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/GraphNodeLock.java
index a7981edcde..ba84d67471 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/GraphNodeLock.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/GraphNodeLock.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,63 +17,57 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.resources.data;
+import java.util.HashMap;
+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.datatypes.enums.NodeTypeEnum;
-import java.util.HashMap;
-import java.util.Map;
-
public class GraphNodeLock extends GraphNode {
- private String uniqueId;
- private Long time;
-
- public GraphNodeLock() {
- super(NodeTypeEnum.LockNode);
- time = System.currentTimeMillis();
- }
-
- public GraphNodeLock(String uniqueId) {
- this();
- this.uniqueId = uniqueId;
- }
-
- public GraphNodeLock(Map<String, Object> properties) {
- super(NodeTypeEnum.LockNode);
-
- setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
- setTime((Long) properties.get(GraphPropertiesDictionary.CREATION_DATE.getProperty()));
- }
-
- @Override
- public String getUniqueId() {
- return uniqueId;
- }
-
- @Override
- public Map<String, Object> toGraphMap() {
-
- Map<String, Object> map = new HashMap<>();
-
- addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, uniqueId);
- addIfExists(map, GraphPropertiesDictionary.CREATION_DATE, time);
- return map;
- }
-
- public void setUniqueId(String uniqueId) {
- this.uniqueId = uniqueId;
- }
-
- public Long getTime() {
- return time;
- }
-
- public void setTime(Long time) {
- this.time = time;
- }
-
+ private String uniqueId;
+ private Long time;
+
+ public GraphNodeLock() {
+ super(NodeTypeEnum.LockNode);
+ time = System.currentTimeMillis();
+ }
+
+ public GraphNodeLock(String uniqueId) {
+ this();
+ this.uniqueId = uniqueId;
+ }
+
+ public GraphNodeLock(Map<String, Object> properties) {
+ super(NodeTypeEnum.LockNode);
+ setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
+ setTime((Long) properties.get(GraphPropertiesDictionary.CREATION_DATE.getProperty()));
+ }
+
+ @Override
+ public String getUniqueId() {
+ return uniqueId;
+ }
+
+ public void setUniqueId(String uniqueId) {
+ this.uniqueId = uniqueId;
+ }
+
+ @Override
+ public Map<String, Object> toGraphMap() {
+ Map<String, Object> map = new HashMap<>();
+ addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, uniqueId);
+ addIfExists(map, GraphPropertiesDictionary.CREATION_DATE, time);
+ return map;
+ }
+
+ public Long getTime() {
+ return time;
+ }
+
+ public void setTime(Long time) {
+ this.time = time;
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/GroupData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/GroupData.java
index 54d55d2645..63f6651e19 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/GroupData.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/GroupData.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,81 +17,71 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.resources.data;
+import java.util.HashMap;
+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.datatypes.elements.GroupDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import java.util.HashMap;
-import java.util.Map;
-
public class GroupData extends GraphNode {
- GroupDataDefinition groupDataDefinition;
-
- public GroupData() {
- super(NodeTypeEnum.Group);
- groupDataDefinition = new GroupDataDefinition();
- }
-
- public GroupData(GroupDataDefinition groupDataDefinition) {
- super(NodeTypeEnum.Group);
- this.groupDataDefinition = groupDataDefinition;
- }
-
- public GroupData(Map<String, Object> properties) {
-
- super(NodeTypeEnum.Group);
-
- groupDataDefinition = new GroupDataDefinition();
-
- groupDataDefinition.setName((String) properties.get(GraphPropertiesDictionary.NAME.getProperty()));
- groupDataDefinition.setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
- groupDataDefinition.setType((String) properties.get(GraphPropertiesDictionary.TYPE.getProperty()));
- groupDataDefinition.setVersion((String) properties.get(GraphPropertiesDictionary.VERSION.getProperty()));
- groupDataDefinition
- .setInvariantUUID((String) properties.get(GraphPropertiesDictionary.INVARIANT_UUID.getProperty()));
- groupDataDefinition.setGroupUUID((String) properties.get(GraphPropertiesDictionary.GROUP_UUID.getProperty()));
- groupDataDefinition
- .setDescription((String) properties.get(GraphPropertiesDictionary.DESCRIPTION.getProperty()));
- groupDataDefinition.setPropertyValueCounter(
- (Integer) properties.get(GraphPropertiesDictionary.PROPERTY_COUNTER.getProperty()));
-
- }
-
- @Override
- public String getUniqueId() {
- return groupDataDefinition.getUniqueId();
- }
-
- @Override
- public Map<String, Object> toGraphMap() {
- Map<String, Object> map = new HashMap<>();
- addIfExists(map, GraphPropertiesDictionary.NAME, groupDataDefinition.getName());
- addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, groupDataDefinition.getUniqueId());
- addIfExists(map, GraphPropertiesDictionary.TYPE, groupDataDefinition.getType());
- addIfExists(map, GraphPropertiesDictionary.VERSION, groupDataDefinition.getVersion());
- addIfExists(map, GraphPropertiesDictionary.INVARIANT_UUID, groupDataDefinition.getInvariantUUID());
- addIfExists(map, GraphPropertiesDictionary.DESCRIPTION, groupDataDefinition.getDescription());
- addIfExists(map, GraphPropertiesDictionary.PROPERTY_COUNTER, groupDataDefinition.getPropertyValueCounter());
- addIfExists(map, GraphPropertiesDictionary.GROUP_UUID, groupDataDefinition.getGroupUUID());
-
- return map;
- }
-
- public GroupDataDefinition getGroupDataDefinition() {
- return groupDataDefinition;
- }
-
- public void setGroupDataDefinition(GroupDataDefinition groupDataDefinition) {
- this.groupDataDefinition = groupDataDefinition;
- }
-
- @Override
- public String toString() {
- return "GroupData [ " + groupDataDefinition.toString() + "]";
- }
+ GroupDataDefinition groupDataDefinition;
+
+ public GroupData() {
+ super(NodeTypeEnum.Group);
+ groupDataDefinition = new GroupDataDefinition();
+ }
+
+ public GroupData(GroupDataDefinition groupDataDefinition) {
+ super(NodeTypeEnum.Group);
+ this.groupDataDefinition = groupDataDefinition;
+ }
+
+ public GroupData(Map<String, Object> properties) {
+ super(NodeTypeEnum.Group);
+ groupDataDefinition = new GroupDataDefinition();
+ groupDataDefinition.setName((String) properties.get(GraphPropertiesDictionary.NAME.getProperty()));
+ groupDataDefinition.setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
+ groupDataDefinition.setType((String) properties.get(GraphPropertiesDictionary.TYPE.getProperty()));
+ groupDataDefinition.setVersion((String) properties.get(GraphPropertiesDictionary.VERSION.getProperty()));
+ groupDataDefinition.setInvariantUUID((String) properties.get(GraphPropertiesDictionary.INVARIANT_UUID.getProperty()));
+ groupDataDefinition.setGroupUUID((String) properties.get(GraphPropertiesDictionary.GROUP_UUID.getProperty()));
+ groupDataDefinition.setDescription((String) properties.get(GraphPropertiesDictionary.DESCRIPTION.getProperty()));
+ groupDataDefinition.setPropertyValueCounter((Integer) properties.get(GraphPropertiesDictionary.PROPERTY_COUNTER.getProperty()));
+ }
+
+ @Override
+ public String getUniqueId() {
+ return groupDataDefinition.getUniqueId();
+ }
+
+ @Override
+ public Map<String, Object> toGraphMap() {
+ Map<String, Object> map = new HashMap<>();
+ addIfExists(map, GraphPropertiesDictionary.NAME, groupDataDefinition.getName());
+ addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, groupDataDefinition.getUniqueId());
+ addIfExists(map, GraphPropertiesDictionary.TYPE, groupDataDefinition.getType());
+ addIfExists(map, GraphPropertiesDictionary.VERSION, groupDataDefinition.getVersion());
+ addIfExists(map, GraphPropertiesDictionary.INVARIANT_UUID, groupDataDefinition.getInvariantUUID());
+ addIfExists(map, GraphPropertiesDictionary.DESCRIPTION, groupDataDefinition.getDescription());
+ addIfExists(map, GraphPropertiesDictionary.PROPERTY_COUNTER, groupDataDefinition.getPropertyValueCounter());
+ addIfExists(map, GraphPropertiesDictionary.GROUP_UUID, groupDataDefinition.getGroupUUID());
+ return map;
+ }
+
+ public GroupDataDefinition getGroupDataDefinition() {
+ return groupDataDefinition;
+ }
+
+ public void setGroupDataDefinition(GroupDataDefinition groupDataDefinition) {
+ this.groupDataDefinition = groupDataDefinition;
+ }
+
+ @Override
+ public String toString() {
+ return "GroupData [ " + groupDataDefinition.toString() + "]";
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/GroupInstanceData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/GroupInstanceData.java
index 88ff20e730..489bfec4c4 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/GroupInstanceData.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/GroupInstanceData.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,109 +17,83 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.resources.data;
+import java.util.HashMap;
+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.datatypes.elements.GroupInstanceDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import java.util.HashMap;
-import java.util.Map;
-
-
public class GroupInstanceData extends GraphNode {
-
- GroupInstanceDataDefinition groupDataDefinition;
-
- public GroupInstanceData() {
- super(NodeTypeEnum.GroupInstance);
- this.groupDataDefinition = new GroupInstanceDataDefinition();
- }
-
- public GroupInstanceData(GroupInstanceDataDefinition groupDataDefinition) {
- super(NodeTypeEnum.GroupInstance);
- this.groupDataDefinition = groupDataDefinition;
- }
-
- public GroupInstanceData(Map<String, Object> properties) {
-
- this();
-
- groupDataDefinition
- .setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
- groupDataDefinition
- .setGroupUid((String) properties.get(GraphPropertiesDictionary.TYPE.getProperty()));
- groupDataDefinition
- .setCreationTime((Long) properties.get(GraphPropertiesDictionary.CREATION_DATE.getProperty()));
- groupDataDefinition
- .setModificationTime((Long) properties.get(GraphPropertiesDictionary.LAST_UPDATE_DATE.getProperty()));
-
- groupDataDefinition
- .setPosX((String) properties.get(GraphPropertiesDictionary.POSITION_X.getProperty()));
- groupDataDefinition
- .setPosY((String) properties.get(GraphPropertiesDictionary.POSITION_Y.getProperty()));
- groupDataDefinition.setName((String) properties.get(GraphPropertiesDictionary.NAME.getProperty()));
- groupDataDefinition.setPropertyValueCounter(
- (Integer) properties.get(GraphPropertiesDictionary.PROPERTY_COUNTER.getProperty()));
-
- groupDataDefinition
- .setNormalizedName((String) properties.get(GraphPropertiesDictionary.NORMALIZED_NAME.getProperty()));
-
- groupDataDefinition
- .setCustomizationUUID((String) properties.get(GraphPropertiesDictionary.CUSTOMIZATION_UUID.getProperty()));
- }
-
- @Override
- public Map<String, Object> toGraphMap() {
-
- Map<String, Object> map = new HashMap<>();
-
- addIfExists(map, GraphPropertiesDictionary.TYPE, groupDataDefinition.getGroupUid());
- addIfExists(map, GraphPropertiesDictionary.CREATION_DATE, groupDataDefinition.getCreationTime());
- addIfExists(map, GraphPropertiesDictionary.LAST_UPDATE_DATE, groupDataDefinition.getModificationTime());
-
- addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, groupDataDefinition.getUniqueId());
- addIfExists(map, GraphPropertiesDictionary.POSITION_X, groupDataDefinition.getPosX());
- addIfExists(map, GraphPropertiesDictionary.POSITION_Y, groupDataDefinition.getPosY());
- addIfExists(map, GraphPropertiesDictionary.NAME, groupDataDefinition.getName());
- addIfExists(map, GraphPropertiesDictionary.PROPERTY_COUNTER,
- groupDataDefinition.getPropertyValueCounter());
-
- addIfExists(map, GraphPropertiesDictionary.NORMALIZED_NAME, groupDataDefinition.getNormalizedName());
-
- addIfExists(map, GraphPropertiesDictionary.CUSTOMIZATION_UUID, groupDataDefinition.getCustomizationUUID());
-
- return map;
- }
-
- @Override
- public String getUniqueId() {
- return groupDataDefinition.getUniqueId();
- }
-
- public String getName() {
- return groupDataDefinition.getName();
- }
-
- @Override
- public String getUniqueIdKey() {
- return GraphPropertiesDictionary.UNIQUE_ID.getProperty();
- }
-
- public GroupInstanceDataDefinition getGroupDataDefinition() {
- return groupDataDefinition;
- }
-
- public void setComponentInstDataDefinition(GroupInstanceDataDefinition groupDataDefinition) {
- this.groupDataDefinition = groupDataDefinition;
- }
-
- @Override
- public String toString() {
- return "GroupInstanceData [groupInstDataDefinition=" + groupDataDefinition + "]";
- }
-
+ GroupInstanceDataDefinition groupDataDefinition;
+
+ public GroupInstanceData() {
+ super(NodeTypeEnum.GroupInstance);
+ this.groupDataDefinition = new GroupInstanceDataDefinition();
+ }
+
+ public GroupInstanceData(GroupInstanceDataDefinition groupDataDefinition) {
+ super(NodeTypeEnum.GroupInstance);
+ this.groupDataDefinition = groupDataDefinition;
+ }
+
+ public GroupInstanceData(Map<String, Object> properties) {
+ this();
+ groupDataDefinition.setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
+ groupDataDefinition.setGroupUid((String) properties.get(GraphPropertiesDictionary.TYPE.getProperty()));
+ groupDataDefinition.setCreationTime((Long) properties.get(GraphPropertiesDictionary.CREATION_DATE.getProperty()));
+ groupDataDefinition.setModificationTime((Long) properties.get(GraphPropertiesDictionary.LAST_UPDATE_DATE.getProperty()));
+ groupDataDefinition.setPosX((String) properties.get(GraphPropertiesDictionary.POSITION_X.getProperty()));
+ groupDataDefinition.setPosY((String) properties.get(GraphPropertiesDictionary.POSITION_Y.getProperty()));
+ groupDataDefinition.setName((String) properties.get(GraphPropertiesDictionary.NAME.getProperty()));
+ groupDataDefinition.setPropertyValueCounter((Integer) properties.get(GraphPropertiesDictionary.PROPERTY_COUNTER.getProperty()));
+ groupDataDefinition.setNormalizedName((String) properties.get(GraphPropertiesDictionary.NORMALIZED_NAME.getProperty()));
+ groupDataDefinition.setCustomizationUUID((String) properties.get(GraphPropertiesDictionary.CUSTOMIZATION_UUID.getProperty()));
+ }
+
+ @Override
+ public Map<String, Object> toGraphMap() {
+ Map<String, Object> map = new HashMap<>();
+ addIfExists(map, GraphPropertiesDictionary.TYPE, groupDataDefinition.getGroupUid());
+ addIfExists(map, GraphPropertiesDictionary.CREATION_DATE, groupDataDefinition.getCreationTime());
+ addIfExists(map, GraphPropertiesDictionary.LAST_UPDATE_DATE, groupDataDefinition.getModificationTime());
+ addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, groupDataDefinition.getUniqueId());
+ addIfExists(map, GraphPropertiesDictionary.POSITION_X, groupDataDefinition.getPosX());
+ addIfExists(map, GraphPropertiesDictionary.POSITION_Y, groupDataDefinition.getPosY());
+ addIfExists(map, GraphPropertiesDictionary.NAME, groupDataDefinition.getName());
+ addIfExists(map, GraphPropertiesDictionary.PROPERTY_COUNTER, groupDataDefinition.getPropertyValueCounter());
+ addIfExists(map, GraphPropertiesDictionary.NORMALIZED_NAME, groupDataDefinition.getNormalizedName());
+ addIfExists(map, GraphPropertiesDictionary.CUSTOMIZATION_UUID, groupDataDefinition.getCustomizationUUID());
+ return map;
+ }
+
+ @Override
+ public String getUniqueId() {
+ return groupDataDefinition.getUniqueId();
+ }
+
+ public String getName() {
+ return groupDataDefinition.getName();
+ }
+
+ @Override
+ public String getUniqueIdKey() {
+ return GraphPropertiesDictionary.UNIQUE_ID.getProperty();
+ }
+
+ public GroupInstanceDataDefinition getGroupDataDefinition() {
+ return groupDataDefinition;
+ }
+
+ public void setComponentInstDataDefinition(GroupInstanceDataDefinition groupDataDefinition) {
+ this.groupDataDefinition = groupDataDefinition;
+ }
+
+ @Override
+ public String toString() {
+ return "GroupInstanceData [groupInstDataDefinition=" + groupDataDefinition + "]";
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/GroupTypeData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/GroupTypeData.java
index 860358ce22..9fde326a43 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/GroupTypeData.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/GroupTypeData.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,120 +17,87 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.resources.data;
import com.google.gson.reflect.TypeToken;
-import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
-import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
-import org.openecomp.sdc.be.datatypes.elements.GroupTypeDataDefinition;
-import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-
import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.List;
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.datatypes.elements.GroupTypeDataDefinition;
+import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
public class GroupTypeData extends GraphNode {
- private static Type listType = new TypeToken<List<String>>() {
- }.getType();
- private static Type mapType = new TypeToken<HashMap<String, String>>() {
- }.getType();
-
- private GroupTypeDataDefinition groupTypeDataDefinition;
-
- private GroupTypeData() {
- super(NodeTypeEnum.GroupType);
- groupTypeDataDefinition = new GroupTypeDataDefinition();
- }
-
- public GroupTypeData(GroupTypeDataDefinition groupTypeDataDefinition) {
- super(NodeTypeEnum.GroupType);
- this.groupTypeDataDefinition = groupTypeDataDefinition;
- }
-
- public GroupTypeData(Map<String, Object> properties) {
-
- this();
- groupTypeDataDefinition.setName((String) properties.get(GraphPropertiesDictionary.NAME.getProperty()));
- groupTypeDataDefinition.setIcon((String) properties.get(GraphPropertiesDictionary.ICON.getProperty()));
- groupTypeDataDefinition.setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
-
- groupTypeDataDefinition.setType((String) properties.get(GraphPropertiesDictionary.TYPE.getProperty()));
-
- groupTypeDataDefinition.setVersion((String) properties.get(GraphPropertiesDictionary.VERSION.getProperty()));
-
- if (properties.get(GraphPropertiesDictionary.IS_HIGHEST_VERSION.getProperty()) != null) {
- groupTypeDataDefinition.setHighestVersion(
- (boolean) properties.get(GraphPropertiesDictionary.IS_HIGHEST_VERSION.getProperty()));
- }
-
- groupTypeDataDefinition
- .setDescription((String) properties.get(GraphPropertiesDictionary.DESCRIPTION.getProperty()));
-
- List<String> members = getGson()
- .fromJson((String) properties.get(GraphPropertiesDictionary.MEMBERS.getProperty()), listType);
- groupTypeDataDefinition.setMembers(members);
-
- HashMap<String, String> metatdata = getGson()
- .fromJson((String) properties.get(GraphPropertiesDictionary.METADATA.getProperty()), mapType);
- groupTypeDataDefinition.setMetadata(metatdata);
-
- groupTypeDataDefinition
- .setCreationTime((Long) properties.get(GraphPropertiesDictionary.CREATION_DATE.getProperty()));
-
- groupTypeDataDefinition
- .setModificationTime((Long) properties.get(GraphPropertiesDictionary.LAST_UPDATE_DATE.getProperty()));
-
- }
-
- @Override
- public Map<String, Object> toGraphMap() {
-
- Map<String, Object> map = new HashMap<>();
-
- addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, groupTypeDataDefinition.getUniqueId());
-
- addIfExists(map, GraphPropertiesDictionary.TYPE, groupTypeDataDefinition.getType());
-
- addIfExists(map, GraphPropertiesDictionary.NAME, groupTypeDataDefinition.getName());
-
- addIfExists(map, GraphPropertiesDictionary.ICON, groupTypeDataDefinition.getIcon());
-
- addIfExists(map, GraphPropertiesDictionary.VERSION, groupTypeDataDefinition.getVersion());
-
- addIfExists(map, GraphPropertiesDictionary.IS_HIGHEST_VERSION, groupTypeDataDefinition.isHighestVersion());
-
- addIfExists(map, GraphPropertiesDictionary.DESCRIPTION, groupTypeDataDefinition.getDescription());
-
- addIfExists(map, GraphPropertiesDictionary.METADATA, groupTypeDataDefinition.getMetadata());
-
- addIfExists(map, GraphPropertiesDictionary.MEMBERS, groupTypeDataDefinition.getMembers());
-
- addIfExists(map, GraphPropertiesDictionary.CREATION_DATE, groupTypeDataDefinition.getCreationTime());
-
- addIfExists(map, GraphPropertiesDictionary.LAST_UPDATE_DATE, groupTypeDataDefinition.getModificationTime());
-
- return map;
- }
-
- public GroupTypeDataDefinition getGroupTypeDataDefinition() {
- return groupTypeDataDefinition;
- }
-
- public void setGroupTypeDataDefinition(GroupTypeDataDefinition groupTypeDataDefinition) {
- this.groupTypeDataDefinition = groupTypeDataDefinition;
- }
-
- @Override
- public String toString() {
- return "GroupTypeData [groupTypeDataDefinition=" + groupTypeDataDefinition + "]";
- }
-
- @Override
- public String getUniqueId() {
- return this.groupTypeDataDefinition.getUniqueId();
- }
-
+ private static Type listType = new TypeToken<List<String>>() {
+ }.getType();
+ private static Type mapType = new TypeToken<HashMap<String, String>>() {
+ }.getType();
+ private GroupTypeDataDefinition groupTypeDataDefinition;
+
+ private GroupTypeData() {
+ super(NodeTypeEnum.GroupType);
+ groupTypeDataDefinition = new GroupTypeDataDefinition();
+ }
+
+ public GroupTypeData(GroupTypeDataDefinition groupTypeDataDefinition) {
+ super(NodeTypeEnum.GroupType);
+ this.groupTypeDataDefinition = groupTypeDataDefinition;
+ }
+
+ public GroupTypeData(Map<String, Object> properties) {
+ this();
+ groupTypeDataDefinition.setName((String) properties.get(GraphPropertiesDictionary.NAME.getProperty()));
+ groupTypeDataDefinition.setIcon((String) properties.get(GraphPropertiesDictionary.ICON.getProperty()));
+ groupTypeDataDefinition.setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
+ groupTypeDataDefinition.setType((String) properties.get(GraphPropertiesDictionary.TYPE.getProperty()));
+ groupTypeDataDefinition.setVersion((String) properties.get(GraphPropertiesDictionary.VERSION.getProperty()));
+ if (properties.get(GraphPropertiesDictionary.IS_HIGHEST_VERSION.getProperty()) != null) {
+ groupTypeDataDefinition.setHighestVersion((boolean) properties.get(GraphPropertiesDictionary.IS_HIGHEST_VERSION.getProperty()));
+ }
+ groupTypeDataDefinition.setDescription((String) properties.get(GraphPropertiesDictionary.DESCRIPTION.getProperty()));
+ List<String> members = getGson().fromJson((String) properties.get(GraphPropertiesDictionary.MEMBERS.getProperty()), listType);
+ groupTypeDataDefinition.setMembers(members);
+ HashMap<String, String> metatdata = getGson().fromJson((String) properties.get(GraphPropertiesDictionary.METADATA.getProperty()), mapType);
+ groupTypeDataDefinition.setMetadata(metatdata);
+ groupTypeDataDefinition.setCreationTime((Long) properties.get(GraphPropertiesDictionary.CREATION_DATE.getProperty()));
+ groupTypeDataDefinition.setModificationTime((Long) properties.get(GraphPropertiesDictionary.LAST_UPDATE_DATE.getProperty()));
+ }
+
+ @Override
+ public Map<String, Object> toGraphMap() {
+ Map<String, Object> map = new HashMap<>();
+ addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, groupTypeDataDefinition.getUniqueId());
+ addIfExists(map, GraphPropertiesDictionary.TYPE, groupTypeDataDefinition.getType());
+ addIfExists(map, GraphPropertiesDictionary.NAME, groupTypeDataDefinition.getName());
+ addIfExists(map, GraphPropertiesDictionary.ICON, groupTypeDataDefinition.getIcon());
+ addIfExists(map, GraphPropertiesDictionary.VERSION, groupTypeDataDefinition.getVersion());
+ addIfExists(map, GraphPropertiesDictionary.IS_HIGHEST_VERSION, groupTypeDataDefinition.isHighestVersion());
+ addIfExists(map, GraphPropertiesDictionary.DESCRIPTION, groupTypeDataDefinition.getDescription());
+ addIfExists(map, GraphPropertiesDictionary.METADATA, groupTypeDataDefinition.getMetadata());
+ addIfExists(map, GraphPropertiesDictionary.MEMBERS, groupTypeDataDefinition.getMembers());
+ addIfExists(map, GraphPropertiesDictionary.CREATION_DATE, groupTypeDataDefinition.getCreationTime());
+ addIfExists(map, GraphPropertiesDictionary.LAST_UPDATE_DATE, groupTypeDataDefinition.getModificationTime());
+ return map;
+ }
+
+ public GroupTypeDataDefinition getGroupTypeDataDefinition() {
+ return groupTypeDataDefinition;
+ }
+
+ public void setGroupTypeDataDefinition(GroupTypeDataDefinition groupTypeDataDefinition) {
+ this.groupTypeDataDefinition = groupTypeDataDefinition;
+ }
+
+ @Override
+ public String toString() {
+ return "GroupTypeData [groupTypeDataDefinition=" + groupTypeDataDefinition + "]";
+ }
+
+ @Override
+ public String getUniqueId() {
+ return this.groupTypeDataDefinition.getUniqueId();
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/HeatParameterData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/HeatParameterData.java
index fc27393c80..cec56a8363 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/HeatParameterData.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/HeatParameterData.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,156 +17,141 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.resources.data;
+import java.math.BigDecimal;
+import java.util.HashMap;
+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.HeatParameterDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import java.math.BigDecimal;
-import java.util.HashMap;
-import java.util.Map;
-
public class HeatParameterData extends GraphNode {
- private HeatParameterDataDefinition heatDataDefinition;
-
- public HeatParameterData() {
- super(NodeTypeEnum.HeatParameter);
- heatDataDefinition = new HeatParameterDataDefinition();
- }
-
- public HeatParameterData(HeatParameterDataDefinition heatDataDef) {
- super(NodeTypeEnum.HeatParameter);
- this.heatDataDefinition = heatDataDef;
- }
-
- public HeatParameterData(Map<String, Object> properties) {
- this();
-
- heatDataDefinition.setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
- heatDataDefinition.setName((String) properties.get(GraphPropertiesDictionary.NAME.getProperty()));
- String type = (String) properties.get(GraphPropertiesDictionary.TYPE.getProperty());
- heatDataDefinition.setType(type);
-
- String description = (String) properties.get(GraphPropertiesDictionary.DESCRIPTION.getProperty());
- if (Constants.GRAPH_EMPTY_VALUE.equals(description)) {
- heatDataDefinition.setDescription(null);
- } else {
- heatDataDefinition.setDescription(description);
- }
-
- String defaultValue = (String) properties.get(GraphPropertiesDictionary.DEFAULT_VALUE.getProperty());
- if (Constants.GRAPH_EMPTY_VALUE.equals(defaultValue)) {
- heatDataDefinition.setDefaultValue(null);
- } else {
- heatDataDefinition.setDefaultValue(getValue(type, defaultValue));
- }
-
- String value = (String) properties.get(GraphPropertiesDictionary.VALUE.getProperty());
- if (Constants.GRAPH_EMPTY_VALUE.equals(value)) {
- heatDataDefinition.setCurrentValue(null);
- } else {
- heatDataDefinition.setCurrentValue(getValue(type, value));
- }
-
- }
-
- private String getValue(String type, String value) {
- if (Constants.GRAPH_EMPTY_VALUE.equals(value)) {
- return value;
- }
- if ("number".equals(type)) {
- return new BigDecimal(value).toPlainString();
- }
- return value;
- }
-
- public HeatParameterDataDefinition getHeatDataDefinition() {
- return heatDataDefinition;
- }
-
- public void setHeatDataDefinition(HeatParameterDataDefinition heatDataDefinition) {
- this.heatDataDefinition = heatDataDefinition;
- }
-
- public String getName() {
- return heatDataDefinition.getName();
- }
-
- public void setName(String name) {
- heatDataDefinition.setName(name);
- }
-
- public String getType() {
- return heatDataDefinition.getType();
- }
-
- public void setType(String type) {
- heatDataDefinition.setType(type);
- }
-
- public String getDescription() {
- return heatDataDefinition.getDescription();
- }
-
- public void setDescription(String description) {
- heatDataDefinition.setDescription(description);
- }
-
- public String getCurrentValue() {
- return heatDataDefinition.getCurrentValue();
- }
-
- public void setCurrentValue(String currentValue) {
- heatDataDefinition.setCurrentValue(currentValue);
- }
-
- public String getDefaultValue() {
- return heatDataDefinition.getDefaultValue();
- }
-
- public void setDefaultValue(String defaultValue) {
- heatDataDefinition.setDefaultValue(defaultValue);
- }
-
- @Override
- public String getUniqueId() {
- return heatDataDefinition.getUniqueId();
- }
-
- @Override
- public Map<String, Object> toGraphMap() {
- Map<String, Object> map = new HashMap<>();
-
- addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, getUniqueId());
-
- addIfExists(map, GraphPropertiesDictionary.NAME, getName());
-
- addIfExists(map, GraphPropertiesDictionary.TYPE, getType());
-
- String description = getDescription();
- if (description == null) {
- description = Constants.GRAPH_EMPTY_VALUE;
- }
- addIfExists(map, GraphPropertiesDictionary.DESCRIPTION, description);
-
- String defaultVal = getDefaultValue();
- if (defaultVal == null) {
- defaultVal = Constants.GRAPH_EMPTY_VALUE;
- }
- addIfExists(map, GraphPropertiesDictionary.DEFAULT_VALUE, getValue(getType(), defaultVal));
-
- String currentVal = getCurrentValue();
- if (currentVal == null) {
- currentVal = Constants.GRAPH_EMPTY_VALUE;
- }
-
- addIfExists(map, GraphPropertiesDictionary.VALUE, getValue(getType(), currentVal));
- return map;
- }
-
+ private HeatParameterDataDefinition heatDataDefinition;
+
+ public HeatParameterData() {
+ super(NodeTypeEnum.HeatParameter);
+ heatDataDefinition = new HeatParameterDataDefinition();
+ }
+
+ public HeatParameterData(HeatParameterDataDefinition heatDataDef) {
+ super(NodeTypeEnum.HeatParameter);
+ this.heatDataDefinition = heatDataDef;
+ }
+
+ public HeatParameterData(Map<String, Object> properties) {
+ this();
+ heatDataDefinition.setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
+ heatDataDefinition.setName((String) properties.get(GraphPropertiesDictionary.NAME.getProperty()));
+ String type = (String) properties.get(GraphPropertiesDictionary.TYPE.getProperty());
+ heatDataDefinition.setType(type);
+ String description = (String) properties.get(GraphPropertiesDictionary.DESCRIPTION.getProperty());
+ if (Constants.GRAPH_EMPTY_VALUE.equals(description)) {
+ heatDataDefinition.setDescription(null);
+ } else {
+ heatDataDefinition.setDescription(description);
+ }
+ String defaultValue = (String) properties.get(GraphPropertiesDictionary.DEFAULT_VALUE.getProperty());
+ if (Constants.GRAPH_EMPTY_VALUE.equals(defaultValue)) {
+ heatDataDefinition.setDefaultValue(null);
+ } else {
+ heatDataDefinition.setDefaultValue(getValue(type, defaultValue));
+ }
+ String value = (String) properties.get(GraphPropertiesDictionary.VALUE.getProperty());
+ if (Constants.GRAPH_EMPTY_VALUE.equals(value)) {
+ heatDataDefinition.setCurrentValue(null);
+ } else {
+ heatDataDefinition.setCurrentValue(getValue(type, value));
+ }
+ }
+
+ private String getValue(String type, String value) {
+ if (Constants.GRAPH_EMPTY_VALUE.equals(value)) {
+ return value;
+ }
+ if ("number".equals(type)) {
+ return new BigDecimal(value).toPlainString();
+ }
+ return value;
+ }
+
+ public HeatParameterDataDefinition getHeatDataDefinition() {
+ return heatDataDefinition;
+ }
+
+ public void setHeatDataDefinition(HeatParameterDataDefinition heatDataDefinition) {
+ this.heatDataDefinition = heatDataDefinition;
+ }
+
+ public String getName() {
+ return heatDataDefinition.getName();
+ }
+
+ public void setName(String name) {
+ heatDataDefinition.setName(name);
+ }
+
+ public String getType() {
+ return heatDataDefinition.getType();
+ }
+
+ public void setType(String type) {
+ heatDataDefinition.setType(type);
+ }
+
+ public String getDescription() {
+ return heatDataDefinition.getDescription();
+ }
+
+ public void setDescription(String description) {
+ heatDataDefinition.setDescription(description);
+ }
+
+ public String getCurrentValue() {
+ return heatDataDefinition.getCurrentValue();
+ }
+
+ public void setCurrentValue(String currentValue) {
+ heatDataDefinition.setCurrentValue(currentValue);
+ }
+
+ public String getDefaultValue() {
+ return heatDataDefinition.getDefaultValue();
+ }
+
+ public void setDefaultValue(String defaultValue) {
+ heatDataDefinition.setDefaultValue(defaultValue);
+ }
+
+ @Override
+ public String getUniqueId() {
+ return heatDataDefinition.getUniqueId();
+ }
+
+ @Override
+ public Map<String, Object> toGraphMap() {
+ Map<String, Object> map = new HashMap<>();
+ addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, getUniqueId());
+ addIfExists(map, GraphPropertiesDictionary.NAME, getName());
+ addIfExists(map, GraphPropertiesDictionary.TYPE, getType());
+ String description = getDescription();
+ if (description == null) {
+ description = Constants.GRAPH_EMPTY_VALUE;
+ }
+ addIfExists(map, GraphPropertiesDictionary.DESCRIPTION, description);
+ String defaultVal = getDefaultValue();
+ if (defaultVal == null) {
+ defaultVal = Constants.GRAPH_EMPTY_VALUE;
+ }
+ addIfExists(map, GraphPropertiesDictionary.DEFAULT_VALUE, getValue(getType(), defaultVal));
+ String currentVal = getCurrentValue();
+ if (currentVal == null) {
+ currentVal = Constants.GRAPH_EMPTY_VALUE;
+ }
+ addIfExists(map, GraphPropertiesDictionary.VALUE, getValue(getType(), currentVal));
+ return map;
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/HeatParameterValueData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/HeatParameterValueData.java
index 71f8f46050..db24df0be6 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/HeatParameterValueData.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/HeatParameterValueData.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,75 +17,65 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.resources.data;
+import java.util.HashMap;
+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.enums.NodeTypeEnum;
-import java.util.HashMap;
-import java.util.Map;
-
public class HeatParameterValueData extends GraphNode {
- public HeatParameterValueData() {
- super(NodeTypeEnum.HeatParameterValue);
- }
-
- public HeatParameterValueData(Map<String, Object> properties) {
- this();
-
- this.setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
- String value = (String) properties.get(GraphPropertiesDictionary.VALUE.getProperty());
- if (Constants.GRAPH_EMPTY_VALUE.equals(value)) {
- this.setValue(null);
- } else {
- this.setValue(value);
- }
-
- }
-
- private String uniqueId;
-
- private String value;
-
- @Override
- public String getUniqueId() {
- return uniqueId;
- }
-
- public String getValue() {
- return value;
- }
-
- public void setValue(String value) {
- this.value = value;
- }
-
- public void setUniqueId(String uniqueId) {
- this.uniqueId = uniqueId;
- }
-
- @Override
- public Map<String, Object> toGraphMap() {
- Map<String, Object> map = new HashMap<>();
-
- addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, uniqueId);
-
- String updatedValue = value;
- if (updatedValue == null) {
- updatedValue = Constants.GRAPH_EMPTY_VALUE;
- }
- addIfExists(map, GraphPropertiesDictionary.VALUE, updatedValue);
-
- return map;
- }
-
- @Override
- public String toString() {
- return "HeatParameterValueData [uniqueId=" + uniqueId + ", value=" + value + "]";
- }
-
+ private String uniqueId;
+ private String value;
+
+ public HeatParameterValueData() {
+ super(NodeTypeEnum.HeatParameterValue);
+ }
+ public HeatParameterValueData(Map<String, Object> properties) {
+ this();
+ this.setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
+ String value = (String) properties.get(GraphPropertiesDictionary.VALUE.getProperty());
+ if (Constants.GRAPH_EMPTY_VALUE.equals(value)) {
+ this.setValue(null);
+ } else {
+ this.setValue(value);
+ }
+ }
+
+ @Override
+ public String getUniqueId() {
+ return uniqueId;
+ }
+
+ public void setUniqueId(String uniqueId) {
+ this.uniqueId = uniqueId;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ @Override
+ public Map<String, Object> toGraphMap() {
+ Map<String, Object> map = new HashMap<>();
+ addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, uniqueId);
+ String updatedValue = value;
+ if (updatedValue == null) {
+ updatedValue = Constants.GRAPH_EMPTY_VALUE;
+ }
+ addIfExists(map, GraphPropertiesDictionary.VALUE, updatedValue);
+ return map;
+ }
+
+ @Override
+ public String toString() {
+ return "HeatParameterValueData [uniqueId=" + uniqueId + ", value=" + value + "]";
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/InputValueData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/InputValueData.java
index 3888c78d59..523aa0140d 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/InputValueData.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/InputValueData.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,130 +17,109 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.resources.data;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
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.enums.NodeTypeEnum;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Objects;
-
public class InputValueData extends GraphNode {
- private String uniqueId;
-
- private String value;
-
- private String type;
-
- private Boolean hidden;
-
- private Long creationTime;
-
- private Long modificationTime;
-
- public InputValueData() {
- super(NodeTypeEnum.InputValue);
- }
-
- public InputValueData(Map<String, Object> properties) {
- this();
-
- this.setType((String) properties.get(GraphPropertiesDictionary.TYPE.getProperty()));
-
- String updatedValue = (String) properties.get(GraphPropertiesDictionary.VALUE.getProperty());
- if (Constants.GRAPH_EMPTY_VALUE.equals(updatedValue)) {
- this.setValue(null);
- } else {
- this.setValue(updatedValue);
- }
-
- this.setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
-
- this.setHidden((Boolean) properties.get(GraphPropertiesDictionary.HIDDEN.getProperty()));
-
- this.setCreationTime((Long) properties.get(GraphPropertiesDictionary.CREATION_DATE.getProperty()));
-
- this.setModificationTime((Long) properties.get(GraphPropertiesDictionary.LAST_UPDATE_DATE.getProperty()));
-
- }
-
- @Override
- public String getUniqueId() {
- return uniqueId;
- }
-
- public void setUniqueId(String uniqueId) {
- this.uniqueId = uniqueId;
- }
-
- public Long getCreationTime() {
- return creationTime;
- }
-
- public void setCreationTime(Long creationTime) {
- this.creationTime = creationTime;
- }
-
- public Long getModificationTime() {
- return modificationTime;
- }
-
- public void setModificationTime(Long modificationTime) {
- this.modificationTime = modificationTime;
- }
-
- @Override
- public Map<String, Object> toGraphMap() {
-
- Map<String, Object> map = new HashMap<>();
-
- addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, uniqueId);
-
- addIfExists(map, GraphPropertiesDictionary.TYPE, type);
-
- addIfExists(map, GraphPropertiesDictionary.HIDDEN, hidden);
-
- addIfExists(map, GraphPropertiesDictionary.CREATION_DATE, creationTime);
-
- addIfExists(map, GraphPropertiesDictionary.LAST_UPDATE_DATE, modificationTime);
-
- String updatedValue = Objects.isNull(value) ? Constants.GRAPH_EMPTY_VALUE : value;
- addIfExists(map, GraphPropertiesDictionary.VALUE, updatedValue);
- return map;
- }
-
- @Override
- public String toString() {
- return "InputValueData [uniqueId=" + uniqueId + ", hidden=" + hidden + ", type=" + type + ", creationTime="
- + creationTime + ", value=" + value + ", modificationTime=" + modificationTime + "]";
- }
-
- public Boolean isHidden() {
- return hidden;
- }
-
- public void setHidden(Boolean hidden) {
- this.hidden = hidden;
- }
-
- public String getType() {
- return type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
- public String getValue() {
- return value;
- }
-
- public void setValue(String value) {
- this.value = value;
- }
+ private String uniqueId;
+ private String value;
+ private String type;
+ private Boolean hidden;
+ private Long creationTime;
+ private Long modificationTime;
+
+ public InputValueData() {
+ super(NodeTypeEnum.InputValue);
+ }
+
+ public InputValueData(Map<String, Object> properties) {
+ this();
+ this.setType((String) properties.get(GraphPropertiesDictionary.TYPE.getProperty()));
+ String updatedValue = (String) properties.get(GraphPropertiesDictionary.VALUE.getProperty());
+ if (Constants.GRAPH_EMPTY_VALUE.equals(updatedValue)) {
+ this.setValue(null);
+ } else {
+ this.setValue(updatedValue);
+ }
+ this.setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
+ this.setHidden((Boolean) properties.get(GraphPropertiesDictionary.HIDDEN.getProperty()));
+ this.setCreationTime((Long) properties.get(GraphPropertiesDictionary.CREATION_DATE.getProperty()));
+ this.setModificationTime((Long) properties.get(GraphPropertiesDictionary.LAST_UPDATE_DATE.getProperty()));
+ }
+
+ @Override
+ public String getUniqueId() {
+ return uniqueId;
+ }
+
+ public void setUniqueId(String uniqueId) {
+ this.uniqueId = uniqueId;
+ }
+
+ public Long getCreationTime() {
+ return creationTime;
+ }
+
+ public void setCreationTime(Long creationTime) {
+ this.creationTime = creationTime;
+ }
+
+ public Long getModificationTime() {
+ return modificationTime;
+ }
+
+ public void setModificationTime(Long modificationTime) {
+ this.modificationTime = modificationTime;
+ }
+
+ @Override
+ public Map<String, Object> toGraphMap() {
+ Map<String, Object> map = new HashMap<>();
+ addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, uniqueId);
+ addIfExists(map, GraphPropertiesDictionary.TYPE, type);
+ addIfExists(map, GraphPropertiesDictionary.HIDDEN, hidden);
+ addIfExists(map, GraphPropertiesDictionary.CREATION_DATE, creationTime);
+ addIfExists(map, GraphPropertiesDictionary.LAST_UPDATE_DATE, modificationTime);
+ String updatedValue = Objects.isNull(value) ? Constants.GRAPH_EMPTY_VALUE : value;
+ addIfExists(map, GraphPropertiesDictionary.VALUE, updatedValue);
+ return map;
+ }
+
+ @Override
+ public String toString() {
+ return "InputValueData [uniqueId=" + uniqueId + ", hidden=" + hidden + ", type=" + type + ", creationTime=" + creationTime + ", value="
+ + value + ", modificationTime=" + modificationTime + "]";
+ }
+
+ public Boolean isHidden() {
+ return hidden;
+ }
+
+ public void setHidden(Boolean hidden) {
+ this.hidden = hidden;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/InputsData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/InputsData.java
index 77e0c02fc4..19c6648037 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/InputsData.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/InputsData.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,10 +17,13 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.resources.data;
import com.google.gson.reflect.TypeToken;
+import java.lang.reflect.Type;
+import java.util.HashMap;
+import java.util.List;
+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;
@@ -28,121 +31,96 @@ 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 java.lang.reflect.Type;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
public class InputsData extends GraphNode {
- PropertyDataDefinition propertyDataDefinition;
-
- private List<String> constraints;
-
- public InputsData() {
- super(NodeTypeEnum.Input);
- propertyDataDefinition = new PropertyDataDefinition();
- }
-
- public InputsData(PropertyDataDefinition propertyDataDefinition, List<String> constraints) {
- super(NodeTypeEnum.Input);
- this.propertyDataDefinition = propertyDataDefinition;
- this.constraints = constraints;
- }
-
- public InputsData(Map<String, Object> properties) {
-
- this();
-
- propertyDataDefinition.setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
-
- propertyDataDefinition.setType((String) properties.get(GraphPropertiesDictionary.TYPE.getProperty()));
-
- propertyDataDefinition.setRequired((Boolean) properties.get(GraphPropertiesDictionary.REQUIRED.getProperty()));
-
- String defaultValue = (String) properties.get(GraphPropertiesDictionary.DEFAULT_VALUE.getProperty());
- if (Constants.GRAPH_EMPTY_VALUE.equals(defaultValue)) {
- propertyDataDefinition.setDefaultValue(null);
- } else {
- propertyDataDefinition.setDefaultValue(defaultValue);
- }
-
- propertyDataDefinition
- .setDescription((String) properties.get(GraphPropertiesDictionary.DESCRIPTION.getProperty()));
-
- Type listType = new TypeToken<List<String>>() {
- }.getType();
- List<String> constraintsfromJson = getGson()
- .fromJson((String) properties.get(GraphPropertiesDictionary.CONSTRAINTS.getProperty()), listType);
- setConstraints(constraintsfromJson);
- // setConstraints((List<String>)
- // properties.get(GraphPropertiesDictionary.CONSTRAINTS.getProperty()));
-
- Type schemaType = new TypeToken<SchemaDefinition>() {
- }.getType();
- SchemaDefinition schema = getGson()
- .fromJson((String) properties.get(GraphPropertiesDictionary.ENTRY_SCHEMA.getProperty()), schemaType);
- propertyDataDefinition.setSchema(schema);
-
- }
-
- @Override
- public Map<String, Object> toGraphMap() {
-
- Map<String, Object> map = new HashMap<>();
-
- addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, propertyDataDefinition.getUniqueId());
-
- addIfExists(map, GraphPropertiesDictionary.TYPE, propertyDataDefinition.getType());
-
- addIfExists(map, GraphPropertiesDictionary.DESCRIPTION, propertyDataDefinition.getDescription());
-
- String defaultValue = propertyDataDefinition.getDefaultValue();
- if (defaultValue == null) {
- defaultValue = Constants.GRAPH_EMPTY_VALUE;
- }
- addIfExists(map, GraphPropertiesDictionary.DEFAULT_VALUE, defaultValue);
-
- addIfExists(map, GraphPropertiesDictionary.REQUIRED, propertyDataDefinition.isRequired());
-
- addIfExists(map, GraphPropertiesDictionary.CONSTRAINTS, getConstraints());
-
- SchemaDefinition entrySchema = propertyDataDefinition.getSchema();
- if (entrySchema != null) {
- String entrySchemaStr = getGson().toJson(entrySchema);
- addIfExists(map, GraphPropertiesDictionary.ENTRY_SCHEMA, entrySchemaStr);
- }
- // String constraintsAsJson = getGson().toJson(getConstraints());
- // addIfExists(map, GraphPropertiesDictionary.CONSTRAINTS,
- // constraintsAsJson);
-
- return map;
- }
-
- public List<String> getConstraints() {
- return constraints;
- }
-
- public void setConstraints(List<String> constraints) {
- this.constraints = constraints;
- }
-
- @Override
- public String getUniqueId() {
- return propertyDataDefinition.getUniqueId();
- }
-
- public PropertyDataDefinition getPropertyDataDefinition() {
- return propertyDataDefinition;
- }
-
- public void setPropertyDataDefinition(PropertyDataDefinition propertyDataDefinition) {
- this.propertyDataDefinition = propertyDataDefinition;
- }
-
- @Override
- public String toString() {
- return "PropertyData [propertyDataDefinition=" + propertyDataDefinition + ", constraints=" + constraints + "]";
- }
-
+ PropertyDataDefinition propertyDataDefinition;
+ private List<String> constraints;
+
+ public InputsData() {
+ super(NodeTypeEnum.Input);
+ propertyDataDefinition = new PropertyDataDefinition();
+ }
+
+ public InputsData(PropertyDataDefinition propertyDataDefinition, List<String> constraints) {
+ super(NodeTypeEnum.Input);
+ this.propertyDataDefinition = propertyDataDefinition;
+ this.constraints = constraints;
+ }
+
+ public InputsData(Map<String, Object> properties) {
+ this();
+ propertyDataDefinition.setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
+ propertyDataDefinition.setType((String) properties.get(GraphPropertiesDictionary.TYPE.getProperty()));
+ propertyDataDefinition.setRequired((Boolean) properties.get(GraphPropertiesDictionary.REQUIRED.getProperty()));
+ String defaultValue = (String) properties.get(GraphPropertiesDictionary.DEFAULT_VALUE.getProperty());
+ if (Constants.GRAPH_EMPTY_VALUE.equals(defaultValue)) {
+ propertyDataDefinition.setDefaultValue(null);
+ } else {
+ propertyDataDefinition.setDefaultValue(defaultValue);
+ }
+ propertyDataDefinition.setDescription((String) properties.get(GraphPropertiesDictionary.DESCRIPTION.getProperty()));
+ Type listType = new TypeToken<List<String>>() {
+ }.getType();
+ List<String> constraintsfromJson = getGson().fromJson((String) properties.get(GraphPropertiesDictionary.CONSTRAINTS.getProperty()), listType);
+ setConstraints(constraintsfromJson);
+ // setConstraints((List<String>)
+
+ // properties.get(GraphPropertiesDictionary.CONSTRAINTS.getProperty()));
+ Type schemaType = new TypeToken<SchemaDefinition>() {
+ }.getType();
+ SchemaDefinition schema = getGson().fromJson((String) properties.get(GraphPropertiesDictionary.ENTRY_SCHEMA.getProperty()), schemaType);
+ propertyDataDefinition.setSchema(schema);
+ }
+
+ @Override
+ public Map<String, Object> toGraphMap() {
+ Map<String, Object> map = new HashMap<>();
+ addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, propertyDataDefinition.getUniqueId());
+ addIfExists(map, GraphPropertiesDictionary.TYPE, propertyDataDefinition.getType());
+ addIfExists(map, GraphPropertiesDictionary.DESCRIPTION, propertyDataDefinition.getDescription());
+ String defaultValue = propertyDataDefinition.getDefaultValue();
+ if (defaultValue == null) {
+ defaultValue = Constants.GRAPH_EMPTY_VALUE;
+ }
+ addIfExists(map, GraphPropertiesDictionary.DEFAULT_VALUE, defaultValue);
+ addIfExists(map, GraphPropertiesDictionary.REQUIRED, propertyDataDefinition.isRequired());
+ addIfExists(map, GraphPropertiesDictionary.CONSTRAINTS, getConstraints());
+ SchemaDefinition entrySchema = propertyDataDefinition.getSchema();
+ if (entrySchema != null) {
+ String entrySchemaStr = getGson().toJson(entrySchema);
+ addIfExists(map, GraphPropertiesDictionary.ENTRY_SCHEMA, entrySchemaStr);
+ }
+ // String constraintsAsJson = getGson().toJson(getConstraints());
+
+ // addIfExists(map, GraphPropertiesDictionary.CONSTRAINTS,
+
+ // constraintsAsJson);
+ return map;
+ }
+
+ public List<String> getConstraints() {
+ return constraints;
+ }
+
+ public void setConstraints(List<String> constraints) {
+ this.constraints = constraints;
+ }
+
+ @Override
+ public String getUniqueId() {
+ return propertyDataDefinition.getUniqueId();
+ }
+
+ public PropertyDataDefinition getPropertyDataDefinition() {
+ return propertyDataDefinition;
+ }
+
+ public void setPropertyDataDefinition(PropertyDataDefinition propertyDataDefinition) {
+ this.propertyDataDefinition = propertyDataDefinition;
+ }
+
+ @Override
+ public String toString() {
+ return "PropertyData [propertyDataDefinition=" + propertyDataDefinition + ", constraints=" + constraints + "]";
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/InterfaceData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/InterfaceData.java
index c5ba3cba14..4f3c4c0e63 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/InterfaceData.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/InterfaceData.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,75 +17,64 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.resources.data;
+import java.util.HashMap;
+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.datatypes.elements.InterfaceDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import java.util.HashMap;
-import java.util.Map;
-
public class InterfaceData extends GraphNode {
- private InterfaceDataDefinition interfaceDataDefinition;
-
- public InterfaceData() {
- super(NodeTypeEnum.Interface);
- interfaceDataDefinition = new InterfaceDataDefinition();
-
- }
-
- public InterfaceData(InterfaceData p) {
- super(NodeTypeEnum.Interface);
- interfaceDataDefinition = p.getInterfaceDataDefinition();
-
- }
-
- public InterfaceData(InterfaceDataDefinition interfaceDataDefinition) {
- super(NodeTypeEnum.Interface);
- this.interfaceDataDefinition = interfaceDataDefinition;
-
- }
-
- public InterfaceData(Map<String, Object> properties) {
- this();
- interfaceDataDefinition.setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
- interfaceDataDefinition.setType((String) properties.get(GraphPropertiesDictionary.TYPE.getProperty()));
- interfaceDataDefinition
- .setDescription((String) properties.get(GraphPropertiesDictionary.DESCRIPTION.getProperty()));
- interfaceDataDefinition
- .setCreationDate((Long) properties.get(GraphPropertiesDictionary.CREATION_DATE.getProperty()));
- interfaceDataDefinition
- .setLastUpdateDate((Long) properties.get(GraphPropertiesDictionary.LAST_UPDATE_DATE.getProperty()));
- }
-
- public InterfaceDataDefinition getInterfaceDataDefinition() {
- return interfaceDataDefinition;
- }
-
- public void setInterfaceDataDefinition(InterfaceDataDefinition interfaceDataDefinition) {
- this.interfaceDataDefinition = interfaceDataDefinition;
- }
-
- @Override
- public String getUniqueId() {
- return interfaceDataDefinition.getUniqueId();
- }
-
- @Override
- public Map<String, Object> toGraphMap() {
- Map<String, Object> map = new HashMap<>();
-
- addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, interfaceDataDefinition.getUniqueId());
- addIfExists(map, GraphPropertiesDictionary.TYPE, interfaceDataDefinition.getType());
- addIfExists(map, GraphPropertiesDictionary.CREATION_DATE, interfaceDataDefinition.getCreationDate());
- addIfExists(map, GraphPropertiesDictionary.LAST_UPDATE_DATE, interfaceDataDefinition.getLastUpdateDate());
- addIfExists(map, GraphPropertiesDictionary.DESCRIPTION, interfaceDataDefinition.getDescription());
-
- return map;
- }
-
+ private InterfaceDataDefinition interfaceDataDefinition;
+
+ public InterfaceData() {
+ super(NodeTypeEnum.Interface);
+ interfaceDataDefinition = new InterfaceDataDefinition();
+ }
+
+ public InterfaceData(InterfaceData p) {
+ super(NodeTypeEnum.Interface);
+ interfaceDataDefinition = p.getInterfaceDataDefinition();
+ }
+
+ public InterfaceData(InterfaceDataDefinition interfaceDataDefinition) {
+ super(NodeTypeEnum.Interface);
+ this.interfaceDataDefinition = interfaceDataDefinition;
+ }
+
+ public InterfaceData(Map<String, Object> properties) {
+ this();
+ interfaceDataDefinition.setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
+ interfaceDataDefinition.setType((String) properties.get(GraphPropertiesDictionary.TYPE.getProperty()));
+ interfaceDataDefinition.setDescription((String) properties.get(GraphPropertiesDictionary.DESCRIPTION.getProperty()));
+ interfaceDataDefinition.setCreationDate((Long) properties.get(GraphPropertiesDictionary.CREATION_DATE.getProperty()));
+ interfaceDataDefinition.setLastUpdateDate((Long) properties.get(GraphPropertiesDictionary.LAST_UPDATE_DATE.getProperty()));
+ }
+
+ public InterfaceDataDefinition getInterfaceDataDefinition() {
+ return interfaceDataDefinition;
+ }
+
+ public void setInterfaceDataDefinition(InterfaceDataDefinition interfaceDataDefinition) {
+ this.interfaceDataDefinition = interfaceDataDefinition;
+ }
+
+ @Override
+ public String getUniqueId() {
+ return interfaceDataDefinition.getUniqueId();
+ }
+
+ @Override
+ public Map<String, Object> toGraphMap() {
+ Map<String, Object> map = new HashMap<>();
+ addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, interfaceDataDefinition.getUniqueId());
+ addIfExists(map, GraphPropertiesDictionary.TYPE, interfaceDataDefinition.getType());
+ addIfExists(map, GraphPropertiesDictionary.CREATION_DATE, interfaceDataDefinition.getCreationDate());
+ addIfExists(map, GraphPropertiesDictionary.LAST_UPDATE_DATE, interfaceDataDefinition.getLastUpdateDate());
+ addIfExists(map, GraphPropertiesDictionary.DESCRIPTION, interfaceDataDefinition.getDescription());
+ return map;
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/MigrationTaskEntry.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/MigrationTaskEntry.java
index a358897bc0..7655a41002 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/MigrationTaskEntry.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/MigrationTaskEntry.java
@@ -17,18 +17,16 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.resources.data;
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;
+import java.util.Date;
import lombok.Getter;
import lombok.Setter;
-import java.util.Date;
-
@Getter
@Setter
@Table(keyspace = "sdcrepository", name = "migrationTasks")
@@ -37,26 +35,19 @@ public class MigrationTaskEntry {
@PartitionKey(0)
@Column(name = "major_version")
private Long majorVersion;
-
@ClusteringColumn
@Column(name = "minor_version")
private Long minorVersion;
-
@Column(name = "timestamp")
private Date timestamp;
-
@Column(name = "task_name")
private String taskName;
-
@Column(name = "execution_time")
private double executionTime;
-
@Column(name = "task_status")
private String taskStatus;
-
@Column(name = "msg")
private String message;
-
@Column(name = "description")
private String description;
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/OperationData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/OperationData.java
index 8246c2f9ff..2fd4b2c694 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/OperationData.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/OperationData.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,72 +17,62 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.resources.data;
+import java.util.HashMap;
+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.datatypes.elements.OperationDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import java.util.HashMap;
-import java.util.Map;
-
public class OperationData extends GraphNode {
- OperationDataDefinition operationDataDefinition;
-
- protected OperationData() {
- super(NodeTypeEnum.InterfaceOperation);
- operationDataDefinition = new OperationDataDefinition();
- }
-
- public OperationData(OperationDataDefinition operationDataDefinition) {
- super(NodeTypeEnum.InterfaceOperation);
- this.operationDataDefinition = operationDataDefinition;
-
- }
-
- public OperationData(OperationData operationData) {
- super(NodeTypeEnum.InterfaceOperation);
- this.operationDataDefinition = operationData.getOperationDataDefinition();
-
- }
-
- public OperationData(Map<String, Object> properties) {
- this();
- operationDataDefinition.setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
- operationDataDefinition
- .setDescription((String) properties.get(GraphPropertiesDictionary.DESCRIPTION.getProperty()));
- operationDataDefinition
- .setCreationDate((Long) properties.get(GraphPropertiesDictionary.CREATION_DATE.getProperty()));
- operationDataDefinition
- .setLastUpdateDate((Long) properties.get(GraphPropertiesDictionary.LAST_UPDATE_DATE.getProperty()));
- }
-
- public OperationDataDefinition getOperationDataDefinition() {
- return operationDataDefinition;
- }
-
- public void setOperationDataDefinition(OperationDataDefinition operationDataDefinition) {
- this.operationDataDefinition = operationDataDefinition;
- }
-
- @Override
- public String getUniqueId() {
- return operationDataDefinition.getUniqueId();
- }
-
- @Override
- public Map<String, Object> toGraphMap() {
- Map<String, Object> map = new HashMap<>();
-
- addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, operationDataDefinition.getUniqueId());
- addIfExists(map, GraphPropertiesDictionary.CREATION_DATE, operationDataDefinition.getCreationDate());
- addIfExists(map, GraphPropertiesDictionary.LAST_UPDATE_DATE, operationDataDefinition.getLastUpdateDate());
- addIfExists(map, GraphPropertiesDictionary.DESCRIPTION, operationDataDefinition.getDescription());
-
- return map;
- }
-
+ OperationDataDefinition operationDataDefinition;
+
+ protected OperationData() {
+ super(NodeTypeEnum.InterfaceOperation);
+ operationDataDefinition = new OperationDataDefinition();
+ }
+
+ public OperationData(OperationDataDefinition operationDataDefinition) {
+ super(NodeTypeEnum.InterfaceOperation);
+ this.operationDataDefinition = operationDataDefinition;
+ }
+
+ public OperationData(OperationData operationData) {
+ super(NodeTypeEnum.InterfaceOperation);
+ this.operationDataDefinition = operationData.getOperationDataDefinition();
+ }
+
+ public OperationData(Map<String, Object> properties) {
+ this();
+ operationDataDefinition.setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
+ operationDataDefinition.setDescription((String) properties.get(GraphPropertiesDictionary.DESCRIPTION.getProperty()));
+ operationDataDefinition.setCreationDate((Long) properties.get(GraphPropertiesDictionary.CREATION_DATE.getProperty()));
+ operationDataDefinition.setLastUpdateDate((Long) properties.get(GraphPropertiesDictionary.LAST_UPDATE_DATE.getProperty()));
+ }
+
+ public OperationDataDefinition getOperationDataDefinition() {
+ return operationDataDefinition;
+ }
+
+ public void setOperationDataDefinition(OperationDataDefinition operationDataDefinition) {
+ this.operationDataDefinition = operationDataDefinition;
+ }
+
+ @Override
+ public String getUniqueId() {
+ return operationDataDefinition.getUniqueId();
+ }
+
+ @Override
+ public Map<String, Object> toGraphMap() {
+ Map<String, Object> map = new HashMap<>();
+ addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, operationDataDefinition.getUniqueId());
+ addIfExists(map, GraphPropertiesDictionary.CREATION_DATE, operationDataDefinition.getCreationDate());
+ addIfExists(map, GraphPropertiesDictionary.LAST_UPDATE_DATE, operationDataDefinition.getLastUpdateDate());
+ addIfExists(map, GraphPropertiesDictionary.DESCRIPTION, operationDataDefinition.getDescription());
+ return map;
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/OperationalEnvironmentEntry.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/OperationalEnvironmentEntry.java
index 8b7032d06b..51c1561c1e 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/OperationalEnvironmentEntry.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/OperationalEnvironmentEntry.java
@@ -17,19 +17,17 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.resources.data;
import com.datastax.driver.mapping.annotations.Column;
import com.datastax.driver.mapping.annotations.PartitionKey;
import com.datastax.driver.mapping.annotations.Table;
-import lombok.Getter;
-import lombok.Setter;
-import org.openecomp.sdc.be.datatypes.enums.EnvironmentStatusEnum;
-
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
+import lombok.Getter;
+import lombok.Setter;
+import org.openecomp.sdc.be.datatypes.enums.EnvironmentStatusEnum;
@Getter
@Setter
@@ -39,32 +37,23 @@ public class OperationalEnvironmentEntry {
@PartitionKey(0)
@Column(name = "environment_id")
private String environmentId;
-
@Column(name = "tenant")
private String tenant;
-
@Column(name = "is_production")
private Boolean isProduction;
-
@Column(name = "ecomp_workload_context")
private String ecompWorkloadContext;
-
@Column(name = "dmaap_ueb_address")
private Set<String> dmaapUebAddress;
-
@Column(name = "ueb_api_key")
private String uebApikey;
-
@Column(name = "ueb_secret_key")
private String uebSecretKey;
-
@Column(name = "status")
private String status;
-
@Column(name = "last_modified")
private Date lastModified;
-
public void setStatus(EnvironmentStatusEnum status) {
this.status = status.getName();
}
@@ -75,18 +64,16 @@ public class OperationalEnvironmentEntry {
}
public void addDmaapUebAddress(String address) {
- if ( this.dmaapUebAddress == null )
+ if (this.dmaapUebAddress == null) {
this.dmaapUebAddress = new HashSet<>();
+ }
dmaapUebAddress.add(address);
}
@Override
public String toString() {
- return "OperationalEnvironmentEntry [environmentId=" + environmentId + ", tenant=" + tenant + ", isProduction="
- + isProduction + ", ecompWorkloadContext=" + ecompWorkloadContext + ", dmaapUebAddress="
- + dmaapUebAddress + ", uebApikey=" + uebApikey + ", status=" + status
- + ", lastModified=" + lastModified + "]";
+ return "OperationalEnvironmentEntry [environmentId=" + environmentId + ", tenant=" + tenant + ", isProduction=" + isProduction
+ + ", ecompWorkloadContext=" + ecompWorkloadContext + ", dmaapUebAddress=" + dmaapUebAddress + ", uebApikey=" + uebApikey + ", status="
+ + status + ", lastModified=" + lastModified + "]";
}
-
-
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/PolicyTypeData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/PolicyTypeData.java
index c09622d17a..1143044d52 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/PolicyTypeData.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/PolicyTypeData.java
@@ -17,27 +17,25 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.resources.data;
import com.google.gson.reflect.TypeToken;
-import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
-import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
-import org.openecomp.sdc.be.datatypes.elements.PolicyTypeDataDefinition;
-import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-
import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.List;
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.datatypes.elements.PolicyTypeDataDefinition;
+import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
public class PolicyTypeData extends GraphNode {
- private PolicyTypeDataDefinition policyTypeDataDefinition;
private static final Type mapType = new TypeToken<HashMap<String, String>>() {
}.getType();
private static final Type listType = new TypeToken<List<String>>() {
}.getType();
+ private PolicyTypeDataDefinition policyTypeDataDefinition;
public PolicyTypeData() {
super(NodeTypeEnum.PolicyType);
@@ -50,67 +48,38 @@ public class PolicyTypeData extends GraphNode {
}
public PolicyTypeData(Map<String, Object> properties) {
-
this();
-
- policyTypeDataDefinition
- .setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
-
- HashMap<String, String> metatdata = getGson()
- .fromJson((String) properties.get(GraphPropertiesDictionary.METADATA.getProperty()), mapType);
+ policyTypeDataDefinition.setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
+ HashMap<String, String> metatdata = getGson().fromJson((String) properties.get(GraphPropertiesDictionary.METADATA.getProperty()), mapType);
policyTypeDataDefinition.setMetadata(metatdata);
-
- List<String> members = getGson()
- .fromJson((String) properties.get(GraphPropertiesDictionary.TARGETS.getProperty()), listType);
+ List<String> members = getGson().fromJson((String) properties.get(GraphPropertiesDictionary.TARGETS.getProperty()), listType);
policyTypeDataDefinition.setTargets(members);
policyTypeDataDefinition.setType((String) properties.get(GraphPropertiesDictionary.TYPE.getProperty()));
policyTypeDataDefinition.setName((String) properties.get(GraphPropertiesDictionary.NAME.getProperty()));
policyTypeDataDefinition.setIcon((String) properties.get(GraphPropertiesDictionary.ICON.getProperty()));
- policyTypeDataDefinition
- .setDescription((String) properties.get(GraphPropertiesDictionary.DESCRIPTION.getProperty()));
-
+ policyTypeDataDefinition.setDescription((String) properties.get(GraphPropertiesDictionary.DESCRIPTION.getProperty()));
if (properties.get(GraphPropertiesDictionary.IS_HIGHEST_VERSION.getProperty()) != null) {
- policyTypeDataDefinition.setHighestVersion(
- (boolean) properties.get(GraphPropertiesDictionary.IS_HIGHEST_VERSION.getProperty()));
- }
-
+ policyTypeDataDefinition.setHighestVersion((boolean) properties.get(GraphPropertiesDictionary.IS_HIGHEST_VERSION.getProperty()));
+ }
policyTypeDataDefinition.setVersion((String) properties.get(GraphPropertiesDictionary.VERSION.getProperty()));
-
- policyTypeDataDefinition
- .setCreationTime((Long) properties.get(GraphPropertiesDictionary.CREATION_DATE.getProperty()));
-
- policyTypeDataDefinition
- .setModificationTime((Long) properties.get(GraphPropertiesDictionary.LAST_UPDATE_DATE.getProperty()));
-
+ policyTypeDataDefinition.setCreationTime((Long) properties.get(GraphPropertiesDictionary.CREATION_DATE.getProperty()));
+ policyTypeDataDefinition.setModificationTime((Long) properties.get(GraphPropertiesDictionary.LAST_UPDATE_DATE.getProperty()));
}
@Override
public Map<String, Object> toGraphMap() {
-
Map<String, Object> map = new HashMap<>();
-
addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, policyTypeDataDefinition.getUniqueId());
-
addIfExists(map, GraphPropertiesDictionary.TYPE, policyTypeDataDefinition.getType());
-
addIfExists(map, GraphPropertiesDictionary.NAME, policyTypeDataDefinition.getName());
-
addIfExists(map, GraphPropertiesDictionary.ICON, policyTypeDataDefinition.getIcon());
-
addIfExists(map, GraphPropertiesDictionary.VERSION, policyTypeDataDefinition.getVersion());
-
addIfExists(map, GraphPropertiesDictionary.IS_HIGHEST_VERSION, policyTypeDataDefinition.isHighestVersion());
-
addIfExists(map, GraphPropertiesDictionary.DESCRIPTION, policyTypeDataDefinition.getDescription());
-
addIfExists(map, GraphPropertiesDictionary.METADATA, policyTypeDataDefinition.getMetadata());
-
addIfExists(map, GraphPropertiesDictionary.TARGETS, policyTypeDataDefinition.getTargets());
-
addIfExists(map, GraphPropertiesDictionary.CREATION_DATE, policyTypeDataDefinition.getCreationTime());
-
addIfExists(map, GraphPropertiesDictionary.LAST_UPDATE_DATE, policyTypeDataDefinition.getModificationTime());
-
return map;
}
@@ -127,6 +96,4 @@ public class PolicyTypeData extends GraphNode {
public PolicyTypeDataDefinition getPolicyTypeDataDefinition() {
return policyTypeDataDefinition;
}
-
-
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ProductMetadataData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ProductMetadataData.java
index fac80b439d..a2534ba77e 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ProductMetadataData.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ProductMetadataData.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,55 +17,47 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.resources.data;
-import com.google.gson.reflect.TypeToken;
+import java.util.Map;
import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionaryExtractor;
import org.openecomp.sdc.be.datatypes.elements.ProductMetadataDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import java.lang.reflect.Type;
-import java.util.List;
-import java.util.Map;
-
public class ProductMetadataData extends ComponentMetadataData {
- public ProductMetadataData() {
- super(NodeTypeEnum.Product, new ProductMetadataDataDefinition());
- }
-
- public ProductMetadataData(ProductMetadataDataDefinition metadataDataDefinition) {
- super(NodeTypeEnum.Product, metadataDataDefinition);
- }
-
- public ProductMetadataData(GraphPropertiesDictionaryExtractor extractor) {
- super(NodeTypeEnum.Product, new ProductMetadataDataDefinition(), extractor);
- ((ProductMetadataDataDefinition) metadataDataDefinition).setFullName(extractor.getFullName());
- ((ProductMetadataDataDefinition) metadataDataDefinition).setContacts(extractor.getContacts());
- ((ProductMetadataDataDefinition) metadataDataDefinition).setIsActive(extractor.isActive());
- }
-
- @Override
- public String getUniqueIdKey() {
- return GraphPropertiesDictionary.UNIQUE_ID.getProperty();
- }
-
- @Override
- public Map<String, Object> toGraphMap() {
- Map<String, Object> graphMap = super.toGraphMap();
- addIfExists(graphMap, GraphPropertiesDictionary.FULL_NAME,
- ((ProductMetadataDataDefinition) metadataDataDefinition).getFullName());
- addIfExists(graphMap, GraphPropertiesDictionary.CONTACTS,
- ((ProductMetadataDataDefinition) metadataDataDefinition).getContacts());
- addIfExists(graphMap, GraphPropertiesDictionary.IS_ACTIVE,
- ((ProductMetadataDataDefinition) metadataDataDefinition).getIsActive());
- return graphMap;
- }
-
- @Override
- public String toString() {
- return "ProductMetadataData [metadataDataDefinition=" + metadataDataDefinition + "]";
- }
+ public ProductMetadataData() {
+ super(NodeTypeEnum.Product, new ProductMetadataDataDefinition());
+ }
+
+ public ProductMetadataData(ProductMetadataDataDefinition metadataDataDefinition) {
+ super(NodeTypeEnum.Product, metadataDataDefinition);
+ }
+
+ public ProductMetadataData(GraphPropertiesDictionaryExtractor extractor) {
+ super(NodeTypeEnum.Product, new ProductMetadataDataDefinition(), extractor);
+ ((ProductMetadataDataDefinition) metadataDataDefinition).setFullName(extractor.getFullName());
+ ((ProductMetadataDataDefinition) metadataDataDefinition).setContacts(extractor.getContacts());
+ ((ProductMetadataDataDefinition) metadataDataDefinition).setIsActive(extractor.isActive());
+ }
+
+ @Override
+ public String getUniqueIdKey() {
+ return GraphPropertiesDictionary.UNIQUE_ID.getProperty();
+ }
+
+ @Override
+ public Map<String, Object> toGraphMap() {
+ Map<String, Object> graphMap = super.toGraphMap();
+ addIfExists(graphMap, GraphPropertiesDictionary.FULL_NAME, ((ProductMetadataDataDefinition) metadataDataDefinition).getFullName());
+ addIfExists(graphMap, GraphPropertiesDictionary.CONTACTS, ((ProductMetadataDataDefinition) metadataDataDefinition).getContacts());
+ addIfExists(graphMap, GraphPropertiesDictionary.IS_ACTIVE, ((ProductMetadataDataDefinition) metadataDataDefinition).getIsActive());
+ return graphMap;
+ }
+
+ @Override
+ public String toString() {
+ return "ProductMetadataData [metadataDataDefinition=" + metadataDataDefinition + "]";
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/PropertyData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/PropertyData.java
index 1047d2bb40..29d4dde848 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/PropertyData.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/PropertyData.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,10 +17,13 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.resources.data;
import com.google.gson.reflect.TypeToken;
+import java.lang.reflect.Type;
+import java.util.HashMap;
+import java.util.List;
+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;
@@ -28,121 +31,96 @@ 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 java.lang.reflect.Type;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
public class PropertyData extends GraphNode {
- PropertyDataDefinition propertyDataDefinition;
-
- private List<String> constraints;
-
- public PropertyData() {
- super(NodeTypeEnum.Property);
- propertyDataDefinition = new PropertyDataDefinition();
- }
-
- public PropertyData(PropertyDataDefinition propertyDataDefinition, List<String> constraints) {
- super(NodeTypeEnum.Property);
- this.propertyDataDefinition = propertyDataDefinition;
- this.constraints = constraints;
- }
-
- public PropertyData(Map<String, Object> properties) {
-
- this();
-
- propertyDataDefinition.setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
-
- propertyDataDefinition.setType((String) properties.get(GraphPropertiesDictionary.TYPE.getProperty()));
-
- propertyDataDefinition.setRequired((Boolean) properties.get(GraphPropertiesDictionary.REQUIRED.getProperty()));
-
- String defaultValue = (String) properties.get(GraphPropertiesDictionary.DEFAULT_VALUE.getProperty());
- if (Constants.GRAPH_EMPTY_VALUE.equals(defaultValue)) {
- propertyDataDefinition.setDefaultValue(null);
- } else {
- propertyDataDefinition.setDefaultValue(defaultValue);
- }
-
- propertyDataDefinition
- .setDescription((String) properties.get(GraphPropertiesDictionary.DESCRIPTION.getProperty()));
-
- Type listType = new TypeToken<List<String>>() {
- }.getType();
- List<String> constraintsfromJson = getGson()
- .fromJson((String) properties.get(GraphPropertiesDictionary.CONSTRAINTS.getProperty()), listType);
- setConstraints(constraintsfromJson);
- // setConstraints((List<String>)
- // properties.get(GraphPropertiesDictionary.CONSTRAINTS.getProperty()));
-
- Type schemaType = new TypeToken<SchemaDefinition>() {
- }.getType();
- SchemaDefinition schema = getGson()
- .fromJson((String) properties.get(GraphPropertiesDictionary.ENTRY_SCHEMA.getProperty()), schemaType);
- propertyDataDefinition.setSchema(schema);
-
- }
-
- @Override
- public Map<String, Object> toGraphMap() {
-
- Map<String, Object> map = new HashMap<>();
-
- addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, propertyDataDefinition.getUniqueId());
-
- addIfExists(map, GraphPropertiesDictionary.TYPE, propertyDataDefinition.getType());
-
- addIfExists(map, GraphPropertiesDictionary.DESCRIPTION, propertyDataDefinition.getDescription());
-
- String defaultValue = propertyDataDefinition.getDefaultValue();
- if (defaultValue == null) {
- defaultValue = Constants.GRAPH_EMPTY_VALUE;
- }
- addIfExists(map, GraphPropertiesDictionary.DEFAULT_VALUE, defaultValue);
-
- addIfExists(map, GraphPropertiesDictionary.REQUIRED, propertyDataDefinition.isRequired());
-
- addIfExists(map, GraphPropertiesDictionary.CONSTRAINTS, getConstraints());
-
- SchemaDefinition entrySchema = propertyDataDefinition.getSchema();
- if (entrySchema != null) {
- String entrySchemaStr = getGson().toJson(entrySchema);
- addIfExists(map, GraphPropertiesDictionary.ENTRY_SCHEMA, entrySchemaStr);
- }
- // String constraintsAsJson = getGson().toJson(getConstraints());
- // addIfExists(map, GraphPropertiesDictionary.CONSTRAINTS,
- // constraintsAsJson);
-
- return map;
- }
-
- public List<String> getConstraints() {
- return constraints;
- }
-
- public void setConstraints(List<String> constraints) {
- this.constraints = constraints;
- }
-
- @Override
- public String getUniqueId() {
- return propertyDataDefinition.getUniqueId();
- }
-
- public PropertyDataDefinition getPropertyDataDefinition() {
- return propertyDataDefinition;
- }
-
- public void setPropertyDataDefinition(PropertyDataDefinition propertyDataDefinition) {
- this.propertyDataDefinition = propertyDataDefinition;
- }
-
- @Override
- public String toString() {
- return "PropertyData [propertyDataDefinition=" + propertyDataDefinition + ", constraints=" + constraints + "]";
- }
-
+ PropertyDataDefinition propertyDataDefinition;
+ private List<String> constraints;
+
+ public PropertyData() {
+ super(NodeTypeEnum.Property);
+ propertyDataDefinition = new PropertyDataDefinition();
+ }
+
+ public PropertyData(PropertyDataDefinition propertyDataDefinition, List<String> constraints) {
+ super(NodeTypeEnum.Property);
+ this.propertyDataDefinition = propertyDataDefinition;
+ this.constraints = constraints;
+ }
+
+ public PropertyData(Map<String, Object> properties) {
+ this();
+ propertyDataDefinition.setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
+ propertyDataDefinition.setType((String) properties.get(GraphPropertiesDictionary.TYPE.getProperty()));
+ propertyDataDefinition.setRequired((Boolean) properties.get(GraphPropertiesDictionary.REQUIRED.getProperty()));
+ String defaultValue = (String) properties.get(GraphPropertiesDictionary.DEFAULT_VALUE.getProperty());
+ if (Constants.GRAPH_EMPTY_VALUE.equals(defaultValue)) {
+ propertyDataDefinition.setDefaultValue(null);
+ } else {
+ propertyDataDefinition.setDefaultValue(defaultValue);
+ }
+ propertyDataDefinition.setDescription((String) properties.get(GraphPropertiesDictionary.DESCRIPTION.getProperty()));
+ Type listType = new TypeToken<List<String>>() {
+ }.getType();
+ List<String> constraintsfromJson = getGson().fromJson((String) properties.get(GraphPropertiesDictionary.CONSTRAINTS.getProperty()), listType);
+ setConstraints(constraintsfromJson);
+ // setConstraints((List<String>)
+
+ // properties.get(GraphPropertiesDictionary.CONSTRAINTS.getProperty()));
+ Type schemaType = new TypeToken<SchemaDefinition>() {
+ }.getType();
+ SchemaDefinition schema = getGson().fromJson((String) properties.get(GraphPropertiesDictionary.ENTRY_SCHEMA.getProperty()), schemaType);
+ propertyDataDefinition.setSchema(schema);
+ }
+
+ @Override
+ public Map<String, Object> toGraphMap() {
+ Map<String, Object> map = new HashMap<>();
+ addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, propertyDataDefinition.getUniqueId());
+ addIfExists(map, GraphPropertiesDictionary.TYPE, propertyDataDefinition.getType());
+ addIfExists(map, GraphPropertiesDictionary.DESCRIPTION, propertyDataDefinition.getDescription());
+ String defaultValue = propertyDataDefinition.getDefaultValue();
+ if (defaultValue == null) {
+ defaultValue = Constants.GRAPH_EMPTY_VALUE;
+ }
+ addIfExists(map, GraphPropertiesDictionary.DEFAULT_VALUE, defaultValue);
+ addIfExists(map, GraphPropertiesDictionary.REQUIRED, propertyDataDefinition.isRequired());
+ addIfExists(map, GraphPropertiesDictionary.CONSTRAINTS, getConstraints());
+ SchemaDefinition entrySchema = propertyDataDefinition.getSchema();
+ if (entrySchema != null) {
+ String entrySchemaStr = getGson().toJson(entrySchema);
+ addIfExists(map, GraphPropertiesDictionary.ENTRY_SCHEMA, entrySchemaStr);
+ }
+ // String constraintsAsJson = getGson().toJson(getConstraints());
+
+ // addIfExists(map, GraphPropertiesDictionary.CONSTRAINTS,
+
+ // constraintsAsJson);
+ return map;
+ }
+
+ public List<String> getConstraints() {
+ return constraints;
+ }
+
+ public void setConstraints(List<String> constraints) {
+ this.constraints = constraints;
+ }
+
+ @Override
+ public String getUniqueId() {
+ return propertyDataDefinition.getUniqueId();
+ }
+
+ public PropertyDataDefinition getPropertyDataDefinition() {
+ return propertyDataDefinition;
+ }
+
+ public void setPropertyDataDefinition(PropertyDataDefinition propertyDataDefinition) {
+ this.propertyDataDefinition = propertyDataDefinition;
+ }
+
+ @Override
+ public String toString() {
+ return "PropertyData [propertyDataDefinition=" + propertyDataDefinition + ", constraints=" + constraints + "]";
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/PropertyValueData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/PropertyValueData.java
index 1ec949dace..1fac5ea0a1 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/PropertyValueData.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/PropertyValueData.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,142 +17,117 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.resources.data;
import com.google.gson.reflect.TypeToken;
+import java.lang.reflect.Type;
+import java.util.HashMap;
+import java.util.List;
+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.PropertyRule;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import java.lang.reflect.Type;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
public class PropertyValueData extends GraphNode {
- public PropertyValueData() {
- super(NodeTypeEnum.PropertyValue);
- }
-
- public PropertyValueData(Map<String, Object> properties) {
- this();
-
- this.setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
-
- String updatedValue = (String) properties.get(GraphPropertiesDictionary.VALUE.getProperty());
- if (Constants.GRAPH_EMPTY_VALUE.equals(updatedValue)) {
- this.setValue(null);
- } else {
- this.setValue(updatedValue);
- }
-
- this.setType((String) properties.get(GraphPropertiesDictionary.TYPE.getProperty()));
-
- this.setCreationTime((Long) properties.get(GraphPropertiesDictionary.CREATION_DATE.getProperty()));
-
- this.setModificationTime((Long) properties.get(GraphPropertiesDictionary.LAST_UPDATE_DATE.getProperty()));
-
- Type mapType = new TypeToken<List<PropertyRule>>() {
- }.getType();
- List<PropertyRule> propertyRules = getGson().fromJson(
- (String) properties.get(GraphPropertiesDictionary.PROPERTY_VALUE_RULES.getProperty()), mapType);
- this.setRules(propertyRules);
-
- }
-
- private String uniqueId;
-
- private String value;
-
- private String type;
-
- private Long creationTime;
-
- private Long modificationTime;
-
- private List<PropertyRule> rules;
-
- @Override
- public String getUniqueId() {
- return uniqueId;
- }
-
- public void setUniqueId(String uniqueId) {
- this.uniqueId = uniqueId;
- }
-
- public String getType() {
- return type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
- public Long getCreationTime() {
- return creationTime;
- }
-
- public void setCreationTime(Long creationTime) {
- this.creationTime = creationTime;
- }
-
- public Long getModificationTime() {
- return modificationTime;
- }
-
- public void setModificationTime(Long modificationTime) {
- this.modificationTime = modificationTime;
- }
-
- public String getValue() {
- return value;
- }
-
- public void setValue(String value) {
- this.value = value;
- }
-
- public List<PropertyRule> getRules() {
- return rules;
- }
-
- public void setRules(List<PropertyRule> rules) {
- this.rules = rules;
- }
-
- @Override
- public Map<String, Object> toGraphMap() {
-
- Map<String, Object> map = new HashMap<>();
-
- addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, uniqueId);
-
- String updatedValue = value;
- if (updatedValue == null) {
- updatedValue = Constants.GRAPH_EMPTY_VALUE;
- }
- addIfExists(map, GraphPropertiesDictionary.VALUE, updatedValue);
-
- addIfExists(map, GraphPropertiesDictionary.TYPE, type);
-
- addIfExists(map, GraphPropertiesDictionary.CREATION_DATE, creationTime);
-
- addIfExists(map, GraphPropertiesDictionary.LAST_UPDATE_DATE, modificationTime);
-
- addIfExists(map, GraphPropertiesDictionary.PROPERTY_VALUE_RULES, rules);
-
- return map;
- }
-
- @Override
- public String toString() {
- return "PropertyValueData [uniqueId=" + uniqueId + ", value=" + value + ", type=" + type + ", creationTime="
- + creationTime + ", modificationTime=" + modificationTime + ", rules=" + rules + "]";
- }
-
+ private String uniqueId;
+ private String value;
+ private String type;
+ private Long creationTime;
+ private Long modificationTime;
+ private List<PropertyRule> rules;
+ public PropertyValueData() {
+ super(NodeTypeEnum.PropertyValue);
+ }
+ public PropertyValueData(Map<String, Object> properties) {
+ this();
+ this.setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
+ String updatedValue = (String) properties.get(GraphPropertiesDictionary.VALUE.getProperty());
+ if (Constants.GRAPH_EMPTY_VALUE.equals(updatedValue)) {
+ this.setValue(null);
+ } else {
+ this.setValue(updatedValue);
+ }
+ this.setType((String) properties.get(GraphPropertiesDictionary.TYPE.getProperty()));
+ this.setCreationTime((Long) properties.get(GraphPropertiesDictionary.CREATION_DATE.getProperty()));
+ this.setModificationTime((Long) properties.get(GraphPropertiesDictionary.LAST_UPDATE_DATE.getProperty()));
+ Type mapType = new TypeToken<List<PropertyRule>>() {
+ }.getType();
+ List<PropertyRule> propertyRules = getGson()
+ .fromJson((String) properties.get(GraphPropertiesDictionary.PROPERTY_VALUE_RULES.getProperty()), mapType);
+ this.setRules(propertyRules);
+ }
+
+ @Override
+ public String getUniqueId() {
+ return uniqueId;
+ }
+
+ public void setUniqueId(String uniqueId) {
+ this.uniqueId = uniqueId;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public Long getCreationTime() {
+ return creationTime;
+ }
+
+ public void setCreationTime(Long creationTime) {
+ this.creationTime = creationTime;
+ }
+
+ public Long getModificationTime() {
+ return modificationTime;
+ }
+
+ public void setModificationTime(Long modificationTime) {
+ this.modificationTime = modificationTime;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ public List<PropertyRule> getRules() {
+ return rules;
+ }
+
+ public void setRules(List<PropertyRule> rules) {
+ this.rules = rules;
+ }
+
+ @Override
+ public Map<String, Object> toGraphMap() {
+ Map<String, Object> map = new HashMap<>();
+ addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, uniqueId);
+ String updatedValue = value;
+ if (updatedValue == null) {
+ updatedValue = Constants.GRAPH_EMPTY_VALUE;
+ }
+ addIfExists(map, GraphPropertiesDictionary.VALUE, updatedValue);
+ addIfExists(map, GraphPropertiesDictionary.TYPE, type);
+ addIfExists(map, GraphPropertiesDictionary.CREATION_DATE, creationTime);
+ addIfExists(map, GraphPropertiesDictionary.LAST_UPDATE_DATE, modificationTime);
+ addIfExists(map, GraphPropertiesDictionary.PROPERTY_VALUE_RULES, rules);
+ return map;
+ }
+
+ @Override
+ public String toString() {
+ return "PropertyValueData [uniqueId=" + uniqueId + ", value=" + value + ", type=" + type + ", creationTime=" + creationTime
+ + ", modificationTime=" + modificationTime + ", rules=" + rules + "]";
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/RelationshipInstData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/RelationshipInstData.java
index 0deba18c02..0ff9edfbca 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/RelationshipInstData.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/RelationshipInstData.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,148 +17,124 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.resources.data;
+import java.util.HashMap;
+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.datatypes.enums.NodeTypeEnum;
-import java.util.HashMap;
-import java.util.Map;
-
public class RelationshipInstData extends GraphNode {
- private String type;
-
- private String uniqueId;
-
- private Long creationTime;
-
- private Long modificationTime;
-
- private String capabilityOwnerId;
- private String requirementOwnerId;
- private String capabiltyId;
- private String requirementId;
-
- public RelationshipInstData() {
- super(NodeTypeEnum.RelationshipInst);
- }
-
- public RelationshipInstData(Map<String, Object> properties) {
-
- this();
-
- this.setType((String) properties.get(GraphPropertiesDictionary.TYPE.getProperty()));
-
- this.setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
-
- this.setCreationTime((Long) properties.get(GraphPropertiesDictionary.CREATION_DATE.getProperty()));
-
- this.setModificationTime((Long) properties.get(GraphPropertiesDictionary.LAST_UPDATE_DATE.getProperty()));
-
- this.setCapabilityOwnerId((String) properties.get(GraphPropertiesDictionary.CAPABILITY_OWNER_ID.getProperty()));
- this.setRequirementOwnerId(
- (String) properties.get(GraphPropertiesDictionary.REQUIREMENT_OWNER_ID.getProperty()));
- this.setRequirementId((String) properties.get(GraphPropertiesDictionary.REQUIREMENT_ID.getProperty()));
- this.setCapabiltyId((String) properties.get(GraphPropertiesDictionary.CAPABILITY_ID.getProperty()));
-
- }
-
- @Override
- public Map<String, Object> toGraphMap() {
-
- Map<String, Object> map = new HashMap<>();
-
- addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, uniqueId);
-
- addIfExists(map, GraphPropertiesDictionary.TYPE, type);
-
- addIfExists(map, GraphPropertiesDictionary.CREATION_DATE, creationTime);
-
- addIfExists(map, GraphPropertiesDictionary.LAST_UPDATE_DATE, modificationTime);
- addIfExists(map, GraphPropertiesDictionary.CAPABILITY_OWNER_ID, capabilityOwnerId);
- addIfExists(map, GraphPropertiesDictionary.REQUIREMENT_OWNER_ID, requirementOwnerId);
-
- addIfExists(map, GraphPropertiesDictionary.REQUIREMENT_ID, requirementId);
-
- addIfExists(map, GraphPropertiesDictionary.CAPABILITY_ID, capabiltyId);
-
- return map;
- }
-
- public Long getCreationTime() {
- return creationTime;
- }
-
- public void setCreationTime(Long creationTime) {
- this.creationTime = creationTime;
- }
-
- public Long getModificationTime() {
- return modificationTime;
- }
-
- public void setModificationTime(Long modificationTime) {
- this.modificationTime = modificationTime;
- }
-
- public void setUniqueId(String uniqueId) {
- this.uniqueId = uniqueId;
- }
-
- @Override
- public String getUniqueId() {
- return uniqueId;
- }
-
- public String getType() {
- return type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
- public String getCapabilityOwnerId() {
- return capabilityOwnerId;
- }
-
- public void setCapabilityOwnerId(String capabilityOwnerId) {
- this.capabilityOwnerId = capabilityOwnerId;
- }
-
- public String getRequirementOwnerId() {
- return requirementOwnerId;
- }
-
- public void setRequirementOwnerId(String requirementOwnerId) {
- this.requirementOwnerId = requirementOwnerId;
- }
-
- public String getCapabiltyId() {
- return capabiltyId;
- }
-
- public void setCapabiltyId(String capabiltyId) {
- this.capabiltyId = capabiltyId;
- }
-
- public String getRequirementId() {
- return requirementId;
- }
-
- public void setRequirementId(String requirementId) {
- this.requirementId = requirementId;
- }
-
- @Override
- public String toString() {
- return "RelationshipInstData [type=" + type + ", uniqueId=" + uniqueId + ", creationTime=" + creationTime
- + ", modificationTime=" + modificationTime + ", capabilityOwnerId=" + capabilityOwnerId
- + ", requirementOwnerId=" + requirementOwnerId + ", capabiltyId=" + capabiltyId + ", requirementId="
- + requirementId + "]";
- }
-
+ private String type;
+ private String uniqueId;
+ private Long creationTime;
+ private Long modificationTime;
+ private String capabilityOwnerId;
+ private String requirementOwnerId;
+ private String capabiltyId;
+ private String requirementId;
+
+ public RelationshipInstData() {
+ super(NodeTypeEnum.RelationshipInst);
+ }
+
+ public RelationshipInstData(Map<String, Object> properties) {
+ this();
+ this.setType((String) properties.get(GraphPropertiesDictionary.TYPE.getProperty()));
+ this.setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
+ this.setCreationTime((Long) properties.get(GraphPropertiesDictionary.CREATION_DATE.getProperty()));
+ this.setModificationTime((Long) properties.get(GraphPropertiesDictionary.LAST_UPDATE_DATE.getProperty()));
+ this.setCapabilityOwnerId((String) properties.get(GraphPropertiesDictionary.CAPABILITY_OWNER_ID.getProperty()));
+ this.setRequirementOwnerId((String) properties.get(GraphPropertiesDictionary.REQUIREMENT_OWNER_ID.getProperty()));
+ this.setRequirementId((String) properties.get(GraphPropertiesDictionary.REQUIREMENT_ID.getProperty()));
+ this.setCapabiltyId((String) properties.get(GraphPropertiesDictionary.CAPABILITY_ID.getProperty()));
+ }
+
+ @Override
+ public Map<String, Object> toGraphMap() {
+ Map<String, Object> map = new HashMap<>();
+ addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, uniqueId);
+ addIfExists(map, GraphPropertiesDictionary.TYPE, type);
+ addIfExists(map, GraphPropertiesDictionary.CREATION_DATE, creationTime);
+ addIfExists(map, GraphPropertiesDictionary.LAST_UPDATE_DATE, modificationTime);
+ addIfExists(map, GraphPropertiesDictionary.CAPABILITY_OWNER_ID, capabilityOwnerId);
+ addIfExists(map, GraphPropertiesDictionary.REQUIREMENT_OWNER_ID, requirementOwnerId);
+ addIfExists(map, GraphPropertiesDictionary.REQUIREMENT_ID, requirementId);
+ addIfExists(map, GraphPropertiesDictionary.CAPABILITY_ID, capabiltyId);
+ return map;
+ }
+
+ public Long getCreationTime() {
+ return creationTime;
+ }
+
+ public void setCreationTime(Long creationTime) {
+ this.creationTime = creationTime;
+ }
+
+ public Long getModificationTime() {
+ return modificationTime;
+ }
+
+ public void setModificationTime(Long modificationTime) {
+ this.modificationTime = modificationTime;
+ }
+
+ @Override
+ public String getUniqueId() {
+ return uniqueId;
+ }
+
+ public void setUniqueId(String uniqueId) {
+ this.uniqueId = uniqueId;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getCapabilityOwnerId() {
+ return capabilityOwnerId;
+ }
+
+ public void setCapabilityOwnerId(String capabilityOwnerId) {
+ this.capabilityOwnerId = capabilityOwnerId;
+ }
+
+ public String getRequirementOwnerId() {
+ return requirementOwnerId;
+ }
+
+ public void setRequirementOwnerId(String requirementOwnerId) {
+ this.requirementOwnerId = requirementOwnerId;
+ }
+
+ public String getCapabiltyId() {
+ return capabiltyId;
+ }
+
+ public void setCapabiltyId(String capabiltyId) {
+ this.capabiltyId = capabiltyId;
+ }
+
+ public String getRequirementId() {
+ return requirementId;
+ }
+
+ public void setRequirementId(String requirementId) {
+ this.requirementId = requirementId;
+ }
+
+ @Override
+ public String toString() {
+ return "RelationshipInstData [type=" + type + ", uniqueId=" + uniqueId + ", creationTime=" + creationTime + ", modificationTime="
+ + modificationTime + ", capabilityOwnerId=" + capabilityOwnerId + ", requirementOwnerId=" + requirementOwnerId + ", capabiltyId="
+ + capabiltyId + ", requirementId=" + requirementId + "]";
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/RelationshipTypeData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/RelationshipTypeData.java
index 440cddad55..39adfd94e3 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/RelationshipTypeData.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/RelationshipTypeData.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,121 +17,92 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.resources.data;
import com.google.gson.reflect.TypeToken;
-import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
-import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
-import org.openecomp.sdc.be.datatypes.elements.RelationshipInstDataDefinition;
-import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-
import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.List;
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.datatypes.elements.RelationshipInstDataDefinition;
+import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
public class RelationshipTypeData extends GraphNode {
- RelationshipInstDataDefinition relationshipTypeDataDefinition;
-
- public RelationshipTypeData() {
- super(NodeTypeEnum.RelationshipType);
- relationshipTypeDataDefinition = new RelationshipInstDataDefinition();
- }
+ RelationshipInstDataDefinition relationshipTypeDataDefinition;
- public RelationshipTypeData(RelationshipInstDataDefinition relationshipTypeDataDefinition) {
- super(NodeTypeEnum.RelationshipType);
- this.relationshipTypeDataDefinition = relationshipTypeDataDefinition;
- }
+ public RelationshipTypeData() {
+ super(NodeTypeEnum.RelationshipType);
+ relationshipTypeDataDefinition = new RelationshipInstDataDefinition();
+ }
- public RelationshipTypeData(Map<String, Object> properties) {
-
- this();
-
- relationshipTypeDataDefinition
- .setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
-
- relationshipTypeDataDefinition.setType((String) properties.get(GraphPropertiesDictionary.TYPE.getProperty()));
-
- relationshipTypeDataDefinition
- .setDescription((String) properties.get(GraphPropertiesDictionary.DESCRIPTION.getProperty()));
-
- Type listSourceType = new TypeToken<List<String>>() {
- }.getType();
- List<String> validSourceTypesfromJson = getGson().fromJson(
- (String) properties.get(GraphPropertiesDictionary.VALID_SOURCE_TYPES.getProperty()), listSourceType);
-
- relationshipTypeDataDefinition.setValidSourceTypes(validSourceTypesfromJson);
+ public RelationshipTypeData(RelationshipInstDataDefinition relationshipTypeDataDefinition) {
+ super(NodeTypeEnum.RelationshipType);
+ this.relationshipTypeDataDefinition = relationshipTypeDataDefinition;
+ }
+ public RelationshipTypeData(Map<String, Object> properties) {
+ this();
+ relationshipTypeDataDefinition.setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
+ relationshipTypeDataDefinition.setType((String) properties.get(GraphPropertiesDictionary.TYPE.getProperty()));
+ relationshipTypeDataDefinition.setDescription((String) properties.get(GraphPropertiesDictionary.DESCRIPTION.getProperty()));
+ Type listSourceType = new TypeToken<List<String>>() {
+ }.getType();
+ List<String> validSourceTypesfromJson = getGson()
+ .fromJson((String) properties.get(GraphPropertiesDictionary.VALID_SOURCE_TYPES.getProperty()), listSourceType);
+ relationshipTypeDataDefinition.setValidSourceTypes(validSourceTypesfromJson);
Type listTargetType = new TypeToken<List<String>>() {
}.getType();
- List<String> validTargetTypesfromJson = getGson().fromJson(
- (String) properties.get(GraphPropertiesDictionary.VALID_TARGET_TYPES.getProperty()), listTargetType);
-
+ List<String> validTargetTypesfromJson = getGson()
+ .fromJson((String) properties.get(GraphPropertiesDictionary.VALID_TARGET_TYPES.getProperty()), listTargetType);
relationshipTypeDataDefinition.setValidTargetTypes(validTargetTypesfromJson);
-
- // relationshipTypeDataDefinition.setValidSourceTypes((List<String>)
- // properties.get(GraphPropertiesDictionary.VALID_SOURCE_TYPES
- // .getProperty()));
-
- relationshipTypeDataDefinition
- .setCreationTime((Long) properties.get(GraphPropertiesDictionary.CREATION_DATE.getProperty()));
-
- relationshipTypeDataDefinition
- .setModificationTime((Long) properties.get(GraphPropertiesDictionary.LAST_UPDATE_DATE.getProperty()));
-
- // capabilityTypeDataDefinition.setVersion(version);
-
- }
-
- @Override
- public Map<String, Object> toGraphMap() {
-
- Map<String, Object> map = new HashMap<>();
-
- addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, relationshipTypeDataDefinition.getUniqueId());
-
- addIfExists(map, GraphPropertiesDictionary.TYPE, relationshipTypeDataDefinition.getType());
-
- addIfExists(map, GraphPropertiesDictionary.DESCRIPTION, relationshipTypeDataDefinition.getDescription());
-
- // String validSourceTypesToJson =
- // getGson().toJson(relationshipTypeDataDefinition.getValidSourceTypes());
-
- // addIfExists(map, GraphPropertiesDictionary.VALID_SOURCE_TYPES,
- // validSourceTypesToJson);
-
- addIfExists(map, GraphPropertiesDictionary.VALID_SOURCE_TYPES,
- relationshipTypeDataDefinition.getValidSourceTypes());
-
- addIfExists(map, GraphPropertiesDictionary.VALID_TARGET_TYPES,
- relationshipTypeDataDefinition.getValidTargetTypes());
-
- addIfExists(map, GraphPropertiesDictionary.CREATION_DATE, relationshipTypeDataDefinition.getCreationTime());
-
- addIfExists(map, GraphPropertiesDictionary.LAST_UPDATE_DATE,
- relationshipTypeDataDefinition.getModificationTime());
-
- return map;
- }
-
- public RelationshipInstDataDefinition getRelationshipTypeDataDefinition() {
- return relationshipTypeDataDefinition;
- }
-
- public void setRelationshipTypeDataDefinition(RelationshipInstDataDefinition relationshipTypeDataDefinition) {
- this.relationshipTypeDataDefinition = relationshipTypeDataDefinition;
- }
-
- @Override
- public String getUniqueId() {
- return this.relationshipTypeDataDefinition.getUniqueId();
- }
-
- @Override
- public String toString() {
- return "RelationshipTypeData [relationshipTypeDataDefinition=" + relationshipTypeDataDefinition + "]";
- }
-
+ // relationshipTypeDataDefinition.setValidSourceTypes((List<String>)
+
+ // properties.get(GraphPropertiesDictionary.VALID_SOURCE_TYPES
+
+ // .getProperty()));
+ relationshipTypeDataDefinition.setCreationTime((Long) properties.get(GraphPropertiesDictionary.CREATION_DATE.getProperty()));
+ relationshipTypeDataDefinition.setModificationTime((Long) properties.get(GraphPropertiesDictionary.LAST_UPDATE_DATE.getProperty()));
+ // capabilityTypeDataDefinition.setVersion(version);
+ }
+
+ @Override
+ public Map<String, Object> toGraphMap() {
+ Map<String, Object> map = new HashMap<>();
+ addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, relationshipTypeDataDefinition.getUniqueId());
+ addIfExists(map, GraphPropertiesDictionary.TYPE, relationshipTypeDataDefinition.getType());
+ addIfExists(map, GraphPropertiesDictionary.DESCRIPTION, relationshipTypeDataDefinition.getDescription());
+ // String validSourceTypesToJson =
+
+ // getGson().toJson(relationshipTypeDataDefinition.getValidSourceTypes());
+
+ // addIfExists(map, GraphPropertiesDictionary.VALID_SOURCE_TYPES,
+
+ // validSourceTypesToJson);
+ addIfExists(map, GraphPropertiesDictionary.VALID_SOURCE_TYPES, relationshipTypeDataDefinition.getValidSourceTypes());
+ addIfExists(map, GraphPropertiesDictionary.VALID_TARGET_TYPES, relationshipTypeDataDefinition.getValidTargetTypes());
+ addIfExists(map, GraphPropertiesDictionary.CREATION_DATE, relationshipTypeDataDefinition.getCreationTime());
+ addIfExists(map, GraphPropertiesDictionary.LAST_UPDATE_DATE, relationshipTypeDataDefinition.getModificationTime());
+ return map;
+ }
+
+ public RelationshipInstDataDefinition getRelationshipTypeDataDefinition() {
+ return relationshipTypeDataDefinition;
+ }
+
+ public void setRelationshipTypeDataDefinition(RelationshipInstDataDefinition relationshipTypeDataDefinition) {
+ this.relationshipTypeDataDefinition = relationshipTypeDataDefinition;
+ }
+
+ @Override
+ public String getUniqueId() {
+ return this.relationshipTypeDataDefinition.getUniqueId();
+ }
+
+ @Override
+ public String toString() {
+ return "RelationshipTypeData [relationshipTypeDataDefinition=" + relationshipTypeDataDefinition + "]";
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/RequirementData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/RequirementData.java
index de1b9c62aa..df696b384e 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/RequirementData.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/RequirementData.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,140 +17,118 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.resources.data;
+import java.util.HashMap;
+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.datatypes.elements.RequirementDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import java.util.HashMap;
-import java.util.Map;
-
public class RequirementData extends GraphNode {
- private String uniqueId;
-
- private String node;
-
- private Long creationTime;
-
- private Long modificationTime;
-
- private String relationshipType;
- private String minOccurrences = RequirementDataDefinition.MIN_OCCURRENCES;
- private String maxOccurrences = RequirementDataDefinition.MAX_DEFAULT_OCCURRENCES;
-
- public RequirementData() {
- super(NodeTypeEnum.Requirement);
-
- }
-
- public RequirementData(Map<String, Object> properties) {
-
- this();
-
- this.setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
-
- this.setNode((String) properties.get(GraphPropertiesDictionary.NODE.getProperty()));
-
- this.setCreationTime((Long) properties.get(GraphPropertiesDictionary.CREATION_DATE.getProperty()));
-
- this.setModificationTime((Long) properties.get(GraphPropertiesDictionary.LAST_UPDATE_DATE.getProperty()));
-
- this.setRelationshipType((String) properties.get(GraphPropertiesDictionary.RELATIONSHIP_TYPE.getProperty()));
- this.setMinOccurrences((String) properties.get(GraphPropertiesDictionary.MIN_OCCURRENCES.getProperty()));
- this.setMaxOccurrences((String) properties.get(GraphPropertiesDictionary.MAX_OCCURRENCES.getProperty()));
-
- }
-
- @Override
- public Map<String, Object> toGraphMap() {
-
- Map<String, Object> map = new HashMap<>();
-
- addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, uniqueId);
-
- addIfExists(map, GraphPropertiesDictionary.NODE, node);
-
- addIfExists(map, GraphPropertiesDictionary.CREATION_DATE, creationTime);
-
- addIfExists(map, GraphPropertiesDictionary.LAST_UPDATE_DATE, modificationTime);
-
- addIfExists(map, GraphPropertiesDictionary.RELATIONSHIP_TYPE, relationshipType);
- addIfExists(map, GraphPropertiesDictionary.MIN_OCCURRENCES, minOccurrences);
- addIfExists(map, GraphPropertiesDictionary.MAX_OCCURRENCES, maxOccurrences);
-
- return map;
- }
-
- public String getNode() {
- return node;
- }
-
- public void setNode(String node) {
- this.node = node;
- }
-
- public Long getCreationTime() {
- return creationTime;
- }
-
- public void setCreationTime(Long creationTime) {
- this.creationTime = creationTime;
- }
-
- public Long getModificationTime() {
- return modificationTime;
- }
-
- public void setModificationTime(Long modificationTime) {
- this.modificationTime = modificationTime;
- }
-
- public void setUniqueId(String uniqueId) {
- this.uniqueId = uniqueId;
- }
-
- public String getRelationshipType() {
- return relationshipType;
- }
-
- public void setRelationshipType(String relationshipType) {
- this.relationshipType = relationshipType;
- }
-
- public String getMinOccurrences() {
- return minOccurrences;
- }
-
- public void setMinOccurrences(String minOccurrences) {
- if (minOccurrences != null) {
- this.minOccurrences = minOccurrences;
- }
- }
-
- public String getMaxOccurrences() {
- return maxOccurrences;
- }
-
- public void setMaxOccurrences(String maxOccurrences) {
- if (maxOccurrences != null) {
- this.maxOccurrences = maxOccurrences;
- }
- }
-
- @Override
- public String getUniqueId() {
- return uniqueId;
- }
-
- @Override
- public String toString() {
- return "RequirementData [uniqueId=" + uniqueId + ", node=" + node + ", creationTime=" + creationTime
- + ", modificationTime=" + modificationTime + ", relationshipType=" + relationshipType
- + ", minOccurrences=" + minOccurrences + ", maxOccurrences=" + maxOccurrences + "]";
- }
-
+ private String uniqueId;
+ private String node;
+ private Long creationTime;
+ private Long modificationTime;
+ private String relationshipType;
+ private String minOccurrences = RequirementDataDefinition.MIN_OCCURRENCES;
+ private String maxOccurrences = RequirementDataDefinition.MAX_DEFAULT_OCCURRENCES;
+
+ public RequirementData() {
+ super(NodeTypeEnum.Requirement);
+ }
+
+ public RequirementData(Map<String, Object> properties) {
+ this();
+ this.setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
+ this.setNode((String) properties.get(GraphPropertiesDictionary.NODE.getProperty()));
+ this.setCreationTime((Long) properties.get(GraphPropertiesDictionary.CREATION_DATE.getProperty()));
+ this.setModificationTime((Long) properties.get(GraphPropertiesDictionary.LAST_UPDATE_DATE.getProperty()));
+ this.setRelationshipType((String) properties.get(GraphPropertiesDictionary.RELATIONSHIP_TYPE.getProperty()));
+ this.setMinOccurrences((String) properties.get(GraphPropertiesDictionary.MIN_OCCURRENCES.getProperty()));
+ this.setMaxOccurrences((String) properties.get(GraphPropertiesDictionary.MAX_OCCURRENCES.getProperty()));
+ }
+
+ @Override
+ public Map<String, Object> toGraphMap() {
+ Map<String, Object> map = new HashMap<>();
+ addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, uniqueId);
+ addIfExists(map, GraphPropertiesDictionary.NODE, node);
+ addIfExists(map, GraphPropertiesDictionary.CREATION_DATE, creationTime);
+ addIfExists(map, GraphPropertiesDictionary.LAST_UPDATE_DATE, modificationTime);
+ addIfExists(map, GraphPropertiesDictionary.RELATIONSHIP_TYPE, relationshipType);
+ addIfExists(map, GraphPropertiesDictionary.MIN_OCCURRENCES, minOccurrences);
+ addIfExists(map, GraphPropertiesDictionary.MAX_OCCURRENCES, maxOccurrences);
+ return map;
+ }
+
+ public String getNode() {
+ return node;
+ }
+
+ public void setNode(String node) {
+ this.node = node;
+ }
+
+ public Long getCreationTime() {
+ return creationTime;
+ }
+
+ public void setCreationTime(Long creationTime) {
+ this.creationTime = creationTime;
+ }
+
+ public Long getModificationTime() {
+ return modificationTime;
+ }
+
+ public void setModificationTime(Long modificationTime) {
+ this.modificationTime = modificationTime;
+ }
+
+ public String getRelationshipType() {
+ return relationshipType;
+ }
+
+ public void setRelationshipType(String relationshipType) {
+ this.relationshipType = relationshipType;
+ }
+
+ public String getMinOccurrences() {
+ return minOccurrences;
+ }
+
+ public void setMinOccurrences(String minOccurrences) {
+ if (minOccurrences != null) {
+ this.minOccurrences = minOccurrences;
+ }
+ }
+
+ public String getMaxOccurrences() {
+ return maxOccurrences;
+ }
+
+ public void setMaxOccurrences(String maxOccurrences) {
+ if (maxOccurrences != null) {
+ this.maxOccurrences = maxOccurrences;
+ }
+ }
+
+ @Override
+ public String getUniqueId() {
+ return uniqueId;
+ }
+
+ public void setUniqueId(String uniqueId) {
+ this.uniqueId = uniqueId;
+ }
+
+ @Override
+ public String toString() {
+ return "RequirementData [uniqueId=" + uniqueId + ", node=" + node + ", creationTime=" + creationTime + ", modificationTime="
+ + modificationTime + ", relationshipType=" + relationshipType + ", minOccurrences=" + minOccurrences + ", maxOccurrences="
+ + maxOccurrences + "]";
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/RequirementImplData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/RequirementImplData.java
index 36d6d8d718..c2296d5373 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/RequirementImplData.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/RequirementImplData.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,125 +17,101 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.resources.data;
+import java.util.HashMap;
+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.datatypes.enums.NodeTypeEnum;
-import java.util.HashMap;
-import java.util.Map;
-
public class RequirementImplData extends GraphNode {
- private String name;
-
- private String uniqueId;
-
- private Long creationTime;
-
- private Long modificationTime;
-
- private String posX;
-
- private String posY;
-
- public RequirementImplData() {
- super(NodeTypeEnum.RequirementImpl);
- }
-
- public RequirementImplData(Map<String, Object> properties) {
-
- this();
-
- this.setName((String) properties.get(GraphPropertiesDictionary.NAME.getProperty()));
-
- this.setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
-
- this.setCreationTime((Long) properties.get(GraphPropertiesDictionary.CREATION_DATE.getProperty()));
-
- this.setModificationTime((Long) properties.get(GraphPropertiesDictionary.LAST_UPDATE_DATE.getProperty()));
-
- setPosX((String) properties.get(GraphPropertiesDictionary.POSITION_X.getProperty()));
-
- setPosY((String) properties.get(GraphPropertiesDictionary.POSITION_Y.getProperty()));
-
- }
-
- @Override
- public Map<String, Object> toGraphMap() {
-
- Map<String, Object> map = new HashMap<>();
-
- addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, uniqueId);
-
- addIfExists(map, GraphPropertiesDictionary.NAME, name);
-
- addIfExists(map, GraphPropertiesDictionary.CREATION_DATE, creationTime);
-
- addIfExists(map, GraphPropertiesDictionary.LAST_UPDATE_DATE, modificationTime);
-
- addIfExists(map, GraphPropertiesDictionary.POSITION_X, posX);
-
- addIfExists(map, GraphPropertiesDictionary.POSITION_Y, posY);
-
- return map;
- }
-
- public Long getCreationTime() {
- return creationTime;
- }
-
- public void setCreationTime(Long creationTime) {
- this.creationTime = creationTime;
- }
-
- public Long getModificationTime() {
- return modificationTime;
- }
-
- public void setModificationTime(Long modificationTime) {
- this.modificationTime = modificationTime;
- }
-
- public void setUniqueId(String uniqueId) {
- this.uniqueId = uniqueId;
- }
-
- @Override
- public String getUniqueId() {
- return uniqueId;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getPosX() {
- return posX;
- }
-
- public void setPosX(String posX) {
- this.posX = posX;
- }
-
- public String getPosY() {
- return posY;
- }
-
- public void setPosY(String posY) {
- this.posY = posY;
- }
-
- @Override
- public String toString() {
- return "RequirementImplData [name=" + name + ", uniqueId=" + uniqueId + ", creationTime=" + creationTime
- + ", modificationTime=" + modificationTime + ", posX=" + posX + ", posY=" + posY + "]";
- }
-
+ private String name;
+ private String uniqueId;
+ private Long creationTime;
+ private Long modificationTime;
+ private String posX;
+ private String posY;
+
+ public RequirementImplData() {
+ super(NodeTypeEnum.RequirementImpl);
+ }
+
+ public RequirementImplData(Map<String, Object> properties) {
+ this();
+ this.setName((String) properties.get(GraphPropertiesDictionary.NAME.getProperty()));
+ this.setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
+ this.setCreationTime((Long) properties.get(GraphPropertiesDictionary.CREATION_DATE.getProperty()));
+ this.setModificationTime((Long) properties.get(GraphPropertiesDictionary.LAST_UPDATE_DATE.getProperty()));
+ setPosX((String) properties.get(GraphPropertiesDictionary.POSITION_X.getProperty()));
+ setPosY((String) properties.get(GraphPropertiesDictionary.POSITION_Y.getProperty()));
+ }
+
+ @Override
+ public Map<String, Object> toGraphMap() {
+ Map<String, Object> map = new HashMap<>();
+ addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, uniqueId);
+ addIfExists(map, GraphPropertiesDictionary.NAME, name);
+ addIfExists(map, GraphPropertiesDictionary.CREATION_DATE, creationTime);
+ addIfExists(map, GraphPropertiesDictionary.LAST_UPDATE_DATE, modificationTime);
+ addIfExists(map, GraphPropertiesDictionary.POSITION_X, posX);
+ addIfExists(map, GraphPropertiesDictionary.POSITION_Y, posY);
+ return map;
+ }
+
+ public Long getCreationTime() {
+ return creationTime;
+ }
+
+ public void setCreationTime(Long creationTime) {
+ this.creationTime = creationTime;
+ }
+
+ public Long getModificationTime() {
+ return modificationTime;
+ }
+
+ public void setModificationTime(Long modificationTime) {
+ this.modificationTime = modificationTime;
+ }
+
+ @Override
+ public String getUniqueId() {
+ return uniqueId;
+ }
+
+ public void setUniqueId(String uniqueId) {
+ this.uniqueId = uniqueId;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getPosX() {
+ return posX;
+ }
+
+ public void setPosX(String posX) {
+ this.posX = posX;
+ }
+
+ public String getPosY() {
+ return posY;
+ }
+
+ public void setPosY(String posY) {
+ this.posY = posY;
+ }
+
+ @Override
+ public String toString() {
+ return "RequirementImplData [name=" + name + ", uniqueId=" + uniqueId + ", creationTime=" + creationTime + ", modificationTime="
+ + modificationTime + ", posX=" + posX + ", posY=" + posY + "]";
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ResourceCategoryData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ResourceCategoryData.java
index 95d8b0b6be..c1c5aa664f 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ResourceCategoryData.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ResourceCategoryData.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,56 +17,53 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.resources.data;
+import java.util.Map;
import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import java.util.Map;
-
public class ResourceCategoryData extends CategoryData {
- private String categoryName;
-
- public ResourceCategoryData() {
- super(NodeTypeEnum.ResourceCategory);
- }
+ private String categoryName;
- public ResourceCategoryData(String categoryName, String name) {
- super(name, "", NodeTypeEnum.ResourceCategory);
- this.categoryName = categoryName;
- createUniqueId();
- }
+ public ResourceCategoryData() {
+ super(NodeTypeEnum.ResourceCategory);
+ }
- public ResourceCategoryData(Map<String, Object> properties) {
- super(properties, NodeTypeEnum.ResourceCategory);
- setCategoryName((String) properties.get(GraphPropertiesDictionary.CATEGORY_NAME.getProperty()));
- }
+ public ResourceCategoryData(String categoryName, String name) {
+ super(name, "", NodeTypeEnum.ResourceCategory);
+ this.categoryName = categoryName;
+ createUniqueId();
+ }
- public String getCategoryName() {
- return categoryName;
- }
+ public ResourceCategoryData(Map<String, Object> properties) {
+ super(properties, NodeTypeEnum.ResourceCategory);
+ setCategoryName((String) properties.get(GraphPropertiesDictionary.CATEGORY_NAME.getProperty()));
+ }
- public void setCategoryName(String categoryName) {
- this.categoryName = categoryName;
- }
+ public String getCategoryName() {
+ return categoryName;
+ }
- @Override
- protected void createUniqueId() {
- setUniqueId(getLabel() + "." + this.categoryName + "." + getName());
- }
+ public void setCategoryName(String categoryName) {
+ this.categoryName = categoryName;
+ }
- @Override
- public String toString() {
- return "ResourceCategoryData [categoryName=" + categoryName + "]" + super.toString();
- }
+ @Override
+ protected void createUniqueId() {
+ setUniqueId(getLabel() + "." + this.categoryName + "." + getName());
+ }
- @Override
- public Map<String, Object> toGraphMap() {
- Map<String, Object> graphMap = super.toGraphMap();
- addIfExists(graphMap, GraphPropertiesDictionary.CATEGORY_NAME, categoryName);
- return graphMap;
- }
+ @Override
+ public String toString() {
+ return "ResourceCategoryData [categoryName=" + categoryName + "]" + super.toString();
+ }
+ @Override
+ public Map<String, Object> toGraphMap() {
+ Map<String, Object> graphMap = super.toGraphMap();
+ addIfExists(graphMap, GraphPropertiesDictionary.CATEGORY_NAME, categoryName);
+ return graphMap;
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ResourceMetadataData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ResourceMetadataData.java
index ddb3b9883d..5163b00df4 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ResourceMetadataData.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ResourceMetadataData.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,50 +17,48 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.resources.data;
+import java.util.Map;
import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionaryExtractor;
import org.openecomp.sdc.be.datatypes.components.ComponentMetadataDataDefinition;
import org.openecomp.sdc.be.datatypes.components.ResourceMetadataDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
-
-import java.util.Map;
public class ResourceMetadataData extends ComponentMetadataData {
- public ResourceMetadataData() {
- super(NodeTypeEnum.Resource, new ResourceMetadataDataDefinition());
- }
-
- public ResourceMetadataData(ComponentMetadataDataDefinition metadataDataDefinition) {
- super(NodeTypeEnum.Resource, metadataDataDefinition);
- }
+ public ResourceMetadataData() {
+ super(NodeTypeEnum.Resource, new ResourceMetadataDataDefinition());
+ }
- public ResourceMetadataData(GraphPropertiesDictionaryExtractor extractor) {
- super(NodeTypeEnum.Resource, new ResourceMetadataDataDefinition(), extractor);
- ((ResourceMetadataDataDefinition) metadataDataDefinition).setVendorName(extractor.getVendorName());
- ((ResourceMetadataDataDefinition) metadataDataDefinition).setVendorRelease(extractor.getVendorRelease());
- ((ResourceMetadataDataDefinition) metadataDataDefinition).setResourceType(extractor.getResourceType());
- ((ResourceMetadataDataDefinition) metadataDataDefinition).setAbstract(extractor.isAbstract());
- ((ResourceMetadataDataDefinition) metadataDataDefinition).setCost(extractor.getCost());
- ((ResourceMetadataDataDefinition) metadataDataDefinition).setLicenseType(extractor.getLicenseType());
- ((ResourceMetadataDataDefinition) metadataDataDefinition).setToscaResourceName(extractor.getToscaResourceName());
- }
+ public ResourceMetadataData(ComponentMetadataDataDefinition metadataDataDefinition) {
+ super(NodeTypeEnum.Resource, metadataDataDefinition);
+ }
- @Override
- public Map<String, Object> toGraphMap() {
- Map<String, Object> graphMap = super.toGraphMap();
- addIfExists(graphMap, GraphPropertiesDictionary.VENDOR_NAME, ((ResourceMetadataDataDefinition) metadataDataDefinition).getVendorName());
- addIfExists(graphMap, GraphPropertiesDictionary.VENDOR_RELEASE, ((ResourceMetadataDataDefinition) metadataDataDefinition).getVendorRelease());
- addIfExists(graphMap, GraphPropertiesDictionary.RESOURCE_TYPE, ((ResourceMetadataDataDefinition) metadataDataDefinition).getResourceType().name());
- addIfExists(graphMap, GraphPropertiesDictionary.IS_ABSTRACT, ((ResourceMetadataDataDefinition) metadataDataDefinition).isAbstract());
- addIfExists(graphMap, GraphPropertiesDictionary.COST, ((ResourceMetadataDataDefinition) metadataDataDefinition).getCost());
- addIfExists(graphMap, GraphPropertiesDictionary.LICENSE_TYPE, ((ResourceMetadataDataDefinition) metadataDataDefinition).getLicenseType());
- addIfExists(graphMap, GraphPropertiesDictionary.TOSCA_RESOURCE_NAME, ((ResourceMetadataDataDefinition) metadataDataDefinition).getToscaResourceName());
- return graphMap;
- }
+ public ResourceMetadataData(GraphPropertiesDictionaryExtractor extractor) {
+ super(NodeTypeEnum.Resource, new ResourceMetadataDataDefinition(), extractor);
+ ((ResourceMetadataDataDefinition) metadataDataDefinition).setVendorName(extractor.getVendorName());
+ ((ResourceMetadataDataDefinition) metadataDataDefinition).setVendorRelease(extractor.getVendorRelease());
+ ((ResourceMetadataDataDefinition) metadataDataDefinition).setResourceType(extractor.getResourceType());
+ ((ResourceMetadataDataDefinition) metadataDataDefinition).setAbstract(extractor.isAbstract());
+ ((ResourceMetadataDataDefinition) metadataDataDefinition).setCost(extractor.getCost());
+ ((ResourceMetadataDataDefinition) metadataDataDefinition).setLicenseType(extractor.getLicenseType());
+ ((ResourceMetadataDataDefinition) metadataDataDefinition).setToscaResourceName(extractor.getToscaResourceName());
+ }
+ @Override
+ public Map<String, Object> toGraphMap() {
+ Map<String, Object> graphMap = super.toGraphMap();
+ addIfExists(graphMap, GraphPropertiesDictionary.VENDOR_NAME, ((ResourceMetadataDataDefinition) metadataDataDefinition).getVendorName());
+ addIfExists(graphMap, GraphPropertiesDictionary.VENDOR_RELEASE, ((ResourceMetadataDataDefinition) metadataDataDefinition).getVendorRelease());
+ addIfExists(graphMap, GraphPropertiesDictionary.RESOURCE_TYPE,
+ ((ResourceMetadataDataDefinition) metadataDataDefinition).getResourceType().name());
+ addIfExists(graphMap, GraphPropertiesDictionary.IS_ABSTRACT, ((ResourceMetadataDataDefinition) metadataDataDefinition).isAbstract());
+ addIfExists(graphMap, GraphPropertiesDictionary.COST, ((ResourceMetadataDataDefinition) metadataDataDefinition).getCost());
+ addIfExists(graphMap, GraphPropertiesDictionary.LICENSE_TYPE, ((ResourceMetadataDataDefinition) metadataDataDefinition).getLicenseType());
+ addIfExists(graphMap, GraphPropertiesDictionary.TOSCA_RESOURCE_NAME,
+ ((ResourceMetadataDataDefinition) metadataDataDefinition).getToscaResourceName());
+ return graphMap;
+ }
}
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
index 401d9099e6..6d16afc0a2 100644
--- 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
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.resources.data;
import com.datastax.driver.mapping.annotations.ClusteringColumn;
@@ -25,72 +24,67 @@ import com.datastax.driver.mapping.annotations.Column;
import com.datastax.driver.mapping.annotations.PartitionKey;
import com.datastax.driver.mapping.annotations.Table;
import com.datastax.driver.mapping.annotations.Transient;
+import java.nio.ByteBuffer;
+import java.util.Date;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
-import java.nio.ByteBuffer;
-import java.util.Date;
-
@Getter
@Setter
@NoArgsConstructor
@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")
- @Setter(AccessLevel.NONE)private ByteBuffer payload;
-
- @Column(name = "checksum")
- private String checksum;
- 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;
- }
+ @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")
+ @Setter(AccessLevel.NONE)
+ private ByteBuffer payload;
+ @Column(name = "checksum")
+ private String checksum;
+ 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 void setPayload(ByteBuffer payload) {
- if(payload != null) {
- this.payload = payload.duplicate();
- }
- }
+ 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());
- }
- }
+ @Transient
+ public byte[] getPayloadAsArray() {
+ return payload != null ? payload.array() : null;
+ }
- @Transient
- public byte[] getPayloadAsArray() {
- return payload != null ? payload.array() : null;
- }
+ public void setPayloadAsArray(byte[] payload) {
+ if (payload != null) {
+ this.payload = ByteBuffer.wrap(payload.clone());
+ }
+ }
- @Override
- public String toString() {
- return "SdcSchemaFilesData [sdcReleaseNum=" + sdcReleaseNum + ", timestamp=" + timestamp + ", conformanceLevel="
- + conformanceLevel + ", fileName=" + fileName + ", checksum=" + checksum + "]";
- }
+ @Override
+ public String toString() {
+ return "SdcSchemaFilesData [sdcReleaseNum=" + sdcReleaseNum + ", timestamp=" + timestamp + ", conformanceLevel=" + conformanceLevel
+ + ", fileName=" + fileName + ", checksum=" + checksum + "]";
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ServiceCategoryData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ServiceCategoryData.java
index 3228cbfc23..2efb4e305e 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ServiceCategoryData.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ServiceCategoryData.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,31 +17,28 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.resources.data;
-import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-
import java.util.Map;
+import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
public class ServiceCategoryData extends CategoryData {
- public ServiceCategoryData() {
- super(NodeTypeEnum.ServiceCategory);
- }
-
- public ServiceCategoryData(String categoryName) {
- super(categoryName, "", NodeTypeEnum.ServiceCategory);
- createUniqueId();
- }
+ public ServiceCategoryData() {
+ super(NodeTypeEnum.ServiceCategory);
+ }
- public ServiceCategoryData(Map<String, Object> properties) {
- super(properties, NodeTypeEnum.ServiceCategory);
- }
+ public ServiceCategoryData(String categoryName) {
+ super(categoryName, "", NodeTypeEnum.ServiceCategory);
+ createUniqueId();
+ }
- @Override
- protected void createUniqueId() {
- setUniqueId(getLabel() + "." + getName());
- }
+ public ServiceCategoryData(Map<String, Object> properties) {
+ super(properties, NodeTypeEnum.ServiceCategory);
+ }
+ @Override
+ protected void createUniqueId() {
+ setUniqueId(getLabel() + "." + getName());
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ServiceMetadataData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ServiceMetadataData.java
index 01e4ca4eb4..2de2d79717 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ServiceMetadataData.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/ServiceMetadataData.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,45 +17,41 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.resources.data;
+import java.util.Map;
import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionaryExtractor;
import org.openecomp.sdc.be.datatypes.components.ServiceMetadataDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import java.util.Map;
-
public class ServiceMetadataData extends ComponentMetadataData {
- public ServiceMetadataData() {
- super(NodeTypeEnum.Service, new ServiceMetadataDataDefinition());
- }
-
- public ServiceMetadataData(ServiceMetadataDataDefinition serviceMetadataDataDefinition) {
- super(NodeTypeEnum.Service, serviceMetadataDataDefinition);
- }
-
- public ServiceMetadataData(GraphPropertiesDictionaryExtractor extractor) {
- super(NodeTypeEnum.Service, new ServiceMetadataDataDefinition(), extractor);
- metadataDataDefinition.setProjectCode(extractor.getProjectCode());
- ((ServiceMetadataDataDefinition) metadataDataDefinition).setDistributionStatus(extractor.getDistributionStatus());
- }
-
- @Override
- public String getUniqueIdKey() {
- return GraphPropertiesDictionary.UNIQUE_ID.getProperty();
- }
-
- @Override
- public Map<String, Object> toGraphMap() {
- Map<String, Object> graphMap = super.toGraphMap();
- addIfExists(graphMap, GraphPropertiesDictionary.PROJECT_CODE,
- ((ServiceMetadataDataDefinition) metadataDataDefinition).getProjectCode());
- addIfExists(graphMap, GraphPropertiesDictionary.DISTRIBUTION_STATUS,
- ((ServiceMetadataDataDefinition) metadataDataDefinition).getDistributionStatus());
- return graphMap;
- }
-
+ public ServiceMetadataData() {
+ super(NodeTypeEnum.Service, new ServiceMetadataDataDefinition());
+ }
+
+ public ServiceMetadataData(ServiceMetadataDataDefinition serviceMetadataDataDefinition) {
+ super(NodeTypeEnum.Service, serviceMetadataDataDefinition);
+ }
+
+ public ServiceMetadataData(GraphPropertiesDictionaryExtractor extractor) {
+ super(NodeTypeEnum.Service, new ServiceMetadataDataDefinition(), extractor);
+ metadataDataDefinition.setProjectCode(extractor.getProjectCode());
+ ((ServiceMetadataDataDefinition) metadataDataDefinition).setDistributionStatus(extractor.getDistributionStatus());
+ }
+
+ @Override
+ public String getUniqueIdKey() {
+ return GraphPropertiesDictionary.UNIQUE_ID.getProperty();
+ }
+
+ @Override
+ public Map<String, Object> toGraphMap() {
+ Map<String, Object> graphMap = super.toGraphMap();
+ addIfExists(graphMap, GraphPropertiesDictionary.PROJECT_CODE, ((ServiceMetadataDataDefinition) metadataDataDefinition).getProjectCode());
+ addIfExists(graphMap, GraphPropertiesDictionary.DISTRIBUTION_STATUS,
+ ((ServiceMetadataDataDefinition) metadataDataDefinition).getDistributionStatus());
+ return graphMap;
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/TagData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/TagData.java
index 949aa83c14..f308105dac 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/TagData.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/TagData.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,9 +17,10 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.resources.data;
+import java.util.HashMap;
+import java.util.Map;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
@@ -28,50 +29,46 @@ import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import java.util.HashMap;
-import java.util.Map;
-
@Getter
@Setter
@EqualsAndHashCode
@ToString
public class TagData extends GraphNode {
- private String name;
-
- protected TagData(NodeTypeEnum label) {
- super(label);
- }
+ private String name;
- public TagData(String name) {
- super(NodeTypeEnum.Tag);
- this.name = name;
- }
+ protected TagData(NodeTypeEnum label) {
+ super(label);
+ }
- public TagData() {
- super(NodeTypeEnum.Tag);
- }
+ public TagData(String name) {
+ super(NodeTypeEnum.Tag);
+ this.name = name;
+ }
- public TagData(Map<String, Object> properties) {
- super(NodeTypeEnum.Tag);
- setName((String) properties.get(GraphPropertiesDictionary.NAME.getProperty()));
- }
+ public TagData() {
+ super(NodeTypeEnum.Tag);
+ }
- @Override
- public Map<String, Object> toGraphMap() {
- Map<String, Object> map = new HashMap<>();
- addIfExists(map, GraphPropertiesDictionary.NAME, name);
- return map;
- }
+ public TagData(Map<String, Object> properties) {
+ super(NodeTypeEnum.Tag);
+ setName((String) properties.get(GraphPropertiesDictionary.NAME.getProperty()));
+ }
- @Override
- public String getUniqueIdKey() {
- return GraphPropertiesDictionary.NAME.getProperty();
- }
+ @Override
+ public Map<String, Object> toGraphMap() {
+ Map<String, Object> map = new HashMap<>();
+ addIfExists(map, GraphPropertiesDictionary.NAME, name);
+ return map;
+ }
- @Override
- public String getUniqueId() {
- return name;
- }
+ @Override
+ public String getUniqueIdKey() {
+ return GraphPropertiesDictionary.NAME.getProperty();
+ }
+ @Override
+ public String getUniqueId() {
+ return name;
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/UniqueIdData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/UniqueIdData.java
index fd3b8659a1..cddfeb33d9 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/UniqueIdData.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/UniqueIdData.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,31 +17,28 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.resources.data;
+import java.util.Map;
import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import java.util.Map;
-
public class UniqueIdData extends GraphNode {
- private String uniqueId;
-
- public UniqueIdData(NodeTypeEnum label, String uniqueId) {
- super(label);
- this.uniqueId = uniqueId;
- }
+ private String uniqueId;
- @Override
- public String getUniqueId() {
- return uniqueId;
- }
+ public UniqueIdData(NodeTypeEnum label, String uniqueId) {
+ super(label);
+ this.uniqueId = uniqueId;
+ }
- @Override
- public Map<String, Object> toGraphMap() {
- return null;
- }
+ @Override
+ public String getUniqueId() {
+ return uniqueId;
+ }
+ @Override
+ public Map<String, Object> toGraphMap() {
+ return null;
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/UserData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/UserData.java
index 420bb7ee79..164502fb15 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/UserData.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/UserData.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,212 +17,218 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.resources.data;
+import java.util.Date;
+import java.util.HashMap;
+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.DaoUtils;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
-
public class UserData extends GraphNode {
- private String firstName;
-
- private String lastName;
-
- private String userId;
-
- private String email;
-
- private String role;
-
- private String status;
-
- private Long lastLoginTime;
-
- public UserData(String firstName, String lastName, String userId, String email, String role, String status,
- Long lastLoginTime) {
- super(NodeTypeEnum.User);
- this.firstName = firstName;
- this.lastName = lastName;
- this.userId = userId;
- this.email = email;
- this.role = role;
- this.status = status;
- this.lastLoginTime = lastLoginTime;
- }
-
- public UserData() {
- super(NodeTypeEnum.User);
- }
-
- public UserData(Map<String, Object> properties) {
- super(NodeTypeEnum.User);
-
- setFirstName((String) properties.get("firstName"));
- setLastName((String) properties.get("lastName"));
- setUserId((String) properties.get("userId"));
- setEmail((String) properties.get("email"));
- setRole((String) properties.get("role"));
- setStatus((String) properties.get("status"));
- setLastLoginTime((Long) properties.get("lastLoginTime"));
- }
-
- public String getFirstName() {
- return firstName;
- }
-
- public void setFirstName(String firstName) {
- this.firstName = firstName;
- }
-
- public String getLastName() {
- return lastName;
- }
-
- public void setLastName(String lastName) {
- this.lastName = lastName;
- }
-
- public String getUserId() {
- return userId;
- }
-
- public void setUserId(String userId) {
- this.userId = userId;
- }
-
- public String getEmail() {
- return email;
- }
-
- public void setEmail(String email) {
- this.email = email;
- }
-
- public String getRole() {
- return role;
- }
-
- public void setRole(String role) {
- this.role = role;
- }
-
- // right name?
- public void setLastLoginTime() {
- Date d = new Date();
- this.lastLoginTime = new Long(d.getTime()); // this is in milli-seconds
- // divide by 1000 to get
- // secs?
- }
-
- public void setLastLoginTime(Long time) {
- this.lastLoginTime = time;
- }
-
- public Long getLastLoginTime() {
- return this.lastLoginTime;
- }
-
- @Override
- public String toString() {
- return "UserData [firstName=" + firstName + ", lastName=" + lastName + ", userId=" + userId + ", email=" + email
- + ", role=" + role + ", last Login time=" + lastLoginTime + ", parent: " + super.toString() + "]";
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((userId == null) ? 0 : userId.hashCode());
- result = prime * result + ((email == null) ? 0 : email.hashCode());
- result = prime * result + ((firstName == null) ? 0 : firstName.hashCode());
- result = prime * result + ((lastName == null) ? 0 : lastName.hashCode());
- result = prime * result + ((role == null) ? 0 : role.hashCode());
- result = prime * result + ((lastLoginTime == null) ? 0 : lastLoginTime.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- UserData other = (UserData) obj;
- if (userId == null) {
- if (other.userId != null)
- return false;
- } else if (!userId.equals(other.userId))
- return false;
- if (email == null) {
- if (other.email != null)
- return false;
- } else if (!email.equals(other.email))
- return false;
- if (firstName == null) {
- if (other.firstName != null)
- return false;
- } else if (!firstName.equals(other.firstName))
- return false;
- if (lastName == null) {
- if (other.lastName != null)
- return false;
- } else if (!lastName.equals(other.lastName))
- return false;
- if (role == null) {
- if (other.role != null)
- return false;
- } else if (!role.equals(other.role))
- return false;
- if (lastLoginTime == null) {
- if (other.lastLoginTime != null)
- return false;
- } else if (!lastLoginTime.equals(other.lastLoginTime))
- return false;
- return true;
- }
-
- public String toJson() {
- return DaoUtils.convertToJson(toGraphMap());
- }
-
- @Override
- public Map<String, Object> toGraphMap() {
- Map<String, Object> map = new HashMap<>();
- addIfExists(map, GraphPropertiesDictionary.USERID, userId);
- addIfExists(map, GraphPropertiesDictionary.EMAIL, email);
- addIfExists(map, GraphPropertiesDictionary.FIRST_NAME, firstName);
- addIfExists(map, GraphPropertiesDictionary.LAST_NAME, lastName);
- addIfExists(map, GraphPropertiesDictionary.ROLE, role);
- addIfExists(map, GraphPropertiesDictionary.USER_STATUS, status);
- addIfExists(map, GraphPropertiesDictionary.LAST_LOGIN_TIME, lastLoginTime);
- return map;
- }
-
- @Override
- public String getUniqueIdKey() {
- return GraphPropertiesDictionary.USERID.getProperty();
- }
-
- @Override
- public String getUniqueId() {
- return userId;
- }
-
- public String getStatus() {
- return status;
- }
-
- public void setStatus(String status) {
- this.status = status;
- }
-
+ private String firstName;
+ private String lastName;
+ private String userId;
+ private String email;
+ private String role;
+ private String status;
+ private Long lastLoginTime;
+
+ public UserData(String firstName, String lastName, String userId, String email, String role, String status, Long lastLoginTime) {
+ super(NodeTypeEnum.User);
+ this.firstName = firstName;
+ this.lastName = lastName;
+ this.userId = userId;
+ this.email = email;
+ this.role = role;
+ this.status = status;
+ this.lastLoginTime = lastLoginTime;
+ }
+
+ public UserData() {
+ super(NodeTypeEnum.User);
+ }
+
+ public UserData(Map<String, Object> properties) {
+ super(NodeTypeEnum.User);
+ setFirstName((String) properties.get("firstName"));
+ setLastName((String) properties.get("lastName"));
+ setUserId((String) properties.get("userId"));
+ setEmail((String) properties.get("email"));
+ setRole((String) properties.get("role"));
+ setStatus((String) properties.get("status"));
+ setLastLoginTime((Long) properties.get("lastLoginTime"));
+ }
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ public String getLastName() {
+ return lastName;
+ }
+
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+
+ public String getUserId() {
+ return userId;
+ }
+
+ public void setUserId(String userId) {
+ this.userId = userId;
+ }
+
+ public String getEmail() {
+ return email;
+ }
+
+ public void setEmail(String email) {
+ this.email = email;
+ }
+
+ public String getRole() {
+ return role;
+ }
+
+ public void setRole(String role) {
+ this.role = role;
+ }
+
+ // right name?
+ public void setLastLoginTime() {
+ Date d = new Date();
+ this.lastLoginTime = new Long(d.getTime()); // this is in milli-seconds
+
+ // divide by 1000 to get
+
+ // secs?
+ }
+
+ public Long getLastLoginTime() {
+ return this.lastLoginTime;
+ }
+
+ public void setLastLoginTime(Long time) {
+ this.lastLoginTime = time;
+ }
+
+ @Override
+ public String toString() {
+ return "UserData [firstName=" + firstName + ", lastName=" + lastName + ", userId=" + userId + ", email=" + email + ", role=" + role
+ + ", last Login time=" + lastLoginTime + ", parent: " + super.toString() + "]";
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((userId == null) ? 0 : userId.hashCode());
+ result = prime * result + ((email == null) ? 0 : email.hashCode());
+ result = prime * result + ((firstName == null) ? 0 : firstName.hashCode());
+ result = prime * result + ((lastName == null) ? 0 : lastName.hashCode());
+ result = prime * result + ((role == null) ? 0 : role.hashCode());
+ result = prime * result + ((lastLoginTime == null) ? 0 : lastLoginTime.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ UserData other = (UserData) obj;
+ if (userId == null) {
+ if (other.userId != null) {
+ return false;
+ }
+ } else if (!userId.equals(other.userId)) {
+ return false;
+ }
+ if (email == null) {
+ if (other.email != null) {
+ return false;
+ }
+ } else if (!email.equals(other.email)) {
+ return false;
+ }
+ if (firstName == null) {
+ if (other.firstName != null) {
+ return false;
+ }
+ } else if (!firstName.equals(other.firstName)) {
+ return false;
+ }
+ if (lastName == null) {
+ if (other.lastName != null) {
+ return false;
+ }
+ } else if (!lastName.equals(other.lastName)) {
+ return false;
+ }
+ if (role == null) {
+ if (other.role != null) {
+ return false;
+ }
+ } else if (!role.equals(other.role)) {
+ return false;
+ }
+ if (lastLoginTime == null) {
+ if (other.lastLoginTime != null) {
+ return false;
+ }
+ } else if (!lastLoginTime.equals(other.lastLoginTime)) {
+ return false;
+ }
+ return true;
+ }
+
+ public String toJson() {
+ return DaoUtils.convertToJson(toGraphMap());
+ }
+
+ @Override
+ public Map<String, Object> toGraphMap() {
+ Map<String, Object> map = new HashMap<>();
+ addIfExists(map, GraphPropertiesDictionary.USERID, userId);
+ addIfExists(map, GraphPropertiesDictionary.EMAIL, email);
+ addIfExists(map, GraphPropertiesDictionary.FIRST_NAME, firstName);
+ addIfExists(map, GraphPropertiesDictionary.LAST_NAME, lastName);
+ addIfExists(map, GraphPropertiesDictionary.ROLE, role);
+ addIfExists(map, GraphPropertiesDictionary.USER_STATUS, status);
+ addIfExists(map, GraphPropertiesDictionary.LAST_LOGIN_TIME, lastLoginTime);
+ return map;
+ }
+
+ @Override
+ public String getUniqueIdKey() {
+ return GraphPropertiesDictionary.USERID.getProperty();
+ }
+
+ @Override
+ public String getUniqueId() {
+ return userId;
+ }
+
+ public String getStatus() {
+ return status;
+ }
+
+ public void setStatus(String status) {
+ this.status = status;
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/UserFunctionalMenuData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/UserFunctionalMenuData.java
index 18ff96bbf0..bc4e29cbf8 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/UserFunctionalMenuData.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/UserFunctionalMenuData.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,79 +17,72 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.resources.data;
+import java.util.HashMap;
+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.DaoUtils;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import java.util.HashMap;
-import java.util.Map;
-
public class UserFunctionalMenuData extends GraphNode {
- private String uniqueId;
-
- private String functionalMenu;
-
- public UserFunctionalMenuData(String functionalMenu, String uniqueId) {
- super(NodeTypeEnum.UserFunctionalMenu);
- this.functionalMenu = functionalMenu;
- this.uniqueId = uniqueId;
- }
-
- public UserFunctionalMenuData() {
- super(NodeTypeEnum.UserFunctionalMenu);
- }
-
- public UserFunctionalMenuData(Map<String, Object> properties) {
- super(NodeTypeEnum.UserFunctionalMenu);
-
- setFunctionalMenu((String) properties.get(GraphPropertiesDictionary.FUNCTIONAL_MENU.getProperty()));
- setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
- }
-
- public String getFunctionalMenu() {
- return functionalMenu;
- }
-
- public void setFunctionalMenu(String functionalMenu) {
- this.functionalMenu = functionalMenu;
- }
-
- public void setUniqueId(String uniqueId) {
- this.uniqueId = uniqueId;
- }
-
- @Override
- public String toString() {
- return "UserFunctionalMenuData [uniqueId=" + uniqueId + ", functionalMenu=" + functionalMenu + "]";
- }
-
- public String toJson() {
- return DaoUtils.convertToJson(toGraphMap());
- }
-
- @Override
- public Map<String, Object> toGraphMap() {
- Map<String, Object> map = new HashMap<>();
-
- addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, uniqueId);
- addIfExists(map, GraphPropertiesDictionary.FUNCTIONAL_MENU, functionalMenu);
-
- return map;
- }
-
- @Override
- public String getUniqueIdKey() {
- return GraphPropertiesDictionary.UNIQUE_ID.getProperty();
- }
-
- @Override
- public String getUniqueId() {
- return uniqueId;
- }
-
+ private String uniqueId;
+ private String functionalMenu;
+
+ public UserFunctionalMenuData(String functionalMenu, String uniqueId) {
+ super(NodeTypeEnum.UserFunctionalMenu);
+ this.functionalMenu = functionalMenu;
+ this.uniqueId = uniqueId;
+ }
+
+ public UserFunctionalMenuData() {
+ super(NodeTypeEnum.UserFunctionalMenu);
+ }
+
+ public UserFunctionalMenuData(Map<String, Object> properties) {
+ super(NodeTypeEnum.UserFunctionalMenu);
+ setFunctionalMenu((String) properties.get(GraphPropertiesDictionary.FUNCTIONAL_MENU.getProperty()));
+ setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
+ }
+
+ public String getFunctionalMenu() {
+ return functionalMenu;
+ }
+
+ public void setFunctionalMenu(String functionalMenu) {
+ this.functionalMenu = functionalMenu;
+ }
+
+ @Override
+ public String toString() {
+ return "UserFunctionalMenuData [uniqueId=" + uniqueId + ", functionalMenu=" + functionalMenu + "]";
+ }
+
+ public String toJson() {
+ return DaoUtils.convertToJson(toGraphMap());
+ }
+
+ @Override
+ public Map<String, Object> toGraphMap() {
+ Map<String, Object> map = new HashMap<>();
+ addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, uniqueId);
+ addIfExists(map, GraphPropertiesDictionary.FUNCTIONAL_MENU, functionalMenu);
+ return map;
+ }
+
+ @Override
+ public String getUniqueIdKey() {
+ return GraphPropertiesDictionary.UNIQUE_ID.getProperty();
+ }
+
+ @Override
+ public String getUniqueId() {
+ return uniqueId;
+ }
+
+ public void setUniqueId(String uniqueId) {
+ this.uniqueId = uniqueId;
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/AuditingActionEnum.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/AuditingActionEnum.java
index 9f176d0c7c..7c9caf91ef 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/AuditingActionEnum.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/AuditingActionEnum.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,14 +17,13 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.resources.data.auditing;
import org.openecomp.sdc.common.log.wrappers.Logger;
//TODO rename to AuditAction
public enum AuditingActionEnum {
-
+ // @formatter:off
// User administration
ADD_USER("AddUser", AuditingTypesConstants.USER_ADMIN_EVENT_TYPE),
UPDATE_USER("UpdateUser", AuditingTypesConstants.USER_ADMIN_EVENT_TYPE),
@@ -52,7 +51,7 @@ public enum AuditingActionEnum {
ARTIFACT_UPLOAD_BY_API("ArtifactUploadByAPI", AuditingTypesConstants.EXTERNAL_API_EVENT_TYPE),
ARTIFACT_UPDATE_BY_API("ArtifactUpdateByAPI", AuditingTypesConstants.EXTERNAL_API_EVENT_TYPE),
ARTIFACT_DELETE_BY_API("ArtifactDeleteByAPI", AuditingTypesConstants.EXTERNAL_API_EVENT_TYPE),
- DOWNLOAD_ARTIFACT("DownloadArtifact",AuditingTypesConstants.EXTERNAL_API_EVENT_TYPE),
+ DOWNLOAD_ARTIFACT("DownloadArtifact", AuditingTypesConstants.EXTERNAL_API_EVENT_TYPE),
CREATE_RESOURCE_BY_API("CreateResourceByAPI", AuditingTypesConstants.EXTERNAL_API_EVENT_TYPE),
CREATE_SERVICE_BY_API("CreateServiceByAPI", AuditingTypesConstants.EXTERNAL_API_EVENT_TYPE),
CHANGE_LIFECYCLE_BY_API("ChangeLifecycleByAPI", AuditingTypesConstants.EXTERNAL_API_EVENT_TYPE),
@@ -63,7 +62,7 @@ public enum AuditingActionEnum {
ARTIFACT_DELETE("ArtifactDelete", AuditingTypesConstants.RESOURCE_ADMIN_EVENT_TYPE),
ARTIFACT_DOWNLOAD("ArtifactDownload", AuditingTypesConstants.RESOURCE_ADMIN_EVENT_TYPE),
- //Automated upgrade
+ //Automated upgrade
UPDATE_SERVICE_REFERENCE("UpdateServiceReference", AuditingTypesConstants.RESOURCE_ADMIN_EVENT_TYPE),
VF_UPGRADE_SERVICES("VfUpgradeServices", AuditingTypesConstants.RESOURCE_ADMIN_EVENT_TYPE),
@@ -83,7 +82,7 @@ public enum AuditingActionEnum {
DISTRIBUTION_UN_REGISTER("DUnRegister", AuditingTypesConstants.DISTRIBUTION_ENGINE_EVENT_TYPE),
DISTRIBUTION_NOTIFY("DNotify", AuditingTypesConstants.DISTRIBUTION_NOTIFICATION_EVENT_TYPE),
DISTRIBUTION_STATUS("DStatus", AuditingTypesConstants.DISTRIBUTION_STATUS_EVENT_TYPE),
- DISTRIBUTION_DEPLOY("DResult",AuditingTypesConstants.DISTRIBUTION_DEPLOY_EVENT_TYPE),
+ DISTRIBUTION_DEPLOY("DResult", AuditingTypesConstants.DISTRIBUTION_DEPLOY_EVENT_TYPE),
GET_UEB_CLUSTER("GetUebCluster", AuditingTypesConstants.DISTRIBUTION_GET_UEB_CLUSTER_EVENT_TYPE),
GET_VALID_ARTIFACT_TYPES("GetValidArtifactTypes", AuditingTypesConstants.DISTRIBUTION_GET_VALID_ARTIFACT_TYPES_EVENT_TYPE),
@@ -118,26 +117,17 @@ public enum AuditingActionEnum {
Import_Replace_Service("ImportReplaceService", AuditingTypesConstants.EXTERNAL_API_EVENT_TYPE),
Replace_VNF("ReplaceVNF", AuditingTypesConstants.EXTERNAL_API_EVENT_TYPE),
Import_Replace_Resource("ReplaceVNF", AuditingTypesConstants.EXTERNAL_API_EVENT_TYPE);
-
- private final String name;
- private final String auditingEsType;
-
+ // @formatter:on
private static Logger log = Logger.getLogger(AuditingActionEnum.class.getName());
+ private final String name;
+ private final String auditingEsType;
AuditingActionEnum(String name, String auditingEsType) {
this.name = name;
this.auditingEsType = auditingEsType;
}
- public String getName() {
- return name;
- }
-
- public String getAuditingEsType() {
- return auditingEsType;
- }
-
public static AuditingActionEnum fromName(String name) {
AuditingActionEnum res = null;
AuditingActionEnum[] values = values();
@@ -152,4 +142,12 @@ public enum AuditingActionEnum {
}
return res;
}
+
+ public String getName() {
+ return name;
+ }
+
+ public String getAuditingEsType() {
+ return auditingEsType;
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/AuditingGenericEvent.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/AuditingGenericEvent.java
index f37f9b9d01..2c9ebe74f6 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/AuditingGenericEvent.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/AuditingGenericEvent.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,23 +17,21 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.resources.data.auditing;
-
-import org.openecomp.sdc.common.datastructure.AuditingFieldsKey;
import com.datastax.driver.mapping.annotations.Transient;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.TimeZone;
+import org.openecomp.sdc.common.datastructure.AuditingFieldsKey;
public class AuditingGenericEvent {
+
+ protected static String dateFormatPattern = "yyyy-MM-dd HH:mm:ss.SSS z";
@Transient
protected SimpleDateFormat simpleDateFormat;
- protected static String dateFormatPattern = "yyyy-MM-dd HH:mm:ss.SSS z";
-
@Transient
protected String requestId;
@Transient
@@ -49,14 +47,12 @@ public class AuditingGenericEvent {
@Transient
protected Map<String, Object> fields = new HashMap<>();
-
public AuditingGenericEvent() {
super();
simpleDateFormat = new SimpleDateFormat(dateFormatPattern);
simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
this.timestamp = simpleDateFormat.format(new Date());
fields.put(AuditingFieldsKey.AUDIT_TIMESTAMP.getDisplayName(), this.timestamp);
-
}
public String getRequestId() {
@@ -65,7 +61,6 @@ public class AuditingGenericEvent {
public void setRequestId(String requestId) {
this.requestId = requestId;
-
}
public String getServiceInstanceId() {
@@ -101,14 +96,12 @@ public class AuditingGenericEvent {
}
public void fillFields() {
-
}
protected Date parseDateFromString(final String timestamp) {
try {
return simpleDateFormat.parse(timestamp);
- }
- catch (Exception e) {
+ } catch (Exception e) {
return new Date();
}
}
@@ -128,6 +121,4 @@ public class AuditingGenericEvent {
public void setFields(Map<String, Object> fields) {
this.fields = fields;
}
-
-
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/AuditingGetUebClusterEvent.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/AuditingGetUebClusterEvent.java
index 17a794691d..31d6fbcfda 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/AuditingGetUebClusterEvent.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/AuditingGetUebClusterEvent.java
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.resources.data.auditing;
import com.datastax.driver.core.utils.UUIDs;
@@ -25,17 +24,16 @@ 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;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.TimeZone;
+import java.util.UUID;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;
import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData;
import org.openecomp.sdc.common.datastructure.AuditingFieldsKey;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.TimeZone;
-import java.util.UUID;
-
@Getter
@Setter
@Table(keyspace = AuditingTypesConstants.AUDIT_KEYSPACE, name = AuditingTypesConstants.DISTRIBUTION_GET_UEB_CLUSTER_EVENT_TYPE)
@@ -43,23 +41,19 @@ public class AuditingGetUebClusterEvent extends AuditingGenericEvent {
@PartitionKey
protected UUID timebaseduuid;
-
@ClusteringColumn
- @Setter(AccessLevel.NONE)protected Date timestamp1;
-
+ @Setter(AccessLevel.NONE)
+ protected Date timestamp1;
@Column(name = "request_id")
protected String requestId;
-
@Column(name = "service_instance_id")
protected String serviceInstanceId;
@Column
protected String action;
@Column
protected String status;
-
@Column(name = "description")
protected String desc;
-
@Column(name = "consumer_id")
private String consumerId;
@@ -82,6 +76,7 @@ public class AuditingGetUebClusterEvent extends AuditingGenericEvent {
public void setTimestamp1(String timestamp) {
this.timestamp1 = parseDateFromString(timestamp);
}
+
public void setTimestamp1(Date timestamp) {
this.timestamp1 = timestamp;
}
@@ -89,7 +84,6 @@ public class AuditingGetUebClusterEvent extends AuditingGenericEvent {
@Override
public void fillFields() {
fields.put(AuditingFieldsKey.AUDIT_REQUEST_ID.getDisplayName(), getRequestId());
-
fields.put(AuditingFieldsKey.AUDIT_SERVICE_INSTANCE_ID.getDisplayName(), getServiceInstanceId());
fields.put(AuditingFieldsKey.AUDIT_ACTION.getDisplayName(), getAction());
fields.put(AuditingFieldsKey.AUDIT_STATUS.getDisplayName(), getStatus());
@@ -98,14 +92,12 @@ public class AuditingGetUebClusterEvent extends AuditingGenericEvent {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateFormatPattern);
simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
fields.put(AuditingFieldsKey.AUDIT_TIMESTAMP.getDisplayName(), simpleDateFormat.format(timestamp1));
-
}
@Override
public String toString() {
- return "AuditingGetUebClusterEvent [timebaseduuid=" + timebaseduuid + ", timestamp1=" + timestamp1
- + ", requestId=" + requestId + ", serviceInstanceId=" + serviceInstanceId + ", action=" + action
- + ", status=" + status + ", desc=" + desc + ", consumerId=" + consumerId + "]";
+ return "AuditingGetUebClusterEvent [timebaseduuid=" + timebaseduuid + ", timestamp1=" + timestamp1 + ", requestId=" + requestId
+ + ", serviceInstanceId=" + serviceInstanceId + ", action=" + action + ", status=" + status + ", desc=" + desc + ", consumerId="
+ + consumerId + "]";
}
-
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/AuditingTypesConstants.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/AuditingTypesConstants.java
index 2716621cae..0d0cfe9111 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/AuditingTypesConstants.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/AuditingTypesConstants.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.resources.data.auditing;
public interface AuditingTypesConstants {
@@ -27,12 +26,10 @@ public interface AuditingTypesConstants {
String AUDIT_KEYSPACE = "sdcaudit";
String COMPONENT_KEYSPACE = "sdccomponent";
String janusGraph_KEYSPACE = "janusgraph";
-
String USER_ADMIN_EVENT_TYPE = "useradminevent";
String USER_ACCESS_EVENT_TYPE = "useraccessevent";
String RESOURCE_ADMIN_EVENT_TYPE = "resourceadminevent";
String DISTRIBUTION_DOWNLOAD_EVENT_TYPE = "distributiondownloadevent";
-
String DISTRIBUTION_ENGINE_EVENT_TYPE = "distributionengineevent";
String DISTRIBUTION_NOTIFICATION_EVENT_TYPE = "distributionnotificationevent";
String DISTRIBUTION_STATUS_EVENT_TYPE = "distributionstatusevent";
@@ -40,7 +37,6 @@ public interface AuditingTypesConstants {
String DISTRIBUTION_GET_UEB_CLUSTER_EVENT_TYPE = "auditinggetuebclusterevent";
//TODO remove if not in use
String DISTRIBUTION_GET_VALID_ARTIFACT_TYPES_EVENT_TYPE = "auditinggetvalidartifacttypesevent";
-
String ECOMP_OPERATIONAL_ENV_EVENT_TYPE = "ecompopenvironmentevent";
String AUTH_EVENT_TYPE = "authevent";
String CONSUMER_EVENT_TYPE = "consumerevent";
@@ -50,5 +46,4 @@ public interface AuditingTypesConstants {
String EXTERNAL_API_EVENT_TYPE = "externalapievent";
String ENVIRONMENT_ENGINE_EVENT_TYPE = "environmentengineevent";
String FEATURE_TOGGLE_STATE = "featuretogglestate";
-
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/AuthEvent.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/AuthEvent.java
index 0133a73e3d..1f57710c25 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/AuthEvent.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/AuthEvent.java
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.resources.data.auditing;
import com.datastax.driver.core.utils.UUIDs;
@@ -25,15 +24,14 @@ 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;
-import lombok.Getter;
-import lombok.Setter;
-import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData;
-import org.openecomp.sdc.common.datastructure.AuditingFieldsKey;
-
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;
import java.util.UUID;
+import lombok.Getter;
+import lombok.Setter;
+import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData;
+import org.openecomp.sdc.common.datastructure.AuditingFieldsKey;
@Getter
@Setter
@@ -42,30 +40,24 @@ public class AuthEvent extends AuditingGenericEvent {
@PartitionKey
protected UUID timebaseduuid;
-
@ClusteringColumn
protected Date timestamp1;
-
- @Column
- private String url;
- @Column
- private String user;
-
- @Column(name = "auth_status")
- private String authStatus;
-
- @Column
- private String realm;
@Column
protected String action;
@Column
protected String status;
-
@Column(name = "description")
protected String desc;
-
@Column(name = "request_id")
protected String requestId;
+ @Column
+ private String url;
+ @Column
+ private String user;
+ @Column(name = "auth_status")
+ private String authStatus;
+ @Column
+ private String realm;
public AuthEvent(String action, CommonAuditData commonAuditData, String user, String authUrl, String realm, String authStatus) {
this();
@@ -96,7 +88,6 @@ public class AuthEvent extends AuditingGenericEvent {
@Override
public void fillFields() {
fields.put(AuditingFieldsKey.AUDIT_AUTH_URL.getDisplayName(), getUrl());
-
fields.put(AuditingFieldsKey.AUDIT_AUTH_USER.getDisplayName(), getUser());
fields.put(AuditingFieldsKey.AUDIT_AUTH_STATUS.getDisplayName(), getAuthStatus());
fields.put(AuditingFieldsKey.AUDIT_AUTH_REALM.getDisplayName(), getRealm());
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/CategoryEvent.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/CategoryEvent.java
index bb3603de88..d1d31ca547 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/CategoryEvent.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/CategoryEvent.java
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.resources.data.auditing;
import com.datastax.driver.core.utils.UUIDs;
@@ -25,15 +24,14 @@ 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;
-import lombok.Getter;
-import lombok.Setter;
-import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData;
-import org.openecomp.sdc.common.datastructure.AuditingFieldsKey;
-
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;
import java.util.UUID;
+import lombok.Getter;
+import lombok.Setter;
+import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData;
+import org.openecomp.sdc.common.datastructure.AuditingFieldsKey;
@Getter
@Setter
@@ -42,35 +40,26 @@ public class CategoryEvent extends AuditingGenericEvent {
@PartitionKey
protected UUID timebaseduuid;
-
@ClusteringColumn
protected Date timestamp1;
-
@Column
String action;
@Column
String status;
@Column(name = "description")
String desc;
-
@Column(name = "category_name")
String categoryName;
-
@Column(name = "sub_category_name")
String subCategoryName;
-
@Column(name = "grouping_name")
String groupingName;
-
@Column
String modifier;
-
@Column(name = "service_instance_id")
String serviceInstanceId;
-
@Column(name = "resource_type")
String resourceType;
-
@Column(name = "request_id")
String requestId;
@@ -105,7 +94,6 @@ public class CategoryEvent extends AuditingGenericEvent {
@Override
public void fillFields() {
-
fields.put(AuditingFieldsKey.AUDIT_ACTION.getDisplayName(), getAction());
fields.put(AuditingFieldsKey.AUDIT_STATUS.getDisplayName(), getStatus());
fields.put(AuditingFieldsKey.AUDIT_DESC.getDisplayName(), getDesc());
@@ -119,6 +107,5 @@ public class CategoryEvent extends AuditingGenericEvent {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateFormatPattern);
simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
fields.put(AuditingFieldsKey.AUDIT_TIMESTAMP.getDisplayName(), simpleDateFormat.format(timestamp1));
-
}
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/ConsumerEvent.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/ConsumerEvent.java
index 77bac06d51..02a2bd99d2 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/ConsumerEvent.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/ConsumerEvent.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.resources.data.auditing;
import com.datastax.driver.core.utils.UUIDs;
@@ -25,18 +24,16 @@ 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;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.TimeZone;
+import java.util.UUID;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
-import org.apache.tinkerpop.shaded.jackson.annotation.JsonSetter;
import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData;
import org.openecomp.sdc.common.datastructure.AuditingFieldsKey;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.TimeZone;
-import java.util.UUID;
-
@Getter
@Setter
@ToString
@@ -45,23 +42,18 @@ public class ConsumerEvent extends AuditingGenericEvent {
@PartitionKey
protected UUID timebaseduuid;
-
@ClusteringColumn
protected Date timestamp1;
-
@Column(name = "request_id")
protected String requestId;
@Column
protected String action;
@Column
protected String status;
-
@Column(name = "description")
protected String desc;
-
@Column
private String modifier;
-
@Column(name = "ecomp_user")
private String ecompUser;
@@ -92,7 +84,6 @@ public class ConsumerEvent extends AuditingGenericEvent {
@Override
public void fillFields() {
fields.put(AuditingFieldsKey.AUDIT_REQUEST_ID.getDisplayName(), getRequestId());
-
fields.put(AuditingFieldsKey.AUDIT_ACTION.getDisplayName(), getAction());
fields.put(AuditingFieldsKey.AUDIT_STATUS.getDisplayName(), getStatus());
fields.put(AuditingFieldsKey.AUDIT_DESC.getDisplayName(), getDesc());
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/DistributionDeployEvent.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/DistributionDeployEvent.java
index afa3f6b4e0..aca939517f 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/DistributionDeployEvent.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/DistributionDeployEvent.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.resources.data.auditing;
import com.datastax.driver.core.utils.UUIDs;
@@ -25,6 +24,10 @@ 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;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.TimeZone;
+import java.util.UUID;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
@@ -32,11 +35,6 @@ import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData;
import org.openecomp.sdc.be.resources.data.auditing.model.ResourceCommonInfo;
import org.openecomp.sdc.common.datastructure.AuditingFieldsKey;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.TimeZone;
-import java.util.UUID;
-
@Getter
@Setter
@ToString
@@ -45,35 +43,26 @@ public class DistributionDeployEvent extends AuditingGenericEvent {
@PartitionKey
protected UUID timebaseduuid;
-
@ClusteringColumn
protected Date timestamp1;
-
@Column(name = "request_id")
protected String requestId;
-
@Column(name = "service_instance_id")
protected String serviceInstanceId;
@Column
protected String action;
@Column
protected String status;
-
@Column(name = "description")
protected String desc;
-
@Column(name = "resource_name")
private String resourceName;
-
@Column(name = "resource_type")
private String resourceType;
-
@Column(name = "curr_version")
private String currVersion;
-
@Column
private String modifier;
-
@Column
private String did;
@@ -112,7 +101,6 @@ public class DistributionDeployEvent extends AuditingGenericEvent {
fields.put(AuditingFieldsKey.AUDIT_ACTION.getDisplayName(), getAction());
fields.put(AuditingFieldsKey.AUDIT_STATUS.getDisplayName(), getStatus());
fields.put(AuditingFieldsKey.AUDIT_DESC.getDisplayName(), getDesc());
-
fields.put(AuditingFieldsKey.AUDIT_DISTRIBUTION_ID.getDisplayName(), getDid());
fields.put(AuditingFieldsKey.AUDIT_MODIFIER_UID.getDisplayName(), getModifier());
fields.put(AuditingFieldsKey.AUDIT_RESOURCE_CURR_VERSION.getDisplayName(), getCurrVersion());
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/DistributionDownloadEvent.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/DistributionDownloadEvent.java
index 84554493d9..5d683ac71d 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/DistributionDownloadEvent.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/DistributionDownloadEvent.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.resources.data.auditing;
import com.datastax.driver.core.utils.UUIDs;
@@ -25,6 +24,10 @@ 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;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.TimeZone;
+import java.util.UUID;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
@@ -32,11 +35,6 @@ import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData;
import org.openecomp.sdc.be.resources.data.auditing.model.DistributionData;
import org.openecomp.sdc.common.datastructure.AuditingFieldsKey;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.TimeZone;
-import java.util.UUID;
-
@Getter
@Setter
@ToString
@@ -45,27 +43,20 @@ public class DistributionDownloadEvent extends AuditingGenericEvent {
@PartitionKey
protected UUID timebaseduuid;
-
@ClusteringColumn
protected Date timestamp1;
-
@Column(name = "request_id")
protected String requestId;
-
@Column(name = "service_instance_id")
protected String serviceInstanceId;
-
@Column
protected String action;
@Column
protected String status;
-
@Column(name = "description")
protected String desc;
-
@Column(name = "consumer_id")
private String consumerId;
-
@Column(name = "resource_url")
private String resourceUrl;
@@ -101,7 +92,6 @@ public class DistributionDownloadEvent extends AuditingGenericEvent {
fields.put(AuditingFieldsKey.AUDIT_ACTION.getDisplayName(), getAction());
fields.put(AuditingFieldsKey.AUDIT_STATUS.getDisplayName(), getStatus());
fields.put(AuditingFieldsKey.AUDIT_DESC.getDisplayName(), getDesc());
-
fields.put(AuditingFieldsKey.AUDIT_DISTRIBUTION_CONSUMER_ID.getDisplayName(), getConsumerId());
fields.put(AuditingFieldsKey.AUDIT_DISTRIBUTION_RESOURCE_URL.getDisplayName(), getResourceUrl());
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateFormatPattern);
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/DistributionEngineEvent.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/DistributionEngineEvent.java
index 3bc3582aaf..c61a1a9370 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/DistributionEngineEvent.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/DistributionEngineEvent.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.resources.data.auditing;
import com.datastax.driver.core.utils.UUIDs;
@@ -25,6 +24,10 @@ 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;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.TimeZone;
+import java.util.UUID;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
@@ -32,11 +35,6 @@ import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData;
import org.openecomp.sdc.be.resources.data.auditing.model.DistributionTopicData;
import org.openecomp.sdc.common.datastructure.AuditingFieldsKey;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.TimeZone;
-import java.util.UUID;
-
@Getter
@Setter
@ToString
@@ -45,39 +43,28 @@ public class DistributionEngineEvent extends AuditingGenericEvent {
@PartitionKey
protected UUID timebaseduuid;
-
@ClusteringColumn
protected Date timestamp1;
-
@Column(name = "request_id")
protected String requestId;
-
@Column(name = "service_instance_id")
protected String serviceInstanceId;
-
@Column
protected String action;
@Column
protected String status;
-
@Column(name = "description")
protected String desc;
-
@Column(name = "consumer_id")
private String consumerId;
-
@Column(name = "DSTATUS_TOPIC")
private String dstatusTopic;
-
@Column(name = "DNOTIF_TOPIC")
private String dnotifTopic;
-
@Column(name = "d_env")
private String environmentName;
-
@Column
private String role;
-
@Column(name = "api_key")
private String apiKey;
@@ -88,7 +75,7 @@ public class DistributionEngineEvent extends AuditingGenericEvent {
}
public DistributionEngineEvent(String action, CommonAuditData commonAuditData, String consumerId, DistributionTopicData distributionTopicData,
- String apiKey, String envName, String role) {
+ String apiKey, String envName, String role) {
this();
this.action = action;
this.requestId = commonAuditData.getRequestId();
@@ -115,19 +102,16 @@ public class DistributionEngineEvent extends AuditingGenericEvent {
@Override
public void fillFields() {
fields.put(AuditingFieldsKey.AUDIT_REQUEST_ID.getDisplayName(), getRequestId());
-
fields.put(AuditingFieldsKey.AUDIT_SERVICE_INSTANCE_ID.getDisplayName(), getServiceInstanceId());
fields.put(AuditingFieldsKey.AUDIT_ACTION.getDisplayName(), getAction());
fields.put(AuditingFieldsKey.AUDIT_STATUS.getDisplayName(), getStatus());
fields.put(AuditingFieldsKey.AUDIT_DESC.getDisplayName(), getDesc());
-
fields.put(AuditingFieldsKey.AUDIT_DISTRIBUTION_CONSUMER_ID.getDisplayName(), getConsumerId());
fields.put(AuditingFieldsKey.AUDIT_DISTRIBUTION_API_KEY.getDisplayName(), getApiKey());
fields.put(AuditingFieldsKey.AUDIT_DISTRIBUTION_ENVRIONMENT_NAME.getDisplayName(), getEnvironmentName());
fields.put(AuditingFieldsKey.AUDIT_DISTRIBUTION_ROLE.getDisplayName(), getRole());
fields.put(AuditingFieldsKey.AUDIT_DISTRIBUTION_STATUS_TOPIC_NAME.getDisplayName(), getDstatusTopic());
- fields.put(AuditingFieldsKey.AUDIT_DISTRIBUTION_NOTIFICATION_TOPIC_NAME.getDisplayName(),
- getDnotifTopic());
+ fields.put(AuditingFieldsKey.AUDIT_DISTRIBUTION_NOTIFICATION_TOPIC_NAME.getDisplayName(), getDnotifTopic());
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateFormatPattern);
simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
fields.put(AuditingFieldsKey.AUDIT_TIMESTAMP.getDisplayName(), simpleDateFormat.format(timestamp1));
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/DistributionNotificationEvent.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/DistributionNotificationEvent.java
index 174dea663d..a487efb885 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/DistributionNotificationEvent.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/DistributionNotificationEvent.java
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.resources.data.auditing;
import com.datastax.driver.core.utils.UUIDs;
@@ -25,6 +24,10 @@ 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;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.TimeZone;
+import java.util.UUID;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;
@@ -34,11 +37,6 @@ import org.openecomp.sdc.be.resources.data.auditing.model.ResourceCommonInfo;
import org.openecomp.sdc.be.resources.data.auditing.model.ResourceVersionInfo;
import org.openecomp.sdc.common.datastructure.AuditingFieldsKey;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.TimeZone;
-import java.util.UUID;
-
@Getter
@Setter
@Table(keyspace = AuditingTypesConstants.AUDIT_KEYSPACE, name = AuditingTypesConstants.DISTRIBUTION_NOTIFICATION_EVENT_TYPE)
@@ -46,50 +44,37 @@ public class DistributionNotificationEvent extends AuditingGenericEvent {
@PartitionKey
protected UUID timebaseduuid;
-
@ClusteringColumn
- @Setter(AccessLevel.NONE)protected Date timestamp1;
-
+ @Setter(AccessLevel.NONE)
+ protected Date timestamp1;
@Column(name = "request_id")
protected String requestId;
-
@Column(name = "service_instance_id")
protected String serviceInstanceId;
@Column
protected String action;
@Column
protected String status;
-
@Column(name = "description")
protected String desc;
-
@Column(name = "resource_name")
private String resourceName;
-
@Column(name = "resource_type")
private String resourceType;
-
@Column(name = "curr_version")
private String currVersion;
-
@Column
private String modifier;
-
@Column(name = "curr_state")
private String currState;
-
@Column(name = "topic_name")
private String topicName;
-
@Column
private String did;
-
@Column(name = "env_id")
private String envId;
-
@Column(name = "vnf_workload_context")
private String vnfWorkloadContext;
-
@Column(name = "tenant")
private String tenant;
@@ -99,8 +84,7 @@ public class DistributionNotificationEvent extends AuditingGenericEvent {
}
public DistributionNotificationEvent(String action, CommonAuditData commonAuditData, ResourceCommonInfo resourceCommonInfo,
- ResourceVersionInfo resourceVersionInfo,
- String did, String modifier, String topicName,
+ ResourceVersionInfo resourceVersionInfo, String did, String modifier, String topicName,
OperationalEnvAuditData opEnvFields) {
this();
this.action = action;
@@ -118,7 +102,6 @@ public class DistributionNotificationEvent extends AuditingGenericEvent {
this.envId = opEnvFields.getEnvId();
this.vnfWorkloadContext = opEnvFields.getVnfWorkloadContext();
this.tenant = opEnvFields.getTenant();
-
}
public void setTimestamp1(String timestamp) {
@@ -132,7 +115,6 @@ public class DistributionNotificationEvent extends AuditingGenericEvent {
@Override
public void fillFields() {
fields.put(AuditingFieldsKey.AUDIT_REQUEST_ID.getDisplayName(), getRequestId());
-
fields.put(AuditingFieldsKey.AUDIT_SERVICE_INSTANCE_ID.getDisplayName(), getServiceInstanceId());
fields.put(AuditingFieldsKey.AUDIT_ACTION.getDisplayName(), getAction());
fields.put(AuditingFieldsKey.AUDIT_STATUS.getDisplayName(), getStatus());
@@ -140,7 +122,6 @@ public class DistributionNotificationEvent extends AuditingGenericEvent {
fields.put(AuditingFieldsKey.AUDIT_DISTRIBUTION_ENVIRONMENT_ID.getDisplayName(), getEnvId());
fields.put(AuditingFieldsKey.AUDIT_DISTRIBUTION_VNF_WORKLOAD_CONTEXT.getDisplayName(), getVnfWorkloadContext());
fields.put(AuditingFieldsKey.AUDIT_DISTRIBUTION_TENANT.getDisplayName(), getTenant());
-
fields.put(AuditingFieldsKey.AUDIT_DISTRIBUTION_ID.getDisplayName(), getDid());
fields.put(AuditingFieldsKey.AUDIT_MODIFIER_UID.getDisplayName(), getModifier());
fields.put(AuditingFieldsKey.AUDIT_RESOURCE_CURR_STATE.getDisplayName(), getCurrState());
@@ -155,12 +136,10 @@ public class DistributionNotificationEvent extends AuditingGenericEvent {
@Override
public String toString() {
- return "DistributionNotificationEvent [timebaseduuid=" + timebaseduuid + ", timestamp1=" + timestamp1
- + ", requestId=" + requestId + ", serviceInstanceId=" + serviceInstanceId + ", action=" + action
- + ", status=" + status + ", desc=" + desc + ", resourceName=" + resourceName + ", resourceType="
- + resourceType + ", currVersion=" + currVersion + ", modifier=" + modifier + ", currState=" + currState
- + ", topicName=" + topicName + ", did=" + did
- + ", envId=" + envId + ", vnfWorkloadContext=" + vnfWorkloadContext + ", tenant=" + tenant + "]";
+ return "DistributionNotificationEvent [timebaseduuid=" + timebaseduuid + ", timestamp1=" + timestamp1 + ", requestId=" + requestId
+ + ", serviceInstanceId=" + serviceInstanceId + ", action=" + action + ", status=" + status + ", desc=" + desc + ", resourceName="
+ + resourceName + ", resourceType=" + resourceType + ", currVersion=" + currVersion + ", modifier=" + modifier + ", currState=" + currState
+ + ", topicName=" + topicName + ", did=" + did + ", envId=" + envId + ", vnfWorkloadContext=" + vnfWorkloadContext + ", tenant=" + tenant
+ + "]";
}
-
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/DistributionStatusEvent.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/DistributionStatusEvent.java
index 3c82a33f33..50ba39bf52 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/DistributionStatusEvent.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/DistributionStatusEvent.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.resources.data.auditing;
import com.datastax.driver.core.utils.UUIDs;
@@ -25,6 +24,10 @@ 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;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.TimeZone;
+import java.util.UUID;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
@@ -32,11 +35,6 @@ import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData;
import org.openecomp.sdc.be.resources.data.auditing.model.DistributionData;
import org.openecomp.sdc.common.datastructure.AuditingFieldsKey;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.TimeZone;
-import java.util.UUID;
-
@Getter
@Setter
@ToString
@@ -45,36 +43,26 @@ public class DistributionStatusEvent extends AuditingGenericEvent {
@PartitionKey
protected UUID timebaseduuid;
-
@ClusteringColumn
protected Date timestamp1;
-
@Column(name = "request_id")
protected String requestId;
-
@Column(name = "service_instance_id")
protected String serviceInstanceId;
-
@Column
protected String action;
@Column
protected String status;
-
@Column(name = "description")
protected String desc;
-
@Column
private String did;
-
@Column(name = "consumer_id")
private String consumerId;
-
@Column(name = "topic_name")
private String topicName;
-
@Column(name = "resoure_url")
private String resoureURL;
-
@Column(name = "status_time")
private String statusTime;
@@ -82,11 +70,10 @@ public class DistributionStatusEvent extends AuditingGenericEvent {
public DistributionStatusEvent() {
timestamp1 = new Date();
timebaseduuid = UUIDs.timeBased();
-
}
- public DistributionStatusEvent(String action, CommonAuditData commonAuditData, DistributionData distributionData,
- String did, String topicName, String statusTime) {
+ public DistributionStatusEvent(String action, CommonAuditData commonAuditData, DistributionData distributionData, String did, String topicName,
+ String statusTime) {
this();
this.action = action;
this.requestId = commonAuditData.getRequestId();
@@ -111,13 +98,11 @@ public class DistributionStatusEvent extends AuditingGenericEvent {
@Override
public void fillFields() {
fields.put(AuditingFieldsKey.AUDIT_REQUEST_ID.getDisplayName(), getRequestId());
-
fields.put(AuditingFieldsKey.AUDIT_SERVICE_INSTANCE_ID.getDisplayName(), getServiceInstanceId());
fields.put(AuditingFieldsKey.AUDIT_ACTION.getDisplayName(), getAction());
fields.put(AuditingFieldsKey.AUDIT_STATUS.getDisplayName(), getStatus());
fields.put(AuditingFieldsKey.AUDIT_DESC.getDisplayName(), getDesc());
fields.put(AuditingFieldsKey.AUDIT_DISTRIBUTION_CONSUMER_ID.getDisplayName(), getConsumerId());
-
fields.put(AuditingFieldsKey.AUDIT_DISTRIBUTION_ID.getDisplayName(), getDid());
fields.put(AuditingFieldsKey.AUDIT_DISTRIBUTION_STATUS_TIME.getDisplayName(), getStatusTime());
fields.put(AuditingFieldsKey.AUDIT_DISTRIBUTION_TOPIC_NAME.getDisplayName(), getTopicName());
@@ -125,6 +110,5 @@ public class DistributionStatusEvent extends AuditingGenericEvent {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateFormatPattern);
simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
fields.put(AuditingFieldsKey.AUDIT_TIMESTAMP.getDisplayName(), simpleDateFormat.format(timestamp1));
-
}
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/EcompOperationalEnvironmentEvent.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/EcompOperationalEnvironmentEvent.java
index c5cff1adb4..20396f6533 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/EcompOperationalEnvironmentEvent.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/EcompOperationalEnvironmentEvent.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,52 +17,42 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.resources.data.auditing;
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;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.TimeZone;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.openecomp.sdc.common.datastructure.AuditingFieldsKey;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.TimeZone;
-
-
@Getter
@Setter
@ToString
@Table(keyspace = AuditingTypesConstants.AUDIT_KEYSPACE, name = AuditingTypesConstants.ECOMP_OPERATIONAL_ENV_EVENT_TYPE)
-public class EcompOperationalEnvironmentEvent extends AuditingGenericEvent {
+public class EcompOperationalEnvironmentEvent extends AuditingGenericEvent {
@PartitionKey
@Column(name = "operational_environment_id")
protected String operationalEnvironmentId;
-
@ClusteringColumn
protected Date timestamp1;
-
@Column
protected String action;
-
@Column(name = "operational_environment_action")
protected String operationalEnvironmentAction;
-
@Column(name = "operational_environment_name")
protected String operationalEnvironmentName;
-
@Column(name = "operational_environment_type")
protected String operationalEnvironmentType;
-
@Column(name = "tenant_context")
protected String tenantContext;
-
//Required to be public as it is used by Cassandra driver on get operation
public EcompOperationalEnvironmentEvent() {
timestamp1 = new Date();
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/ExternalApiEvent.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/ExternalApiEvent.java
index 3d10792cba..dbd644b7cc 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/ExternalApiEvent.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/ExternalApiEvent.java
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.resources.data.auditing;
import com.datastax.driver.core.utils.UUIDs;
@@ -25,6 +24,10 @@ 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;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.TimeZone;
+import java.util.UUID;
import lombok.Getter;
import lombok.Setter;
import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData;
@@ -33,72 +36,50 @@ import org.openecomp.sdc.be.resources.data.auditing.model.ResourceCommonInfo;
import org.openecomp.sdc.be.resources.data.auditing.model.ResourceVersionInfo;
import org.openecomp.sdc.common.datastructure.AuditingFieldsKey;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.TimeZone;
-import java.util.UUID;
-
/**
* This class Represents the Audit for External API
- *
*/
@Getter
@Setter
@Table(keyspace = AuditingTypesConstants.AUDIT_KEYSPACE, name = AuditingTypesConstants.EXTERNAL_API_EVENT_TYPE)
public class ExternalApiEvent extends AuditingGenericEvent {
+
@PartitionKey
protected UUID timebaseduuid;
-
@ClusteringColumn()
protected Date timestamp1;
-
@Column
protected String action;
@Column
protected String status;
-
@Column(name = "description")
protected String desc;
-
+ @Column(name = "service_instance_id")
+ protected String serviceInstanceId;
+ @Column(name = "invariant_uuid")
+ protected String invariantUuid;
+ @Column(name = "prev_version")
+ protected String prevVersion;
+ @Column(name = "prev_state")
+ protected String prevState;
+ @Column(name = "curr_state")
+ protected String currState;
@Column(name = "consumer_id")
private String consumerId;
-
@Column(name = "resource_url")
private String resourceURL;
-
@Column(name = "resource_name")
private String resourceName;
-
@Column(name = "resource_type")
private String resourceType;
-
- @Column(name = "service_instance_id")
- protected String serviceInstanceId;
-
- @Column(name = "invariant_uuid")
- protected String invariantUuid;
-
@Column(name = "modifier")
private String modifier;
-
- @Column(name = "prev_version")
- protected String prevVersion;
-
@Column(name = "curr_version")
private String currVersion;
-
- @Column(name = "prev_state")
- protected String prevState;
-
- @Column(name = "curr_state")
- protected String currState;
-
@Column(name = "prev_artifact_uuid")
private String prevArtifactUuid;
-
@Column(name = "curr_artifact_uuid")
private String currArtifactUuid;
-
@Column(name = "artifact_data")
private String artifactData;
@@ -108,9 +89,9 @@ public class ExternalApiEvent extends AuditingGenericEvent {
timebaseduuid = UUIDs.timeBased();
}
- public ExternalApiEvent(String action, CommonAuditData commonAuditData, ResourceCommonInfo resourceCommonInfo,
- DistributionData distributionData, ResourceVersionInfo prevParams, ResourceVersionInfo currParams,
- String modifier, String invariantUuid, String artifactData) {
+ public ExternalApiEvent(String action, CommonAuditData commonAuditData, ResourceCommonInfo resourceCommonInfo, DistributionData distributionData,
+ ResourceVersionInfo prevParams, ResourceVersionInfo currParams, String modifier, String invariantUuid,
+ String artifactData) {
this();
this.action = action;
this.status = commonAuditData.getStatus();
@@ -147,12 +128,10 @@ public class ExternalApiEvent extends AuditingGenericEvent {
fields.put(AuditingFieldsKey.AUDIT_RESOURCE_NAME.getDisplayName(), getResourceName());
fields.put(AuditingFieldsKey.AUDIT_RESOURCE_TYPE.getDisplayName(), getResourceType());
fields.put(AuditingFieldsKey.AUDIT_MODIFIER_UID.getDisplayName(), getModifier());
-
fields.put(AuditingFieldsKey.AUDIT_RESOURCE_PREV_VERSION.getDisplayName(), getPrevVersion());
fields.put(AuditingFieldsKey.AUDIT_RESOURCE_CURR_VERSION.getDisplayName(), getCurrVersion());
fields.put(AuditingFieldsKey.AUDIT_RESOURCE_PREV_STATE.getDisplayName(), getPrevState());
fields.put(AuditingFieldsKey.AUDIT_RESOURCE_CURR_STATE.getDisplayName(), getCurrState());
-
fields.put(AuditingFieldsKey.AUDIT_PREV_ARTIFACT_UUID.getDisplayName(), getPrevArtifactUuid());
fields.put(AuditingFieldsKey.AUDIT_CURR_ARTIFACT_UUID.getDisplayName(), getCurrArtifactUuid());
fields.put(AuditingFieldsKey.AUDIT_ARTIFACT_DATA.getDisplayName(), getArtifactData());
@@ -160,13 +139,10 @@ public class ExternalApiEvent extends AuditingGenericEvent {
@Override
public String toString() {
- return "ExternalApiEvent [timebaseduuid=" + timebaseduuid + ", timestamp1=" + timestamp1 + ", action=" + action
- + ", status=" + status + ", desc=" + desc + ", consumerId=" + consumerId + ", resourceURL="
- + resourceURL + ", resourceName=" + resourceName + ", resourceType=" + resourceType
- + ", serviceInstanceId=" + serviceInstanceId + ", invariantUuid=" + invariantUuid + ", modifier=" + modifier
- + ", prevVersion=" + prevVersion+ ", currVersion=" + currVersion
- + ", prevState=" + prevState + ", currState=" + currState
- + ", prevArtifactUuid="
- + prevArtifactUuid + ", currArtifactUuid=" + currArtifactUuid + ", artifactData=" + artifactData + "]";
+ return "ExternalApiEvent [timebaseduuid=" + timebaseduuid + ", timestamp1=" + timestamp1 + ", action=" + action + ", status=" + status
+ + ", desc=" + desc + ", consumerId=" + consumerId + ", resourceURL=" + resourceURL + ", resourceName=" + resourceName + ", resourceType="
+ + resourceType + ", serviceInstanceId=" + serviceInstanceId + ", invariantUuid=" + invariantUuid + ", modifier=" + modifier
+ + ", prevVersion=" + prevVersion + ", currVersion=" + currVersion + ", prevState=" + prevState + ", currState=" + currState
+ + ", prevArtifactUuid=" + prevArtifactUuid + ", currArtifactUuid=" + currArtifactUuid + ", artifactData=" + artifactData + "]";
}
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/GetCategoryHierarchyEvent.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/GetCategoryHierarchyEvent.java
index 95dc1f1729..513cdc5b81 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/GetCategoryHierarchyEvent.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/GetCategoryHierarchyEvent.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.resources.data.auditing;
import com.datastax.driver.core.utils.UUIDs;
@@ -25,42 +24,37 @@ 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;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.TimeZone;
+import java.util.UUID;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData;
import org.openecomp.sdc.common.datastructure.AuditingFieldsKey;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.TimeZone;
-import java.util.UUID;
-
@Getter
@Setter
@ToString
@Table(keyspace = AuditingTypesConstants.AUDIT_KEYSPACE, name = AuditingTypesConstants.GET_CATEGORY_HIERARCHY_EVENT_TYPE)
public class GetCategoryHierarchyEvent extends AuditingGenericEvent {
+
@PartitionKey
protected UUID timebaseduuid;
-
@ClusteringColumn()
// @Column(name="timestamp")
protected Date timestamp1;
-
@Column(name = "request_id")
protected String requestId;
@Column
protected String action;
@Column
protected String status;
-
@Column(name = "description")
protected String desc;
-
@Column
private String modifier;
-
@Column
private String details;
@@ -88,10 +82,9 @@ public class GetCategoryHierarchyEvent extends AuditingGenericEvent {
this.timestamp1 = timestamp1;
}
- @Override
+ @Override
public void fillFields() {
fields.put(AuditingFieldsKey.AUDIT_REQUEST_ID.getDisplayName(), getRequestId());
-
fields.put(AuditingFieldsKey.AUDIT_SERVICE_INSTANCE_ID.getDisplayName(), getServiceInstanceId());
fields.put(AuditingFieldsKey.AUDIT_ACTION.getDisplayName(), getAction());
fields.put(AuditingFieldsKey.AUDIT_STATUS.getDisplayName(), getStatus());
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/GetUsersListEvent.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/GetUsersListEvent.java
index 0ced76bd1c..6d0b8ce806 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/GetUsersListEvent.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/GetUsersListEvent.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.resources.data.auditing;
import com.datastax.driver.core.utils.UUIDs;
@@ -25,41 +24,36 @@ 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;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.TimeZone;
+import java.util.UUID;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData;
import org.openecomp.sdc.common.datastructure.AuditingFieldsKey;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.TimeZone;
-import java.util.UUID;
-
@Getter
@Setter
@ToString
@Table(keyspace = AuditingTypesConstants.AUDIT_KEYSPACE, name = AuditingTypesConstants.GET_USERS_LIST_EVENT_TYPE)
public class GetUsersListEvent extends AuditingGenericEvent {
+
@PartitionKey
protected UUID timebaseduuid;
-
@ClusteringColumn
protected Date timestamp1;
-
@Column(name = "request_id")
protected String requestId;
@Column
protected String action;
@Column
protected String status;
-
@Column(name = "description")
protected String desc;
-
@Column
private String modifier;
-
@Column
private String details;
@@ -90,7 +84,6 @@ public class GetUsersListEvent extends AuditingGenericEvent {
@Override
public void fillFields() {
fields.put(AuditingFieldsKey.AUDIT_REQUEST_ID.getDisplayName(), getRequestId());
-
fields.put(AuditingFieldsKey.AUDIT_ACTION.getDisplayName(), getAction());
fields.put(AuditingFieldsKey.AUDIT_STATUS.getDisplayName(), getStatus());
fields.put(AuditingFieldsKey.AUDIT_DESC.getDisplayName(), getDesc());
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/ResourceAdminEvent.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/ResourceAdminEvent.java
index da3563e7f5..c30cdb2d56 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/ResourceAdminEvent.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/ResourceAdminEvent.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.resources.data.auditing;
import com.datastax.driver.core.utils.UUIDs;
@@ -25,6 +24,10 @@ 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;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.TimeZone;
+import java.util.UUID;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
@@ -33,11 +36,6 @@ import org.openecomp.sdc.be.resources.data.auditing.model.ResourceCommonInfo;
import org.openecomp.sdc.be.resources.data.auditing.model.ResourceVersionInfo;
import org.openecomp.sdc.common.datastructure.AuditingFieldsKey;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.TimeZone;
-import java.util.UUID;
-
@Getter
@Setter
@ToString
@@ -46,80 +44,59 @@ public class ResourceAdminEvent extends AuditingGenericEvent {
@PartitionKey
protected UUID timebaseduuid;
-
@ClusteringColumn
protected Date timestamp1;
-
@Column
protected String action;
-
@Column(name = "resource_type")
protected String resourceType;
-
@Column(name = "prev_version")
protected String prevVersion;
-
@Column(name = "prev_state")
protected String prevState;
-
@Column(name = "curr_state")
protected String currState;
-
- @Column(name = "resource_name")
- private String resourceName;
-
- @Column(name = "curr_version")
- private String currVersion;
-
@Column(name = "request_id")
protected String requestId;
-
@Column(name = "service_instance_id")
protected String serviceInstanceId;
-
@Column
protected String status;
-
@Column(name = "description")
protected String desc;
-
@Column
protected String modifier;
-
@Column(name = "prev_artifact_UUID")
protected String prevArtifactUUID;
-
@Column(name = "curr_artifact_UUID")
protected String currArtifactUUID;
-
@Column(name = "artifact_data")
protected String artifactData;
-
@Column
protected String did;
-
@Column(name = "dprev_status")
protected String dprevStatus;
-
@Column(name = "dcurr_status")
protected String dcurrStatus;
-
@Column(name = "tosca_node_type")
protected String toscaNodeType;
-
@Column
protected String comment;
-
@Column(name = "invariant_UUID")
protected String invariantUUID;
+ @Column(name = "resource_name")
+ private String resourceName;
+ @Column(name = "curr_version")
+ private String currVersion;
public ResourceAdminEvent() {
timestamp1 = new Date();
timebaseduuid = UUIDs.timeBased();
}
- public ResourceAdminEvent(String action, CommonAuditData commonAuditData, ResourceCommonInfo resourceCommonInfo, ResourceVersionInfo prevParams, ResourceVersionInfo currParams,
- String invariantUuid, String modifier, String artifactData, String comment, String did, String toscaNodeType) {
+ public ResourceAdminEvent(String action, CommonAuditData commonAuditData, ResourceCommonInfo resourceCommonInfo, ResourceVersionInfo prevParams,
+ ResourceVersionInfo currParams, String invariantUuid, String modifier, String artifactData, String comment, String did,
+ String toscaNodeType) {
this();
this.action = action;
this.requestId = commonAuditData.getRequestId();
@@ -155,7 +132,6 @@ public class ResourceAdminEvent extends AuditingGenericEvent {
@Override
public void fillFields() {
fields.put(AuditingFieldsKey.AUDIT_REQUEST_ID.getDisplayName(), getRequestId());
-
fields.put(AuditingFieldsKey.AUDIT_SERVICE_INSTANCE_ID.getDisplayName(), getServiceInstanceId());
fields.put(AuditingFieldsKey.AUDIT_ACTION.getDisplayName(), getAction());
fields.put(AuditingFieldsKey.AUDIT_STATUS.getDisplayName(), getStatus());
@@ -176,7 +152,6 @@ public class ResourceAdminEvent extends AuditingGenericEvent {
fields.put(AuditingFieldsKey.AUDIT_RESOURCE_DPREV_STATUS.getDisplayName(), getDprevStatus());
fields.put(AuditingFieldsKey.AUDIT_RESOURCE_TOSCA_NODE_TYPE.getDisplayName(), getToscaNodeType());
fields.put(AuditingFieldsKey.AUDIT_INVARIANT_UUID.getDisplayName(), getInvariantUUID());
-
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateFormatPattern);
simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
fields.put(AuditingFieldsKey.AUDIT_TIMESTAMP.getDisplayName(), timestamp1.getTime());
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/UserAccessEvent.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/UserAccessEvent.java
index bbf647a525..370336041d 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/UserAccessEvent.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/UserAccessEvent.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.resources.data.auditing;
import com.datastax.driver.core.utils.UUIDs;
@@ -25,17 +24,16 @@ 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;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.TimeZone;
+import java.util.UUID;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData;
import org.openecomp.sdc.common.datastructure.AuditingFieldsKey;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.TimeZone;
-import java.util.UUID;
-
@Getter
@Setter
@ToString
@@ -44,25 +42,18 @@ public class UserAccessEvent extends AuditingGenericEvent {
@PartitionKey
protected UUID timebaseduuid;
-
@ClusteringColumn
protected Date timestamp1;
-
@Column(name = "REQUEST_ID")
protected String requestId;
-
@Column(name = "USER")
private String userUid;
-
@Column
private String status;
-
@Column(name = "DESCRIPTION")
private String desc;
-
@Column
private String action;
-
@Column(name = "service_instance_id")
private String serviceInstanceId;
@@ -93,7 +84,6 @@ public class UserAccessEvent extends AuditingGenericEvent {
@Override
public void fillFields() {
fields.put(AuditingFieldsKey.AUDIT_REQUEST_ID.getDisplayName(), getRequestId());
-
fields.put(AuditingFieldsKey.AUDIT_SERVICE_INSTANCE_ID.getDisplayName(), getServiceInstanceId());
fields.put(AuditingFieldsKey.AUDIT_ACTION.getDisplayName(), getAction());
fields.put(AuditingFieldsKey.AUDIT_STATUS.getDisplayName(), getStatus());
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/UserAdminEvent.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/UserAdminEvent.java
index f0763fe0b8..f9d72620de 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/UserAdminEvent.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/UserAdminEvent.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.resources.data.auditing;
import com.datastax.driver.core.utils.UUIDs;
@@ -25,17 +24,16 @@ 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;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.TimeZone;
+import java.util.UUID;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData;
import org.openecomp.sdc.common.datastructure.AuditingFieldsKey;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.TimeZone;
-import java.util.UUID;
-
@Getter
@Setter
@ToString
@@ -44,30 +42,22 @@ public class UserAdminEvent extends AuditingGenericEvent {
@PartitionKey
protected UUID timebaseduuid;
-
@ClusteringColumn
protected Date timestamp1;
-
@Column(name = "REQUEST_ID")
protected String requestId;
-
@Column(name = "SERVICE_INSTANCE_ID")
protected String serviceInstanceId;
-
@Column(name = "ACTION")
protected String action;
@Column
protected String status;
-
@Column(name = "description")
protected String desc;
-
@Column
private String modifier;
-
@Column(name = "user_before")
private String userBefore;
-
@Column(name = "user_after")
private String userAfter;
@@ -100,7 +90,6 @@ public class UserAdminEvent extends AuditingGenericEvent {
@Override
public void fillFields() {
fields.put(AuditingFieldsKey.AUDIT_REQUEST_ID.getDisplayName(), getRequestId());
-
fields.put(AuditingFieldsKey.AUDIT_SERVICE_INSTANCE_ID.getDisplayName(), getServiceInstanceId());
fields.put(AuditingFieldsKey.AUDIT_ACTION.getDisplayName(), getAction());
fields.put(AuditingFieldsKey.AUDIT_STATUS.getDisplayName(), getStatus());
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/model/CommonAuditData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/model/CommonAuditData.java
index 6fb64ecce1..e676257742 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/model/CommonAuditData.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/model/CommonAuditData.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,10 +17,10 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.resources.data.auditing.model;
public class CommonAuditData {
+
private String description;
private String requestId;
private String serviceInstanceId;
@@ -30,6 +30,10 @@ public class CommonAuditData {
//for builder
}
+ public static Builder newBuilder() {
+ return new Builder();
+ }
+
public String getStatus() {
return status;
}
@@ -38,27 +42,24 @@ public class CommonAuditData {
return description;
}
- public void setRequestId(String requestId) {
- this.requestId = requestId;
- }
-
public String getRequestId() {
return requestId;
}
+ public void setRequestId(String requestId) {
+ this.requestId = requestId;
+ }
+
public String getServiceInstanceId() {
return serviceInstanceId;
}
public void setServiceInstanceId(String serviceInstanceId) {
- this.serviceInstanceId = serviceInstanceId ;
- }
-
- public static Builder newBuilder() {
- return new Builder();
+ this.serviceInstanceId = serviceInstanceId;
}
public static class Builder {
+
private final CommonAuditData instance;
private Builder() {
@@ -93,7 +94,5 @@ public class CommonAuditData {
public CommonAuditData build() {
return instance;
}
-
}
-
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/model/DistributionData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/model/DistributionData.java
index 2101a0cf60..118f10b6ef 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/model/DistributionData.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/model/DistributionData.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.resources.data.auditing.model;
public class DistributionData {
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/model/DistributionTopicData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/model/DistributionTopicData.java
index 01436dc3c7..f8dff71bcb 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/model/DistributionTopicData.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/model/DistributionTopicData.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,16 +17,20 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.resources.data.auditing.model;
public class DistributionTopicData {
+
private String statusTopic;
private String notificationTopic;
private DistributionTopicData() {
}
+ public static Builder newBuilder() {
+ return new Builder();
+ }
+
public String getStatusTopic() {
return statusTopic;
}
@@ -35,10 +39,6 @@ public class DistributionTopicData {
return notificationTopic;
}
- public static Builder newBuilder() {
- return new Builder();
- }
-
public static class Builder {
private final DistributionTopicData instance;
@@ -60,6 +60,5 @@ public class DistributionTopicData {
public DistributionTopicData build() {
return instance;
}
-
}
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/model/OperationalEnvAuditData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/model/OperationalEnvAuditData.java
index 06242481dd..31f2c4fa74 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/model/OperationalEnvAuditData.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/model/OperationalEnvAuditData.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,14 +17,20 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.resources.data.auditing.model;
public class OperationalEnvAuditData {
+
private String envId;
private String vnfWorkloadContext;
private String tenant;
+ public OperationalEnvAuditData(String envId, String vnfWorkloadContext, String tenant) {
+ this.envId = envId;
+ this.vnfWorkloadContext = vnfWorkloadContext;
+ this.tenant = tenant;
+ }
+
public String getEnvId() {
return envId;
}
@@ -36,11 +42,4 @@ public class OperationalEnvAuditData {
public String getTenant() {
return tenant;
}
-
- public OperationalEnvAuditData(String envId, String vnfWorkloadContext, String tenant) {
- this.envId = envId;
- this.vnfWorkloadContext = vnfWorkloadContext;
- this.tenant = tenant;
- }
-
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/model/ResourceCommonInfo.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/model/ResourceCommonInfo.java
index 4ca585ccc1..155ba07ee8 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/model/ResourceCommonInfo.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/model/ResourceCommonInfo.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.resources.data.auditing.model;
import lombok.AllArgsConstructor;
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/model/ResourceVersionInfo.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/model/ResourceVersionInfo.java
index 26d28a34a2..abf204b2e7 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/model/ResourceVersionInfo.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/auditing/model/ResourceVersionInfo.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,10 +17,10 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.resources.data.auditing.model;
public class ResourceVersionInfo {
+
private String artifactUuid;
private String state;
private String version;
@@ -37,16 +37,21 @@ public class ResourceVersionInfo {
public String getArtifactUuid() {
return artifactUuid;
}
+
public String getState() {
return state;
}
+
public String getVersion() {
return version;
}
- public String getDistributionStatus() { return distributionStatus; }
+ public String getDistributionStatus() {
+ return distributionStatus;
+ }
public static class Builder {
+
private final ResourceVersionInfo instance;
private Builder() {
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/category/CategoryData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/category/CategoryData.java
index 613f91d841..8c4f2076ca 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/category/CategoryData.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/category/CategoryData.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,84 +17,81 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.resources.data.category;
import com.google.gson.reflect.TypeToken;
+import java.lang.reflect.Type;
+import java.util.HashMap;
+import java.util.List;
+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.datatypes.category.CategoryDataDefinition;
import org.openecomp.sdc.be.datatypes.category.MetadataKeyDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import java.lang.reflect.Type;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
public class CategoryData extends GraphNode {
- private CategoryDataDefinition categoryDataDefinition;
-
- public CategoryData(NodeTypeEnum label) {
- super(label);
- categoryDataDefinition = new CategoryDataDefinition();
- }
- public CategoryData(NodeTypeEnum label, CategoryDataDefinition categoryDataDefinition) {
- super(label);
- this.categoryDataDefinition = categoryDataDefinition;
- }
+ private CategoryDataDefinition categoryDataDefinition;
- public CategoryData(Map<String, Object> properties) {
- this(NodeTypeEnum.getByName((String) properties.get(GraphPropertiesDictionary.LABEL.getProperty())));
+ public CategoryData(NodeTypeEnum label) {
+ super(label);
+ categoryDataDefinition = new CategoryDataDefinition();
+ }
- categoryDataDefinition.setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
- categoryDataDefinition
- .setNormalizedName((String) properties.get(GraphPropertiesDictionary.NORMALIZED_NAME.getProperty()));
- categoryDataDefinition.setName((String) properties.get(GraphPropertiesDictionary.NAME.getProperty()));
- final Object useServiceSubstitutionForNestedServicesProperty = properties.get(GraphPropertiesDictionary.USE_SERVICE_SUBSTITUTION_FOR_NESTED_SERVICES.getProperty());
- final boolean useServiceSubstitutionForNestedServices = useServiceSubstitutionForNestedServicesProperty != null && (boolean) useServiceSubstitutionForNestedServicesProperty;
- categoryDataDefinition.setUseServiceSubstitutionForNestedServices(useServiceSubstitutionForNestedServices);
+ public CategoryData(NodeTypeEnum label, CategoryDataDefinition categoryDataDefinition) {
+ super(label);
+ this.categoryDataDefinition = categoryDataDefinition;
+ }
- Type listType = new TypeToken<List<String>>() {
- }.getType();
- List<String> iconsfromJson = getGson()
- .fromJson((String) properties.get(GraphPropertiesDictionary.ICONS.getProperty()), listType);
- categoryDataDefinition.setIcons(iconsfromJson);
-
- final Type metadataKeylistType = new TypeToken<List<MetadataKeyDataDefinition>>() {}.getType();
- final List<MetadataKeyDataDefinition> metadataKeysfromJson = getGson()
- .fromJson((String) properties.get(GraphPropertiesDictionary.METADATA_KEYS.getProperty()), metadataKeylistType);
- categoryDataDefinition.setMetadataKeys(metadataKeysfromJson);
- }
+ public CategoryData(Map<String, Object> properties) {
+ this(NodeTypeEnum.getByName((String) properties.get(GraphPropertiesDictionary.LABEL.getProperty())));
+ categoryDataDefinition.setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
+ categoryDataDefinition.setNormalizedName((String) properties.get(GraphPropertiesDictionary.NORMALIZED_NAME.getProperty()));
+ categoryDataDefinition.setName((String) properties.get(GraphPropertiesDictionary.NAME.getProperty()));
+ final Object useServiceSubstitutionForNestedServicesProperty = properties
+ .get(GraphPropertiesDictionary.USE_SERVICE_SUBSTITUTION_FOR_NESTED_SERVICES.getProperty());
+ final boolean useServiceSubstitutionForNestedServices =
+ useServiceSubstitutionForNestedServicesProperty != null && (boolean) useServiceSubstitutionForNestedServicesProperty;
+ categoryDataDefinition.setUseServiceSubstitutionForNestedServices(useServiceSubstitutionForNestedServices);
+ Type listType = new TypeToken<List<String>>() {
+ }.getType();
+ List<String> iconsfromJson = getGson().fromJson((String) properties.get(GraphPropertiesDictionary.ICONS.getProperty()), listType);
+ categoryDataDefinition.setIcons(iconsfromJson);
+ final Type metadataKeylistType = new TypeToken<List<MetadataKeyDataDefinition>>() {
+ }.getType();
+ final List<MetadataKeyDataDefinition> metadataKeysfromJson = getGson()
+ .fromJson((String) properties.get(GraphPropertiesDictionary.METADATA_KEYS.getProperty()), metadataKeylistType);
+ categoryDataDefinition.setMetadataKeys(metadataKeysfromJson);
+ }
- @Override
- public String getUniqueId() {
- return categoryDataDefinition.getUniqueId();
- }
+ @Override
+ public String getUniqueId() {
+ return categoryDataDefinition.getUniqueId();
+ }
- public CategoryDataDefinition getCategoryDataDefinition() {
- return categoryDataDefinition;
- }
+ public CategoryDataDefinition getCategoryDataDefinition() {
+ return categoryDataDefinition;
+ }
- @Override
- public Map<String, Object> toGraphMap() {
- Map<String, Object> map = new HashMap<>();
+ @Override
+ public Map<String, Object> toGraphMap() {
+ Map<String, Object> map = new HashMap<>();
+ addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, categoryDataDefinition.getUniqueId());
+ addIfExists(map, GraphPropertiesDictionary.NAME, categoryDataDefinition.getName());
+ addIfExists(map, GraphPropertiesDictionary.NORMALIZED_NAME, categoryDataDefinition.getNormalizedName());
+ // String icons=getGson().toJson(categoryDataDefinition.getIcons());
- addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, categoryDataDefinition.getUniqueId());
- addIfExists(map, GraphPropertiesDictionary.NAME, categoryDataDefinition.getName());
- addIfExists(map, GraphPropertiesDictionary.NORMALIZED_NAME, categoryDataDefinition.getNormalizedName());
- // String icons=getGson().toJson(categoryDataDefinition.getIcons());
- // addIfExists(map, GraphPropertiesDictionary.ICONS, icons);
+ // addIfExists(map, GraphPropertiesDictionary.ICONS, icons);
addIfExists(map, GraphPropertiesDictionary.ICONS, categoryDataDefinition.getIcons());
- addIfExists(map, GraphPropertiesDictionary.USE_SERVICE_SUBSTITUTION_FOR_NESTED_SERVICES, categoryDataDefinition.isUseServiceSubstitutionForNestedServices());
+ addIfExists(map, GraphPropertiesDictionary.USE_SERVICE_SUBSTITUTION_FOR_NESTED_SERVICES,
+ categoryDataDefinition.isUseServiceSubstitutionForNestedServices());
addIfExists(map, GraphPropertiesDictionary.METADATA_KEYS, categoryDataDefinition.getMetadataKeys());
- return map;
- }
-
- @Override
- public String toString() {
- return "CategoryData [categoryDataDefinition=" + categoryDataDefinition + "]";
- }
+ return map;
+ }
+ @Override
+ public String toString() {
+ return "CategoryData [categoryDataDefinition=" + categoryDataDefinition + "]";
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/category/GroupingData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/category/GroupingData.java
index 1991c48f48..ce35ecb7e3 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/category/GroupingData.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/category/GroupingData.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,57 +17,51 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.resources.data.category;
+import java.util.HashMap;
+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.datatypes.category.GroupingDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import java.util.HashMap;
-import java.util.Map;
-
public class GroupingData extends GraphNode {
- private GroupingDataDefinition groupingDataDefinition;
-
- public GroupingData(NodeTypeEnum label) {
- super(label);
- groupingDataDefinition = new GroupingDataDefinition();
- }
-
- public GroupingData(NodeTypeEnum label, GroupingDataDefinition groupingDataDefinition) {
- super(label);
- this.groupingDataDefinition = groupingDataDefinition;
- }
-
- public GroupingData(Map<String, Object> properties) {
- this(NodeTypeEnum.getByName((String) properties.get(GraphPropertiesDictionary.LABEL.getProperty())));
+ private GroupingDataDefinition groupingDataDefinition;
- groupingDataDefinition.setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
- groupingDataDefinition
- .setNormalizedName((String) properties.get(GraphPropertiesDictionary.NORMALIZED_NAME.getProperty()));
- groupingDataDefinition.setName((String) properties.get(GraphPropertiesDictionary.NAME.getProperty()));
- }
+ public GroupingData(NodeTypeEnum label) {
+ super(label);
+ groupingDataDefinition = new GroupingDataDefinition();
+ }
- public GroupingDataDefinition getGroupingDataDefinition() {
- return groupingDataDefinition;
- }
+ public GroupingData(NodeTypeEnum label, GroupingDataDefinition groupingDataDefinition) {
+ super(label);
+ this.groupingDataDefinition = groupingDataDefinition;
+ }
- @Override
- public String getUniqueId() {
- return groupingDataDefinition.getUniqueId();
- }
+ public GroupingData(Map<String, Object> properties) {
+ this(NodeTypeEnum.getByName((String) properties.get(GraphPropertiesDictionary.LABEL.getProperty())));
+ groupingDataDefinition.setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
+ groupingDataDefinition.setNormalizedName((String) properties.get(GraphPropertiesDictionary.NORMALIZED_NAME.getProperty()));
+ groupingDataDefinition.setName((String) properties.get(GraphPropertiesDictionary.NAME.getProperty()));
+ }
- @Override
- public Map<String, Object> toGraphMap() {
- Map<String, Object> map = new HashMap<>();
+ public GroupingDataDefinition getGroupingDataDefinition() {
+ return groupingDataDefinition;
+ }
- addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, groupingDataDefinition.getUniqueId());
- addIfExists(map, GraphPropertiesDictionary.NAME, groupingDataDefinition.getName());
- addIfExists(map, GraphPropertiesDictionary.NORMALIZED_NAME, groupingDataDefinition.getNormalizedName());
- return map;
- }
+ @Override
+ public String getUniqueId() {
+ return groupingDataDefinition.getUniqueId();
+ }
+ @Override
+ public Map<String, Object> toGraphMap() {
+ Map<String, Object> map = new HashMap<>();
+ addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, groupingDataDefinition.getUniqueId());
+ addIfExists(map, GraphPropertiesDictionary.NAME, groupingDataDefinition.getName());
+ addIfExists(map, GraphPropertiesDictionary.NORMALIZED_NAME, groupingDataDefinition.getNormalizedName());
+ return map;
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/category/SubCategoryData.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/category/SubCategoryData.java
index 13976035b6..ed96691804 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/category/SubCategoryData.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/category/SubCategoryData.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,76 +17,69 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.resources.data.category;
import com.google.gson.reflect.TypeToken;
+import java.lang.reflect.Type;
+import java.util.HashMap;
+import java.util.List;
+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.datatypes.category.MetadataKeyDataDefinition;
import org.openecomp.sdc.be.datatypes.category.SubCategoryDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import java.lang.reflect.Type;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
public class SubCategoryData extends GraphNode {
- private SubCategoryDataDefinition subCategoryDataDefinition;
-
- public SubCategoryData(NodeTypeEnum label) {
- super(label);
- subCategoryDataDefinition = new SubCategoryDataDefinition();
- }
-
- public SubCategoryData(NodeTypeEnum label, SubCategoryDataDefinition subCategoryDataDefinition) {
- super(label);
- this.subCategoryDataDefinition = subCategoryDataDefinition;
- }
+ private SubCategoryDataDefinition subCategoryDataDefinition;
- public SubCategoryData(Map<String, Object> properties) {
- this(NodeTypeEnum.getByName((String) properties.get(GraphPropertiesDictionary.LABEL.getProperty())));
+ public SubCategoryData(NodeTypeEnum label) {
+ super(label);
+ subCategoryDataDefinition = new SubCategoryDataDefinition();
+ }
- subCategoryDataDefinition
- .setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
- subCategoryDataDefinition
- .setNormalizedName((String) properties.get(GraphPropertiesDictionary.NORMALIZED_NAME.getProperty()));
- subCategoryDataDefinition.setName((String) properties.get(GraphPropertiesDictionary.NAME.getProperty()));
+ public SubCategoryData(NodeTypeEnum label, SubCategoryDataDefinition subCategoryDataDefinition) {
+ super(label);
+ this.subCategoryDataDefinition = subCategoryDataDefinition;
+ }
- Type listType = new TypeToken<List<String>>() {
- }.getType();
- List<String> iconsfromJson = getGson()
- .fromJson((String) properties.get(GraphPropertiesDictionary.ICONS.getProperty()), listType);
- subCategoryDataDefinition.setIcons(iconsfromJson);
-
- final Type metadataKeylistType = new TypeToken<List<MetadataKeyDataDefinition>>() {}.getType();
- final List<MetadataKeyDataDefinition> metadataKeysfromJson = getGson()
- .fromJson((String) properties.get(GraphPropertiesDictionary.METADATA_KEYS.getProperty()), metadataKeylistType);
- subCategoryDataDefinition.setMetadataKeys(metadataKeysfromJson);
- }
+ public SubCategoryData(Map<String, Object> properties) {
+ this(NodeTypeEnum.getByName((String) properties.get(GraphPropertiesDictionary.LABEL.getProperty())));
+ subCategoryDataDefinition.setUniqueId((String) properties.get(GraphPropertiesDictionary.UNIQUE_ID.getProperty()));
+ subCategoryDataDefinition.setNormalizedName((String) properties.get(GraphPropertiesDictionary.NORMALIZED_NAME.getProperty()));
+ subCategoryDataDefinition.setName((String) properties.get(GraphPropertiesDictionary.NAME.getProperty()));
+ Type listType = new TypeToken<List<String>>() {
+ }.getType();
+ List<String> iconsfromJson = getGson().fromJson((String) properties.get(GraphPropertiesDictionary.ICONS.getProperty()), listType);
+ subCategoryDataDefinition.setIcons(iconsfromJson);
+ final Type metadataKeylistType = new TypeToken<List<MetadataKeyDataDefinition>>() {
+ }.getType();
+ final List<MetadataKeyDataDefinition> metadataKeysfromJson = getGson()
+ .fromJson((String) properties.get(GraphPropertiesDictionary.METADATA_KEYS.getProperty()), metadataKeylistType);
+ subCategoryDataDefinition.setMetadataKeys(metadataKeysfromJson);
+ }
- public SubCategoryDataDefinition getSubCategoryDataDefinition() {
- return subCategoryDataDefinition;
- }
+ public SubCategoryDataDefinition getSubCategoryDataDefinition() {
+ return subCategoryDataDefinition;
+ }
- @Override
- public String getUniqueId() {
- return subCategoryDataDefinition.getUniqueId();
- }
+ @Override
+ public String getUniqueId() {
+ return subCategoryDataDefinition.getUniqueId();
+ }
- @Override
- public Map<String, Object> toGraphMap() {
- Map<String, Object> map = new HashMap<>();
+ @Override
+ public Map<String, Object> toGraphMap() {
+ Map<String, Object> map = new HashMap<>();
+ addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, subCategoryDataDefinition.getUniqueId());
+ addIfExists(map, GraphPropertiesDictionary.NAME, subCategoryDataDefinition.getName());
+ addIfExists(map, GraphPropertiesDictionary.NORMALIZED_NAME, subCategoryDataDefinition.getNormalizedName());
+ // String icons=getGson().toJson(subCategoryDataDefinition.getIcons());
- addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, subCategoryDataDefinition.getUniqueId());
- addIfExists(map, GraphPropertiesDictionary.NAME, subCategoryDataDefinition.getName());
- addIfExists(map, GraphPropertiesDictionary.NORMALIZED_NAME, subCategoryDataDefinition.getNormalizedName());
- // String icons=getGson().toJson(subCategoryDataDefinition.getIcons());
- // addIfExists(map, GraphPropertiesDictionary.ICONS, icons);
- addIfExists(map, GraphPropertiesDictionary.ICONS, subCategoryDataDefinition.getIcons());
- addIfExists(map, GraphPropertiesDictionary.METADATA_KEYS, subCategoryDataDefinition.getMetadataKeys());
- return map;
- }
+ // addIfExists(map, GraphPropertiesDictionary.ICONS, icons);
+ addIfExists(map, GraphPropertiesDictionary.ICONS, subCategoryDataDefinition.getIcons());
+ addIfExists(map, GraphPropertiesDictionary.METADATA_KEYS, subCategoryDataDefinition.getMetadataKeys());
+ return map;
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/togglz/FeatureToggleEvent.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/togglz/FeatureToggleEvent.java
index 8fdb576cbe..a92842161b 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/togglz/FeatureToggleEvent.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/data/togglz/FeatureToggleEvent.java
@@ -17,14 +17,15 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.resources.data.togglz;
import com.datastax.driver.mapping.annotations.Column;
import com.datastax.driver.mapping.annotations.PartitionKey;
import com.datastax.driver.mapping.annotations.Table;
+import com.datastax.driver.mapping.annotations.Transient;
import com.google.common.base.Joiner;
import com.google.common.base.Splitter;
+import java.util.Map;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@@ -34,27 +35,21 @@ import org.openecomp.sdc.common.log.enums.EcompLoggerErrorCode;
import org.openecomp.sdc.common.log.wrappers.Logger;
import org.togglz.core.Feature;
import org.togglz.core.repository.FeatureState;
-import com.datastax.driver.mapping.annotations.Transient;
-
-import java.util.Map;
@Getter
@Setter
@NoArgsConstructor
@Table(keyspace = AuditingTypesConstants.REPO_KEYSPACE, name = AuditingTypesConstants.FEATURE_TOGGLE_STATE)
public class FeatureToggleEvent {
- private static final Logger logger = Logger.getLogger(FeatureToggleEvent.class);
+ private static final Logger logger = Logger.getLogger(FeatureToggleEvent.class);
@PartitionKey
@Column(name = "feature_name")
private String featureName;
-
@Column(name = "enabled")
private String enabled;
-
@Column(name = "strategy_id")
private String strategyId;
-
@Column(name = "parameters")
private String parameters;
@@ -74,22 +69,16 @@ public class FeatureToggleEvent {
}
FeatureState featureState = new FeatureState(feature, Boolean.valueOf(enabled));
featureState.setStrategyId(strategyId);
-
setParameters(featureState);
return featureState;
-
}
private void setParameters(FeatureState featureState) {
try {
Map<String, String> paramMap = Splitter.on(",").withKeyValueSeparator("=").split(parameters);
- paramMap.keySet().forEach(p->featureState.setParameter(p, paramMap.get(p)));
- }
- catch(IllegalArgumentException e) {
- logger.warn(EcompLoggerErrorCode.DATA_ERROR, "FeatureToggle",
- "FeatureState Object generating", e.getMessage());
+ paramMap.keySet().forEach(p -> featureState.setParameter(p, paramMap.get(p)));
+ } catch (IllegalArgumentException e) {
+ logger.warn(EcompLoggerErrorCode.DATA_ERROR, "FeatureToggle", "FeatureState Object generating", e.getMessage());
}
}
-
-
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/exception/DeleteDeployedException.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/exception/DeleteDeployedException.java
index f0d320114f..0a7d2eaa8c 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/exception/DeleteDeployedException.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/exception/DeleteDeployedException.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,26 +17,24 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.resources.exception;
import org.openecomp.sdc.exception.TechnicalException;
/**
* Thrown when a deployed environment / topology is about to be deleted
- *
- * @author mourouvi
*
+ * @author mourouvi
*/
public class DeleteDeployedException extends TechnicalException {
- private static final long serialVersionUID = -5192834855057177252L;
+ private static final long serialVersionUID = -5192834855057177252L;
- public DeleteDeployedException(String message, Throwable cause) {
- super(message, cause);
- }
+ public DeleteDeployedException(String message, Throwable cause) {
+ super(message, cause);
+ }
- public DeleteDeployedException(String message) {
- super(message);
- }
+ public DeleteDeployedException(String message) {
+ super(message);
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/exception/InitializationException.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/exception/InitializationException.java
index 9c4337554e..98bf960f02 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/exception/InitializationException.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/resources/exception/InitializationException.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.be.resources.exception;
import org.openecomp.sdc.exception.TechnicalException;
@@ -26,7 +25,8 @@ import org.openecomp.sdc.exception.TechnicalException;
* Exception to be thrown in case of an error that prevents alien to startup.
*/
public class InitializationException extends TechnicalException {
- public InitializationException(String message, Throwable cause) {
- super(message, cause);
- }
+
+ public InitializationException(String message, Throwable cause) {
+ super(message, cause);
+ }
}