Search in sources :

Example 6 with ActivityEntity

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());
}
Also used : ActivityEntity(org.mifos.security.rolesandpermission.business.ActivityEntity) UserContext(org.mifos.security.util.UserContext) RolesPermissionsActionForm(org.mifos.security.rolesandpermission.struts.actionforms.RolesPermissionsActionForm) ArrayList(java.util.ArrayList) List(java.util.List) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 7 with ActivityEntity

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();
}
Also used : ActivityEntity(org.mifos.security.rolesandpermission.business.ActivityEntity) ReportsBO(org.mifos.reports.business.ReportsBO) LookUpValueEntity(org.mifos.application.master.business.LookUpValueEntity)

Example 8 with ActivityEntity

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());
}
Also used : ActivityEntity(org.mifos.security.rolesandpermission.business.ActivityEntity) Test(org.junit.Test)

Example 9 with ActivityEntity

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());
}
Also used : ActivityEntity(org.mifos.security.rolesandpermission.business.ActivityEntity) Connection(java.sql.Connection) SQLException(java.sql.SQLException) IOException(java.io.IOException) ApplicationException(org.mifos.framework.exceptions.ApplicationException) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 10 with ActivityEntity

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);
}
Also used : ActivityEntity(org.mifos.security.rolesandpermission.business.ActivityEntity) LookUpValueLocaleEntity(org.mifos.application.master.business.LookUpValueLocaleEntity) Test(org.junit.Test)

Aggregations

ActivityEntity (org.mifos.security.rolesandpermission.business.ActivityEntity)42 PersistenceException (org.mifos.framework.exceptions.PersistenceException)13 MifosRuntimeException (org.mifos.core.MifosRuntimeException)12 Test (org.junit.Test)10 LookUpValueEntity (org.mifos.application.master.business.LookUpValueEntity)9 RoleBO (org.mifos.security.rolesandpermission.business.RoleBO)9 ArrayList (java.util.ArrayList)8 UserContext (org.mifos.security.util.UserContext)8 HibernateException (org.hibernate.HibernateException)7 ActivityGeneratorException (org.mifos.security.activity.ActivityGeneratorException)7 ApplicationException (org.mifos.framework.exceptions.ApplicationException)6 ServiceException (org.mifos.framework.exceptions.ServiceException)6 RolesPermissionsBusinessService (org.mifos.security.rolesandpermission.business.service.RolesPermissionsBusinessService)6 HibernateProcessException (org.mifos.framework.exceptions.HibernateProcessException)5 SystemException (org.mifos.framework.exceptions.SystemException)5 IOException (java.io.IOException)4 MessageLookup (org.mifos.application.master.MessageLookup)4 SecurityException (org.mifos.framework.exceptions.SecurityException)4 List (java.util.List)3 UserContextFactory (org.mifos.accounts.servicefacade.UserContextFactory)3