Search in sources :

Example 6 with LookUpEntity

use of org.mifos.application.master.business.LookUpEntity in project head by mifos.

the class LegacyRolesPermissionsDao method createLookUpValue.

private int createLookUpValue(DynamicLookUpValueCreationTypes type, String lookUpDescription) throws PersistenceException {
    LookUpValueEntity anLookUp = new LookUpValueEntity();
    LookUpEntity lookUpEntity = getPersistentObject(LookUpEntity.class, Short.valueOf((short) LookUpEntity.ACTIVITY));
    String lookupName = SearchUtils.generateLookupName(type.name(), lookUpDescription);
    anLookUp.setLookUpName(lookupName);
    anLookUp.setLookUpEntity(lookUpEntity);
    createOrUpdate(anLookUp);
    ApplicationContextProvider.getBean(MessageLookup.class).updateLookupValueInCache(lookupName, lookUpDescription);
    int lookUpId = anLookUp.getLookUpId().intValue();
    return lookUpId;
}
Also used : LookUpEntity(org.mifos.application.master.business.LookUpEntity) MessageLookup(org.mifos.application.master.MessageLookup) LookUpValueEntity(org.mifos.application.master.business.LookUpValueEntity)

Example 7 with LookUpEntity

use of org.mifos.application.master.business.LookUpEntity in project head by mifos.

the class LegacyRolesPermissionsDaoIntegrationTest method testShouldInsertSuccessActivity.

@Test
public void testShouldInsertSuccessActivity() throws Exception {
    Session session = StaticHibernateUtil.getSessionTL();
    short parentId = 13;
    int numberOfActivitiesBefore = session.createQuery("from ActivityEntity r where r.parent.id =" + parentId).list().size();
    RoleBO roleBo = (RoleBO) session.load(RoleBO.class, (short) RolesAndPermissionConstants.ADMIN_ROLE);
    int adminActivities = roleBo.getActivities().size();
    LookUpEntity lookUpEntity = new LookUpEntity();
    lookUpEntity.setEntityId((short) LookUpEntity.ACTIVITY);
    int lookUpId = legacyRolesPermissionsDao.createActivityForReports(parentId, "abcd");
    Assert.assertEquals("abcd", legacyMasterDao.retrieveOneLookUpValueLocaleEntity(Localization.ENGLISH_LOCALE_ID, lookUpId).getLookUpValue());
    Assert.assertEquals(legacyRolesPermissionsDao.calculateDynamicActivityId(), (int) legacyRolesPermissionsDao.getActivityEntity(lookUpId).getId() - 1);
    int numberOfActivitiesAfter = session.createQuery("from ActivityEntity r where r.parent.id =" + parentId).list().size();
    Assert.assertEquals(numberOfActivitiesBefore + 1, numberOfActivitiesAfter);
    Assert.assertEquals(adminActivities + 1, roleBo.getActivities().size());
}
Also used : LookUpEntity(org.mifos.application.master.business.LookUpEntity) Session(org.hibernate.Session) RoleBO(org.mifos.security.rolesandpermission.business.RoleBO) Test(org.junit.Test)

Example 8 with LookUpEntity

use of org.mifos.application.master.business.LookUpEntity in project head by mifos.

the class LegacyRolesPermissionsDaoIntegrationTest method insertActivityForTest.

private ActivityEntity insertActivityForTest(short activityId) throws PersistenceException {
    LookUpValueEntity anLookUp = new LookUpValueEntity();
    LookUpEntity lookUpEntity = legacyMasterDao.getPersistentObject(LookUpEntity.class, Short.valueOf((short) LookUpEntity.ACTIVITY));
    anLookUp.setLookUpEntity(lookUpEntity);
    ActivityEntity parent = legacyMasterDao.getPersistentObject(ActivityEntity.class, (short) 13);
    ActivityEntity activityEntity = new ActivityEntity(activityId, parent, anLookUp);
    legacyRolesPermissionsDao.createOrUpdate(anLookUp);
    legacyRolesPermissionsDao.createOrUpdate(activityEntity);
    return activityEntity;
}
Also used : ActivityEntity(org.mifos.security.rolesandpermission.business.ActivityEntity) LookUpEntity(org.mifos.application.master.business.LookUpEntity) LookUpValueEntity(org.mifos.application.master.business.LookUpValueEntity)

Example 9 with LookUpEntity

use of org.mifos.application.master.business.LookUpEntity in project head by mifos.

the class ApplicationConfigurationDaoHibernate method findLookupValueByEntityType.

@Override
public LookUpEntity findLookupValueByEntityType(final String entityType) {
    HashMap<String, Object> queryParameters = new HashMap<String, Object>();
    queryParameters.put("entityType", entityType);
    LookUpEntity entity = (LookUpEntity) this.genericDao.executeUniqueResultNamedQuery("findLookupEntityByEntityType", queryParameters);
    return entity;
}
Also used : LookUpEntity(org.mifos.application.master.business.LookUpEntity) HashMap(java.util.HashMap)

Example 10 with LookUpEntity

use of org.mifos.application.master.business.LookUpEntity in project head by mifos.

the class BirtReportsUploadActionStrutsTest method insertActivityForTest.

private ActivityEntity insertActivityForTest(short activityId) throws PersistenceException {
    LookUpValueEntity anLookUp = new LookUpValueEntity();
    LookUpEntity lookUpEntity = legacyMasterDao.getPersistentObject(LookUpEntity.class, Short.valueOf((short) LookUpEntity.ACTIVITY));
    anLookUp.setLookUpEntity(lookUpEntity);
    ActivityEntity parent = legacyMasterDao.getPersistentObject(ActivityEntity.class, (short) 13);
    ActivityEntity activityEntity = new ActivityEntity(activityId, parent, anLookUp);
    legacyRolesPermissionsDao.createOrUpdate(anLookUp);
    legacyRolesPermissionsDao.createOrUpdate(activityEntity);
    return activityEntity;
}
Also used : ActivityEntity(org.mifos.security.rolesandpermission.business.ActivityEntity) LookUpEntity(org.mifos.application.master.business.LookUpEntity) LookUpValueEntity(org.mifos.application.master.business.LookUpValueEntity)

Aggregations

LookUpEntity (org.mifos.application.master.business.LookUpEntity)14 LookUpValueEntity (org.mifos.application.master.business.LookUpValueEntity)8 Test (org.junit.Test)5 MessageLookup (org.mifos.application.master.MessageLookup)3 LookUpLabelEntity (org.mifos.application.master.business.LookUpLabelEntity)3 ActivityEntity (org.mifos.security.rolesandpermission.business.ActivityEntity)3 Session (org.hibernate.Session)2 LookUpValueLocaleEntity (org.mifos.application.master.business.LookUpValueLocaleEntity)2 HashMap (java.util.HashMap)1 Ignore (org.junit.Ignore)1 GracePeriodTypeEntity (org.mifos.accounts.productdefinition.business.GracePeriodTypeEntity)1 MifosRuntimeException (org.mifos.core.MifosRuntimeException)1 OfficeLevelEntity (org.mifos.customers.office.business.OfficeLevelEntity)1 RoleBO (org.mifos.security.rolesandpermission.business.RoleBO)1 BusinessRuleException (org.mifos.service.BusinessRuleException)1