Specifies a filter for entities that are sources of a relationship with the specified entity.

@param entityPath the entity that is the target of the relationship
@param relationship the name of the relationship
@return a new "related" filter instance
359459
public static Related with(CanonicalPath entityPath, String relationship) {
        return new Related(entityPath, relationship, EntityRole.SOURCE);
    }
98374
private Set<RelationshipTuple> getRels(String relsDatastreamName) {
        List<Datastream> relsDatastreamVersions = m_datastreams.get(relsDatastreamName);

        if (relsDatastreamVersions == null || relsDatastreamVersions.size() == 0) {
            return new HashSet<RelationshipTuple>();
        }

        Datastream latestRels = relsDatastreamVersions.get(0);

        for (Datastream v : relsDatastreamVersions) {
           	if (v.DSCreateDT == null){
           		latestRels = v;
           		break;
           	}
            if (v.DSCreateDT.getTime() > latestRels.DSCreateDT.getTime()) {
                latestRels = v;
            }
        }

        try {
            return RDFRelationshipReader.readRelationships(latestRels);
        } catch (ServerException e) {
            throw new RuntimeException("Error reading object relationships in " + relsDatastreamName, e);
        }
    }
668564
@Override
    public List<Object> findByRelation(String colName, Object colValue, Class entityClazz)
    {
        EntityMetadata m = KunderaMetadataManager.getEntityMetadata(kunderaMetadata, entityClazz);
        String tableName = HBaseUtils.getHTableName(m.getSchema(), m.getTableName());
        String columnFamilyName = m.getTableName();
        byte[] valueInBytes = HBaseUtils.getBytes(colValue);
        SingleColumnValueFilter filter = new SingleColumnValueFilter(Bytes.toBytes(columnFamilyName),
                Bytes.toBytes(colName), CompareOp.EQUAL, valueInBytes);
        filter.setFilterIfMissing(true);
        try
        {
            return ((HBaseDataHandler) handler).readData(tableName, m, null, null, null, null, getFilterList(filter));
        }
        catch (IOException ex)
        {
            log.error("Error during find By Relation, Caused by: .", ex);
            throw new KunderaException("Error during find By Relation, Caused by: .", ex);
        }
    }
826947
public void setRelatedFindingsProductArn(java.util.Collection<StringFilter> relatedFindingsProductArn) {
        if (relatedFindingsProductArn == null) {
            this.relatedFindingsProductArn = null;
            return;
        }

        this.relatedFindingsProductArn = new java.util.ArrayList<StringFilter>(relatedFindingsProductArn);
    }
119012
public void addRelationshipToTarget(final SpecTopic topic, final RelationshipType type) {
        final TargetRelationship relationship = new TargetRelationship(this, topic, type);
        topicTargetRelationships.add(relationship);
        relationships.add(relationship);
    }
298330
RelationBuilder getRelationBuilder(Object target, Relation relation, Node source)
    {
        RelationBuilder relationBuilder = new RelationBuilder(target, relation, source);
        relationBuilder.assignGraphGenerator(this.generator);
        return relationBuilder;
    }
471484
@Override
	public Links findLinksWithRel(LinkRelation relation, String representation) {

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

		try {
			Object parseResult = getExpression(relation).read(representation);
			return createLinksFrom(parseResult, relation);
		} catch (InvalidPathException e) {
			return Links.NONE;
		}
	}
1191502
function defineRelationshipResolution(
  schema: GraphQLSchema,
  relationships: Relationship[],
  database: DatabaseInterface,
): void {
  relationships.forEach(relationship => {
    defineFieldResolve(
      schema,
      relationship.path[0].fromType,
      relationship.fieldName,
      database.generateRelationshipResolver(relationship),
    );
  });
}
728345
private void addRelationshipIndex(EntityMetadata entityMetadata, Relationship relationship,
            Index<Relationship> relationshipIndex, MetamodelImpl metaModel)
    {
//        MetamodelImpl metaModel = (MetamodelImpl) kunderaMetadata.getApplicationMetadata().getMetamodel(
//                entityMetadata.getPersistenceUnit());

        // ID attribute has to be indexed first
        String idColumnName = ((AbstractAttribute) entityMetadata.getIdAttribute()).getJPAColumnName();
        relationshipIndex.add(relationship, idColumnName, relationship.getProperty(idColumnName));

        // Index all other fields, for whom indexing is enabled
        for (Attribute attribute : metaModel.entity(entityMetadata.getEntityClazz()).getSingularAttributes())
        {
            Field field = (Field) attribute.getJavaMember();
            if (!attribute.isCollection() && !attribute.isAssociation()
                    && entityMetadata.getIndexProperties().keySet().contains(field.getName()))
            {
                String columnName = ((AbstractAttribute) attribute).getJPAColumnName();
                relationshipIndex.add(relationship, columnName, relationship.getProperty(columnName));
            }
        }
    }
1371446
public function filterRelations()
    {
        // Verify we can filter by relations and there are relations to filter by
        if ($this->relationsEnabled()) {
            foreach ($this->getAllRelations() as $related => $filterable) {
                // Make sure we have filterable input
                if (count($filterable) > 0) {
                    if ($this->relationIsJoined($related)) {
                        $this->filterJoinedRelation($related);
                    } else {
                        $this->filterUnjoinedRelation($related);
                    }
                }
            }
        }

        return $this;
    }
194592
protected function createIdentifierCollectionRelationship($object, RelationshipDefinition $definition, MappingContext $context): IdentifierCollectionRelationship
    {
        $relationship = new IdentifierCollectionRelationship();
        $collection   = $object->{$definition->getGetter()}();
        $dataLimit    = $definition->getDataLimit();

        if ($dataLimit > 0) {
            $collection = new \LimitIterator($collection, 0, $dataLimit);
        }

        $mapper = $context->getMapper();

        foreach ($collection as $relatedObject)
        {
            $resource = $mapper->toResourceIdentifier($relatedObject);

            $relationship->addIdentifier($resource);
        }

        return $relationship;
    }
1245396
public List<RelationshipInterface> execute(NodeInterface sourceNode, RelationshipType relType, Direction dir) throws FrameworkException {

		RelationshipFactory factory        = new RelationshipFactory(securityContext);
		List<RelationshipInterface> result = new LinkedList<>();
		Node node                          = sourceNode.getNode();
		Iterable<Relationship> rels;

		if (node == null) {

			return Collections.EMPTY_LIST;

		}

		if (relType != null) {

			rels = node.getRelationships(dir, relType);

		} else {

			rels = node.getRelationships(dir);
		}

		try {

			for (Relationship r : rels) {

				result.add(factory.instantiate(r));
			}

		} catch (RuntimeException e) {

			logger.warn("Exception occured: ", e.getMessage());

			/**
				* ********* FIXME
				*
				* Here an exception occurs:
				*
				* org.neo4j.kernel.impl.nioneo.store.InvalidRecordException: Node[5] is neither firstNode[37781] nor secondNode[37782] for Relationship[188125]
				* at org.neo4j.kernel.impl.nioneo.xa.ReadTransaction.getMoreRelationships(ReadTransaction.java:131)
				* at org.neo4j.kernel.impl.nioneo.xa.NioNeoDbPersistenceSource$ReadOnlyResourceConnection.getMoreRelationships(NioNeoDbPersistenceSource.java:280)
				* at org.neo4j.kernel.impl.persistence.PersistenceManager.getMoreRelationships(PersistenceManager.java:100)
				* at org.neo4j.kernel.impl.core.NodeManager.getMoreRelationships(NodeManager.java:585)
				* at org.neo4j.kernel.impl.core.NodeImpl.getMoreRelationships(NodeImpl.java:358)
				* at org.neo4j.kernel.impl.core.IntArrayIterator.hasNext(IntArrayIterator.java:115)
				*
				*
				*/
		}

		return result;
	}
438710
public function filterUnjoinedRelation($related)
    {
        $this->query->whereHas($related, function ($q) use ($related) {
            $this->callRelatedLocalSetup($related, $q);

            // If we defined it locally then we're running the closure on the related model here right.
            foreach ($this->getLocalRelation($related) as $closure) {
                // Run in context of the related model locally
                $closure($q);
            }

            if (count($filterableRelated = $this->getRelatedFilterInput($related)) > 0) {
                $q->filter($filterableRelated);
            }

            return $q;
        });
    }
13797
protected function applyRelationshipFiltersAndSorts(ModelQueryBuilder $builder): self
    {
        // While joining tables we select distinct rows. This flag used to apply `distinct` no more than once.
        $distinctApplied = false;

        foreach ($this->relFiltersAndSorts as $relationshipName => $filtersAndSorts) {
            assert(is_string($relationshipName) === true && is_array($filtersAndSorts) === true);
            $builder->addRelationshipFiltersAndSorts(
                $relationshipName,
                $filtersAndSorts[self::REL_FILTERS_AND_SORTS__FILTERS] ?? [],
                $filtersAndSorts[self::REL_FILTERS_AND_SORTS__SORTS] ?? []
            );

            if ($distinctApplied === false) {
                $builder->distinct();
                $distinctApplied = true;
            }
        }

        return $this;
    }
1372323
public void setEntityPath(java.util.Collection<ResponseTimeRootCauseEntity> entityPath) {
        if (entityPath == null) {
            this.entityPath = null;
            return;
        }

        this.entityPath = new java.util.ArrayList<ResponseTimeRootCauseEntity>(entityPath);
    }
707024
private void onPersist(EntityMetadata entityMetadata, Object entity, Object id, List<RelationHolder> rlHolders,
            Object connection)
    {
        // first open a pipeline
        AttributeWrapper wrapper = wrap(entityMetadata, entity);

        // add relations.

        if (rlHolders != null)
        {
            for (RelationHolder relation : rlHolders)
            {
                String name = relation.getRelationName();
                Object value = relation.getRelationValue();
                byte[] valueInBytes = PropertyAccessorHelper.getBytes(value);
                byte[] nameInBytes = getEncodedBytes(name);
                String valueAsStr = PropertyAccessorHelper.getString(value);
                wrapper.addColumn(nameInBytes, valueInBytes);
                wrapper.addIndex(getHashKey(entityMetadata.getTableName(), name), getDouble(valueAsStr));

                // this index is required to work for UNION/INTERSECT
                // support.

                wrapper.addIndex(getHashKey(entityMetadata.getTableName(), getHashKey(name, valueAsStr)),
                        getDouble(valueAsStr));
            }
        }

        // prepareCompositeKey

        MetamodelImpl metaModel = (MetamodelImpl) kunderaMetadata.getApplicationMetadata().getMetamodel(
                entityMetadata.getPersistenceUnit());

        EntityType entityType = metaModel.entity(entityMetadata.getEntityClazz());
        String discrColumn = ((AbstractManagedType) entityType).getDiscriminatorColumn();
        String discrValue = ((AbstractManagedType) entityType).getDiscriminatorValue();

        // No need to check for empty or blank, as considering it as valid name
        // for nosql!
        if (discrColumn != null && discrValue != null)
        {
            byte[] valueInBytes = PropertyAccessorHelper.getBytes(discrValue);
            byte[] nameInBytes = getEncodedBytes(discrColumn);
            wrapper.addColumn(nameInBytes, valueInBytes);
            wrapper.addIndex(getHashKey(entityMetadata.getTableName(), discrColumn), getDouble(discrValue));
            wrapper.addIndex(getHashKey(entityMetadata.getTableName(), getHashKey(discrColumn, discrValue)),
                    getDouble(discrValue));
        }

        String rowKey = null;
        if (metaModel.isEmbeddable(entityMetadata.getIdAttribute().getBindableJavaType()))
        {
            rowKey = KunderaCoreUtils.prepareCompositeKey(entityMetadata, id);
        }
        else
        {
            ObjectAccessor accessor = new ObjectAccessor();
            rowKey = accessor.toString(id);
            // rowKey = /*PropertyAccessorHelper.getString(entity, (Field)
            // entityMetadata.getIdAttribute().getJavaMember())*/ ;
        }

        String hashKey = getHashKey(entityMetadata.getTableName(), rowKey);

        if (resource != null && resource.isActive())
        {
            ((Transaction) connection).hmset(getEncodedBytes(hashKey), wrapper.getColumns());
        }
        else
        {
            ((Pipeline) connection).hmset(getEncodedBytes(hashKey), wrapper.getColumns());
        }

        // Add inverted indexes for column based search.

        // // Add row key to list(Required for wild search over table).
        //
        // wrapper.addIndex(getHashKey(entityMetadata.getTableName(),
        // ((AbstractAttribute)
        // entityMetadata.getIdAttribute()).getJPAColumnName()),
        // getDouble(rowKey));
        //
        // // Add row-key as inverted index as well needed for multiple clause
        // // search with key and non row key.
        // wrapper.addIndex(getHashKey(
        // entityMetadata.getTableName(),
        // getHashKey(((AbstractAttribute)
        // entityMetadata.getIdAttribute()).getJPAColumnName(), rowKey)),
        // getDouble(rowKey));
        KunderaCoreUtils.printQuery(
                "Persist data into " + entityMetadata.getSchema() + "." + entityMetadata.getTableName()
                        + " for primary key " + rowKey, showQuery);
        addIndex(connection, wrapper, rowKey, entityMetadata);

    }
1160153
public RelationshipRepository<Resource, String, Resource, String> getRepositoryForPath(String sourceResourceType,
                                                                                           String targetResourceType) {
        init();

        ResourceInformation sourceResourceInformation =
                new ResourceInformation(moduleRegistry.getTypeParser(), Resource.class, sourceResourceType, null, null,
                        PagingSpec.class);
        return (RelationshipRepository<Resource, String, Resource, String>) decorate(new RelationshipRepositoryStubImpl<>(this, Resource.class, Resource.class, sourceResourceInformation, urlBuilder));
    }