Read/Load DB Tools file (for editing)

@emre I have been thinking for a very long time it would help in a HUGE way if we could load/read a DB Tools export and display it for review, additions, changes, etc, then Save it back to file.

Can you give us another button to do that? Would also help people to see exactly what they are about to Import into their DB beforehand.

1 Like

Like editing it in notepad?

You know how it shows the YAML output in configuration task when you Build Yaml? Maybe something like that… a way to see it like YAML. I know its not saved as YAML but something to visually see it before committing maybe.

Such transformation (XML > Editable and Editable > XML) needs a lot of development. I can’t promise a quick solution but I have some plans to improve YAML format for partial imports (like updating a single custom data of all entities). While doing that I can also look that.

No, I mean to display the loaded file in the dialog for review, changes, and ability to save it again. I don’t want to edit a TXT/YAML/XML file by hand.

This dialog…

1 Like

Oh you mean to load the file on export screen? Hmm…

Here is the scenario that I struggle with all the time:

  • Build a cool solution that uses multiple elements like Automation, Reports, etc.

  • Create DB Tools Export TXT file.

  • (later) Add something to the cool solution (sometimes much later).

  • Load the old DB Tools TXT file into the dialog.

  • Using the dialog:

  • add another element

  • remove an already selected element

  • even if we need to de-select and re-select every already-selected element to make it work easier, that would be ok (for now), because we can already see what is selected.

  • Export/Save the DB Tools TXT file

1 Like

Oh yes I also needed that a lot.

3 Likes

See I need it today for GQL-Modules. I created a bunch of Exports, and today I changed some of the HUB Rules (maybe 2 out of 13-ish, and maybe I added a Rule, or whatever, I don’t remember), and now I need to re-create the Exports.

But which ones? And what did I select for Export last time? Will I miss something this time? Probably… :wink: So it would be so much easier and less error-prone if we had this.

I mean, I forget what is in the Exports already, and I just made them 2 days ago. And even then if I miss something and I notice it, then I need to re-make it on the spot again, and again, and again… tedious and subject to missing something again and again.

1 Like

When I think about that we should have some additional data in export file to be able to restore a previous export. I’ll add that to todo list. I hope I can find a quick solution.

2 Likes

I hope so too :wink:

I need a JSON parser here LOL, but having a dialog to do this would be soooo much better… how hard could it be? LOL

Trying to compare 2 Exports here … um, NO :stuck_out_tongue_winking_eye:

I have been using config tasks for all of my stuff lately. You can use them virtually the same as DB Tasks with exception you get a NICE YAML view of your export.

its actually fairly easy to manually edit them this way as well.

I just export the single config task…

1 Like

I do enough typing already! :wink:

1 Like

I agree but I have found myself doing this lol it seemed easier for me a few times vs having to go through selecting everything again and making sure I didn’t forget something.

1 Like

I’m still.trying to figure out how to create repo 's for config tasks so I can load them whenever I need them on any site.

Better than nothing …

2 Likes

Yes, also had similar problems with modular partitioning of automation sets and keeping track of changss. In our case we are 2 people making changes to 2 different versions of the system in different areas. While I’m updating rules and possibly breaking things, a colleague is running tests and making small changes.

My plan was to simply merge the new automation into the other db with Import/Export. But alas, there are various scenarios which cause the import to break, and last time it took me hours to merge. Looks like Import needs some work.

After getting everything working smoothly after many hours work, it is disheartening to get see the error “Sequence contains more than one element” at which point I suspect the neighbors are wondering what’s going on next door. Sounds exciting but not.

QMcKay I would love to use your new extension to the phpApp to at least review prior to import!

It seems the best would be to use Configuration tasks as Kendash suggests, because I often rename rules for clarity and organization and after transfer end up with a load of rule duplicates and need to manually go through and delete them.

It would be much cleaner to delete everything In a “module” name space by matching a token or prefix, then import the replacements.

To avoid conflicts between function modules I have been using cloned tasks with module prefixes instead of using generic tasks even when they are currently identical. It’s an attempt to create independence where possible, but so far it didn’t help much because of so many import errors. I mean it still takes too long to sort it all out!

This is code for reading and parsing DB Tools files. Basic. Could use some work :wink:

dbops_readdbtoolsfile.php

<?php
// *******************************************************
// READ DB Tools File
// *******************************************************


// Read $myDBToolsFile

$cr = 1;

$fhandle = fopen("$myDBToolsFolder"."$myDBToolsFile", "r");
if (!$fhandle) {
    $msg1 = 'Could not read file: '.$myDBToolsFolder.$myDBToolsFile;
    $msg2 = 'Ensure the file exists in the ';
    $msg2.= ($myDBToolsFolder=="" ? 'same path as dbops.php' : 'path:'.$myDBToolsFolder);
    THROWERROR($msg1,$msg2,TRUE);
}
echo '<hr />';
echo 'Reading file: <b>'.$myDBToolsFolder.$myDBToolsFile.'</b> ... <br />';

$JSONstring = file_get_contents($myDBToolsFolder.$myDBToolsFile);
//echo $JSONstring;


echo ($showRead ? '<div style="font-family:Consolas,Lucida Console;font-size:12px;background-color:#000000;color:#AAAAAA;padding:10px;">'."\r\n" : "");

$jsonIterator = new RecursiveIteratorIterator(
    new RecursiveArrayIterator(json_decode($JSONstring, TRUE)),
    RecursiveIteratorIterator::SELF_FIRST);

echo '<br />';

foreach ($jsonIterator as $key => $val) {
    if(is_array($val)) {
//        echo $key.'>'.$val;
//        echo $key=='Actions' ? '' : '<br />';
        echo '<br />';
        
        if (is_numeric($key)) {
            echo $key . '>';
        } else {
            switch ($key) {
                case 'Actions':
                    echo '<br />';
                    echo '<span style="font-size:14px;font-weight:bold;color:#FF00FF;text-decoration:underline;">';
                    echo $key;
                    echo '</span>';
                    break;
                case 'TaskTypes':
                case 'Rules':
                    echo '<br />';
                    echo '<span style="font-size:22px;font-weight:bold;color:#FFBB00;text-decoration:underline;">';
                    echo '>>>>>>>>>>>>>>> '.$key.' >>>>>>>>>>>>>>>';
                    echo '</span>';
                    break;
                case 'AutomationCommandMaps':
                    echo '<br />';
                    echo '<span style="font-size:18px;font-weight:bold;color:#FF0000;">';
//                    echo $key;
                    echo '>>> AUTOMATION COMMAND >>>';
                    echo '</span>';
                    break;
                case 'AppRuleMaps':
                    echo '<br />';
                    echo '<span style="font-size:18px;font-weight:bold;color:#FF0000;">';
//                    echo $key;
                    echo '>>> RULE >>>';
                    echo '</span>';
                    break;
                case 'EntityScreenMaps':
                    echo '<br />';
                    echo '<span style="font-size:18px;font-weight:bold;color:#FF0000;">';
//                    echo $key;
                    echo '>>> ENTITY SCREEN >>>';
                    echo '</span>';
                    break;
                case 'EntityScreens':
                case 'Scripts':
                    echo '<br />';
                    echo '<span style="font-size:22px;font-weight:bold;color:#00FF00;text-decoration:underline;">';
                    echo '>>>>>>>>>>>>>>> '.$key.' >>>>>>>>>>>>>>>';
                    echo '</span>';
                    break;
                case 'AutomationCommands':
                case 'CustomReports':
                case 'PrintJobs':
                case 'PrinterTemplates':
                case 'Printers':
                    echo '<br />';
                    echo '<span style="font-size:22px;font-weight:bold;color:#FFFF00;text-decoration:underline;">';
                    echo '>>>>>>>>>>>>>>> '.$key.' >>>>>>>>>>>>>>>';
                    echo '</span>';
                    break;                default:
                    echo '<b>::: ' . $key . ' :::</b>';
                    break;
            }
        }
        
    } else {
        if ($key=='Name') {
            echo  $key . ' => ';
            echo ($key=='Name' ? '<b style="font-size:18px;color:#00DDFF;">'.$val.'</b>' : $val);
//            echo '<br />';
        }
    }
}


echo ($showRead ? '</div>' : "");

// Done reading file - close it
if ($fhandle) {
    fclose($fhandle);
}
$frowcount=$r;

echo ($showRead ? "<br />" : "");

echo 'Done. Columns:'.$columnCount.' Rows:'.$frowcount.'<br />';

that’s great, Thanks for sharing!