Field f[] = {
new Field("key.job", jobId),
new Field("key.danger", details.dangerId)
};
List list = findEntityList(DangerJob.class, f);
DangerJob dangerJob = null;
AuditDoc<DangerJob> auditDJ;
if (!list.isEmpty()){
dangerJob = findEntityList(DangerJob.class, f).get(0);//Должна быть одна
auditDJ = new AuditDoc<DangerJob>(dangerJob, getCollaborator());
dangerJob.setLastExam(details.lastExam);
dangerJob.setExamManually(true);///Если заюзано из бина значит руками
}else {
auditDJ = new AuditDoc<DangerJob>(null, getCollaborator());
dangerJob = new DangerJob();
dangerJob.setKey(new DangerJobPK(details.dangerId, jobId));
dangerJob.setDanger(findEntity(Danger.class, details.dangerId));
dangerJob.setJob(findEntity(Job.class, jobId));
dangerJob.setLastExam(details.lastExam);
dangerJob.setExamManually(details.lastExamManually);
}
int id = saveEntity(dangerJob);
auditDJ.check(dangerJob);
return new ModificationInfo(id, persistAudit(auditDJ));