Pattern for two different EntityReference have member PhysicalEntity in the same Complex, and
the Complex has an activity. Complex membership can be through multiple nesting and/or
through homology relations.
@return the pattern
18271
public static Pattern inSameActiveComplex()
	{
		Pattern p = inSameComplex();
		p.add(new ActivityConstraint(true), "Complex");
		return p;
	}
940449
public Optional<String> getPattern() {
        if (property instanceof StringProperty) {
            StringProperty stringProperty = (StringProperty) property;
            return Optional.ofNullable(stringProperty.getPattern());
        } else if (property instanceof UUIDProperty) {
            UUIDProperty uuidProperty = (UUIDProperty) property;
            return Optional.ofNullable(uuidProperty.getPattern());
        }
        return Optional.empty();
    }
950005
public static Pattern molecularInteraction()
	{
		Pattern p = new Pattern(SequenceEntityReference.class, "Protein 1");
		p.add(linkedER(true), "Protein 1", "generic Protein 1");
		p.add(erToPE(), "generic Protein 1", "SPE1");
		p.add(linkToComplex(), "SPE1", "PE1");
		p.add(new PathConstraint("PhysicalEntity/participantOf:MolecularInteraction"), "PE1", "MI");
		p.add(participant(), "MI", "PE2");
		p.add(equal(false), "PE1", "PE2");

		// participants are not both baits or preys
		p.add(new NOT(new AND(new MappedConst(isPrey(), 0), new MappedConst(isPrey(), 1))), "PE1", "PE2");
		p.add(new NOT(new AND(new MappedConst(isBait(), 0), new MappedConst(isBait(), 1))), "PE1", "PE2");

		p.add(linkToSpecific(), "PE2", "SPE2");
		p.add(type(SequenceEntity.class), "SPE2");
		p.add(new PEChainsIntersect(false), "SPE1", "PE1", "SPE2", "PE2");
		p.add(peToER(), "SPE2", "generic Protein 2");
		p.add(linkedER(false), "generic Protein 2", "Protein 2");
		p.add(equal(false), "Protein 1", "Protein 2");
		return p;
	}
853817
<T extends Entity> T getRelation(Class<T> valuesClass, String name) {
        return getRelation(valuesClass, name, true);
    }
105092
protected function getPattern()/*# : string */
    {
        if (is_null($this->reference_pattern)) {
            if ('' === $this->reference_start ||
                is_null($this->reference_end)) {
                $this->reference_pattern = '';
            } else {
                $this->reference_pattern = '~('  .
                    preg_quote($this->reference_start) .
                    '([a-zA-Z_][a-zA-Z0-9._]*+)' .
                    preg_quote($this->reference_end) . ')~';
            }
        }
        return $this->reference_pattern;
    }
1273400
public List<EntityBeanType<EnterpriseBeansType<T>>> getAllEntity()
   {
      List<EntityBeanType<EnterpriseBeansType<T>>> list = new ArrayList<EntityBeanType<EnterpriseBeansType<T>>>();
      List<Node> nodeList = childNode.get("entity");
      for(Node node: nodeList)
      {
         EntityBeanType<EnterpriseBeansType<T>>  type = new EntityBeanTypeImpl<EnterpriseBeansType<T>>(this, "entity", childNode, node);
         list.add(type);
      }
      return list;
   }
1071743
public static <T1, T2> Pattern2<T1, T2> and(/* this */Observable<T1> left, Observable<T2> right) {
        if (left == null) {
            throw new NullPointerException("left");
        }
        if (right == null) {
            throw new NullPointerException("right");
        }
        return new Pattern2<T1, T2>(left, right);
    }
482506
@Override
    public List<Object> findByRelation(String colName, Object colValue, Class entityClazz)
    {

        EntityMetadata entityMetadata = KunderaMetadataManager.getEntityMetadata(kunderaMetadata, entityClazz);
        Object[] ids = findIdsByColumn(entityMetadata.getTableName(), colName, colValue);
        List<Object> resultSet = new ArrayList<Object>();
        if (ids != null)
        {
            // just to insure uniqueness.

            for (Object id : new HashSet(Arrays.asList(ids)))
            {
                resultSet.add(find(entityClazz, id));
            }
        }

        return resultSet;
    }
221433
private Object getEntityWithAssociationFromNode(EntityMetadata m, Node node)
    {
        Map<String, Object> relationMap = new HashMap<String, Object>();

        /**
         * Map containing Node ID as key and Entity object as value. Helps cache
         * entity objects found earlier for faster lookup and prevents repeated
         * processing
         */
        Map<Long, Object> nodeIdToEntityMap = new HashMap<Long, Object>();

        Object entity = mapper.getEntityFromNode(node, m);

        nodeIdToEntityMap.put(node.getId(), entity);
        populateRelations(m, entity, relationMap, node, nodeIdToEntityMap);

        nodeIdToEntityMap.clear();

        if (!relationMap.isEmpty() && entity != null)
        {
            return new EnhanceEntity(entity, PropertyAccessorHelper.getId(entity, m), relationMap);
        }
        else
        {
            return entity;
        }

    }
884935
@ManyToOne(targetEntity = org.openprovenance.prov.sql.QualifiedName.class, cascade = {
        CascadeType.ALL
    })
    @JoinColumn(name = "USED_ENTITY")
    public org.openprovenance.prov.model.QualifiedName getUsedEntity() {
        return usedEntity;
    }
87549
public Map<String, byte[]> getCurrentMembers()
    {
        ImmutableMap.Builder<String, byte[]> builder = ImmutableMap.builder();
        boolean thisIdAdded = false;
        for ( ChildData data : cache.getCurrentData() )
        {
            String id = idFromPath(data.getPath());
            thisIdAdded = thisIdAdded || id.equals(thisId);
            builder.put(id, data.getData());
        }
        if ( !thisIdAdded )
        {
            builder.put(thisId, pen.getData());   // this instance is always a member
        }
        return builder.build();
    }
24951
<T extends Entity> T getRelation(Class<T> valuesClass, String name,
            boolean cachable) {
        return instance.getRelation(this, valuesClass, name, cachable);
    }
1239934
private String getRelatedIDs(SmallMoleculeReference smr)
	{
		String ids = smr.getUri();

		for (Object o : new PathAccessor(
			"SmallMoleculeReference/entityReferenceOf").getValueFromBean(smr))
		{
			SimplePhysicalEntity spe = (SimplePhysicalEntity) o;
			ids += "\n" + spe.getUri();
		}
		return ids;
	}
638397
@Override
    protected EntityDecl findEntity(String id, Object arg)
    {
        // Expand a Parameter Entity?
        if (arg == ENTITY_EXP_PE) { // for attribute default
            EntityDecl ed = (mPredefdPEs == null) ? null : mPredefdPEs.get(id);
            if (ed != null) { // Entity from int. subset...
                mUsesPredefdEntities = true;
                /* No need to further keep track of internal references,
                 * since this subset can not be cached, so let's just free
                 * up Map if it has been created
                 */
                mRefdPEs = null;
            } else if (mParamEntities != null) {
                ed = mParamEntities.get(id);
                if (ed != null) {
                    if (!mUsesPredefdEntities) {
                        // Let's also mark down the fact we referenced the entity:
                        Set<String> used = mRefdPEs;
                        if (used == null) {
                            mRefdPEs = used = new HashSet<String>();
                        }
                        used.add(id);
                    }
                }
            }
            return ed;
        }

        // Nope, General Entity (within attribute default value)?
        if (arg == ENTITY_EXP_GE) {
            /* This is only complicated for external subsets, since
             * they may 'inherit' entity definitions from preceding
             * internal subset...
             */
            EntityDecl ed = (mPredefdGEs == null) ? null : mPredefdGEs.get(id);
            if (ed != null) {
                mUsesPredefdEntities = true;
                /* No need to further keep track of references,
                 * as this means this subset is not cachable...
                 * so let's just free up Map if it has been created
                 */
                mRefdGEs = null;
            } else if (mGeneralEntities != null) {
                ed = mGeneralEntities.get(id);
                if (ed != null) {
                    // Ok, just need to mark reference, if we still care:
                    if (!mUsesPredefdEntities) {
                        // Let's also mark down the fact we referenced the entity:
                        if (mRefdGEs == null) {
                            mRefdGEs = new HashSet<String>();
                        }
                        mRefdGEs.add(id);
                    }
                }
            }
            return ed;
        }

        throw new IllegalStateException(ErrorConsts.ERR_INTERNAL);
    }
101878
@Override
    public Set<EntityType<?>> getEntities()
    {
        Set<EntityType<?>> entities = null;
        if (entityTypes != null)
        {
            entities = new HashSet<EntityType<?>>(entityTypes.values());
        }
        return entities;
    }
741897
public List<BaseDescr> getRemainingPatterns() {
        if ( this.patterns.size() > 1 ) {
            return this.patterns.subList( 1,
                                          this.patterns.size() );
        } else if ( this.patterns.size() == 1 ) {
            // in case there is only one pattern, we do a rewrite, so:
            // forall( Cheese( type == "stilton" ) )
            // becomes
            // forall( BASE_IDENTIFIER : Cheese() Cheese( this == BASE_IDENTIFIER, type == "stilton" ) )
            PatternDescr original = (PatternDescr) this.patterns.get( 0 );
            PatternDescr remaining = (PatternDescr) original.clone();
            remaining.addConstraint( new ExprConstraintDescr( "this == " + BASE_IDENTIFIER ) );
            remaining.setResource(original.getResource());
            return Collections.singletonList( (BaseDescr)remaining );
        }
        return Collections.emptyList();
    }
1253851
public Map<String, Object> createRelationshipProperties(EntityMetadata entityMetadata,
            EntityMetadata targetEntityMetadata, Object relationshipEntity)
    {
        MetamodelImpl metaModel = (MetamodelImpl) kunderaMetadata.getApplicationMetadata().getMetamodel(
                entityMetadata.getPersistenceUnit());
        EntityType entityType = metaModel.entity(relationshipEntity.getClass());
        Map<String, Object> relationshipProperties = new HashMap<String, Object>();

        Set<Attribute> attributes = entityType.getSingularAttributes();
        for (Attribute attribute : attributes)
        {
            Field f = (Field) attribute.getJavaMember();
            if (!f.getType().equals(entityMetadata.getEntityClazz())
                    && !f.getType().equals(targetEntityMetadata.getEntityClazz()))
            {
                String relPropertyName = ((AbstractAttribute) attribute).getJPAColumnName();
                Object value = PropertyAccessorHelper.getObject(relationshipEntity, f);
                relationshipProperties.put(relPropertyName, toNeo4JProperty(value));
            }
        }
        return relationshipProperties;
    }