Creates a relation id string from the source and target ids and a relation type.<p>

@param source the source id
@param target the target id
@param relType the relation type

@return the relation id
190028
protected static String createKey(CmsUUID source, CmsUUID target, String relType) {

        return RELATION_ID_PREFIX + source + "_" + target + "_" + relType;
    }
1036675
private void computeStrongestMappingForSource(INode source) {
        INode strongetsRelationInTarget = null;
        List<IMappingElement<INode>> strongest = new ArrayList<IMappingElement<INode>>();

        //look for the strongest relation, and deletes all the non structure preserving relations
        for (INode j : defautlMappings.getTargetContext().getNodesList()) {
            if (isSameStructure(source, j)) {
                if (strongest.isEmpty() && defautlMappings.getRelation(source, j) != IMappingElement.IDK
                        && !existsStrongerInColumn(source, j)) {
                    strongetsRelationInTarget = j;
                    strongest.add(new MappingElement<INode>(source, j, defautlMappings.getRelation(source, j)));
                } else if (defautlMappings.getRelation(source, j) != IMappingElement.IDK && !strongest.isEmpty()) {
                    int precedence = comparePrecedence(strongest.get(0).getRelation(), defautlMappings.getRelation(source, j));
                    if (precedence == -1 && !existsStrongerInColumn(source, j)) {
                        //if target is more precedent, and there is no other stronger relation for that particular target
                        strongetsRelationInTarget = j;
                        strongest.set(0, new MappingElement<INode>(source, j, defautlMappings.getRelation(source, j)));
                    }
                }
            } else {
                //they are not the same structure, function to function, variable to variable
                //delete the relation
                defautlMappings.setRelation(source, j, IMappingElement.IDK);
            }
        }

        //if there is a strongest element, and it is different from IDK
        if (!strongest.isEmpty() && strongest.get(0).getRelation() != IMappingElement.IDK) {
            //erase all the weaker relations in the row
            for (INode j : defautlMappings.getTargetContext().getNodesList()) {
                if (j != strongetsRelationInTarget && defautlMappings.getRelation(source, j) != IMappingElement.IDK) {
                    int precedence = comparePrecedence(strongest.get(0).getRelation(), defautlMappings.getRelation(source, j));
                    if (precedence == 1) {
                        defautlMappings.setRelation(source, j, IMappingElement.IDK);
                    } else if (precedence == 0) {
                        if (isSameStructure(source, j)) {
                            strongest.add(new MappingElement<INode>(source, j, defautlMappings.getRelation(source, j)));
                        }
                    }
                }
            }

            //if there is more than one strongest relation
            if (strongest.size() > 1) {
                resolveStrongestMappingConflicts(source, strongest);
            } else {
                //deletes all the relations in the column
                for (INode i : defautlMappings.getSourceContext().getNodesList()) {
                    if (i != source) {
                        defautlMappings.setRelation(i, strongetsRelationInTarget, IMappingElement.IDK);
                    }
                }

                if (strongest.get(0).getRelation() != IMappingElement.IDK) {
                    spsmMapping.add(strongest.get(0));

                    // remove the relations from the same column and row
                    deleteRemainingRelationsFromMatrix(strongest.get(0));
                }
            }
        }
    }
803053
RelationReified buildRelationReified(VertexElement vertex, RelationType type) {
        return RelationReified.create(vertex, type);
    }
406348
public static HalRelation build(String relName, Class<?> resourceType, UriBuilder urlTemplate) {
    HalRelation relation = new HalRelation();
    relation.relName = relName;
    relation.uriTemplate = urlTemplate;
    relation.resourceType = resourceType;
    return relation;
  }
639932
private static String buildLink(final URI linkUri, final String relation) {
        return Link.fromUri(linkUri).rel(relation).build().toString();
    }
577888
private static void checkRelationAliasesConsistency(RAExpressionAttributes re1,
                                                        RAExpressionAttributes re2) throws IllegalJoinException {

        ImmutableSet<RelationID> alias1 = re1.attributes.keySet().stream()
                .filter(id -> id.getRelation() != null)
                .map(QualifiedAttributeID::getRelation).collect(ImmutableCollectors.toSet());

        ImmutableSet<RelationID> alias2 = re2.attributes.keySet().stream()
                .filter(id -> id.getRelation() != null)
                .map(QualifiedAttributeID::getRelation).collect(ImmutableCollectors.toSet());

        if (alias1.stream().anyMatch(alias2::contains))
            throw new IllegalJoinException(re1, re2 ,"Relation alias " +
                    alias1.stream().filter(alias2::contains).collect(ImmutableCollectors.toList()) +
                    " occurs in both arguments of the JOIN");
    }
1247298
private void populateCollectionFromMap(Object entity, PersistenceDelegator delegator, Relation relation,
            Object relObject, Map<String, Object> relationsMap)
    {
        EntityMetadata childMetadata = KunderaMetadataManager.getEntityMetadata(delegator.getKunderaMetadata(),
                relation.getTargetEntity());
        // Map collection to be set into entity
        Map<Object, Object> relationshipEntityMap = new HashMap<Object, Object>();

        if ((relObject == null || ProxyHelper.isProxyCollection(relObject)) && relationsMap != null
                && !relationsMap.isEmpty())
        {
            for (String relationName : relationsMap.keySet())
            {
                Object relationValue = relationsMap.get(relationName);
                if (relationValue instanceof Map)
                {
                    Map<Object, Object> relationValueMap = (Map<Object, Object>) relationValue;

                    // Client for target entity
                    Client targetEntityClient = delegator.getClient(childMetadata);

                    for (Object targetEntityKey : relationValueMap.keySet())
                    {
                        // Find target entity from database
                        Object targetEntity = targetEntityClient.find(childMetadata.getEntityClazz(), targetEntityKey);
                        if (targetEntity != null && targetEntity instanceof EnhanceEntity)
                        {
                            targetEntity = ((EnhanceEntity) targetEntity).getEntity();
                        }

                        // Set source and target entities into Map key entity
                        Object mapKeyEntity = relationValueMap.get(targetEntityKey);
                        Class<?> relationshipClass = relation.getMapKeyJoinClass();
                        for (Field f : relationshipClass.getDeclaredFields())
                        {
                            if (f.getType().equals(entity.getClass()))
                            {
                                PropertyAccessorHelper.set(mapKeyEntity, f, entity);
                            }
                            else if (f.getType().equals(childMetadata.getEntityClazz()))
                            {
                                PropertyAccessorHelper.set(mapKeyEntity, f, targetEntity);
                            }
                        }

                        // Finally, put map key and value into collection
                        relationshipEntityMap.put(mapKeyEntity, targetEntity);
                    }
                }
            }
            relObject = relationshipEntityMap;
        }

        // Set relationship collection into original entity
        PropertyAccessorHelper.set(entity, relation.getProperty(), relObject);

        // Add target entities into persistence cache
        if (relObject != null && !ProxyHelper.isProxyCollection(relObject))
        {
            for (Object child : ((Map) relObject).values())
            {
                if (child != null)
                {
                    Object childId = PropertyAccessorHelper.getId(child, childMetadata);
                    PersistenceCacheManager.addEntityToPersistenceCache(child, delegator, childId);
                }
            }
        }
    }
845654
@Description("apoc.index.relationships('TYPE','prop:value*') YIELD rel - lucene query on relationship index with the given type name")
    @Procedure(mode = Mode.READ)
    public Stream<WeightedRelationshipResult> relationships(@Name("type") String type, @Name("query") String query) throws Exception {
        if (!db.index().existsForRelationships(type)) return Stream.empty();
        return toWeightedRelationshipResult(db.index().forRelationships(type).query(query,null,null));
    }
645216
public static RelationType create(@NonNull String name) {
      RelationType toReturn = DynamicEnum.register(new RelationType(name));
      values.add(toReturn);
      return toReturn;
   }
74811
RelationImpl buildRelation(EdgeElement edge) {
        return getOrBuildConcept(edge, (e) -> RelationImpl.create(RelationEdge.get(edge)));
    }
1077230
public boolean hasRel(String rel) {

		Assert.hasText(rel, "Link relation must not be null or empty!");

		return hasRel(LinkRelation.of(rel));
	}
1067509
public <T extends Relation> T add(T statement,
                                     int num,
                                     Collection<T> anonRelationCollection,
                                     HashMap<QualifiedName, Collection<T>> namedRelationMap,
                                     HashMap<QualifiedName, Collection<T>> effectRelationMap,
                                     HashMap<QualifiedName, Collection<T>> causeRelationMap) {
	QualifiedName aid2 = u.getEffect(statement); //wib.getInformed();
	QualifiedName aid1 = u.getCause(statement); //wib.getInformant();

	statement = pFactory.newStatement(statement); // clone
	
	QualifiedName id;
	if (statement instanceof Identifiable) {
	    id=((Identifiable)statement).getId();	
	} else {
	    id=null;
	}

	if (id == null) {

	    boolean found = false;
	    Collection<T> relationCollection = effectRelationMap.get(aid2);
	    if (relationCollection == null) {
		relationCollection = new LinkedList<T>();
		relationCollection.add(statement);
		effectRelationMap.put(aid2, relationCollection);
	    } else {
		for (T u : relationCollection) {
		    if (u.equals(statement)) {
			found = true;
			statement = u;
			break;
		    }
		}
		if (!found) {
		    relationCollection.add(statement);
		}
	    }

	    relationCollection = causeRelationMap.get(aid1);
	    if (relationCollection == null) {
		relationCollection = new LinkedList<T>();
		relationCollection.add(statement);
		causeRelationMap.put(aid1, relationCollection);
	    } else {
		if (!found) {
		    // if we had not found it in the first table, then we
		    // have to add it here too
		    relationCollection.add(statement);
		}
	    }

	    if (!found) {
		anonRelationCollection.add(statement);
	    }
	} else {
	    Collection<T> relationCollection=namedRelationMap.get(id);
	    if (relationCollection==null) {
		relationCollection=new LinkedList<T>();
		relationCollection.add(statement);
		namedRelationMap.put(id, relationCollection);
	    } else {
		boolean found=false;
		for (T u1: relationCollection) {
		    if (sameEdge(u1,statement,num)) {
			found=true;
			mergeAttributes(u1, statement);
			break;			
		    }
		}
		if (!found) {
		    relationCollection.add(statement);
		}
	    }
	}
	return statement;
}
381303
@Override
	public Links findLinksWithRel(LinkRelation relation, InputStream representation) {

		Assert.notNull(relation, "LinkRelation must not be null!");

		try {

			Object parseResult = getExpression(relation).read(representation);
			return createLinksFrom(parseResult, relation);

		} catch (IOException o_O) {
			throw new RuntimeException(o_O);
		} catch (PathNotFoundException o_O) {
			return Links.NONE;
		}
	}
1123172
public void setRelationId(String relationId) {

        try {
            m_relationId = new CmsUUID(relationId);
        } catch (Throwable e) {
            setThrowable(e);
        }
    }
717776
@Override
    public InheritanceEdge createEdge(ClassVertex source, ClassVertex target) {
        if (!target.isInterface()) {
            source.setDirectSuperclass(target);
        }
        return super.createEdge(source, target);
    }
1285819
public static function buildRelationQuery($entity, Relation $relation) {
        $relQuery = "";
        $getid = "getId";
        if ($relation->getCardinality() == Relation::$manyToMany) {
            $m = "get" . $relation->getName();
            $relQuery .= "INSERT INTO " . $relation->getTable() . " (" . $relation->getLocalColumn() . ", " . $relation->getForeignColumn() . ") ";
            $relQuery .= "VALUES (:" . $relation->getLocalColumn() . ", :" . $relation->getForeignColumn() . ");";
        }
        if ($relation->getCardinality() == Relation::$oneToMany) {
            $relMapper = MapperBuilder::buildFromName($this->mapping, $relation->getEntity());
            $m = "get" . $relation->getName();
            foreach ($entity->$m() as $rel) {
                $setid = "set" . $relMapper->getNameForColumn($relation->getForeignColumn());
                $rel->$setid($entity->$getid());
                $relQuery .= $this->buildInsertQuery($rel);
            }
        }


        return $relQuery;
    }
108431
protected static CmsRelationType getRelationType(String typeName) {

        for (CmsRelationType relType : CmsRelationType.getAll()) {
            if (relType.getName().equalsIgnoreCase(typeName)) {
                return relType;
            }
        }
        return null;
    }