use of org.mifos.security.rolesandpermission.business.ActivityEntity in project head by mifos.
the class RolesPermissionsAction method create.
@TransactionDemarcate(validateAndResetToken = true)
public ActionForward create(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
UserContext userContext = (UserContext) SessionUtils.getAttribute(Constants.USER_CONTEXT_KEY, request.getSession());
List<ActivityEntity> activities = (List<ActivityEntity>) SessionUtils.getAttribute(RolesAndPermissionConstants.ACTIVITYLIST, request);
RolesPermissionsActionForm rolesPermissionsActionForm = (RolesPermissionsActionForm) form;
rolesPermissionServiceFacade.createRole(userContext.getId(), rolesPermissionsActionForm.getName(), getActivityIds(getActivities(activities, rolesPermissionsActionForm.getActivities())), rolesPermissionsActionForm.getActivityRestrictionDtoToPersistList());
return mapping.findForward(ActionForwards.create_success.toString());
}
use of org.mifos.security.rolesandpermission.business.ActivityEntity in project head by mifos.
the class BirtAdminDocumentUploadActionStrutsTest method removeReport.
private void removeReport(Short reportId) throws PersistenceException {
legacyAdminDocumentDao.getSession().clear();
ReportsBO report = legacyAdminDocumentDao.getPersistentObject(ReportsBO.class, reportId);
ActivityEntity activityEntity = legacyRolesPermissionsDao.getPersistentObject(ActivityEntity.class, report.getActivityId());
legacyAdminDocumentDao.delete(report);
LookUpValueEntity anLookUp = activityEntity.getActivityNameLookupValues();
legacyRolesPermissionsDao.delete(activityEntity);
legacyRolesPermissionsDao.delete(anLookUp);
StaticHibernateUtil.flushSession();
}
use of org.mifos.security.rolesandpermission.business.ActivityEntity in project head by mifos.
the class AddActivityIntegrationTest method testNoParent.
@Test
public void testNoParent() throws Exception {
short newId = 17032;
AddActivity upgrade = new AddActivity(newId, null, "Can use the executive washroom");
upgrade.upgrade(session.connection());
ActivityEntity fetched = (ActivityEntity) session.get(ActivityEntity.class, newId);
Assert.assertEquals(null, fetched.getParent());
}
use of org.mifos.security.rolesandpermission.business.ActivityEntity in project head by mifos.
the class AddActivityIntegrationTest method testConstructorTest.
@Ignore
@Test
public void testConstructorTest() throws Exception {
Connection conn = session.connection();
// conn.setAutoCommit(true);
short newId = 30000;
AddActivity upgrade = null;
String invalidKey = "NewActivity";
try {
// use invalid lookup key format
upgrade = new AddActivity(invalidKey, newId, null);
} catch (Exception e) {
Assert.assertEquals(e.getMessage(), AddActivity.wrongLookupValueKeyFormat);
}
String goodKey = "Permissions-NewActivity";
// use valid constructor and valid key
upgrade = new AddActivity(goodKey, newId, null);
upgrade.upgrade(conn);
ActivityEntity fetched = (ActivityEntity) session.get(ActivityEntity.class, newId);
Assert.assertEquals(null, fetched.getParent());
Assert.assertEquals(goodKey, fetched.getActivityName());
Assert.assertEquals(goodKey, fetched.getActivityNameLookupValues().getLookUpName());
}
use of org.mifos.security.rolesandpermission.business.ActivityEntity in project head by mifos.
the class LegacyRolesPermissionsDaoIntegrationTest method testShouldSuccessWhenChangeActivityMessage.
@Test
public void testShouldSuccessWhenChangeActivityMessage() throws Exception {
ActivityEntity activityEntity = legacyRolesPermissionsDao.getPersistentObject(ActivityEntity.class, Short.valueOf((short) 3));
Integer lookUpId = activityEntity.getActivityNameLookupValues().getLookUpId();
Assert.assertEquals(373, lookUpId.intValue());
short localeId = Localization.ENGLISH_LOCALE_ID;
LookUpValueLocaleEntity lookUpValueLocaleEntity = legacyMasterDao.retrieveOneLookUpValueLocaleEntity(localeId, lookUpId.intValue());
Assert.assertNull(lookUpValueLocaleEntity.getLookUpValue());
legacyRolesPermissionsDao.changeActivityMessage((short) 3, localeId, "wahaha");
lookUpValueLocaleEntity = legacyMasterDao.retrieveOneLookUpValueLocaleEntity(localeId, lookUpId.intValue());
Assert.assertEquals("wahaha", lookUpValueLocaleEntity.getLookUpValue());
legacyRolesPermissionsDao.changeActivityMessage((short) 3, localeId, null);
}
Aggregations