use of org.hisp.dhis.dataset.DataSet 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();
}
use of org.hisp.dhis.dataset.DataSet in project dhis2-core by dhis2.
the class LockExceptionControllerDocumentation method testAddLockException.
@Test
public void testAddLockException() 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);
String postUrl = "/lockExceptions?ou=" + orgUnit.getUid() + "&pe=201612&ds=" + dataSet.getUid();
mvc.perform(post(postUrl).session(session).accept(TestUtils.APPLICATION_JSON_UTF8)).andExpect(status().is(201)).andExpect(content().contentTypeCompatibleWith(TestUtils.APPLICATION_JSON_UTF8)).andDo(documentPrettyPrint("lockExceptions/add"));
}
use of org.hisp.dhis.dataset.DataSet in project dhis2-core by dhis2.
the class LockExceptionControllerDocumentation method testDeleteLockException.
@Test
public void testDeleteLockException() 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 deleteUrl = "/lockExceptions?ou=" + orgUnit.getUid() + "&pe=201612&ds=" + dataSet.getUid();
mvc.perform(delete(deleteUrl).session(session).accept(TestUtils.APPLICATION_JSON_UTF8)).andExpect(status().isNoContent()).andDo(documentPrettyPrint("lockExceptions/delete"));
}
use of org.hisp.dhis.dataset.DataSet in project dhis2-core by dhis2.
the class DataEntryFormServiceTest method testGetDataEntryFormByName.
@Test
public void testGetDataEntryFormByName() {
DataSet dataSetA = createDataSet('A', periodType);
dataSetService.addDataSet(dataSetA);
DataEntryForm dataEntryForm = createDataEntryForm('A');
int id = dataEntryFormService.addDataEntryForm(dataEntryForm);
dataEntryForm = dataEntryFormService.getDataEntryForm(id);
assertEquals(dataEntryFormService.getDataEntryFormByName("DataEntryFormA"), dataEntryForm);
assertNull(dataEntryFormService.getDataEntryFormByName("DataEntryFormX"));
}
use of org.hisp.dhis.dataset.DataSet in project dhis2-core by dhis2.
the class UserRoleObjectBundleHook method postCommit.
@Override
@SuppressWarnings("unchecked")
public void postCommit(ObjectBundle bundle) {
if (!bundle.getObjectMap().containsKey(UserAuthorityGroup.class))
return;
List<IdentifiableObject> objects = bundle.getObjectMap().get(UserAuthorityGroup.class);
Map<String, Map<String, Object>> userRoleReferences = bundle.getObjectReferences(UserAuthorityGroup.class);
if (userRoleReferences == null || userRoleReferences.isEmpty()) {
return;
}
for (IdentifiableObject object : objects) {
object = bundle.getPreheat().get(bundle.getPreheatIdentifier(), object);
Map<String, Object> userRoleReferenceMap = userRoleReferences.get(object.getUid());
if (userRoleReferenceMap == null || userRoleReferenceMap.isEmpty()) {
continue;
}
UserAuthorityGroup userRole = (UserAuthorityGroup) object;
userRole.setDataSets((Set<DataSet>) userRoleReferenceMap.get("dataSets"));
userRole.setPrograms((Set<Program>) userRoleReferenceMap.get("programs"));
preheatService.connectReferences(userRole, bundle.getPreheat(), bundle.getPreheatIdentifier());
sessionFactory.getCurrentSession().update(userRole);
}
}
Aggregations