Search in sources :

Example 1 with DBMoreThenOneRecordsFoundException

use of org.adempiere.exceptions.DBMoreThenOneRecordsFoundException in project metasfresh-webui-api by metasfresh.

the class SqlDocumentsRepository method retrieveDocument.

@Override
public Document retrieveDocument(final DocumentQuery query, final IDocumentChangesCollector changesCollector) {
    final int limit = 2;
    final OrderedDocumentsList documents = retriveDocuments(query, limit, changesCollector);
    if (documents.isEmpty()) {
        return null;
    } else if (documents.size() > 1) {
        throw new DBMoreThenOneRecordsFoundException("More than one record found for " + query + " on " + this + "\n First " + limit + " records: " + Joiner.on("\n").join(documents.toList()));
    } else {
        return documents.get(0);
    }
}
Also used : OrderedDocumentsList(de.metas.ui.web.window.model.OrderedDocumentsList) DBMoreThenOneRecordsFoundException(org.adempiere.exceptions.DBMoreThenOneRecordsFoundException)

Aggregations

OrderedDocumentsList (de.metas.ui.web.window.model.OrderedDocumentsList)1 DBMoreThenOneRecordsFoundException (org.adempiere.exceptions.DBMoreThenOneRecordsFoundException)1