public void saveAudit(List<AuditDetails> auditDetails) throws ClipsServerException {
String s = "";
long t1 = new Date().getTime();
for (AuditDetails ad : auditDetails) {
s += "AuditDetails[ id: " + ad.id + ", sign: " + Converter.hexDump(ad.sign) + "]\n";
Audit audit = findEntity(Audit.class, ad.id);
audit.setDsa(Converter.hexDump(ad.sign));
List list = findEntityWhatWithResCount(null, CollaboratorCertificate.class, new Field[]{new Field("collaborator.id", ad.collaboratorID)}, " ORDER BY a.id", 1);
if (list.size() != 1){
throw new ClipsServerException("Документ аудита не может быть подписан, т.к. не найден сертификат открытого ключа");
}
audit.setCertificate((CollaboratorCertificate) list.get(0));
manager.persist(audit);
}
System.out.println("Save audit\n" + s + " in " + (new Date().getTime() - t1)+ " мс");
// throw new UnsupportedOperationException("Not supported yet.");
}