Search in sources :

Example 1 with DQLTerm

use of org.openntf.xsp.nosql.communication.driver.DQL.DQLTerm in project org.openntf.xsp.jakartaee by OpenNTF.

the class DefaultDominoDocumentCollectionManager method delete.

@Override
public void delete(DocumentDeleteQuery query) {
    try {
        Database database = supplier.get();
        List<String> unids = query.getDocuments();
        if (unids != null && !unids.isEmpty()) {
            for (String unid : unids) {
                if (unid != null && !unid.isEmpty()) {
                    lotus.domino.Document doc = database.getDocumentByUNID(unid);
                    doc.remove(true);
                }
            }
        } else if (query.getCondition().isPresent()) {
            // Then do it via DQL
            DQLTerm dql = QueryConverter.getCondition(query.getCondition().get());
            DominoQuery dominoQuery = database.createDominoQuery();
            DocumentCollection docs = dominoQuery.execute(dql.toString());
            docs.removeAll(true);
        }
    } catch (NotesException e) {
        throw new RuntimeException(e);
    }
}
Also used : NotesException(lotus.domino.NotesException) Database(lotus.domino.Database) DominoQuery(lotus.domino.DominoQuery) DocumentCollection(lotus.domino.DocumentCollection) DQLTerm(org.openntf.xsp.nosql.communication.driver.DQL.DQLTerm)

Example 2 with DQLTerm

use of org.openntf.xsp.nosql.communication.driver.DQL.DQLTerm in project org.openntf.xsp.jakartaee by OpenNTF.

the class DefaultDominoDocumentCollectionManager method count.

@Override
public long count(String documentCollection) {
    try {
        Database database = supplier.get();
        DominoQuery dominoQuery = database.createDominoQuery();
        DQLTerm dql = DQL.item(EntityConverter.NAME_FIELD).isEqualTo(documentCollection);
        DocumentCollection result = dominoQuery.execute(dql.toString());
        return result.getCount();
    } catch (NotesException e) {
        throw new RuntimeException(e);
    }
}
Also used : NotesException(lotus.domino.NotesException) Database(lotus.domino.Database) DominoQuery(lotus.domino.DominoQuery) DocumentCollection(lotus.domino.DocumentCollection) DQLTerm(org.openntf.xsp.nosql.communication.driver.DQL.DQLTerm)

Aggregations

Database (lotus.domino.Database)2 DocumentCollection (lotus.domino.DocumentCollection)2 DominoQuery (lotus.domino.DominoQuery)2 NotesException (lotus.domino.NotesException)2 DQLTerm (org.openntf.xsp.nosql.communication.driver.DQL.DQLTerm)2