use of org.akaza.openclinica.domain.datamap.ItemData in project OpenClinica by OpenClinica.
the class ItemProcessor method removeDeletedRows.
private void removeDeletedRows(HashMap<Integer, Set<Integer>> groupOrdinalMapping, SubmissionContainer container) {
Iterator<Integer> keys = groupOrdinalMapping.keySet().iterator();
while (keys.hasNext()) {
Integer itemGroupId = keys.next();
List<ItemData> itemDatas = itemDataDao.findByEventCrfGroup(container.getEventCrf().getEventCrfId(), itemGroupId);
for (ItemData itemData : itemDatas) {
if (!groupOrdinalMapping.get(itemGroupId).contains(itemData.getOrdinal()) && !itemData.isDeleted()) {
itemData.setDeleted(true);
itemData.setValue("");
itemData.setOldStatus(itemData.getStatus());
itemData.setUserAccount(container.getUser());
itemData.setStatus(Status.AVAILABLE);
itemData.setUpdateId(container.getUser().getUserId());
itemData.setInstanceId(container.getInstanceId());
itemData = itemDataDao.saveOrUpdate(itemData);
// Close discrepancy notes
closeItemDiscrepancyNotes(container, itemData);
}
}
}
}
use of org.akaza.openclinica.domain.datamap.ItemData in project OpenClinica by OpenClinica.
the class QueryServiceImpl method process.
@Override
public void process(QueryServiceHelperBean helperBean, SubmissionContainer container, Node itemNode, int itemOrdinal) throws Exception {
String node = itemNode.getTextContent();
if (StringUtils.isEmpty(node))
return;
helperBean.setContainer(container);
helperBean.setItemOrdinal(itemOrdinal);
helperBean.setItemNode(itemNode);
ItemData id = getItemData(helperBean);
if (id == null) {
helperBean.setItemData(createBlankItemData(helperBean));
} else {
helperBean.setItemData(id);
}
QueriesBean queries = null;
try {
ObjectMapper objectMapper = new ObjectMapper();
queries = objectMapper.readValue(node, QueriesBean.class);
} catch (IOException e) {
logger.error(e.getMessage());
throw e;
}
List<Integer> idList = new ArrayList();
List<QueryBean> qBeans = queries.getQueries();
QueryBean queryBean = null;
DiscrepancyNote childDN = null;
DiscrepancyNote parentDN = null;
List<DiscrepancyNote> childDns = null;
if (qBeans.size() > 0) {
for (QueryBean qBean : qBeans) {
idList.add(Integer.valueOf(qBean.getId()));
}
Collections.reverse(idList);
queryBean = qBeans.get(0);
parentDN = findQueryParent(helperBean);
if (parentDN == null) {
parentDN = createQuery(helperBean, queryBean);
parentDN = discrepancyNoteDao.saveOrUpdate(parentDN);
helperBean.setDn(parentDN);
saveQueryItemDatamap(helperBean);
}
childDns = findChildQueries(helperBean);
if (childDns.size() < qBeans.size()) {
// Enketo passes JSON "id" attribute for unsubmitted queries only
// if (StringUtils.isEmpty(queryBean.getId())){
childDN = createQuery(helperBean, queryBean);
childDN.setParentDiscrepancyNote(parentDN);
childDN = discrepancyNoteDao.saveOrUpdate(childDN);
parentDN.setUserAccount(childDN.getUserAccount());
setResolutionStatus(queryBean, parentDN);
parentDN.setUserAccountByOwnerId(helperBean.getContainer().getUser());
parentDN.setDetailedNotes(childDN.getDetailedNotes());
parentDN.setDiscrepancyNoteType(childDN.getDiscrepancyNoteType());
parentDN = discrepancyNoteDao.saveOrUpdate(parentDN);
helperBean.setDn(childDN);
saveQueryItemDatamap(helperBean);
handleEmailNotification(helperBean, queryBean);
}
}
}
use of org.akaza.openclinica.domain.datamap.ItemData in project OpenClinica by OpenClinica.
the class QueryServiceImpl method createBlankItemData.
private ItemData createBlankItemData(QueryServiceHelperBean helperBean) {
Item item = itemDao.findByNameCrfId(helperBean.getParentElementName(), helperBean.getContainer().getCrfVersion().getCrf().getCrfId());
ItemData itemData = new ItemData();
itemData.setItem(item);
itemData.setEventCrf(helperBean.getContainer().getEventCrf());
itemData.setValue("");
itemData.setDateCreated(new Date());
itemData.setStatus(Status.AVAILABLE);
// TODO this value should change once you have an ordinal attribute specified in the query
itemData.setOrdinal(helperBean.getItemOrdinal());
itemData.setUserAccount(helperBean.getUserAccount());
itemData.setDeleted(false);
itemData.setInstanceId(helperBean.getContainer().getInstanceId());
itemDataDao.saveOrUpdate(itemData);
return itemData;
}
use of org.akaza.openclinica.domain.datamap.ItemData in project OpenClinica by OpenClinica.
the class GenerateClinicalDataServiceImpl method fetchItemData.
private ArrayList<ImportItemGroupDataBean> fetchItemData(Set<ItemGroupMetadata> set, int eventCrfId, List<VersioningMap> vms, EventCrf eventCrf) {
String groupOID, itemOID;
String itemValue = null;
String itemDataValue;
HashMap<String, ArrayList<String>> oidMap = new HashMap<String, ArrayList<String>>();
HashMap<String, List<ItemData>> oidDNAuditMap = new HashMap<String, List<ItemData>>();
List<ItemData> itds = eventCrf.getItemDatas();
// itemOIDs with corresponding values will be created.
for (ItemData itemData : itds) {
List<ItemGroupMetadata> igmetadatas = itemData.getItem().getItemGroupMetadatas();
for (ItemGroupMetadata igGrpMetadata : igmetadatas) {
groupOID = igGrpMetadata.getItemGroup().getOcOid();
if (!oidMap.containsKey(groupOID)) {
String groupOIDOrdnl = groupOID;
ArrayList<String> itemsValues = new ArrayList<String>();
ArrayList<ItemData> itemDatas = new ArrayList<ItemData>();
List<ItemGroupMetadata> allItemsInAGroup = igGrpMetadata.getItemGroup().getItemGroupMetadatas();
for (ItemGroupMetadata itemGrpMetada : allItemsInAGroup) {
itemOID = itemGrpMetada.getItem().getOcOid();
itemsValues = new ArrayList<String>();
/*
* List<ItemData> itds = itemGrpMetada.getItem()
* .getItemDatas();
*/
// look for the key
// of same group and ordinal and add this item to
// that hashmap
itemsValues = new ArrayList<String>();
itemDataValue = fetchItemDataValue(itemData, itemData.getItem());
itemDatas = new ArrayList<ItemData>();
itemValue = itemOID + DELIMITER + itemDataValue;
itemsValues.add(itemValue);
groupOIDOrdnl = groupOID + GROUPOID_ORDINAL_DELIM + itemData.getOrdinal() + GROUPOID_ORDINAL_DELIM + itemData.isDeleted();
if (itemData.getItem().getOcOid() == itemOID) {
if (oidMap.containsKey(groupOIDOrdnl)) {
ArrayList<String> itemgrps = oidMap.get(groupOIDOrdnl);
List<ItemData> itemDataTemps = oidDNAuditMap.get(groupOIDOrdnl);
if (!itemgrps.contains(itemValue)) {
itemgrps.add(itemValue);
oidMap.remove(groupOIDOrdnl);
itemDataTemps.add(itemData);
oidDNAuditMap.remove(groupOIDOrdnl);
}
oidMap.put(groupOIDOrdnl, itemgrps);
oidDNAuditMap.put(groupOIDOrdnl, itemDataTemps);
} else {
oidMap.put(groupOIDOrdnl, itemsValues);
itemDatas.add(itemData);
oidDNAuditMap.put(groupOIDOrdnl, itemDatas);
}
}
}
}
}
}
return populateImportItemGrpBean(oidMap, oidDNAuditMap);
}
use of org.akaza.openclinica.domain.datamap.ItemData in project OpenClinica by OpenClinica.
the class ItemDataDao method findByEventCrfItemName.
public ItemData findByEventCrfItemName(int eventCrfId, String itemName, int ordinal) {
Query q = getCurrentSession().createQuery(findByEventCrfItemName);
q.setParameter("eventCrfId", eventCrfId);
q.setParameter("itemName", itemName);
q.setParameter("ordinal", ordinal);
return (ItemData) q.uniqueResult();
}
Aggregations