/** * Compares two models. * * @param $thisModel First Model. * @param $thatModel Second Model. * * @return boolean */ function compare($thisModel, $thatModel) { $thisModeltriples = null; $thatModeltriples = null; if (is_a($thisModel, "DbModel")) { $thisModeltriples = $thisModel->getMemModel(); } else { $thisModeltriples = $thisModel; } if (is_a($thatModel, "DbModel")) { $thatModeltriples = $thatModel->getMemModel(); } else { $thatModeltriples = $thatModel; } $sortArray1 = ModelComparator::buildSortArray($thisModeltriples->triples); $sortArray2 = ModelComparator::buildSortArray($thatModeltriples->triples); $renamedArray1 = ModelComparator::renameBlanks($sortArray1); $renamedArray2 = ModelComparator::renameBlanks($sortArray2); return ModelComparator::compareTriples($renamedArray1, $renamedArray2); }
/** * Check if two models are equal. * Two models are equal if and only if the two RDF graphs they represent are isomorphic. * * Warning: This method doesn't work correct with models where the same blank node has different * identifiers in the two models. We will correct this in a future version. * * @param object model &$that * @return boolean * @throws PhpError * @access public */ function equals(&$that) { if (!is_a($that, 'Model')) { $errmsg = RDFAPI_ERROR . '(class: DbModel; method: equals): Model expected.'; trigger_error($errmsg, E_USER_ERROR); } if ($this->size() != $that->size()) { return FALSE; } include_once RDFAPI_INCLUDE_DIR . "util/ModelComparator.php"; return ModelComparator::compare($this, $that); }