use of org.eclipse.sw360.datahandler.couchdb.DatabaseRepository in project sw360portal by sw360.
the class RepositoryUtils method doBulk.
// This works with any repository
public static RequestSummary doBulk(Collection<?> objects, User user, DatabaseRepository<?> repository) {
RequestSummary requestSummary = new RequestSummary();
if (PermissionUtils.isAdmin(user)) {
// Prepare component for database
final List<DocumentOperationResult> documentOperationResults = repository.executeBulk(objects);
requestSummary.setTotalElements(objects.size());
requestSummary.setTotalAffectedElements(objects.size() - documentOperationResults.size());
requestSummary.setRequestStatus(RequestStatus.SUCCESS);
} else {
requestSummary.setRequestStatus(RequestStatus.FAILURE);
}
return requestSummary;
}
Aggregations