Search code examples
dqldocumentum

count how many objects have been updated in Documentum


I am doing a project connected to Documentum data storage . And I am trying to update all the acl names assigned to the sub folders of a folder using the following function :

try {
        StringBuilder str = new StringBuilder();
        str.append(dirDestination);
        str.append("/");
        str.append(companyName);

        String query = "update dm_folder object set acl_name = '@acl_name' , set acl_domain ='@acl_domain' where folder ('@acl_dirPath',descend)";
        query = query.replace("@acl_name",newAclName);
        query = query.replace("@acl_domain",inheritedAclDomain );
        query = query.replace("@acl_dirPath",str.toString() );



        IDfQuery ACLQuery = new DfQuery();
        ACLQuery.setDQL(query);
        ACLQuery.execute(_session, IDfQuery.DF_EXEC_QUERY);
        log.info("All the sub folders have received the new ACL.");

}catch(Exception E){
    System.out.println(E.getLocalizedMessage());
}

The function works perfectly fine but I want to know how many folders have been updated as a result of using these lines of code. One way would be to use IDfCollections which seems not to be working for this DQL as I've written the following and I keep getting 1 :

try{
    StringBuilder path = new StringBuilder();
    path.append(dirDestination);
    path.append("/" + companyName);
    String query = "update dm_folder object set acl_name = '@newAclName' , set acl_domain ='@newAclDomain' where folder ('@aclPath',descend)";
    query = query.replace("@newAclName" , newAclName );
    query = query.replace("@newAclDomain" , inheritedAclDomain );
    query = query.replace("@aclPath" , path );
    IDfQuery ACLQuery = new DfQuery();
    ACLQuery.setDQL(query);
    IDfCollection count = ACLQuery.execute(_session, IDfQuery.DF_EXEC_QUERY);
    int counter = 0 ;
    while (count.next()){
        counter++ ;

    }
    System.out.println("counter for sub folders ==> " + counter);
     log.info("The ACl name for all the sub folders are updated .");
}catch(Exception E ){
    System.out.println(E.getLocalizedMessage());
}

So the questions is how can I know the metadata of how many objects have been updated ? another way can be checking based on the objects' date of modification . But is there any other easier(more straight forward) way ?


Solution

  • You just need to fetch objects_updated instead of increment variable in your while loop:

    IDfCollection count = ACLQuery.execute(_session, IDfQuery.DF_EXEC_QUERY);
    
    int counter = 0 ;
    if (count.next()) {
      counter   = count.getInt("objects_updated");
    }
    
    System.out.println("count of updated sub folders ==> " + counter   );