src/wcmf/lib/model/NodeUtil.php
public static function getRelationQueryCondition($node, $otherRole) {
    $mapper = $node->getMapper();
    $relationDescription = $mapper->getRelation($otherRole);
    $otherType = $relationDescription->getOtherType();

    $query = new ObjectQuery($otherType, __CLASS__.__METHOD__.$node->getType().$otherRole);
    // add the primary keys of the node
    // using the role name as alias (avoids ambiguous paths)
    $nodeTpl = $query->getObjectTemplate($node->getType(), $relationDescription->getThisRole());
    $oid = $node->getOID();
    $ids = $oid->getId();
    $i = 0;
    foreach ($mapper->getPkNames() as $pkName) {
      $nodeTpl->setValue($pkName, Criteria::asValue("=", $ids[$i++]));
    }
    // add the other type in the given relation
    $otherTpl = $query->getObjectTemplate($otherType);
    $nodeTpl->addNode($otherTpl, $otherRole);
    $condition = $query->getQueryCondition();
    // prevent selecting all objects, if the condition is empty
    if (strlen($condition) == 0) {
      $condition = 0;
    }
    return $condition;
  }
public static function getRelationQueryCondition($node, $otherRole) {
    $mapper = $node->getMapper();
    $relationDescription = $mapper->getRelation($otherRole);
    $otherType = $relationDescription->getOtherType();

    $query = new ObjectQuery($otherType, __CLASS__.__METHOD__.$node->getType().$otherRole);
    // add the primary keys of the node
    // using the role name as alias (avoids ambiguous paths)
    $nodeTpl = $query->getObjectTemplate($node->getType(), $relationDescription->getThisRole());
    $oid = $node->getOID();
    $ids = $oid->getId();
    $i = 0;
    foreach ($mapper->getPkNames() as $pkName) {
      $nodeTpl->setValue($pkName, Criteria::asValue("=", $ids[$i++]));
    }
    // add the other type in the given relation
    $otherTpl = $query->getObjectTemplate($otherType);
    $nodeTpl->addNode($otherTpl, $otherRole);
    $condition = $query->getQueryCondition();
    // prevent selecting all objects, if the condition is empty
    if (strlen($condition) == 0) {
      $condition = 0;
    }
    return $condition;
  }
public static function getRelationQueryCondition ( $ node , $ otherRole ) { $ mapper = $ node -> getMapper ( ) ; $ relationDescription = $ mapper -> getRelation ( $ otherRole ) ; $ otherType = $ relationDescription -> getOtherType ( ) ; $ query = new ObjectQuery ( $ otherType , __CLASS__ . __METHOD__ . $ node -> getType ( ) . $ otherRole ) ; // add the primary keys of the node // using the role name as alias (avoids ambiguous paths) $ nodeTpl = $ query -> getObjectTemplate ( $ node -> getType ( ) , $ relationDescription -> getThisRole ( ) ) ; $ oid = $ node -> getOID ( ) ; $ ids = $ oid -> getId ( ) ; $ i = 0 ; foreach ( $ mapper -> getPkNames ( ) as $ pkName ) { $ nodeTpl -> setValue ( $ pkName , Criteria :: asValue ( "=" , $ ids [ $ i ++ ] ) ) ; } // add the other type in the given relation $ otherTpl = $ query -> getObjectTemplate ( $ otherType ) ; $ nodeTpl -> addNode ( $ otherTpl , $ otherRole ) ; $ condition = $ query -> getQueryCondition ( ) ; // prevent selecting all objects, if the condition is empty if ( strlen ( $ condition ) == 0 ) { $ condition = 0 ; } return $ condition ; }
Get the query condition used to select all related Nodes of a given role.
@param $node The Node to select the relatives for
@param $otherRole The role of the other nodes
@return The condition string to be used with StringQuery.
Get the query condition used to select all related Nodes of a given role .