Method for listing the location of an object, and the location of its links

In another discussion about the limitations of ucybdbld,I proposed a work-around based on Java API calls that query and change object folder location(s) in an Automation Engine system. I would like to investigate the feasibility of such a work-around.

Given the name of a UC4 object, I would like to know the best way to use the Java Application Interface to find out:

2. Get the folder ID & OH ID of the folders where any links to an object reside

Turning these IDs into usable paths usually requires a recursive query. The OH_NAME returned by the following query contains the name of the directory, prefixed by the OH_IDNR of the parent directory, a lowercase letter k, and a backslash.

this means that the folder in which the object resides is called TEST, and that the parent folder of TEST has the OH_IDNR 2139047. One can get the information on the parent folder using this query:

select OH_OTYPE,OH_NAME from OHwhere OH_IDNR = '2139047';

One must keep going up the folder hierarchy like this until one reaches an OH record whose OH_TYPE is CLNT instead of FOLD. At that point, the previous OH record found corresponds to a top-level folder in that client.

If there is no Java method for getting the folder, then the simplest solution might be to get the folder ID using query 1 or 2, above, and then to use the IFolder.fullPath method to get the folder’s full path. I hope there is a way to do this just using the Java APIs though.

I ran into this problem again today, and was surprised anew that there is no script statement to get the folder path of an object. One can move an object to a particular folder using MOVE_OBJECT, but there’s no equivalent GET_OBJECT_LOCATION or GET_OBJECT_FOLDER_PATH script statement to find out where it is. :smile:

Not deterred by this, I decided to adapt the above SQL statement into something roughly equivalent an AE script statement. Simply create an SQLI VARA object called UC4.GET_FOLDER_PATH_OF_OBJECT.VARA_SQLI, with the following SQL statement:

Note that I’ve written the SQLI VARA to pass the bind parameter for the object name via the predefined variable &$ARCHIVE_KEY# because Automation Engine v9 does not properly support using ordinary object variables in SQLI/SQL VARA bind parameters. AE v10 and later do not suffer from this limitation, so if you’re running v10 or later, you can just put &OBJECT_NAME# directly in bind parameter 1, and omit the :PUT_ATT statement.