use of org.mifos.security.rolesandpermission.business.ActivityEntity in project head by mifos.
the class RoleTempleteBuilder method makeTable.
/**
* This function is recursive function helps in making the tree table
*
* @param l
* List of all activities in the system
* @param aid
* current activity id
* @param buff
* StringBuffer which would hold the table
* @param level
* level of recursion
* @param name
* name to be given to control
*/
private void makeTable(List<ActivityEntity> l, Short aid, StringBuilder buff, int level, String name) {
List<ActivityEntity> lst = childMap.get(aid);
if (lst.size() > 0) {
for (int i = 0; i < lst.size(); i++) {
buff.append("<tr >");
String name1 = name + "_" + Integer.toString(i);
for (int j = 0; j < level; j++) {
buff.append("<td bgcolor=\"#FFFFFF\" class=\"paddingleft05BottomBorder\"> </td> ");
}
buff.append("<td width=\"3%\" bgcolor=\"#FFFFFF\" class=\"paddingleft05BottomBorder\"><input name=\"" + "activity(" + nameHelper++ + ")\"" + " id=\"" + name1 + "\" type=\"checkbox\" ");
// check whether it is leaf
List<ActivityEntity> li = childMap.get(lst.get(i).getId());
Short index = getIndex(lst.get(i).getId());
if (li.size() == 0) {
buff.append("value=\"" + lst.get(i).getId().shortValue() + "\"");
} else {
buff.append(" value=\"checkbox\"");
}
// check whether checked or not
if (currentActivites.contains(lst.get(i).getId())) {
buff.append(" checked=true ");
} else if (checkedLinks.contains(lst.get(i).getId())) {
buff.append(" checked=true ");
}
buff.append(" onclick=\"doCheck(this)\" ></td>");
buff.append("<td colspan=\"");
// adding colspan for proper formatting
buff.append(maxDepth - level + "\" ");
buff.append("bgcolor=\"#FFFFFF\" class=\"paddingleft05BottomBorder\" ><span class=\"fontnormal\">");
ActivityEntity entity = l.get(index);
String activityName = ApplicationContextProvider.getBean(MessageLookup.class).lookup(entity.getActivityNameLookupValues());
entity.setActivityName(activityName);
buff.append(l.get(index).getActivityName());
buff.append("</span></td>");
buff.append("<td width=\"50%\" bgcolor=\"#FFFFFF\" class=\"paddingleft05BottomLeftBorder\" >" + "<span class=\"fontnormal\">");
String description = ApplicationContextProvider.getBean(MessageLookup.class).lookup(entity.getActivityNameLookupValues());
entity.setDescription(description);
if (StringUtils.isBlank(entity.getDescription())) {
buff.append(" ");
} else {
buff.append(entity.getDescription());
}
buff.append("</span></td></tr>");
if (li.size() == 0) {
makeActivityRestrictionRow(entity.getActivityRestrictionTypes(), buff);
}
makeTable(l, lst.get(i).getId(), buff, level + 1, name1);
}
}
}
use of org.mifos.security.rolesandpermission.business.ActivityEntity in project head by mifos.
the class BirtReportsUploadActionStrutsTest method testShouldCreateFailureWhenActivityIdOutOfRange.
@Test
public void testShouldCreateFailureWhenActivityIdOutOfRange() throws Exception {
ActivityEntity activityEntity = insertActivityForTest(Short.MIN_VALUE);
FormFile file = new MockFormFile("testFilename");
BirtReportsUploadActionForm actionForm = new BirtReportsUploadActionForm();
setRequestPathInfo("/birtReportsUploadAction.do");
addRequestParameter("method", "upload");
actionForm.setFile(file);
actionForm.setReportTitle("existingTitle");
actionForm.setReportCategoryId("1");
actionForm.setIsActive("1");
setActionForm(actionForm);
actionPerform();
verifyForward("preview_failure");
String[] errors = { ReportsConstants.ERROR_NOMOREDYNAMICACTIVITYID };
verifyActionErrors(errors);
deleteActivityForTest(activityEntity);
}
use of org.mifos.security.rolesandpermission.business.ActivityEntity in project head by mifos.
the class BirtReportsUploadActionStrutsTest method testUpgradePathNotRuined.
@Test
public void testUpgradePathNotRuined() throws Exception {
// TODO Temporary solution to avoid unsuccessful test on some machines
// Retrieve initial activities information
List<ActivityEntity> activities = new RolesPermissionsBusinessService().getActivities();
int newActivityId = activities.get(activities.size() - 1).getId() + 1;
// Upload a report creating an activity for the report
FormFile file = new MockFormFile("testFilename.rptdesign");
BirtReportsUploadActionForm actionForm = new BirtReportsUploadActionForm();
setRequestPathInfo("/birtReportsUploadAction.do");
addRequestParameter("method", "upload");
actionForm.setFile(file);
actionForm.setReportTitle("exsitTitle");
actionForm.setReportCategoryId("1");
actionForm.setIsActive("1");
setActionForm(actionForm);
actionPerform();
Assert.assertEquals(0, getErrorSize());
Assert.assertNotNull(request.getAttribute("report"));
// Simulate an future activities upgrade
AddActivity activity = null;
try {
activity = new AddActivity((short) newActivityId, SecurityConstants.ORGANIZATION_MANAGEMENT, "no name");
activity.upgrade(StaticHibernateUtil.getSessionTL().connection());
} catch (Exception e) {
legacyRolesPermissionsDao.delete(request.getAttribute("report"));
StaticHibernateUtil.flushSession();
throw e;
}
// Undo
ReportsBO report = (ReportsBO) request.getAttribute("report");
removeReport(report.getReportId());
}
use of org.mifos.security.rolesandpermission.business.ActivityEntity 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;
}
use of org.mifos.security.rolesandpermission.business.ActivityEntity in project head by mifos.
the class BirtReportsUploadActionStrutsTest method removeReport.
private void removeReport(Short reportId) throws PersistenceException {
ReportsPersistence reportPersistence = new ReportsPersistence();
reportPersistence.getSession().clear();
ReportsBO report = reportPersistence.getPersistentObject(ReportsBO.class, reportId);
ActivityEntity activityEntity = legacyRolesPermissionsDao.getPersistentObject(ActivityEntity.class, report.getActivityId());
reportPersistence.delete(report);
LookUpValueEntity anLookUp = activityEntity.getActivityNameLookupValues();
legacyRolesPermissionsDao.delete(activityEntity);
legacyRolesPermissionsDao.delete(anLookUp);
StaticHibernateUtil.flushSession();
}
Aggregations