/**
  * Calculated data matching ratios for all links in a relationship specified by rel_id. The computation is done in a background.
  * While computing the ratios distinct values from stories involved in the relationship might be cached in MSSQL server. The caching happens only if two stories are form 
  * different locations (e.g. different DBMS and server).
  * 
  * @param  [type] $rel_ids colfusion relationship id for which to calculate links data matching rations.
  * @return [type]          [description]
  */
 public function calculateDataMatchingRatios($rel_ids)
 {
     //var_dump($rel_ids);
     if (!isset($rel_ids) || count($rel_ids) == 0) {
         return;
     }
     $relationshipDAO = new RelationshipDAO();
     foreach ($rel_ids as $key => $rel_id) {
         $rel = $relationshipDAO->getRelationship($rel_id);
         //this might too expensive, I don't need all infor about relationships, just sids, tablemes and links
         foreach ($rel->links as $key => $link) {
             $from = new DataMatcherLinkOnePart();
             $from->sid = $rel->fromDataset->sid;
             $from->tableName = $rel->fromTableName;
             $from->transformation = $link->fromPartEncoded;
             $to = new DataMatcherLinkOnePart();
             $to->sid = $rel->toDataset->sid;
             $to->tableName = $rel->toTableName;
             $to->transformation = $link->toPartEncoded;
             //var_dump($from, $to);
             ExecutionManager::callChildProcessToCacheDistinctColumnValues($from, $to);
         }
     }
 }
function testRelDAO()
{
    $datasetFinder = new DatasetFinder();
    //var_dump($datasetFinder->findDatasetInfoBySid(1495));
    //var_dump($datasetFinder->findDatasetInfoBySid(1487));
    $relDAO = new RelationshipDAO();
    var_dump($relDAO->getRelationship(752));
    //var_dump($relDAO->getComments(1454));
    //var_dump($relDAO->getComment(1462, 20));
    //var_dump($relDAO->updateComment(1462, 20, 0.7, 'Test update'));
}
 /**
  * Add neo4j relationship and nodes if needed by colfusion relationship id.
  * @param [type] $rel_id colfusion relationships id.
  */
 public function addRelationshipByRelId($rel_id)
 {
     $relationshipDao = new RelationshipDAO();
     $relationship = $relationshipDao->getRelationship($rel_id);
     //var_dump($relationship);
     $confidence = $relationshipDao->getRelationshipAverageConfidenceByRelId($rel_id);
     $this->addRelationship($relationship->fromDataset->sid, $relationship->toDataset->sid, $rel_id, 1 - $confidence);
 }
<?php

require_once realpath(dirname(__FILE__)) . '/../config.php';
require_once realpath(dirname(__FILE__)) . '/../DAL/RelationshipDAO.php';
$relId = $_POST['relId'];
$simThreshold = $_POST['simThreshold'];
$userName = $current_user->user_login;
$relationshipDAO = new RelationshipDAO();
try {
    $relationship = $relationshipDAO->getRelationship($relId, $simThreshold);
    $relationship->isOwned = $relationship->creator == $userName;
    $relationship->simThreshold = $simThreshold;
    echo json_encode($relationship);
} catch (Exception $e) {
    die($e->getMessage());
}