public String execute() { if (dataSetId != null) { dataSet = dataSetService.getDataSet(dataSetId); operands = new ArrayList<DataElementOperand>( dataElementCategoryService.getFullOperands(dataSet.getDataElements())); } else { operands = new ArrayList<DataElementOperand>(); } if (key != null) { Iterator<DataElementOperand> iterator = operands.iterator(); while (iterator.hasNext()) { DataElementOperand operand = iterator.next(); if (operand.getOperandName().toLowerCase().indexOf(key.toLowerCase()) == -1) { iterator.remove(); } } } Collections.sort(operands, new DataElementOperandNameComparator()); if (usePaging) { this.paging = createPaging(operands.size()); operands = operands.subList(paging.getStartPos(), paging.getEndPos()); } return SUCCESS; }
public String execute() throws Exception { DataSet dataSet = dataSetService.getDataSet(dataSetId); DataEntryStatus dataStatus = new DataEntryStatus(); dataStatus.setDataSet(dataSet); dataStatus.setMakeDefault(makeDefault); dataStatus.setPeriodType(dataSet.getPeriodType()); exportReportService.saveDataEntryStatus(dataStatus); return SUCCESS; }
@Override public String execute() throws Exception { DataSet dataSet = dataSetService.getDataSet(dataSetId); DataEntryForm dataEntryForm = dataEntryFormService.getDataEntryForm(dataEntryFormId); dataSet.setDataEntryForm(null); dataSet.increaseVersion(); dataSetService.updateDataSet(dataSet); dataEntryFormService.deleteDataEntryForm(dataEntryForm); return SUCCESS; }
private List<Period> getPeriodsForDataSet(int id) { DataSet dataSet = dataSetService.getDataSet(id); if (dataSet == null) { return new ArrayList<Period>(); } CalendarPeriodType periodType = (CalendarPeriodType) dataSet.getPeriodType(); List<Period> periods = periodType.generateLast5Years(new Date()); FilterUtils.filter(periods, new PastAndCurrentPeriodFilter()); Collections.reverse(periods); if (periods.size() > 10) { periods = periods.subList(0, 10); } return periods; }
@Transactional public void matchObject(int importObjectId, int existingObjectId) { ImportObject importObject = importObjectStore.getImportObject(importObjectId); Object object = importObject.getObject(); // --------------------------------------------------------------------- // Updates the name of the import object to the name of the existing // object. // --------------------------------------------------------------------- if (object.getClass().equals(DataElement.class)) { DataElement element = (DataElement) object; element.setName(dataElementService.getDataElement(existingObjectId).getName()); } else if (object.getClass().equals(DataElementGroup.class)) { DataElementGroup group = (DataElementGroup) object; group.setName(dataElementService.getDataElementGroup(existingObjectId).getName()); } else if (object.getClass().equals(DataElementGroupSet.class)) { DataElementGroupSet groupSet = (DataElementGroupSet) object; groupSet.setName(dataElementService.getDataElementGroupSet(existingObjectId).getName()); } else if (object.getClass().equals(IndicatorType.class)) { IndicatorType type = (IndicatorType) object; type.setName(indicatorService.getIndicatorType(existingObjectId).getName()); } else if (object.getClass().equals(Indicator.class)) { Indicator indicator = (Indicator) object; indicator.setName(indicatorService.getIndicator(existingObjectId).getName()); } else if (object.getClass().equals(IndicatorGroup.class)) { IndicatorGroup group = (IndicatorGroup) object; group.setName(indicatorService.getIndicatorGroup(existingObjectId).getName()); } else if (object.getClass().equals(IndicatorGroupSet.class)) { IndicatorGroupSet groupSet = (IndicatorGroupSet) object; groupSet.setName(indicatorService.getIndicatorGroupSet(existingObjectId).getName()); } else if (object.getClass().equals(DataDictionary.class)) { DataDictionary dictionary = (DataDictionary) object; dictionary.setName(dataDictionaryService.getDataDictionary(existingObjectId).getName()); } else if (object.getClass().equals(DataSet.class)) { DataSet dataSet = (DataSet) object; dataSet.setName(dataSetService.getDataSet(existingObjectId).getName()); } else if (object.getClass().equals(OrganisationUnit.class)) { OrganisationUnit unit = (OrganisationUnit) object; unit.setName(organisationUnitService.getOrganisationUnit(existingObjectId).getName()); } else if (object.getClass().equals(OrganisationUnitGroup.class)) { OrganisationUnitGroup group = (OrganisationUnitGroup) object; group.setName( organisationUnitGroupService.getOrganisationUnitGroup(existingObjectId).getName()); } else if (object.getClass().equals(OrganisationUnitGroupSet.class)) { OrganisationUnitGroupSet groupSet = (OrganisationUnitGroupSet) object; groupSet.setName( organisationUnitGroupService.getOrganisationUnitGroupSet(existingObjectId).getName()); } else if (object.getClass().equals(OrganisationUnitLevel.class)) { OrganisationUnitLevel level = (OrganisationUnitLevel) object; level.setName(organisationUnitService.getOrganisationUnitLevel(existingObjectId).getName()); } else if (object.getClass().equals(ValidationRule.class)) { ValidationRule validationRule = (ValidationRule) object; validationRule.setName(validationRuleService.getValidationRule(existingObjectId).getName()); } else if (object.getClass().equals(Report.class)) { Report report = (Report) object; report.setName(reportService.getReport(existingObjectId).getName()); } else if (object.getClass().equals(ReportTable.class)) { ReportTable reportTable = (ReportTable) object; reportTable.setName(reportTableService.getReportTable(existingObjectId).getName()); } else if (object.getClass().equals(Chart.class)) { Chart chart = (Chart) object; chart.setName(chartService.getChart(existingObjectId).getName()); } else if (object.getClass().equals(DataValue.class)) { DataValue dataValue = (DataValue) object; dataValue = updateDataValue( dataValue, dataValueService.getDataValue( dataValue.getSource(), dataValue.getDataElement(), dataValue.getPeriod(), dataValue.getOptionCombo())); } // --------------------------------------------------------------------- // Sets the status of the import object to match, these objects will // later be ignored on import all but is needed for matching of // associations. // --------------------------------------------------------------------- importObject.setStatus(ImportObjectStatus.MATCH); importObjectStore.updateImportObject(importObject); }