The rules around what gets replaced and what gets added when reuploading a folder structure

LabKey Support Forum (Inactive)
The rules around what gets replaced and what gets added when reuploading a folder structure adam  2015-08-26 07:51
Status: Closed
 
You should consider building one or more modules to manage your standard queries, reports, views, webparts, etc. With modules, you can develop your resources under source code control and then deploy standard versions to multiple servers. Here's a starting point: https://www.labkey.org/wiki/home/Documentation/page.view?name=moduleDirectoryStructures

We don't have a formal API for exporting/importing folders. That would be a nice addition… and wouldn't be difficult. You might be able to automate exports by posting directly to the folderManagement action and automate imports using the pipeline, but this can be tricky and fragile. We've also considered generalizing the "study reload" feature to folders, to provide an option for (say) nightly auto-reloading from a folder archive. One other existing option that may be relevant: at the point you create a new folder in the UI you can specify a "template folder" and select the objects to copy from that template.

As for the replacement rules, here are the guiding principles:

  1. Existing objects in the folder are left alone unless there's a replacement in the archive.
  2. Individual objects are replaced if they have a canonical name… and an object with the same name is present in both archive and folder. For example, query names, list names, and dataset ids are canonical names, so these objects get replaced if names match. A new object (name not present in the folder) simply gets inserted.
  3. We take a "best effort" approach to importing. For example, if an archive refers to a folder or user that doesn't exist in the target system, the import process will do its best to succeed by resolving to the current folder or ignoring unknown users.
As you've seen, renaming a query (changing its canonical name) via folder import isn't possible under these rules. Since the name identifies the query there's no way to detect a rename. Webparts, on the other hand, are replaced as a group because they don't have individual names; the assumption is that the archive represents the full list of webparts.

I hope this helps...

Adam