tehn0drom
tehn0drom

Reputation: 29

DQL drop group_name in DFC

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?

Upvotes: 0

Views: 419

Answers (2)

Miki
Miki

Reputation: 2517

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.

Upvotes: 0

tehn0drom
tehn0drom

Reputation: 29

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);
    }
}

Upvotes: 1

Related Questions