/** Copy this defined meaning to specified dataset-context * Warning: This is somewhat new code, which still needs * shoring up. * @param $dataset dataset to copy to. * @returns defined meaning id in the new dataset */ public function copyTo( $dataset ) { # $definedMeaningID=$this->getId(); echo "copy to:$dataset "; # $from_dc=$this->getDataset(); $to_dc = $dataset; # TODO We should actually thoroughly check that everything # is present before proceding, and throw some exceptions # if not. global $wdCurrentContext; $concept_map = array(); # while we're here, let's map the concepts. $from_dc = $this->getDataSet(); $oldId = $this->getId(); $concept_map["$from_dc"] = $oldId; $wdCurrentContext = $to_dc; # set global override (DIRTY!) $newDefinedMeaningId = $this->saveWithinTransaction(); $concept_map["$to_dc"] = $newDefinedMeaningId; $wdCurrentContext = null; # unset override, we probably should # use proper OO for this. createConceptMapping( $concept_map ); }
/** utility function, maps bootstrapped defined meanings across multiple datasets. * @param $key_dataset: any dataset which has a known-good bootstrap table. We assume all others are the same. * @param $datasets: an array with the datasets to map (eg: array("uw", "sp", "umls") ). */ public static function map_bootstraps( $key_dataset, $datasets ) { $bootstrap_raw = CopyTools::getRows( $key_dataset, "bootstrapped_defined_meanings", "" ); $bootstrap = CopyTools::_table_to_assoc( $bootstrap_raw, "name", "defined_meaning_id" ); # only use the keys from the key dataset :-P foreach ( $bootstrap as $name => $dmid_ignored ) { $concepts = array(); foreach ( $datasets as $dataset ) { $other_bootstrap_raw = CopyTools::getRows( $dataset, "bootstrapped_defined_meanings", "" ); $other_bootstrap = CopyTools::_table_to_assoc( $other_bootstrap_raw, "name", "defined_meaning_id" ); $concepts[$dataset] = $other_bootstrap[$name]; } createConceptMapping( $concepts ); } }
protected function insert() { global $wgRequest, $wgOut; # $wgRequest->getText( 'page' ); $sets = wdGetDataSets(); # $requests=$wgRequest->getValues(); $wgOut->addWikiText( "<h2>" . wfMsgSc( "will_insert" ) . "</h2>" ); $map = array(); foreach ( $sets as $key => $set ) { $dc = $set->getPrefix(); $dm_id = $wgRequest->getText( $dc ); $name = $set->fetchName(); $dm_id_ui = $dm_id; # Only for teh purdy if ( $dm_id_ui == null ) $dm_id_ui = "unset"; $wgOut->addWikiText( "$name ->$dm_id_ui" ); $map[$dc] = $dm_id; # $dbr=&wfGetDB(DB_MASTER); } createConceptMapping( $map ); }