use of org.akaza.openclinica.domain.datamap.DiscrepancyNoteType in project OpenClinica by OpenClinica.
the class QueryServiceImpl method createQuery.
private DiscrepancyNote createQuery(QueryServiceHelperBean helperBean, QueryBean queryBean) throws Exception {
DiscrepancyNote dn = new DiscrepancyNote();
dn.setStudy(helperBean.getContainer().getStudy());
dn.setEntityType("itemData");
dn.setDescription("description");
dn.setDetailedNotes(queryBean.getComment());
dn.setDiscrepancyNoteType(new DiscrepancyNoteType(3));
String user = queryBean.getUser();
if (user == null) {
dn.setUserAccountByOwnerId(helperBean.getContainer().getUser());
} else {
UserAccount userAccountByOwnerId = userAccountDao.findByUserName(user);
dn.setUserAccountByOwnerId(userAccountByOwnerId);
}
setResolutionStatus(queryBean, dn);
String assignedTo = "";
if (queryBean.getComment().startsWith("Automatic query for:")) {
assignedTo = helperBean.getContainer().getUser().getUserName();
} else {
assignedTo = queryBean.getAssigned_to();
}
if (!StringUtils.isEmpty(assignedTo)) {
UserAccount userAccount = userAccountDao.findByUserName(assignedTo);
helperBean.setUserAccount(userAccount);
dn.setUserAccount(userAccount);
}
// create itemData when a query is created without an autosaved itemdata
if (helperBean.getItemData() == null) {
helperBean.setItemData(createBlankItemData(helperBean));
}
dn.setDateCreated(new Date());
return dn;
}
Aggregations