use of org.mifos.dto.domain.PersonnelDto in project head by mifos.
the class CollectionSheetServiceFacadeWebTierTest method shouldPopulateDtoWithLoanOfficersAndPreviouslyPopulatedDataWithDto.
@SuppressWarnings("unchecked")
@Test
public void shouldPopulateDtoWithLoanOfficersAndPreviouslyPopulatedDataWithDto() throws Exception {
// setup
final Short branchId = userContext.getBranchId();
final Short levelId = OfficeLevel.BRANCHOFFICE.getValue();
final OfficeDetailsDto officeStub1 = new OfficeDetailsDto(branchId, "branchName1", levelId, Integer.valueOf(1));
final List<OfficeDetailsDto> onlyOneActiveBranch = Arrays.asList(officeStub1);
final ListItem<Short> paymentType1 = new ListItem<Short>(Short.valueOf("1"), "paymentType1");
final CollectionSheetEntryFormDto previousCollectionSheetFormDto = new CollectionSheetEntryFormDto(onlyOneActiveBranch, Arrays.<ListItem<Short>>asList(paymentType1), new ArrayList<PersonnelDto>(), new ArrayList<CustomerDto>(), Constants.YES, Constants.YES, Constants.YES);
final PersonnelDto loanOfficer1 = new PersonnelDto(Short.valueOf("1"), "LoanOfficer1");
final PersonnelDto loanOfficer2 = new PersonnelDto(Short.valueOf("2"), "LoanOfficer2");
final List<PersonnelDto> loanOfficers = Arrays.asList(loanOfficer1, loanOfficer2);
// stub interaction with DAO/Persistence layer.
when(personnelPersistence.getActiveLoanOfficersInBranch(PersonnelConstants.LOAN_OFFICER, branchId, userContext.getId(), userContext.getLevelId())).thenReturn(loanOfficers);
// exercise test
CollectionSheetEntryFormDto formDto = collectionSheetServiceFacadeWebTier.loadLoanOfficersForBranch(branchId, userContext, previousCollectionSheetFormDto);
// verification
assertThat(formDto.getLoanOfficerList(), is(loanOfficers));
// assert rest of data comes from previousDto
assertThat(formDto.getActiveBranchesList(), is(previousCollectionSheetFormDto.getActiveBranchesList()));
}
use of org.mifos.dto.domain.PersonnelDto in project head by mifos.
the class PentahoParamParser method updatePossibleValuesForParam.
private Map<String, String> updatePossibleValuesForParam(ListParameter paramDefEntry, ParameterContext paramContext, Map<String, AbstractPentahoParameter> selectedValues) throws ReportDataFactoryException {
Map<String, String> result = new HashMap<String, String>();
String id;
if (parameterIsOffice(paramDefEntry.getName())) {
ParameterValues paramValues = paramDefEntry.getValues(paramContext);
for (int i = 0; i < paramValues.getRowCount(); i++) {
String key = String.valueOf(paramValues.getKeyValue(i));
String value = String.valueOf(paramValues.getTextValue(i));
result.put(key, value);
}
} else if (parameterIsCenter(paramDefEntry.getName())) {
String keyValue = searchKey("(.*officer$)|(.*officer_id$)", selectedValues, paramDefEntry.getName());
if (!keyValue.equals("")) {
id = (String) selectedValues.get(keyValue).getParamValue();
if (!id.equals("-1")) {
List<CustomerDetailDto> customerList = ApplicationContextProvider.getBean(CenterServiceFacade.class).retrieveCustomersUnderUser(new Short(id));
for (CustomerDetailDto office : customerList) {
String key = office.getCustomerId().toString();
String value = office.getDisplayName();
result.put(key, value);
}
} else {
ParameterValues paramValues = paramDefEntry.getValues(paramContext);
for (int i = 0; i < paramValues.getRowCount(); i++) {
String key = String.valueOf(paramValues.getKeyValue(i));
String value = String.valueOf(paramValues.getTextValue(i));
result.put(key, value);
}
}
} else {
keyValue = searchKey("(selected_office$)|(.*BRANCH_NAME.*)", selectedValues, paramDefEntry.getName());
if (!keyValue.equals("")) {
id = (String) selectedValues.get(keyValue).getParamValue();
if (!id.equals("-1")) {
List<CustomerDetailDto> customerList = ApplicationContextProvider.getBean(CenterServiceFacade.class).retrieveCustomersUnderBranch(new Short(id));
for (CustomerDetailDto office : customerList) {
String key = office.getCustomerId().toString();
String value = office.getDisplayName();
result.put(key, value);
}
} else {
ParameterValues paramValues = paramDefEntry.getValues(paramContext);
for (int i = 0; i < paramValues.getRowCount(); i++) {
String key = String.valueOf(paramValues.getKeyValue(i));
String value = String.valueOf(paramValues.getTextValue(i));
result.put(key, value);
}
}
} else {
ParameterValues paramValues = paramDefEntry.getValues(paramContext);
for (int i = 0; i < paramValues.getRowCount(); i++) {
String key = String.valueOf(paramValues.getKeyValue(i));
String value = String.valueOf(paramValues.getTextValue(i));
result.put(key, value);
}
}
}
String key = "-1";
String value = "All";
result.put(key, value);
} else if (parameterIsGroup(paramDefEntry.getName())) {
String keyValue = searchKey("(.*officer*)", selectedValues, paramDefEntry.getName());
if (!keyValue.equals("")) {
id = (String) selectedValues.get(keyValue).getParamValue();
if (!id.equals("-1")) {
List<CustomerDetailDto> customerList = ApplicationContextProvider.getBean(CenterServiceFacade.class).retrieveGroupForPentahoReport(new Short(id));
for (CustomerDetailDto office : customerList) {
String key = office.getCustomerId().toString();
String value = office.getDisplayName();
result.put(key, value);
}
} else {
ParameterValues paramValues = paramDefEntry.getValues(paramContext);
for (int i = 0; i < paramValues.getRowCount(); i++) {
String key = String.valueOf(paramValues.getKeyValue(i));
String value = String.valueOf(paramValues.getTextValue(i));
result.put(key, value);
}
}
} else {
ParameterValues paramValues = paramDefEntry.getValues(paramContext);
for (int i = 0; i < paramValues.getRowCount(); i++) {
String key = String.valueOf(paramValues.getKeyValue(i));
String value = String.valueOf(paramValues.getTextValue(i));
result.put(key, value);
}
}
String key = "-1";
String value = "All";
result.put(key, value);
} else if (parameterIsOfficer(paramDefEntry.getName())) {
String keyValue = searchKey("(.*office$)|(.*office_id$)|(.*branch_id$)|(.*office$)|(.*selectedBranch.*)", selectedValues, paramDefEntry.getName());
if (!keyValue.equals("")) {
id = (String) selectedValues.get(keyValue).getParamValue();
if (!id.equals("-1")) {
ChangeAccountStatusDto changeAccountStatusDto = ApplicationContextProvider.getBean(LoanAccountServiceFacade.class).retrieveLoanOfficerDetailsForBranch(new Short(id));
List<PersonnelDto> officers = changeAccountStatusDto.getLoanOfficers();
for (PersonnelDto officer : officers) {
String key = officer.getPersonnelId().toString();
String value = officer.getDisplayName();
result.put(key, value);
}
}
String key = "-1";
String value = "All";
result.put(key, value);
}
} else {
ParameterValues paramValues = paramDefEntry.getValues(paramContext);
for (int i = 0; i < paramValues.getRowCount(); i++) {
String key = String.valueOf(paramValues.getKeyValue(i));
String value = String.valueOf(paramValues.getTextValue(i));
result.put(key, value);
}
}
return result;
}
use of org.mifos.dto.domain.PersonnelDto in project head by mifos.
the class CollectionSheetServiceFacadeWebTier method loadAllActiveBranchesAndSubsequentDataIfApplicable.
@Override
public CollectionSheetEntryFormDto loadAllActiveBranchesAndSubsequentDataIfApplicable(final UserContext userContext) {
final Short branchId = userContext.getBranchId();
final Short centerHierarchyExists = ClientRules.getCenterHierarchyExists() ? Constants.YES : Constants.NO;
List<OfficeDetailsDto> activeBranches = new ArrayList<OfficeDetailsDto>();
List<ListItem<Short>> paymentTypesDtoList = new ArrayList<ListItem<Short>>();
List<CustomerDto> customerList = new ArrayList<CustomerDto>();
List<PersonnelDto> loanOfficerList = new ArrayList<PersonnelDto>();
Short reloadFormAutomatically = Constants.YES;
final Short backDatedTransactionAllowed = Constants.NO;
try {
final List<PaymentTypeEntity> paymentTypesList = legacyMasterDao.findMasterDataEntitiesWithLocale(PaymentTypeEntity.class);
paymentTypesDtoList = convertToPaymentTypesListItemDto(paymentTypesList);
activeBranches = officePersistence.getActiveOffices(branchId);
if (activeBranches.size() == 1) {
loanOfficerList = legacyPersonnelDao.getActiveLoanOfficersInBranch(PersonnelConstants.LOAN_OFFICER, branchId, userContext.getId(), userContext.getLevelId());
if (loanOfficerList.size() == 1) {
Short customerLevel;
if (centerHierarchyExists.equals(Constants.YES)) {
customerLevel = Short.valueOf(CustomerLevel.CENTER.getValue());
} else {
customerLevel = Short.valueOf(CustomerLevel.GROUP.getValue());
}
customerList = customerPersistence.getActiveParentList(loanOfficerList.get(0).getPersonnelId(), customerLevel, branchId);
if (customerList.size() == 1) {
reloadFormAutomatically = Constants.YES;
}
reloadFormAutomatically = Constants.NO;
}
}
} catch (PersistenceException e) {
throw new MifosRuntimeException(e);
}
return new CollectionSheetEntryFormDto(activeBranches, paymentTypesDtoList, loanOfficerList, customerList, reloadFormAutomatically, centerHierarchyExists, backDatedTransactionAllowed);
}
use of org.mifos.dto.domain.PersonnelDto in project head by mifos.
the class ClientServiceFacadeWebTier method retrieveMfiInfoForEdit.
@Override
public ClientMfiInfoDto retrieveMfiInfoForEdit(String clientSystemId) {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = toUserContext(user);
ClientBO client = this.customerDao.findClientBySystemId(clientSystemId);
String groupDisplayName = "";
String centerDisplayName = "";
if (client.getParentCustomer() != null) {
groupDisplayName = client.getParentCustomer().getDisplayName();
if (client.getParentCustomer().getParentCustomer() != null) {
centerDisplayName = client.getParentCustomer().getParentCustomer().getDisplayName();
}
}
List<PersonnelDto> loanOfficersList = new ArrayList<PersonnelDto>();
if (!client.isClientUnderGroup()) {
CenterCreation centerCreation = new CenterCreation(client.getOffice().getOfficeId(), userContext.getId(), userContext.getLevelId(), userContext.getPreferredLocale());
loanOfficersList = this.personnelDao.findActiveLoanOfficersForOffice(centerCreation);
}
CustomerDetailDto customerDetail = client.toCustomerDetailDto();
ClientDetailDto clientDetail = client.toClientDetailDto(ClientRules.isFamilyDetailsRequired());
return new ClientMfiInfoDto(groupDisplayName, centerDisplayName, loanOfficersList, customerDetail, clientDetail);
}
use of org.mifos.dto.domain.PersonnelDto in project head by mifos.
the class ClientServiceFacadeWebTier method retreiveClientDetailsForRemovalFromGroup.
@Override
public ClientRemovalFromGroupDto retreiveClientDetailsForRemovalFromGroup(String globalCustNum) {
try {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = toUserContext(user);
ClientBO client = this.customerDao.findClientBySystemId(globalCustNum);
client.updateDetails(userContext);
client.checkIfClientIsATitleHolder();
List<OfficeDetailsDto> activeBranches = this.officeDao.findActiveBranches(userContext.getBranchId());
boolean isCenterHierarchyExists = ClientRules.getCenterHierarchyExists();
boolean isActive = client.isActive();
Short loanOfficerId = client.getPersonnel().getPersonnelId();
CenterCreation clientDetails = new CenterCreation(client.getOfficeId(), userContext.getId(), userContext.getLevelId(), userContext.getPreferredLocale());
List<PersonnelDto> loanOfficers = this.personnelDao.findActiveLoanOfficersForOffice(clientDetails);
return new ClientRemovalFromGroupDto(client.getGlobalCustNum(), isActive, isCenterHierarchyExists, loanOfficerId, loanOfficers, activeBranches);
} catch (CustomerException e) {
throw new BusinessRuleException(e.getKey(), e);
}
}
Aggregations