use of org.mifos.dto.screen.OfficeFormDto in project head by mifos.
the class OffAction method load.
@TransactionDemarcate(saveToken = true)
public ActionForward load(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
OffActionForm actionForm = (OffActionForm) form;
actionForm.clear();
String officeLevel = request.getParameter("officeLevel");
Short officeLevelId = null;
if (StringUtils.isNotBlank(officeLevel)) {
officeLevelId = Short.valueOf(officeLevel);
}
OfficeFormDto officeFormDto = this.officeServiceFacade.retrieveOfficeFormInformation(officeLevelId);
if (StringUtils.isNotBlank(officeLevel)) {
actionForm.setOfficeLevel(officeLevel);
OfficeDto office = (OfficeDto) SessionUtils.getAttribute(OfficeConstants.OFFICE_DTO, request);
List<OfficeDto> validParentOffices = new ArrayList<OfficeDto>();
if (actionForm.getInput() != null && actionForm.getInput().equals("edit") && office != null) {
for (OfficeDto view : officeFormDto.getParents()) {
if (!view.getId().equals(office.getOfficeId())) {
validParentOffices.add(view);
}
}
} else {
validParentOffices.addAll(officeFormDto.getParents());
}
SessionUtils.setCollectionAttribute(OfficeConstants.PARENTS, validParentOffices, request);
}
actionForm.setCustomFields(officeFormDto.getCustomFields());
SessionUtils.setCollectionAttribute(CustomerConstants.CUSTOM_FIELDS_LIST, officeFormDto.getCustomFields(), request);
SessionUtils.setCollectionAttribute(OfficeConstants.OFFICELEVELLIST, officeFormDto.getOfficeLevels(), request);
SessionUtils.setAttribute(CustomerConstants.URL_MAP, null, request.getSession(false));
return mapping.findForward(ActionForwards.load_success.toString());
}
use of org.mifos.dto.screen.OfficeFormDto in project head by mifos.
the class OfficeServiceFacadeWebTier method retrieveOfficeFormInformation.
@Override
public OfficeFormDto retrieveOfficeFormInformation(Short officeLevelId) {
try {
List<CustomFieldDto> customFields = new ArrayList<CustomFieldDto>();
OfficeLevel officeLevel = OfficeLevel.HEADOFFICE;
if (officeLevelId != null) {
officeLevel = OfficeLevel.getOfficeLevel(officeLevelId);
}
List<OfficeDto> parents = this.officeDao.findActiveParents(officeLevel);
for (OfficeDto office : parents) {
String levelName = ApplicationContextProvider.getBean(MessageLookup.class).lookup(office.getLookupNameKey());
office.setLevelName(levelName);
}
List<OfficeDetailsDto> officeLevels = new OfficePersistence().getActiveLevels();
for (OfficeDetailsDto officeDetailsDto : officeLevels) {
String levelName = ApplicationContextProvider.getBean(MessageLookup.class).lookup(officeDetailsDto.getLevelNameKey());
officeDetailsDto.setLevelName(levelName);
}
return new OfficeFormDto(customFields, parents, officeLevels);
} catch (PersistenceException e) {
throw new MifosRuntimeException(e);
}
}
Aggregations