Futilities/v0.6/clade/Sys/dba/InReq/DoImport/@removed
Jump to navigation
Jump to search
|
Removed Code
|
2025-07-20
#
// 2025-07-15 old version
public function Describe() : string {
$oScrn = self::Screen();
#echo $this->ReflectThis()->Report();
#echo $this->OAThisInput()->ReflectThis()->Report();
$oaData = $this->OAThisInput();
$osDbSlug = $oaData->QDbConnSlug();
$osScSlug = $oaData->QSchemaSlug();
#echo 'SLUGS: db?['.$osDbSlug->HasIt().'] sch?['.$osScSlug->HasIt().']'.CRLF;
#$this->AmHere();
$doListFiles = FALSE;
// Has a DB Connection been specified?
if ($osDbSlug->HasIt()) {
// Get DB Connection slug for UI display:
$sDbSlug = $osDbSlug->GetIt();
$ftDbSlug = $oScrn->BoldIt($sDbSlug);
echo "DATABASE $ftDbSlug".CRLF;
// Get the DB Connection object:
echo $oSchm->ReflectThis()->Report();
$oDBC = $this->ODbConn();
// Has the Schema been specified?
if ($osScSlug->HasIt()) {
$sScSlug = $osScSlug->GetIt();
$ftScSlug = $oScrn->BoldIt($sScSlug);
$sRtn = "Import schema '$ftScSlug' into the '$ftDbSlug' database"; // TODO 2025-01-26 I think this will need refinement.
} else {
$sRtn = "Import into the '$ftDbSlug' database: can't complete because no schema specified.";
$doListFiles = TRUE;
}
} else {
// no database slug specified
$sRtn = "Import data file to database: no database connection or schema was given.";
$doListFiles = TRUE;
}
if ($doListFiles) {
$sRtn .=
$oScrn->InfoIt('Input needed').": here are the available data files.".CRLF
.$this->RenderFiles(); // ...so the user can see what's available
}
return $sRtn;
}
2025-05-20
#
// 2025-03-24 no longer used
protected function ImportSchema(string $sSchema) {
// Get the Engine object:
$oDB = $this->OEngine();
// Get the Request object to use:
$oRq = $this->NewXferRequest();
$oTplt->Lookup()->QEngine()->SetIt($oDB);
// Long term, we might make the meaning of this value depend on what *else* has already been specified.
// For now, let's just say it's a filename, and the basename should be the name of the schema to write to.
$oTplt = FilePaths::Me()->ImportFoTplt();
$oTplt->Lookup()->QEngine()->SetIt($oDB);
$fp = $oTplt->Render();
$arAwol = $oTplt->Enzyme()->Nucleus()->Missing();
$nAwol = count($arAwol);
if ($nAwol > 0) {
if ($nAwol == 1) {
$sS = '';
$sVerb = 'is';
$sList = $arAwol[0];
} else {
$sS = 's';
$sVerb = 'are';
$sList = '';
$oaAwol = ArrayClass::FromArray($arAwol);
$f = function($val) { return $val; };
$sList = $oaAwol->SerialShowList($f);
}
echo self::CodingPrompt("There $sVerb $nAwol missing template parameter$sS: $sList");
echo "filepath=[$fp] missing#:[$nAwol]".CRLF; die();
}
// Run the request on it:
$oRq->AskEngine($oDB);
}
Not sure when this was commented out:
#
// ++ INPUT ++ //
// This is probably a dead end.
protected function ProcessInput() {
$oScrn = self::Screen();
$oaData = $this->OAThisInput();
$osDbSlug = $oaData->QDbConnSlug();
$osScSlug = $oaData->QSchemaSlug();
// Has a DB Connection been specified?
if ($osDbSlug->HasIt()) {
// Get DB Connection slug for UI display:
$sDbSlug = $osDbSlug->GetIt();
// Has the Schema been specified?
if ($osScSlug->HasIt()) {
$sScSlug = $osScSlug->GetIt();
$ftScSlug = $oScrn->BoldIt($sScSlug);
$sRtn = "Import schema '$ftScSlug' into the '$ftDbSlug' database"; // TODO 2025-01-26 I think this will need refinement.
} else {
$sRtn = "Import into the '$ftDbSlug' database: can't complete because no schema specified.";
$doListFiles = TRUE;
}
} else {
// no database slug specified
$sRtn = "Import data file to database: no database connection or schema was given.";
$doListFiles = TRUE;
}
}
2025-05-19
#
// 2025-03-24 no longer used
protected function ImportUsingMeta(InfoNodeIface $ofMeta) {
$oScrn = self::Screen();
$fsMeta = $ofMeta->Ident()->SpecFull();
#$ofData =
#echo $ofMeta->ReflectThis()->Report(); die();
#echo $ofMeta->InOut()->ReflectThis()->Report(); die();
#echo $ofMeta->Ident()->ReflectThis()->Report(); die();
$oIOMeta = $ofMeta->InOut();
$ofData = $oIOMeta->TargetNode();
$fsData = $ofData->Ident()->SpecFull();
$sSchema = $oIOMeta->SchemaName();
echo $oScrn->InfoIt('Importing from')." $fsData into $sSchema".CRLF;
$oDB = $this->ODbConn();
#echo $o->InOut()->ReflectThis()->Report();
$oSchema = $oDB->GetSchema($sSchema);
#echo $this->OAThisInput()->ReflectThis()->Report();
#echo $this->ReflectThis()->Report();
$oSchema->DoImport($fsData,$this->OAKeptInput()->OkToReplace());
}
2025-03-05
#
/**
* CONDITION: Export was requested without specifying anything (need DB & schema)
* ACTION: check to see if the needed information was set earlier. If it is, then we're ok.
*/
// 2025-03-05 This does not seem to be called by anything anymore.
public function HandleMissing() : void {
$oStat = $this->HowItWent();
echo '8';
// check retained settings
$oSet = $this->OInput(); // RECURSIVE LOOP
echo '9';
$oKept = $oSet->Latest();
echo $oKept->ReflectThis()->Report();
$oMsg = new NoDbaseMsgClass($this);
$oStat->AddMsgObject($oMsg);
$oStat->SetOkay(FALSE);
}
2025-02-10
This (from `ShowFiles()`) is being migrated over to [WFu]Sys\dba\files\cDataFolder:
#
if ($of->Ident()->Exists()) {
$oaDir = $of->InOut()->ContentArray(); // read the dir into an array
$oaExts = $oaDir->IndexByExt(); // index the array by filename extension
$osJS = $oaExts->GetItQ('json');
if ($osJS->HasIt()) {
$arJS = $osJS->GetIt();
$arMeta = [];
foreach ($arJS as $nIdx => $oEntry) {
$fsMeta = $oEntry->Ident()->SpecFull();
$oMeta = InfoNodeClass::FromSpec($fsMeta);
$oMeta->InOut()->Fetch();
$sName = $oMeta->InOut()->TargetFileName();
$arMeta[$sName] = $oMeta;
}
} else {
$arJS = [];
}
// TODO 2025-01-27: use data-migration enum as basis for orphaned-file-extension list
// (...that is, data files which don't have an associated .json index file)
$osSQ = $oaExts->GetItQ('sql');
if ($osSQ->HasIt()) {
$arSQ = $osSQ->GetIt();
foreach ($arSQ as $nIdx => $oEntry) {
$fsTarg = $oEntry->Ident()->SpecFull();
$oMeta = InfoNodeClass::FromTargetSpec($fsTarg);
$sName = $oMeta->InOut()->TargetFileName();
if (array_key_exists($sName,$arMeta)) {
$oMeta = $arMeta[$sName];
} else {
// JSON-meta file not found; create object...
$arMeta[$sName] = $oMeta;
// ...and save data:
$oMeta->InOut()->DatabaseSlug($this->OEngine()->ObjectSlug());
$oMeta->InOut()->Store();
}
}
} else {
$arSQ = [];
}
if (isset($arMeta) > 0) {
$oaNodes = NodesClass::FromArray($arMeta);
echo "Listing for import folder $ffp:".CRLF;
echo $oaNodes->Viewer()->RenderAsTable();
} else {
echo "No importable files found in $ffp.".CRLF;
}
} else {
self::GotToHere();
echo "Can't access import folder $ffp. Does it exist?".CRLF;
}
2025-01-30
#
/**
* PURPOSE: handles when a value is not given, even though the UI definition says one is required
* EXPECTED: schema to be imported, and dbase to import it into
* Currently using the format {dbase}/{schema}, though maybe it should be {dbase}:{schema}
* INSTAR: show a list of available files
*/
// 2025-01-26 I don't think these are used anymore.
protected function InChker_ReqValue() : void {
echo 'TODO: show file-list here.'.CRLF;
}
protected function UseDbase(string $s) {
$oaDBs = $this->DbaseListArray();
$ok = array_key_exists($oaDBs,$s);
if ($ok) {
$oDB = $oaDBs[$s];
echo 'OBJECT TYPE: '.gettype($oDB).CRLF;
} else {
echo "INPUT ERROR: Database '$s' isn't known.".CRLF;
}
}
protected function UseSchema(string $s) {
self::GotToHere('SCHEMA ACCESS: TO BE WRITTEN');
}
2025-01-26
This functionality is being reworked into a separate input-checker class:
#
// TODO: *actually* check $sValue to see if it matches known entities
protected function InChker_IsValueOk(string $sValue) : bool {
echo "VALUE: [$sValue]".CRLF;
$arPcs = explode('/',$sValue); // 2025-01-22 This is a bit of a kluge
$nPcs = count($arPcs);
switch($nPcs) {
case 0:
$ok = FALSE;
echo 'Indicate what and where to import like this: "write:{db name}/{schema name}".'.CRLF;
break;
case 1:
$sDB = $arPcs[0];
echo 'Indicate which file to import like this: "write:'.$sDB.'/{schema name}".'.CRLF;
$ok = FALSE;
break;
default: // 2 or more
[$sDbase,$sSchema] = $arPcs;
$this->UseDbase($sDbase);
$this->UseSchema($sSchema);
$ok = TRUE; // ...if we don't error out before this
break;
}
return $ok;
}