Binds the given PhysicalEntity to the downstream.
@param pe PhysicalEntity to bind
@param graph Owner graph
974087
protected void addToDownstream(BioPAXElement pe, Graph graph)
	{
		AbstractNode node = (AbstractNode) graph.getGraphObject(pe);

		if (node != null)
		{
			EdgeL3 edge = new EdgeL3(this, node, graph);
			edge.setTranscription(true);

			node.getUpstreamNoInit().add(edge);
			this.getDownstreamNoInit().add(edge);
		}
	}
542853
public static synchronized void bind(String propertiesPath, Class clazz) throws BindingException
    {
        if (em == null)
        {
            em = PersistenceService.getEM(emf, propertiesPath, clazz.getName());
        }
        onBind(clazz);
    }
779053
@Override
    public void addModelToGraph(URI graphUri, Model data) {
        if (graphUri == null || data == null)
            return;

        // Use HTTP protocol if possible
        if (this.sparqlServiceEndpoint != null) {
            datasetAccessor.add(graphUri.toASCIIString(), data);
        } else {
            this.addModelToGraphSparqlQuery(graphUri, data);
        }
    }
162019
public void connectSource(int inputNumber, IntermediateResult source, JobEdge edge, int consumerNumber) {

		final DistributionPattern pattern = edge.getDistributionPattern();
		final IntermediateResultPartition[] sourcePartitions = source.getPartitions();

		ExecutionEdge[] edges;

		switch (pattern) {
			case POINTWISE:
				edges = connectPointwise(sourcePartitions, inputNumber);
				break;

			case ALL_TO_ALL:
				edges = connectAllToAll(sourcePartitions, inputNumber);
				break;

			default:
				throw new RuntimeException("Unrecognized distribution pattern.");

		}

		inputEdges[inputNumber] = edges;

		// add the consumers to the source
		// for now (until the receiver initiated handshake is in place), we need to register the
		// edges as the execution graph
		for (ExecutionEdge ee : edges) {
			ee.getSource().addConsumer(ee, consumerNumber);
		}
	}
169573
@Override
	public void onRelationshipInstantiation() {

		try {

			if (dbRelationship != null) {

				Node startNode = dbRelationship.getStartNode();
				Node endNode   = dbRelationship.getEndNode();

				if ((startNode != null) && (endNode != null) && startNode.hasProperty(GraphObject.id.dbName()) && endNode.hasProperty(GraphObject.id.dbName())) {

					cachedStartNodeId = (String) startNode.getProperty(GraphObject.id.dbName());
					cachedEndNodeId   = (String) endNode.getProperty(GraphObject.id.dbName());

				}

			}

		} catch (Throwable t) {
		}
	}
351818
@Override
	public void initDownstream()
	{
		for (Process prc : ctrl.getControlled())
		{
			if (prc instanceof Conversion ||
				prc instanceof Control ||
				prc instanceof TemplateReaction)
			{
				AbstractNode node = (AbstractNode) graph.getGraphObject(prc);

				if (node != null)
				{
					Edge edge = new EdgeL3(this, node, graph);
					node.getUpstreamNoInit().add(edge);
					getDownstreamNoInit().add(edge);
				}
			}
		}
	}
573589
private Node createNode(final DatabaseService graphDb, final Principal user, final String type, final Set<String> labels, final Map<String, Object> properties) throws FrameworkException {

		final Map<String, Object> ownsProperties     = new HashMap<>();
		final Map<String, Object> securityProperties = new HashMap<>();
		final String newUuid                         = (String)properties.get("id");

		if (user != null && user.shouldSkipSecurityRelationships() == false) {

			final String userId = user.getUuid();

			// configure OWNS relationship creation statement for maximum performance
			ownsProperties.put(GraphObject.id.dbName(),                          getNextUuid());
			ownsProperties.put(GraphObject.type.dbName(),                        PrincipalOwnsNode.class.getSimpleName());
			ownsProperties.put(GraphObject.visibleToPublicUsers.dbName(),        false);
			ownsProperties.put(GraphObject.visibleToAuthenticatedUsers.dbName(), false);
			ownsProperties.put(AbstractRelationship.relType.dbName(),            "OWNS");
			ownsProperties.put(AbstractRelationship.sourceId.dbName(),           userId);
			ownsProperties.put(AbstractRelationship.targetId.dbName(),           newUuid);
			ownsProperties.put(AbstractRelationship.internalTimestamp.dbName(),  graphDb.getInternalTimestamp());

			// configure SECURITY relationship creation statement for maximum performance
			securityProperties.put(GraphObject.id.dbName(),                          getNextUuid());
			securityProperties.put(GraphObject.type.dbName(),                        Security.class.getSimpleName());
			securityProperties.put(GraphObject.visibleToPublicUsers.dbName(),        false);
			securityProperties.put(GraphObject.visibleToAuthenticatedUsers.dbName(), false);
			securityProperties.put(AbstractRelationship.relType.dbName(),            "SECURITY");
			securityProperties.put(AbstractRelationship.sourceId.dbName(),           userId);
			securityProperties.put(AbstractRelationship.targetId.dbName(),           newUuid);
			securityProperties.put(AbstractRelationship.internalTimestamp.dbName(),  graphDb.getInternalTimestamp());
			securityProperties.put(Security.allowed.dbName(),                        new String[] { Permission.read.name(), Permission.write.name(), Permission.delete.name(), Permission.accessControl.name() } );
			securityProperties.put(Security.principalId.dbName(),                    userId);
			securityProperties.put(Security.accessControllableId.dbName(),           newUuid);

			try {

				final NodeWithOwnerResult result = graphDb.createNodeWithOwner(user.getNode().getId(), type, labels, properties, ownsProperties, securityProperties);
				final Relationship securityRel   = result.getSecurityRelationship();
				final Relationship ownsRel       = result.getOwnsRelationship();
				final Node newNode               = result.getNewNode();

				notifySecurityRelCreation(user, securityRel);
				notifyOwnsRelCreation(user, ownsRel);

				return newNode;

			} catch (DataFormatException dex) {
				throw new FrameworkException(422, dex.getMessage());
			} catch (ConstraintViolationException qex) {
				throw new FrameworkException(422, qex.getMessage());
			}


		} else {

			try {

				return graphDb.createNode(type, labels, properties);

			} catch (DataFormatException dex) {
				throw new FrameworkException(422, dex.getMessage());
			} catch (ConstraintViolationException qex) {
				throw new FrameworkException(422, qex.getMessage());
			}
		}
	}
973057
@Override
    @GraphTransaction
    public void addTrait(List<String> entityGuids, ITypedStruct traitInstance) throws RepositoryException {
        Preconditions.checkNotNull(entityGuids, "entityGuids list cannot be null");
        Preconditions.checkNotNull(traitInstance, "Trait instance cannot be null");

        if (LOG.isDebugEnabled()) {
            LOG.debug("Adding a new trait={} for entities={}", traitInstance.getTypeName(), entityGuids);
        }

        GraphTransactionInterceptor.lockObjectAndReleasePostCommit(entityGuids);
        for (String entityGuid : entityGuids) {
            addTraitImpl(entityGuid, traitInstance);
        }
    }
19434
public void addDependency(org.sonatype.aether.graph.Dependency aetherDep) {
        Artifact artifact = aetherDep.getArtifact();

        Dependency dependency = new Dependency();
        dependency.setGroupId( artifact.getGroupId() );
        dependency.setArtifactId( artifact.getArtifactId() );
        dependency.setType( artifact.getExtension() );
        dependency.setVersion( artifact.getVersion() );
        dependency.setScope( aetherDep.getScope() );
        addDependency( dependency );
    }
768590
private Glyph createComplexMember(PhysicalEntity pe, Glyph container) {
		Glyph g = createGlyphBasics(pe, false);
		container.getGlyph().add(g);

		// A PhysicalEntity may appear in many complexes -- we identify the member using its complex
		g.setId(g.getId() + "_" + ModelUtils.md5hex(container.getId()));
		glyphMap.put(g.getId(), g);

		Set<String> uris =  new HashSet<String>();
		uris.add(pe.getUri());
		sbgn2BPMap.put(g.getId(), uris);

		if("or".equalsIgnoreCase(g.getClazz())) {
			buildGeneric(pe, g, container);
		}

		return g;
	}
149017
@Override
	public void initUpstream()
	{
		for (Controller controller : ctrl.getController())
		{
			if (controller instanceof Pathway) continue;

			PhysicalEntity pe = (PhysicalEntity) controller;
			bindUpstream(pe);
		}

		for (Control control : ctrl.getControlledOf())
		{
			bindUpstream(control);
		}

		for (Process prc : ctrl.getControlled())
		{
			if (prc instanceof Interaction)
			{
				bindUpstream(prc);
			}
		}
	}
689668
private PhysicalEntity getMappedPE(physicalEntityParticipant pep, Model newModel)
	{
		String id = pep2PE.get(pep.getUri());
		physicalEntity pe2er = pep.getPHYSICAL_ENTITY();
		
		if(id == null || pe2er == null)
			throw new IllegalAccessError("Illegal pEP (cannot convert): " 
				+ pep.getUri());
		
		BioPAXElement pe = newModel.getByID(id);
		String inf = "pEP " + pep + " that contains " 
			+ pe2er.getModelInterface().getSimpleName();
		if(!isSimplePhysicalEntity(pe2er)) {
			if(pe == null) {
				if(log.isDebugEnabled())
					log.debug(inf + " gets new ID: " + pe2er.getUri());
				pe = newModel.getByID(pe2er.getUri());
			} else { // error: complex and basic p.entity's pEP 
				throw new IllegalAccessError("Illegal conversion of pEP: " + inf); 
			}
		} else if(pe == null){
			// for a pEP having a simple PE, a new PE should be created
			throw new IllegalAccessError("No PE for: " + inf
					+ " found in the new Model");
		}
		
		return (PhysicalEntity) pe;
	}
1308252
@Override
	public <T> GraphRequest<T> graph(String object, TypeReference<T> type, Param... params) {
		return this.graph(object, mapper.getTypeFactory().constructType(type), params);
	}
1250897
private void addProviderRelationships(DefaultDirectedWeightedGraph<RuleProvider, DefaultEdge> graph)
    {
        linkRulePhases();

        for (RuleProvider provider : providers)
        {
            RuleProvider phaseProvider = getByClass(provider.getMetadata().getPhase());

            List<String> errors = new LinkedList<>();

            for (Class<? extends RuleProvider> clz : provider.getMetadata().getExecuteAfter())
            {
                // add connections to ruleproviders that should execute before this one
                addExecuteAfterRelationship(graph, provider, errors, clz);
            }

            if (phaseProvider != null)
            {
                if (provider.getMetadata().getPhase() != Proxies.unwrap(provider).getClass())
                    addExecuteAfterRelationship(graph, provider, errors, provider.getMetadata().getPhase());

                for (Class<? extends RuleProvider> clz : phaseProvider.getMetadata().getExecuteAfter())
                {
                    addExecuteAfterRelationship(graph, provider, errors, clz);
                }
            }

            for (Class<? extends RuleProvider> clz : provider.getMetadata().getExecuteBefore())
            {
                // add connections to ruleproviders that should execute after this one
                addExecuteBeforeRelationship(graph, provider, errors, clz);
            }

            if (phaseProvider != null)
            {
                for (Class<? extends RuleProvider> clz : phaseProvider.getMetadata().getExecuteBefore())
                {
                    addExecuteBeforeRelationship(graph, provider, errors, clz);
                }
            }

            for (String depID : provider.getMetadata().getExecuteAfterIDs())
            {
                // add connections to ruleproviders that should execute before this one (by String ID)
                RuleProvider otherProvider = getByID(depID);
                if (otherProvider == null)
                {
                    errors.add("RuleProvider " + provider.getMetadata().getID() + " is specified to execute after: "
                                + depID + " but this provider could not be found.");
                }
                else
                    graph.addEdge(otherProvider, provider);
            }

            for (String depID : provider.getMetadata().getExecuteBeforeIDs())
            {
                // add connections to ruleproviders that should execute before this one (by String ID)
                RuleProvider otherProvider = getByID(depID);
                if (otherProvider == null)
                {
                    errors.add("RuleProvider " + provider.getMetadata().getID() + " is specified to execute before: "
                                + depID + " but this provider could not be found.");
                }
                else
                    graph.addEdge(provider, otherProvider);
            }

            if (!errors.isEmpty())
                throw new WindupMultiStringException("Some rules to be executed before or after were not found:", errors);

        }
    }
537459
def end_prov_graph(self):
        
        endTime = Literal(datetime.now())
        self.prov_g.add((self.entity_d, self.prov.generatedAtTime, endTime))
        self.prov_g.add((self.activity, self.prov.endedAtTime, endTime))
1286661
public void bindEip(String eip, String instanceId, String instanceType) {
        this.bindEip(new BindEipRequest().withEip(eip).withInstanceId(instanceId).withInstanceType(instanceType));
    }
241103
private String getSMRID(PhysicalEntity pe)
	{
		if (pe instanceof SmallMolecule)
		{
			EntityReference er = ((SmallMolecule) pe).getEntityReference();
			if (er != null) return er.getUri();
		}
		return null;
	}