summaryrefslogtreecommitdiffstats
path: root/catalog-model
diff options
context:
space:
mode:
authorfranciscovila <javier.paradela.vila@est.tech>2022-01-18 09:42:50 +0000
committerMichael Morris <michael.morris@est.tech>2022-01-20 14:18:56 +0000
commit93f24e4b3ffc331befc5bcdcffd361d77f5ecadd (patch)
treea158fa348d854570c231e787263b98165d5e9bc4 /catalog-model
parent129f40e169a572b9dd5cfe6ad66bc0ee74b922d9 (diff)
Fix use of Optional in ModelOperation
Checking the Optionals are present before getting their values in the ModelOperation class Issue-ID: SDC-3832 Signed-off-by: franciscovila <javier.paradela.vila@est.tech> Change-Id: I1bf55744a6bd31d1fe423fd0eabf09f0c04a2422
Diffstat (limited to 'catalog-model')
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/ModelOperation.java7
1 files changed, 5 insertions, 2 deletions
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/ModelOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/ModelOperation.java
index b73f40f8f1..8118eb3619 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/ModelOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/ModelOperation.java
@@ -246,8 +246,11 @@ public class ModelOperation {
private Model convertToModel(final GraphVertex modelGraphVertex) {
final String modelName = (String) modelGraphVertex.getMetadataProperty(GraphPropertyEnum.NAME);
final String modelTypeProperty = (String) modelGraphVertex.getMetadataProperty(GraphPropertyEnum.MODEL_TYPE);
- final ModelTypeEnum modelType = StringUtils.isEmpty(modelTypeProperty) ? ModelTypeEnum.NORMATIVE :
- ModelTypeEnum.findByValue(modelTypeProperty).isPresent() ? ModelTypeEnum.findByValue(modelTypeProperty).get() : ModelTypeEnum.NORMATIVE;
+ ModelTypeEnum modelType = ModelTypeEnum.NORMATIVE;
+ final Optional<ModelTypeEnum> optionalModelTypeEnum = ModelTypeEnum.findByValue(modelTypeProperty);
+ if (optionalModelTypeEnum.isPresent()) {
+ modelType = optionalModelTypeEnum.get();
+ }
final Either<ImmutablePair<ModelData, GraphEdge>, JanusGraphOperationStatus> parentNode =
janusGraphGenericDao.getChild(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.Model), UniqueIdBuilder.buildModelUid(modelName),