aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-model/src
diff options
context:
space:
mode:
authorvasraz <vasyl.razinkov@est.tech>2023-05-24 17:30:41 +0100
committerMichael Morris <michael.morris@est.tech>2023-06-08 19:44:38 +0000
commit98f08c1f9b617e670cd4c71321c9152e8f63b18c (patch)
tree5823c85f9c16dd24918438e251238ba770532a91 /catalog-model/src
parent1c4fe946f65fb4e7db5cc5d4225b14ec6cc22306 (diff)
Update external query api with new query params
Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech> Change-Id: Ib4970d4f57f9e236f520ca1925915d288c9c5236 Issue-ID: SDC-4409
Diffstat (limited to 'catalog-model/src')
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/DistributionStatusEnum.java14
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacade.java47
2 files changed, 32 insertions, 29 deletions
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/DistributionStatusEnum.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/DistributionStatusEnum.java
index e81be9f09e..2e521c7b2e 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/DistributionStatusEnum.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/DistributionStatusEnum.java
@@ -19,13 +19,14 @@
*/
package org.openecomp.sdc.be.model;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+@AllArgsConstructor
+@Getter
public enum DistributionStatusEnum {
DISTRIBUTION_NOT_APPROVED("Distribution not approved"), DISTRIBUTED("Distributed");
- private String value;
-
- private DistributionStatusEnum(String value) {
- this.value = value;
- }
+ private final String value;
public static DistributionStatusEnum findState(String state) {
for (DistributionStatusEnum distributionStatus : DistributionStatusEnum.values()) {
@@ -36,7 +37,4 @@ public enum DistributionStatusEnum {
return null;
}
- public String getValue() {
- return value;
- }
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacade.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacade.java
index 42781b21d8..0ed0a7b79d 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacade.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacade.java
@@ -135,6 +135,7 @@ import static java.util.Objects.requireNonNull;
import static org.apache.commons.collections.CollectionUtils.isEmpty;
import static org.apache.commons.collections.CollectionUtils.isNotEmpty;
import static org.janusgraph.core.attribute.Text.REGEX;
+import static org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum.TOPOLOGY_TEMPLATE;
@org.springframework.stereotype.Component("tosca-operation-facade")
public class ToscaOperationFacade {
@@ -604,7 +605,7 @@ public class ToscaOperationFacade {
public Either<Resource, StorageOperationStatus> getLatestResourceByToscaResourceName(String toscaResourceName) {
if (toscaResourceName != null && toscaResourceName.contains("org.openecomp.resource.vf")) {
- return getLatestResourceByToscaResourceName(toscaResourceName, VertexTypeEnum.TOPOLOGY_TEMPLATE, JsonParseFlagEnum.ParseMetadata);
+ return getLatestResourceByToscaResourceName(toscaResourceName, TOPOLOGY_TEMPLATE, JsonParseFlagEnum.ParseMetadata);
} else {
return getLatestResourceByToscaResourceName(toscaResourceName, VertexTypeEnum.NODE_TYPE, JsonParseFlagEnum.ParseMetadata);
}
@@ -861,7 +862,7 @@ public class ToscaOperationFacade {
propertiesNotToMatch.put(GraphPropertyEnum.IS_DELETED, true);
final Either<List<GraphVertex>, JanusGraphOperationStatus> getResourceResult
- = janusGraphDao.getByCriteria(null, propertiesToMatch, propertiesNotToMatch,JsonParseFlagEnum.ParseAll);
+ = janusGraphDao.getByCriteria(null, propertiesToMatch, propertiesNotToMatch, JsonParseFlagEnum.ParseAll);
if (getResourceResult.isRight()) {
final JanusGraphOperationStatus status = getResourceResult.right().value();
log.debug("Failed to find resource with systemName {}, version {}. Status is {} ", systemName, version, status);
@@ -1647,23 +1648,23 @@ public class ToscaOperationFacade {
}
public Either<Map<String, MapInterfaceDataDefinition>, StorageOperationStatus> associateComponentInstanceInterfacesToComponent(
- Map<String, Map<String, InterfaceDefinition>> instInterfaces,
- String componentId
+ Map<String, Map<String, InterfaceDefinition>> instInterfaces,
+ String componentId
) {
Either<GraphVertex, JanusGraphOperationStatus> getVertexEither = janusGraphDao.getVertexById(
- componentId,
- JsonParseFlagEnum.NoParse
+ componentId,
+ JsonParseFlagEnum.NoParse
);
if (getVertexEither.isRight()) {
log.debug(
- COULDNT_FETCH_COMPONENT_WITH_AND_UNIQUE_ID_ERROR,
- componentId,
- getVertexEither.right().value()
+ COULDNT_FETCH_COMPONENT_WITH_AND_UNIQUE_ID_ERROR,
+ componentId,
+ getVertexEither.right().value()
);
return Either.right(
- DaoStatusConverter.convertJanusGraphStatusToStorageStatus(
- getVertexEither.right().value()
- )
+ DaoStatusConverter.convertJanusGraphStatusToStorageStatus(
+ getVertexEither.right().value()
+ )
);
}
GraphVertex vertex = getVertexEither.left().value();
@@ -1672,15 +1673,15 @@ public class ToscaOperationFacade {
for (Map.Entry<String, Map<String, InterfaceDefinition>> entryInstances : instInterfaces.entrySet()) {
Map<String, InterfaceDataDefinition> incomingInterfacesMap = entryInstances.getValue().entrySet().stream()
- .collect(Collectors.toMap(e -> e.getKey(), e -> e.getValue()));
+ .collect(Collectors.toMap(e -> e.getKey(), e -> e.getValue()));
MapInterfaceDataDefinition interfacesMap = new MapInterfaceDataDefinition();
interfacesMap.setMapToscaDataDefinition(incomingInterfacesMap);
instInterfacesMap.put(entryInstances.getKey(), interfacesMap);
}
}
StorageOperationStatus status = topologyTemplateOperation.associateInstInterfacesToComponent(
- vertex,
- instInterfacesMap
+ vertex,
+ instInterfacesMap
);
if (StorageOperationStatus.OK == status) {
log.debug(COMPONENT_CREATED_SUCCESSFULLY);
@@ -2334,7 +2335,7 @@ public class ToscaOperationFacade {
}
private VertexTypeEnum getVertexTypeEnum(final ResourceTypeEnum resourceType) {
- return ModelConverter.isAtomicComponent(resourceType) ? VertexTypeEnum.NODE_TYPE : VertexTypeEnum.TOPOLOGY_TEMPLATE;
+ return ModelConverter.isAtomicComponent(resourceType) ? VertexTypeEnum.NODE_TYPE : TOPOLOGY_TEMPLATE;
}
private Map<GraphPropertyEnum, Object> propertiesToMatch(final String normalizedName, final ComponentTypeEnum componentType) {
@@ -2406,7 +2407,7 @@ public class ToscaOperationFacade {
}
if (ComponentTypeEnum.SERVICE == componentTypeEnum || SERVICE.equalsIgnoreCase(internalComponentType) || VF.equalsIgnoreCase(
internalComponentType)) {
- internalVertexTypes.add(VertexTypeEnum.TOPOLOGY_TEMPLATE);
+ internalVertexTypes.add(TOPOLOGY_TEMPLATE);
}
return internalVertexTypes;
}
@@ -2767,7 +2768,7 @@ public class ToscaOperationFacade {
}
propertiesToMatch.put(GraphPropertyEnum.COMPONENT_TYPE, ComponentTypeEnum.SERVICE.name());
propertiesNotToMatch.put(GraphPropertyEnum.IS_DELETED, true);
- if (distStatus != null && !distStatus.isEmpty()) {
+ if (CollectionUtils.isNotEmpty(distStatus)) {
for (DistributionStatusEnum state : distStatus) {
propertiesToMatch.put(GraphPropertyEnum.DISTRIBUTION_STATUS, state.name());
Either<List<Service>, StorageOperationStatus> fetchServicesByCriteria = fetchServicesByCriteria(servicesAll, propertiesToMatch,
@@ -2788,8 +2789,12 @@ public class ToscaOperationFacade {
Map<GraphPropertyEnum, Object> propertiesToMatch,
Map<GraphPropertyEnum, Object> propertiesNotToMatch,
String modelName) {
- Either<List<GraphVertex>, JanusGraphOperationStatus> getRes = janusGraphDao
- .getByCriteria(VertexTypeEnum.TOPOLOGY_TEMPLATE, propertiesToMatch, propertiesNotToMatch, JsonParseFlagEnum.ParseAll, modelName);
+ Either<List<GraphVertex>, JanusGraphOperationStatus> getRes;
+ if (StringUtils.isEmpty(modelName)) {
+ getRes = janusGraphDao.getByCriteria(TOPOLOGY_TEMPLATE, propertiesToMatch, propertiesNotToMatch, JsonParseFlagEnum.ParseAll);
+ } else {
+ getRes = janusGraphDao.getByCriteria(TOPOLOGY_TEMPLATE, propertiesToMatch, propertiesNotToMatch, JsonParseFlagEnum.ParseAll, modelName);
+ }
if (getRes.isRight()) {
if (getRes.right().value() != JanusGraphOperationStatus.NOT_FOUND) {
CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG,
@@ -3441,7 +3446,7 @@ public class ToscaOperationFacade {
log.error(COULDNT_FETCH_A_COMPONENT_WITH_AND_UNIQUE_ID_ERROR, componentId, getVertexEither.right().value());
result = Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(getVertexEither.right().value()));
} else {
- if (getVertexEither.left().value().getLabel() != VertexTypeEnum.TOPOLOGY_TEMPLATE) {
+ if (getVertexEither.left().value().getLabel() != TOPOLOGY_TEMPLATE) {
log.error("Policy association to component of Tosca type {} is not allowed. ", getVertexEither.left().value().getLabel());
result = Either.right(StorageOperationStatus.BAD_REQUEST);
}