use of de.symeda.sormas.app.backend.task.Task in project SORMAS-Project by hzi-braunschweig.
the class TaskListFragment method onListItemClick.
@Override
public void onListItemClick(View view, int position, Object item) {
Task t = (Task) item;
TaskEditActivity.startActivity(getContext(), t.getUuid());
}
use of de.symeda.sormas.app.backend.task.Task in project SORMAS-Project by hzi-braunschweig.
the class TaskNewActivity method buildRootEntity.
@Override
protected Task buildRootEntity() {
Task _task;
if (!DataHelper.isNullOrEmpty(caseUuid)) {
Case _case = DatabaseHelper.getCaseDao().queryUuidBasic(caseUuid);
_task = DatabaseHelper.getTaskDao().build(_case);
} else if (!DataHelper.isNullOrEmpty(contactUuid)) {
Contact _contact = DatabaseHelper.getContactDao().queryUuid(contactUuid);
_task = DatabaseHelper.getTaskDao().build(_contact);
} else if (!DataHelper.isNullOrEmpty(eventUuid)) {
Event _event = DatabaseHelper.getEventDao().queryUuid(eventUuid);
_task = DatabaseHelper.getTaskDao().build(_event);
} else {
_task = DatabaseHelper.getTaskDao().build();
}
return _task;
}
use of de.symeda.sormas.app.backend.task.Task in project SORMAS-Project by hzi-braunschweig.
the class TaskNewActivity method saveData.
@Override
public void saveData() {
if (saveTask != null) {
NotificationHelper.showNotification(this, WARNING, getString(R.string.message_already_saving));
// don't save multiple times
return;
}
final Task taskToSave = getStoredRootEntity();
TaskEditFragment fragment = (TaskEditFragment) getActiveFragment();
fragment.setLiveValidationDisabled(false);
try {
FragmentValidator.validate(getContext(), fragment.getContentBinding());
} catch (ValidationException e) {
NotificationHelper.showNotification(this, ERROR, e.getMessage());
return;
}
saveDataInner(taskToSave);
}
use of de.symeda.sormas.app.backend.task.Task in project SORMAS-Project by hzi-braunschweig.
the class CaseBackendTest method shouldUpdateCaseAndAssociatedEntitiesOnMove.
@Test
public void shouldUpdateCaseAndAssociatedEntitiesOnMove() throws DaoException {
CaseDao caseDao = DatabaseHelper.getCaseDao();
Case caze = TestEntityCreator.createCase();
User user = DatabaseHelper.getUserDao().queryUuid(TestHelper.USER_UUID);
TaskDao taskDao = DatabaseHelper.getTaskDao();
Task pendingTask = TestEntityCreator.createCaseTask(caze, TaskStatus.PENDING, user);
Task doneTask = TestEntityCreator.createCaseTask(caze, TaskStatus.DONE, user);
Case existingCase = caseDao.queryUuidWithEmbedded(caze.getUuid());
District secondDistrict = DatabaseHelper.getDistrictDao().queryUuid(TestHelper.SECOND_DISTRICT_UUID);
caze.setResponsibleDistrict(secondDistrict);
Community secondCommunity = DatabaseHelper.getCommunityDao().queryUuid(TestHelper.SECOND_COMMUNITY_UUID);
caze.setResponsibleCommunity(secondCommunity);
caze.setHealthFacility(DatabaseHelper.getFacilityDao().queryUuid(TestHelper.SECOND_FACILITY_UUID));
caseDao.createPreviousHospitalizationAndUpdateHospitalization(caze, existingCase);
caseDao.saveAndSnapshot(caze);
caze = caseDao.queryUuidWithEmbedded(caze.getUuid());
pendingTask = taskDao.queryUuid(pendingTask.getUuid());
doneTask = taskDao.queryUuid(doneTask.getUuid());
// Case should have the new region, district, community and facility set
assertEquals(caze.getResponsibleRegion().getUuid(), TestHelper.REGION_UUID);
assertEquals(caze.getResponsibleDistrict().getUuid(), TestHelper.SECOND_DISTRICT_UUID);
assertEquals(caze.getResponsibleCommunity().getUuid(), TestHelper.SECOND_COMMUNITY_UUID);
assertEquals(caze.getHealthFacility().getUuid(), TestHelper.SECOND_FACILITY_UUID);
// The case officer should have changed
assertEquals(caze.getSurveillanceOfficer().getUuid(), TestHelper.SECOND_USER_UUID);
// Pending task should have been reassigned to the second user, done task should still be assigned to the first one
assertEquals(pendingTask.getAssigneeUser().getUuid(), TestHelper.SECOND_USER_UUID);
assertEquals(doneTask.getAssigneeUser().getUuid(), TestHelper.USER_UUID);
// A previous hospitalization with the former facility should have been created
List<PreviousHospitalization> previousHospitalizations = caze.getHospitalization().getPreviousHospitalizations();
assertEquals(1, previousHospitalizations.size());
}
use of de.symeda.sormas.app.backend.task.Task in project SORMAS-Project by hzi-braunschweig.
the class CaseBackendTest method testTaskReassignmentAfterChangedCaseCommunity.
@Test
public void testTaskReassignmentAfterChangedCaseCommunity() throws DaoException {
CaseDao caseDao = DatabaseHelper.getCaseDao();
Case caze = TestEntityCreator.createCase();
caze.setRegion(caze.getResponsibleRegion());
caze.setDistrict(caze.getResponsibleDistrict());
caze.setCommunity(caze.getResponsibleCommunity());
caseDao.saveAndSnapshot(caze);
User user = ConfigProvider.getUser();
user.setCommunity(caze.getCommunity());
UserRole userRole = UserRole.COMMUNITY_OFFICER;
Set<UserRole> userRoles = new HashSet<>();
userRoles.add(userRole);
user.setUserRoles(userRoles);
DatabaseHelper.getUserDao().saveAndSnapshot(user);
TaskDao taskDao = DatabaseHelper.getTaskDao();
Task task = TestEntityCreator.createCaseTask(caze, TaskStatus.PENDING, user);
caze = caseDao.queryUuidBasic(caze.getUuid());
assertEquals(TestHelper.USER_UUID, caze.getSurveillanceOfficer().getUuid());
assertEquals(caze.getResponsibleRegion().getUuid(), TestHelper.REGION_UUID);
assertEquals(caze.getResponsibleDistrict().getUuid(), TestHelper.DISTRICT_UUID);
assertEquals(caze.getResponsibleCommunity().getUuid(), TestHelper.COMMUNITY_UUID);
assertEquals(caze.getRegion().getUuid(), TestHelper.REGION_UUID);
assertEquals(caze.getDistrict().getUuid(), TestHelper.DISTRICT_UUID);
assertEquals(caze.getCommunity().getUuid(), TestHelper.COMMUNITY_UUID);
assertEquals(caze.getHealthFacility().getUuid(), TestHelper.FACILITY_UUID);
task = taskDao.queryUuid(task.getUuid());
assertEquals(TestHelper.USER_UUID, task.getAssigneeUser().getUuid());
// ResponsibleDistrict and ResponsibleCommunity changed,
// but District and Community still in user's jurisdiction
District secondDistrict = DatabaseHelper.getDistrictDao().queryUuid(TestHelper.SECOND_DISTRICT_UUID);
Community secondCommunity = DatabaseHelper.getCommunityDao().queryUuid(TestHelper.SECOND_COMMUNITY_UUID);
caze.setResponsibleDistrict(secondDistrict);
caze.setResponsibleCommunity(secondCommunity);
caze.setDistrict(secondDistrict);
caseDao.saveAndSnapshot(caze);
task = taskDao.queryUuid(task.getUuid());
assertEquals(TestHelper.USER_UUID, task.getAssigneeUser().getUuid());
caze = caseDao.queryUuidBasic(caze.getUuid());
assertEquals(TestHelper.SECOND_USER_UUID, caze.getSurveillanceOfficer().getUuid());
// Case not in user's jurisdiction anymore
caze.setCommunity(null);
caseDao.saveAndSnapshot(caze);
task = taskDao.queryUuid(task.getUuid());
assertEquals(TestHelper.SECOND_USER_UUID, task.getAssigneeUser().getUuid());
}
Aggregations