use of org.hisp.dhis.period.PeriodType in project dhis2-core by dhis2.
the class ConfigurationController method setInfrastructuralPeriodType.
@PreAuthorize("hasRole('ALL') or hasRole('F_SYSTEM_SETTING')")
@RequestMapping(value = "/infrastructuralPeriodType", method = RequestMethod.POST)
@ResponseStatus(HttpStatus.NO_CONTENT)
public void setInfrastructuralPeriodType(@RequestBody String name) throws NotFoundException {
PeriodType periodType = PeriodType.getPeriodTypeByName(name);
if (periodType == null) {
throw new NotFoundException("Period type", name);
}
Configuration config = configurationService.getConfiguration();
periodType = periodService.reloadPeriodType(periodType);
config.setInfrastructuralPeriodType(periodType);
configurationService.setConfiguration(config);
}
use of org.hisp.dhis.period.PeriodType in project dhis2-core by dhis2.
the class CompleteDataSetRegistrationController method getCompleteDataSetRegistrations.
private CompleteDataSetRegistrations getCompleteDataSetRegistrations(Set<String> dataSet, String period, Date startDate, Date endDate, Set<String> orgUnit, boolean children) {
Set<Period> periods = new HashSet<>();
Set<DataSet> dataSets = new HashSet<>();
Set<OrganisationUnit> organisationUnits = new HashSet<>();
PeriodType periodType = periodService.getPeriodTypeByName(period);
if (periodType != null) {
periods.addAll(periodService.getPeriodsBetweenDates(periodType, startDate, endDate));
} else {
periods.addAll(periodService.getPeriodsBetweenDates(startDate, endDate));
}
if (periods.isEmpty()) {
return new CompleteDataSetRegistrations();
}
if (children) {
organisationUnits.addAll(organisationUnitService.getOrganisationUnitsWithChildren(orgUnit));
} else {
organisationUnits.addAll(organisationUnitService.getOrganisationUnitsByUid(orgUnit));
}
dataSets.addAll(manager.getByUid(DataSet.class, dataSet));
CompleteDataSetRegistrations completeDataSetRegistrations = new CompleteDataSetRegistrations();
completeDataSetRegistrations.setCompleteDataSetRegistrations(new ArrayList<>(registrationService.getCompleteDataSetRegistrations(dataSets, organisationUnits, periods)));
return completeDataSetRegistrations;
}
use of org.hisp.dhis.period.PeriodType in project dhis2-core by dhis2.
the class HibernateValidationRuleStore method save.
// -------------------------------------------------------------------------
// Implementation
// -------------------------------------------------------------------------
@Override
public void save(ValidationRule validationRule) {
PeriodType periodType = periodService.reloadPeriodType(validationRule.getPeriodType());
validationRule.setPeriodType(periodType);
super.save(validationRule);
}
use of org.hisp.dhis.period.PeriodType in project dhis2-core by dhis2.
the class HibernateValidationRuleStore method update.
@Override
public void update(ValidationRule validationRule) {
PeriodType periodType = periodService.reloadPeriodType(validationRule.getPeriodType());
validationRule.setPeriodType(periodType);
super.save(validationRule);
}
use of org.hisp.dhis.period.PeriodType in project dhis2-core by dhis2.
the class LockExceptionControllerDocumentation method testGetLockException.
@Test
public void testGetLockException() throws Exception {
MockHttpSession session = getSession("ALL");
PeriodType periodType = periodService.getPeriodTypeByName("Monthly");
Period period = createPeriod(periodType, getDate(2016, 12, 1), getDate(2016, 12, 31));
manager.save(period);
OrganisationUnit orgUnit = createOrganisationUnit('B');
manager.save(orgUnit);
DataSet dataSet = createDataSet('A', periodType);
dataSet.addOrganisationUnit(orgUnit);
manager.save(dataSet);
LockException lockException = new LockException(period, orgUnit, dataSet);
dataSetService.addLockException(lockException);
String getUrl = "/lockExceptions?filter=organisationUnit.id:eq:" + orgUnit.getUid() + "&filter=period:eq:201612&filter=dataSet.id:eq:" + dataSet.getUid();
Lists.newArrayList(fieldWithPath("period").description("Property"), fieldWithPath("organisationUnit").description("Property"), fieldWithPath("dataSet").description("Property"));
mvc.perform(get(getUrl).session(session).accept(MediaType.APPLICATION_JSON_UTF8)).andExpect(status().is(200)).andDo(documentPrettyPrint("lockExceptions/get")).andReturn();
}
Aggregations