Automic Workload Automation

 View Only
  • 1.  Swap Link With Object

    Posted Mar 18, 2020 07:38 AM
    Edited by Michael A. Lowry Mar 27, 2020 07:11 AM
    I need to prepare to clean up the mess left by the recent ImportObject.keepFolderLinks() bug.

    This will require two steps:
    1. Identify objects that have links. In our testing and production systems, we do not permit links. Therefore, any links present in these systems are the result of the bug.
    2. Swap the link location with the home folder location.

    Step 1 I have already accomplished using this SQL query:
    -- Based on query provided by Matthew Bailey at Automic
    -- https://community.automic.com/discussion/comment/2673/#Comment_2673
    with object_paths as (
    select (select OH_Client from oh where oh_idnr = child) Client
    , (select OH_OType from oh where oh_idnr = child) Type
    , (select OH_Name from oh where oh_idnr = child) Object_Name
    , (select OH_ModDate from oh where oh_idnr = child) Mod_Date
    , Path
    , ofs_link Link
    from (select level
    , ofs_oh_idnr_f as parent
    , ofs_oh_idnr_o as child
    , oh_name
    , replace(SYS_CONNECT_BY_PATH(
    case when oh_otype='FOLD'
    then substr(oh_name,instr(oh_name,'k\',1)+2)
    else oh_name
    end,'|'),'|','/') as Path
    , ofs_link
    from ofs
    , oh
    where oh_idnr = ofs_oh_idnr_f
    start with ofs_oh_idnr_f = (select oh_idnr
    from oh
    where oh_otype = 'CLNT'
    and oh_client = 110)
    connect by prior ofs_oh_idnr_o = ofs_oh_idnr_f)

     Object_links as
    (select Object_Name,
    count(distinct(path)) as link_count
    from object_paths
    where Link = 1
    group by Object_Name
    order by Object_Name
    )

    Select * from object_paths op1
    where exists (select 1 from Objects_links where op1.object_name = Objects_with_links.Object_name and link_count = 2 )
    order by Object_Name

    For step 2, I'll use the Java APIs. I saw that in AWI 12.3.2, when you right-click on a link in the Process Assembly perspective, there is an option called Swap Link With Object.

    What API(s) does this function use behind the scenes? Is there a dedicated API for this, or does it just use DeleteLink followed by MoveObject?


  • 2.  RE: Swap Link With Object
    Best Answer

    Posted Mar 24, 2020 11:33 AM
    Edited by Michael A. Lowry Mar 27, 2020 07:09 AM
    OK, this is what I did. This is just a code snippet, with lots of logging and error checking omitted.

    ...
    IFolder linkFolder = folderTree.getFolder(linkPath);
    IFolder homeFolder = folderTree.getFolder(homePath);
    FolderList linkParentFolderList = new FolderList(folderTree.getFolder(linkPath));
    myConnection.sendRequestAndWait(linkParentFolderList);
    FolderListItem folderListItem = linkParentFolderList.findByName(objName);
    if (folderListItem.isLink()) {
      System.out.println(String.format("Deleting the link to object %s", objName));
      DeleteLink deleteLink = new DeleteLink(folderListItem);
      myConnection.sendRequestAndWait(deleteLink);
      System.out.println(String.format("Moving object from %s to %s", homePath, linkPath));
      MoveObject moveObject = new MoveObject(folderListItem, homeFolder, linkFolder);
      myConnection.sendRequestAndWait(moveObject);
      }
    ...


    For what it's worth, I looked at an AWI trace but could not determine whether the AWI is doing something like this, or swapping the links some other way.