/** * Gets mixed array of MeshingOwnNode and *KnownNode objects to send to */ protected function getLocalAndRemoteReceiverNodes(P2POwnNode $node) { // Rewrite the above from the perspective of the local 'to' node $localNodes = P2POwnNodeQuery::create()->joinMeshingTrustLocalRelatedByToOwnNodeId('TrustLocal')->useQuery('TrustLocal')->joinMeshingTrustType()->endUse()->where('TrustLocal.FromOwnNodeId = ?', $node->getId())->where('MeshingTrustType.Name LIKE ?', 'write%')->find(); // Get array of node ids in remote database (we can't join between system and node dbs) $remoteNodeIds = MeshingTrustRemoteQuery::create()->joinMeshingTrustType()->where('MeshingTrustRemote.FromOwnNodeId = ?', $node->getId())->where('MeshingTrustType.Name LIKE ?', 'write%')->select('MeshingTrustRemote.KnownNodeId')->find()->getArrayCopy(); // Initialise remote node models $schemaName = $node->getMeshingSchema()->getName(); Meshing_Utils::initialiseNodeDbs($schemaName); $con = Meshing_Node_Utils::getConnectionForNode($node); // Do select in node database for remote node ids $className = Meshing_Node_Utils::getNodeClassName($schemaName, 'KnownNodeQuery'); /* @var $query JobsKnownNodeQuery */ // (This is just an example - can be of any *KnownNodeQuery class) $query = call_user_func(array($className, 'create'), 'KnownNode'); $remoteNodes = $query->where('KnownNode.Id IN ?', $remoteNodeIds)->find($con); /* @var $localNodes PropelObjectCollection */ /* @var $remoteNodes PropelObjectCollection */ return array_merge($localNodes->getArrayCopy(), $remoteNodes->getArrayCopy()); }
/** * If this collection has already been initialized with * an identical criteria, it returns the collection. * Otherwise if this P2POwnNode is new, it will return * an empty collection; or if this P2POwnNode has previously * been saved, it will retrieve related MeshingTrustRemotesRelatedByInOwnNodeId from storage. * * This method is protected by default in order to keep the public * api reasonable. You can provide public methods for those you * actually need in P2POwnNode. * * @param Criteria $criteria optional Criteria object to narrow the query * @param PropelPDO $con optional connection object * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) * @return PropelCollection|array MeshingTrustRemote[] List of MeshingTrustRemote objects */ public function getMeshingTrustRemotesRelatedByInOwnNodeIdJoinMeshingTrustType($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) { $query = MeshingTrustRemoteQuery::create(null, $criteria); $query->joinWith('MeshingTrustType', $join_behavior); return $this->getMeshingTrustRemotesRelatedByInOwnNodeId($query, $con); }
/** * Removes this object from datastore and sets delete attribute. * * @param PropelPDO $con * @return void * @throws PropelException * @see BaseObject::setDeleted() * @see BaseObject::isDeleted() */ public function delete(PropelPDO $con = null) { if ($this->isDeleted()) { throw new PropelException("This object has already been deleted."); } if ($con === null) { $con = Propel::getConnection(MeshingTrustRemotePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } $con->beginTransaction(); try { $ret = $this->preDelete($con); if ($ret) { MeshingTrustRemoteQuery::create()->filterByPrimaryKey($this->getPrimaryKey())->delete($con); $this->postDelete($con); $con->commit(); $this->setDeleted(true); } else { $con->commit(); } } catch (PropelException $e) { $con->rollBack(); throw $e; } }