public String getAttributeName(Long id) { if (resolvedAttributeIds.contains(id)) return ""; Attribute a = attributeDAO.findByID(id); resolvedAttributeIds.add(id); if (a == null) return ""; return a.getName(); }
public TrialDataImportResult importTrialData(Long editTrialDataID, InputStream is) throws ExcelImportExportException { // map to collect invalid date values. this map allows further // processing // (not implemented atm) Map<Value, Serializable> invalidDateValues = new HashMap<Value, Serializable>(); // map to store the values from the xls Map<String, Serializable> valueMap = null; int importCnt = 0; TrialData trialData = trialDataDAO.findByID(editTrialDataID); valueMap = excelReader.readXLSX(is); log.info("sucessfully loaded data from excel sheet"); for (AttributeGroup aGroup : trialData.getTrialform().getAttributeGroups()) { for (Attribute attr : aGroup.getAttributes()) { // search attribute in map Serializable mapVal = valueMap.get(attr.getName()); if (mapVal == null) continue; importCnt++; Value value = valueFactory.getValueObject(attr.getFormElement().getDataType()); try { value.setValueObject(mapVal); } catch (IllegalArgumentException e) { if (value.getType() == DATATYPE.DATE) { invalidDateValues.put(value, mapVal); } } value.setAttribute(attr); value.setTrialData(trialData); trialData.getValues().add(value); valueDAO.persist(value); } } TrialDataImportResult result = new TrialDataImportResult(); result.setImportCnt(importCnt); result.setSuccCnt(valueMap.keySet().size()); result.setTrialData(trialData); return result; }