use of org.mifos.customers.office.persistence.OfficePersistence in project head by mifos.
the class OfficeServiceFacadeWebTier method retrieveActiveBranchesUnderUser.
@Override
public List<OfficeDto> retrieveActiveBranchesUnderUser(Short userId) {
PersonnelBO personnel = personnelDao.findPersonnelById(userId);
try {
List<OfficeBO> officesListBO = new OfficePersistence().getActiveBranchesUnderUser(personnel.getOfficeSearchId());
List<OfficeDto> officesList = new ArrayList<OfficeDto>();
for (OfficeBO officeBO : officesListBO) {
OfficeDto officeDto = new OfficeDto(officeBO.getOfficeId(), officeBO.getOfficeName(), officeBO.getSearchId(), officeBO.getShortName(), officeBO.getGlobalOfficeNum(), officeBO.getParentOffice().getOfficeId(), officeBO.getStatus().getId(), officeBO.getLevel().getId());
officesList.add(officeDto);
}
return officesList;
} catch (PersistenceException e) {
throw new MifosRuntimeException(e);
}
}
use of org.mifos.customers.office.persistence.OfficePersistence 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.customers.office.persistence.OfficePersistence in project head by mifos.
the class OfficeServiceFacadeWebTier method generateSearchId.
private String generateSearchId(OfficeBO parentOffice) throws OfficeException {
Integer noOfChildern;
try {
noOfChildern = new OfficePersistence().getChildCount(parentOffice.getOfficeId());
} catch (PersistenceException e) {
throw new OfficeException(e);
}
String parentSearchId = HierarchyManager.getInstance().getSearchId(parentOffice.getOfficeId());
parentSearchId += ++noOfChildern;
parentSearchId += ".";
return parentSearchId;
}
use of org.mifos.customers.office.persistence.OfficePersistence in project head by mifos.
the class OfficeServiceFacadeWebTier method retrieveActiveParentOffices.
@Override
public List<OfficeDetailsDto> retrieveActiveParentOffices(Short officeLevelId) {
OfficeLevel Level = OfficeLevel.getOfficeLevel(officeLevelId);
try {
List<OfficeDetailsDto> officeParents = new OfficePersistence().getActiveParents(Level);
for (OfficeDetailsDto officeDetailsDto : officeParents) {
String levelName = ApplicationContextProvider.getBean(MessageLookup.class).lookup(officeDetailsDto.getLevelNameKey());
officeDetailsDto.setLevelName(levelName);
}
return officeParents;
} catch (PersistenceException e) {
throw new MifosRuntimeException(e);
}
}
use of org.mifos.customers.office.persistence.OfficePersistence in project head by mifos.
the class CustomerPersistence method mainSearch.
private QueryResult mainSearch(final String searchString, final Short officeId, final Short userId, final Short userOfficeId, final SearchFiltersDto filters) throws PersistenceException, HibernateSearchException {
String[] namedQuery = new String[2];
List<Param> paramList = new ArrayList<Param>();
QueryInputs queryInputs = setQueryInputsValues(namedQuery, paramList);
QueryResult queryResult = QueryFactory.getQueryResult(CustomerSearchConstants.CUSTOMERSEARCHRESULTS);
if (officeId.shortValue() != 0) {
namedQuery[0] = NamedQueryConstants.CUSTOMER_SEARCH_COUNT;
namedQuery[1] = NamedQueryConstants.CUSTOMER_SEARCH;
paramList.add(typeNameValue("Short", "OFFICEID", officeId));
} else {
namedQuery[0] = NamedQueryConstants.CUSTOMER_SEARCH_COUNT_NOOFFICEID;
namedQuery[1] = NamedQueryConstants.CUSTOMER_SEARCH_NOOFFICEID;
paramList.add(typeNameValue("String", "OFFICE_SEARCH_ID", new OfficePersistence().getOffice(userOfficeId).getSearchId() + "%"));
}
paramList.add(typeNameValue("String", "SEARCH_STRING", "%" + searchString + "%"));
if (searchString.contains(" ")) {
List<String> words = new ArrayList<String>(Arrays.asList(searchString.split(" +")));
// strings to get exactly 3 words
if (words.size() > 3) {
for (int i = 3; i < words.size(); ++i) {
words.set(2, words.get(2) + " " + words.get(i));
}
words = words.subList(0, 3);
} else if (words.size() < 3) {
int elementsToAdd = 3 - words.size();
for (int i = 0; i < elementsToAdd; ++i) {
words.add("");
}
}
paramList.add(typeNameValue("String", "SEARCH_STRING1", "%" + words.get(0) + "%"));
paramList.add(typeNameValue("String", "SEARCH_STRING2", "%" + words.get(1) + "%"));
paramList.add(typeNameValue("String", "SEARCH_STRING3", "%" + words.get(2) + "%"));
} else {
paramList.add(typeNameValue("String", "SEARCH_STRING1", searchString));
paramList.add(typeNameValue("String", "SEARCH_STRING2", ""));
paramList.add(typeNameValue("String", "SEARCH_STRING3", ""));
}
setParams(paramList, userId);
setSearchFilters(paramList, filters);
queryResult.setQueryInputs(queryInputs);
return queryResult;
}
Aggregations