aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-model
diff options
context:
space:
mode:
authorMichael Lando <ml636r@att.com>2017-06-11 14:22:02 +0300
committerMichael Lando <ml636r@att.com>2017-06-11 17:48:32 +0300
commitb3d4898d9e8452ea0b8d848c048e712d43b8d9a3 (patch)
tree0609319203be13f6c29ccbe24cb39c9d64f90095 /catalog-model
parentaf9929df75604ce407d0ca542b200630164e0ae6 (diff)
[SDC-29] rebase continue work to align source
Change-Id: I218f1c5ee23fb2c8314f1c70921d3ad8682c10f4 Signed-off-by: Michael Lando <ml636r@att.com>
Diffstat (limited to 'catalog-model')
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/AttributeDefinition.java71
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/Component.java6
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstanceAttribute.java78
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstanceInput.java18
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstanceProperty.java8
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/PropertyDefinition.java30
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/Resource.java6
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/datamodel/NodeType.java8
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/datamodel/TopologyTemplate.java9
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ArtifactsOperations.java16
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/BaseOperation.java50
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/NodeTemplateOperation.java67
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/NodeTypeOperation.java135
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/TopologyTemplateOperation.java40
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaElementLifecycleOperation.java906
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaElementOperation.java204
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaOperationFacade.java217
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/utils/ModelConverter.java28
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/api/IAttributeOperation.java26
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/api/IComponentInstanceOperation.java7
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/api/IConsumerOperation.java8
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/api/IResourceOperation.java5
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/api/IUserAdminOperation.java2
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/AttributeOperation.java96
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/ComponentInstanceOperation.java41
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/ConsumerOperation.java16
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/ResourceOperation.java124
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/UserAdminOperation.java14
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/migration/MigrationMalformedDataLogger.java (renamed from catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/migration/MigrationErrorInformer.java)13
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/ToscaPropertyType.java2
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/converters/ToscaMapValueConverter.java2
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiComponentDataTransfer.java10
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiComponentMetadata.java1
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiResourceDataTransfer.java9
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiResourceMetadata.java3
35 files changed, 1252 insertions, 1024 deletions
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/AttributeDefinition.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/AttributeDefinition.java
deleted file mode 100644
index 120a87c610..0000000000
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/AttributeDefinition.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.be.model;
-
-import java.io.Serializable;
-
-import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition;
-
-public class AttributeDefinition extends AttributeDataDefinition implements IComplexDefaultValue, Serializable {
-
- /**
- *
- */
- private static final long serialVersionUID = -6306111879714097811L;
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = super.hashCode();
- result = prime * result + ((parentUniqueId == null) ? 0 : parentUniqueId.hashCode());
- return result;
- }
-
- /**
- * The resource id which this property belongs to
- */
- private String parentUniqueId;
-
- public AttributeDefinition(AttributeDefinition hpdd) {
- super(hpdd);
- }
-
- public AttributeDefinition() {
- super();
- }
-
- public AttributeDefinition(AttributeDataDefinition p) {
- super(p);
- }
-
- public String getParentUniqueId() {
- return parentUniqueId;
- }
-
- public void setParentUniqueId(String parentUniqueId) {
- this.parentUniqueId = parentUniqueId;
- }
-
- @Override
- public String toString() {
- return super.toString() + " [ parentUniqueId=" + parentUniqueId + "]";
- }
-}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/Component.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/Component.java
index 6ccb49a4b3..036108e81f 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/Component.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/Component.java
@@ -54,7 +54,7 @@ public abstract class Component implements Serializable {
private Map<String, List<ComponentInstanceProperty>> componentInstancesProperties;
- private Map<String, List<ComponentInstanceAttribute>> componentInstancesAttributes;
+ private Map<String, List<ComponentInstanceProperty>> componentInstancesAttributes;
private Map<String, List<CapabilityDefinition>> capabilities;
@@ -609,12 +609,12 @@ public abstract class Component implements Serializable {
}
}
- public Map<String, List<ComponentInstanceAttribute>> getComponentInstancesAttributes() {
+ public Map<String, List<ComponentInstanceProperty>> getComponentInstancesAttributes() {
return componentInstancesAttributes;
}
public void setComponentInstancesAttributes(
- Map<String, List<ComponentInstanceAttribute>> componentInstancesAttributes) {
+ Map<String, List<ComponentInstanceProperty>> componentInstancesAttributes) {
this.componentInstancesAttributes = componentInstancesAttributes;
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstanceAttribute.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstanceAttribute.java
deleted file mode 100644
index 4e55152526..0000000000
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstanceAttribute.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.be.model;
-
-import java.io.Serializable;
-
-public class ComponentInstanceAttribute extends AttributeDefinition
- implements IComponentInstanceConnectedElement, Serializable {
-
- /**
- *
- */
- private static final long serialVersionUID = -496828411269235795L;
-
- private Boolean hidden;
-
- /**
- * The unique id of the attribute value on graph
- */
- private String valueUniqueUid;
-
- public ComponentInstanceAttribute() {
- super();
- }
-
- public ComponentInstanceAttribute(AttributeDefinition pd, Boolean hidden, String valueUniqueUid) {
- super(pd);
-
- this.hidden = hidden;
- this.valueUniqueUid = valueUniqueUid;
- setParentUniqueId(pd.getParentUniqueId());
- }
-
- public ComponentInstanceAttribute(AttributeDefinition attributeDefinition) {
- super(attributeDefinition);
- }
-
- public String getValueUniqueUid() {
- return valueUniqueUid;
- }
-
- public void setValueUniqueUid(String valueUniqueUid) {
- this.valueUniqueUid = valueUniqueUid;
- }
-
- @Override
- public String toString() {
- return "ComponentInstanceAttribute [ " + super.toString() + " , value=" + hidden + ", valueUniqueUid = "
- + valueUniqueUid + " ]";
- }
-
- public Boolean isHidden() {
- return hidden;
- }
-
- public void setHidden(Boolean hidden) {
- this.hidden = hidden;
- }
-
-}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstanceInput.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstanceInput.java
index ca53db69d9..9347f326d1 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstanceInput.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstanceInput.java
@@ -32,10 +32,6 @@ public class ComponentInstanceInput extends InputDefinition implements IComponen
*/
private static final long serialVersionUID = -3937554584759816724L;
- /**
- * Value of property
- */
- private String value;
/**
* The unique id of the property value on graph
@@ -58,14 +54,14 @@ public class ComponentInstanceInput extends InputDefinition implements IComponen
String valueUniqueUid) {
super(curPropertyDef);
this.inputId = inputId;
- this.value = value;
+ setValue(value);
this.valueUniqueUid = valueUniqueUid;
}
public ComponentInstanceInput(InputDefinition pd, String value, String valueUniqueUid) {
super(pd);
- this.value = value;
+ setValue(value);
this.valueUniqueUid = valueUniqueUid;
}
@@ -100,14 +96,6 @@ public class ComponentInstanceInput extends InputDefinition implements IComponen
this.inputId = inputId;
}
- public String getValue() {
- return value;
- }
-
- public void setValue(String value) {
- this.value = value;
- }
-
public String getValueUniqueUid() {
return valueUniqueUid;
}
@@ -142,7 +130,7 @@ public class ComponentInstanceInput extends InputDefinition implements IComponen
@Override
public String toString() {
- return "ComponentInstanceInput [ " + super.toString() + " , value=" + value + ", valueUniqueUid = "
+ return "ComponentInstanceInput [ " + super.toString() + " , value=" + getValue() + ", valueUniqueUid = "
+ valueUniqueUid + " , rules=" + rules + " , path=" + path + " ]";
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstanceProperty.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstanceProperty.java
index 17eb045630..8bd3a9c809 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstanceProperty.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentInstanceProperty.java
@@ -87,6 +87,14 @@ public class ComponentInstanceProperty extends PropertyDefinition implements ICo
this.setValue(value);
this.valueUniqueUid = valueUniqueUid;
}
+
+ public ComponentInstanceProperty(Boolean hidden, PropertyDefinition pd, String valueUniqueUid) {
+ super(pd);
+
+ this.hidden = hidden;
+ this.valueUniqueUid = valueUniqueUid;
+ setParentUniqueId(pd.getParentUniqueId());
+ }
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/PropertyDefinition.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/PropertyDefinition.java
index b315d5c7fd..34ecdbf06d 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/PropertyDefinition.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/PropertyDefinition.java
@@ -104,7 +104,7 @@ public class PropertyDefinition extends PropertyDataDefinition
private List<PropertyConstraint> constraints;
// private Schema schema;
- private String status;
+ // private String status;
@@ -120,7 +120,7 @@ public class PropertyDefinition extends PropertyDataDefinition
public PropertyDefinition(PropertyDefinition pd) {
super(pd);
this.setConstraints(pd.getConstraints());
- status = pd.status;
+ //status = pd.status;
}
@@ -149,13 +149,13 @@ public class PropertyDefinition extends PropertyDataDefinition
// return schema;
// }
- public String getStatus() {
- return status;
- }
-
- public void setStatus(String status) {
- this.status = status;
- }
+// public String getStatus() {
+// return status;
+// }
+//
+// public void setStatus(String status) {
+// this.status = status;
+// }
@@ -174,7 +174,7 @@ public class PropertyDefinition extends PropertyDataDefinition
int result = super.hashCode();
result = prime * result + ((constraints == null) ? 0 : constraints.hashCode());
result = prime * result + ((getName() == null) ? 0 : getName().hashCode());
- result = prime * result + ((status == null) ? 0 : status.hashCode());
+ //result = prime * result + ((status == null) ? 0 : status.hashCode());
return result;
}
@@ -197,11 +197,11 @@ public class PropertyDefinition extends PropertyDataDefinition
return false;
} else if (!getName().equals(other.getName()))
return false;
- if (status == null) {
- if (other.status != null)
- return false;
- } else if (!status.equals(other.status))
- return false;
+// if (status == null) {
+// if (other.status != null)
+// return false;
+// } else if (!status.equals(other.status))
+// return false;
return true;
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/Resource.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/Resource.java
index 5e7983acea..a9c6b44324 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/Resource.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/Resource.java
@@ -52,7 +52,7 @@ public class Resource extends Component implements Serializable {
private List<PropertyDefinition> properties;
- private List<AttributeDefinition> attributes;
+ private List<PropertyDefinition> attributes;
// Later
private Map<String, InterfaceDefinition> interfaces;
@@ -98,11 +98,11 @@ public class Resource extends Component implements Serializable {
this.properties = properties;
}
- public List<AttributeDefinition> getAttributes() {
+ public List<PropertyDefinition> getAttributes() {
return attributes;
}
- public void setAttributes(List<AttributeDefinition> attributes) {
+ public void setAttributes(List<PropertyDefinition> attributes) {
this.attributes = attributes;
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/datamodel/NodeType.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/datamodel/NodeType.java
index 7c6c207f74..c1b4129afc 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/datamodel/NodeType.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/datamodel/NodeType.java
@@ -3,11 +3,11 @@ package org.openecomp.sdc.be.model.jsontitan.datamodel;
import java.util.List;
import java.util.Map;
-import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.InterfaceDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.ListCapabilityDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.ListRequirementDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.MapPropertiesDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
public class NodeType extends ToscaElement{
@@ -18,7 +18,7 @@ public class NodeType extends ToscaElement{
private List<String> derivedFrom;
private List<String> derivedList;
- private Map<String, AttributeDataDefinition> attributes;
+ private Map<String, PropertyDataDefinition> attributes;
private Map<String, ListCapabilityDataDefinition> capabilties;
private Map<String, MapPropertiesDataDefinition> capabiltiesProperties;
private Map<String, ListRequirementDataDefinition> requirements;
@@ -45,11 +45,11 @@ public class NodeType extends ToscaElement{
this.derivedFrom = derivedFrom;
}
- public Map<String, AttributeDataDefinition> getAttributes() {
+ public Map<String, PropertyDataDefinition> getAttributes() {
return attributes;
}
- public void setAttributes(Map<String, AttributeDataDefinition> attributes) {
+ public void setAttributes(Map<String, PropertyDataDefinition> attributes) {
this.attributes = attributes;
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/datamodel/TopologyTemplate.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/datamodel/TopologyTemplate.java
index 74c4c30aa5..5b236e4b84 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/datamodel/TopologyTemplate.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/datamodel/TopologyTemplate.java
@@ -9,7 +9,6 @@ import org.openecomp.sdc.be.datatypes.elements.ComponentInstanceDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.CompositionDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.GroupDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.MapArtifactDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.MapAttributesDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.MapCapabiltyProperty;
import org.openecomp.sdc.be.datatypes.elements.MapGroupsDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.MapListCapabiltyDataDefinition;
@@ -28,7 +27,7 @@ public class TopologyTemplate extends ToscaElement{
private Map<String, PropertyDataDefinition> inputs;
private Map<String, MapPropertiesDataDefinition> instInputs;
private Map<String, ? extends ToscaDataDefinition> heatParameters;
- private Map<String, MapAttributesDataDefinition> instAttributes;
+ private Map<String, MapPropertiesDataDefinition> instAttributes;
private Map<String, MapPropertiesDataDefinition> instProperties;
private Map<String, GroupDataDefinition> groups;
private Map<String, MapGroupsDataDefinition> instGroups;
@@ -64,10 +63,10 @@ public class TopologyTemplate extends ToscaElement{
public void setHeatParameters(Map<String, ? extends ToscaDataDefinition> heatParameters) {
this.heatParameters = heatParameters;
}
- public Map<String, MapAttributesDataDefinition> getInstAttributes() {
+ public Map<String, MapPropertiesDataDefinition> getInstAttributes() {
return instAttributes;
}
- public void setInstAttributes(Map<String, MapAttributesDataDefinition> instAttributes) {
+ public void setInstAttributes(Map<String, MapPropertiesDataDefinition> instAttributes) {
this.instAttributes = instAttributes;
}
public Map<String, MapPropertiesDataDefinition> getInstProperties() {
@@ -163,7 +162,7 @@ public class TopologyTemplate extends ToscaElement{
getCompositions().get(JsonConstantKeysEnum.COMPOSITION.getValue()).getComponentInstances().put(componentInstance.getUniqueId(), componentInstance);
}
/**
- * Returns map of component inctances from composition
+ * Returns map of component instances from composition
* @return
*/
public Map<String, ComponentInstanceDataDefinition> getComponentInstances() {
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ArtifactsOperations.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ArtifactsOperations.java
index 55853479d2..a3cb41f1c0 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ArtifactsOperations.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ArtifactsOperations.java
@@ -30,6 +30,7 @@ import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
import org.openecomp.sdc.be.model.operations.impl.DaoStatusConverter;
import org.openecomp.sdc.be.model.operations.impl.UniqueIdBuilder;
import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum;
+import org.openecomp.sdc.common.api.ArtifactTypeEnum;
import org.openecomp.sdc.common.jsongraph.util.CommonUtility;
import org.openecomp.sdc.common.jsongraph.util.CommonUtility.LogLevelEnum;
import org.slf4j.Logger;
@@ -45,7 +46,7 @@ public class ArtifactsOperations extends BaseOperation {
public Either<ArtifactDefinition, StorageOperationStatus> addArifactToComponent(ArtifactDefinition artifactInfo, String parentId, NodeTypeEnum type, boolean failIfExist, String instanceId) {
- Either<ArtifactDataDefinition, StorageOperationStatus> status = updateArtifactOnGraph(parentId, artifactInfo, type, artifactInfo.getUniqueId(), instanceId);
+ Either<ArtifactDataDefinition, StorageOperationStatus> status = updateArtifactOnGraph(parentId, artifactInfo, type, artifactInfo.getUniqueId(), instanceId, false);
if (status.isRight()) {
log.debug("Failed to update artifact {} of {} {}. status is {}", artifactInfo.getArtifactName(), type.getName(), parentId, status.right().value());
@@ -64,7 +65,7 @@ public class ArtifactsOperations extends BaseOperation {
public Either<ArtifactDefinition, StorageOperationStatus> updateArifactOnResource(ArtifactDefinition artifactInfo, String id, String artifactId, NodeTypeEnum type, String instanceId) {
- Either<ArtifactDataDefinition, StorageOperationStatus> status = updateArtifactOnGraph(id, artifactInfo, type, artifactId, instanceId);
+ Either<ArtifactDataDefinition, StorageOperationStatus> status = updateArtifactOnGraph(id, artifactInfo, type, artifactId, instanceId, true);
if (status.isRight()) {
log.debug("Failed to update artifact {} of {} {}. status is {}", artifactInfo.getArtifactName(), type.getName(), id, status.right().value());
@@ -211,11 +212,14 @@ public class ArtifactsOperations extends BaseOperation {
}
- public void updateUUID(ArtifactDataDefinition artifactData, String oldChecksum, String oldVesrion) {
+ public void updateUUID(ArtifactDataDefinition artifactData, String oldChecksum, String oldVesrion, boolean isUpdate) {
if (oldVesrion == null || oldVesrion.isEmpty())
oldVesrion = "0";
String currentChecksum = artifactData.getArtifactChecksum();
+ if(isUpdate && artifactData.getArtifactType().equalsIgnoreCase(ArtifactTypeEnum.HEAT_ENV.getType())){
+ generateUUID(artifactData, oldVesrion);
+ }
if (oldChecksum == null || oldChecksum.isEmpty()) {
if (currentChecksum != null) {
generateUUID(artifactData, oldVesrion);
@@ -259,7 +263,7 @@ public class ArtifactsOperations extends BaseOperation {
}
Map<String, ArtifactDefinition> artifacts = artifactsEither.left().value();
- List<ArtifactDefinition> envList = artifacts.values().stream().filter(a -> a.getGeneratedFromId().equals(artifactId)).collect(Collectors.toList());
+ List<ArtifactDefinition> envList = artifacts.values().stream().filter(a -> a.getGeneratedFromId()!= null && a.getGeneratedFromId().equals(artifactId)).collect(Collectors.toList());
if (envList != null && !envList.isEmpty()) {
envList.forEach(a -> {
a.setGeneratedFromId(newArtifactId);
@@ -409,7 +413,7 @@ public class ArtifactsOperations extends BaseOperation {
}
- public Either<ArtifactDataDefinition, StorageOperationStatus> updateArtifactOnGraph(String componentId, ArtifactDefinition artifactInfo, NodeTypeEnum type, String artifactId, String instanceId) {
+ public Either<ArtifactDataDefinition, StorageOperationStatus> updateArtifactOnGraph(String componentId, ArtifactDefinition artifactInfo, NodeTypeEnum type, String artifactId, String instanceId, boolean isUpdate) {
Either<ArtifactDataDefinition, StorageOperationStatus> res = null;
ArtifactDataDefinition artifactToUpdate = new ArtifactDataDefinition(artifactInfo);
ArtifactGroupTypeEnum groupType = artifactInfo.getArtifactGroupType();
@@ -479,7 +483,7 @@ public class ArtifactsOperations extends BaseOperation {
}
}
}
- updateUUID(artifactToUpdate, oldChecksum, oldVersion);
+ updateUUID(artifactToUpdate, oldChecksum, oldVersion, isUpdate);
if (artifactInfo.getPayloadData() == null) {
if (!artifactToUpdate.getMandatory() || artifactToUpdate.getEsId() != null) {
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/BaseOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/BaseOperation.java
index 629d9ecdd4..ed14bac8bb 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/BaseOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/BaseOperation.java
@@ -5,6 +5,7 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.UUID;
import java.util.stream.Collectors;
import org.apache.commons.collections.CollectionUtils;
@@ -23,17 +24,24 @@ import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum;
import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
import org.openecomp.sdc.be.dao.jsongraph.utils.IdBuilderUtils;
import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
+import org.openecomp.sdc.be.datatypes.elements.ComponentInstanceDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.GroupDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.GroupInstanceDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.MapDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
+import org.openecomp.sdc.be.model.ComponentInstance;
+import org.openecomp.sdc.be.model.GroupDefinition;
import org.openecomp.sdc.be.model.User;
import org.openecomp.sdc.be.model.jsontitan.datamodel.ToscaElementTypeEnum;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
import org.openecomp.sdc.be.model.operations.impl.DaoStatusConverter;
+import org.openecomp.sdc.be.model.operations.impl.UniqueIdBuilder;
import org.openecomp.sdc.common.jsongraph.util.CommonUtility;
import org.openecomp.sdc.common.jsongraph.util.CommonUtility.LogLevelEnum;
+import org.openecomp.sdc.common.util.ValidationUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -948,7 +956,7 @@ public abstract class BaseOperation {
if (result == null) {
currMap.put(key, toscaDataBlock);
}
- return null;
+ return result;
}
@SuppressWarnings("unchecked")
@@ -1248,9 +1256,9 @@ public abstract class BaseOperation {
return result;
}
- private <K extends ToscaDataDefinition> StorageOperationStatus handleToscaData(GraphVertex toscaElement, VertexTypeEnum vertexLabel, EdgeLabelEnum edgeLabel, GraphVertex toscaDataVertex, Map<String, K> mergedToscaDataMap) {
+ protected <K extends ToscaDataDefinition> StorageOperationStatus handleToscaData(GraphVertex toscaElement, VertexTypeEnum vertexLabel, EdgeLabelEnum edgeLabel, GraphVertex toscaDataVertex, Map<String, K> mergedToscaDataMap) {
- StorageOperationStatus result = null;
+ StorageOperationStatus result = StorageOperationStatus.OK;
if (toscaDataVertex == null) {
Either<GraphVertex, StorageOperationStatus> createRes = assosiateElementToData(toscaElement, vertexLabel, edgeLabel, mergedToscaDataMap);
@@ -1312,5 +1320,41 @@ public abstract class BaseOperation {
// }
// return StorageOperationStatus.OK;
// }
+
+ protected GroupInstanceDataDefinition buildGroupInstanceDataDefinition(GroupDataDefinition group, ComponentInstanceDataDefinition componentInstance) {
+
+ String componentInstanceName = componentInstance.getName();
+ Long creationDate = System.currentTimeMillis();
+ GroupInstanceDataDefinition groupInstance = new GroupInstanceDataDefinition();
+ String groupUid = group.getUniqueId();
+
+ groupInstance.setGroupUid(groupUid);
+ groupInstance.setType(group.getType());
+ groupInstance.setCustomizationUUID(generateCustomizationUUID());
+ groupInstance.setCreationTime(creationDate);
+ groupInstance.setModificationTime(creationDate);
+ groupInstance.setName(buildGroupInstanceName(componentInstanceName, group.getName()));
+ groupInstance.setGroupName(group.getName());
+ groupInstance.setNormalizedName(ValidationUtils.normalizeComponentInstanceName(groupInstance.getName()));
+ groupInstance.setUniqueId(UniqueIdBuilder.buildResourceInstanceUniuqeId(componentInstance.getUniqueId(), groupUid, groupInstance.getNormalizedName()));
+ groupInstance.setArtifacts(group.getArtifacts());
+ groupInstance.setArtifactsUuid(group.getArtifactsUuid());
+ groupInstance.setProperties(group.getProperties());
+ groupInstance.setInvariantUUID(group.getInvariantUUID());
+ groupInstance.setGroupUUID(group.getGroupUUID());
+ groupInstance.setVersion(group.getVersion());
+
+ return groupInstance;
+ }
+
+ protected String buildGroupInstanceName(String instanceName, String groupName) {
+ int groupNameIndex = groupName.indexOf("..");
+ //turn group name from VFName..heatfile..module-n to VFiName..heatfile..module-n
+ return ValidationUtils.normaliseComponentName(instanceName) + groupName.substring(groupNameIndex);
+ }
+
+ protected String generateCustomizationUUID() {
+ return UUID.randomUUID().toString();
+ }
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/NodeTemplateOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/NodeTemplateOperation.java
index a20f85ad7b..58ee914046 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/NodeTemplateOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/NodeTemplateOperation.java
@@ -30,11 +30,11 @@ import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.CapabilityDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.ComponentInstanceDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.CompositionDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.GroupDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.GroupInstanceDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.ListCapabilityDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.ListRequirementDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.MapArtifactDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.MapAttributesDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.MapCapabiltyProperty;
import org.openecomp.sdc.be.datatypes.elements.MapDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.MapGroupsDataDefinition;
@@ -343,7 +343,7 @@ public class NodeTemplateOperation extends BaseOperation {
CompositionDataDefinition composition = container.getCompositions().get(JsonConstantKeysEnum.COMPOSITION.getValue());
if (composition != null) {
Map<String, RelationshipInstDataDefinition> relations = composition.getRelations();
- if (relations != null) {
+ if (MapUtils.isNotEmpty(relations)) {
Either<Pair<GraphVertex, Map<String, MapListCapabiltyDataDefinition>>, StorageOperationStatus> capResult = fetchContainerCalculatedCapability(containerV, EdgeLabelEnum.CALCULATED_CAPABILITIES);
if (capResult.isRight()) {
return capResult.right().value();
@@ -397,6 +397,11 @@ public class NodeTemplateOperation extends BaseOperation {
CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to remove calculated capabilty for instance {} in container {}. error {] ", componentInstanceId, containerV.getUniqueId(), status);
return status;
}
+ status = deleteToscaDataDeepElementsBlockToToscaElement(containerV, EdgeLabelEnum.CALCULATED_CAP_PROPERTIES, VertexTypeEnum.CALCULATED_CAP_PROPERTIES, componentInstanceId);
+ if (status != StorageOperationStatus.OK && status != StorageOperationStatus.NOT_FOUND) {
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to remove calculated capabilty properties for instance {} in container {}. error {] ", componentInstanceId, containerV.getUniqueId(), status);
+ return status;
+ }
status = deleteToscaDataDeepElementsBlockToToscaElement(containerV, EdgeLabelEnum.CALCULATED_REQUIREMENTS, VertexTypeEnum.CALCULATED_REQUIREMENTS, componentInstanceId);
if (status != StorageOperationStatus.OK && status != StorageOperationStatus.NOT_FOUND) {
CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to remove calculated requirement for instance {} in container {}. error {] ", componentInstanceId, containerV.getUniqueId(), status);
@@ -414,12 +419,12 @@ public class NodeTemplateOperation extends BaseOperation {
}
status = deleteToscaDataDeepElementsBlockToToscaElement(containerV, EdgeLabelEnum.INST_ATTRIBUTES, VertexTypeEnum.INST_ATTRIBUTES, componentInstanceId);
if (status != StorageOperationStatus.OK && status != StorageOperationStatus.NOT_FOUND) {
- CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to remove fullfilled requirement for instance {} in container {}. error {] ", componentInstanceId, containerV.getUniqueId(), status);
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to remove attributes for instance {} in container {}. error {] ", componentInstanceId, containerV.getUniqueId(), status);
return status;
}
status = deleteToscaDataDeepElementsBlockToToscaElement(containerV, EdgeLabelEnum.INST_PROPERTIES, VertexTypeEnum.INST_PROPERTIES, componentInstanceId);
if (status != StorageOperationStatus.OK && status != StorageOperationStatus.NOT_FOUND) {
- CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to remove fullfilled requirement for instance {} in container {}. error {] ", componentInstanceId, containerV.getUniqueId(), status);
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to remove properties for instance {} in container {}. error {] ", componentInstanceId, containerV.getUniqueId(), status);
return status;
}
status = deleteToscaDataDeepElementsBlockToToscaElement(containerV, EdgeLabelEnum.INST_INPUTS, VertexTypeEnum.INST_INPUTS, componentInstanceId);
@@ -434,13 +439,18 @@ public class NodeTemplateOperation extends BaseOperation {
}
status = deleteToscaDataDeepElementsBlockToToscaElement(containerV, EdgeLabelEnum.INST_DEPLOYMENT_ARTIFACTS, VertexTypeEnum.INST_DEPLOYMENT_ARTIFACTS, componentInstanceId);
if (status != StorageOperationStatus.OK && status != StorageOperationStatus.NOT_FOUND) {
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to remove instance deployment artifacts for instance {} in container {}. error {] ", componentInstanceId, containerV.getUniqueId(), status);
+ return status;
+ }
+ status = deleteToscaDataDeepElementsBlockToToscaElement(containerV, EdgeLabelEnum.INSTANCE_ARTIFACTS, VertexTypeEnum.INSTANCE_ARTIFACTS, componentInstanceId);
+ if (status != StorageOperationStatus.OK && status != StorageOperationStatus.NOT_FOUND) {
CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to remove instance artifacts for instance {} in container {}. error {] ", componentInstanceId, containerV.getUniqueId(), status);
return status;
}
return StorageOperationStatus.OK;
}
- private Either<GraphVertex, StorageOperationStatus> addComponentInstanceToscaDataToContainerComponent(ToscaElement originToscaElement, ComponentInstanceDataDefinition componentInstance, GraphVertex updatedContainerVertex, User user) {
+ protected Either<GraphVertex, StorageOperationStatus> addComponentInstanceToscaDataToContainerComponent(ToscaElement originToscaElement, ComponentInstanceDataDefinition componentInstance, GraphVertex updatedContainerVertex, User user) {
Either<GraphVertex, StorageOperationStatus> result;
StorageOperationStatus status;
@@ -561,7 +571,7 @@ public class NodeTemplateOperation extends BaseOperation {
return status;
}
- MapAttributesDataDefinition instAttributes = new MapAttributesDataDefinition(originNodeType.getAttributes());
+ MapPropertiesDataDefinition instAttributes = new MapPropertiesDataDefinition(originNodeType.getAttributes());
status = addToscaDataDeepElementsBlockToToscaElement(updatedContainerVertex, EdgeLabelEnum.INST_ATTRIBUTES, VertexTypeEnum.INST_ATTRIBUTES, instAttributes, componentInstance.getUniqueId());
@@ -775,7 +785,7 @@ public class NodeTemplateOperation extends BaseOperation {
return null;
}
- public StorageOperationStatus addGroupInstancesToComponentInstance(Component containerComponent, ComponentInstance componentInstance, List<GroupDefinition> groups, Map<String, List<ArtifactDefinition>> groupInstancesArtifacts) {
+ public StorageOperationStatus addGroupInstancesToComponentInstance(Component containerComponent, ComponentInstanceDataDefinition componentInstance, List<GroupDefinition> groups, Map<String, List<ArtifactDefinition>> groupInstancesArtifacts) {
StorageOperationStatus result = null;
Map<String, GroupInstanceDataDefinition> groupInstanceToCreate = new HashMap<>();
@@ -783,7 +793,7 @@ public class NodeTemplateOperation extends BaseOperation {
for (Map.Entry<String, List<ArtifactDefinition>> groupArtifacts : groupInstancesArtifacts.entrySet()) {
Optional<GroupDefinition> groupOptional = groups.stream().filter(g -> g.getUniqueId().equals(groupArtifacts.getKey())).findFirst();
if (groupOptional.isPresent()) {
- GroupInstanceDataDefinition groupInstance = buildGroupInstanceDataDefinition(groupOptional.get(), componentInstance);
+ GroupInstanceDataDefinition groupInstance = buildGroupInstanceDataDefinition((GroupDataDefinition)groupOptional.get(), (ComponentInstanceDataDefinition)componentInstance);
groupInstance.setGroupInstanceArtifacts(groupArtifacts.getValue().stream().map(a -> a.getUniqueId()).collect(Collectors.toList()));
groupInstance.setGroupInstanceArtifactsUuid(groupArtifacts.getValue().stream().map(a -> a.getArtifactUUID()).collect(Collectors.toList()));
groupInstanceToCreate.put(groupInstance.getName(), groupInstance);
@@ -799,31 +809,7 @@ public class NodeTemplateOperation extends BaseOperation {
return result;
}
- private GroupInstanceDataDefinition buildGroupInstanceDataDefinition(GroupDefinition group, ComponentInstance componentInstance) {
-
- String componentInstanceName = componentInstance.getName();
- Long creationDate = System.currentTimeMillis();
- GroupInstanceDataDefinition groupInstance = new GroupInstanceDataDefinition();
- String groupUid = group.getUniqueId();
-
- groupInstance.setGroupUid(groupUid);
- groupInstance.setType(group.getType());
- groupInstance.setCustomizationUUID(generateCustomizationUUID());
- groupInstance.setCreationTime(creationDate);
- groupInstance.setModificationTime(creationDate);
- groupInstance.setName(buildGroupInstanceName(componentInstanceName, group.getName()));
- groupInstance.setGroupName(groupInstance.getName());
- groupInstance.setNormalizedName(ValidationUtils.normalizeComponentInstanceName(groupInstance.getName()));
- groupInstance.setUniqueId(UniqueIdBuilder.buildResourceInstanceUniuqeId(componentInstance.getUniqueId(), groupUid, groupInstance.getNormalizedName()));
- groupInstance.setArtifacts(group.getArtifacts());
- groupInstance.setArtifactsUuid(group.getArtifactsUuid());
- groupInstance.setProperties(group.getProperties());
- groupInstance.setInvariantUUID(group.getInvariantUUID());
- groupInstance.setGroupUUID(group.getGroupUUID());
- groupInstance.setVersion(group.getVersion());
-
- return groupInstance;
- }
+
private ComponentInstanceDataDefinition buildComponentInstanceDataDefinition(ComponentInstance resourceInstance, String containerComponentId, String instanceNewName, boolean generateUid, ToscaElement originToscaElement) {
String ciOriginComponentUid = resourceInstance.getComponentUid();
@@ -892,15 +878,9 @@ public class NodeTemplateOperation extends BaseOperation {
return isUniqueName;
}
- private String buildGroupInstanceName(String instanceName, String groupName) {
- int groupNameIndex = groupName.indexOf("..");
- //turn group name from VFName..heatfile..module-n to VFiName..heatfile..module-n
- return ValidationUtils.normaliseComponentName(instanceName) + groupName.substring(groupNameIndex);
- }
+
- private String generateCustomizationUUID() {
- return UUID.randomUUID().toString();
- }
+
private String buildComponentInstanceName(String instanceSuffixNumber, String instanceName) {
return instanceName + " " + (instanceSuffixNumber == null ? 0 : instanceSuffixNumber);
@@ -1525,7 +1505,7 @@ public class NodeTemplateOperation extends BaseOperation {
RelationshipInstDataDefinition relationshipTypeData = buildRelationshipInstData(fromInstId, toInstId, relationPair);
- relationshipTypeData.setType(type);
+ relationshipTypeData.setType(requirementForRelation.getRelationship());
return Either.left(relationshipTypeData);
}
@@ -1716,7 +1696,8 @@ public class NodeTemplateOperation extends BaseOperation {
pathKeys.add(componentInstanceId);
return updateToscaDataDeepElementOfToscaElement(containerComponent.getUniqueId(), EdgeLabelEnum.INST_PROPERTIES, VertexTypeEnum.INST_PROPERTIES, property, pathKeys, JsonPresentationFields.NAME);
}
-
+
+
public StorageOperationStatus addComponentInstanceProperty(Component containerComponent, String componentInstanceId, ComponentInstanceProperty property) {
List<String> pathKeys = new ArrayList<>();
pathKeys.add(componentInstanceId);
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/NodeTypeOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/NodeTypeOperation.java
index 1eb67e5c51..985870b5e3 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/NodeTypeOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/NodeTypeOperation.java
@@ -2,16 +2,17 @@ package org.openecomp.sdc.be.model.jsontitan.operations;
import fj.data.Either;
+import org.apache.commons.lang3.tuple.ImmutablePair;
+import org.apache.commons.lang3.tuple.ImmutableTriple;
import org.apache.tinkerpop.gremlin.structure.Direction;
import org.apache.tinkerpop.gremlin.structure.Edge;
+import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
import org.openecomp.sdc.be.dao.jsongraph.types.EdgeLabelEnum;
import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum;
import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
import org.openecomp.sdc.be.datatypes.elements.AdditionalInfoParameterDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.CapabilityDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.InterfaceDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.ListCapabilityDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.ListDataDefinition;
@@ -20,11 +21,11 @@ import org.openecomp.sdc.be.datatypes.elements.MapCapabiltyProperty;
import org.openecomp.sdc.be.datatypes.elements.MapPropertiesDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
+import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
import org.openecomp.sdc.be.model.ComponentParametersView;
import org.openecomp.sdc.be.model.DerivedNodeTypeResolver;
import org.openecomp.sdc.be.model.LifecycleStateEnum;
-import org.openecomp.sdc.be.model.RequirementDefinition;
import org.openecomp.sdc.be.model.jsontitan.datamodel.NodeType;
import org.openecomp.sdc.be.model.jsontitan.datamodel.TopologyTemplate;
import org.openecomp.sdc.be.model.jsontitan.datamodel.ToscaElement;
@@ -32,6 +33,22 @@ import org.openecomp.sdc.be.model.jsontitan.datamodel.ToscaElementTypeEnum;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
import org.openecomp.sdc.be.model.operations.impl.DaoStatusConverter;
import org.openecomp.sdc.be.model.operations.impl.UniqueIdBuilder;
+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.CapabilityTypeData;
+import org.openecomp.sdc.be.resources.data.DataTypeData;
+import org.openecomp.sdc.be.resources.data.GroupData;
+import org.openecomp.sdc.be.resources.data.GroupTypeData;
+import org.openecomp.sdc.be.resources.data.InputValueData;
+import org.openecomp.sdc.be.resources.data.InputsData;
+import org.openecomp.sdc.be.resources.data.PolicyTypeData;
+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.ResourceMetadataData;
import org.openecomp.sdc.common.jsongraph.util.CommonUtility;
import org.openecomp.sdc.common.jsongraph.util.CommonUtility.LogLevelEnum;
import org.slf4j.Logger;
@@ -44,6 +61,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.function.Function;
import java.util.regex.Pattern;
@org.springframework.stereotype.Component("node-type-operation")
@@ -152,7 +170,7 @@ public class NodeTypeOperation extends ToscaElementOperation {
private StorageOperationStatus associateInterfacesToResource(GraphVertex nodeTypeVertex, NodeType nodeType, List<GraphVertex> derivedResources) {
// Note : currently only one derived supported!!!!
- Either<Map<String, InterfaceDataDefinition>, StorageOperationStatus> dataFromDerived = getDataFromDerived(derivedResources, InterfaceDataDefinition.class, EdgeLabelEnum.INTERFACE_ARTIFACTS);
+ Either<Map<String, InterfaceDataDefinition>, StorageOperationStatus> dataFromDerived = getDataFromDerived(derivedResources, EdgeLabelEnum.INTERFACE_ARTIFACTS);
if (dataFromDerived.isRight()) {
return dataFromDerived.right().value();
}
@@ -377,7 +395,7 @@ public class NodeTypeOperation extends ToscaElementOperation {
}
private TitanOperationStatus setResourceAttributesFromGraph(GraphVertex componentV, NodeType toscaElement) {
- Either<Map<String, AttributeDataDefinition>, TitanOperationStatus> result = getDataFromGraph(componentV, EdgeLabelEnum.ATTRIBUTES);
+ Either<Map<String, PropertyDataDefinition>, TitanOperationStatus> result = getDataFromGraph(componentV, EdgeLabelEnum.ATTRIBUTES);
if (result.isLeft()) {
toscaElement.setAttributes(result.left().value());
} else {
@@ -413,7 +431,7 @@ public class NodeTypeOperation extends ToscaElementOperation {
private StorageOperationStatus addAdditionalInformationToResource(GraphVertex nodeTypeVertex, NodeType nodeType, List<GraphVertex> derivedResources) {
// Note : currently only one derived supported!!!!
- Either<Map<String, AdditionalInfoParameterDataDefinition>, StorageOperationStatus> dataFromDerived = getDataFromDerived(derivedResources, AdditionalInfoParameterDataDefinition.class, EdgeLabelEnum.ADDITIONAL_INFORMATION);
+ Either<Map<String, AdditionalInfoParameterDataDefinition>, StorageOperationStatus> dataFromDerived = getDataFromDerived(derivedResources, EdgeLabelEnum.ADDITIONAL_INFORMATION);
if (dataFromDerived.isRight()) {
return dataFromDerived.right().value();
}
@@ -421,7 +439,7 @@ public class NodeTypeOperation extends ToscaElementOperation {
Map<String, AdditionalInfoParameterDataDefinition> addInformation = nodeType.getAdditionalInformation();
if (addInformation != null) {
- addInformationAll.putAll(addInformation);
+ ToscaDataDefinition.mergeDataMaps(addInformationAll, addInformation);
}
if (!addInformationAll.isEmpty()) {
Either<GraphVertex, StorageOperationStatus> assosiateElementToData = assosiateElementToData(nodeTypeVertex, VertexTypeEnum.ADDITIONAL_INFORMATION, EdgeLabelEnum.ADDITIONAL_INFORMATION, addInformationAll);
@@ -434,7 +452,7 @@ public class NodeTypeOperation extends ToscaElementOperation {
private StorageOperationStatus associateCapabilitiesToResource(GraphVertex nodeTypeVertex, NodeType nodeType, List<GraphVertex> derivedResources) {
// Note : currently only one derived supported!!!!
- Either<Map<String, ListCapabilityDataDefinition>, StorageOperationStatus> dataFromDerived = getDataFromDerived(derivedResources, ListCapabilityDataDefinition.class, EdgeLabelEnum.CAPABILITIES);
+ Either<Map<String, ListCapabilityDataDefinition>, StorageOperationStatus> dataFromDerived = getDataFromDerived(derivedResources, EdgeLabelEnum.CAPABILITIES);
if (dataFromDerived.isRight()) {
return dataFromDerived.right().value();
}
@@ -452,9 +470,7 @@ public class NodeTypeOperation extends ToscaElementOperation {
});
});
- for (Entry<String, ListCapabilityDataDefinition> entry : capabilties.entrySet()) {
- capabiltiesAll.merge(entry.getKey(), entry.getValue(), (list1, list2) -> list1.mergeListItemsByName(list2));
- }
+ ToscaDataDefinition.mergeDataMaps(capabiltiesAll, capabilties);
}
if (!capabiltiesAll.isEmpty()) {
Either<GraphVertex, StorageOperationStatus> assosiateElementToData = assosiateElementToData(nodeTypeVertex, VertexTypeEnum.CAPABILTIES, EdgeLabelEnum.CAPABILITIES, capabiltiesAll);
@@ -467,7 +483,7 @@ public class NodeTypeOperation extends ToscaElementOperation {
private StorageOperationStatus associateRequirementsToResource(GraphVertex nodeTypeVertex, NodeType nodeType, List<GraphVertex> derivedResources) {
// Note : currently only one derived supported!!!!
- Either<Map<String, ListRequirementDataDefinition>, StorageOperationStatus> dataFromDerived = getDataFromDerived(derivedResources, ListRequirementDataDefinition.class, EdgeLabelEnum.REQUIREMENTS);
+ Either<Map<String, ListRequirementDataDefinition>, StorageOperationStatus> dataFromDerived = getDataFromDerived(derivedResources, EdgeLabelEnum.REQUIREMENTS);
if (dataFromDerived.isRight()) {
return dataFromDerived.right().value();
}
@@ -485,9 +501,8 @@ public class NodeTypeOperation extends ToscaElementOperation {
});
});
- for (Entry<String, ListRequirementDataDefinition> entry : requirements.entrySet()) {
- requirementsAll.merge(entry.getKey(), entry.getValue(), (list1, list2) -> list1.mergeListItemsByName(list2));
- }
+ ToscaDataDefinition.mergeDataMaps(requirementsAll, requirements);
+
}
if (!requirementsAll.isEmpty()) {
Either<GraphVertex, StorageOperationStatus> assosiateElementToData = assosiateElementToData(nodeTypeVertex, VertexTypeEnum.REQUIREMENTS, EdgeLabelEnum.REQUIREMENTS, requirementsAll);
@@ -500,19 +515,19 @@ public class NodeTypeOperation extends ToscaElementOperation {
private StorageOperationStatus associateAttributesToResource(GraphVertex nodeTypeVertex, NodeType nodeType, List<GraphVertex> derivedResources) {
// Note : currently only one derived supported!!!!
- Either<Map<String, AttributeDataDefinition>, StorageOperationStatus> dataFromDerived = getDataFromDerived(derivedResources, AttributeDataDefinition.class, EdgeLabelEnum.ATTRIBUTES);
+ Either<Map<String, PropertyDataDefinition>, StorageOperationStatus> dataFromDerived = getDataFromDerived(derivedResources, EdgeLabelEnum.ATTRIBUTES);
if (dataFromDerived.isRight()) {
return dataFromDerived.right().value();
}
- Map<String, AttributeDataDefinition> attributesAll = dataFromDerived.left().value();
+ Map<String, PropertyDataDefinition> attributesAll = dataFromDerived.left().value();
- Map<String, AttributeDataDefinition> attributes = nodeType.getAttributes();
+ Map<String, PropertyDataDefinition> attributes = nodeType.getAttributes();
if (attributes != null) {
attributes.values().stream().filter(p -> p.getUniqueId() == null).forEach(p -> {
String uid = UniqueIdBuilder.buildAttributeUid(nodeTypeVertex.getUniqueId(), p.getName());
p.setUniqueId(uid);
});
- attributesAll.putAll(attributes);
+ ToscaDataDefinition.mergeDataMaps(attributesAll, attributes);
}
if (!attributesAll.isEmpty()) {
Either<GraphVertex, StorageOperationStatus> assosiateElementToData = assosiateElementToData(nodeTypeVertex, VertexTypeEnum.ATTRIBUTES, EdgeLabelEnum.ATTRIBUTES, attributesAll);
@@ -526,7 +541,7 @@ public class NodeTypeOperation extends ToscaElementOperation {
// TODO get from derived
private StorageOperationStatus associateCapabilitiesPropertiesToResource(GraphVertex nodeTypeVertex, NodeType nodeType, List<GraphVertex> derivedResources) {
// // Note : currently only one derived supported!!!!
- Either<Map<String, MapPropertiesDataDefinition>, StorageOperationStatus> dataFromDerived = getDataFromDerived(derivedResources, MapPropertiesDataDefinition.class, EdgeLabelEnum.CAPABILITIES_PROPERTIES);
+ Either<Map<String, MapPropertiesDataDefinition>, StorageOperationStatus> dataFromDerived = getDataFromDerived(derivedResources, EdgeLabelEnum.CAPABILITIES_PROPERTIES);
if (dataFromDerived.isRight()) {
return dataFromDerived.right().value();
}
@@ -542,9 +557,9 @@ public class NodeTypeOperation extends ToscaElementOperation {
});
}
});
- propertiesAll.putAll(capabiltiesProps);
+ ToscaDataDefinition.mergeDataMaps(propertiesAll, capabiltiesProps);
}
- if (propertiesAll != null) {
+ if (!propertiesAll.isEmpty()) {
Either<GraphVertex, StorageOperationStatus> assosiateElementToData = assosiateElementToData(nodeTypeVertex, VertexTypeEnum.CAPABILITIES_PROPERTIES, EdgeLabelEnum.CAPABILITIES_PROPERTIES, propertiesAll);
if (assosiateElementToData.isRight()) {
return assosiateElementToData.right().value();
@@ -657,7 +672,7 @@ public class NodeTypeOperation extends ToscaElementOperation {
protected <T extends ToscaElement> StorageOperationStatus updateDerived(T toscaElementToUpdate, GraphVertex nodeTypeV) {
NodeType nodeType = (NodeType) toscaElementToUpdate;
- List<GraphVertex> derivedResources = null;
+ List<GraphVertex> derivedResources = new ArrayList<>();
List<String> derivedFromResources = nodeType.getDerivedFrom();
@@ -691,7 +706,8 @@ public class NodeTypeOperation extends ToscaElementOperation {
}
// must be only one
GraphVertex newDerived = getParentResources.left().value().get(0);
- StorageOperationStatus updateStatus = updateDataFromNewDerived(newDerived, nodeTypeV);
+ derivedResources.add(newDerived);
+ StorageOperationStatus updateStatus = updateDataFromNewDerived(derivedResources, nodeTypeV, (NodeType)toscaElementToUpdate);
if (updateStatus != StorageOperationStatus.OK) {
CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to update data for {} from new derived {} ", nodeTypeV.getUniqueId(), newDerived.getUniqueId(), updateStatus);
return updateStatus;
@@ -704,44 +720,70 @@ public class NodeTypeOperation extends ToscaElementOperation {
return DaoStatusConverter.convertTitanStatusToStorageStatus(deleteError);
}
- titanDao.createEdge(nodeTypeV, newDerived, EdgeLabelEnum.DERIVED_FROM, null);
+ titanDao.createEdge(nodeTypeV, newDerived, EdgeLabelEnum.DERIVED_FROM, new HashMap<>());
}
}
return StorageOperationStatus.OK;
}
+
+ private StorageOperationStatus associateDerivedDataByType(EdgeLabelEnum edgeLabel, GraphVertex nodeTypeV, NodeType nodeToUpdate, List<GraphVertex> newDerived) {
+
+ switch (edgeLabel) {
+ case CAPABILITIES:
+ return associateCapabilitiesToResource(nodeTypeV, nodeToUpdate, newDerived);
+ case REQUIREMENTS:
+ return associateRequirementsToResource(nodeTypeV, nodeToUpdate, newDerived);
+ case PROPERTIES:
+ return associatePropertiesToResource(nodeTypeV, nodeToUpdate, newDerived);
+ case ATTRIBUTES:
+ return associateAttributesToResource(nodeTypeV, nodeToUpdate, newDerived);
+ case ADDITIONAL_INFORMATION:
+ return addAdditionalInformationToResource(nodeTypeV, nodeToUpdate, newDerived);
+ case CAPABILITIES_PROPERTIES:
+ return associateCapabilitiesPropertiesToResource(nodeTypeV, nodeToUpdate, newDerived);
+ default:
+ return StorageOperationStatus.OK;
+ }
+
+ }
- private StorageOperationStatus updateDataFromNewDerived(GraphVertex newDerived, GraphVertex nodeTypeV) {
- StorageOperationStatus status = updateDataByType(newDerived, nodeTypeV, EdgeLabelEnum.CAPABILITIES, CapabilityDataDefinition.class);
+ private StorageOperationStatus updateDataFromNewDerived(List<GraphVertex> newDerived, GraphVertex nodeTypeV, NodeType nodeToUpdate) {
+
+ StorageOperationStatus status = updateDataByType(newDerived, nodeTypeV, EdgeLabelEnum.CAPABILITIES, nodeToUpdate);
if (status != StorageOperationStatus.OK) {
return status;
}
- status = updateDataByType(newDerived, nodeTypeV, EdgeLabelEnum.REQUIREMENTS, RequirementDefinition.class);
+
+ status = updateDataByType(newDerived, nodeTypeV, EdgeLabelEnum.REQUIREMENTS, nodeToUpdate);
if (status != StorageOperationStatus.OK) {
return status;
}
- status = updateDataByType(newDerived, nodeTypeV, EdgeLabelEnum.PROPERTIES, PropertyDataDefinition.class);
+
+ status = updateDataByType(newDerived, nodeTypeV, EdgeLabelEnum.PROPERTIES, nodeToUpdate);
if (status != StorageOperationStatus.OK) {
return status;
}
- status = updateDataByType(newDerived, nodeTypeV, EdgeLabelEnum.ATTRIBUTES, AttributeDataDefinition.class);
+
+ status = updateDataByType(newDerived, nodeTypeV, EdgeLabelEnum.ATTRIBUTES, nodeToUpdate);
+ if (status != StorageOperationStatus.OK) {
+ return status;
+ }
+
+ status = updateDataByType(newDerived, nodeTypeV,EdgeLabelEnum.CAPABILITIES_PROPERTIES, nodeToUpdate);
if (status != StorageOperationStatus.OK) {
return status;
}
- // TODO
- // status = updateDataByType(newDerived, nodeTypeV,
- // EdgeLabelEnum.CAPABILITIES_PROPERTIES, capa);
- // if ( status != StorageOperationStatus.OK){
- // return status;
- // }
- status = updateDataByType(newDerived, nodeTypeV, EdgeLabelEnum.ADDITIONAL_INFORMATION, AdditionalInfoParameterDataDefinition.class);
+ status = updateDataByType(newDerived, nodeTypeV, EdgeLabelEnum.ADDITIONAL_INFORMATION, nodeToUpdate);
return status;
}
- private <T extends ToscaDataDefinition> StorageOperationStatus updateDataByType(GraphVertex newDerived, GraphVertex nodeTypeV, EdgeLabelEnum label, Class<T> clazz) {
+ private <T extends ToscaDataDefinition> StorageOperationStatus updateDataByType(List<GraphVertex> newDerivedList, GraphVertex nodeTypeV, EdgeLabelEnum label, NodeType nodeElement) {
log.debug("Update data from derived for element {} type {}", nodeTypeV.getUniqueId(), label);
Either<GraphVertex, TitanOperationStatus> dataFromGraph = getDataVertex(nodeTypeV, label);
if (dataFromGraph.isRight()) {
+ if (TitanOperationStatus.NOT_FOUND == dataFromGraph.right().value())
+ return associateDerivedDataByType(label, nodeTypeV, nodeElement, newDerivedList);
return DaoStatusConverter.convertTitanStatusToStorageStatus(dataFromGraph.right().value());
}
GraphVertex dataV = dataFromGraph.left().value();
@@ -749,16 +791,19 @@ public class NodeTypeOperation extends ToscaElementOperation {
Map<String, T> mapFromGraph = (Map<String, T>) dataV.getJson();
mapFromGraph.entrySet().removeIf(e -> e.getValue().getOwnerId() != null);
- List<GraphVertex> derivedList = new ArrayList<>();
- derivedList.add(newDerived);
-
- Either<Map<String, T>, StorageOperationStatus> dataFromDerived = getDataFromDerived(derivedList, clazz, EdgeLabelEnum.CAPABILITIES);
+
+ Either<Map<String, T>, StorageOperationStatus> dataFromDerived = getDataFromDerived(newDerivedList, label);
if (dataFromDerived.isRight()) {
return dataFromDerived.right().value();
}
- Map<String, T> capabiltiesAll = dataFromDerived.left().value();
- capabiltiesAll.putAll(mapFromGraph);
-
+ Map<String, T> dataFromDerivedAll = dataFromDerived.left().value();
+
+ Either<Map<String, T>, String> merged = ToscaDataDefinition.mergeDataMaps(dataFromDerivedAll, mapFromGraph);
+ if(merged.isRight()){
+ log.debug("property {} cannot be overriden", merged.right().value());
+ return StorageOperationStatus.INVALID_PROPERTY;
+ }
+ dataV.setJson(dataFromDerivedAll);
Either<GraphVertex, TitanOperationStatus> updateDataV = updateOrCopyOnUpdate(dataV, nodeTypeV, label);
if (updateDataV.isRight()) {
return DaoStatusConverter.convertTitanStatusToStorageStatus(updateDataV.right().value());
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/TopologyTemplateOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/TopologyTemplateOperation.java
index 62d04edf4f..0389c2739a 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/TopologyTemplateOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/TopologyTemplateOperation.java
@@ -6,6 +6,8 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Optional;
+import java.util.Map.Entry;
import org.apache.tinkerpop.gremlin.structure.Direction;
import org.apache.tinkerpop.gremlin.structure.Edge;
@@ -20,7 +22,6 @@ import org.openecomp.sdc.be.datatypes.elements.ComponentInstanceDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.CompositionDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.GroupDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.MapArtifactDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.MapAttributesDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.MapCapabiltyProperty;
import org.openecomp.sdc.be.datatypes.elements.MapGroupsDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.MapListCapabiltyDataDefinition;
@@ -31,6 +32,7 @@ import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
+import org.openecomp.sdc.be.model.ComponentInstanceProperty;
import org.openecomp.sdc.be.model.ComponentParametersView;
import org.openecomp.sdc.be.model.DistributionStatusEnum;
import org.openecomp.sdc.be.model.User;
@@ -117,6 +119,12 @@ public class TopologyTemplateOperation extends ToscaElementOperation {
result = Either.right(associateInstInputs);
return result;
}
+ StorageOperationStatus associateInstGroups = associateInstGroupsToComponent(topologyTemplateVertex, topologyTemplate);
+ if (associateInstProperties != StorageOperationStatus.OK) {
+ result = Either.right(associateInstInputs);
+ return result;
+ }
+
StorageOperationStatus associateRequirements = associateRequirementsToResource(topologyTemplateVertex, topologyTemplate);
if (associateRequirements != StorageOperationStatus.OK) {
result = Either.right(associateRequirements);
@@ -251,6 +259,12 @@ public class TopologyTemplateOperation extends ToscaElementOperation {
Map<String, MapPropertiesDataDefinition> instProps = topologyTemplate.getInstInputs();
return associateInstInputsToComponent(nodeTypeVertex, instProps);
}
+
+ public StorageOperationStatus associateInstGroupsToComponent(GraphVertex nodeTypeVertex, TopologyTemplate topologyTemplate) {
+ Map<String, MapGroupsDataDefinition> instGroups = topologyTemplate.getInstGroups();
+ return associateInstGroupsToComponent(nodeTypeVertex, instGroups);
+ }
+
public StorageOperationStatus associateInstPropertiesToComponent(GraphVertex nodeTypeVertex, Map<String, MapPropertiesDataDefinition> instProps) {
if (instProps != null && !instProps.isEmpty()) {
@@ -271,21 +285,18 @@ public class TopologyTemplateOperation extends ToscaElementOperation {
}
return StorageOperationStatus.OK;
}
-
- public StorageOperationStatus addInstInputsToComponent(GraphVertex nodeTypeVertex, Map<String, MapPropertiesDataDefinition> instInputs) {
-
- if (instInputs != null && !instInputs.isEmpty()) {
- instInputs.entrySet().forEach(i -> {
- StorageOperationStatus status = addToscaDataDeepElementsBlockToToscaElement(nodeTypeVertex, EdgeLabelEnum.INST_INPUTS, VertexTypeEnum.INST_INPUTS, i.getValue(), i.getKey());
- if (status != StorageOperationStatus.OK) {
- return;
- }
- });
+
+ public StorageOperationStatus associateInstGroupsToComponent(GraphVertex nodeTypeVertex, Map<String, MapGroupsDataDefinition> instGroups) {
+ if (instGroups != null && !instGroups.isEmpty()) {
+ Either<GraphVertex, StorageOperationStatus> assosiateElementToData = assosiateElementToData(nodeTypeVertex, VertexTypeEnum.INST_GROUPS, EdgeLabelEnum.INST_GROUPS, instGroups);
+ if (assosiateElementToData.isRight()) {
+ return assosiateElementToData.right().value();
+ }
}
-
return StorageOperationStatus.OK;
}
+
public StorageOperationStatus deleteInstInputsToComponent(GraphVertex nodeTypeVertex, Map<String, MapPropertiesDataDefinition> instInputs) {
if (instInputs != null && !instInputs.isEmpty()) {
@@ -361,11 +372,11 @@ public class TopologyTemplateOperation extends ToscaElementOperation {
}
private StorageOperationStatus associateInstAttributesToComponent(GraphVertex nodeTypeVertex, TopologyTemplate topologyTemplate) {
- Map<String, MapAttributesDataDefinition> instAttr = topologyTemplate.getInstAttributes();
+ Map<String, MapPropertiesDataDefinition> instAttr = topologyTemplate.getInstAttributes();
return associateInstAttributeToComponent(nodeTypeVertex, instAttr);
}
- public StorageOperationStatus associateInstAttributeToComponent(GraphVertex nodeTypeVertex, Map<String, MapAttributesDataDefinition> instAttr) {
+ public StorageOperationStatus associateInstAttributeToComponent(GraphVertex nodeTypeVertex, Map<String, MapPropertiesDataDefinition> instAttr) {
if (instAttr != null && !instAttr.isEmpty()) {
Either<GraphVertex, StorageOperationStatus> assosiateElementToData = assosiateElementToData(nodeTypeVertex, VertexTypeEnum.INST_ATTRIBUTES, EdgeLabelEnum.INST_ATTRIBUTES, instAttr);
if (assosiateElementToData.isRight()) {
@@ -953,6 +964,7 @@ public class TopologyTemplateOperation extends ToscaElementOperation {
if (instances != null && instances.getComponentInstances() != null && !instances.getComponentInstances().isEmpty()) {
for (ComponentInstanceDataDefinition ci : instances.getComponentInstances().values()) {
if (ci.getComponentUid().equals(elementV.getUniqueId())) {
+ log.debug("The resource {} failed to delete cause in use as component instance UniqueID = {} in {} with UniqueID {}", elementV.getUniqueId(), ci.getUniqueId(), containerV.getType(), containerV.getUniqueId());
return true;
}
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaElementLifecycleOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaElementLifecycleOperation.java
index be995089a9..1397e81f9c 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaElementLifecycleOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaElementLifecycleOperation.java
@@ -1,10 +1,13 @@
package org.openecomp.sdc.be.model.jsontitan.operations;
+import java.util.ArrayList;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Optional;
+import java.util.Map.Entry;
import java.util.stream.Collectors;
import org.apache.commons.collections.CollectionUtils;
@@ -14,7 +17,9 @@ import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.tinkerpop.gremlin.structure.Direction;
import org.apache.tinkerpop.gremlin.structure.Edge;
import org.apache.tinkerpop.gremlin.structure.Vertex;
+
import org.openecomp.sdc.be.config.ConfigurationManager;
+import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
import org.openecomp.sdc.be.dao.jsongraph.types.EdgeLabelEnum;
import org.openecomp.sdc.be.dao.jsongraph.types.EdgePropertyEnum;
@@ -24,20 +29,39 @@ import org.openecomp.sdc.be.dao.jsongraph.utils.IdBuilderUtils;
import org.openecomp.sdc.be.dao.jsongraph.utils.JsonParserUtils;
import org.openecomp.sdc.be.dao.neo4j.GraphEdgeLabels;
import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
+import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.ComponentInstanceDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.CompositionDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.GroupDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.GroupInstanceDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.MapArtifactDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.MapDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.MapGroupsDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.MapPropertiesDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
+import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
+import org.openecomp.sdc.be.datatypes.enums.OriginTypeEnum;
import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
+import org.openecomp.sdc.be.model.ArtifactDefinition;
import org.openecomp.sdc.be.model.ComponentParametersView;
import org.openecomp.sdc.be.model.DistributionStatusEnum;
+import org.openecomp.sdc.be.model.GroupDefinition;
import org.openecomp.sdc.be.model.LifecycleStateEnum;
import org.openecomp.sdc.be.model.User;
+import org.openecomp.sdc.be.model.jsontitan.datamodel.TopologyTemplate;
import org.openecomp.sdc.be.model.jsontitan.datamodel.ToscaElement;
+import org.openecomp.sdc.be.model.jsontitan.datamodel.ToscaElementTypeEnum;
+import org.openecomp.sdc.be.model.jsontitan.enums.JsonConstantKeysEnum;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
import org.openecomp.sdc.be.model.operations.impl.DaoStatusConverter;
import org.openecomp.sdc.be.model.operations.impl.UniqueIdBuilder;
+import org.openecomp.sdc.common.api.ArtifactTypeEnum;
import org.openecomp.sdc.common.jsongraph.util.CommonUtility;
import org.openecomp.sdc.common.jsongraph.util.CommonUtility.LogLevelEnum;
+import org.openecomp.sdc.exception.ResponseFormat;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -46,20 +70,19 @@ import fj.data.Either;
@org.springframework.stereotype.Component("tosca-element-lifecycle-operation")
/**
- * Allows to perform lifecycle operations:
- * checkin, checkout, submit for testing, start certification and certification process
- * for tosca element
+ * Allows to perform lifecycle operations: checkin, checkout, submit for testing, start certification and certification process for tosca element
*/
public class ToscaElementLifecycleOperation extends BaseOperation {
-
+
private static final String FAILED_TO_GET_VERTICES = "Failed to get vertices by id {}. Status is {}. ";
public static final String VERSION_DELIMETER = ".";
public static final String VERSION_DELIMETER_REGEXP = "\\.";
-
+
private static Logger logger = LoggerFactory.getLogger(ToscaElementLifecycleOperation.class.getName());
/**
- * Performs changing a lifecycle state of tosca element from "checked out" or "ready for certification" to "checked in"
+ * Performs changing a lifecycle state of tosca element from "checked out" or "ready for certification" to "checked in"
+ *
* @param currState
* @param toscaElementId
* @param modifierId
@@ -72,109 +95,115 @@ public class ToscaElementLifecycleOperation extends BaseOperation {
Map<String, GraphVertex> vertices = null;
ToscaElementOperation operation;
try {
- Either<Map<String, GraphVertex>, TitanOperationStatus> getVerticesRes =
- titanDao.getVerticesByUniqueIdAndParseFlag(prepareParametersToGetVerticesForCheckin(toscaElementId, modifierId, ownerId));
- if(getVerticesRes.isRight()){
+ Either<Map<String, GraphVertex>, TitanOperationStatus> getVerticesRes = titanDao.getVerticesByUniqueIdAndParseFlag(prepareParametersToGetVerticesForCheckin(toscaElementId, modifierId, ownerId));
+ if (getVerticesRes.isRight()) {
CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, FAILED_TO_GET_VERTICES, toscaElementId);
updateResult = Either.right(DaoStatusConverter.convertTitanStatusToStorageStatus(getVerticesRes.right().value()));
} else {
vertices = getVerticesRes.left().value();
updateResult = checkinToscaELement(currState, vertices.get(toscaElementId), vertices.get(ownerId), vertices.get(modifierId), LifecycleStateEnum.NOT_CERTIFIED_CHECKIN);
}
- if(updateResult.isLeft()) {
+ if (updateResult.isLeft()) {
ComponentParametersView componentParametersView = buildComponentParametersViewAfterCheckin();
operation = getToscaElementOperation(vertices.get(toscaElementId).getLabel());
result = operation.getToscaElement(updateResult.left().value().getUniqueId(), componentParametersView);
- if(result.isRight()){
- CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG,"Failed to get updated tosca element {}. Status is {}", toscaElementId, result.right().value());
+ if (result.isRight()) {
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to get updated tosca element {}. Status is {}", toscaElementId, result.right().value());
}
} else {
result = Either.right(updateResult.right().value());
}
- } catch (Exception e){
- CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG,"Exception occured during checkin of tosca element {}. {} ", toscaElementId, e.getMessage());
+ } catch (Exception e) {
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Exception occured during checkin of tosca element {}. {} ", toscaElementId, e.getMessage());
}
return result;
}
+
/**
* Returns vertex presenting owner of tosca element specified by uniqueId
+ *
* @param toscaElement
* @return
*/
public Either<User, StorageOperationStatus> getToscaElementOwner(String toscaElementId) {
- Either<User, StorageOperationStatus> result = null;
+ Either<User, StorageOperationStatus> result = null;
GraphVertex toscaElement = null;
Either<GraphVertex, TitanOperationStatus> getToscaElementRes = titanDao.getVertexById(toscaElementId, JsonParseFlagEnum.NoParse);
- if(getToscaElementRes.isRight()){
+ if (getToscaElementRes.isRight()) {
result = Either.right(DaoStatusConverter.convertTitanStatusToStorageStatus(getToscaElementRes.right().value()));
}
- if(result == null){
+ if (result == null) {
toscaElement = getToscaElementRes.left().value();
Iterator<Vertex> vertices = toscaElement.getVertex().vertices(Direction.IN, EdgeLabelEnum.STATE.name());
- if(vertices == null || !vertices.hasNext()){
+ if (vertices == null || !vertices.hasNext()) {
result = Either.right(StorageOperationStatus.NOT_FOUND);
} else {
result = Either.left(convertToUser(vertices.next()));
}
}
- return result;
- }
+ return result;
+ }
+
/**
* Returns vertex presenting owner of tosca element specified by uniqueId
+ *
* @param toscaElement
* @return
*/
public Either<User, StorageOperationStatus> getToscaElementOwner(GraphVertex toscaElement) {
- Either<User, StorageOperationStatus> result = null;
+ Either<User, StorageOperationStatus> result = null;
Iterator<Vertex> vertices = toscaElement.getVertex().vertices(Direction.IN, EdgeLabelEnum.STATE.name());
- if(vertices == null || !vertices.hasNext()){
+ if (vertices == null || !vertices.hasNext()) {
result = Either.right(StorageOperationStatus.NOT_FOUND);
} else {
result = Either.left(convertToUser(vertices.next()));
}
- return result;
- }
+ return result;
+ }
-/**
- * Performs checkout of a tosca element
- * @param toscaElementId
- * @param modifierId
- * @param ownerId
- * @param currState
- * @return
- */
+ /**
+ * Performs checkout of a tosca element
+ *
+ * @param toscaElementId
+ * @param modifierId
+ * @param ownerId
+ * @param currState
+ * @return
+ */
public Either<ToscaElement, StorageOperationStatus> checkoutToscaElement(String toscaElementId, String modifierId, String ownerId) {
Either<ToscaElement, StorageOperationStatus> result = null;
Map<String, GraphVertex> vertices = null;
- try{
- Either<Map<String, GraphVertex>, TitanOperationStatus> getVerticesRes =
- titanDao.getVerticesByUniqueIdAndParseFlag(prepareParametersToGetVerticesForCheckout(toscaElementId, modifierId, ownerId));
- if(getVerticesRes.isRight()){
+ try {
+ Either<Map<String, GraphVertex>, TitanOperationStatus> getVerticesRes = titanDao.getVerticesByUniqueIdAndParseFlag(prepareParametersToGetVerticesForCheckout(toscaElementId, modifierId, ownerId));
+ if (getVerticesRes.isRight()) {
CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, FAILED_TO_GET_VERTICES, toscaElementId);
result = Either.right(DaoStatusConverter.convertTitanStatusToStorageStatus(getVerticesRes.right().value()));
}
- if(result == null){
+ if (result == null) {
vertices = getVerticesRes.left().value();
// update previous component if not certified
StorageOperationStatus status = updatePreviousVersion(vertices.get(toscaElementId), vertices.get(ownerId));
- if(status != StorageOperationStatus.OK){
+ if (status != StorageOperationStatus.OK) {
CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to update vertex with id {} . Status is {}. ", status);
result = Either.right(status);
}
}
- if(result == null){
+ if (result == null) {
result = cloneToscaElementForCheckout(vertices.get(toscaElementId), vertices.get(modifierId));
if (result.isRight()) {
- CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG,"Failed to checkout tosca element {}. Status is {} ", toscaElementId, result.right().value());
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to checkout tosca element {}. Status is {} ", toscaElementId, result.right().value());
}
+
}
- } catch (Exception e){
- CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG,"Exception occured during checkout tosca element {}. {}", toscaElementId, e.getMessage());
+ } catch (Exception e) {
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Exception occured during checkout tosca element {}. {}", toscaElementId, e.getMessage());
}
return result;
}
+
/**
* Performs undo checkout for tosca element
+ *
* @param toscaElementId
* @return
*/
@@ -185,44 +214,45 @@ public class ToscaElementLifecycleOperation extends BaseOperation {
ToscaElementOperation operation;
try {
getToscaElementRes = titanDao.getVertexById(toscaElementId, JsonParseFlagEnum.ParseMetadata);
- if(getToscaElementRes.isRight()){
+ if (getToscaElementRes.isRight()) {
CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, FAILED_TO_GET_VERTICES, toscaElementId);
result = Either.right(DaoStatusConverter.convertTitanStatusToStorageStatus(getToscaElementRes.right().value()));
}
- if(result == null && hasPreviousVersion(getToscaElementRes.left().value())){
+ if (result == null && hasPreviousVersion(getToscaElementRes.left().value())) {
// find previous version
nextVersionComponentIter = getToscaElementRes.left().value().getVertex().edges(Direction.IN, EdgeLabelEnum.VERSION.name());
- if(nextVersionComponentIter == null || !nextVersionComponentIter.hasNext()){
- CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to fetch previous version of tosca element with name {}. ",
- getToscaElementRes.left().value().getMetadataProperty(GraphPropertyEnum.NORMALIZED_NAME).toString());
- result = Either.right(StorageOperationStatus.NOT_FOUND);
+ if (nextVersionComponentIter == null || !nextVersionComponentIter.hasNext()) {
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to fetch previous version of tosca element with name {}. ", getToscaElementRes.left().value().getMetadataProperty(GraphPropertyEnum.NORMALIZED_NAME).toString());
+ result = Either.right(StorageOperationStatus.NOT_FOUND);
}
- if(result == null){
+ if (result == null) {
StorageOperationStatus updateOldResourceResult = updateOldToscaElementBeforeUndoCheckout(nextVersionComponentIter.next().outVertex());
if (updateOldResourceResult != StorageOperationStatus.OK) {
result = Either.right(updateOldResourceResult);
}
}
}
- if(result == null){
+ if (result == null) {
operation = getToscaElementOperation(getToscaElementRes.left().value().getLabel());
result = operation.deleteToscaElement(getToscaElementRes.left().value());
}
- } catch(Exception e){
- CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG,"Exception occured during undo checkout tosca element {}. {}", toscaElementId, e.getMessage());
+ } catch (Exception e) {
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Exception occured during undo checkout tosca element {}. {}", toscaElementId, e.getMessage());
}
- return result;
+ return result;
}
-
+
private boolean hasPreviousVersion(GraphVertex toscaElementVertex) {
boolean hasPreviousVersion = true;
String version = (String) toscaElementVertex.getMetadataProperty(GraphPropertyEnum.VERSION);
- if(StringUtils.isEmpty(version) || version.equals("0.1"))
+ if (StringUtils.isEmpty(version) || version.equals("0.1"))
hasPreviousVersion = false;
return hasPreviousVersion;
}
+
/**
* Performs request certification for tosca element
+ *
* @param toscaElementId
* @param modifierId
* @param ownerId
@@ -235,49 +265,48 @@ public class ToscaElementLifecycleOperation extends BaseOperation {
GraphVertex modifier = null;
GraphVertex owner;
try {
- Either<Map<String, GraphVertex>, TitanOperationStatus> getVerticesRes =
- titanDao.getVerticesByUniqueIdAndParseFlag(prepareParametersToGetVerticesForRequestCertification(toscaElementId, modifierId, ownerId));
- if(getVerticesRes.isRight()){
+ Either<Map<String, GraphVertex>, TitanOperationStatus> getVerticesRes = titanDao.getVerticesByUniqueIdAndParseFlag(prepareParametersToGetVerticesForRequestCertification(toscaElementId, modifierId, ownerId));
+ if (getVerticesRes.isRight()) {
CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, FAILED_TO_GET_VERTICES, toscaElementId);
result = Either.right(DaoStatusConverter.convertTitanStatusToStorageStatus(getVerticesRes.right().value()));
}
- if(result == null){
+ if (result == null) {
toscaElement = getVerticesRes.left().value().get(toscaElementId);
modifier = getVerticesRes.left().value().get(modifierId);
owner = getVerticesRes.left().value().get(ownerId);
-
+
StorageOperationStatus status = handleRelationsUponRequestForCertification(toscaElement, modifier, owner);
- if(status != StorageOperationStatus.OK){
- CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG,"Failed to handle relations on certification request for tosca element {}. Status is {}. ",
- toscaElement.getUniqueId(), status);
+ if (status != StorageOperationStatus.OK) {
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to handle relations on certification request for tosca element {}. Status is {}. ", toscaElement.getUniqueId(), status);
}
}
- if(result == null){
+ if (result == null) {
LifecycleStateEnum nextState = LifecycleStateEnum.READY_FOR_CERTIFICATION;
-
+
toscaElement.addMetadataProperty(GraphPropertyEnum.STATE, nextState.name());
toscaElement.setJsonMetadataField(JsonPresentationFields.LAST_UPDATE_DATE, System.currentTimeMillis());
-
+
resultUpdate = updateToscaElementVertexMetadataPropertiesAndJson(toscaElement);
if (resultUpdate.isRight()) {
- CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG,"Failed to set lifecycle for tosca elememt {} to state {}, error: {}", toscaElement.getUniqueId(), nextState, resultUpdate.right().value());
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to set lifecycle for tosca elememt {} to state {}, error: {}", toscaElement.getUniqueId(), nextState, resultUpdate.right().value());
result = Either.right(resultUpdate.right().value());
}
}
- if(result == null){
+ if (result == null) {
ToscaElementOperation operation = getToscaElementOperation(toscaElement.getLabel());
result = operation.getToscaElement(toscaElement.getUniqueId());
}
return result;
- } catch (Exception e){
- CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG,"Exception occured during request certification tosca element {}. {}", toscaElementId, e.getMessage());
+ } catch (Exception e) {
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Exception occured during request certification tosca element {}. {}", toscaElementId, e.getMessage());
}
return result;
}
-
+
/**
* Starts certification of tosca element
+ *
* @param toscaElementId
* @param modifierId
* @param ownerId
@@ -290,45 +319,43 @@ public class ToscaElementLifecycleOperation extends BaseOperation {
GraphVertex modifier = null;
GraphVertex owner;
try {
- Either<Map<String, GraphVertex>, TitanOperationStatus> getVerticesRes =
- titanDao.getVerticesByUniqueIdAndParseFlag(prepareParametersToGetVerticesForRequestCertification(toscaElementId, modifierId, ownerId));
- if(getVerticesRes.isRight()){
+ Either<Map<String, GraphVertex>, TitanOperationStatus> getVerticesRes = titanDao.getVerticesByUniqueIdAndParseFlag(prepareParametersToGetVerticesForRequestCertification(toscaElementId, modifierId, ownerId));
+ if (getVerticesRes.isRight()) {
CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, FAILED_TO_GET_VERTICES, toscaElementId);
result = Either.right(DaoStatusConverter.convertTitanStatusToStorageStatus(getVerticesRes.right().value()));
}
- if(result == null){
+ if (result == null) {
toscaElement = getVerticesRes.left().value().get(toscaElementId);
modifier = getVerticesRes.left().value().get(modifierId);
owner = getVerticesRes.left().value().get(ownerId);
-
+
StorageOperationStatus status = handleRelationsUponCertification(toscaElement, modifier, owner);
- if(status != StorageOperationStatus.OK){
- CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG,"Failed to handle relations during certification of tosca element {}. Status is {}. ",
- toscaElement.getUniqueId(), status);
+ if (status != StorageOperationStatus.OK) {
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to handle relations during certification of tosca element {}. Status is {}. ", toscaElement.getUniqueId(), status);
}
}
- if(result == null){
+ if (result == null) {
LifecycleStateEnum nextState = LifecycleStateEnum.CERTIFICATION_IN_PROGRESS;
-
+
toscaElement.addMetadataProperty(GraphPropertyEnum.STATE, nextState.name());
toscaElement.setJsonMetadataField(JsonPresentationFields.LAST_UPDATE_DATE, System.currentTimeMillis());
-
+
resultUpdate = updateToscaElementVertexMetadataPropertiesAndJson(toscaElement);
if (resultUpdate.isRight()) {
- CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG,"Couldn't set lifecycle for component {} to state {}, error: {}", toscaElement.getUniqueId(), nextState, resultUpdate.right().value());
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Couldn't set lifecycle for component {} to state {}, error: {}", toscaElement.getUniqueId(), nextState, resultUpdate.right().value());
result = Either.right(resultUpdate.right().value());
}
}
- if(result == null){
+ if (result == null) {
ToscaElementOperation operation = getToscaElementOperation(toscaElement.getLabel());
result = operation.getToscaElement(toscaElement.getUniqueId());
}
- } catch (Exception e){
- CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG,"Exception occured during start certification tosca element {}. {}", toscaElementId, e.getMessage());
+ } catch (Exception e) {
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Exception occured during start certification tosca element {}. {}", toscaElementId, e.getMessage());
}
return result;
}
-
+
public Either<ToscaElement, StorageOperationStatus> certifyToscaElement(String toscaElementId, String modifierId, String ownerId) {
Either<ToscaElement, StorageOperationStatus> result = null;
Either<GraphVertex, StorageOperationStatus> cloneRes = null;
@@ -339,53 +366,52 @@ public class ToscaElementLifecycleOperation extends BaseOperation {
StorageOperationStatus status;
try {
- Either<Map<String, GraphVertex>, TitanOperationStatus> getVerticesRes =
- titanDao.getVerticesByUniqueIdAndParseFlag(prepareParametersToGetVerticesForRequestCertification(toscaElementId, modifierId, ownerId));
- if(getVerticesRes.isRight()){
+ Either<Map<String, GraphVertex>, TitanOperationStatus> getVerticesRes = titanDao.getVerticesByUniqueIdAndParseFlag(prepareParametersToGetVerticesForRequestCertification(toscaElementId, modifierId, ownerId));
+ if (getVerticesRes.isRight()) {
CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, FAILED_TO_GET_VERTICES, toscaElementId);
result = Either.right(DaoStatusConverter.convertTitanStatusToStorageStatus(getVerticesRes.right().value()));
}
- if(result == null){
+ if (result == null) {
toscaElement = getVerticesRes.left().value().get(toscaElementId);
modifier = getVerticesRes.left().value().get(modifierId);
majorVersion = getMajorVersion((String) toscaElement.getMetadataProperty(GraphPropertyEnum.VERSION));
status = handleRelationsOfPreviousToscaElementBeforeCertifying(toscaElement, modifier, majorVersion);
- if(status != StorageOperationStatus.OK){
- CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG,"Failed to handle relations of previous tosca element before certifying {}. Status is {}. ",
- toscaElement.getUniqueId(), status);
+ if (status != StorageOperationStatus.OK) {
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to handle relations of previous tosca element before certifying {}. Status is {}. ", toscaElement.getUniqueId(), status);
}
}
- if(result == null){
+ if (result == null) {
cloneRes = cloneToscaElementForCertify(toscaElement, modifier, majorVersion);
if (cloneRes.isRight()) {
CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to clone tosca element during certification. ");
result = Either.right(cloneRes.right().value());
}
}
- if(result == null){
+ if (result == null) {
certifiedToscaElement = cloneRes.left().value();
status = handleRelationsOfNewestCertifiedToscaElement(toscaElement, certifiedToscaElement);
- if(status != StorageOperationStatus.OK){
- CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG,"Failed to handle relations of newest certified tosca element {}. Status is {}. ",
- certifiedToscaElement.getUniqueId(), status);
+ if (status != StorageOperationStatus.OK) {
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to handle relations of newest certified tosca element {}. Status is {}. ", certifiedToscaElement.getUniqueId(), status);
}
}
- if(result == null){
- return getToscaElementOperation(toscaElement.getLabel()).getToscaElement(certifiedToscaElement.getUniqueId());
+ if (result == null) {
+ return getToscaElementOperation(toscaElement.getLabel()).getToscaElement(certifiedToscaElement.getUniqueId());
}
- } catch (Exception e){
- CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG,"Exception occured during certification tosca element {}. {}", toscaElementId, e.getMessage());
+ } catch (Exception e) {
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Exception occured during certification tosca element {}. {}", toscaElementId, e.getMessage());
}
return result;
}
-/**
- * Deletes (marks as deleted) all tosca elements according received name and uuid
- * @param vertexType
- * @param componentType
- * @param componentName
- * @param uuid
- * @return
- */
+
+ /**
+ * Deletes (marks as deleted) all tosca elements according received name and uuid
+ *
+ * @param vertexType
+ * @param componentType
+ * @param componentName
+ * @param uuid
+ * @return
+ */
public Either<Boolean, StorageOperationStatus> deleteOldToscaElementVersions(VertexTypeEnum vertexType, ComponentTypeEnum componentType, String componentName, String uuid) {
Either<Boolean, StorageOperationStatus> result = null;
@@ -395,29 +421,31 @@ public class ToscaElementLifecycleOperation extends BaseOperation {
Map<GraphPropertyEnum, Object> properties = new EnumMap<>(GraphPropertyEnum.class);
properties.put(GraphPropertyEnum.UUID, uuid);
properties.put(GraphPropertyEnum.NAME, componentName);
- Either<List<GraphVertex>, TitanOperationStatus> getToscaElementsRes= titanDao.getByCriteria(vertexType, properties, JsonParseFlagEnum.ParseMetadata);
+ Either<List<GraphVertex>, TitanOperationStatus> getToscaElementsRes = titanDao.getByCriteria(vertexType, properties, JsonParseFlagEnum.ParseMetadata);
if (getToscaElementsRes.isRight()) {
result = Either.right(DaoStatusConverter.convertTitanStatusToStorageStatus(getToscaElementsRes.right().value()));
}
- if(result == null){
+ if (result == null) {
result = markToscaElementsAsDeleted(operation, getToscaElementsRes.left().value());
}
- if(result == null){
+ if (result == null) {
result = Either.left(true);
}
- } catch (Exception e){
- CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG,"Exception occured during deleteng all tosca elements by UUID {} and name {}. {} ", uuid, componentName, e.getMessage());
+ } catch (Exception e) {
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Exception occured during deleteng all tosca elements by UUID {} and name {}. {} ", uuid, componentName, e.getMessage());
}
return result;
}
-/**
- * Performs cancelation or failure of certification for received tosca element
- * @param toscaElementId
- * @param modifierId
- * @param ownerId
- * @param nextState
- * @return
- */
+
+ /**
+ * Performs cancelation or failure of certification for received tosca element
+ *
+ * @param toscaElementId
+ * @param modifierId
+ * @param ownerId
+ * @param nextState
+ * @return
+ */
public Either<ToscaElement, StorageOperationStatus> cancelOrFailCertification(String toscaElementId, String modifierId, String ownerId, LifecycleStateEnum nextState) {
Either<ToscaElement, StorageOperationStatus> result = null;
StorageOperationStatus status;
@@ -425,60 +453,56 @@ public class ToscaElementLifecycleOperation extends BaseOperation {
GraphVertex toscaElement = null;
GraphVertex modifier = null;
try {
- Either<Map<String, GraphVertex>, TitanOperationStatus> getVerticesRes =
- titanDao.getVerticesByUniqueIdAndParseFlag(prepareParametersToGetVerticesForRequestCertification(toscaElementId, modifierId, ownerId));
- if(getVerticesRes.isRight()){
+ Either<Map<String, GraphVertex>, TitanOperationStatus> getVerticesRes = titanDao.getVerticesByUniqueIdAndParseFlag(prepareParametersToGetVerticesForRequestCertification(toscaElementId, modifierId, ownerId));
+ if (getVerticesRes.isRight()) {
CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, FAILED_TO_GET_VERTICES, toscaElementId);
result = Either.right(DaoStatusConverter.convertTitanStatusToStorageStatus(getVerticesRes.right().value()));
}
- if(result == null){
+ if (result == null) {
toscaElement = getVerticesRes.left().value().get(toscaElementId);
modifier = getVerticesRes.left().value().get(modifierId);
operation = getToscaElementOperation(toscaElement.getLabel());
toscaElement.setJsonMetadataField(JsonPresentationFields.LAST_UPDATE_DATE, System.currentTimeMillis());
toscaElement.setJsonMetadataField(JsonPresentationFields.USER_ID_LAST_UPDATER, modifier.getUniqueId());
toscaElement.addMetadataProperty(GraphPropertyEnum.STATE, nextState.name());
-
+
Either<GraphVertex, TitanOperationStatus> updateVertexRes = titanDao.updateVertex(toscaElement);
- if(updateVertexRes.isRight()){
+ if (updateVertexRes.isRight()) {
CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to update vertex {} . Status is {}. ", toscaElementId, updateVertexRes.right().value());
result = Either.right(DaoStatusConverter.convertTitanStatusToStorageStatus(updateVertexRes.right().value()));
}
}
- if(result == null){
- // cancel certification process
+ if (result == null) {
+ // cancel certification process
status = handleRelationsUponCancelCertification(toscaElement, nextState);
- if(status != StorageOperationStatus.OK){
- CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG,"Failed to handle relations upon cancel certification {}. Status is {}. ",
- toscaElement.getUniqueId(), status);
+ if (status != StorageOperationStatus.OK) {
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to handle relations upon cancel certification {}. Status is {}. ", toscaElement.getUniqueId(), status);
}
}
- if(result == null){
- // fail certification
+ if (result == null) {
+ // fail certification
status = handleRelationsUponFailCertification(toscaElement, nextState);
- if(status != StorageOperationStatus.OK){
- CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG,"Failed to handle relations upon fail certification {}. Status is {}. ",
- toscaElement.getUniqueId(), status);
+ if (status != StorageOperationStatus.OK) {
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to handle relations upon fail certification {}. Status is {}. ", toscaElement.getUniqueId(), status);
}
- }
+ }
if (result == null) {
result = operation.getToscaElement(toscaElementId);
}
- } catch (Exception e){
- CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG,"Exception occured during cancel or fail certification of tosca element {}. {}. ",
- toscaElementId, e.getMessage());
+ } catch (Exception e) {
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Exception occured during cancel or fail certification of tosca element {}. {}. ", toscaElementId, e.getMessage());
}
return result;
}
-
+
public Either<GraphVertex, TitanOperationStatus> findUser(String userId) {
return findUserVertex(userId);
}
-
- private Either<Boolean, StorageOperationStatus> markToscaElementsAsDeleted(ToscaElementOperation operation, List<GraphVertex> toscaElements) {
+
+ private Either<Boolean, StorageOperationStatus> markToscaElementsAsDeleted(ToscaElementOperation operation, List<GraphVertex> toscaElements) {
Either<Boolean, StorageOperationStatus> result = Either.left(true);
for (GraphVertex resourceToDelete : toscaElements) {
- if(!((String)resourceToDelete.getJsonMetadataField(JsonPresentationFields.LIFECYCLE_STATE)).equals(LifecycleStateEnum.CERTIFIED.name())){
+ if (!((String) resourceToDelete.getJsonMetadataField(JsonPresentationFields.LIFECYCLE_STATE)).equals(LifecycleStateEnum.CERTIFIED.name())) {
Either<GraphVertex, StorageOperationStatus> deleteElementRes = operation.markComponentToDelete(resourceToDelete);
if (deleteElementRes.isRight()) {
CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to delete tosca element {}. Status is {}. ", resourceToDelete.getUniqueId(), deleteElementRes.right().value());
@@ -489,7 +513,6 @@ public class ToscaElementLifecycleOperation extends BaseOperation {
}
return result;
}
-
private StorageOperationStatus handleRelationsOfNewestCertifiedToscaElement(GraphVertex toscaElement, GraphVertex certifiedToscaElement) {
StorageOperationStatus result = null;
@@ -498,46 +521,53 @@ public class ToscaElementLifecycleOperation extends BaseOperation {
// add rfc relation to preserve follower information
// get user of certification request
certReqUserEdgeIter = toscaElement.getVertex().edges(Direction.IN, GraphEdgeLabels.LAST_STATE.name());
- if(certReqUserEdgeIter == null || !certReqUserEdgeIter.hasNext()){
+ if (certReqUserEdgeIter == null || !certReqUserEdgeIter.hasNext()) {
CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to find rfc relation during certification clone. ");
result = StorageOperationStatus.NOT_FOUND;
}
+ if (result == null) {
+ TitanOperationStatus createVersionEdgeStatus = titanDao.createEdge(toscaElement, certifiedToscaElement, EdgeLabelEnum.VERSION, new HashMap<>());
+ if (createVersionEdgeStatus != TitanOperationStatus.OK) {
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to create version edge from last element {} to new certified element {}. status=", toscaElement.getUniqueId(),certifiedToscaElement.getUniqueId(), createVersionEdgeStatus);
+ result = DaoStatusConverter.convertTitanStatusToStorageStatus(createVersionEdgeStatus);
+ }
+ }
if(result == null){
-
- while(certReqUserEdgeIter.hasNext()){
+
+ while (certReqUserEdgeIter.hasNext()) {
Edge edge = certReqUserEdgeIter.next();
- if(((String)titanDao.getProperty(edge, EdgePropertyEnum.STATE)).equals(LifecycleStateEnum.READY_FOR_CERTIFICATION.name()) ){
+ if (((String) titanDao.getProperty(edge, EdgePropertyEnum.STATE)).equals(LifecycleStateEnum.READY_FOR_CERTIFICATION.name())) {
foundEdge = edge;
break;
}
-
+
}
- if(foundEdge == null){
+ if (foundEdge == null) {
CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to find rfc relation during certification clone. ");
result = StorageOperationStatus.NOT_FOUND;
}
}
- if(result == null){
+ if (result == null) {
TitanOperationStatus createEdgeRes = titanDao.createEdge(foundEdge.outVertex(), certifiedToscaElement.getVertex(), EdgeLabelEnum.LAST_STATE, foundEdge);
if (createEdgeRes != TitanOperationStatus.OK) {
CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to create rfc relation for component {}. status=", certifiedToscaElement.getUniqueId(), createEdgeRes);
result = DaoStatusConverter.convertTitanStatusToStorageStatus(createEdgeRes);
}
}
- if(result == null){
+ if (result == null) {
result = StorageOperationStatus.OK;
}
return result;
}
-
+
private StorageOperationStatus handleRelationsUponFailCertification(GraphVertex toscaElement, LifecycleStateEnum nextState) {
StorageOperationStatus result = null;
TitanOperationStatus status = null;
Edge originEdge;
Vertex user = null;
- if(nextState == LifecycleStateEnum.NOT_CERTIFIED_CHECKIN){
- // fail certification
- // delete relation CERTIFICATION_IN_PROGRESS
+ if (nextState == LifecycleStateEnum.NOT_CERTIFIED_CHECKIN) {
+ // fail certification
+ // delete relation CERTIFICATION_IN_PROGRESS
Map<GraphPropertyEnum, Object> properties = new EnumMap<>(GraphPropertyEnum.class);
properties.put(GraphPropertyEnum.STATE, LifecycleStateEnum.CERTIFICATION_IN_PROGRESS);
@@ -547,29 +577,29 @@ public class ToscaElementLifecycleOperation extends BaseOperation {
CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to delete state edge. Status is {}. ", status);
result = StorageOperationStatus.INCONSISTENCY;
}
- if(result == null){
- // delete relation READY_FOR_CERTIFICATION
+ if (result == null) {
+ // delete relation READY_FOR_CERTIFICATION
properties.put(GraphPropertyEnum.STATE, LifecycleStateEnum.READY_FOR_CERTIFICATION);
deleteResult = titanDao.deleteBelongingEdgeByCriteria(toscaElement, EdgeLabelEnum.LAST_STATE, properties);
- if(deleteResult.isRight()){
+ if (deleteResult.isRight()) {
status = deleteResult.right().value();
CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to delete last state edge. Status is {}. ", status);
result = StorageOperationStatus.INCONSISTENCY;
}
}
- if(result == null){
- // delete relation NOT_CERTIFIED_CHECKIN (in order to change to STATE)
+ if (result == null) {
+ // delete relation NOT_CERTIFIED_CHECKIN (in order to change to STATE)
properties.put(GraphPropertyEnum.STATE, LifecycleStateEnum.NOT_CERTIFIED_CHECKIN);
deleteResult = titanDao.deleteBelongingEdgeByCriteria(toscaElement, EdgeLabelEnum.LAST_STATE, properties);
- if(deleteResult.isRight()){
+ if (deleteResult.isRight()) {
status = deleteResult.right().value();
CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to delete last state edge. Status is {}. ", status);
result = StorageOperationStatus.INCONSISTENCY;
}
}
- if(result == null){
+ if (result == null) {
// create new STATE relation NOT_CERTIFIED_CHECKIN
- originEdge = deleteResult.left().value();
+ originEdge = deleteResult.left().value();
user = originEdge.outVertex();
status = titanDao.createEdge(user, toscaElement.getVertex(), EdgeLabelEnum.STATE, originEdge);
if (status != TitanOperationStatus.OK) {
@@ -577,17 +607,17 @@ public class ToscaElementLifecycleOperation extends BaseOperation {
result = StorageOperationStatus.INCONSISTENCY;
}
}
- if(result == null){
- // delete relation LAST_MODIFIER (in order to change tester to designer)
+ if (result == null) {
+ // delete relation LAST_MODIFIER (in order to change tester to designer)
deleteResult = titanDao.deleteBelongingEdgeByCriteria(toscaElement, EdgeLabelEnum.LAST_MODIFIER, new HashMap<>());
if (status != TitanOperationStatus.OK) {
CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to create last modifier edge. Status is {}. ", status);
result = StorageOperationStatus.INCONSISTENCY;
}
}
- if(result == null){
+ if (result == null) {
// create new LAST_MODIFIER relation
- originEdge = deleteResult.left().value();
+ originEdge = deleteResult.left().value();
status = titanDao.createEdge(user, toscaElement.getVertex(), EdgeLabelEnum.LAST_MODIFIER, originEdge);
if (status != TitanOperationStatus.OK) {
CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to create last modifier edge. Status is {}. ", status);
@@ -595,7 +625,7 @@ public class ToscaElementLifecycleOperation extends BaseOperation {
}
}
}
- if(result == null){
+ if (result == null) {
result = StorageOperationStatus.OK;
}
return result;
@@ -604,27 +634,27 @@ public class ToscaElementLifecycleOperation extends BaseOperation {
private StorageOperationStatus handleRelationsUponCancelCertification(GraphVertex toscaElement, LifecycleStateEnum nextState) {
StorageOperationStatus result = null;
Edge originEdge;
- if(nextState == LifecycleStateEnum.READY_FOR_CERTIFICATION){
- // delete relation CERTIFICATION_IN_PROGRESS
+ if (nextState == LifecycleStateEnum.READY_FOR_CERTIFICATION) {
+ // delete relation CERTIFICATION_IN_PROGRESS
Map<GraphPropertyEnum, Object> properties = new EnumMap<>(GraphPropertyEnum.class);
properties.put(GraphPropertyEnum.STATE, LifecycleStateEnum.CERTIFICATION_IN_PROGRESS);
Either<Edge, TitanOperationStatus> deleteResult = titanDao.deleteBelongingEdgeByCriteria(toscaElement, EdgeLabelEnum.STATE, properties);
-
+
if (deleteResult.isRight()) {
CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to delete state edge. Status is {}. ", deleteResult.right().value());
result = StorageOperationStatus.INCONSISTENCY;
}
- if(result == null){
+ if (result == null) {
// delete relation READY_FOR_CERTIFICATION (LAST_STATE)
properties.put(GraphPropertyEnum.STATE, nextState);
deleteResult = titanDao.deleteBelongingEdgeByCriteria(toscaElement, EdgeLabelEnum.LAST_STATE, properties);
-
+
if (deleteResult.isRight()) {
CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to delete last state edge. Status is {}. ", deleteResult.right().value());
result = StorageOperationStatus.INCONSISTENCY;
}
}
- if(result == null){
+ if (result == null) {
// create relation READY_FOR_CERTIFICATION (STATE)
originEdge = deleteResult.left().value();
TitanOperationStatus status = titanDao.createEdge(originEdge.outVertex(), toscaElement.getVertex(), EdgeLabelEnum.STATE, originEdge);
@@ -633,43 +663,43 @@ public class ToscaElementLifecycleOperation extends BaseOperation {
result = StorageOperationStatus.INCONSISTENCY;
}
}
- if(result == null){
+ if (result == null) {
result = StorageOperationStatus.OK;
}
}
return result;
}
- private StorageOperationStatus handleRelationsOfPreviousToscaElementBeforeCertifying(GraphVertex toscaElement, GraphVertex modifier, Integer majorVersion) {
+ private StorageOperationStatus handleRelationsOfPreviousToscaElementBeforeCertifying(GraphVertex toscaElement, GraphVertex modifier, Integer majorVersion) {
StorageOperationStatus result = null;
if (majorVersion > 0) {
Either<Vertex, StorageOperationStatus> findRes = findLastCertifiedToscaElementVertex(toscaElement);
- if(findRes.isRight()){
+ if (findRes.isRight()) {
CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to fetch last certified tosca element {} . Status is {}. ", toscaElement.getMetadataProperty(GraphPropertyEnum.NAME), findRes.right().value());
result = findRes.right().value();
}
- if(result == null){
+ if (result == null) {
Vertex lastCertifiedVertex = findRes.left().value();
Map<GraphPropertyEnum, Object> properties = new EnumMap<>(GraphPropertyEnum.class);
properties.put(GraphPropertyEnum.IS_HIGHEST_VERSION, false);
TitanOperationStatus status = titanDao.updateVertexMetadataPropertiesWithJson(lastCertifiedVertex, properties);
if (status != TitanOperationStatus.OK) {
- CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG,"Failed to set highest version of tosca element {} to [{}]. Status is {}", toscaElement.getUniqueId(), false, status);
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to set highest version of tosca element {} to [{}]. Status is {}", toscaElement.getUniqueId(), false, status);
result = DaoStatusConverter.convertTitanStatusToStorageStatus(status);
}
}
}
- if(result == null){
+ if (result == null) {
result = StorageOperationStatus.OK;
}
return result;
}
-
+
private StorageOperationStatus handleRelationsUponRequestForCertification(GraphVertex toscaElement, GraphVertex modifier, GraphVertex owner) {
TitanOperationStatus status;
StorageOperationStatus result = null;
-
- if (((String)toscaElement.getMetadataProperty(GraphPropertyEnum.STATE)).equals(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT.name())) {
+
+ if (((String) toscaElement.getMetadataProperty(GraphPropertyEnum.STATE)).equals(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT.name())) {
// remove CHECKOUT relation
Either<Edge, TitanOperationStatus> deleteRes = titanDao.deleteEdge(owner, toscaElement, EdgeLabelEnum.STATE);
if (deleteRes.isRight()) {
@@ -677,7 +707,7 @@ public class ToscaElementLifecycleOperation extends BaseOperation {
CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to delete edge. Status is {}. ", status);
result = DaoStatusConverter.convertTitanStatusToStorageStatus(status);
}
- if(result == null){
+ if (result == null) {
// create CHECKIN relation
Map<EdgePropertyEnum, Object> properties = new EnumMap<>(EdgePropertyEnum.class);
properties.put(EdgePropertyEnum.STATE, LifecycleStateEnum.NOT_CERTIFIED_CHECKIN);
@@ -693,54 +723,54 @@ public class ToscaElementLifecycleOperation extends BaseOperation {
result = DaoStatusConverter.convertTitanStatusToStorageStatus(status);
}
}
- if(result == null){
+ if (result == null) {
// create RFC relation
Map<EdgePropertyEnum, Object> properties = new EnumMap<>(EdgePropertyEnum.class);
properties.put(EdgePropertyEnum.STATE, LifecycleStateEnum.READY_FOR_CERTIFICATION);
status = titanDao.createEdge(modifier.getVertex(), toscaElement.getVertex(), EdgeLabelEnum.STATE, properties);
if (status != TitanOperationStatus.OK) {
CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to create edge. Status is {}", status);
- result = DaoStatusConverter.convertTitanStatusToStorageStatus(status);
+ result = DaoStatusConverter.convertTitanStatusToStorageStatus(status);
}
}
- if(result == null){
+ if (result == null) {
result = StorageOperationStatus.OK;
}
return result;
}
-
- private StorageOperationStatus handleRelationsUponCertification(GraphVertex toscaElement, GraphVertex modifier, GraphVertex owner) {
+
+ private StorageOperationStatus handleRelationsUponCertification(GraphVertex toscaElement, GraphVertex modifier, GraphVertex owner) {
StorageOperationStatus result = null;
TitanOperationStatus status = titanDao.replaceEdgeLabel(owner.getVertex(), toscaElement.getVertex(), EdgeLabelEnum.STATE, EdgeLabelEnum.LAST_STATE);
if (status != TitanOperationStatus.OK) {
result = DaoStatusConverter.convertTitanStatusToStorageStatus(status);
}
- if(result == null){
+ if (result == null) {
Map<EdgePropertyEnum, Object> properties = new EnumMap<>(EdgePropertyEnum.class);
properties.put(EdgePropertyEnum.STATE, LifecycleStateEnum.CERTIFICATION_IN_PROGRESS);
status = titanDao.createEdge(modifier, toscaElement, EdgeLabelEnum.STATE, properties);
if (status != TitanOperationStatus.OK) {
- CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG,"failed to create edge. Status is {}", status);
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "failed to create edge. Status is {}", status);
result = DaoStatusConverter.convertTitanStatusToStorageStatus(status);
}
}
- if(result == null){
+ if (result == null) {
result = StorageOperationStatus.OK;
}
return result;
}
-
+
private Either<Vertex, StorageOperationStatus> findLastCertifiedToscaElementVertex(GraphVertex toscaElement) {
return findLastCertifiedToscaElementVertexRecursively(toscaElement.getVertex());
}
private Either<Vertex, StorageOperationStatus> findLastCertifiedToscaElementVertexRecursively(Vertex vertex) {
- if(isCertifiedVersion((String)vertex.property(GraphPropertyEnum.VERSION.getProperty()).value())){
+ if (isCertifiedVersion((String) vertex.property(GraphPropertyEnum.VERSION.getProperty()).value())) {
return Either.left(vertex);
}
Iterator<Edge> edgeIter = vertex.edges(Direction.IN, EdgeLabelEnum.VERSION.name());
- if(!edgeIter.hasNext()){
+ if (!edgeIter.hasNext()) {
return Either.right(StorageOperationStatus.NOT_FOUND);
}
return findLastCertifiedToscaElementVertexRecursively(edgeIter.next().outVertex());
@@ -748,131 +778,350 @@ public class ToscaElementLifecycleOperation extends BaseOperation {
private boolean isCertifiedVersion(String version) {
String[] versionParts = version.split(VERSION_DELIMETER_REGEXP);
- if(Integer.parseInt(versionParts[0]) > 0 && Integer.parseInt(versionParts[1]) == 0){
+ if (Integer.parseInt(versionParts[0]) > 0 && Integer.parseInt(versionParts[1]) == 0) {
return true;
}
return false;
}
private StorageOperationStatus updateOldToscaElementBeforeUndoCheckout(Vertex previousVersionToscaElement) {
-
+
StorageOperationStatus result = StorageOperationStatus.OK;
String previousVersion = (String) previousVersionToscaElement.property(GraphPropertyEnum.VERSION.getProperty()).value();
if (!previousVersion.endsWith(".0")) {
- try{
- CommonUtility.addRecordToLog(logger, LogLevelEnum.TRACE, "Going to update vertex of previous version of tosca element",
- previousVersionToscaElement.property(GraphPropertyEnum.NORMALIZED_NAME.getProperty()));
-
+ try {
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.TRACE, "Going to update vertex of previous version of tosca element", previousVersionToscaElement.property(GraphPropertyEnum.NORMALIZED_NAME.getProperty()));
+
Map<String, Object> propertiesToUpdate = new HashMap<>();
propertiesToUpdate.put(GraphPropertyEnum.IS_HIGHEST_VERSION.getProperty(), true);
- Map<String, Object> jsonMetadataMap =
- JsonParserUtils.parseToJson((String)previousVersionToscaElement.property(GraphPropertyEnum.METADATA.getProperty()).value());
+ Map<String, Object> jsonMetadataMap = JsonParserUtils.parseToJson((String) previousVersionToscaElement.property(GraphPropertyEnum.METADATA.getProperty()).value());
jsonMetadataMap.put(GraphPropertyEnum.IS_HIGHEST_VERSION.getProperty(), true);
propertiesToUpdate.put(GraphPropertyEnum.METADATA.getProperty(), JsonParserUtils.jsonToString(jsonMetadataMap));
-
+
titanDao.setVertexProperties(previousVersionToscaElement, propertiesToUpdate);
-
+
Iterator<Edge> edgesIter = previousVersionToscaElement.edges(Direction.IN, EdgeLabelEnum.LAST_STATE.name());
- if(!edgesIter.hasNext()){
+ if (!edgesIter.hasNext()) {
CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to fetch last modifier vertex for tosca element {}. ", previousVersionToscaElement.property(GraphPropertyEnum.NORMALIZED_NAME.getProperty()));
result = StorageOperationStatus.NOT_FOUND;
} else {
Edge lastStateEdge = edgesIter.next();
Vertex lastModifier = lastStateEdge.outVertex();
- TitanOperationStatus replaceRes =
- titanDao.replaceEdgeLabel(lastModifier, previousVersionToscaElement, lastStateEdge, EdgeLabelEnum.LAST_STATE, EdgeLabelEnum.STATE);
+ TitanOperationStatus replaceRes = titanDao.replaceEdgeLabel(lastModifier, previousVersionToscaElement, lastStateEdge, EdgeLabelEnum.LAST_STATE, EdgeLabelEnum.STATE);
if (replaceRes != TitanOperationStatus.OK) {
- CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to replace label from {} to {}. status = {}", EdgeLabelEnum.LAST_STATE, EdgeLabelEnum.STATE, replaceRes);
- result = StorageOperationStatus.INCONSISTENCY;
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to replace label from {} to {}. status = {}", EdgeLabelEnum.LAST_STATE, EdgeLabelEnum.STATE, replaceRes);
+ result = StorageOperationStatus.INCONSISTENCY;
if (replaceRes != TitanOperationStatus.INVALID_ID) {
result = DaoStatusConverter.convertTitanStatusToStorageStatus(replaceRes);
}
}
}
- } catch (Exception e){
+ } catch (Exception e) {
CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Exception occured during update previous tosca element {} before undo checkout. {} ", e.getMessage());
}
}
return result;
}
+
private StorageOperationStatus updatePreviousVersion(GraphVertex toscaElementVertex, GraphVertex ownerVertex) {
StorageOperationStatus result = null;
String ownerId = (String) ownerVertex.getMetadataProperty(GraphPropertyEnum.USERID);
String toscaElementId = toscaElementVertex.getUniqueId();
- if(!toscaElementVertex.getMetadataProperty(GraphPropertyEnum.STATE).equals(LifecycleStateEnum.CERTIFIED.name())){
+ if (!toscaElementVertex.getMetadataProperty(GraphPropertyEnum.STATE).equals(LifecycleStateEnum.CERTIFIED.name())) {
toscaElementVertex.addMetadataProperty(GraphPropertyEnum.IS_HIGHEST_VERSION, false);
Either<GraphVertex, TitanOperationStatus> updateVertexRes = titanDao.updateVertex(toscaElementVertex);
if (updateVertexRes.isRight()) {
TitanOperationStatus titatStatus = updateVertexRes.right().value();
- CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG,
- "Failed to update tosca element vertex {}. Status is {}", toscaElementVertex.getUniqueId(), titatStatus);
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to update tosca element vertex {}. Status is {}", toscaElementVertex.getUniqueId(), titatStatus);
result = DaoStatusConverter.convertTitanStatusToStorageStatus(titatStatus);
}
Either<Edge, TitanOperationStatus> deleteEdgeRes = null;
- if(result == null){
- CommonUtility.addRecordToLog(logger, LogLevelEnum.TRACE,"Going to replace edge with label {} to label {} from {} to {}. ",
- EdgeLabelEnum.STATE , EdgeLabelEnum.LAST_STATE, ownerId, toscaElementId);
-
+ if (result == null) {
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.TRACE, "Going to replace edge with label {} to label {} from {} to {}. ", EdgeLabelEnum.STATE, EdgeLabelEnum.LAST_STATE, ownerId, toscaElementId);
+
deleteEdgeRes = titanDao.deleteEdge(ownerVertex, toscaElementVertex, EdgeLabelEnum.STATE);
- if(deleteEdgeRes.isRight()){
+ if (deleteEdgeRes.isRight()) {
TitanOperationStatus titanStatus = deleteEdgeRes.right().value();
- CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG,
- "Failed to delete edge with label {} from {} to {}. Status is {} ",
- EdgeLabelEnum.STATE , EdgeLabelEnum.LAST_STATE, ownerId, toscaElementId, titanStatus);
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to delete edge with label {} from {} to {}. Status is {} ", EdgeLabelEnum.STATE, EdgeLabelEnum.LAST_STATE, ownerId, toscaElementId, titanStatus);
if (!titanStatus.equals(TitanOperationStatus.INVALID_ID)) {
result = DaoStatusConverter.convertTitanStatusToStorageStatus(titanStatus);
- } else{
+ } else {
result = StorageOperationStatus.INCONSISTENCY;
}
}
}
- if(result == null){
+ if (result == null) {
TitanOperationStatus createEdgeRes = titanDao.createEdge(ownerVertex.getVertex(), toscaElementVertex.getVertex(), EdgeLabelEnum.LAST_STATE, deleteEdgeRes.left().value());
- if(createEdgeRes != TitanOperationStatus.OK){
+ if (createEdgeRes != TitanOperationStatus.OK) {
result = DaoStatusConverter.convertTitanStatusToStorageStatus(createEdgeRes);
}
}
}
- if(result == null){
+ if (result == null) {
result = StorageOperationStatus.OK;
}
return result;
}
-
- private Either<ToscaElement, StorageOperationStatus> cloneToscaElementForCheckout(GraphVertex toscaElementVertex, GraphVertex modifierVertex) {
-
+
+ private Either<ToscaElement, StorageOperationStatus> cloneToscaElementForCheckout(GraphVertex toscaElementVertex, GraphVertex modifierVertex) {
+
Either<ToscaElement, StorageOperationStatus> result = null;
Either<GraphVertex, StorageOperationStatus> cloneResult = null;
ToscaElementOperation operation = getToscaElementOperation(toscaElementVertex.getLabel());
// check if component with the next version doesn't exist.
Iterator<Edge> nextVersionComponentIter = toscaElementVertex.getVertex().edges(Direction.OUT, EdgeLabelEnum.VERSION.name());
- if(nextVersionComponentIter != null && nextVersionComponentIter.hasNext()){
+ if (nextVersionComponentIter != null && nextVersionComponentIter.hasNext()) {
String fetchedVersion = (String) nextVersionComponentIter.next().inVertex().property(GraphPropertyEnum.VERSION.getProperty()).value();
String fetchedName = (String) nextVersionComponentIter.next().inVertex().property(GraphPropertyEnum.NORMALIZED_NAME.getProperty()).value();
CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to checkout component {} with version {}. The component with name {} and version {} was fetched from graph as existing following version. ",
toscaElementVertex.getMetadataProperty(GraphPropertyEnum.NORMALIZED_NAME).toString(), toscaElementVertex.getMetadataProperty(GraphPropertyEnum.VERSION).toString(), fetchedName, fetchedVersion);
result = Either.right(StorageOperationStatus.ENTITY_ALREADY_EXISTS);
}
- if(result == null){
+ if (result == null) {
cloneResult = operation.cloneToscaElement(toscaElementVertex, cloneGraphVertexForCheckout(toscaElementVertex, modifierVertex), modifierVertex);
- if(cloneResult.isRight()){
+ if (cloneResult.isRight()) {
result = Either.right(cloneResult.right().value());
}
}
+ GraphVertex clonedVertex = null;
if (result == null) {
+ clonedVertex = cloneResult.left().value();
TitanOperationStatus status = titanDao.createEdge(toscaElementVertex.getVertex(), cloneResult.left().value().getVertex(), EdgeLabelEnum.VERSION, new HashMap<>());
if (status != TitanOperationStatus.OK) {
- CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to create edge with label {} from vertex {} to tosca element vertex {} on graph. Status is {}. ", EdgeLabelEnum.VERSION, toscaElementVertex.getMetadataProperty(GraphPropertyEnum.NORMALIZED_NAME),
- cloneResult.left().value().getMetadataProperty(GraphPropertyEnum.NORMALIZED_NAME), status);
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to create edge with label {} from vertex {} to tosca element vertex {} on graph. Status is {}. ", EdgeLabelEnum.VERSION,
+ toscaElementVertex.getMetadataProperty(GraphPropertyEnum.NORMALIZED_NAME), cloneResult.left().value().getMetadataProperty(GraphPropertyEnum.NORMALIZED_NAME), status);
result = Either.right(DaoStatusConverter.convertTitanStatusToStorageStatus(status));
}
}
- if(result == null){
+ if (result == null) {
result = operation.getToscaElement(cloneResult.left().value().getUniqueId());
+ if (result.isRight()) {
+ return result;
+ }
+
+ ToscaElement toscaElement = result.left().value();
+ if (toscaElement.getToscaType() == ToscaElementTypeEnum.TopologyTemplate) {
+ result = handleFixTopologyTemplate(toscaElementVertex, result, operation, clonedVertex, toscaElement);
+ }
+ }
+ return result;
+ }
+
+ private Either<ToscaElement, StorageOperationStatus> handleFixTopologyTemplate(GraphVertex toscaElementVertex, Either<ToscaElement, StorageOperationStatus> result, ToscaElementOperation operation, GraphVertex clonedVertex,
+ ToscaElement toscaElement) {
+ TopologyTemplate topologyTemplate = (TopologyTemplate) toscaElement;
+ Map<String, MapPropertiesDataDefinition> instInputs = topologyTemplate.getInstInputs();
+ Map<String, MapGroupsDataDefinition> instGroups = topologyTemplate.getInstGroups();
+ Map<String, MapArtifactDataDefinition> instArtifactsMap = topologyTemplate.getInstanceArtifacts();
+ Map<String, ToscaElement> origCompMap = new HashMap<>();
+ if (instInputs == null) {
+ instInputs = new HashMap<>();
+ }
+ if (instGroups == null) {
+ instGroups = new HashMap<>();
+ }
+ if (instArtifactsMap == null) {
+ instArtifactsMap = new HashMap<>();
+ }
+ Map<String, ComponentInstanceDataDefinition> instancesMap = topologyTemplate.getComponentInstances();
+ boolean isAddInstGroup = instGroups == null || instGroups.isEmpty();
+ boolean needUpdateComposition = false;
+
+ if (instancesMap != null && !instancesMap.isEmpty()) {
+ for (ComponentInstanceDataDefinition vfInst : instancesMap.values()) {
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "vfInst name is {} . OriginType {}. ", vfInst.getName(), vfInst.getOriginType());
+ if (vfInst.getOriginType().name().equals(OriginTypeEnum.VF.name())) {
+ collectInstanceInputAndGroups(instInputs, instGroups, instArtifactsMap, origCompMap, isAddInstGroup, vfInst, clonedVertex);
+ }
+ needUpdateComposition = needUpdateComposition || fixToscaComponentName(vfInst, origCompMap);
+ if(needUpdateComposition){
+ instancesMap.put(vfInst.getUniqueId(), vfInst);
+ }
+ }
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "before add to graph instInputs {} instGroups {} needUpdateComposition {}", instInputs, instGroups, needUpdateComposition);
+ if (!instInputs.isEmpty()) {
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "before add inst inputs {} ", instInputs == null ? 0 : instInputs.size());
+ GraphVertex toscaDataVertex = null;
+ Either<GraphVertex, TitanOperationStatus> instInpVertexEither = titanDao.getChildVertex(toscaElementVertex, EdgeLabelEnum.INST_INPUTS, JsonParseFlagEnum.ParseJson);
+ if (instInpVertexEither.isLeft()) {
+ toscaDataVertex = instInpVertexEither.left().value();
+ }
+
+ StorageOperationStatus status = handleToscaData(clonedVertex, VertexTypeEnum.INST_INPUTS, EdgeLabelEnum.INST_INPUTS, toscaDataVertex, instInputs);
+ if (status != StorageOperationStatus.OK) {
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to update instance inputs . Status is {}. ", status);
+ result = Either.right(status);
+ return result;
+ }
+
+ }
+ if (!instGroups.isEmpty()) {
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "before add inst groups {} ", instGroups == null ? 0 : instGroups.size());
+ GraphVertex toscaDataVertex = null;
+ Either<GraphVertex, TitanOperationStatus> instGrVertexEither = titanDao.getChildVertex(toscaElementVertex, EdgeLabelEnum.INST_GROUPS, JsonParseFlagEnum.ParseJson);
+ if (instGrVertexEither.isLeft()) {
+ toscaDataVertex = instGrVertexEither.left().value();
+ }
+
+ StorageOperationStatus status = handleToscaData(clonedVertex, VertexTypeEnum.INST_GROUPS, EdgeLabelEnum.INST_GROUPS, toscaDataVertex, instGroups);
+ if (status != StorageOperationStatus.OK) {
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to update instance group . Status is {}. ", status);
+ result = Either.right(status);
+ return result;
+ }
+
+ }
+ if (needUpdateComposition) {
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "before update Instances ");
+ Map<String, CompositionDataDefinition> jsonComposition = (Map<String, CompositionDataDefinition>) clonedVertex.getJson();
+ CompositionDataDefinition compositionDataDefinition = jsonComposition.get(JsonConstantKeysEnum.COMPOSITION.getValue());
+ compositionDataDefinition.setComponentInstances(instancesMap);
+ Either<GraphVertex, TitanOperationStatus> updateElement = titanDao.updateVertex(clonedVertex);
+ if (updateElement.isRight()) {
+ TitanOperationStatus status = updateElement.right().value();
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to update instances on metadata vertex . Status is {}. ", status);
+ result = Either.right(DaoStatusConverter.convertTitanStatusToStorageStatus(status));
+ return result;
+ }
+ }
+
+ result = operation.getToscaElement(clonedVertex.getUniqueId());
+
+ } else {
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "RI map empty on component {}", toscaElement.getUniqueId());
}
return result;
}
+ private boolean fixToscaComponentName(ComponentInstanceDataDefinition vfInst, Map<String, ToscaElement> origCompMap) {
+ if (vfInst.getToscaComponentName() == null || vfInst.getToscaComponentName().isEmpty()) {
+ String ciUid = vfInst.getUniqueId();
+ String origCompUid = vfInst.getComponentUid();
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "fixToscaComponentName:: Ri id {} . origin component id is {}. type is{} ", ciUid, origCompUid, vfInst.getOriginType());
+ ToscaElement origComp = null;
+ if (!origCompMap.containsKey(origCompUid)) {
+ Either<ToscaElement, StorageOperationStatus> origCompEither;
+ if (vfInst.getOriginType() == null || vfInst.getOriginType().name().equals(OriginTypeEnum.VF.name())) {
+ origCompEither = topologyTemplateOperation.getToscaElement(origCompUid);
+ }else{
+ origCompEither = nodeTypeOperation.getToscaElement(origCompUid);
+ }
+ if (origCompEither.isRight()) {
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to find orig component {} . Status is {}. ", origCompEither.right().value());
+ return false;
+ }
+ origComp = origCompEither.left().value();
+ origCompMap.put(origCompUid, origComp);
+ } else {
+ origComp = origCompMap.get(origCompUid);
+ }
+ String toscaName = (String) origComp.getMetadataValue(JsonPresentationFields.TOSCA_RESOURCE_NAME);
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Origin component id is {}. toscaName {}", origCompUid, toscaName);
+ vfInst.setToscaComponentName(toscaName);
+ return true;
+ }
+ return false;
+ }
+
+ private void collectInstanceInputAndGroups(Map<String, MapPropertiesDataDefinition> instInputs, Map<String, MapGroupsDataDefinition> instGroups, Map<String, MapArtifactDataDefinition> instArtifactsMap, Map<String, ToscaElement> origCompMap,
+ boolean isAddInstGroup, ComponentInstanceDataDefinition vfInst, GraphVertex clonedVertex) {
+ String ciUid = vfInst.getUniqueId();
+ String origCompUid = vfInst.getComponentUid();
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "collectInstanceInputAndGroups:: Ri id {} . origin component id is {}. ", ciUid, origCompUid);
+ TopologyTemplate origComp = null;
+ if (!origCompMap.containsKey(origCompUid)) {
+ Either<ToscaElement, StorageOperationStatus> origCompEither = topologyTemplateOperation.getToscaElement(origCompUid);
+ if (origCompEither.isRight()) {
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to find orig component {} . Status is {}. ", origCompEither.right().value());
+ return;
+ }
+ origComp = (TopologyTemplate) origCompEither.left().value();
+ origCompMap.put(origCompUid, origComp);
+ } else {
+ origComp = (TopologyTemplate) origCompMap.get(origCompUid);
+ }
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Orig component {}. ", origComp.getUniqueId());
+
+ Map<String, PropertyDataDefinition> origInputs = origComp.getInputs();
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Orig component inputs size {}. ", origInputs == null ? 0 : origInputs.size());
+ if (origInputs != null) {
+ if (!instInputs.containsKey(ciUid)) {
+ MapPropertiesDataDefinition instProperties = new MapPropertiesDataDefinition(origInputs);
+ instInputs.put(ciUid, instProperties);
+ } else {
+
+ MapPropertiesDataDefinition instInputMap = instInputs.get(ciUid);
+ Map<String, PropertyDataDefinition> instProp = instInputMap.getMapToscaDataDefinition();
+ origInputs.forEach((propName, propMap) -> {
+ if (!instProp.containsKey(propName)) {
+ instProp.put(propName, propMap);
+ }
+ });
+ }
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "ComponentInstanseInputs {}. ", instInputs.get(ciUid));
+ }
+
+ if (isAddInstGroup) {
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "before create group instance. ");
+ List<GroupDataDefinition> filteredGroups = null;
+
+
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "check vf groups before filter. Size is {} ", filteredGroups == null ? 0 : filteredGroups.size());
+ if (origComp.getGroups() != null && !origComp.getGroups().isEmpty()) {
+ filteredGroups = origComp.getGroups().values().stream().filter(g -> g.getType().equals(VF_MODULE)).collect(Collectors.toList());
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "check vf groups . Size is {} ", filteredGroups == null ? 0 : filteredGroups.size());
+ }
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "check vf groups after filter. Size is {} ", filteredGroups == null ? 0 : filteredGroups.size());
+ if (CollectionUtils.isNotEmpty(filteredGroups)) {
+ MapArtifactDataDefinition instArifacts = null;
+ if(!instArtifactsMap.containsKey(ciUid)){
+
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "istance artifacts not found ");
+
+ Map<String, ArtifactDataDefinition> deploymentArtifacts = origComp.getDeploymentArtifacts();
+
+
+ instArifacts = new MapArtifactDataDefinition(deploymentArtifacts);
+ addToscaDataDeepElementsBlockToToscaElement(clonedVertex, EdgeLabelEnum.INST_DEPLOYMENT_ARTIFACTS, VertexTypeEnum.INST_DEPLOYMENT_ARTIFACTS, instArifacts, ciUid);
+
+ instArtifactsMap.put(ciUid, instArifacts);
+
+ }else{
+ instArifacts = instArtifactsMap.get(ciUid);
+ }
+
+ if(instArifacts != null){
+ Map<String, ArtifactDataDefinition> instDeplArtifMap = instArifacts.getMapToscaDataDefinition();
+
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "check group dep artifacts. Size is {} ", instDeplArtifMap == null ? 0 : instDeplArtifMap.values().size());
+ Map<String, GroupInstanceDataDefinition> groupInstanceToCreate = new HashMap<>();
+ for(GroupDataDefinition group:filteredGroups){
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "create new groupInstance {} ", group.getName());
+ GroupInstanceDataDefinition groupInstance = buildGroupInstanceDataDefinition(group, vfInst);
+ List<String> artifactsUid = new ArrayList<>();
+ List<String> artifactsId = new ArrayList<>();
+ for (ArtifactDataDefinition artifact : instDeplArtifMap.values()) {
+ //CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "create new groupInstance {} ", artifact.getA);
+ Optional<String> op = group.getArtifacts().stream().filter(p -> p.equals(artifact.getGeneratedFromId())).findAny();
+ if (op.isPresent()) {
+ artifactsUid.add(artifact.getArtifactUUID());
+ artifactsId.add(artifact.getUniqueId());
+
+ }
+ }
+ groupInstance.setGroupInstanceArtifacts(artifactsId);
+ groupInstance.setGroupInstanceArtifactsUuid(artifactsUid);
+ groupInstanceToCreate.put(groupInstance.getName(), groupInstance);
+ }
+ if (MapUtils.isNotEmpty(groupInstanceToCreate)) {
+ instGroups.put(vfInst.getUniqueId(), new MapGroupsDataDefinition(groupInstanceToCreate));
+
+ }
+ }
+ }
+ }
+ }
+
private GraphVertex cloneGraphVertexForCheckout(GraphVertex toscaElementVertex, GraphVertex modifierVertex) {
GraphVertex nextVersionToscaElementVertex = new GraphVertex();
String uniqueId = UniqueIdBuilder.buildComponentUniqueId();
@@ -881,11 +1130,11 @@ public class ToscaElementLifecycleOperation extends BaseOperation {
nextVersionToscaElementVertex.setUniqueId(uniqueId);
nextVersionToscaElementVertex.setLabel(toscaElementVertex.getLabel());
nextVersionToscaElementVertex.setType(toscaElementVertex.getType());
-
+
nextVersionToscaElementVertex.addMetadataProperty(GraphPropertyEnum.UNIQUE_ID, uniqueId);
nextVersionToscaElementVertex.addMetadataProperty(GraphPropertyEnum.COMPONENT_TYPE, nextVersionToscaElementVertex.getType().name());
String nextVersion = getNextVersion((String) toscaElementVertex.getMetadataProperty(GraphPropertyEnum.VERSION));
- if(isFirstCheckoutAfterCertification(nextVersion)){
+ if (isFirstCheckoutAfterCertification(nextVersion)) {
nextVersionToscaElementVertex.addMetadataProperty(GraphPropertyEnum.UUID, IdBuilderUtils.generateUUID());
}
nextVersionToscaElementVertex.addMetadataProperty(GraphPropertyEnum.VERSION, nextVersion);
@@ -895,7 +1144,7 @@ public class ToscaElementLifecycleOperation extends BaseOperation {
if (toscaElementVertex.getType() == ComponentTypeEnum.SERVICE && toscaElementVertex.getMetadataProperty(GraphPropertyEnum.STATE).equals(LifecycleStateEnum.CERTIFIED.name())) {
nextVersionToscaElementVertex.addMetadataProperty(GraphPropertyEnum.DISTRIBUTION_STATUS, DistributionStatusEnum.DISTRIBUTION_NOT_APPROVED.getValue());
}
- if(!MapUtils.isEmpty(toscaElementVertex.getMetadataJson())){
+ if (!MapUtils.isEmpty(toscaElementVertex.getMetadataJson())) {
nextVersionToscaElementVertex.setMetadataJson(new HashMap<String, Object>(toscaElementVertex.getMetadataJson()));
nextVersionToscaElementVertex.updateMetadataJsonWithCurrentMetadataProperties();
}
@@ -904,73 +1153,70 @@ public class ToscaElementLifecycleOperation extends BaseOperation {
nextVersionToscaElementVertex.setJsonMetadataField(JsonPresentationFields.LAST_UPDATE_DATE, currTime);
nextVersionToscaElementVertex.setJsonMetadataField(JsonPresentationFields.USER_ID_CREATOR, modifierVertex.getUniqueId());
nextVersionToscaElementVertex.setJsonMetadataField(JsonPresentationFields.USER_ID_LAST_UPDATER, modifierVertex.getUniqueId());
- if(toscaElementVertex.getType() == ComponentTypeEnum.SERVICE) {
+ if (toscaElementVertex.getType() == ComponentTypeEnum.SERVICE) {
nextVersionToscaElementVertex.setJsonMetadataField(JsonPresentationFields.CONFORMANCE_LEVEL, ConfigurationManager.getConfigurationManager().getConfiguration().getToscaConformanceLevel());
}
-
- if(!MapUtils.isEmpty(toscaElementVertex.getJson())){
+
+ if (!MapUtils.isEmpty(toscaElementVertex.getJson())) {
nextVersionToscaElementVertex.setJson(new HashMap<String, ToscaDataDefinition>(toscaElementVertex.getJson()));
}
return nextVersionToscaElementVertex;
}
-
+
private Either<GraphVertex, StorageOperationStatus> cloneToscaElementForCertify(GraphVertex toscaElementVertex, GraphVertex modifierVertex, Integer majorVersion) {
Either<GraphVertex, StorageOperationStatus> result;
Either<List<GraphVertex>, StorageOperationStatus> deleteResult = null;
GraphVertex clonedToscaElement = null;
result = getToscaElementOperation(toscaElementVertex.getLabel()).cloneToscaElement(toscaElementVertex, cloneGraphVertexForCertify(toscaElementVertex, modifierVertex, majorVersion), modifierVertex);
- if(result.isRight()){
+ if (result.isRight()) {
CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to clone tosca element {} for certification. Sattus is {}. ", toscaElementVertex.getUniqueId(), result.right().value());
- }
- else{
+ } else {
clonedToscaElement = result.left().value();
deleteResult = deleteAllPreviousNotCertifiedVersions(toscaElementVertex);
- if(deleteResult.isRight()){
- CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to delete all previous npt certified versions of tosca element {}. Status is {}. ",
- toscaElementVertex.getUniqueId(), deleteResult.right().value());
+ if (deleteResult.isRight()) {
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to delete all previous npt certified versions of tosca element {}. Status is {}. ", toscaElementVertex.getUniqueId(), deleteResult.right().value());
result = Either.right(deleteResult.right().value());
}
}
- if(result.isLeft()){
+ if (result.isLeft()) {
result = handlePreviousVersionRelation(clonedToscaElement, deleteResult.left().value(), majorVersion);
}
return result;
}
-
+
private Either<GraphVertex, StorageOperationStatus> handlePreviousVersionRelation(GraphVertex clonedToscaElement, List<GraphVertex> deletedVersions, Integer majorVersion) {
Either<GraphVertex, StorageOperationStatus> result = null;
Vertex previousCertifiedToscaElement = null;
- if(majorVersion > 0){
- List<GraphVertex> firstMinorVersionVertex = deletedVersions.stream()
- .filter(gv->getMinorVersion((String)gv.getMetadataProperty(GraphPropertyEnum.VERSION)) == 1).collect(Collectors.toList());
-
- if(CollectionUtils.isEmpty(firstMinorVersionVertex)){
+ if (majorVersion > 0) {
+ List<GraphVertex> firstMinorVersionVertex = deletedVersions.stream().filter(gv -> getMinorVersion((String) gv.getMetadataProperty(GraphPropertyEnum.VERSION)) == 1).collect(Collectors.toList());
+
+ if (CollectionUtils.isEmpty(firstMinorVersionVertex)) {
result = Either.right(StorageOperationStatus.NOT_FOUND);
} else {
previousCertifiedToscaElement = getPreviousCertifiedToscaElement(firstMinorVersionVertex.get(0));
- if(previousCertifiedToscaElement == null){
+ if (previousCertifiedToscaElement == null) {
result = Either.right(StorageOperationStatus.NOT_FOUND);
}
}
- if(result == null){
+ if (result == null) {
TitanOperationStatus status = titanDao.createEdge(previousCertifiedToscaElement, clonedToscaElement.getVertex(), EdgeLabelEnum.VERSION, new HashMap<>());
if (status != TitanOperationStatus.OK) {
- CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to create edge with label {} from vertex {} to tosca element vertex {} on graph. Status is {}. ", EdgeLabelEnum.VERSION, previousCertifiedToscaElement.property(GraphPropertyEnum.UNIQUE_ID.getProperty()),
- clonedToscaElement.getUniqueId(), status);
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to create edge with label {} from vertex {} to tosca element vertex {} on graph. Status is {}. ", EdgeLabelEnum.VERSION,
+ previousCertifiedToscaElement.property(GraphPropertyEnum.UNIQUE_ID.getProperty()), clonedToscaElement.getUniqueId(), status);
result = Either.right(DaoStatusConverter.convertTitanStatusToStorageStatus(status));
}
}
}
- if(result == null){
+ if (result == null) {
result = Either.left(clonedToscaElement);
}
return result;
}
private Vertex getPreviousCertifiedToscaElement(GraphVertex graphVertex) {
-
+
Iterator<Edge> edges = graphVertex.getVertex().edges(Direction.IN, EdgeLabelEnum.VERSION.name());
- if(edges.hasNext()){
+ if (edges.hasNext()) {
return edges.next().outVertex();
}
return null;
@@ -978,7 +1224,7 @@ public class ToscaElementLifecycleOperation extends BaseOperation {
private Either<List<GraphVertex>, StorageOperationStatus> deleteAllPreviousNotCertifiedVersions(GraphVertex toscaElementVertex) {
Either<List<GraphVertex>, StorageOperationStatus> result = null;
-
+
ToscaElementOperation operation = getToscaElementOperation(toscaElementVertex.getLabel());
List<GraphVertex> previosVersions = null;
Object uuid = toscaElementVertex.getMetadataProperty(GraphPropertyEnum.UUID);
@@ -987,28 +1233,28 @@ public class ToscaElementLifecycleOperation extends BaseOperation {
Map<GraphPropertyEnum, Object> properties = new HashMap<>();
properties.put(GraphPropertyEnum.UUID, uuid);
properties.put(GraphPropertyEnum.NAME, componentName);
- Either<List<GraphVertex>, TitanOperationStatus> getToscaElementsRes= titanDao.getByCriteria(toscaElementVertex.getLabel(), properties, JsonParseFlagEnum.ParseMetadata);
+ Either<List<GraphVertex>, TitanOperationStatus> getToscaElementsRes = titanDao.getByCriteria(toscaElementVertex.getLabel(), properties, JsonParseFlagEnum.ParseMetadata);
if (getToscaElementsRes.isRight()) {
result = Either.right(DaoStatusConverter.convertTitanStatusToStorageStatus(getToscaElementsRes.right().value()));
}
- if(result == null){
+ if (result == null) {
previosVersions = getToscaElementsRes.left().value();
Either<Boolean, StorageOperationStatus> deleteResult = markToscaElementsAsDeleted(operation, getToscaElementsRes.left().value());
- if(deleteResult.isRight()){
+ if (deleteResult.isRight()) {
result = Either.right(deleteResult.right().value());
}
}
- if(result == null){
+ if (result == null) {
result = Either.left(previosVersions);
}
- } catch (Exception e){
- CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG,"Exception occured during deleteng all tosca elements by UUID {} and name {}. {} ", uuid, componentName, e.getMessage());
+ } catch (Exception e) {
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Exception occured during deleteng all tosca elements by UUID {} and name {}. {} ", uuid, componentName, e.getMessage());
}
return result;
}
private GraphVertex cloneGraphVertexForCertify(GraphVertex toscaElementVertex, GraphVertex modifierVertex, Integer majorVersion) {
-
+
GraphVertex nextVersionToscaElementVertex = new GraphVertex();
String uniqueId = IdBuilderUtils.generateUniqueId();
Map<GraphPropertyEnum, Object> metadataProperties = new HashMap<>(toscaElementVertex.getMetadataProperties());
@@ -1016,7 +1262,7 @@ public class ToscaElementLifecycleOperation extends BaseOperation {
nextVersionToscaElementVertex.setUniqueId(uniqueId);
nextVersionToscaElementVertex.setLabel(toscaElementVertex.getLabel());
nextVersionToscaElementVertex.setType(toscaElementVertex.getType());
-
+
nextVersionToscaElementVertex.addMetadataProperty(GraphPropertyEnum.UNIQUE_ID, uniqueId);
nextVersionToscaElementVertex.addMetadataProperty(GraphPropertyEnum.COMPONENT_TYPE, nextVersionToscaElementVertex.getType().name());
nextVersionToscaElementVertex.addMetadataProperty(GraphPropertyEnum.VERSION, (majorVersion + 1) + VERSION_DELIMETER + "0");
@@ -1026,20 +1272,20 @@ public class ToscaElementLifecycleOperation extends BaseOperation {
nextVersionToscaElementVertex.setJsonMetadataField(JsonPresentationFields.LAST_UPDATE_DATE, null);
nextVersionToscaElementVertex.setJsonMetadataField(JsonPresentationFields.USER_ID_CREATOR, modifierVertex.getUniqueId());
nextVersionToscaElementVertex.setJsonMetadataField(JsonPresentationFields.USER_ID_LAST_UPDATER, modifierVertex.getUniqueId());
-
+
if (toscaElementVertex.getType() == ComponentTypeEnum.SERVICE && toscaElementVertex.getMetadataProperty(GraphPropertyEnum.STATE).equals(LifecycleStateEnum.CERTIFIED)) {
nextVersionToscaElementVertex.addMetadataProperty(GraphPropertyEnum.DISTRIBUTION_STATUS, DistributionStatusEnum.DISTRIBUTION_NOT_APPROVED.getValue());
}
- if(!MapUtils.isEmpty(toscaElementVertex.getMetadataJson())){
+ if (!MapUtils.isEmpty(toscaElementVertex.getMetadataJson())) {
nextVersionToscaElementVertex.setMetadataJson(new HashMap<String, Object>(toscaElementVertex.getMetadataJson()));
nextVersionToscaElementVertex.updateMetadataJsonWithCurrentMetadataProperties();
}
- if(!MapUtils.isEmpty(toscaElementVertex.getJson())){
+ if (!MapUtils.isEmpty(toscaElementVertex.getJson())) {
nextVersionToscaElementVertex.setJson(new HashMap<String, ToscaDataDefinition>(toscaElementVertex.getJson()));
}
return nextVersionToscaElementVertex;
}
-
+
private ComponentParametersView buildComponentParametersViewAfterCheckin() {
ComponentParametersView componentParametersView = new ComponentParametersView();
componentParametersView.disableAll();
@@ -1050,141 +1296,141 @@ public class ToscaElementLifecycleOperation extends BaseOperation {
private Either<GraphVertex, StorageOperationStatus> checkinToscaELement(LifecycleStateEnum currState, GraphVertex toscaElementVertex, GraphVertex ownerVertex, GraphVertex modifierVertex, LifecycleStateEnum nextState) {
Either<GraphVertex, StorageOperationStatus> updateRelationsRes;
Either<GraphVertex, StorageOperationStatus> result = changeStateToCheckedIn(currState, toscaElementVertex, ownerVertex, modifierVertex);
- if(result.isLeft()) {
+ if (result.isLeft()) {
toscaElementVertex.addMetadataProperty(GraphPropertyEnum.STATE, nextState.name());
toscaElementVertex.setJsonMetadataField(JsonPresentationFields.LAST_UPDATE_DATE, System.currentTimeMillis());
result = updateToscaElementVertexMetadataPropertiesAndJson(toscaElementVertex);
}
- if(result.isLeft()){
+ if (result.isLeft()) {
updateRelationsRes = updateLastModifierEdge(toscaElementVertex, ownerVertex, modifierVertex);
- if(updateRelationsRes.isRight()){
+ if (updateRelationsRes.isRight()) {
result = Either.right(updateRelationsRes.right().value());
}
}
return result;
}
- private Either<GraphVertex, StorageOperationStatus> updateToscaElementVertexMetadataPropertiesAndJson(GraphVertex toscaElementVertex){
-
+ private Either<GraphVertex, StorageOperationStatus> updateToscaElementVertexMetadataPropertiesAndJson(GraphVertex toscaElementVertex) {
+
Either<GraphVertex, StorageOperationStatus> result;
-
+
Either<GraphVertex, TitanOperationStatus> updateVertexRes = titanDao.updateVertex(toscaElementVertex);
if (updateVertexRes.isRight()) {
TitanOperationStatus titatStatus = updateVertexRes.right().value();
- CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG,"Failed to update state of tosca element vertex {} metadata. Status is {}", toscaElementVertex.getUniqueId(), titatStatus);
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to update state of tosca element vertex {} metadata. Status is {}", toscaElementVertex.getUniqueId(), titatStatus);
result = Either.right(DaoStatusConverter.convertTitanStatusToStorageStatus(titatStatus));
} else {
result = Either.left(updateVertexRes.left().value());
}
return result;
}
-
+
private Either<GraphVertex, StorageOperationStatus> changeStateToCheckedIn(LifecycleStateEnum currState, GraphVertex toscaElementVertex, GraphVertex ownerVertex, GraphVertex modifierVertex) {
Either<GraphVertex, StorageOperationStatus> result = null;
LifecycleStateEnum nextState = LifecycleStateEnum.NOT_CERTIFIED_CHECKIN;
String faileToUpdateStateMsg = "Failed to update state of tosca element {}. Status is {}";
-
+
if (currState == LifecycleStateEnum.READY_FOR_CERTIFICATION) {
- //In case of cancel "ready for certification" remove last state edge with "STATE" property equals to "NOT_CERTIFIED_CHECKIN"
+ // In case of cancel "ready for certification" remove last state edge with "STATE" property equals to "NOT_CERTIFIED_CHECKIN"
Map<GraphPropertyEnum, Object> vertexProperties = new HashMap<>();
vertexProperties.put(GraphPropertyEnum.STATE, nextState);
- Either<Edge, TitanOperationStatus> deleteResult = titanDao.deleteBelongingEdgeByCriteria(toscaElementVertex, EdgeLabelEnum.LAST_STATE, vertexProperties);
+ Either<Edge, TitanOperationStatus> deleteResult = titanDao.deleteBelongingEdgeByCriteria(toscaElementVertex, EdgeLabelEnum.LAST_STATE, vertexProperties);
if (deleteResult.isRight()) {
- CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG,faileToUpdateStateMsg, toscaElementVertex.getUniqueId(), deleteResult.right().value());
- CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG,"failed to update last state relation");
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, faileToUpdateStateMsg, toscaElementVertex.getUniqueId(), deleteResult.right().value());
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "failed to update last state relation");
result = Either.right(StorageOperationStatus.INCONSISTENCY);
}
}
- if(result == null) {
- //Remove CHECKOUT relation
+ if (result == null) {
+ // Remove CHECKOUT relation
Either<Edge, TitanOperationStatus> deleteEdgeResult = titanDao.deleteEdge(ownerVertex, toscaElementVertex, EdgeLabelEnum.STATE);
if (deleteEdgeResult.isRight()) {
- CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG,faileToUpdateStateMsg, toscaElementVertex.getUniqueId());
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, faileToUpdateStateMsg, toscaElementVertex.getUniqueId());
result = Either.right(DaoStatusConverter.convertTitanStatusToStorageStatus(deleteEdgeResult.right().value()));
}
}
- if(result == null) {
- //Create CHECKIN relation
+ if (result == null) {
+ // Create CHECKIN relation
Map<EdgePropertyEnum, Object> edgeProperties = new HashMap<>();
edgeProperties.put(EdgePropertyEnum.STATE, nextState);
TitanOperationStatus createEdgeRes = titanDao.createEdge(modifierVertex.getVertex(), toscaElementVertex.getVertex(), EdgeLabelEnum.STATE, edgeProperties);
if (createEdgeRes != TitanOperationStatus.OK) {
- CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG,faileToUpdateStateMsg, toscaElementVertex.getUniqueId());
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, faileToUpdateStateMsg, toscaElementVertex.getUniqueId());
result = Either.right(DaoStatusConverter.convertTitanStatusToStorageStatus(createEdgeRes));
}
}
- if(result == null) {
+ if (result == null) {
result = Either.left(toscaElementVertex);
}
return result;
}
- private Either<GraphVertex, StorageOperationStatus> updateLastModifierEdge( GraphVertex toscaElementVertex, GraphVertex ownerVertex, GraphVertex modifierVertex) {
+ private Either<GraphVertex, StorageOperationStatus> updateLastModifierEdge(GraphVertex toscaElementVertex, GraphVertex ownerVertex, GraphVertex modifierVertex) {
Either<GraphVertex, StorageOperationStatus> result = null;
- if(!modifierVertex.getMetadataProperties().get(GraphPropertyEnum.USERID).equals(ownerVertex.getMetadataProperties().get(GraphPropertyEnum.USERID))){
+ if (!modifierVertex.getMetadataProperties().get(GraphPropertyEnum.USERID).equals(ownerVertex.getMetadataProperties().get(GraphPropertyEnum.USERID))) {
Either<Edge, TitanOperationStatus> deleteEdgeRes = titanDao.deleteEdge(ownerVertex, toscaElementVertex, EdgeLabelEnum.LAST_MODIFIER);
- if(deleteEdgeRes.isRight()){
- CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG,"Failed to delete last modifier {} to tosca element {}. Edge type is {}", ownerVertex.getUniqueId(), ownerVertex.getUniqueId(), EdgeLabelEnum.LAST_MODIFIER);
+ if (deleteEdgeRes.isRight()) {
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to delete last modifier {} to tosca element {}. Edge type is {}", ownerVertex.getUniqueId(), ownerVertex.getUniqueId(), EdgeLabelEnum.LAST_MODIFIER);
result = Either.right(DaoStatusConverter.convertTitanStatusToStorageStatus(deleteEdgeRes.right().value()));
}
- if(result == null) {
+ if (result == null) {
TitanOperationStatus createEdgeRes = titanDao.createEdge(modifierVertex.getVertex(), toscaElementVertex.getVertex(), EdgeLabelEnum.LAST_MODIFIER, new HashMap<>());
-
- if(createEdgeRes != TitanOperationStatus.OK){
- CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG,"Failed to associate user {} to component {}. Edge type is {}", modifierVertex.getUniqueId(), ownerVertex.getUniqueId(), EdgeLabelEnum.LAST_MODIFIER);
+
+ if (createEdgeRes != TitanOperationStatus.OK) {
+ CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to associate user {} to component {}. Edge type is {}", modifierVertex.getUniqueId(), ownerVertex.getUniqueId(), EdgeLabelEnum.LAST_MODIFIER);
result = Either.right(DaoStatusConverter.convertTitanStatusToStorageStatus(createEdgeRes));
- } else{
+ } else {
result = Either.left(modifierVertex);
}
}
- } else{
+ } else {
result = Either.left(ownerVertex);
}
return result;
}
- private Map<String, ImmutablePair<GraphPropertyEnum ,JsonParseFlagEnum>> prepareParametersToGetVerticesForCheckin(String toscaElementId, String modifierId, String ownerId) {
- Map<String, ImmutablePair<GraphPropertyEnum ,JsonParseFlagEnum>> verticesToGetParameters = new HashMap<>();
+ private Map<String, ImmutablePair<GraphPropertyEnum, JsonParseFlagEnum>> prepareParametersToGetVerticesForCheckin(String toscaElementId, String modifierId, String ownerId) {
+ Map<String, ImmutablePair<GraphPropertyEnum, JsonParseFlagEnum>> verticesToGetParameters = new HashMap<>();
verticesToGetParameters.put(toscaElementId, new ImmutablePair<>(GraphPropertyEnum.UNIQUE_ID, JsonParseFlagEnum.ParseMetadata));
- verticesToGetParameters.put(modifierId, new ImmutablePair<>(GraphPropertyEnum.USERID,JsonParseFlagEnum.NoParse));
- verticesToGetParameters.put(ownerId, new ImmutablePair<>(GraphPropertyEnum.USERID,JsonParseFlagEnum.NoParse));
+ verticesToGetParameters.put(modifierId, new ImmutablePair<>(GraphPropertyEnum.USERID, JsonParseFlagEnum.NoParse));
+ verticesToGetParameters.put(ownerId, new ImmutablePair<>(GraphPropertyEnum.USERID, JsonParseFlagEnum.NoParse));
return verticesToGetParameters;
}
-
- private Map<String, ImmutablePair<GraphPropertyEnum ,JsonParseFlagEnum>> prepareParametersToGetVerticesForRequestCertification(String toscaElementId, String modifierId, String ownerId) {
- Map<String, ImmutablePair<GraphPropertyEnum ,JsonParseFlagEnum>> verticesToGetParameters = new HashMap<>();
+
+ private Map<String, ImmutablePair<GraphPropertyEnum, JsonParseFlagEnum>> prepareParametersToGetVerticesForRequestCertification(String toscaElementId, String modifierId, String ownerId) {
+ Map<String, ImmutablePair<GraphPropertyEnum, JsonParseFlagEnum>> verticesToGetParameters = new HashMap<>();
verticesToGetParameters.put(toscaElementId, new ImmutablePair<>(GraphPropertyEnum.UNIQUE_ID, JsonParseFlagEnum.ParseAll));
- verticesToGetParameters.put(modifierId, new ImmutablePair<>(GraphPropertyEnum.USERID,JsonParseFlagEnum.NoParse));
- verticesToGetParameters.put(ownerId, new ImmutablePair<>(GraphPropertyEnum.USERID,JsonParseFlagEnum.NoParse));
+ verticesToGetParameters.put(modifierId, new ImmutablePair<>(GraphPropertyEnum.USERID, JsonParseFlagEnum.NoParse));
+ verticesToGetParameters.put(ownerId, new ImmutablePair<>(GraphPropertyEnum.USERID, JsonParseFlagEnum.NoParse));
return verticesToGetParameters;
}
-
- private Map<String, ImmutablePair<GraphPropertyEnum ,JsonParseFlagEnum>> prepareParametersToGetVerticesForCheckout(String toscaElementId, String modifierId, String ownerId) {
- Map<String, ImmutablePair<GraphPropertyEnum ,JsonParseFlagEnum>> verticesToGetParameters = new HashMap<>();
+
+ private Map<String, ImmutablePair<GraphPropertyEnum, JsonParseFlagEnum>> prepareParametersToGetVerticesForCheckout(String toscaElementId, String modifierId, String ownerId) {
+ Map<String, ImmutablePair<GraphPropertyEnum, JsonParseFlagEnum>> verticesToGetParameters = new HashMap<>();
verticesToGetParameters.put(toscaElementId, new ImmutablePair<>(GraphPropertyEnum.UNIQUE_ID, JsonParseFlagEnum.ParseAll));
- verticesToGetParameters.put(modifierId, new ImmutablePair<>(GraphPropertyEnum.USERID,JsonParseFlagEnum.NoParse));
- verticesToGetParameters.put(ownerId, new ImmutablePair<>(GraphPropertyEnum.USERID,JsonParseFlagEnum.NoParse));
+ verticesToGetParameters.put(modifierId, new ImmutablePair<>(GraphPropertyEnum.USERID, JsonParseFlagEnum.NoParse));
+ verticesToGetParameters.put(ownerId, new ImmutablePair<>(GraphPropertyEnum.USERID, JsonParseFlagEnum.NoParse));
return verticesToGetParameters;
}
-
+
private String getNextVersion(String currVersion) {
String[] versionParts = currVersion.split(VERSION_DELIMETER_REGEXP);
Integer minorVersion = Integer.parseInt(versionParts[1]) + 1;
return versionParts[0] + VERSION_DELIMETER + minorVersion;
}
-
+
private Integer getMinorVersion(String version) {
String[] versionParts = version.split(VERSION_DELIMETER_REGEXP);
return Integer.parseInt(versionParts[1]);
}
-
+
private Integer getMajorVersion(String version) {
String[] versionParts = version.split(VERSION_DELIMETER_REGEXP);
return Integer.parseInt(versionParts[0]);
}
-
+
private boolean isFirstCheckoutAfterCertification(String version) {
- if(Integer.parseInt(version.split(VERSION_DELIMETER_REGEXP)[0]) != 0 && Integer.parseInt(version.split(VERSION_DELIMETER_REGEXP)[1]) == 1){
+ if (Integer.parseInt(version.split(VERSION_DELIMETER_REGEXP)[0]) != 0 && Integer.parseInt(version.split(VERSION_DELIMETER_REGEXP)[1]) == 1) {
return true;
}
return false;
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaElementOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaElementOperation.java
index 95e65e1e82..699d9e0e9d 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaElementOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaElementOperation.java
@@ -130,7 +130,7 @@ public abstract class ToscaElementOperation extends BaseOperation {
Either<GraphVertex, StorageOperationStatus> result = null;
GraphVertex createdToscaElementVertex = null;
TitanOperationStatus status;
-
+
Either<GraphVertex, TitanOperationStatus> createNextVersionRes = titanDao.createVertex(nextToscaElement);
if (createNextVersionRes.isRight()) {
status = createNextVersionRes.right().value();
@@ -182,7 +182,7 @@ public abstract class ToscaElementOperation extends BaseOperation {
}
}
}
-
+
if (result == null) {
result = Either.left(createdToscaElementVertex);
} else {
@@ -203,6 +203,7 @@ public abstract class ToscaElementOperation extends BaseOperation {
toscaElement.setLastUpdaterFullName(buildFullName(userV));
return TitanOperationStatus.OK;
}
+
public String buildFullName(GraphVertex userV) {
String fullName = (String) userV.getMetadataProperty(GraphPropertyEnum.FIRST_NAME);
@@ -217,6 +218,7 @@ public abstract class ToscaElementOperation extends BaseOperation {
}
return fullName;
}
+
protected TitanOperationStatus setCreatorFromGraph(GraphVertex componentV, ToscaElement toscaElement) {
Either<GraphVertex, TitanOperationStatus> parentVertex = titanDao.getParentVertex(componentV, EdgeLabelEnum.CREATOR, JsonParseFlagEnum.NoParse);
if (parentVertex.isRight()) {
@@ -227,7 +229,7 @@ public abstract class ToscaElementOperation extends BaseOperation {
String creatorUserId = (String) userV.getMetadataProperty(GraphPropertyEnum.USERID);
toscaElement.setCreatorUserId(creatorUserId);
toscaElement.setCreatorFullName(buildFullName(userV));
-
+
return TitanOperationStatus.OK;
}
@@ -318,7 +320,7 @@ public abstract class ToscaElementOperation extends BaseOperation {
toscaElement.setLastUpdaterUserId(toscaElement.getCreatorUserId());
toscaElement.setLastUpdaterFullName(toscaElement.getCreatorFullName());
-
+
result = titanDao.createEdge(creatorVertex, nodeTypeVertex, EdgeLabelEnum.CREATOR, null);
log.debug("After associating user {} to resource {}. Edge type is {} ", creatorVertex, nodeTypeVertex.getUniqueId(), EdgeLabelEnum.CREATOR);
if (!result.equals(TitanOperationStatus.OK)) {
@@ -472,9 +474,9 @@ public abstract class ToscaElementOperation extends BaseOperation {
return StorageOperationStatus.OK;
}
- private StorageOperationStatus associatePropertiesToResource(GraphVertex nodeTypeVertex, ToscaElement nodeType, List<GraphVertex> derivedResources) {
+ protected StorageOperationStatus associatePropertiesToResource(GraphVertex nodeTypeVertex, ToscaElement nodeType, List<GraphVertex> derivedResources) {
// Note : currently only one derived supported!!!!
- Either<Map<String, PropertyDataDefinition>, StorageOperationStatus> dataFromDerived = getDataFromDerived(derivedResources, PropertyDataDefinition.class, EdgeLabelEnum.PROPERTIES);
+ Either<Map<String, PropertyDataDefinition>, StorageOperationStatus> dataFromDerived = getDataFromDerived(derivedResources, EdgeLabelEnum.PROPERTIES);
if (dataFromDerived.isRight()) {
return dataFromDerived.right().value();
}
@@ -488,13 +490,12 @@ public abstract class ToscaElementOperation extends BaseOperation {
p.setUniqueId(uid);
});
- Either<Map<String, PropertyDataDefinition>, String> eitherMerged = PropertyDataDefinition.mergeProperties(propertiesAll, properties, false);
+ Either<Map<String, PropertyDataDefinition>, String> eitherMerged = ToscaDataDefinition.mergeDataMaps(propertiesAll, properties);
if (eitherMerged.isRight()) {
// TODO re-factor error handling - moving BL to operation resulted in loss of info about the invalid property
log.debug("property {} cannot be overriden", eitherMerged.right().value());
return StorageOperationStatus.INVALID_PROPERTY;
}
-
}
if (!propertiesAll.isEmpty()) {
Either<GraphVertex, StorageOperationStatus> assosiateElementToData = assosiateElementToData(nodeTypeVertex, VertexTypeEnum.PROPERTIES, EdgeLabelEnum.PROPERTIES, propertiesAll);
@@ -516,7 +517,7 @@ public abstract class ToscaElementOperation extends BaseOperation {
return StorageOperationStatus.OK;
}
- protected <T extends ToscaDataDefinition> Either<Map<String, T>, StorageOperationStatus> getDataFromDerived(List<GraphVertex> derivedResources, Class<T> clazz, EdgeLabelEnum edge) {
+ protected <T extends ToscaDataDefinition> Either<Map<String, T>, StorageOperationStatus> getDataFromDerived(List<GraphVertex> derivedResources, EdgeLabelEnum edge) {
Map<String, T> propertiesAll = new HashMap<>();
if (derivedResources != null && !derivedResources.isEmpty()) {
@@ -575,10 +576,11 @@ public abstract class ToscaElementOperation extends BaseOperation {
Map<String, String> allVersion = new HashMap<>();
allVersion.put((String) componentV.getMetadataProperty(GraphPropertyEnum.VERSION), componentV.getUniqueId());
+ ArrayList<GraphVertex> allChildrenAndParants = new ArrayList<GraphVertex>();
Either<GraphVertex, TitanOperationStatus> childResourceRes = titanDao.getChildVertex(componentV, EdgeLabelEnum.VERSION, JsonParseFlagEnum.NoParse);
while (childResourceRes.isLeft()) {
GraphVertex child = childResourceRes.left().value();
- allVersion.put((String) child.getMetadataProperty(GraphPropertyEnum.VERSION), child.getUniqueId());
+ allChildrenAndParants.add(child);
childResourceRes = titanDao.getChildVertex(child, EdgeLabelEnum.VERSION, JsonParseFlagEnum.NoParse);
}
TitanOperationStatus operationStatus = childResourceRes.right().value();
@@ -589,13 +591,18 @@ public abstract class ToscaElementOperation extends BaseOperation {
Either<GraphVertex, TitanOperationStatus> parentResourceRes = titanDao.getParentVertex(componentV, EdgeLabelEnum.VERSION, JsonParseFlagEnum.NoParse);
while (parentResourceRes.isLeft()) {
GraphVertex parent = parentResourceRes.left().value();
- allVersion.put((String) parent.getMetadataProperty(GraphPropertyEnum.VERSION), parent.getUniqueId());
+ allChildrenAndParants.add(parent);
parentResourceRes = titanDao.getParentVertex(parent, EdgeLabelEnum.VERSION, JsonParseFlagEnum.NoParse);
}
operationStatus = parentResourceRes.right().value();
if (operationStatus != TitanOperationStatus.NOT_FOUND) {
return operationStatus;
} else {
+ allChildrenAndParants.stream().filter(vertex -> {
+ Boolean isDeleted = (Boolean) vertex.getMetadataProperty(GraphPropertyEnum.IS_DELETED);
+ return (isDeleted == null || isDeleted == false);
+ }).forEach(vertex -> allVersion.put((String) vertex.getMetadataProperty(GraphPropertyEnum.VERSION), vertex.getUniqueId()));
+
toscaElement.setAllVersions(allVersion);
return TitanOperationStatus.OK;
}
@@ -1047,98 +1054,113 @@ public abstract class ToscaElementOperation extends BaseOperation {
return status;
}
-
- public <T extends ToscaElement> Either<List<T>, StorageOperationStatus> getElementCatalogData(ComponentTypeEnum componentType , ToscaElementTypeEnum toscaElement) {
- Either<List<GraphVertex>, TitanOperationStatus> listOfHighestAndAllCertifiedComponents = this.getListOfHighestAndAllCertifiedComponents(componentType , toscaElement);
- if (listOfHighestAndAllCertifiedComponents.isRight() && listOfHighestAndAllCertifiedComponents.right().value() != TitanOperationStatus.NOT_FOUND) {
- return Either.right(DaoStatusConverter.convertTitanStatusToStorageStatus(listOfHighestAndAllCertifiedComponents.right().value()));
+ public <T extends ToscaElement> Either<List<T>, StorageOperationStatus> getElementCatalogData(ComponentTypeEnum componentType, ToscaElementTypeEnum toscaElement, boolean isHighestVersions) {
+ Either<List<GraphVertex>, TitanOperationStatus> listOfComponents;
+ if (isHighestVersions) {
+ listOfComponents = getListOfHighestComponents(componentType, toscaElement);
+ } else {
+ listOfComponents = getListOfHighestAndAllCertifiedComponents(componentType, toscaElement);
+ }
+ if (listOfComponents.isRight() && listOfComponents.right().value() != TitanOperationStatus.NOT_FOUND) {
+ return Either.right(DaoStatusConverter.convertTitanStatusToStorageStatus(listOfComponents.right().value()));
}
- List<GraphVertex> highestAndAllCertified = listOfHighestAndAllCertifiedComponents.left().value();
List<T> result = new ArrayList<>();
- if (highestAndAllCertified != null && false == highestAndAllCertified.isEmpty()) {
- for (GraphVertex vertexComponent : highestAndAllCertified) {
- Either<T, StorageOperationStatus> component = getLightComponent(vertexComponent, componentType, new ComponentParametersView(true));
- if (component.isRight()) {
- log.debug("Failed to fetch ligth element for {} error {}", vertexComponent.getUniqueId(), component.right().value());
- return Either.right(component.right().value());
- } else {
- result.add(component.left().value());
+ if (listOfComponents.isLeft()) {
+ List<GraphVertex> highestAndAllCertified = listOfComponents.left().value();
+ if (highestAndAllCertified != null && false == highestAndAllCertified.isEmpty()) {
+ for (GraphVertex vertexComponent : highestAndAllCertified) {
+ Either<T, StorageOperationStatus> component = getLightComponent(vertexComponent, componentType, new ComponentParametersView(true));
+ if (component.isRight()) {
+ log.debug("Failed to fetch ligth element for {} error {}", vertexComponent.getUniqueId(), component.right().value());
+ return Either.right(component.right().value());
+ } else {
+ result.add(component.left().value());
+ }
}
}
}
return Either.left(result);
}
-
-
-public Either<List<GraphVertex>, TitanOperationStatus> getListOfHighestAndAllCertifiedComponents(ComponentTypeEnum componentType , ToscaElementTypeEnum toscaElement) {
- long startFetchAllStates = System.currentTimeMillis();
- Map<GraphPropertyEnum, Object> propertiesToMatchCertified = new HashMap<>();
- propertiesToMatchCertified.put(GraphPropertyEnum.STATE , LifecycleStateEnum.CERTIFIED.name());
- propertiesToMatchCertified.put(GraphPropertyEnum.COMPONENT_TYPE, componentType.name());
- if (componentType == ComponentTypeEnum.RESOURCE ){
- propertiesToMatchCertified.put(GraphPropertyEnum.IS_ABSTRACT, false);
- }
- Map<GraphPropertyEnum, Object> propertiesHasNotToMatchCertified = new HashMap<>();
- propertiesHasNotToMatchCertified.put(GraphPropertyEnum.IS_DELETED, true);
-
-
- Either<List<GraphVertex>, TitanOperationStatus> certifiedNodes = titanDao.getByCriteria(ToscaElementTypeEnum.getVertexTypeByToscaType(toscaElement) , propertiesToMatchCertified, propertiesHasNotToMatchCertified, JsonParseFlagEnum.ParseMetadata);
- if (certifiedNodes.isRight() && certifiedNodes.right().value() != TitanOperationStatus.NOT_FOUND) {
- return Either.right(certifiedNodes.right().value());
- }
-
- Map<GraphPropertyEnum, Object> propertiesToMatchHighest = new HashMap<>();
- propertiesToMatchHighest.put(GraphPropertyEnum.IS_HIGHEST_VERSION , true);
- propertiesToMatchHighest.put(GraphPropertyEnum.COMPONENT_TYPE, componentType.name());
- if (componentType == ComponentTypeEnum.RESOURCE ){
- propertiesToMatchHighest.put(GraphPropertyEnum.IS_ABSTRACT, false);
- }
+ private Either<List<GraphVertex>, TitanOperationStatus> getListOfHighestComponents(ComponentTypeEnum componentType, ToscaElementTypeEnum toscaElement) {
+ Map<GraphPropertyEnum, Object> propertiesToMatch = new HashMap<>();
+ propertiesToMatch.put(GraphPropertyEnum.COMPONENT_TYPE, componentType.name());
+ propertiesToMatch.put(GraphPropertyEnum.IS_HIGHEST_VERSION, true);
+ if (componentType == ComponentTypeEnum.RESOURCE) {
+ propertiesToMatch.put(GraphPropertyEnum.IS_ABSTRACT, false);
+ }
- Map<GraphPropertyEnum, Object> propertiesHasNotToMatchHighest = new HashMap<>();
- propertiesHasNotToMatchHighest.put(GraphPropertyEnum.IS_DELETED, true);
- propertiesHasNotToMatchHighest.put(GraphPropertyEnum.STATE, LifecycleStateEnum.CERTIFIED.name());
-
-
- Either<List<GraphVertex>, TitanOperationStatus> highestNode = titanDao.getByCriteria(ToscaElementTypeEnum.getVertexTypeByToscaType(toscaElement) , propertiesToMatchHighest, propertiesHasNotToMatchHighest, JsonParseFlagEnum.ParseMetadata);
- if (highestNode.isRight() && highestNode.right().value() != TitanOperationStatus.NOT_FOUND) {
- return Either.right(highestNode.right().value());
- }
-
- long endFetchAllStates = System.currentTimeMillis();
-
-
- List<GraphVertex> allNodes = new ArrayList<>();
-
- if (certifiedNodes.isLeft()) {
- allNodes.addAll(certifiedNodes.left().value());
- }
- if (highestNode.isLeft()){
- allNodes.addAll(highestNode.left().value());
- }
-
- int certifiedSize;
- int nonCertifiedSize;
-
- if (certifiedNodes.isRight()){
- certifiedSize = 0;
- } else {
- certifiedSize = certifiedNodes.left().value().size();
- }
-
- if (highestNode.isRight()){
- nonCertifiedSize = 0;
- } else {
- nonCertifiedSize = highestNode.left().value().size();
+ Map<GraphPropertyEnum, Object> propertiesHasNotToMatch = new HashMap<>();
+ propertiesHasNotToMatch.put(GraphPropertyEnum.IS_DELETED, true);
+
+ return titanDao.getByCriteria(ToscaElementTypeEnum.getVertexTypeByToscaType(toscaElement), propertiesToMatch, propertiesHasNotToMatch, JsonParseFlagEnum.ParseMetadata);
}
-
-
- log.debug("Fetch catalog {}s all states: certified {}, noncertified {}", componentType, certifiedSize , nonCertifiedSize );
- log.debug("Fetch catalog {}s all states from graph took {} ms", componentType, endFetchAllStates - startFetchAllStates);
- return Either.left(allNodes);
-}
+ public Either<List<GraphVertex>, TitanOperationStatus> getListOfHighestAndAllCertifiedComponents(ComponentTypeEnum componentType, ToscaElementTypeEnum toscaElement) {
+ long startFetchAllStates = System.currentTimeMillis();
+ Map<GraphPropertyEnum, Object> propertiesToMatchCertified = new HashMap<>();
+ propertiesToMatchCertified.put(GraphPropertyEnum.STATE, LifecycleStateEnum.CERTIFIED.name());
+ propertiesToMatchCertified.put(GraphPropertyEnum.COMPONENT_TYPE, componentType.name());
+ if (componentType == ComponentTypeEnum.RESOURCE) {
+ propertiesToMatchCertified.put(GraphPropertyEnum.IS_ABSTRACT, false);
+ }
+
+ Map<GraphPropertyEnum, Object> propertiesHasNotToMatchCertified = new HashMap<>();
+ propertiesHasNotToMatchCertified.put(GraphPropertyEnum.IS_DELETED, true);
+
+ Either<List<GraphVertex>, TitanOperationStatus> certifiedNodes = titanDao.getByCriteria(ToscaElementTypeEnum.getVertexTypeByToscaType(toscaElement), propertiesToMatchCertified, propertiesHasNotToMatchCertified,
+ JsonParseFlagEnum.ParseMetadata);
+ if (certifiedNodes.isRight() && certifiedNodes.right().value() != TitanOperationStatus.NOT_FOUND) {
+ return Either.right(certifiedNodes.right().value());
+ }
+
+ Map<GraphPropertyEnum, Object> propertiesToMatchHighest = new HashMap<>();
+ propertiesToMatchHighest.put(GraphPropertyEnum.IS_HIGHEST_VERSION, true);
+ propertiesToMatchHighest.put(GraphPropertyEnum.COMPONENT_TYPE, componentType.name());
+ if (componentType == ComponentTypeEnum.RESOURCE) {
+ propertiesToMatchHighest.put(GraphPropertyEnum.IS_ABSTRACT, false);
+ }
+
+ Map<GraphPropertyEnum, Object> propertiesHasNotToMatchHighest = new HashMap<>();
+ propertiesHasNotToMatchHighest.put(GraphPropertyEnum.IS_DELETED, true);
+ propertiesHasNotToMatchHighest.put(GraphPropertyEnum.STATE, LifecycleStateEnum.CERTIFIED.name());
+
+ Either<List<GraphVertex>, TitanOperationStatus> highestNode = titanDao.getByCriteria(ToscaElementTypeEnum.getVertexTypeByToscaType(toscaElement), propertiesToMatchHighest, propertiesHasNotToMatchHighest, JsonParseFlagEnum.ParseMetadata);
+ if (highestNode.isRight() && highestNode.right().value() != TitanOperationStatus.NOT_FOUND) {
+ return Either.right(highestNode.right().value());
+ }
+
+ long endFetchAllStates = System.currentTimeMillis();
+
+ List<GraphVertex> allNodes = new ArrayList<>();
+
+ if (certifiedNodes.isLeft()) {
+ allNodes.addAll(certifiedNodes.left().value());
+ }
+ if (highestNode.isLeft()) {
+ allNodes.addAll(highestNode.left().value());
+ }
+
+ int certifiedSize;
+ int nonCertifiedSize;
+
+ if (certifiedNodes.isRight()) {
+ certifiedSize = 0;
+ } else {
+ certifiedSize = certifiedNodes.left().value().size();
+ }
+
+ if (highestNode.isRight()) {
+ nonCertifiedSize = 0;
+ } else {
+ nonCertifiedSize = highestNode.left().value().size();
+ }
+
+ log.debug("Fetch catalog {}s all states: certified {}, noncertified {}", componentType, certifiedSize, nonCertifiedSize);
+ log.debug("Fetch catalog {}s all states from graph took {} ms", componentType, endFetchAllStates - startFetchAllStates);
+ return Either.left(allNodes);
+ }
protected Either<List<GraphVertex>, StorageOperationStatus> getAllComponentsMarkedForDeletion(ComponentTypeEnum componentType) {
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaOperationFacade.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaOperationFacade.java
index 9c7f108a05..458bbbe226 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaOperationFacade.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaOperationFacade.java
@@ -24,14 +24,12 @@ import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
import org.openecomp.sdc.be.datatypes.components.ComponentMetadataDataDefinition;
import org.openecomp.sdc.be.datatypes.components.ResourceMetadataDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.CapabilityDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.ComponentInstanceDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.GroupDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.ListCapabilityDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.ListRequirementDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.MapArtifactDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.MapAttributesDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.MapCapabiltyProperty;
import org.openecomp.sdc.be.datatypes.elements.MapListCapabiltyDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.MapListRequirementDataDefinition;
@@ -44,7 +42,6 @@ import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
import org.openecomp.sdc.be.model.ArtifactDefinition;
-import org.openecomp.sdc.be.model.AttributeDefinition;
import org.openecomp.sdc.be.model.CapabilityDefinition;
import org.openecomp.sdc.be.model.Component;
import org.openecomp.sdc.be.model.ComponentInstance;
@@ -100,12 +97,14 @@ public class ToscaOperationFacade {
return getToscaElement(componentId, JsonParseFlagEnum.ParseAll);
}
+
public <T extends Component> Either<T, StorageOperationStatus> getToscaFullElement(String componentId) {
ComponentParametersView filters = new ComponentParametersView();
filters.setIgnoreCapabiltyProperties(false);
-
+
return getToscaElement(componentId, filters);
}
+
public <T extends Component> Either<T, StorageOperationStatus> getToscaElement(String componentId, ComponentParametersView filters) {
Either<GraphVertex, TitanOperationStatus> getVertexEither = titanDao.getVertexById(componentId, filters.detectParseFlag());
@@ -657,25 +656,25 @@ public class ToscaOperationFacade {
return getToscaElementByOperation(getResourceRes.left().value().get(0));
}
- public <T extends Component> Either<List<T>, StorageOperationStatus> getCatalogComponents(ComponentTypeEnum componentType) {
+ public <T extends Component> Either<List<T>, StorageOperationStatus> getCatalogComponents(ComponentTypeEnum componentType, boolean isHighestVersions) {
List<T> components = new ArrayList<>();
Either<List<ToscaElement>, StorageOperationStatus> catalogDataResult;
List<ToscaElement> toscaElements;
switch (componentType) {
case RESOURCE:
- catalogDataResult = nodeTypeOperation.getElementCatalogData(ComponentTypeEnum.RESOURCE ,ToscaElementTypeEnum.NodeType);
+ catalogDataResult = nodeTypeOperation.getElementCatalogData(ComponentTypeEnum.RESOURCE, ToscaElementTypeEnum.NodeType, isHighestVersions);
if (catalogDataResult.isRight()) {
return Either.right(catalogDataResult.right().value());
}
toscaElements = catalogDataResult.left().value();
- Either<List<ToscaElement>, StorageOperationStatus> resourceCatalogData = topologyTemplateOperation.getElementCatalogData(ComponentTypeEnum.RESOURCE ,ToscaElementTypeEnum.TopologyTemplate);
+ Either<List<ToscaElement>, StorageOperationStatus> resourceCatalogData = topologyTemplateOperation.getElementCatalogData(ComponentTypeEnum.RESOURCE, ToscaElementTypeEnum.TopologyTemplate, isHighestVersions);
if (resourceCatalogData.isRight()) {
return Either.right(resourceCatalogData.right().value());
}
toscaElements.addAll(resourceCatalogData.left().value());
break;
case SERVICE:
- catalogDataResult = topologyTemplateOperation.getElementCatalogData(ComponentTypeEnum.SERVICE , ToscaElementTypeEnum.TopologyTemplate);
+ catalogDataResult = topologyTemplateOperation.getElementCatalogData(ComponentTypeEnum.SERVICE, ToscaElementTypeEnum.TopologyTemplate, isHighestVersions);
if (catalogDataResult.isRight()) {
return Either.right(catalogDataResult.right().value());
}
@@ -1034,37 +1033,34 @@ public class ToscaOperationFacade {
}
- public Either<Map<String, List<ComponentInstanceInput>>, StorageOperationStatus> addComponentInstanceInputsToComponent(Map<String, List<ComponentInstanceInput>> instProperties, String componentId) {
-
- Either<GraphVertex, TitanOperationStatus> getVertexEither = titanDao.getVertexById(componentId, JsonParseFlagEnum.NoParse);
- if (getVertexEither.isRight()) {
- log.debug("Couldn't fetch component with and unique id {}, error: {}", componentId, getVertexEither.right().value());
- return Either.right(DaoStatusConverter.convertTitanStatusToStorageStatus(getVertexEither.right().value()));
-
- }
+ public Either<Map<String, List<ComponentInstanceInput>>, StorageOperationStatus> addComponentInstanceInputsToComponent(Component containerComponent, Map<String, List<ComponentInstanceInput>> instProperties) {
- GraphVertex vertex = getVertexEither.left().value();
- Map<String, MapPropertiesDataDefinition> instPropsMap = new HashMap<>();
+ StorageOperationStatus status = StorageOperationStatus.OK;
if (instProperties != null) {
- MapPropertiesDataDefinition propertiesMap;
for (Entry<String, List<ComponentInstanceInput>> entry : instProperties.entrySet()) {
- propertiesMap = new MapPropertiesDataDefinition();
-
- propertiesMap.setMapToscaDataDefinition(entry.getValue().stream().map(e -> new PropertyDataDefinition(e)).collect(Collectors.toMap(e -> e.getName(), e -> e)));
-
- instPropsMap.put(entry.getKey(), propertiesMap);
+ List<ComponentInstanceInput> props = entry.getValue();
+ String componentInstanseId = entry.getKey();
+ if (props != null && !props.isEmpty()) {
+ for (ComponentInstanceInput property : props) {
+ List<ComponentInstanceInput> componentInstancesInputs = containerComponent.getComponentInstancesInputs().get(componentInstanseId);
+ Optional<ComponentInstanceInput> instanceProperty = componentInstancesInputs.stream().filter(p -> p.getName().equals(property.getName())).findAny();
+ if (instanceProperty.isPresent()) {
+ status = updateComponentInstanceInput(containerComponent, componentInstanseId, property);
+ } else {
+ status = addComponentInstanceInput(containerComponent, componentInstanseId, property);
+ }
+ if (status != StorageOperationStatus.OK) {
+ log.debug("Failed to update instance input {} for instance {} error {} ", property, componentInstanseId, status);
+ return Either.right(status);
+ } else {
+ log.trace("instance input {} for instance {} updated", property, componentInstanseId);
+ }
+ }
+ }
}
}
-
- StorageOperationStatus status = topologyTemplateOperation.addInstInputsToComponent(vertex, instPropsMap);
-
- if (StorageOperationStatus.OK == status) {
- log.debug("Component created successfully!!!");
- return Either.left(instProperties);
- }
- return Either.right(status);
-
+ return Either.left(instProperties);
}
public StorageOperationStatus deleteComponentInstanceInputsToComponent(Map<String, List<ComponentInstanceInput>> instProperties, String componentId) {
@@ -1148,7 +1144,7 @@ public class ToscaOperationFacade {
}
- public StorageOperationStatus associateInstAttributeToComponentToInstances(Map<String, List<AttributeDefinition>> instArttributes, String componentId) {
+ public StorageOperationStatus associateInstAttributeToComponentToInstances(Map<String, List<PropertyDefinition>> instArttributes, String componentId) {
Either<GraphVertex, TitanOperationStatus> getVertexEither = titanDao.getVertexById(componentId, JsonParseFlagEnum.NoParse);
if (getVertexEither.isRight()) {
@@ -1158,13 +1154,13 @@ public class ToscaOperationFacade {
}
GraphVertex vertex = getVertexEither.left().value();
- Map<String, MapAttributesDataDefinition> instAttr = new HashMap<>();
+ Map<String, MapPropertiesDataDefinition> instAttr = new HashMap<>();
if (instArttributes != null) {
- MapAttributesDataDefinition attributesMap;
- for (Entry<String, List<AttributeDefinition>> entry : instArttributes.entrySet()) {
- attributesMap = new MapAttributesDataDefinition();
- attributesMap.setMapToscaDataDefinition(entry.getValue().stream().map(e -> new AttributeDataDefinition(e)).collect(Collectors.toMap(e -> e.getName(), e -> e)));
+ MapPropertiesDataDefinition attributesMap;
+ for (Entry<String, List<PropertyDefinition>> entry : instArttributes.entrySet()) {
+ attributesMap = new MapPropertiesDataDefinition();
+ attributesMap.setMapToscaDataDefinition(entry.getValue().stream().map(e -> new PropertyDataDefinition(e)).collect(Collectors.toMap(e -> e.getName(), e -> e)));
instAttr.put(entry.getKey(), attributesMap);
}
}
@@ -1184,9 +1180,10 @@ public class ToscaOperationFacade {
GraphVertex vertex = getVertexEither.left().value();
Map<String, MapListRequirementDataDefinition> calcRequirements = new HashMap<>();
-
+
Map<String, MapListCapabiltyDataDefinition> calcCapabilty = new HashMap<>();
- Map<String, MapCapabiltyProperty> calculatedCapabilitiesProperties = new HashMap<>();;
+ Map<String, MapCapabiltyProperty> calculatedCapabilitiesProperties = new HashMap<>();
+ ;
if (instCapabilties != null) {
for (Entry<ComponentInstance, Map<String, List<CapabilityDefinition>>> entry : instCapabilties.entrySet()) {
@@ -1200,7 +1197,7 @@ public class ToscaOperationFacade {
MapListCapabiltyDataDefinition capMap = nodeTemplateOperation.prepareCalculatedCapabiltyForNodeType(mapToscaDataDefinition, componentInstance);
MapCapabiltyProperty mapCapabiltyProperty = ModelConverter.convertToMapOfMapCapabiltyProperties(caps, componentInstance.getUniqueId(), true);
-
+
calcCapabilty.put(entry.getKey().getUniqueId(), capMap);
calculatedCapabilitiesProperties.put(entry.getKey().getUniqueId(), mapCapabiltyProperty);
}
@@ -1226,8 +1223,7 @@ public class ToscaOperationFacade {
return status;
}
- private Either<List<Component>, StorageOperationStatus> getLatestVersionNotAbstractToscaElementsMetadataOnly(boolean isAbstract, Boolean isHighest, ComponentTypeEnum componentTypeEnum, String internalComponentType,
- VertexTypeEnum vertexType) {
+ private Either<List<Component>, StorageOperationStatus> getLatestVersionNotAbstractToscaElementsMetadataOnly(boolean isAbstract, Boolean isHighest, ComponentTypeEnum componentTypeEnum, String internalComponentType, VertexTypeEnum vertexType) {
Map<GraphPropertyEnum, Object> hasProps = new EnumMap<>(GraphPropertyEnum.class);
Map<GraphPropertyEnum, Object> hasNotProps = new EnumMap<>(GraphPropertyEnum.class);
@@ -1242,33 +1238,35 @@ public class ToscaOperationFacade {
return Either.right(DaoStatusConverter.convertTitanStatusToStorageStatus(getRes.right().value()));
}
} else {
- List<Component> nonAbstractLatestComponents = new ArrayList<>();
- ComponentParametersView params = new ComponentParametersView(true);
- params.setIgnoreAllVersions(false);
- for (GraphVertex vertexComponent : getRes.left().value()) {
- Either<ToscaElement, StorageOperationStatus> componentRes = topologyTemplateOperation.getLightComponent(vertexComponent, componentTypeEnum, params);
- if (componentRes.isRight()) {
- log.debug("Failed to fetch ligth element for {} error {}", vertexComponent.getUniqueId(), componentRes.right().value());
- return Either.right(componentRes.right().value());
- } else {
- Component component = ModelConverter.convertFromToscaElement(componentRes.left().value());
-
- nonAbstractLatestComponents.add(component);
- }
- }
+ List<Component> nonAbstractLatestComponents = new ArrayList<>();
+ ComponentParametersView params = new ComponentParametersView(true);
+ params.setIgnoreAllVersions(false);
+ for (GraphVertex vertexComponent : getRes.left().value()) {
+ Either<ToscaElement, StorageOperationStatus> componentRes = topologyTemplateOperation.getLightComponent(vertexComponent, componentTypeEnum, params);
+ if (componentRes.isRight()) {
+ log.debug("Failed to fetch ligth element for {} error {}", vertexComponent.getUniqueId(), componentRes.right().value());
+ return Either.right(componentRes.right().value());
+ } else {
+ Component component = ModelConverter.convertFromToscaElement(componentRes.left().value());
+
+ nonAbstractLatestComponents.add(component);
+ }
+ }
return Either.left(nonAbstractLatestComponents);
}
}
- public Either<ComponentMetadataData, StorageOperationStatus> getLatestComponentMetadataByUuid(String componentUuid, JsonParseFlagEnum parseFlag) {
+ public Either<ComponentMetadataData, StorageOperationStatus> getLatestComponentMetadataByUuid(String componentUuid, JsonParseFlagEnum parseFlag, Boolean isHighest) {
Either<ComponentMetadataData, StorageOperationStatus> result;
Map<GraphPropertyEnum, Object> hasProperties = new EnumMap<>(GraphPropertyEnum.class);
hasProperties.put(GraphPropertyEnum.UUID, componentUuid);
- hasProperties.put(GraphPropertyEnum.IS_HIGHEST_VERSION, true);
+ if (isHighest != null) {
+ hasProperties.put(GraphPropertyEnum.IS_HIGHEST_VERSION, isHighest.booleanValue());
+ }
Map<GraphPropertyEnum, Object> propertiesNotToMatch = new EnumMap<>(GraphPropertyEnum.class);
propertiesNotToMatch.put(GraphPropertyEnum.IS_DELETED, true);
@@ -1499,6 +1497,7 @@ public class ToscaOperationFacade {
hasNotProps.put(GraphPropertyEnum.STATE, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT.name());
hasNotProps.put(GraphPropertyEnum.IS_DELETED, true);
+ hasProps.put(GraphPropertyEnum.IS_HIGHEST_VERSION, true);
if (VertexTypeEnum.NODE_TYPE == internalVertexType) {
hasProps.put(GraphPropertyEnum.IS_ABSTRACT, isAbstract);
if (internalComponentType != null) {
@@ -1533,21 +1532,21 @@ public class ToscaOperationFacade {
return Either.left(result);
}
-
+
public Either<List<Component>, StorageOperationStatus> getLatestComponentListByUuid(String componentUuid) {
Map<GraphPropertyEnum, Object> propertiesToMatch = new EnumMap<>(GraphPropertyEnum.class);
propertiesToMatch.put(GraphPropertyEnum.IS_HIGHEST_VERSION, true);
return getComponentListByUuid(componentUuid, propertiesToMatch);
}
-
+
public Either<List<Component>, StorageOperationStatus> getComponentListByUuid(String componentUuid, Map<GraphPropertyEnum, Object> additionalPropertiesToMatch) {
-
+
Map<GraphPropertyEnum, Object> propertiesToMatch = new EnumMap<>(GraphPropertyEnum.class);
-
- if(additionalPropertiesToMatch != null){
+
+ if (additionalPropertiesToMatch != null) {
propertiesToMatch.putAll(additionalPropertiesToMatch);
}
-
+
propertiesToMatch.put(GraphPropertyEnum.UUID, componentUuid);
Map<GraphPropertyEnum, Object> propertiesNotToMatch = new EnumMap<>(GraphPropertyEnum.class);
@@ -1781,14 +1780,14 @@ public class ToscaOperationFacade {
}
public Either<Service, StorageOperationStatus> updateDistributionStatus(Service service, User user, DistributionStatusEnum distributionStatus) {
- Either<GraphVertex, StorageOperationStatus> updateDistributionStatus = topologyTemplateOperation.updateDistributionStatus(service.getUniqueId(), user, distributionStatus);
- if ( updateDistributionStatus.isRight() ){
- return Either.right(updateDistributionStatus.right().value());
- }
- GraphVertex serviceV = updateDistributionStatus.left().value();
- service.setDistributionStatus(distributionStatus);
- service.setLastUpdateDate((Long) serviceV.getJsonMetadataField(JsonPresentationFields.LAST_UPDATE_DATE));
- return Either.left(service);
+ Either<GraphVertex, StorageOperationStatus> updateDistributionStatus = topologyTemplateOperation.updateDistributionStatus(service.getUniqueId(), user, distributionStatus);
+ if (updateDistributionStatus.isRight()) {
+ return Either.right(updateDistributionStatus.right().value());
+ }
+ GraphVertex serviceV = updateDistributionStatus.left().value();
+ service.setDistributionStatus(distributionStatus);
+ service.setLastUpdateDate((Long) serviceV.getJsonMetadataField(JsonPresentationFields.LAST_UPDATE_DATE));
+ return Either.left(service);
}
public Either<ComponentMetadataData, StorageOperationStatus> updateComponentLastUpdateDateOnGraph(Component component, Long modificationTime) {
@@ -1821,25 +1820,25 @@ public class ToscaOperationFacade {
public TitanDao getTitanDao() {
return titanDao;
}
-
+
public Either<List<Service>, StorageOperationStatus> getCertifiedServicesWithDistStatus(Set<DistributionStatusEnum> distStatus) {
Map<GraphPropertyEnum, Object> propertiesToMatch = new EnumMap<>(GraphPropertyEnum.class);
propertiesToMatch.put(GraphPropertyEnum.STATE, LifecycleStateEnum.CERTIFIED.name());
-
+
return getServicesWithDistStatus(distStatus, propertiesToMatch);
}
-
+
public Either<List<Service>, StorageOperationStatus> getServicesWithDistStatus(Set<DistributionStatusEnum> distStatus, Map<GraphPropertyEnum, Object> additionalPropertiesToMatch) {
List<Service> servicesAll = new ArrayList<>();
Map<GraphPropertyEnum, Object> propertiesToMatch = new EnumMap<>(GraphPropertyEnum.class);
Map<GraphPropertyEnum, Object> propertiesNotToMatch = new EnumMap<>(GraphPropertyEnum.class);
-
- if(additionalPropertiesToMatch != null && !additionalPropertiesToMatch.isEmpty()) {
+
+ if (additionalPropertiesToMatch != null && !additionalPropertiesToMatch.isEmpty()) {
propertiesToMatch.putAll(additionalPropertiesToMatch);
}
-
+
propertiesToMatch.put(GraphPropertyEnum.COMPONENT_TYPE, ComponentTypeEnum.SERVICE.name());
propertiesNotToMatch.put(GraphPropertyEnum.IS_DELETED, true);
@@ -1848,10 +1847,9 @@ public class ToscaOperationFacade {
for (DistributionStatusEnum state : distStatus) {
propertiesToMatch.put(GraphPropertyEnum.DISTRIBUTION_STATUS, state.name());
Either<List<Service>, StorageOperationStatus> fetchServicesByCriteria = fetchServicesByCriteria(servicesAll, propertiesToMatch, propertiesNotToMatch);
- if ( fetchServicesByCriteria.isRight() ){
+ if (fetchServicesByCriteria.isRight()) {
return fetchServicesByCriteria;
- }
- else{
+ } else {
servicesAll = fetchServicesByCriteria.left().value();
}
}
@@ -1861,6 +1859,27 @@ public class ToscaOperationFacade {
}
}
+ // private Either<List<Service>, StorageOperationStatus> fetchServicesByCriteria(List<Service> servicesAll, Map<GraphPropertyEnum, Object> propertiesToMatch, Map<GraphPropertyEnum, Object> propertiesNotToMatch) {
+ // Either<List<GraphVertex>, TitanOperationStatus> getRes = titanDao.getByCriteria(VertexTypeEnum.TOPOLOGY_TEMPLATE, propertiesToMatch, propertiesNotToMatch, JsonParseFlagEnum.ParseAll);
+ // if (getRes.isRight()) {
+ // if (getRes.right().value() != TitanOperationStatus.NOT_FOUND) {
+ // CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to fetch certified services by match properties {} not match properties {} . Status is {}. ", propertiesToMatch, propertiesNotToMatch, getRes.right().value());
+ // return Either.right(DaoStatusConverter.convertTitanStatusToStorageStatus(getRes.right().value()));
+ // }
+ // } else {
+ // for (GraphVertex vertex : getRes.left().value()) {
+ // Either<Component, StorageOperationStatus> getServiceRes = getToscaElementByOperation(vertex);
+ // if (getServiceRes.isRight()) {
+ // CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to fetch certified service {}. Status is {}. ", vertex.getJsonMetadataField(JsonPresentationFields.NAME), getServiceRes.right().value());
+ // return Either.right(getServiceRes.right().value());
+ // } else {
+ // servicesAll.add((Service) getToscaElementByOperation(vertex).left().value());
+ // }
+ // }
+ // }
+ // return Either.left(servicesAll);
+ // }
+
private Either<List<Service>, StorageOperationStatus> fetchServicesByCriteria(List<Service> servicesAll, Map<GraphPropertyEnum, Object> propertiesToMatch, Map<GraphPropertyEnum, Object> propertiesNotToMatch) {
Either<List<GraphVertex>, TitanOperationStatus> getRes = titanDao.getByCriteria(VertexTypeEnum.TOPOLOGY_TEMPLATE, propertiesToMatch, propertiesNotToMatch, JsonParseFlagEnum.ParseAll);
if (getRes.isRight()) {
@@ -1870,12 +1889,14 @@ public class ToscaOperationFacade {
}
} else {
for (GraphVertex vertex : getRes.left().value()) {
- Either<Component, StorageOperationStatus> getServiceRes = getToscaElementByOperation(vertex);
+ // Either<Component, StorageOperationStatus> getServiceRes = getToscaElementByOperation(vertex);
+ Either<ToscaElement, StorageOperationStatus> getServiceRes = topologyTemplateOperation.getLightComponent(vertex, ComponentTypeEnum.SERVICE, new ComponentParametersView(true));
+
if (getServiceRes.isRight()) {
CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to fetch certified service {}. Status is {}. ", vertex.getJsonMetadataField(JsonPresentationFields.NAME), getServiceRes.right().value());
return Either.right(getServiceRes.right().value());
} else {
- servicesAll.add((Service) getToscaElementByOperation(vertex).left().value());
+ servicesAll.add(ModelConverter.convertFromToscaElement(getServiceRes.left().value()));
}
}
}
@@ -1942,7 +1963,7 @@ public class ToscaOperationFacade {
public StorageOperationStatus deletePropertyOfResource(Resource resource, String propertyName) {
return getToscaElementOperation(resource).deleteToscaDataElement(resource.getUniqueId(), EdgeLabelEnum.PROPERTIES, VertexTypeEnum.PROPERTIES, propertyName, JsonPresentationFields.NAME);
}
-
+
public StorageOperationStatus deleteAttributeOfResource(Component component, String attributeName) {
return getToscaElementOperation(component).deleteToscaDataElement(component.getUniqueId(), EdgeLabelEnum.ATTRIBUTES, VertexTypeEnum.ATTRIBUTES, attributeName, JsonPresentationFields.NAME);
}
@@ -1980,16 +2001,16 @@ public class ToscaOperationFacade {
}
return result;
}
-
- public Either<AttributeDefinition, StorageOperationStatus> addAttributeOfResource(Component component, AttributeDefinition newAttributeDef) {
+
+ public Either<PropertyDefinition, StorageOperationStatus> addAttributeOfResource(Component component, PropertyDefinition newAttributeDef) {
Either<Component, StorageOperationStatus> getUpdatedComponentRes = null;
- Either<AttributeDefinition, StorageOperationStatus> result = null;
- if(newAttributeDef.getUniqueId() == null || newAttributeDef.getUniqueId().isEmpty()){
+ Either<PropertyDefinition, StorageOperationStatus> result = null;
+ if (newAttributeDef.getUniqueId() == null || newAttributeDef.getUniqueId().isEmpty()) {
String attUniqueId = UniqueIdBuilder.buildAttributeUid(component.getUniqueId(), newAttributeDef.getName());
newAttributeDef.setUniqueId(attUniqueId);
}
-
+
StorageOperationStatus status = getToscaElementOperation(component).addToscaDataToToscaElement(component.getUniqueId(), EdgeLabelEnum.ATTRIBUTES, VertexTypeEnum.ATTRIBUTES, newAttributeDef, JsonPresentationFields.NAME);
if (status != StorageOperationStatus.OK) {
CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to add the property {} to the resource {}. Status is {}. ", newAttributeDef.getName(), component.getName(), status);
@@ -2005,7 +2026,7 @@ public class ToscaOperationFacade {
}
}
if (result == null) {
- Optional<AttributeDefinition> newAttribute = ((Resource) getUpdatedComponentRes.left().value()).getAttributes().stream().filter(p -> p.getName().equals(newAttributeDef.getName())).findAny();
+ Optional<PropertyDefinition> newAttribute = ((Resource) getUpdatedComponentRes.left().value()).getAttributes().stream().filter(p -> p.getName().equals(newAttributeDef.getName())).findAny();
if (newAttribute.isPresent()) {
result = Either.left(newAttribute.get());
} else {
@@ -2015,11 +2036,11 @@ public class ToscaOperationFacade {
}
return result;
}
-
- public Either<AttributeDefinition, StorageOperationStatus> updateAttributeOfResource(Component component, AttributeDefinition newAttributeDef) {
+
+ public Either<PropertyDefinition, StorageOperationStatus> updateAttributeOfResource(Component component, PropertyDefinition newAttributeDef) {
Either<Component, StorageOperationStatus> getUpdatedComponentRes = null;
- Either<AttributeDefinition, StorageOperationStatus> result = null;
+ Either<PropertyDefinition, StorageOperationStatus> result = null;
StorageOperationStatus status = getToscaElementOperation(component).updateToscaDataOfToscaElement(component.getUniqueId(), EdgeLabelEnum.ATTRIBUTES, VertexTypeEnum.ATTRIBUTES, newAttributeDef, JsonPresentationFields.NAME);
if (status != StorageOperationStatus.OK) {
CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to add the property {} to the resource {}. Status is {}. ", newAttributeDef.getName(), component.getName(), status);
@@ -2035,7 +2056,7 @@ public class ToscaOperationFacade {
}
}
if (result == null) {
- Optional<AttributeDefinition> newProperty = ((Resource) getUpdatedComponentRes.left().value()).getAttributes().stream().filter(p -> p.getName().equals(newAttributeDef.getName())).findAny();
+ Optional<PropertyDefinition> newProperty = ((Resource) getUpdatedComponentRes.left().value()).getAttributes().stream().filter(p -> p.getName().equals(newAttributeDef.getName())).findAny();
if (newProperty.isPresent()) {
result = Either.left(newProperty.get());
} else {
@@ -2045,7 +2066,7 @@ public class ToscaOperationFacade {
}
return result;
}
-
+
public Either<InputDefinition, StorageOperationStatus> updateInputOfComponent(Component component, InputDefinition newInputDefinition) {
Either<Component, StorageOperationStatus> getUpdatedComponentRes = null;
@@ -2103,7 +2124,7 @@ public class ToscaOperationFacade {
public StorageOperationStatus addComponentInstanceProperty(Component containerComponent, String componentInstanceId, ComponentInstanceProperty property) {
return nodeTemplateOperation.addComponentInstanceProperty(containerComponent, componentInstanceId, property);
}
-
+
public StorageOperationStatus updateComponentInstanceInput(Component containerComponent, String componentInstanceId, ComponentInstanceInput property) {
return nodeTemplateOperation.updateComponentInstanceInput(containerComponent, componentInstanceId, property);
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/utils/ModelConverter.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/utils/ModelConverter.java
index 07845c8ea5..e6f9ff6f93 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/utils/ModelConverter.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/utils/ModelConverter.java
@@ -21,11 +21,9 @@ import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
import org.openecomp.sdc.be.model.AdditionalInformationDefinition;
import org.openecomp.sdc.be.model.ArtifactDefinition;
-import org.openecomp.sdc.be.model.AttributeDefinition;
import org.openecomp.sdc.be.model.CapabilityDefinition;
import org.openecomp.sdc.be.model.Component;
import org.openecomp.sdc.be.model.ComponentInstance;
-import org.openecomp.sdc.be.model.ComponentInstanceAttribute;
import org.openecomp.sdc.be.model.ComponentInstanceInput;
import org.openecomp.sdc.be.model.ComponentInstanceProperty;
import org.openecomp.sdc.be.model.DistributionStatusEnum;
@@ -168,15 +166,15 @@ public class ModelConverter {
}
private static void convertAttributes(NodeType nodeType, Resource resource) {
- Map<String, AttributeDataDefinition> attributes = nodeType.getAttributes();
+ Map<String, PropertyDataDefinition> attributes = nodeType.getAttributes();
if (attributes != null) {
- List<AttributeDefinition> attrs = attributes.values().stream().map(dataDef -> ModelConverter.fromDataDefinition(resource.getUniqueId(), dataDef)).collect(Collectors.toList());
+ List<PropertyDefinition> attrs = attributes.values().stream().map(dataDef -> ModelConverter.fromDataDefinition(resource.getUniqueId(), dataDef)).collect(Collectors.toList());
resource.setAttributes(attrs);
}
}
- private static AttributeDefinition fromDataDefinition(String resourceId, AttributeDataDefinition dataDefinition) {
- AttributeDefinition attributeDefinition = new AttributeDefinition(dataDefinition);
+ private static PropertyDefinition fromDataDefinition(String resourceId, PropertyDataDefinition dataDefinition) {
+ PropertyDefinition attributeDefinition = new PropertyDefinition(dataDefinition);
attributeDefinition.setParentUniqueId(resourceId);
return attributeDefinition;
}
@@ -684,9 +682,9 @@ public class ModelConverter {
}
private static void convertAttributes(Resource component, NodeType nodeType) {
- List<AttributeDefinition> attributes = component.getAttributes();
+ List<PropertyDefinition> attributes = component.getAttributes();
if (attributes != null) {
- Map<String, AttributeDataDefinition> attrsByName = attributes.stream().map(AttributeDataDefinition::new).collect(Collectors.toMap(AttributeDataDefinition::getName, Function.identity()));
+ Map<String, PropertyDataDefinition> attrsByName = attributes.stream().map(PropertyDataDefinition::new).collect(Collectors.toMap(PropertyDataDefinition::getName, Function.identity()));
nodeType.setAttributes(attrsByName);
}
}
@@ -997,11 +995,11 @@ public class ModelConverter {
private static void setComponentInstancesAttributesToComponent(TopologyTemplate topologyTemplate, Component component) {
if (topologyTemplate.getInstAttributes() != null) {
- Map<String, List<ComponentInstanceAttribute>> attributes = new HashMap<>();
- for (Map.Entry<String, MapAttributesDataDefinition> entry : topologyTemplate.getInstAttributes().entrySet()) {
+ Map<String, List<ComponentInstanceProperty>> attributes = new HashMap<>();
+ for (Map.Entry<String, MapPropertiesDataDefinition> entry : topologyTemplate.getInstAttributes().entrySet()) {
if (entry.getValue() != null && entry.getValue().getMapToscaDataDefinition() != null) {
String key = entry.getKey();
- List<ComponentInstanceAttribute> componentInstanceAttributes = entry.getValue().getMapToscaDataDefinition().entrySet().stream().map(e -> new ComponentInstanceAttribute(new AttributeDefinition(e.getValue())))
+ List<ComponentInstanceProperty> componentInstanceAttributes = entry.getValue().getMapToscaDataDefinition().entrySet().stream().map(e -> new ComponentInstanceProperty(new ComponentInstanceProperty(e.getValue())))
.collect(Collectors.toList());
attributes.put(key, componentInstanceAttributes);
}
@@ -1206,11 +1204,11 @@ public class ModelConverter {
if (component.getComponentInstancesAttributes() != null) {
topologyTemplate.setInstAttributes(new HashMap<>());
- MapAttributesDataDefinition attributesMap;
- for (Entry<String, List<ComponentInstanceAttribute>> entry : component.getComponentInstancesAttributes().entrySet()) {
- attributesMap = new MapAttributesDataDefinition();
+ MapPropertiesDataDefinition attributesMap;
+ for (Entry<String, List<ComponentInstanceProperty>> entry : component.getComponentInstancesAttributes().entrySet()) {
+ attributesMap = new MapPropertiesDataDefinition();
- attributesMap.setMapToscaDataDefinition(entry.getValue().stream().map(e -> new AttributeDataDefinition(e)).collect(Collectors.toMap(e -> e.getName(), e -> e)));
+ attributesMap.setMapToscaDataDefinition(entry.getValue().stream().map(e -> new PropertyDataDefinition(e)).collect(Collectors.toMap(e -> e.getName(), e -> e)));
topologyTemplate.getInstAttributes().put(entry.getKey(), attributesMap);
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/api/IAttributeOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/api/IAttributeOperation.java
index db2b988f5f..c5fc70eb38 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/api/IAttributeOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/api/IAttributeOperation.java
@@ -25,10 +25,10 @@ import java.util.Map;
import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import org.openecomp.sdc.be.model.AttributeDefinition;
import org.openecomp.sdc.be.model.ComponentInstance;
-import org.openecomp.sdc.be.model.ComponentInstanceAttribute;
+import org.openecomp.sdc.be.model.ComponentInstanceProperty;
import org.openecomp.sdc.be.model.DataTypeDefinition;
+import org.openecomp.sdc.be.model.PropertyDefinition;
import org.openecomp.sdc.be.resources.data.AttributeData;
import org.openecomp.sdc.be.resources.data.AttributeValueData;
@@ -39,23 +39,23 @@ import fj.data.Either;
public interface IAttributeOperation {
Either<AttributeData, StorageOperationStatus> deleteAttribute(String attributeId);
- TitanOperationStatus addAttributesToGraph(TitanVertex metadataVertex, Map<String, AttributeDefinition> attributes, String resourceId, Map<String, DataTypeDefinition> dataTypes);
+ TitanOperationStatus addAttributesToGraph(TitanVertex metadataVertex, Map<String, PropertyDefinition> attributes, String resourceId, Map<String, DataTypeDefinition> dataTypes);
- Either<List<ComponentInstanceAttribute>, TitanOperationStatus> getAllAttributesOfResourceInstance(ComponentInstance compInstance);
+ Either<List<ComponentInstanceProperty>, TitanOperationStatus> getAllAttributesOfResourceInstance(ComponentInstance compInstance);
- TitanOperationStatus findAllResourceAttributesRecursively(String resourceId, List<AttributeDefinition> attributes);
+ TitanOperationStatus findAllResourceAttributesRecursively(String resourceId, List<PropertyDefinition> attributes);
- Either<Map<String, AttributeDefinition>, StorageOperationStatus> deleteAllAttributeAssociatedToNode(NodeTypeEnum nodeType, String uniqueId);
+ Either<Map<String, PropertyDefinition>, StorageOperationStatus> deleteAllAttributeAssociatedToNode(NodeTypeEnum nodeType, String uniqueId);
- TitanOperationStatus findNodeNonInheretedAttribues(String uniqueId, NodeTypeEnum nodeType, List<AttributeDefinition> attributes);
+ TitanOperationStatus findNodeNonInheretedAttribues(String uniqueId, NodeTypeEnum nodeType, List<PropertyDefinition> attributes);
- Either<AttributeData, StorageOperationStatus> addAttribute(AttributeDefinition attributeDefinition, String resourceId);
+ Either<AttributeData, StorageOperationStatus> addAttribute(PropertyDefinition attributeDefinition, String resourceId);
- Either<AttributeData, TitanOperationStatus> addAttributeToGraph(AttributeDefinition attribute, String resourceId, Map<String, DataTypeDefinition> dataTypes);
+ Either<AttributeData, TitanOperationStatus> addAttributeToGraph(PropertyDefinition attribute, String resourceId, Map<String, DataTypeDefinition> dataTypes);
- AttributeDefinition convertAttributeDataToAttributeDefinition(AttributeData attributeData, String attributeName, String resourceId);
+ PropertyDefinition convertAttributeDataToAttributeDefinition(AttributeData attributeData, String attributeName, String resourceId);
- Either<AttributeData, StorageOperationStatus> updateAttribute(String attributeId, AttributeDefinition newAttDef, Map<String, DataTypeDefinition> dataTypes);
+ Either<AttributeData, StorageOperationStatus> updateAttribute(String attributeId, PropertyDefinition newAttDef, Map<String, DataTypeDefinition> dataTypes);
/**
* Builds ComponentInstanceAttribute from AttributeValueData
@@ -64,8 +64,8 @@ public interface IAttributeOperation {
* @param resourceInstanceAttribute
* @return
*/
- ComponentInstanceAttribute buildResourceInstanceAttribute(AttributeValueData attributeValueData, ComponentInstanceAttribute resourceInstanceAttribute);
+ ComponentInstanceProperty buildResourceInstanceAttribute(AttributeValueData attributeValueData, ComponentInstanceProperty resourceInstanceAttribute);
- TitanOperationStatus addAttributeToGraphByVertex(TitanVertex metadataVertex, AttributeDefinition attribute, String resourceId, Map<String, DataTypeDefinition> dataTypes);
+ TitanOperationStatus addAttributeToGraphByVertex(TitanVertex metadataVertex, PropertyDefinition attribute, String resourceId, Map<String, DataTypeDefinition> dataTypes);
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/api/IComponentInstanceOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/api/IComponentInstanceOperation.java
index 28e70ad127..f4cb13fa64 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/api/IComponentInstanceOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/api/IComponentInstanceOperation.java
@@ -30,7 +30,6 @@ import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
import org.openecomp.sdc.be.model.ArtifactDefinition;
import org.openecomp.sdc.be.model.ComponentInstance;
-import org.openecomp.sdc.be.model.ComponentInstanceAttribute;
import org.openecomp.sdc.be.model.ComponentInstanceInput;
import org.openecomp.sdc.be.model.ComponentInstanceProperty;
import org.openecomp.sdc.be.model.RequirementAndRelationshipPair;
@@ -196,7 +195,7 @@ public interface IComponentInstanceOperation {
* * @param resourceInstanceId * @param index * @param inTransaction
* @return
**/
- public Either<ComponentInstanceAttribute, StorageOperationStatus> addAttributeValueToResourceInstance(ComponentInstanceAttribute resourceInstanceAttribute, String resourceInstanceId, Integer index, boolean inTransaction);
+ public Either<ComponentInstanceProperty, StorageOperationStatus> addAttributeValueToResourceInstance(ComponentInstanceProperty resourceInstanceAttribute, String resourceInstanceId, Integer index, boolean inTransaction);
public Either<ComponentInstanceProperty, StorageOperationStatus> updatePropertyValueInResourceInstance(ComponentInstanceProperty resourceInstanceProperty, String resourceInstanceId, boolean inTransaction);
@@ -208,9 +207,9 @@ public interface IComponentInstanceOperation {
* @param inTransaction
* @return
*/
- public Either<ComponentInstanceAttribute, StorageOperationStatus> updateAttributeValueInResourceInstance(ComponentInstanceAttribute attribute, String resourceInstanceId, boolean inTransaction);
+ public Either<ComponentInstanceProperty, StorageOperationStatus> updateAttributeValueInResourceInstance(ComponentInstanceProperty attribute, String resourceInstanceId, boolean inTransaction);
- public Either<AttributeValueData, TitanOperationStatus> createOrUpdateAttributeOfResourceInstance(ComponentInstanceAttribute attributeInstanceProperty, String resourceInstanceId);
+ public Either<AttributeValueData, TitanOperationStatus> createOrUpdateAttributeOfResourceInstance(ComponentInstanceProperty attributeInstanceProperty, String resourceInstanceId);
public Either<ComponentInstanceInput, StorageOperationStatus> addInputValueToResourceInstance(ComponentInstanceInput input, String resourceInstanceId, Integer innerElement, boolean b);
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/api/IConsumerOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/api/IConsumerOperation.java
index ed43b7ce1f..cab49fe47d 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/api/IConsumerOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/api/IConsumerOperation.java
@@ -24,6 +24,8 @@ import org.openecomp.sdc.be.resources.data.ConsumerData;
import fj.data.Either;
+import java.util.List;
+
public interface IConsumerOperation {
/**
@@ -95,4 +97,10 @@ public interface IConsumerOperation {
*/
Either<ConsumerData, StorageOperationStatus> getCredentials(String consumerName);
+ /**
+ *
+ * @return all consumers
+ */
+ Either<List<ConsumerData>, StorageOperationStatus> getAll();
+
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/api/IResourceOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/api/IResourceOperation.java
index 01db3a5105..8d9994ba8a 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/api/IResourceOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/api/IResourceOperation.java
@@ -137,10 +137,5 @@ public interface IResourceOperation extends IComponentOperation {
*/
Either<List<Resource>, StorageOperationStatus> getVFResources();
- /**
- *
- * @return all resources
- */
- Either<List<Resource>, StorageOperationStatus> getAll();
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/api/IUserAdminOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/api/IUserAdminOperation.java
index 84413f7987..254432c682 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/api/IUserAdminOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/api/IUserAdminOperation.java
@@ -50,7 +50,7 @@ public interface IUserAdminOperation {
Either<List<User>, ActionStatus> getAllUsers();
- public Either<List<Edge>, StorageOperationStatus> getUserPandingTasksList(User user, Map<String, Object> properties);
+ public Either<List<Edge>, StorageOperationStatus> getUserPendingTasksList(User user, Map<String, Object> properties);
public Either<ImmutablePair<User, FunctionalMenuInfo>, ActionStatus> getUserDataWithFunctionalMenu(String userId);
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/AttributeOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/AttributeOperation.java
index f82a2982b0..279aab667c 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/AttributeOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/AttributeOperation.java
@@ -35,12 +35,12 @@ import org.apache.commons.lang3.tuple.ImmutablePair;
import org.openecomp.sdc.be.dao.graph.datatype.GraphEdge;
import org.openecomp.sdc.be.dao.neo4j.GraphEdgeLabels;
import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
-import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import org.openecomp.sdc.be.model.AttributeDefinition;
import org.openecomp.sdc.be.model.ComponentInstance;
-import org.openecomp.sdc.be.model.ComponentInstanceAttribute;
+import org.openecomp.sdc.be.model.ComponentInstanceProperty;
import org.openecomp.sdc.be.model.DataTypeDefinition;
+import org.openecomp.sdc.be.model.PropertyDefinition;
import org.openecomp.sdc.be.model.operations.api.IAttributeOperation;
import org.openecomp.sdc.be.model.operations.api.IPropertyOperation;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
@@ -81,7 +81,7 @@ public class AttributeOperation extends AbstractOperation implements IAttributeO
* @param attributeDefinition
* @return
*/
- private Either<AttributeData, TitanOperationStatus> addAttributeToNodeType(AttributeDefinition attributeDefinition, NodeTypeEnum nodeType, String nodeUniqueId) {
+ private Either<AttributeData, TitanOperationStatus> addAttributeToNodeType(PropertyDefinition attributeDefinition, NodeTypeEnum nodeType, String nodeUniqueId) {
String attUniqueId = UniqueIdBuilder.buildAttributeUid(nodeUniqueId, attributeDefinition.getName());
Supplier<AttributeData> dataBuilder = () -> buildAttributeData(attributeDefinition, attUniqueId);
Supplier<String> defNameGenerator = () -> "Attribute : " + attributeDefinition.getName();
@@ -90,7 +90,7 @@ public class AttributeOperation extends AbstractOperation implements IAttributeO
}
- private TitanOperationStatus addAttributeToNodeType(TitanVertex metadataVertex, AttributeDefinition attributeDefinition, NodeTypeEnum nodeType, String nodeUniqueId) {
+ private TitanOperationStatus addAttributeToNodeType(TitanVertex metadataVertex, PropertyDefinition attributeDefinition, NodeTypeEnum nodeType, String nodeUniqueId) {
String attUniqueId = UniqueIdBuilder.buildAttributeUid(nodeUniqueId, attributeDefinition.getName());
Supplier<AttributeData> dataBuilder = () -> buildAttributeData(attributeDefinition, attUniqueId);
Supplier<String> defNameGenerator = () -> "Attribute : " + attributeDefinition.getName();
@@ -99,7 +99,7 @@ public class AttributeOperation extends AbstractOperation implements IAttributeO
}
- private AttributeData buildAttributeData(AttributeDefinition attributeDefinition, String attUniqueId) {
+ private AttributeData buildAttributeData(PropertyDefinition attributeDefinition, String attUniqueId) {
attributeDefinition.setUniqueId(attUniqueId);
return new AttributeData(attributeDefinition);
}
@@ -115,14 +115,14 @@ public class AttributeOperation extends AbstractOperation implements IAttributeO
}
@Override
- public Either<Map<String, AttributeDefinition>, StorageOperationStatus> deleteAllAttributeAssociatedToNode(NodeTypeEnum nodeType, String uniqueId) {
+ public Either<Map<String, PropertyDefinition>, StorageOperationStatus> deleteAllAttributeAssociatedToNode(NodeTypeEnum nodeType, String uniqueId) {
Wrapper<TitanOperationStatus> errorWrapper;
- List<AttributeDefinition> attributes = new ArrayList<>();
+ List<PropertyDefinition> attributes = new ArrayList<>();
TitanOperationStatus findAllResourceAttribues = findNodeNonInheretedAttribues(uniqueId, NodeTypeEnum.Resource, attributes);
errorWrapper = (findAllResourceAttribues != TitanOperationStatus.OK) ? new Wrapper<>(findAllResourceAttribues) : new Wrapper<>();
if (errorWrapper.isEmpty()) {
- for (AttributeDefinition attDef : attributes) {
+ for (PropertyDefinition attDef : attributes) {
log.debug("Before deleting attribute from graph {}", attDef.getUniqueId());
Either<AttributeData, TitanOperationStatus> deleteNode = titanGenericDao.deleteNode(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.Attribute), attDef.getUniqueId(), AttributeData.class);
if (deleteNode.isRight()) {
@@ -133,7 +133,7 @@ public class AttributeOperation extends AbstractOperation implements IAttributeO
}
if (errorWrapper.isEmpty()) {
- Map<String, AttributeDefinition> attributesMap = attributes.stream().collect(Collectors.toMap(e -> e.getName(), e -> e));
+ Map<String, PropertyDefinition> attributesMap = attributes.stream().collect(Collectors.toMap(e -> e.getName(), e -> e));
return Either.left(attributesMap);
} else {
return Either.right(DaoStatusConverter.convertTitanStatusToStorageStatus(errorWrapper.getInnerElement()));
@@ -147,9 +147,9 @@ public class AttributeOperation extends AbstractOperation implements IAttributeO
}
@Override
- public TitanOperationStatus addAttributesToGraph(TitanVertex metadataVertex, Map<String, AttributeDefinition> attributes, String resourceId, Map<String, DataTypeDefinition> dataTypes) {
+ public TitanOperationStatus addAttributesToGraph(TitanVertex metadataVertex, Map<String, PropertyDefinition> attributes, String resourceId, Map<String, DataTypeDefinition> dataTypes) {
TitanOperationStatus titanStatus = TitanOperationStatus.OK;
- for (AttributeDefinition attribute : attributes.values()) {
+ for (PropertyDefinition attribute : attributes.values()) {
TitanOperationStatus eitherAddAttribute = addAttributeToGraphByVertex(metadataVertex, attribute, resourceId, dataTypes);
if (!eitherAddAttribute.equals(TitanOperationStatus.OK)) {
titanStatus = eitherAddAttribute;
@@ -160,9 +160,9 @@ public class AttributeOperation extends AbstractOperation implements IAttributeO
}
@Override
- public Either<List<ComponentInstanceAttribute>, TitanOperationStatus> getAllAttributesOfResourceInstance(ComponentInstance compInstance) {
+ public Either<List<ComponentInstanceProperty>, TitanOperationStatus> getAllAttributesOfResourceInstance(ComponentInstance compInstance) {
- Either<List<ComponentInstanceAttribute>, TitanOperationStatus> result;
+ Either<List<ComponentInstanceProperty>, TitanOperationStatus> result;
Either<List<ImmutablePair<AttributeValueData, GraphEdge>>, TitanOperationStatus> attributeImplNodes = titanGenericDao.getChildrenNodes(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.ResourceInstance), compInstance.getUniqueId(),
GraphEdgeLabels.ATTRIBUTE_VALUE, NodeTypeEnum.AttributeValue, AttributeValueData.class);
@@ -185,31 +185,31 @@ public class AttributeOperation extends AbstractOperation implements IAttributeO
return result;
}
- private Either<List<ComponentInstanceAttribute>, TitanOperationStatus> mergeAttributesResults(Either<List<ComponentInstanceAttribute>, TitanOperationStatus> eitherAttributesThatDoesNotExistOnRI,
- Either<List<ComponentInstanceAttribute>, TitanOperationStatus> eitherAttributesThatExistOnRI) {
+ private Either<List<ComponentInstanceProperty>, TitanOperationStatus> mergeAttributesResults(Either<List<ComponentInstanceProperty>, TitanOperationStatus> eitherAttributesThatDoesNotExistOnRI,
+ Either<List<ComponentInstanceProperty>, TitanOperationStatus> eitherAttributesThatExistOnRI) {
- Either<List<ComponentInstanceAttribute>, TitanOperationStatus> result;
+ Either<List<ComponentInstanceProperty>, TitanOperationStatus> result;
if (eitherAttributesThatExistOnRI.isRight()) {
result = Either.right(eitherAttributesThatExistOnRI.right().value());
} else if (eitherAttributesThatDoesNotExistOnRI.isRight()) {
result = Either.right(eitherAttributesThatDoesNotExistOnRI.right().value());
} else {
- final List<ComponentInstanceAttribute> attributesThatExistOnRI = eitherAttributesThatExistOnRI.left().value();
- final List<ComponentInstanceAttribute> attributesThatDoesNotExistOnRI = eitherAttributesThatDoesNotExistOnRI.left().value();
+ final List<ComponentInstanceProperty> attributesThatExistOnRI = eitherAttributesThatExistOnRI.left().value();
+ final List<ComponentInstanceProperty> attributesThatDoesNotExistOnRI = eitherAttributesThatDoesNotExistOnRI.left().value();
Set<String> attributesIdThatExistOnRI = attributesThatExistOnRI.stream().map(e -> e.getUniqueId()).collect(Collectors.toSet());
// Attributes From The Resource Without attributes that also exist
// on the instance
- Stream<ComponentInstanceAttribute> filterAttributesThatDoesNotExistOnRI = attributesThatDoesNotExistOnRI.stream().filter(e -> !attributesIdThatExistOnRI.contains(e.getUniqueId()));
+ Stream<ComponentInstanceProperty> filterAttributesThatDoesNotExistOnRI = attributesThatDoesNotExistOnRI.stream().filter(e -> !attributesIdThatExistOnRI.contains(e.getUniqueId()));
// Add Fields From Resource Attributes
fillAttributeInfoFromResource(attributesThatExistOnRI, attributesThatDoesNotExistOnRI);
// Adding the Attributes on the instance for the full list
- List<ComponentInstanceAttribute> mergedList = Stream.concat(filterAttributesThatDoesNotExistOnRI, attributesThatExistOnRI.stream()).collect(Collectors.toList());
+ List<ComponentInstanceProperty> mergedList = Stream.concat(filterAttributesThatDoesNotExistOnRI, attributesThatExistOnRI.stream()).collect(Collectors.toList());
result = Either.left(mergedList);
}
return result;
}
- private void fillAttributeInfoFromResource(List<ComponentInstanceAttribute> attributesThatExistOnRI, List<ComponentInstanceAttribute> attributesThatDoesNotExistOnRI) {
+ private void fillAttributeInfoFromResource(List<ComponentInstanceProperty> attributesThatExistOnRI, List<ComponentInstanceProperty> attributesThatDoesNotExistOnRI) {
attributesThatExistOnRI.stream()
.forEach(e -> addAttributeInfo(e,
// Finds the same attribute in the resource
@@ -217,7 +217,7 @@ public class AttributeOperation extends AbstractOperation implements IAttributeO
}
- private void addAttributeInfo(ComponentInstanceAttribute attributeFromRI, ComponentInstanceAttribute attributeFromResource) {
+ private void addAttributeInfo(ComponentInstanceProperty attributeFromRI, ComponentInstanceProperty attributeFromResource) {
attributeFromRI.setName(attributeFromResource.getName());
attributeFromRI.setDescription(attributeFromResource.getDescription());
attributeFromRI.setDefaultValue(attributeFromResource.getDefaultValue());
@@ -228,18 +228,18 @@ public class AttributeOperation extends AbstractOperation implements IAttributeO
}
}
- private Either<List<ComponentInstanceAttribute>, TitanOperationStatus> getAttributesFromResource(ComponentInstance compInstance) {
- Either<List<ComponentInstanceAttribute>, TitanOperationStatus> result;
- List<AttributeDefinition> attributes = new ArrayList<>();
+ private Either<List<ComponentInstanceProperty>, TitanOperationStatus> getAttributesFromResource(ComponentInstance compInstance) {
+ Either<List<ComponentInstanceProperty>, TitanOperationStatus> result;
+ List<PropertyDefinition> attributes = new ArrayList<>();
// Attributes does not exist on Ri - fetch them from resource
TitanOperationStatus findAllResourceAttribues = findAllResourceAttributesRecursively(compInstance.getComponentUid(), attributes);
if (findAllResourceAttribues != TitanOperationStatus.OK) {
result = Either.right(findAllResourceAttribues);
} else {
- List<ComponentInstanceAttribute> buildAttInstanceFromResource = attributes.stream().map(attDef -> new ComponentInstanceAttribute(attDef, false, null)).collect(Collectors.toList());
+ List<ComponentInstanceProperty> buildAttInstanceFromResource = attributes.stream().map(attDef -> new ComponentInstanceProperty(false, attDef, null)).collect(Collectors.toList());
// Set Value to be default value in case it is empty
- Consumer<ComponentInstanceAttribute> valueSetter = att -> {
+ Consumer<ComponentInstanceProperty> valueSetter = att -> {
if (StringUtils.isEmpty(att.getValue())) {
att.setValue(att.getDefaultValue());
}
@@ -251,9 +251,9 @@ public class AttributeOperation extends AbstractOperation implements IAttributeO
return result;
}
- private Either<List<ComponentInstanceAttribute>, TitanOperationStatus> convertToComponentInstanceAttribute(List<ImmutablePair<AttributeValueData, GraphEdge>> list) {
- Either<List<ComponentInstanceAttribute>, TitanOperationStatus> result = null;
- List<ComponentInstanceAttribute> componentInstanceAttribute = new ArrayList<>();
+ private Either<List<ComponentInstanceProperty>, TitanOperationStatus> convertToComponentInstanceAttribute(List<ImmutablePair<AttributeValueData, GraphEdge>> list) {
+ Either<List<ComponentInstanceProperty>, TitanOperationStatus> result = null;
+ List<ComponentInstanceProperty> componentInstanceAttribute = new ArrayList<>();
for (ImmutablePair<AttributeValueData, GraphEdge> attributeValue : list) {
AttributeValueData attributeValueData = attributeValue.getLeft();
String attributeValueUid = attributeValueData.getUniqueId();
@@ -272,7 +272,7 @@ public class AttributeOperation extends AbstractOperation implements IAttributeO
ImmutablePair<AttributeData, GraphEdge> attributeDefPair = attributeDefRes.left().value();
String attributeUniqueId = attributeDefPair.left.getUniqueId();
- ComponentInstanceAttribute resourceInstanceAttribute = new ComponentInstanceAttribute();
+ ComponentInstanceProperty resourceInstanceAttribute = new ComponentInstanceProperty();
// set attribute original unique id
resourceInstanceAttribute.setUniqueId(attributeUniqueId);
// set hidden
@@ -302,14 +302,14 @@ public class AttributeOperation extends AbstractOperation implements IAttributeO
* @return
*/
@Override
- public TitanOperationStatus findAllResourceAttributesRecursively(String resourceId, List<AttributeDefinition> attributes) {
- final NodeElementFetcher<AttributeDefinition> singleNodeFetcher = (resourceIdParam, attributesParam) -> findNodeNonInheretedAttribues(resourceIdParam, NodeTypeEnum.Resource, attributesParam);
+ public TitanOperationStatus findAllResourceAttributesRecursively(String resourceId, List<PropertyDefinition> attributes) {
+ final NodeElementFetcher<PropertyDefinition> singleNodeFetcher = (resourceIdParam, attributesParam) -> findNodeNonInheretedAttribues(resourceIdParam, NodeTypeEnum.Resource, attributesParam);
return findAllResourceElementsDefinitionRecursively(resourceId, attributes, singleNodeFetcher);
}
@Override
- public TitanOperationStatus findNodeNonInheretedAttribues(String uniqueId, NodeTypeEnum nodeType, List<AttributeDefinition> attributes) {
+ public TitanOperationStatus findNodeNonInheretedAttribues(String uniqueId, NodeTypeEnum nodeType, List<PropertyDefinition> attributes) {
Either<List<ImmutablePair<AttributeData, GraphEdge>>, TitanOperationStatus> childrenNodes = titanGenericDao.getChildrenNodes(UniqueIdBuilder.getKeyByNodeType(nodeType), uniqueId, GraphEdgeLabels.ATTRIBUTE, NodeTypeEnum.Attribute,
AttributeData.class);
@@ -330,7 +330,7 @@ public class AttributeOperation extends AbstractOperation implements IAttributeO
log.debug("Attribute {} is associated to node {}", attributeName, uniqueId);
AttributeData attributeData = immutablePair.getKey();
- AttributeDefinition attributeDefinition = this.convertAttributeDataToAttributeDefinition(attributeData, attributeName, uniqueId);
+ PropertyDefinition attributeDefinition = this.convertAttributeDataToAttributeDefinition(attributeData, attributeName, uniqueId);
attributes.add(attributeDefinition);
@@ -343,16 +343,16 @@ public class AttributeOperation extends AbstractOperation implements IAttributeO
}
@Override
- public AttributeDefinition convertAttributeDataToAttributeDefinition(AttributeData attributeData, String attributeName, String resourceId) {
+ public PropertyDefinition convertAttributeDataToAttributeDefinition(AttributeData attributeData, String attributeName, String resourceId) {
log.debug("The object returned after create attribute is {}", attributeData);
- AttributeDefinition attributeDefResult = new AttributeDefinition(attributeData.getAttributeDataDefinition());
+ PropertyDefinition attributeDefResult = new PropertyDefinition(attributeData.getAttributeDataDefinition());
attributeDefResult.setName(attributeName);
attributeDefResult.setParentUniqueId(resourceId);
return attributeDefResult;
}
@Override
- public Either<AttributeData, StorageOperationStatus> addAttribute(AttributeDefinition attributeDefinition, String resourceId) {
+ public Either<AttributeData, StorageOperationStatus> addAttribute(PropertyDefinition attributeDefinition, String resourceId) {
Either<AttributeData, StorageOperationStatus> eitherResult;
Either<Map<String, DataTypeDefinition>, TitanOperationStatus> allDataTypes = applicationDataTypeCache.getAll();
@@ -373,7 +373,7 @@ public class AttributeOperation extends AbstractOperation implements IAttributeO
}
@Override
- public Either<AttributeData, StorageOperationStatus> updateAttribute(String attributeId, AttributeDefinition newAttDef, Map<String, DataTypeDefinition> dataTypes) {
+ public Either<AttributeData, StorageOperationStatus> updateAttribute(String attributeId, PropertyDefinition newAttDef, Map<String, DataTypeDefinition> dataTypes) {
StorageOperationStatus validateAndUpdateAttribute = propertyOperation.validateAndUpdateProperty(newAttDef, dataTypes);
if (validateAndUpdateAttribute != StorageOperationStatus.OK) {
@@ -388,7 +388,7 @@ public class AttributeOperation extends AbstractOperation implements IAttributeO
return Either.left(either.left().value());
}
- private Either<AttributeData, TitanOperationStatus> updateAttributeFromGraph(String attributeId, AttributeDefinition attributeDefenition) {
+ private Either<AttributeData, TitanOperationStatus> updateAttributeFromGraph(String attributeId, PropertyDefinition attributeDefenition) {
log.debug("Before updating attribute on graph {}", attributeId);
// get the original property data
@@ -398,12 +398,12 @@ public class AttributeOperation extends AbstractOperation implements IAttributeO
return Either.right(eitherAttribute.right().value());
}
AttributeData orgAttributeData = eitherAttribute.left().value();
- AttributeDataDefinition orgAttributeDataDefinition = orgAttributeData.getAttributeDataDefinition();
+ PropertyDataDefinition orgAttributeDataDefinition = orgAttributeData.getAttributeDataDefinition();
// create new property data to update
AttributeData newAttributeData = new AttributeData();
newAttributeData.setAttributeDataDefinition(attributeDefenition);
- AttributeDataDefinition newAttributeDataDefinition = newAttributeData.getAttributeDataDefinition();
+ PropertyDataDefinition newAttributeDataDefinition = newAttributeData.getAttributeDataDefinition();
// update the original property data with new values
if (!Objects.equals(orgAttributeDataDefinition.getDefaultValue(), newAttributeDataDefinition.getDefaultValue())) {
@@ -424,17 +424,15 @@ public class AttributeOperation extends AbstractOperation implements IAttributeO
}
@Override
- public ComponentInstanceAttribute buildResourceInstanceAttribute(AttributeValueData attributeValueData, ComponentInstanceAttribute resourceInstanceAttribute) {
+ public ComponentInstanceProperty buildResourceInstanceAttribute(AttributeValueData attributeValueData, ComponentInstanceProperty resourceInstanceAttribute) {
Boolean hidden = attributeValueData.isHidden();
String uid = attributeValueData.getUniqueId();
- ComponentInstanceAttribute instanceAttribute = new ComponentInstanceAttribute(resourceInstanceAttribute, hidden, uid);
-
- return instanceAttribute;
+ return new ComponentInstanceProperty(hidden, resourceInstanceAttribute, uid);
}
@Override
- public Either<AttributeData, TitanOperationStatus> addAttributeToGraph(AttributeDefinition attribute, String resourceId, Map<String, DataTypeDefinition> dataTypes) {
+ public Either<AttributeData, TitanOperationStatus> addAttributeToGraph(PropertyDefinition attribute, String resourceId, Map<String, DataTypeDefinition> dataTypes) {
Either<AttributeData, TitanOperationStatus> eitherResult;
StorageOperationStatus validateAndUpdateAttribute = propertyOperation.validateAndUpdateProperty(attribute, dataTypes);
if (validateAndUpdateAttribute != StorageOperationStatus.OK) {
@@ -448,7 +446,7 @@ public class AttributeOperation extends AbstractOperation implements IAttributeO
}
@Override
- public TitanOperationStatus addAttributeToGraphByVertex(TitanVertex metadataVertex, AttributeDefinition attribute, String resourceId, Map<String, DataTypeDefinition> dataTypes) {
+ public TitanOperationStatus addAttributeToGraphByVertex(TitanVertex metadataVertex, PropertyDefinition attribute, String resourceId, Map<String, DataTypeDefinition> dataTypes) {
StorageOperationStatus validateAndUpdateAttribute = propertyOperation.validateAndUpdateProperty(attribute, dataTypes);
TitanOperationStatus result;
if (validateAndUpdateAttribute != StorageOperationStatus.OK) {
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/ComponentInstanceOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/ComponentInstanceOperation.java
index c487b0ce71..43e4d0683b 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/ComponentInstanceOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/ComponentInstanceOperation.java
@@ -66,7 +66,6 @@ import org.openecomp.sdc.be.model.ArtifactDefinition;
import org.openecomp.sdc.be.model.CapabilityDefinition;
import org.openecomp.sdc.be.model.Component;
import org.openecomp.sdc.be.model.ComponentInstance;
-import org.openecomp.sdc.be.model.ComponentInstanceAttribute;
import org.openecomp.sdc.be.model.ComponentInstanceInput;
import org.openecomp.sdc.be.model.ComponentInstanceProperty;
import org.openecomp.sdc.be.model.DataTypeDefinition;
@@ -3893,7 +3892,7 @@ public class ComponentInstanceOperation extends AbstractOperation implements ICo
private StorageOperationStatus cloneResourceInstanceAttributeValues(ComponentInstance createdInstance, ComponentInstance resourceInstance) {
Wrapper<StorageOperationStatus> storageStatusWrapper = new Wrapper<>();
- Wrapper<List<ComponentInstanceAttribute>> compInstanceAttList = new Wrapper<>();
+ Wrapper<List<ComponentInstanceProperty>> compInstanceAttList = new Wrapper<>();
findAllAttributesOfResourceInstance(resourceInstance, compInstanceAttList, storageStatusWrapper);
@@ -3902,7 +3901,7 @@ public class ComponentInstanceOperation extends AbstractOperation implements ICo
}
if (storageStatusWrapper.isEmpty()) {
- List<ComponentInstanceAttribute> attributesOnInstance = compInstanceAttList.getInnerElement();
+ List<ComponentInstanceProperty> attributesOnInstance = compInstanceAttList.getInnerElement();
for (int i = 0; i < attributesOnInstance.size() && storageStatusWrapper.isEmpty(); i++) {
cloneSingleAttributeOnResourceInstance(createdInstance, attributesOnInstance.get(i), storageStatusWrapper);
}
@@ -3915,7 +3914,7 @@ public class ComponentInstanceOperation extends AbstractOperation implements ICo
private StorageOperationStatus cloneResourceInstanceAttributeValues(TitanVertex createdInstanceVertex, ComponentInstance resourceInstance, String instanceId) {
Wrapper<StorageOperationStatus> storageStatusWrapper = new Wrapper<>();
- Wrapper<List<ComponentInstanceAttribute>> compInstanceAttList = new Wrapper<>();
+ Wrapper<List<ComponentInstanceProperty>> compInstanceAttList = new Wrapper<>();
findAllAttributesOfResourceInstance(resourceInstance, compInstanceAttList, storageStatusWrapper);
@@ -3924,7 +3923,7 @@ public class ComponentInstanceOperation extends AbstractOperation implements ICo
}
if (storageStatusWrapper.isEmpty()) {
- List<ComponentInstanceAttribute> attributesOnInstance = compInstanceAttList.getInnerElement();
+ List<ComponentInstanceProperty> attributesOnInstance = compInstanceAttList.getInnerElement();
for (int i = 0; i < attributesOnInstance.size() && storageStatusWrapper.isEmpty(); i++) {
StorageOperationStatus result = cloneSingleAttributeOnResourceInstance(createdInstanceVertex, attributesOnInstance.get(i), instanceId);
if (result != StorageOperationStatus.OK) {
@@ -3945,9 +3944,9 @@ public class ComponentInstanceOperation extends AbstractOperation implements ICo
}
}
- private void findAllAttributesOfResourceInstance(ComponentInstance resourceInstance, Wrapper<List<ComponentInstanceAttribute>> compInstanceAttList, Wrapper<StorageOperationStatus> storageStatusWrapper) {
+ private void findAllAttributesOfResourceInstance(ComponentInstance resourceInstance, Wrapper<List<ComponentInstanceProperty>> compInstanceAttList, Wrapper<StorageOperationStatus> storageStatusWrapper) {
- Either<List<ComponentInstanceAttribute>, TitanOperationStatus> allAttributes = attributeOperation.getAllAttributesOfResourceInstance(resourceInstance);
+ Either<List<ComponentInstanceProperty>, TitanOperationStatus> allAttributes = attributeOperation.getAllAttributesOfResourceInstance(resourceInstance);
if (allAttributes.isRight()) {
TitanOperationStatus status = allAttributes.right().value();
if (status == TitanOperationStatus.NOT_FOUND) {
@@ -3960,7 +3959,7 @@ public class ComponentInstanceOperation extends AbstractOperation implements ICo
}
}
- private void cloneSingleAttributeOnResourceInstance(ComponentInstance createdInstance, ComponentInstanceAttribute attribute, Wrapper<StorageOperationStatus> storageStatusWrapper) {
+ private void cloneSingleAttributeOnResourceInstance(ComponentInstance createdInstance, ComponentInstanceProperty attribute, Wrapper<StorageOperationStatus> storageStatusWrapper) {
// Only if valueUniqueId is not empty, then its belongs to the
// instance
if (attribute.getValueUniqueUid() != null) {
@@ -3981,7 +3980,7 @@ public class ComponentInstanceOperation extends AbstractOperation implements ICo
}
- private StorageOperationStatus cloneSingleAttributeOnResourceInstance(TitanVertex createdInstanceVertex, ComponentInstanceAttribute attribute, String instanceId) {
+ private StorageOperationStatus cloneSingleAttributeOnResourceInstance(TitanVertex createdInstanceVertex, ComponentInstanceProperty attribute, String instanceId) {
// Only if valueUniqueId is not empty, then its belongs to the
// instance
if (attribute.getValueUniqueUid() != null) {
@@ -4053,7 +4052,7 @@ public class ComponentInstanceOperation extends AbstractOperation implements ICo
}
}
- private void createAttributeValueDataNode(ComponentInstanceAttribute attributeInstanceProperty, Integer index, Wrapper<TitanOperationStatus> errorWrapper, ComponentInstanceData resourceInstanceData,
+ private void createAttributeValueDataNode(ComponentInstanceProperty attributeInstanceProperty, Integer index, Wrapper<TitanOperationStatus> errorWrapper, ComponentInstanceData resourceInstanceData,
Wrapper<AttributeValueData> attValueDataWrapper) {
String valueUniqueUid = attributeInstanceProperty.getValueUniqueUid();
if (valueUniqueUid == null) {
@@ -4093,7 +4092,7 @@ public class ComponentInstanceOperation extends AbstractOperation implements ICo
* } else { BeEcompErrorManager.getInstance().logInternalFlowError( "CreateAttributeValueDataNode", "attribute value already exists.", ErrorSeverity.ERROR); errorWrapper.setInnerElement(TitanOperationStatus.ALREADY_EXIST); } }
*/
- private AttributeValueData buildAttributeValueDataFromComponentInstanceAttribute(ComponentInstanceAttribute resourceInstanceAttribute, String uniqueId) {
+ private AttributeValueData buildAttributeValueDataFromComponentInstanceAttribute(ComponentInstanceProperty resourceInstanceAttribute, String uniqueId) {
AttributeValueData attributeValueData = new AttributeValueData();
attributeValueData.setUniqueId(uniqueId);
attributeValueData.setHidden(resourceInstanceAttribute.isHidden());
@@ -4509,7 +4508,7 @@ public class ComponentInstanceOperation extends AbstractOperation implements ICo
}
@Override
- public Either<AttributeValueData, TitanOperationStatus> createOrUpdateAttributeOfResourceInstance(ComponentInstanceAttribute attributeInstanceProperty, String resourceInstanceId) {
+ public Either<AttributeValueData, TitanOperationStatus> createOrUpdateAttributeOfResourceInstance(ComponentInstanceProperty attributeInstanceProperty, String resourceInstanceId) {
Either<AttributeValueData, TitanOperationStatus> result;
// Create
if (attributeInstanceProperty.getValueUniqueUid() == null) {
@@ -4536,7 +4535,7 @@ public class ComponentInstanceOperation extends AbstractOperation implements ICo
* @param resourceInstanceId
* @return
*/
- private Either<AttributeValueData, TitanOperationStatus> updateAttributeOfResourceInstance(ComponentInstanceAttribute resourceInstanceAttribute, String resourceInstanceId) {
+ private Either<AttributeValueData, TitanOperationStatus> updateAttributeOfResourceInstance(ComponentInstanceProperty resourceInstanceAttribute, String resourceInstanceId) {
Either<AttributeValueData, TitanOperationStatus> result = null;
Wrapper<TitanOperationStatus> errorWrapper = new Wrapper<>();
@@ -4562,7 +4561,7 @@ public class ComponentInstanceOperation extends AbstractOperation implements ICo
}
- private Either<AttributeValueData, TitanOperationStatus> addAttributeToResourceInstance(ComponentInstanceAttribute attributeInstanceProperty, String resourceInstanceId, Integer index) {
+ private Either<AttributeValueData, TitanOperationStatus> addAttributeToResourceInstance(ComponentInstanceProperty attributeInstanceProperty, String resourceInstanceId, Integer index) {
Wrapper<TitanOperationStatus> errorWrapper = new Wrapper<>();
Wrapper<ComponentInstanceData> compInsWrapper = new Wrapper<>();
Wrapper<AttributeData> attDataWrapper = new Wrapper<>();
@@ -5263,8 +5262,8 @@ public class ComponentInstanceOperation extends AbstractOperation implements ICo
}
@Override
- public Either<ComponentInstanceAttribute, StorageOperationStatus> addAttributeValueToResourceInstance(ComponentInstanceAttribute resourceInstanceAttribute, String resourceInstanceId, Integer index, boolean inTransaction) {
- Either<ComponentInstanceAttribute, StorageOperationStatus> result = null;
+ public Either<ComponentInstanceProperty, StorageOperationStatus> addAttributeValueToResourceInstance(ComponentInstanceProperty resourceInstanceAttribute, String resourceInstanceId, Integer index, boolean inTransaction) {
+ Either<ComponentInstanceProperty, StorageOperationStatus> result = null;
try {
@@ -5277,7 +5276,7 @@ public class ComponentInstanceOperation extends AbstractOperation implements ICo
} else {
AttributeValueData attributeValueData = eitherStatus.left().value();
- ComponentInstanceAttribute attributeValueResult = attributeOperation.buildResourceInstanceAttribute(attributeValueData, resourceInstanceAttribute);
+ ComponentInstanceProperty attributeValueResult = attributeOperation.buildResourceInstanceAttribute(attributeValueData, resourceInstanceAttribute);
log.debug("The returned ResourceInstanceAttribute is {}", attributeValueResult);
result = Either.left(attributeValueResult);
@@ -5291,9 +5290,9 @@ public class ComponentInstanceOperation extends AbstractOperation implements ICo
}
@Override
- public Either<ComponentInstanceAttribute, StorageOperationStatus> updateAttributeValueInResourceInstance(ComponentInstanceAttribute resourceInstanceAttribute, String resourceInstanceId, boolean inTransaction) {
+ public Either<ComponentInstanceProperty, StorageOperationStatus> updateAttributeValueInResourceInstance(ComponentInstanceProperty resourceInstanceAttribute, String resourceInstanceId, boolean inTransaction) {
- Either<ComponentInstanceAttribute, StorageOperationStatus> result = null;
+ Either<ComponentInstanceProperty, StorageOperationStatus> result = null;
try {
Either<AttributeValueData, TitanOperationStatus> eitherAttributeValue = updateAttributeOfResourceInstance(resourceInstanceAttribute, resourceInstanceId);
@@ -5305,7 +5304,7 @@ public class ComponentInstanceOperation extends AbstractOperation implements ICo
} else {
AttributeValueData attributeValueData = eitherAttributeValue.left().value();
- ComponentInstanceAttribute attributeValueResult = attributeOperation.buildResourceInstanceAttribute(attributeValueData, resourceInstanceAttribute);
+ ComponentInstanceProperty attributeValueResult = attributeOperation.buildResourceInstanceAttribute(attributeValueData, resourceInstanceAttribute);
log.debug("The returned ResourceInstanceAttribute is {}", attributeValueResult);
result = Either.left(attributeValueResult);
@@ -5463,7 +5462,7 @@ public class ComponentInstanceOperation extends AbstractOperation implements ICo
return Either.left(result);
}
- // TODO Tal G US831698
+ //US831698
public Either<List<ComponentInstanceProperty>, StorageOperationStatus> getComponentInstancesPropertiesAndValuesFromGraph(ComponentInstance resourceInstance) {
Map<String, List<PropertyDefinition>> alreadyProcessedResources = new HashMap<>();
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/ConsumerOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/ConsumerOperation.java
index 215a1464a6..a5a1348f21 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/ConsumerOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/ConsumerOperation.java
@@ -23,24 +23,29 @@ package org.openecomp.sdc.be.model.operations.impl;
import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
import org.openecomp.sdc.be.dao.titan.TitanGenericDao;
import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
+import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
import org.openecomp.sdc.be.model.operations.api.IConsumerOperation;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
import org.openecomp.sdc.be.resources.data.ConsumerData;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import fj.data.Either;
+import java.util.Collections;
+import java.util.List;
+
@Component("consumer-operation")
public class ConsumerOperation implements IConsumerOperation {
- @javax.annotation.Resource
private TitanGenericDao titanGenericDao;
private static Logger log = LoggerFactory.getLogger(ConsumerOperation.class.getName());
- public ConsumerOperation() {
+ public ConsumerOperation(@Qualifier("titan-generic-dao") TitanGenericDao titanGenericDao) {
+ this.titanGenericDao = titanGenericDao;
}
@Override
@@ -59,6 +64,13 @@ public class ConsumerOperation implements IConsumerOperation {
}
@Override
+ public Either<List<ConsumerData>, StorageOperationStatus> getAll() {
+ log.debug("retrieving all consumers");
+ return titanGenericDao.getByCriteria(NodeTypeEnum.ConsumerCredentials, Collections.emptyMap(), ConsumerData.class)
+ .right().map(DaoStatusConverter::convertTitanStatusToStorageStatus);
+ }
+
+ @Override
public Either<ConsumerData, StorageOperationStatus> createCredentials(ConsumerData consumerData) {
return createCredentials(consumerData, false);
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/ResourceOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/ResourceOperation.java
index 4dce650f18..2cc78eade2 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/ResourceOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/ResourceOperation.java
@@ -20,20 +20,11 @@
package org.openecomp.sdc.be.model.operations.impl;
-import java.util.ArrayList;
-import java.util.Collections;
-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 java.util.Set;
-import java.util.UUID;
-import java.util.function.Predicate;
-import java.util.regex.Pattern;
-import java.util.stream.Collectors;
-
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.thinkaurelius.titan.core.TitanGraph;
+import com.thinkaurelius.titan.core.TitanVertex;
+import fj.data.Either;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.ImmutablePair;
@@ -54,25 +45,7 @@ import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.FilterKeyEnum;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
-import org.openecomp.sdc.be.model.AdditionalInformationDefinition;
-import org.openecomp.sdc.be.model.ArtifactDefinition;
-import org.openecomp.sdc.be.model.AttributeDefinition;
-import org.openecomp.sdc.be.model.CapabilityDefinition;
-import org.openecomp.sdc.be.model.Component;
-import org.openecomp.sdc.be.model.ComponentInstance;
-import org.openecomp.sdc.be.model.ComponentInstanceAttribute;
-import org.openecomp.sdc.be.model.ComponentInstanceProperty;
-import org.openecomp.sdc.be.model.ComponentParametersView;
-import org.openecomp.sdc.be.model.DataTypeDefinition;
-import org.openecomp.sdc.be.model.GroupDefinition;
-import org.openecomp.sdc.be.model.InputDefinition;
-import org.openecomp.sdc.be.model.InterfaceDefinition;
-import org.openecomp.sdc.be.model.LifecycleStateEnum;
-import org.openecomp.sdc.be.model.Operation;
-import org.openecomp.sdc.be.model.PropertyDefinition;
-import org.openecomp.sdc.be.model.RequirementDefinition;
-import org.openecomp.sdc.be.model.Resource;
-import org.openecomp.sdc.be.model.ResourceMetadataDefinition;
+import org.openecomp.sdc.be.model.*;
import org.openecomp.sdc.be.model.cache.ComponentCache;
import org.openecomp.sdc.be.model.category.CategoryDefinition;
import org.openecomp.sdc.be.model.category.SubCategoryDefinition;
@@ -82,7 +55,7 @@ import org.openecomp.sdc.be.model.operations.api.IAttributeOperation;
import org.openecomp.sdc.be.model.operations.api.IElementOperation;
import org.openecomp.sdc.be.model.operations.api.IResourceOperation;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
-import org.openecomp.sdc.be.model.operations.migration.MigrationErrorInformer;
+import org.openecomp.sdc.be.model.operations.migration.MigrationMalformedDataLogger;
import org.openecomp.sdc.be.model.operations.utils.GraphDeleteUtil;
import org.openecomp.sdc.be.resources.data.ComponentMetadataData;
import org.openecomp.sdc.be.resources.data.PropertyData;
@@ -100,13 +73,18 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import com.thinkaurelius.titan.core.TitanGraph;
-import com.thinkaurelius.titan.core.TitanVertex;
-
-import fj.Function;
-import fj.data.Either;
+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 java.util.Set;
+import java.util.UUID;
+import java.util.function.Predicate;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
@org.springframework.stereotype.Component("resource-operation")
@Deprecated
@@ -651,7 +629,7 @@ public class ResourceOperation extends ComponentOperation implements IResourceOp
return getPropertiesOfAllDerivedFromRes;
}
- private TitanOperationStatus associateAttributesToResource(TitanVertex metadataVertex, List<AttributeDefinition> attributes, String resourceId) {
+ private TitanOperationStatus associateAttributesToResource(TitanVertex metadataVertex, List<PropertyDefinition> attributes, String resourceId) {
TitanOperationStatus operationStatus = TitanOperationStatus.OK;
Either<Map<String, DataTypeDefinition>, TitanOperationStatus> allDataTypes = applicationDataTypeCache.getAll();
@@ -662,7 +640,7 @@ public class ResourceOperation extends ComponentOperation implements IResourceOp
}
if (attributes != null) {
- Map<String, AttributeDefinition> convertedAttributes = attributes.stream().collect(Collectors.toMap(e -> e.getName(), e -> e));
+ Map<String, PropertyDefinition> convertedAttributes = attributes.stream().collect(Collectors.toMap(e -> e.getName(), e -> e));
operationStatus = attributeOperation.addAttributesToGraph(metadataVertex, convertedAttributes, resourceId, allDataTypes.left().value());
}
return operationStatus;
@@ -805,12 +783,12 @@ public class ResourceOperation extends ComponentOperation implements IResourceOp
}
private TitanOperationStatus setComponentInstancesAttributesFromGraph(String uniqueId, Resource component) {
- Map<String, List<ComponentInstanceAttribute>> resourceInstancesAttributes = new HashMap<>();
+ Map<String, List<ComponentInstanceProperty>> resourceInstancesAttributes = new HashMap<>();
TitanOperationStatus status = TitanOperationStatus.OK;
List<ComponentInstance> componentInstances = component.getComponentInstances();
if (componentInstances != null) {
for (ComponentInstance resourceInstance : componentInstances) {
- Either<List<ComponentInstanceAttribute>, TitanOperationStatus> eitherRIAttributes = attributeOperation.getAllAttributesOfResourceInstance(resourceInstance);
+ Either<List<ComponentInstanceProperty>, TitanOperationStatus> eitherRIAttributes = attributeOperation.getAllAttributesOfResourceInstance(resourceInstance);
if (eitherRIAttributes.isRight()) {
status = eitherRIAttributes.right().value();
break;
@@ -875,8 +853,7 @@ public class ResourceOperation extends ComponentOperation implements IResourceOp
} else {
Map<String, CapabilityDefinition> capabilities = result.left().value();
if (capabilities != null && !capabilities.isEmpty() && resource.getResourceType().equals(ResourceTypeEnum.VF)) {
- log.error(String.format("VF %s has direct capabilities.!!!!!!!!!!!!!", resource.getName()));
- MigrationErrorInformer.addMalformedVF(resource.getUniqueId());
+ MigrationMalformedDataLogger.reportMalformedVF(resource.getUniqueId(), String.format("VF %s with id %s has direct capabilities.!!!!!!!!!!!!!", resource.getName(), resource.getUniqueId()));
}
if (capabilities == null || capabilities.isEmpty() || resource.getResourceType().equals(ResourceTypeEnum.VF)) {
Either<Map<String, List<CapabilityDefinition>>, TitanOperationStatus> eitherCapabilities = super.getCapabilities(resource, NodeTypeEnum.Resource, true);
@@ -946,8 +923,7 @@ public class ResourceOperation extends ComponentOperation implements IResourceOp
} else {
Map<String, RequirementDefinition> requirements = result.left().value();
if (requirements != null && !requirements.isEmpty() && resource.getResourceType().equals(ResourceTypeEnum.VF)) {
- log.error(String.format("VF %s has direct requirements.!!!!!!!!!!!!!", resource.getName()));
- MigrationErrorInformer.addMalformedVF(resource.getUniqueId());
+ MigrationMalformedDataLogger.reportMalformedVF(resource.getUniqueId(), String.format("VF %s with id %s has direct requirements.!!!!!!!!!!!!!", resource.getName(), resource.getUniqueId()));
}
if (requirements == null || requirements.isEmpty() || resource.getResourceType() == ResourceTypeEnum.VF) {
Either<Map<String, List<RequirementDefinition>>, TitanOperationStatus> eitherCapabilities = super.getRequirements(resource, NodeTypeEnum.Resource, true);
@@ -982,7 +958,7 @@ public class ResourceOperation extends ComponentOperation implements IResourceOp
private TitanOperationStatus setResourceAttributesFromGraph(String uniqueId, Resource resource) {
- List<AttributeDefinition> attributes = new ArrayList<>();
+ List<PropertyDefinition> attributes = new ArrayList<>();
TitanOperationStatus status = attributeOperation.findAllResourceAttributesRecursively(uniqueId, attributes);
if (status == TitanOperationStatus.OK) {
resource.setAttributes(attributes);
@@ -1372,7 +1348,7 @@ public class ResourceOperation extends ComponentOperation implements IResourceOp
}
private StorageOperationStatus removeAttributesFromResource(Resource resource) {
- Either<Map<String, AttributeDefinition>, StorageOperationStatus> deleteAllAttributeAssociatedToNode = attributeOperation.deleteAllAttributeAssociatedToNode(NodeTypeEnum.Resource, resource.getUniqueId());
+ Either<Map<String, PropertyDefinition>, StorageOperationStatus> deleteAllAttributeAssociatedToNode = attributeOperation.deleteAllAttributeAssociatedToNode(NodeTypeEnum.Resource, resource.getUniqueId());
return deleteAllAttributeAssociatedToNode.isRight() ? deleteAllAttributeAssociatedToNode.right().value() : StorageOperationStatus.OK;
}
@@ -1862,25 +1838,23 @@ public class ResourceOperation extends ComponentOperation implements IResourceOp
return getResourceListByCriteria(rootToscaResource, false);
}
- @Override
- public Either<List<Resource>, StorageOperationStatus> getAll() {
- Either<List<Resource>, StorageOperationStatus> resourceListByCriteria = getResourceListByCriteria(new HashMap<>(), false);
- if (resourceListByCriteria.isRight() && resourceListByCriteria.right().value() == StorageOperationStatus.NOT_FOUND) {
- return Either.left(Collections.emptyList());
- }
- return resourceListByCriteria;
- }
-
-
private Either<List<ImmutablePair<ResourceMetadataData, GraphEdge>>, TitanOperationStatus> getDerivingChildren(Resource resource) {
return titanGenericDao.getParentNodes(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.Resource), resource.getUniqueId(), GraphEdgeLabels.DERIVED_FROM, NodeTypeEnum.Resource, ResourceMetadataData.class);
}
private Either<List<Resource>, StorageOperationStatus> convertToResources(List<ResourceMetadataData> resourcesMetaData) {
- List<Either<Resource, StorageOperationStatus>> resources = resourcesMetaData.stream()
- .map(resourceMetaData -> this.getResource(resourceMetaData.getMetadataDataDefinition().getUniqueId()))
- .collect(Collectors.toList());
- return Either.sequenceLeft(fj.data.List.iterableList(resources)).bimap(fj.data.List::toJavaList, Function.identity());
+ List<Resource> resources = new ArrayList<>();
+ for (ResourceMetadataData resourceMetadataData : resourcesMetaData) {
+ String uniqueId = resourceMetadataData.getMetadataDataDefinition().getUniqueId();
+ Either<Resource, StorageOperationStatus> resource = this.getResource(uniqueId);
+ if (resource.isRight()) {
+ StorageOperationStatus status = resource.right().value();
+ log.error("Failed to fetch resource {} . status is {}", uniqueId, status);
+ return Either.right(status);
+ }
+ resources.add(resource.left().value());
+ }
+ return Either.left(resources);
}
protected TitanOperationStatus findResourcesPathRecursively(String resourceId, List<ResourceMetadataData> resourcesPathList) {
@@ -2163,19 +2137,23 @@ public class ResourceOperation extends ComponentOperation implements IResourceOp
if (byCriteria.isRight()) {
return Either.right(DaoStatusConverter.convertTitanStatusToStorageStatus(byCriteria.right().value()));
}
- List<Resource> resources = new ArrayList<Resource>();
+ List<Resource> resources = new ArrayList<>();
List<ResourceMetadataData> resourcesDataList = byCriteria.left().value();
for (ResourceMetadataData data : resourcesDataList) {
- Either<Resource, StorageOperationStatus> resource = getResource(data.getMetadataDataDefinition().getUniqueId(), inTransaction);
- if (resource.isLeft()) {
- resources.add(resource.left().value());
- } else {
- log.debug("Failed to fetch resource for name = {} and id = {}", data.getUniqueId(), data.getMetadataDataDefinition().getName());
- }
+ buildResource(inTransaction, resources, data);
}
return Either.left(resources);
}
+ private void buildResource(boolean inTransaction, List<Resource> resources, ResourceMetadataData data) {
+ Either<Resource, StorageOperationStatus> resource = getResource(data.getMetadataDataDefinition().getUniqueId(), inTransaction);
+ if (resource.isLeft()) {
+ resources.add(resource.left().value());
+ } else {
+ log.debug("Failed to fetch resource for name = {} and id = {}", data.getUniqueId(), data.getMetadataDataDefinition().getName());
+ }
+ }
+
public Either<List<Resource>, StorageOperationStatus> getResourceListByUuid(String uuid, boolean inTransaction) {
return getLatestResourceByUuid(uuid, false, inTransaction);
}
@@ -2623,7 +2601,7 @@ public class ResourceOperation extends ComponentOperation implements IResourceOp
}
resource.setInterfaces(interfacesOfResourceOnly.left().value());
- List<AttributeDefinition> attributes = new ArrayList<>();
+ List<PropertyDefinition> attributes = new ArrayList<>();
TitanOperationStatus status = attributeOperation.findNodeNonInheretedAttribues(prevId, NodeTypeEnum.Resource, attributes);
if (status != TitanOperationStatus.OK) {
return DaoStatusConverter.convertTitanStatusToStorageStatus(status);
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/UserAdminOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/UserAdminOperation.java
index 7c45f8f384..81ca98444c 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/UserAdminOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/UserAdminOperation.java
@@ -33,6 +33,7 @@ import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
import org.openecomp.sdc.be.dao.titan.TitanGenericDao;
import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
import org.openecomp.sdc.be.dao.utils.UserStatusEnum;
+import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
import org.openecomp.sdc.be.model.FunctionalMenuInfo;
import org.openecomp.sdc.be.model.User;
@@ -282,7 +283,7 @@ public class UserAdminOperation implements IUserAdminOperation {
}
}
- public Either<List<Edge>, StorageOperationStatus> getUserPandingTasksList(User user, Map<String, Object> properties) {
+ public Either<List<Edge>, StorageOperationStatus> getUserPendingTasksList(User user, Map<String, Object> properties) {
UserData userData = convertToUserData(user);
@@ -316,7 +317,16 @@ public class UserAdminOperation implements IUserAdminOperation {
}
}
}
-
+
+ if(log.isDebugEnabled()) {
+ for (Edge edge : pandingTasks) {
+ Object resourceUuid = edge.inVertex().property(GraphPropertyEnum.UNIQUE_ID.getProperty()).value();
+ Object componentName = edge.inVertex().property(GraphPropertyEnum.NAME.getProperty()).value();
+ Object componentState = edge.inVertex().property(GraphPropertyEnum.STATE.getProperty()).value();
+ log.debug("The user userId = {} is working on the component name = {} uid = {} in state {}", user.getUserId(), componentName, resourceUuid, componentState);
+ }
+ }
+
return Either.left(pandingTasks);
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/migration/MigrationErrorInformer.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/migration/MigrationMalformedDataLogger.java
index 952c0672cc..2d4ca635e7 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/migration/MigrationErrorInformer.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/migration/MigrationMalformedDataLogger.java
@@ -14,16 +14,21 @@ import java.util.stream.Collectors;
/**
* to be moved with all operations to the migration project
*/
-@Deprecated
-public class MigrationErrorInformer {
- private static Logger log = LoggerFactory.getLogger(MigrationErrorInformer.class);
+public class MigrationMalformedDataLogger {
+
+ private static Logger log = LoggerFactory.getLogger(MigrationMalformedDataLogger.class);
private static Set<String> malformedVFs = new HashSet<>();
- public static void addMalformedVF(String vfId) {
+ public static void reportMalformedVF(String vfId, String errorMsg) {
+ log.error(errorMsg);
malformedVFs.add(vfId);
}
+ public static void logMalformedDataMsg(String errorMsg) {
+ log.error(errorMsg);
+ }
+
public static void logIfServiceUsingMalformedVfs(Component service) {
List<ComponentInstance> componentInstances = service.getComponentInstances();
if (componentInstances != null && !componentInstances.isEmpty() && !malformedVFs.isEmpty()) {
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/ToscaPropertyType.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/ToscaPropertyType.java
index 079d64a60e..ad226f4e57 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/ToscaPropertyType.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/ToscaPropertyType.java
@@ -63,6 +63,8 @@ public enum ToscaPropertyType {
FLOAT("float", FloatValidator.getInstance(), ToscaFloatConverter.getInstance(), FloatConverter.getInstance()),
INTEGER("integer", IntegerValidator.getInstance(), DefaultConverter.getInstance(), IntegerConverter.getInstance()),
+
+ SCALAR_UNIT("scalar-unit", StringValidator.getInstance(), DefaultConverter.getInstance(), ToscaValueDefaultConverter.getInstance()),
SCALAR_UNIT_SIZE("scalar-unit.size", StringValidator.getInstance(), DefaultConverter.getInstance(), ToscaValueDefaultConverter.getInstance()),
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/converters/ToscaMapValueConverter.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/converters/ToscaMapValueConverter.java
index 80b8779e1e..14f63650ac 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/converters/ToscaMapValueConverter.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/tosca/converters/ToscaMapValueConverter.java
@@ -168,7 +168,7 @@ public class ToscaMapValueConverter extends ToscaValueBaseConverter implements T
return handleComplexJsonValue(entryValue);
}
- // Tal G ticket 228696523 created / DE272734 / Bug 154492 Fix
+ // ticket 228696523 created / DE272734 / Bug 154492 Fix
if(entryValue instanceof JsonArray) {
ArrayList<Object> toscaObjectPresentationArray = new ArrayList<>();
JsonArray jsonArray = entryValue.getAsJsonArray();
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiComponentDataTransfer.java b/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiComponentDataTransfer.java
index 6eb7b841ab..36b6c574aa 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiComponentDataTransfer.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiComponentDataTransfer.java
@@ -7,10 +7,8 @@ import org.openecomp.sdc.be.datatypes.components.ComponentMetadataDataDefinition
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.model.AdditionalInformationDefinition;
import org.openecomp.sdc.be.model.ArtifactDefinition;
-import org.openecomp.sdc.be.model.AttributeDefinition;
import org.openecomp.sdc.be.model.CapabilityDefinition;
import org.openecomp.sdc.be.model.ComponentInstance;
-import org.openecomp.sdc.be.model.ComponentInstanceAttribute;
import org.openecomp.sdc.be.model.ComponentInstanceInput;
import org.openecomp.sdc.be.model.ComponentInstanceProperty;
import org.openecomp.sdc.be.model.GroupDefinition;
@@ -48,7 +46,7 @@ public class UiComponentDataTransfer {
private Map<String, List<ComponentInstanceProperty>> componentInstancesProperties;
- private Map<String, List<ComponentInstanceAttribute>> componentInstancesAttributes;
+ private Map<String, List<ComponentInstanceProperty>> componentInstancesAttributes;
private Map<String, List<CapabilityDefinition>> capabilities;
@@ -60,7 +58,7 @@ public class UiComponentDataTransfer {
protected List<AdditionalInformationDefinition> additionalInformation;
-
+ public UiComponentDataTransfer(){}
public Map<String, ArtifactDefinition> getArtifacts() {
return artifacts;
@@ -192,13 +190,13 @@ public class UiComponentDataTransfer {
}
- public Map<String, List<ComponentInstanceAttribute>> getComponentInstancesAttributes() {
+ public Map<String, List<ComponentInstanceProperty>> getComponentInstancesAttributes() {
return componentInstancesAttributes;
}
public void setComponentInstancesAttributes(
- Map<String, List<ComponentInstanceAttribute>> componentInstancesAttributes) {
+ Map<String, List<ComponentInstanceProperty>> componentInstancesAttributes) {
this.componentInstancesAttributes = componentInstancesAttributes;
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiComponentMetadata.java b/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiComponentMetadata.java
index f0679d31de..6dabfc1402 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiComponentMetadata.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiComponentMetadata.java
@@ -64,6 +64,7 @@ public abstract class UiComponentMetadata {
private String lastUpdaterFullName;
+ public UiComponentMetadata(){}
public UiComponentMetadata (List<CategoryDefinition> categories, ComponentMetadataDataDefinition metadata) {
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiResourceDataTransfer.java b/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiResourceDataTransfer.java
index c56daa4fc9..2547457abc 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiResourceDataTransfer.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiResourceDataTransfer.java
@@ -4,7 +4,6 @@ import java.util.List;
import java.util.Map;
import org.openecomp.sdc.be.model.AdditionalInformationDefinition;
-import org.openecomp.sdc.be.model.AttributeDefinition;
import org.openecomp.sdc.be.model.InterfaceDefinition;
import org.openecomp.sdc.be.model.PropertyDefinition;
@@ -18,7 +17,7 @@ public class UiResourceDataTransfer extends UiComponentDataTransfer{
private List<PropertyDefinition> properties;
- private List<AttributeDefinition> attributes;
+ private List<PropertyDefinition> attributes;
private Map<String, InterfaceDefinition> interfaces;
@@ -26,6 +25,8 @@ public class UiResourceDataTransfer extends UiComponentDataTransfer{
private List<AdditionalInformationDefinition> additionalInformation;
+ public UiResourceDataTransfer(){}
+
public List<AdditionalInformationDefinition> getAdditionalInformation() {
return additionalInformation;
}
@@ -66,11 +67,11 @@ public class UiResourceDataTransfer extends UiComponentDataTransfer{
this.properties = properties;
}
- public List<AttributeDefinition> getAttributes() {
+ public List<PropertyDefinition> getAttributes() {
return attributes;
}
- public void setAttributes(List<AttributeDefinition> attributes) {
+ public void setAttributes(List<PropertyDefinition> attributes) {
this.attributes = attributes;
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiResourceMetadata.java b/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiResourceMetadata.java
index 19c7246462..3675bc619c 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiResourceMetadata.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiResourceMetadata.java
@@ -16,6 +16,7 @@ public class UiResourceMetadata extends UiComponentMetadata {
private String toscaResourceName;
private List<String> derivedFrom;
+
public UiResourceMetadata(List<CategoryDefinition> categories, List<String> derivedFrom, ResourceMetadataDataDefinition metadata) {
super(categories, metadata);
this.vendorName = metadata.getVendorName();
@@ -27,6 +28,8 @@ public class UiResourceMetadata extends UiComponentMetadata {
this.derivedFrom = derivedFrom;
}
+ public UiResourceMetadata(){}
+
public List<String> getDerivedFrom() {
return derivedFrom;
}