1
0
-1

Hi Unifacers,

one of my Uniface project is including some external files, either text and binary files; I have included them into a project deployment archive to be distributed. This functionality is already available into current deployment archive functionality:
- Binary files are saved into deployment archive within "fil" subdir
- Text files are saved into deployment archive within "txt" subdir
Now I have found one issues:
All these files are configuration files related to this project and are organized in a subtree starting from base project directory. This project was initially setup 2 years ago and it was positioned on a machine in a certain position into file system.
Now the same project was restored to be reviewed into another machine in another position of the files system; all references to external files into UARCHITEM are broken!

The reason is UDE is saving for these files their FULL PATH NAME into table UARCHITEM, I feel because being its primary key. As of today in U9.7.05.024 I did not find any way to save a relative filename: there is a checkbox available (Qualify source name) but also unchecking it always the full path file name is saved because the filename cannot be manually edited.

My question:
Shouldn't UDE require to developer to define UNIQUE original filenames either full path names or path names relative to current directory?

Any suggestion?
Gianni

    CommentAdd your comment...

    5 answers

    1.  
      1
      0
      -1

      And finally there is a proposal for a "all uniface" solution in 9.6.04

      entry do_fill_x_workdir
      x_workdir = $ldir()
      end ; do_fill_x_workdir
      
      entry do_retrieve
      clear/e "UARCHITEM"
      U_OBJNAME = $concat(X_WORKDIR,"·*")
      retrieve/e "UARCHITEM"
      end ; do_retrieve
      
      entry do_transform
      $1 = ""
      setocc "UARCHITEM",1
      while ($dbocc > 0)
      putlistitems/occ $2 ,"UARCHITEM"
      putitem $1,-1,$2
      remocc "UARCHITEM",1
      endwhile
      message/info $1
      while ($1 != "")
         getitem $2, $1, 1
         delitem $1, 1
         creocc "UARCHITEM",-1
         getlistitems/occ $2, "UARCHITEM"
         U_OBJNAME = $replace(U_OBJNAME,1,X_WORKDIR,"")
      endwhile
      end ; do_transform
      
      entry do_save
      macro "^store"
      end ; do_save
      
      ; NOTE: to break the readonly UARCHITEM put a WRITE/DELETE in the triggers
      
      

      The benefit of U9 is that GOLD chars have this "central dot" prefix so you should be able to just copy&paste

      1. Gianni Sandigliano

        Hi Uli,

        YES, also this your second solution is really valid...
        because could be embedded into UDE.
        So, the previous one is a workaround, this is a solution.

        I've asked for THE solution fully integrated into UDE defining wish #58.

        Gianni

      CommentAdd your comment...
    2.  
      1
      0
      -1

      The SQL magic is more difficult as it needs proprietary statements depending on your database.

      But it works similar to editing the export file with the following steps:

      • For all the records where U_OBJNAME starts with the path to the working directory
      • we UPDATE u_objname taking away the leading path to the working directory (via SUBSTRING or so.)
      • finally we must not forget to commit this transaction with another SQL command

      This way we are database dependend, but do not need to export/delete/import.

      190822: Just to complete the suggestion with an example

      For a SOLID database, the statements you can use with the SQL Workbench (GOLD-W) are for $IDF:

      update UARCHITEM set U_OBJNAME = replace(U_OBJNAME,'C:\drive_g\!drive_!m4l\umeFASTory\umeFASTory_TDD-9604\work\','') where u_objname like 'C:\drive_g\!drive_!m4l\umeFASTory\umeFASTory_TDD-9604\work\%'
      
      commit work

      or you can write a tiny form using $ldir to get the working directory, but I would use the "all uniface" implementation because it should work on all databases.

        CommentAdd your comment...
      1.  
        1
        0
        -1

        Hi Gianni,

        Have you had a look at the mklink command in Dos?

        Knut

        1. Gianni Sandigliano

          Hi Knut,

          Thanks for your suggestion.

          I consider the export/edit/delete/import session Uli suggested the simpler solution.

          Gianni

        CommentAdd your comment...
      2.  
        1
        0
        -1

        To REPAIR this situation without artistic SQL tricks we edit the export file:

        1. Export the archive(s)
        2. Delete the archive(s) in Uniface (as we change the primary keys)
        3. To remove the hardcoded path to the working directory, use an Editor on the export file replacing
          '<DAT name="U_OBJNAME">C:\drive_g\!drive_!m4l\umeFASTory\umeFASTory_TDD-9604\work\' with '<DAT name="U_OBJNAME">'
        4. Import the exported Archive back to Uniface
        5. create the archive output now with relative positioning

        This should be able to handle even the subtrees Gianni has mentioned as we cut only the leading part of the full path which is a constant to all PKs


        Its a fast and easy way to transform from fullpath to relative path while benefit from all the support of IDE.

        PLUS you can maintain the archive using the standard way which is the fastest one and finally apply the transformation routine again which works on the new records only.

        1. Gianni Sandigliano

          Hi Uli,

          It works! Workaround accepted.

          Gianni

        CommentAdd your comment...
      3.  
        1
        0
        -1

        Hi Gianni,

        I just had a little experiment with 9604 with Select Files Form:

        uncheck Qualify Source file names
        check Qualify target file names
        but leave target folder (which is editable) empty

        "Define Development Archive" shows only the pure filename as ObjectName

        The generated UAR looks OK for me because under the root we find "txt and "uar" subdirectory

        HIH, Uli

        P.S:

        so it may take only a little SQL magic to change the PKs for the existing Archives

        1. Gianni Sandigliano

          Hi Uli,

          I've checked the usage you proposed but unfortunately it does NOT work for me because my files are hosted in a directory tree including 4 different configurations, having more files with same basic name in different directories...I am receiving DUPKEY errors!

          I am going to check later this evening the hand made solution you've called "a little SQL magic"... (wink) (wink) (wink)

          Thanks for your efforts.

          Gianni

        2. . UliMerkel

          Hi Gianni,

          what about adding just the relative part of the directory tree manually as "destination folder" ??

          This should solve the duplicate key problem,

          Uli

          P.S. the export solution should work on the subtrees as well in just one go

        3. Gianni Sandigliano

          Hi Uli,

          good try but unfortunately(again) the destination folder is in use for those files...
          because I need to duplicate to uar:
          configs\config1\config.xml
          configs\config1\[aFirstWholeSubtree]
          ...
          configs\config4\config.xml
          configs\config4\[aFourthWholeSubtree]
          and those subtrees contains many files with same name in different directories.

          I'll probably go for the XML editing session instead of SQL... (smile)

          Gianni

        CommentAdd your comment...