private function cacheDistinctValues()
 {
     $queryToCleanCach = $this->prepareQueryToCleanCacheDistinctValues();
     $queryToCach = $this->prepareQueryToCacheDistinctValues();
     $dbHandler = DatabaseHandlerFactory::createDatabaseHandler("mssql", MSSQL_CQS_DB_USER, MSSQL_CQS_DB_PASSWORD, MSSQL_RC_DB_DATABASE, MSSQL_CQS_DB_HOST, MSSQL_CQS_DB_PORT, null, null);
     //var_dump($queryToCleanCach, $queryToCach, $dbHandler);
     $dataMatchingCheckerDAO = new DataMatchingCheckerDAO();
     try {
         $dataMatchingCheckerDAO->setQueryRelationshipColumnCaching($this->source->transformation, $queryToCleanCach);
         $dbHandler->ExecuteNonQuery($queryToCleanCach);
         $dataMatchingCheckerDAO->setQueryRelationshipColumnCaching($this->source->transformation, $queryToCach);
         $dbHandler->ExecuteNonQuery($queryToCach);
         $dataMatchingCheckerDAO->setSuccessRelationshipColumnCaching($this->source->transformation);
     } catch (Exception $e) {
         $dataMatchingCheckerDAO->setFailureRelationshipColumnCaching($this->source->transformation, $e->getMessage());
     }
 }
 public function storeRatiosInDB($dataMatchingFromRatio, $dataMatchingToRatio)
 {
     $dataMatchingCheckerDAO = new DataMatchingCheckerDAO();
     $dataMatchingCheckerDAO->storeDataMatchingRatios($this->from->transformation, $dataMatchingFromRatio, $this->to->transformation, $dataMatchingToRatio);
     //var_dump($this->from->transformation, $this->to->transformation);
     //     	$relationshipDAO = new RelationshipDAO();
     //     	$res = $relationshipDAO->getRelIdByTransformations($this->from->transformation, $this->to->transformation);
     //     	$rel_id = $res->rel_id;
     //     	$rel = $relationshipDAO->getRelationship($rel_id);
     // //var_dump($rel_id, $rel);
     //     	if (isset($rel)) {
     //     		if ($rel->creator == "ColfusionAgent") {
     //                 $avgOfDataMatchingRatiosOfSides = $relationshipDAO->getRelationshipAverageDataMatchingRatios($rel_id);
     //     			$relationshipDAO->updateComment($rel_id, $rel->creatorId, max($avgOfDataMatchingRatiosOfSides->avgFrom, $avgOfDataMatchingRatiosOfSides->avgTo), "Based on data matching ratio");
     //     			$avgConfidence = $relationshipDAO->getRelationshipAverageConfidenceByRelId($rel_id);
     // 	    		$n4jDao = new Neo4JDAO();
     // 	    		$n4jDao->updateCostByRelId($rel_id, 1 - $avgConfidence);
     //     		}
     //     	}
 }
<?php

require_once realpath(dirname(__FILE__)) . '/../config.php';
require_once realpath(dirname(__FILE__)) . '/../DAL/DataMatchingCheckerDAO.php';
if (!$current_user->authenticated) {
    die('Please login to use this function.');
}
$userId = $current_user->user_id;
$fromSid = $_POST['fromSid'];
$fromTableName = $_POST['fromTableName'];
$fromTransInput = $_POST['fromTransInput'];
$toSid = $_POST['toSid'];
$toTableName = $_POST['toTableName'];
$toTransInput = $_POST['toTransInput'];
$dao = new DataMatchingCheckerDAO();
$synonyms = $dao->getLinkSynonyms($fromSid, $fromTableName, $fromTransInput, $toSid, $toTableName, $toTransInput);
$synonyms = $synonyms == null ? array() : $synonyms;
foreach ($synonyms as $synonym) {
    $synonym->isOwned = $synonym->userId == $userId;
}
echo json_encode($synonyms);
 public function GetCondisionsByRelationship($relationship)
 {
     $relstionshipDAO = new RelationshipDAO();
     $links = $relstionshipDAO->GetLinksByRelId($relationship->relId, 1);
     $conditionsArr = array();
     $dataMatchingCheckerDAO = new DataMatchingCheckerDAO();
     foreach ($links as $key => $link) {
         if (isset($relationship->selectedLinks)) {
             //no selected property might be setup because, in case we just use all links
             $shouldBeIncluded = $this->isLinkSelected($link, $relationship->selectedLinks);
             if (!$shouldBeIncluded) {
                 continue;
             }
         }
         $condition = " [{$relationship->sidFrom->tableName}{$relationship->sidFrom->sid}].[{$link->fromPart}] = [{$relationship->sidTo->tableName}{$relationship->sidTo->sid}].[{$link->toPart}] ";
         $encodeToDecodeMap = array($link->fromPartEncoded => $link->fromPart, $link->toPartEncoded => $link->toPart);
         $synonums = $dataMatchingCheckerDAO->getSynonymnsByCids($link->fromPartEncoded, $link->toPartEncoded);
         if (isset($synonums) && count($synonums) > 0) {
             $synCondArr = array();
             foreach ($synonums as $key => $syn) {
                 $synStr = " ( [{$relationship->sidFrom->tableName}{$relationship->sidFrom->sid}].[{$encodeToDecodeMap[$syn->linkFrom]}] = '{$syn->valueFrom}' AND [{$relationship->sidTo->tableName}{$relationship->sidTo->sid}].[{$encodeToDecodeMap[$syn->linkTo]}] = '{$syn->valueTo}' ) ";
                 $synCondArr[] = $synStr;
             }
             $synCond = implode(" OR ", $synCondArr);
             $conditionsArr[] = "( {$condition} OR {$synCond} )";
         } else {
             $conditionsArr[] = "( {$condition} )";
         }
     }
     return implode(" and ", $conditionsArr);
 }
예제 #5
0
<?php

require_once realpath(dirname(__FILE__)) . '/../config.php';
require_once realpath(dirname(__FILE__)) . '/../DAL/DataMatchingCheckerDAO.php';
if (!$current_user->authenticated) {
    die('Please login to use this function.');
}
$userId = $current_user->user_id;
$sidFrom = $_POST["sidFrom"];
$sidTo = $_POST["sidTo"];
$tableFrom = $_POST["tableFrom"];
$tableTo = $_POST["tableTo"];
$fromTransInput = $_POST["fromTransInput"];
$toTransInput = $_POST["toTransInput"];
$synFrom = $_POST["synFrom"];
$synTo = $_POST["synTo"];
$dao = new DataMatchingCheckerDAO();
try {
    $dao->storeSynonym($sidFrom, $tableFrom, $fromTransInput, $synFrom, $sidTo, $tableTo, $toTransInput, $synTo, $userId);
    //TODO: need to update data matching ratios in db in neo4j.
    $jsonResult["isSuccessful"] = true;
} catch (SynonymExistedException $e) {
    $jsonResult["isSuccessful"] = false;
    $jsonResult["message"] = $e->getMessage();
} catch (ValueNotFoundException $e) {
    $jsonResult["isSuccessful"] = false;
    $jsonResult["message"] = $e->getMessage();
} catch (Exception $e) {
    $jsonResult["isSuccessful"] = false;
}
echo json_encode($jsonResult);
<?php

require_once realpath(dirname(__FILE__)) . '/../config.php';
require_once realpath(dirname(__FILE__)) . '/../DAL/DataMatchingCheckerDAO.php';
if (!$current_user->authenticated) {
    die('Please login to use this function.');
}
$userId = $current_user->user_id;
$synId = $_POST['synId'];
try {
    $dao = new DataMatchingCheckerDAO();
    $dao->deleteSynonym($synId, $userId);
    $jsonResult["isSuccessful"] = true;
} catch (Exception $e) {
    $jsonResult["isSuccessful"] = false;
    $jsonResult["message"] = $e->getMessage();
}
echo json_encode($jsonResult);