return newOrExistingNode;
}
public RelationshipInterface storeRelationship(final DataContainer receivedData) throws FrameworkException {
final RelationshipDataContainer receivedRelationshipData = (RelationshipDataContainer) receivedData;
final String sourceStartNodeId = receivedRelationshipData.getSourceStartNodeId();
final String sourceEndNodeId = receivedRelationshipData.getSourceEndNodeId();
final String uuid = receivedRelationshipData.getRelationshipId();
// if end node ID was not found in the ID map,
// assume it already exists in the database
// (i.e. it was created earlier)
String targetStartNodeId = idMap.get(sourceStartNodeId);
if (targetStartNodeId == null) {
targetStartNodeId = sourceStartNodeId;
}
// if end node ID was not found in the ID map,
// assume it already exists in the database
// (i.e. it was created earlier)
String targetEndNodeId = idMap.get(sourceEndNodeId);
if (targetEndNodeId == null) {
targetEndNodeId = sourceEndNodeId;
}
if (targetStartNodeId != null && targetEndNodeId != null) {
// Get new start and end node
final SecurityContext securityContext = SecurityContext.getSuperUserInstance();
final NodeInterface targetStartNode = (NodeInterface) app.get(targetStartNodeId);
final NodeInterface targetEndNode = (NodeInterface) app.get(targetEndNodeId);
final String typeName = receivedRelationshipData.getType();
final Class relType = config.getRelationshipEntityClass(typeName);
if (targetStartNode != null && targetEndNode != null) {
final RelationshipInterface existingCandidate = app.relationshipQuery().and(GraphObject.id, uuid).includeDeletedAndHidden().getFirst();
final PropertyMap properties = PropertyMap.databaseTypeToJavaType(securityContext, relType, receivedRelationshipData.getProperties());
if (existingCandidate != null) {
// merge properties?
((Syncable) existingCandidate).updateFromPropertyMap(properties);