0

I have a list of group names which the app is reading from external .txt. I want to pass to method as a List <String> group names and to execute dql query something like:

for (String s : groupnames) {
    dql = "DROP GROUP " + s;
    System.out.println("dropped group: " + s;
}

How to write/execute DQL?

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
tehn0drom
  • 29
  • 9

2 Answers2

1

I have done it by myself:

private static void deleteGroups(List<String> groupsToDelete) {
    try {
        DfClientX clientX = new DfClientX();
        IDfQuery query = clientX.getQuery();

        for (String s : groupsToDelete){
            query.setDQL("DROP GROUP '" + s + "'");
            printInfo("Executing DQL: " + query.getDQL());
            query.execute(_session, 0);

        }

    } catch (DfException e) {
        printError(e.getMessage());
        DfLogger.error("app", "DQL DROP GROUP execution", null,e);
    }
}
tehn0drom
  • 29
  • 9
  • Two points: 1) You **have** to close documentum collections. You get one when executing query.execute() method. If this is only a one-time activity, then it is fine. If you are using it in your application - this needs to be fixed 2) Deleting a group may have consequences as there might be objects holding references to it. It is better to run dm_ConsistencyChecker job and check it's output – Sergi Sep 13 '16 at 15:04
0

Not quite sure does CS permit to delete group via DFC but it should be like:

IDfQuery query = new DfQuery();
query.setDQL("DROP GROUP <group_name>");
query.execute(getSession(), IDfQuery.DF_EXEC_QUERY);

There is for sure way to instantiate group object in memory and call .delete() method. I'll try to check it out.

Miki
  • 2,493
  • 2
  • 27
  • 39