Restore Recursive from local disk to Doors DB

Hello everyone,

I am new to dxl programming , can anybody please let me know how to recursively restore the projects (*.dpa) to the doors database. Also, once restored in to the doors database it should align in to a sequence.

For example if have 3 projects in my local drive (C or D) the script should restore all the projects one by one in to the doors database.

Please suggest and help!

Thanks

 


doors@36677 - Mon Oct 12 04:55:24 EDT 2015

Re: Restore Recursive from local disk to Doors DB
Mike.Scharnow - Thu Oct 15 04:58:55 EDT 2015

Hi TMSK,

 

You can read how to restore a project from a dpa file in https://www.ibm.com/developerworks/community/forums/html/topic?id=ce2ceea4-6560-4e4b-ba6d-0ebb5fba8203

I am not so sure what "recursive" will mean in your specific context.

When you have a project "P1", which contains a project "P1.1" and you create an archive of "P1", then the archive file p1.dpa will contain both projects. When you restore this file, your new projects will be called "P1 1" and "P1.1 1" (or, if you delete and purge P1 before the restore or if you rename P1 and P1.1, the new projects will again be called "P1" and "P1.1")

Now, when you have a project "P2" and in parallel have a project "P2.1", you can make separate dpa files which only contain the respective project. In this way you could

- restore P2.dpa to the new project "P2 1".

- make the project "P2 1" the current one (see code in post above), optionally navigate to a subfolder of "P2 1" and from here, restore P2.1.dpa to "P2 1/<subfolder>/P2.1 1"

But there's no general approach for this. You need to know where the destination for the subprojects are.

Hope this helps,
Mike

Re: Restore Recursive from local disk to Doors DB
Mike.Scharnow - Thu Oct 15 08:00:26 EDT 2015

I assume by "at one time" you mean "in one script".

the easiest way would of course be to write 10 lines like restoreProject("D:/P1.dpa","Demo 1","Descrip") ; restoreProject("D:/P2.dpa","Demo 2","Descrip")  … but I'm sure that's not the solution you are looking for...Eyebrow

For each restore you need the parameters

1. which file

2. which destination project

3. which project name

4. which description.

I cannot really help you with 2, 3 and 4 - that depends on your requirements. You might say that project name is identical to filename or be a combination of a base name plus a counter or you might have information stored somewhere that tells you more.

 

About 1: I think you want to have something like "look into directory D:\myfiles, search for all files which match the pattern *.dpa and for each found file do a restoreProject".

For this, have a look at the DXL manual, chapter 10 "General language facilities" and look at the "for file in directory" loop.

should be something like

string sFilename
Regexp isDPAFile = regexp2 "\\.[dD][pP][aA]$"
for sFilename in directory "D:\\myfiles" do {
   if (isDPAFile sFilename ) {
       restoreProject (sFilename, ...)
   } 
}

HTH, Mike

Re: Restore Recursive from local disk to Doors DB
Mike.Scharnow - Fri Oct 16 03:07:05 EDT 2015

the term "not working" is never a good feedback.

What is not working? How is it not working? When I paste the code to my DOORS, I don't see any problems (of course except for the syntax error related to line 5 not being complete and needing your input)

Re: Restore Recursive from local disk to Doors DB
Mike.Scharnow - Fri Oct 16 06:36:19 EDT 2015

Hi!

That's rather strange.

  • do you see the separate windows which open and close and restore the project? If so, it might just be that your DB explorer is not refreshed, so the new project is not shown. Use View -> Refresh(F5) in the DB explorer, or add "refreshDBExplorer()" to your script.
  • does the message contain any information? You can print the result of the variable by adding'print message;' to your script or
    print "->" message "<-\n";
  • Did you care for the slashes in your path? You can either use Unix Syntax, where paths are separated by one forward slash /, e.g. D:/path/to/P1.dpa  or you can use DOS Syntax with paths separated by an (escaped=double) backwards slash \, e.g. D:\\path\\to\\P1.dpa
    If not, this should be shown in the content of the return message. (->Archive file does not exist<-)
  • Did you delete and purge the project "Demo" before trying to recreate it?
    If not, this should be shown in the content of the return message. (->duplicate project name / Failed to create item :/test1/Demo / Archive Item restore failed)<-

 HTH, Mike

Re: Restore Recursive from local disk to Doors DB
Mike.Scharnow - Tue Oct 27 02:41:58 EDT 2015

Not really sure..

- is there a file d:\doors_projects\xx.dpa in your directory or are the files deeper, like in d:\doors_projects\some_dir\xx.dpa? The latter does not work with this script.

- switch "description" and "Restored Project"

- perhaps use "\Restored Project" instead of "Restored Project"?

- ensure that your script restores into the correct destination project by using sth. like " current = project '/test' "

- get the result of the restoreProject perm by using "string sResult = restoreProject..." and "print '->' sResult '<-\n' "

 

Re: Restore Recursive from local disk to Doors DB
Mike.Scharnow - Mon Nov 02 17:02:13 EST 2015

Hello TMSK,

sorry for not being able to reply earlier, I have not been available for some days.

Why did you delete all your answers? Is your problem solved?

Regards,
Mike