/** * Add a conflict to the tank_source * * @param TankSource $tsrc * @param string $field * @param mixed $oldval * @param mixed $newval */ protected function disc_add_conflict($tsrc, $field, $oldval, $newval) { $tsrc->add_conflict('Fact.' . $this->sf_fact_id, $field, 'Conflicting tank value'); }
/** * Attempt to fetch conflict-with existing record from database * * @param type $key * @param type $confl * @return type */ private function _get_with($key, $confl) { $mname = TankSource::get_model_for($key); if ($mname && isset($confl['uuid'])) { if ($mname != 'SrcFact') { $rec = AIR2_Record::find($mname, $confl['uuid']); if ($rec) { $data = $rec->toArray(); air2_clean_radix($data); return $data; } } else { // facts suck ... src_id.fact_id ... use raw sql for speed! $ids = explode('.', $confl['uuid']); if ($ids && count($ids) == 2) { $conn = AIR2_DBManager::get_connection(); $s = 'f.fact_id, f.fact_name, f.fact_identifier, f.fact_fv_type, ' . 'afv.fv_value as analyst_fv, sfv.fv_value as source_fv, ' . 'sf.sf_src_value as source_text, sf.sf_lock_flag'; $f = 'src_fact sf join fact f on (sf.sf_fact_id=f.fact_id) left ' . 'join fact_value afv on (sf.sf_fv_id=afv.fv_id) left join ' . 'fact_value sfv on (sf.sf_src_fv_id=sfv.fv_id)'; $w = 'sf_src_id=? and sf_fact_id=?'; $rs = $conn->fetchRow("select {$s} from {$f} where {$w}", array($ids[0], $ids[1])); if ($rs) { return $rs; } } } } return false; }
/** * Move tank_response_set records into src_response_set. * * @param array $data TankResponseSet data * @param integer $src_id * @param TankSource $tsrc */ protected function move_tank_response_set($data, $src_id, $tsrc) { // get array data from the tank_response_set $data['SrcResponse'] = $data['TankResponse']; // create a new response set $new_resp = new SrcResponseSet(); $new_resp->fromArray($data, true); //deep // add the source id's $new_resp->srs_src_id = $src_id; foreach ($new_resp->SrcResponse as $r) { $r->sr_src_id = $src_id; } try { $new_resp->save(); } catch (Exception $e) { $msg = $e->getMessage(); $tsrc->add_error("FATAL ERROR creating Source Responses - {$msg}"); } // cleanup $new_resp->free(true); }
/** * Add a conflict to the tank_source * * @param TankSource $tsrc * @param string $field * @param mixed $oldval * @param mixed $newval */ protected function disc_add_conflict($tsrc, $field, $oldval, $newval) { $cls = $this->getTable()->getClassnameToReturn(); $uuidcol = air2_get_model_uuid_col($cls); $uuid = $this->{$uuidcol}; $tsrc->add_conflict($cls, $field, 'Conflicting tank value', $uuid); }