@Override protected boolean isIdentical(ReportTable object, ReportTable existing) { if (!object.getName().equals(existing.getName())) { return false; } if (object.isRegression() != existing.isRegression()) { return false; } if (object.isDoIndicators() != existing.isDoIndicators()) { return false; } if (object.isDoPeriods() != existing.isDoPeriods()) { return false; } if (object.isDoUnits() != existing.isDoUnits()) { return false; } return true; }
@Override protected void importMatching(ReportTable object, ReportTable match) { match.setName(object.getName()); match.setRegression(object.isRegression()); match.setDoIndicators(match.isDoIndicators()); match.setDoPeriods(match.isDoPeriods()); match.setDoUnits(match.isDoUnits()); match.getRelatives().setLastMonth(object.getRelatives().isLastMonth()); match.getRelatives().setMonthsThisYear(object.getRelatives().isMonthsThisYear()); match.getRelatives().setQuartersThisYear(object.getRelatives().isQuartersThisYear()); match.getRelatives().setThisYear(object.getRelatives().isThisYear()); match.getRelatives().setMonthsLastYear(object.getRelatives().isMonthsLastYear()); match.getRelatives().setQuartersLastYear(object.getRelatives().isQuartersLastYear()); match.getRelatives().setLastYear(object.getRelatives().isLastYear()); match .getReportParams() .setParamReportingMonth(object.getReportParams().isParamReportingMonth()); match .getReportParams() .setParamParentOrganisationUnit(object.getReportParams().isParamParentOrganisationUnit()); match .getReportParams() .setParamOrganisationUnit(object.getReportParams().isParamOrganisationUnit()); reportTableService.saveReportTable(match); }
@Override protected ReportTable getMatching(ReportTable object) { List<ReportTable> reportTableByName = reportTableService.getReportTableByName(object.getName()); return reportTableByName.isEmpty() ? null : reportTableByName.get(0); }
@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); }