use of org.mifos.dto.screen.OfficeDetailsForEdit in project head by mifos.
the class OfficeServiceFacadeWebTier method retrieveOfficeDetailsForEdit.
@Override
public OfficeDetailsForEdit retrieveOfficeDetailsForEdit(String officeLevel) {
List<OfficeDetailsDto> parents = new ArrayList<OfficeDetailsDto>();
if (StringUtils.isNotBlank(officeLevel)) {
parents = retrieveActiveParentOffices(Short.valueOf(officeLevel));
}
try {
List<OfficeDetailsDto> configuredOfficeLevels = new OfficePersistence().getActiveLevels();
for (OfficeDetailsDto officeDetailsDto : configuredOfficeLevels) {
String levelName = ApplicationContextProvider.getBean(MessageLookup.class).lookup(officeDetailsDto.getLevelNameKey());
officeDetailsDto.setLevelName(levelName);
}
List<OfficeDetailsDto> statusList = new OfficePersistence().getStatusList();
for (OfficeDetailsDto officeDetailsDto : statusList) {
officeDetailsDto.setLevelName(ApplicationContextProvider.getBean(MessageLookup.class).lookup(officeDetailsDto.getLevelNameKey()));
}
return new OfficeDetailsForEdit(parents, statusList, configuredOfficeLevels);
} catch (PersistenceException e) {
throw new MifosRuntimeException(e);
}
}
use of org.mifos.dto.screen.OfficeDetailsForEdit in project head by mifos.
the class OffAction method edit.
@TransactionDemarcate(joinToken = true)
public ActionForward edit(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
OffActionForm offActionForm = (OffActionForm) form;
OfficeDto sessionOffice = (OfficeDto) SessionUtils.getAttribute(OfficeConstants.OFFICE_DTO, request);
OfficeBO office = this.officeDao.findOfficeById(sessionOffice.getOfficeId());
checkVersionMismatch(sessionOffice.getVersionNum(), office.getVersionNo());
String officeLevel = request.getParameter("officeLevel");
OfficeDetailsForEdit officeDetailsForEdit = this.officeServiceFacade.retrieveOfficeDetailsForEdit(officeLevel);
if (StringUtils.isNotBlank(officeLevel)) {
offActionForm.setOfficeLevel(officeLevel);
List<OfficeDetailsDto> parents = this.officeServiceFacade.retrieveActiveParentOffices(Short.valueOf(officeLevel));
OfficeDto office1 = (OfficeDto) SessionUtils.getAttribute(OfficeConstants.OFFICE_DTO, request);
if (offActionForm.getInput() != null && offActionForm.getInput().equals("edit") && office1 != null) {
for (int i = 0; i < parents.size(); i++) {
OfficeDetailsDto view = parents.get(i);
if (view.getOfficeId().equals(office1.getOfficeId())) {
parents.remove(view);
}
}
}
SessionUtils.setCollectionAttribute(OfficeConstants.PARENTS, parents, request);
}
offActionForm.setCustomFields(new ArrayList<CustomFieldDto>());
SessionUtils.setCollectionAttribute(OfficeConstants.OFFICELEVELLIST, officeDetailsForEdit.getConfiguredOfficeLevels(), request);
SessionUtils.setCollectionAttribute(OfficeConstants.OFFICESTATUSLIST, officeDetailsForEdit.getStatusList(), request);
List<CustomFieldDefinitionEntity> customFieldDefs = new ArrayList<CustomFieldDefinitionEntity>();
SessionUtils.setCollectionAttribute(CustomerConstants.CUSTOM_FIELDS_LIST, customFieldDefs, request);
return mapping.findForward(ActionForwards.edit_success.toString());
}
Aggregations