Futilities/v0.6/clade/Sys/dba/files/DataFolder/@fx/PairCheck: Difference between revisions
< Futilities | v0.6 | clade | Sys | dba | files/DataFolder
Jump to navigation
Jump to search
m (Woozle moved page Futilities/v0.6/Sys/dba/files/DataFolder/@fx/IndexIt to Futilities/v0.6/clade/Sys/dba/files/DataFolder/@fx/IndexIt without leaving a redirect: improper naming) |
No edit summary |
||
| (5 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
{{fmt/title|<code>[[../../|DataFolder]]::PairCheck()</code>}} | |||
==About== | |||
* '''General docs''': {{l/ver/fx|PairCheck}} | |||
* '''Note''': the core function of indexing-by-ext is in <code>$oaDir->{{l/ver/fx|IndexByExt}}()</code>. | |||
==Status== | ==Status== | ||
* '''{{fmt/date|2025|01|27}}''' {{hashtag|TODO}}: use data-migration enum as basis for orphaned-file-extension list (in the <code>QryIt('sql')</code> section) | * '''{{fmt/date|2025|01|27}}''' {{hashtag|TODO}}: use data-migration enum as basis for orphaned-file-extension list (in the <code>QryIt('sql')</code> section) | ||
** (...that is, data files which don't have an associated .json index file) | ** (...that is, data files which don't have an associated .json index file) | ||
* '''{{fmt/date|2025|11|02}}''' renamed from <code>IndexIt()</code> ⇒ <code>PairCheck()</code> | |||
==Code== | ==Code== | ||
''as of {{fmt/date|2025|11| | ''as of {{fmt/date|2025|11|11}} (including some debug code)'' | ||
{{fmt/php/block|1= | {{fmt/php/block|1= | ||
public function | public function PairCheck() : StatusIface { | ||
$oStat = new StatusClass; | $oStat = new StatusClass; | ||
$this->AmHere( | $this->AmHere(); | ||
if ($this->Ident()->Exists()) { | if ($this->Ident()->Exists()) { | ||
$oaDir = $this->InOut()->ContentArray(); // read the dir into an array | $oaDir = $this->InOut()->ContentArray(); // read the dir into an array | ||
$oaExts = $oaDir->IndexByExt(); // index the array by filename extension | $oaExts = $oaDir->IndexByExt(); // index the array by filename extension | ||
$osJS = $oaExts->QryIt('json'); | $osJS = $oaExts->QryIt('json'); | ||
#echo '## $oaExts is: '.get_class($oaExts).CRLF; | |||
$arJSNames = $this->NamesArrayFromQArray($osJS); | |||
// First, look at all the .sql files: | |||
// | |||
$osSQ = $oaExts->QryIt('sql'); | $osSQ = $oaExts->QryIt('sql'); | ||
if ($osSQ->HasIt()) { // if | if ($osSQ->HasIt()) { // if any were found -- | ||
$arSQ = $osSQ->GetIt(); // get the list | $this->AmHere(); | ||
$arSQ = $osSQ->GetIt(); // get the list | |||
foreach ($arSQ as $nIdx => $oEntry) { | foreach ($arSQ as $nIdx => $oEntry) { | ||
// for each .sql file: | // for each .sql file, create a MetaPair object: | ||
$ | $fsData = $oEntry->Ident()->SpecFull(); | ||
$ | $this->AmHere("fsData=[$fsData]"); | ||
$oPair = $this->MetaPairClass()::FromDataSpec($fsData); | |||
$oData = $oPair->DataFile(); | |||
$oMeta = $oPair->MetaFile(); | |||
$oMetaIO = $oMeta->InOut(); | $oMetaIO = $oMeta->InOut(); | ||
$oMetaIO->DataFormat('SQL'); // TODO: should be tied to enum | $oaMeta = $oMetaIO->OAData(); | ||
$sName = $ | $oaMeta->DataFormat('SQL'); // TODO: should be tied to enum or clade-const | ||
if (array_key_exists($sName,$ | $sName = $oaMeta->QSFileName()->GetIt(); | ||
#$sName2 = $oData->SpecFull(); | |||
#$this->AmHere("NAME1: [$sName] NAME2: [$sName2]"); die(); | |||
if (array_key_exists($sName,$arJSNames)) { | |||
// There's already a .json metafile for this .sql: | // There's already a .json metafile for this .sql: | ||
$oMeta = $ | $oMeta = $arJSNames[$sName]; | ||
} else { | } else { | ||
// JSON-meta file not found; create object... | // JSON-meta file not found; create object... | ||
$ | $arJSNames[$sName] = $oMeta; | ||
// ...and save data: | // ...and save data: | ||
$oMetaIO->OAData()->Store(); // create/populate the meta file | $oMetaIO->OAData()->Store(); // create/populate the meta file | ||
} | } | ||
} | } | ||
$oStat->SetOkay(TRUE); | $oStat->SetOkay(TRUE); | ||
} | } | ||
} else { | } else { | ||
$this->AmHere(); | |||
$oStat->SetOkay(FALSE); | |||
// 2025-02-10 This method will need some rewriting. | |||
$ffp = $this->Ident()->SpecFull(); | |||
$oStat->AddMsgString("Can't access import folder $ffp. Does it exist?"); | |||
} | } | ||
return $oStat; | return $oStat; | ||
} | } | ||
}} | }} | ||
Latest revision as of 02:42, 12 November 2025
DataFolder::PairCheck() |
About
- General docs: PairCheck
- Note: the core function of indexing-by-ext is in
$oaDir->IndexByExt().
Status
- 2025-01-27 #TODO: use data-migration enum as basis for orphaned-file-extension list (in the
QryIt('sql')section)- (...that is, data files which don't have an associated .json index file)
- 2025-11-02 renamed from
IndexIt()⇒PairCheck()
Code
as of 2025-11-11 (including some debug code)
public function PairCheck() : StatusIface {
$oStat = new StatusClass;
$this->AmHere();
if ($this->Ident()->Exists()) {
$oaDir = $this->InOut()->ContentArray(); // read the dir into an array
$oaExts = $oaDir->IndexByExt(); // index the array by filename extension
$osJS = $oaExts->QryIt('json');
#echo '## $oaExts is: '.get_class($oaExts).CRLF;
$arJSNames = $this->NamesArrayFromQArray($osJS);
// First, look at all the .sql files:
$osSQ = $oaExts->QryIt('sql');
if ($osSQ->HasIt()) { // if any were found --
$this->AmHere();
$arSQ = $osSQ->GetIt(); // get the list
foreach ($arSQ as $nIdx => $oEntry) {
// for each .sql file, create a MetaPair object:
$fsData = $oEntry->Ident()->SpecFull();
$this->AmHere("fsData=[$fsData]");
$oPair = $this->MetaPairClass()::FromDataSpec($fsData);
$oData = $oPair->DataFile();
$oMeta = $oPair->MetaFile();
$oMetaIO = $oMeta->InOut();
$oaMeta = $oMetaIO->OAData();
$oaMeta->DataFormat('SQL'); // TODO: should be tied to enum or clade-const
$sName = $oaMeta->QSFileName()->GetIt();
#$sName2 = $oData->SpecFull();
#$this->AmHere("NAME1: [$sName] NAME2: [$sName2]"); die();
if (array_key_exists($sName,$arJSNames)) {
// There's already a .json metafile for this .sql:
$oMeta = $arJSNames[$sName];
} else {
// JSON-meta file not found; create object...
$arJSNames[$sName] = $oMeta;
// ...and save data:
$oMetaIO->OAData()->Store(); // create/populate the meta file
}
}
$oStat->SetOkay(TRUE);
}
} else {
$this->AmHere();
$oStat->SetOkay(FALSE);
// 2025-02-10 This method will need some rewriting.
$ffp = $this->Ident()->SpecFull();
$oStat->AddMsgString("Can't access import folder $ffp. Does it exist?");
}
return $oStat;
}