List of usage examples for org.apache.commons.lang3.tuple ImmutablePair getLeft
@Override
public L getLeft()
From source file:org.openecomp.sdc.be.model.operations.impl.ArtifactOperation.java
private Either<Boolean, StorageOperationStatus> setRelevantHeatParamId(TitanVertex artifactV, ArtifactDefinition artifactInfo) { Map<String, String> heatParametersHM = new HashMap<String, String>(); Iterator<Edge> iterHeat = artifactV.edges(Direction.OUT, GraphEdgeLabels.GENERATED_FROM.getProperty()); if (!iterHeat.hasNext()) { log.debug("No edges with label GENERATED_FROM for the node {}", artifactInfo.getUniqueId()); return Either.right(StorageOperationStatus.NOT_FOUND); }/*from w w w. ja v a 2 s. c om*/ Edge heat = iterHeat.next(); Vertex heatVertex = heat.inVertex(); String heatUniqueId = (String) heatVertex.value(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.ArtifactRef)); Either<List<ImmutablePair<HeatParameterData, GraphEdge>>, TitanOperationStatus> getHeatParametersRes = titanGenericDao .getChildrenNodes(GraphPropertiesDictionary.UNIQUE_ID.getProperty(), heatUniqueId, GraphEdgeLabels.HEAT_PARAMETER, NodeTypeEnum.HeatParameter, HeatParameterData.class); if (getHeatParametersRes.isRight()) { log.debug("No heat parameters for heat artifact {}", heatUniqueId); return Either.right(StorageOperationStatus.NOT_FOUND); } List<ImmutablePair<HeatParameterData, GraphEdge>> heatParameters = getHeatParametersRes.left().value(); if (heatParameters == null) { log.debug("No heat parameters for heat artifact {}", heatUniqueId); return Either.right(StorageOperationStatus.NOT_FOUND); } for (ImmutablePair<HeatParameterData, GraphEdge> heatParamEdge : heatParameters) { HeatParameterData heatParam = heatParamEdge.getLeft(); heatParametersHM.put(heatParam.getName(), (String) heatParam.getUniqueId()); } String curName = null; for (HeatParameterDefinition heatEnvParam : artifactInfo.getHeatParameters()) { curName = heatEnvParam.getName(); if (heatParametersHM.containsKey(curName)) { heatEnvParam.setUniqueId(heatParametersHM.get(curName)); } } return Either.left(true); }
From source file:org.openecomp.sdc.be.model.operations.impl.ArtifactOperation.java
@Override public Either<Map<String, ArtifactDefinition>, StorageOperationStatus> getArtifacts(String parentId, NodeTypeEnum parentType, boolean inTransaction, String groupType) { Either<Map<String, ArtifactDefinition>, StorageOperationStatus> result = null; try {//w ww.ja v a 2s . c o m Either<TitanGraph, TitanOperationStatus> graph = titanGenericDao.getGraph(); if (graph.isRight()) { log.debug("Failed to work with graph {}", graph.right().value()); return Either.right(DaoStatusConverter.convertTitanStatusToStorageStatus(graph.right().value())); } TitanGraph tGraph = graph.left().value(); @SuppressWarnings("unchecked") Iterable<TitanVertex> vertices = tGraph.query() .has(UniqueIdBuilder.getKeyByNodeType(parentType), parentId).vertices(); if (vertices == null || vertices.iterator() == null || false == vertices.iterator().hasNext()) { log.debug("No nodes for type {} for id = {}", parentType, parentId); result = Either.right(StorageOperationStatus.NOT_FOUND); return result; } Iterator<TitanVertex> iterator = vertices.iterator(); Vertex vertex = iterator.next(); Map<String, Object> edgeProperties = null; if (groupType != null) { edgeProperties = new HashMap<>(); edgeProperties.put(GraphEdgePropertiesDictionary.GROUP_TYPE.getProperty(), groupType); } Either<List<ImmutablePair<ArtifactData, GraphEdge>>, TitanOperationStatus> childrenByEdgeCriteria = titanGenericDao .getChildrenByEdgeCriteria(vertex, parentId, GraphEdgeLabels.ARTIFACT_REF, NodeTypeEnum.ArtifactRef, ArtifactData.class, edgeProperties); if (childrenByEdgeCriteria.isRight()) { TitanOperationStatus status = childrenByEdgeCriteria.right().value(); result = Either.right(DaoStatusConverter.convertTitanStatusToStorageStatus(status)); return result; } List<ImmutablePair<ArtifactData, GraphEdge>> list = childrenByEdgeCriteria.left().value(); Map<String, ArtifactDefinition> artifactsMap = new HashMap<>(); for (ImmutablePair<ArtifactData, GraphEdge> pair : list) { ArtifactData artifactData = pair.getLeft(); ArtifactDefinition artifactDefinition = new ArtifactDefinition( artifactData.getArtifactDataDefinition()); List<HeatParameterDefinition> heatParams = new ArrayList<HeatParameterDefinition>(); StorageOperationStatus heatParametersStatus = heatParametersOperation.getHeatParametersOfNode( NodeTypeEnum.ArtifactRef, artifactDefinition.getUniqueId(), heatParams); if (!heatParametersStatus.equals(StorageOperationStatus.OK)) { log.debug("failed to get heat parameters for node {} {}", parentType.getName(), parentId); return Either.right(heatParametersStatus); } if (!heatParams.isEmpty()) { artifactDefinition.setHeatParameters(heatParams); } Either<ImmutablePair<ArtifactData, GraphEdge>, TitanOperationStatus> getResult = titanGenericDao .getChild(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.ArtifactRef), artifactDefinition.getUniqueId(), GraphEdgeLabels.GENERATED_FROM, NodeTypeEnum.ArtifactRef, ArtifactData.class); if (getResult.isRight()) { TitanOperationStatus status = getResult.right().value(); if (!status.equals(TitanOperationStatus.NOT_FOUND)) { return Either.right(DaoStatusConverter.convertTitanStatusToStorageStatus(status)); } } else { ImmutablePair<ArtifactData, GraphEdge> immutablePair = getResult.left().value(); artifactDefinition.setGeneratedFromId((String) immutablePair.left.getUniqueId()); } artifactsMap.put(artifactDefinition.getArtifactLabel(), artifactDefinition); log.debug("Artifact {} was added to list ", artifactData.getUniqueId()); } result = Either.left(artifactsMap); return result; } finally { if (inTransaction == false) { if (result == null || result.isRight()) { this.titanGenericDao.rollback(); } else { this.titanGenericDao.commit(); } } } }
From source file:org.openecomp.sdc.be.model.operations.impl.AttributeOperation.java
private Either<List<ComponentInstanceAttribute>, TitanOperationStatus> convertToComponentInstanceAttribute( List<ImmutablePair<AttributeValueData, GraphEdge>> list) { Either<List<ComponentInstanceAttribute>, TitanOperationStatus> result = null; List<ComponentInstanceAttribute> componentInstanceAttribute = new ArrayList<>(); for (ImmutablePair<AttributeValueData, GraphEdge> attributeValue : list) { AttributeValueData attributeValueData = attributeValue.getLeft(); String attributeValueUid = attributeValueData.getUniqueId(); Either<ImmutablePair<AttributeData, GraphEdge>, TitanOperationStatus> attributeDefRes = titanGenericDao .getChild(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.AttributeValue), attributeValueUid, GraphEdgeLabels.ATTRIBUTE_IMPL, NodeTypeEnum.Attribute, AttributeData.class); if (attributeDefRes.isRight()) { TitanOperationStatus status = attributeDefRes.right().value(); if (status == TitanOperationStatus.NOT_FOUND) { status = TitanOperationStatus.INVALID_ID; }/*w ww.j av a 2 s . c o m*/ result = Either.right(status); break; } else { ImmutablePair<AttributeData, GraphEdge> attributeDefPair = attributeDefRes.left().value(); String attributeUniqueId = attributeDefPair.left.getUniqueId(); ComponentInstanceAttribute resourceInstanceAttribute = new ComponentInstanceAttribute(); // set attribute original unique id resourceInstanceAttribute.setUniqueId(attributeUniqueId); // set hidden resourceInstanceAttribute.setHidden(attributeValueData.isHidden()); // set value resourceInstanceAttribute.setValue(attributeValueData.getValue()); // set property value unique id resourceInstanceAttribute.setValueUniqueUid(attributeValueUid); resourceInstanceAttribute.setType(attributeValueData.getType()); componentInstanceAttribute.add(resourceInstanceAttribute); } } if (result == null) { result = Either.left(componentInstanceAttribute); } return result; }
From source file:org.openecomp.sdc.be.model.operations.impl.AttributeOperation.java
@Override public TitanOperationStatus findNodeNonInheretedAttribues(String uniqueId, NodeTypeEnum nodeType, List<AttributeDefinition> attributes) { Either<List<ImmutablePair<AttributeData, GraphEdge>>, TitanOperationStatus> childrenNodes = titanGenericDao .getChildrenNodes(UniqueIdBuilder.getKeyByNodeType(nodeType), uniqueId, GraphEdgeLabels.ATTRIBUTE, NodeTypeEnum.Attribute, AttributeData.class); if (childrenNodes.isRight()) { TitanOperationStatus status = childrenNodes.right().value(); if (status == TitanOperationStatus.NOT_FOUND) { status = TitanOperationStatus.OK; }//from w ww. j ava2 s . c o m return status; } List<ImmutablePair<AttributeData, GraphEdge>> values = childrenNodes.left().value(); if (values != null) { for (ImmutablePair<AttributeData, GraphEdge> immutablePair : values) { AttributeData attData = immutablePair.getLeft(); String attributeName = attData.getAttributeDataDefinition().getName(); log.debug("Attribute {} is associated to node {}", attributeName, uniqueId); AttributeData attributeData = immutablePair.getKey(); AttributeDefinition attributeDefinition = this .convertAttributeDataToAttributeDefinition(attributeData, attributeName, uniqueId); attributes.add(attributeDefinition); log.trace("findAttributesOfNode - property {} associated to node {}", attributeDefinition, uniqueId); } } return TitanOperationStatus.OK; }
From source file:org.openecomp.sdc.be.model.operations.impl.CapabilityInstanceOperation.java
private Either<Boolean, TitanOperationStatus> deleteAllPropertyValuesOfCapabilityInstance( String resourceInstanceId, String capabilityInstanceId) { log.debug("Before deleting all property values of capability instance {} fromRI {}.", capabilityInstanceId, resourceInstanceId);//from w w w . j a va 2s . c o m TitanOperationStatus error = null; List<ImmutablePair<PropertyValueData, GraphEdge>> deletePropertiesPairs; Either<List<ImmutablePair<PropertyValueData, GraphEdge>>, TitanOperationStatus> getPropertyValuesRes = titanGenericDao .getChildrenNodes(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.CapabilityInst), capabilityInstanceId, GraphEdgeLabels.PROPERTY_VALUE, NodeTypeEnum.PropertyValue, PropertyValueData.class); if (getPropertyValuesRes.isRight()) { error = getPropertyValuesRes.right().value(); log.debug("Failed to retrieve property values of capability instance {} forRI {} status {}.", capabilityInstanceId, resourceInstanceId, error); } if (error == null) { deletePropertiesPairs = getPropertyValuesRes.left().value(); for (ImmutablePair<PropertyValueData, GraphEdge> propertyPair : deletePropertiesPairs) { Either<PropertyValueData, TitanOperationStatus> deletePropertyRes = titanGenericDao .deleteNode(propertyPair.getLeft(), PropertyValueData.class); if (deletePropertyRes.isRight()) { error = deletePropertyRes.right().value(); log.debug("failedDeletePropertyValues {} forRI {} statusIs {}.", capabilityInstanceId, resourceInstanceId, error); break; } } } log.debug("After deleting all property values of capability instance {} fromRI {} statusIs {}.", capabilityInstanceId, resourceInstanceId, error); if (error == null) { return Either.left(true); } return Either.right(error); }
From source file:org.openecomp.sdc.be.model.operations.impl.CapabilityInstanceOperation.java
/** * clone and associate capability instance with property values * //from w w w . j a v a 2 s . c o m * @param createdComponentInstance * @param capability * @param capabilityInstPair * @return */ @Override public Either<ImmutablePair<CapabilityInstData, List<PropertyValueData>>, TitanOperationStatus> cloneAssociateCapabilityInstanceWithPropertyValues( ComponentInstanceData createdComponentInstance, CapabilityDefinition capability, ImmutablePair<CapabilityInstData, GraphEdge> capabilityInstPair) { TitanOperationStatus error = null; String componentInstanceId = createdComponentInstance.getUniqueId(); String capabilityInstanceId = capabilityInstPair.getLeft().getUniqueId(); log.debug("Before cloning capability instance with property values of capability instance {} ofRI {}.", capabilityInstanceId, componentInstanceId); List<ImmutablePair<PropertyValueData, GraphEdge>> propertyValuePairs; List<PropertyValueData> newPropertyValues = new ArrayList<>(); CapabilityInstData cloneCapabilityInstance = null; Either<CapabilityInstData, TitanOperationStatus> cloneCapabilityInstanceNodeRes = null; log.debug("Before getting all property values ofCI {} ofRI {}.", capabilityInstanceId, componentInstanceId); Either<List<ImmutablePair<PropertyValueData, GraphEdge>>, TitanOperationStatus> getPropertyValuesRes = titanGenericDao .getChildrenNodes(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.CapabilityInst), capabilityInstPair.getLeft().getUniqueId(), GraphEdgeLabels.PROPERTY_VALUE, NodeTypeEnum.PropertyValue, PropertyValueData.class); if (getPropertyValuesRes.isRight()) { error = getPropertyValuesRes.right().value(); log.debug("Failed to retrieve property values of capability instance {} ofCI {} statusIs {}.", capabilityInstPair.getLeft().getUniqueId(), componentInstanceId, error); } log.debug("After getting all property values ofCI {} ofRI {} statusIs {}.", capabilityInstanceId, componentInstanceId, error); if (error == null) { CapabilityInstData cloneCapabilityInst = buildCapabilityInstanceData(componentInstanceId, capability); log.debug("Before creating capability instance node {} onGraph.", cloneCapabilityInst.getUniqueId()); cloneCapabilityInstanceNodeRes = titanGenericDao.createNode(cloneCapabilityInst, CapabilityInstData.class); if (cloneCapabilityInstanceNodeRes.isRight()) { error = cloneCapabilityInstanceNodeRes.right().value(); log.debug("Failed to create capability instance of capability {} ofCI {} statusIs {}.", capability.getUniqueId(), componentInstanceId, error); } log.debug("After creating capability instance node {} onGraph. statusIs {}", cloneCapabilityInst.getUniqueId(), error); } if (error == null) { log.debug("Before creating relation from capability instance {} toCapability {} onGraph.", cloneCapabilityInstanceNodeRes.left().value().getUniqueId(), capability.getUniqueId()); cloneCapabilityInstance = cloneCapabilityInstanceNodeRes.left().value(); CapabilityData capabilityData = buildCapabilityData(capability); Map<String, Object> props = new HashMap<>(); props.put(GraphPropertiesDictionary.CAPABILITY_ID.getProperty(), capabilityData.getUniqueId()); Either<GraphRelation, TitanOperationStatus> createRelationRes = titanGenericDao .createRelation(cloneCapabilityInstance, capabilityData, GraphEdgeLabels.INSTANCE_OF, props); if (createRelationRes.isRight()) { error = createRelationRes.right().value(); log.debug("Failed to associate capability instance {} toCapability {} statusIs {}.", cloneCapabilityInstance.getUniqueId(), capability.getUniqueId(), error); } log.debug("After creating relation from capability instance {} toCapability {} onGraph. statusIs {}.", cloneCapabilityInstanceNodeRes.left().value().getUniqueId(), capability.getUniqueId(), error); } if (error == null) { log.debug("Before cloning property values ofCI {}.", capabilityInstanceId); propertyValuePairs = getPropertyValuesRes.left().value(); for (ImmutablePair<PropertyValueData, GraphEdge> propertyValuePair : propertyValuePairs) { Either<PropertyValueData, TitanOperationStatus> clonePropertyValueRes = cloneAssociatePropertyValue( cloneCapabilityInstance, propertyValuePair); if (clonePropertyValueRes.isRight()) { error = clonePropertyValueRes.right().value(); if (log.isDebugEnabled()) { log.debug("Failed to clone property value {} ofCapability {} ofCI {}. statusIs {}.", propertyValuePair.getLeft().getUniqueId(), capability.getUniqueId(), componentInstanceId, error); } break; } else { newPropertyValues.add(clonePropertyValueRes.left().value()); } } log.debug("After cloning property values of CI {} statusIs {}.", capabilityInstanceId, error); } log.debug( "After cloning capability instance with property values of capability instance {} ofRI {} statusIs {}.", capabilityInstanceId, componentInstanceId, error); if (error == null) { return Either.left(new ImmutablePair<CapabilityInstData, List<PropertyValueData>>( cloneCapabilityInstance, newPropertyValues)); } return Either.right(error); }
From source file:org.openecomp.sdc.be.model.operations.impl.CapabilityInstanceOperation.java
public Either<TitanVertex, TitanOperationStatus> cloneAssociateCapabilityInstanceWithPropertyValues( TitanVertex componentInstanceVertex, CapabilityDefinition capability, ImmutablePair<CapabilityInstData, GraphEdge> capabilityInstPair) { TitanOperationStatus error = null;/*from www . j a v a 2 s .c o m*/ String componentInstanceId = (String) titanGenericDao.getProperty(componentInstanceVertex, GraphPropertiesDictionary.UNIQUE_ID.getProperty()); String capabilityInstanceId = capabilityInstPair.getLeft().getUniqueId(); if (log.isTraceEnabled()) { log.trace("Before cloning capability instance with property values of capability instance {} {} {}", capabilityInstanceId, ofRI, componentInstanceId); } List<ImmutablePair<TitanVertex, Edge>> propertyValuePairs; Either<TitanVertex, TitanOperationStatus> cloneCapabilityInstanceNodeRes = null; if (log.isTraceEnabled()) { log.trace("Before getting all property values {} {} {} {}", ofCI, capabilityInstanceId, ofRI, componentInstanceId); } Either<List<ImmutablePair<TitanVertex, Edge>>, TitanOperationStatus> getPropertyValuesRes = titanGenericDao .getChildrenVertecies(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.CapabilityInst), capabilityInstPair.getLeft().getUniqueId(), GraphEdgeLabels.PROPERTY_VALUE); if (getPropertyValuesRes.isRight()) { error = getPropertyValuesRes.right().value(); if (log.isDebugEnabled()) { log.debug("Failed to retrieve property values of capability instance {} {} {} {} {}", capabilityInstPair.getLeft().getUniqueId(), ofCI, componentInstanceId, statusIs, error); } } if (log.isTraceEnabled()) { log.trace("After getting all property values {} {} {} {} {} {}", ofCI, capabilityInstanceId, ofRI, componentInstanceId, statusIs, error); } if (error == null) { CapabilityInstData cloneCapabilityInst = buildCapabilityInstanceData(componentInstanceId, capability); log.trace("Before creating capability instance node {} {} ", cloneCapabilityInst.getUniqueId(), onGraph); cloneCapabilityInstanceNodeRes = titanGenericDao.createNode(cloneCapabilityInst); if (cloneCapabilityInstanceNodeRes.isRight()) { error = cloneCapabilityInstanceNodeRes.right().value(); if (log.isDebugEnabled()) { log.debug("Failed to create capability instance of capability {} {} {} {} {}", capability.getUniqueId(), ofCI, componentInstanceId, statusIs, error); } } if (log.isTraceEnabled()) { log.trace("After creating capability instance node {} {} {} {}", cloneCapabilityInst.getUniqueId(), onGraph, statusIs, error); } } CapabilityData capabilityData; TitanVertex cloneCapabilityInstance = null; if (error == null) { if (log.isTraceEnabled()) { log.trace("Before creating relation from capability instance {} {} {} {}", capability.getUniqueId(), toCapability, capability.getUniqueId(), onGraph); } capabilityData = buildCapabilityData(capability); Map<String, Object> props = new HashMap<>(); props.put(GraphPropertiesDictionary.CAPABILITY_ID.getProperty(), capabilityData.getUniqueId()); cloneCapabilityInstance = cloneCapabilityInstanceNodeRes.left().value(); TitanOperationStatus createRelationRes = titanGenericDao.createEdge(cloneCapabilityInstance, capabilityData, GraphEdgeLabels.INSTANCE_OF, props); if (!createRelationRes.equals(TitanOperationStatus.OK)) { error = createRelationRes; if (log.isDebugEnabled()) { log.debug("Failed to associate capability instance {} {} {} {} {}", capabilityData.getUniqueId(), toCapability, capability.getUniqueId(), statusIs, createRelationRes); } } if (log.isTraceEnabled()) { log.trace("After creating relation from capability instance {} {} {} {} {} {}", capabilityData.getUniqueId(), toCapability, capability.getUniqueId(), onGraph, statusIs, error); } } if (error == null) { log.trace("Before cloning property values {} {} ", ofCI, capabilityInstanceId); propertyValuePairs = getPropertyValuesRes.left().value(); for (ImmutablePair<TitanVertex, Edge> propertyValuePair : propertyValuePairs) { TitanOperationStatus clonePropertyValueRes = cloneAssociatePropertyValue(cloneCapabilityInstance, propertyValuePair); if (!clonePropertyValueRes.equals(TitanOperationStatus.OK)) { error = clonePropertyValueRes; if (log.isDebugEnabled()) { log.debug("Failed to clone property value of capability {} {} {} {} {}", capability.getUniqueId(), ofCI, componentInstanceId, statusIs, error); } break; } } if (log.isDebugEnabled()) { log.debug("After cloning property values {} {} {} {}", ofCI, capabilityInstanceId, statusIs, error); } } log.debug( "After cloning capability instance with property values of capability instance {} ofRI {} statusIs {}.", capabilityInstanceId, componentInstanceId, error); if (error == null) { return Either.left(cloneCapabilityInstance); } return Either.right(error); }
From source file:org.openecomp.sdc.be.model.operations.impl.CapabilityInstanceOperation.java
private Either<PropertyValueData, TitanOperationStatus> cloneAssociatePropertyValue( CapabilityInstData cloneCapabilityInstance, ImmutablePair<PropertyValueData, GraphEdge> propertyValuePair) { TitanOperationStatus error = null;//from www . j a va 2 s .com String propertyValueID = propertyValuePair.getLeft().getUniqueId(); String capabilityInstanceId = cloneCapabilityInstance.getUniqueId(); log.debug("Before cloning property values {} ofCI {}.", propertyValueID, capabilityInstanceId); Map<String, Object> props = propertyValuePair.getRight().getProperties(); PropertyData propertyData = new PropertyData(); String propertyId = (String) props.get(GraphPropertiesDictionary.PROPERTY_ID.name()); propertyData.getPropertyDataDefinition().setUniqueId(propertyId); PropertyValueData propertyValue = buildPropertyValueData( (String) props.get(GraphPropertiesDictionary.PROPERTY_NAME.name()), propertyValuePair.getLeft().getType(), propertyValuePair.getLeft().getValue(), capabilityInstanceId); PropertyValueData createdValue = null; Either<GraphRelation, TitanOperationStatus> createRelationRes; log.debug("Before creating property values node {} onGraph.", propertyValue.getUniqueId()); Either<PropertyValueData, TitanOperationStatus> createValueRes = titanGenericDao.createNode(propertyValue, PropertyValueData.class); if (createValueRes.isRight()) { error = createValueRes.right().value(); log.debug("Failed to create property value for capability instance {} ofRI. statusIs {}.", cloneCapabilityInstance.getUniqueId(), error); } log.debug("After creating property values node {} onGraph. statusIs {}.", propertyValue.getUniqueId(), error); if (error == null) { createdValue = createValueRes.left().value(); log.debug("Before creating relation from capability instance {} toValue {}.", capabilityInstanceId, createdValue.getUniqueId()); createRelationRes = titanGenericDao.createRelation(cloneCapabilityInstance, createdValue, GraphEdgeLabels.PROPERTY_VALUE, props); if (createRelationRes.isRight()) { error = createRelationRes.right().value(); log.debug("Failed to create relation from capability instance {} toValue {} statusIs {}.", cloneCapabilityInstance.getUniqueId(), createdValue.getUniqueId(), error); } log.debug("After creating relation from capability instance {} toValue {} statusIs {}", capabilityInstanceId, createdValue.getUniqueId(), error); } if (error == null) { log.debug("Before creating relation from property value {} toProperty {}.", createdValue, propertyData.getUniqueId()); createRelationRes = titanGenericDao.createRelation(createdValue, propertyData, GraphEdgeLabels.PROPERTY_IMPL, props); if (createRelationRes.isRight()) { error = createRelationRes.right().value(); log.debug("Failed to create relation from property value {} toProperty {} statusIs {}.", createdValue.getUniqueId(), propertyId, error); } log.debug("Before creating relation from property value {} toProperty {} statusIs {}.", createdValue, propertyData.getUniqueId(), error); } log.debug("After cloning property values {} ofCI {} statusIs {}.", propertyValueID, capabilityInstanceId, error); if (error == null) { return Either.left(createdValue); } return Either.right(error); }
From source file:org.openecomp.sdc.be.model.operations.impl.CapabilityInstanceOperation.java
private TitanOperationStatus cloneAssociatePropertyValue(TitanVertex capabilityInstanceVertex, ImmutablePair<TitanVertex, Edge> propertyValuePair) { TitanOperationStatus error = null;/*from w w w.jav a2 s . c o m*/ TitanVertex propertyVertex = propertyValuePair.getLeft(); String propertyValueID = (String) titanGenericDao.getProperty(propertyVertex, GraphPropertiesDictionary.UNIQUE_ID.getProperty()); String capabilityInstanceId = (String) titanGenericDao.getProperty(capabilityInstanceVertex, GraphPropertiesDictionary.UNIQUE_ID.getProperty()); if (log.isTraceEnabled()) { log.trace("Before cloning property values {} {} {}", propertyValueID, ofCI, capabilityInstanceId); } Map<String, Object> props = titanGenericDao.getProperties(propertyValuePair.getRight()); PropertyData propertyData = new PropertyData(); String propertyId = (String) props.get(GraphPropertiesDictionary.PROPERTY_ID.name()); propertyData.getPropertyDataDefinition().setUniqueId(propertyId); String propertyType = (String) titanGenericDao.getProperty(propertyVertex, GraphPropertiesDictionary.TYPE.getProperty()); String propertyValueStr = (String) titanGenericDao.getProperty(propertyVertex, GraphPropertiesDictionary.VALUE.getProperty()); PropertyValueData propertyValue = buildPropertyValueData( (String) props.get(GraphPropertiesDictionary.PROPERTY_NAME.name()), propertyType, propertyValueStr, capabilityInstanceId); TitanVertex createdValue = null; TitanOperationStatus createRelationRes; log.trace("Before creating property values node {} {} ", propertyValue.getUniqueId(), onGraph); Either<TitanVertex, TitanOperationStatus> createValueRes = titanGenericDao.createNode(propertyValue); String capabiltyInstId = (String) titanGenericDao.getProperty(capabilityInstanceVertex, GraphPropertiesDictionary.UNIQUE_ID.getProperty()); if (createValueRes.isRight()) { error = createValueRes.right().value(); if (log.isDebugEnabled()) { log.debug("Failed to create property value for capability instance {} {} {} {}", capabiltyInstId, ofRI, statusIs, error); } } if (log.isTraceEnabled()) { log.trace("After creating property values node {} {} {} {} ", propertyValue.getUniqueId(), onGraph, statusIs, error); } if (error == null) { createdValue = createValueRes.left().value(); log.trace("Before creating relation from capability instance {} {} {}", capabilityInstanceId, toValue, propertyValue.getUniqueId()); createRelationRes = titanGenericDao.createEdge(capabilityInstanceVertex, createdValue, GraphEdgeLabels.PROPERTY_VALUE, props); if (!createRelationRes.equals(TitanOperationStatus.OK)) { error = createRelationRes; if (log.isDebugEnabled()) { log.debug("Failed to create relation from capability instance {} {} {} {} {}", capabiltyInstId, toValue, propertyValue.getUniqueId(), statusIs, error); } } if (log.isTraceEnabled()) { log.trace("After creating relation from capability instance {} {} {} {} {} ", capabilityInstanceId, toValue, propertyValue.getUniqueId(), statusIs, error); } } if (error == null) { log.trace("Before creating relation from property value {} {} {} ", createdValue, toProperty, propertyData.getUniqueId()); createRelationRes = titanGenericDao.createEdge(createdValue, propertyData, GraphEdgeLabels.PROPERTY_IMPL, props); if (!createRelationRes.equals(TitanOperationStatus.OK)) { error = createRelationRes; if (log.isDebugEnabled()) { log.debug("Failed to create relation from property value {} {} {} {} {}", propertyValue.getUniqueId(), toProperty, propertyId, statusIs, error); } } if (log.isTraceEnabled()) { log.trace("Before creating relation from property value c", createdValue, toProperty, propertyData.getUniqueId(), statusIs, error); } } if (log.isTraceEnabled()) { log.trace("After cloning property values {} {} {} {} {}", propertyValueID, ofCI, capabilityInstanceId, statusIs, error); } if (error == null) { return TitanOperationStatus.OK; } return error; }
From source file:org.openecomp.sdc.be.model.operations.impl.ComponentInstanceOperation.java
private Either<List<GraphRelation>, TitanOperationStatus> associateCreatedComponentInstanceToClonedCapabilityInstances( String newComponentResourceId, List<ImmutablePair<CapabilityInstData, GraphEdge>> capabilityInstances) { TitanOperationStatus error = null;// w w w. j a v a 2 s . co m List<GraphRelation> relationsToCapabilityInstances = new ArrayList<>(); UniqueIdData componentInstanceIdData = new UniqueIdData(NodeTypeEnum.ResourceInstance, newComponentResourceId); for (ImmutablePair<CapabilityInstData, GraphEdge> capInstPair : capabilityInstances) { Either<GraphRelation, TitanOperationStatus> associateComponentInstanceToCapabilityinstanceRes = titanGenericDao .createRelation(componentInstanceIdData, capInstPair.getLeft(), GraphEdgeLabels.CAPABILITY_INST, capInstPair.getRight().getProperties()); if (associateComponentInstanceToCapabilityinstanceRes.isRight()) { error = associateComponentInstanceToCapabilityinstanceRes.right().value(); log.debug("Failed to associate capability instance {} to resource instance {}. Status is {}.", capInstPair.getLeft().getUniqueId(), newComponentResourceId, error); break; } else { relationsToCapabilityInstances .add(associateComponentInstanceToCapabilityinstanceRes.left().value()); } } if (error == null) { return Either.left(relationsToCapabilityInstances); } return Either.right(error); }