use of org.mifos.dto.domain.OfficeDto 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());
}
use of org.mifos.dto.domain.OfficeDto in project head by mifos.
the class OfficeServiceFacadeWebTier method retrieveBranchOnlyOfficeHierarchy.
@Override
public OnlyBranchOfficeHierarchyDto retrieveBranchOnlyOfficeHierarchy() {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
OfficeDto office = officeDao.findOfficeDtoById(user.getBranchId());
List<OfficeBO> branchParents = officeDao.findBranchsOnlyWithParentsMatching(office.getSearchId());
List<OfficeDetailsDto> levels = officeDao.findActiveOfficeLevels();
List<OfficeHierarchyDto> branchOnlyOfficeHierarchy = OfficeBO.convertToBranchOnlyHierarchyWithParentsOfficeHierarchy(branchParents);
return new OnlyBranchOfficeHierarchyDto(Locale.getDefault(), levels, office.getSearchId(), branchOnlyOfficeHierarchy);
}
use of org.mifos.dto.domain.OfficeDto 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);
}
}
use of org.mifos.dto.domain.OfficeDto in project head by mifos.
the class OfficeServiceFacadeWebTier method branchOffices.
private List<OfficeDto> branchOffices(List<OfficeDto> allOffices) {
List<OfficeDto> branchOffices = new ArrayList<OfficeDto>();
for (OfficeDto officeDto : allOffices) {
if (OfficeLevel.BRANCHOFFICE.getValue().equals(officeDto.getLevelId())) {
branchOffices.add(officeDto);
}
}
// sort branch offices by parent due to UI dependency on this.
Collections.sort(branchOffices, new Comparator<OfficeDto>() {
@Override
public int compare(OfficeDto first, OfficeDto next) {
return first.getParentId().compareTo(next.getParentId());
}
});
return branchOffices;
}
use of org.mifos.dto.domain.OfficeDto in project head by mifos.
the class OfficeServiceFacadeWebTier method retrieveOfficeById.
@Override
public OfficeDto retrieveOfficeById(Short id) {
OfficeBO officeBO = officeDao.findOfficeById(id);
List<CustomFieldDto> customFields = new ArrayList<CustomFieldDto>();
Short parentOfficeId = null;
String parentOffineName = null;
if (officeBO.getParentOffice() != null) {
parentOfficeId = officeBO.getParentOffice().getOfficeId();
parentOffineName = officeBO.getParentOffice().getOfficeName();
}
Address address = officeBO.getAddress() != null ? officeBO.getAddress().getAddress() : null;
AddressDto addressDto = address != null ? Address.toDto(officeBO.getAddress().getAddress()) : null;
String officeLevelName = ApplicationContextProvider.getBean(MessageLookup.class).lookup(officeBO.getLevel().getLookUpValue());
String officeStatusName = ApplicationContextProvider.getBean(MessageLookup.class).lookup(officeBO.getStatus().getLookUpValue());
OfficeDto officeDto = new OfficeDto(officeBO.getOfficeId(), officeBO.getOfficeName(), officeBO.getSearchId(), officeBO.getShortName(), officeBO.getGlobalOfficeNum(), parentOfficeId, officeBO.getStatus().getId(), officeBO.getLevel().getId(), parentOffineName, officeBO.getVersionNo(), officeStatusName, officeLevelName, addressDto, customFields);
return officeDto;
}
Aggregations