Search in sources :

Example 1 with PersonImpl

use of org.kuali.kfs.kim.impl.identity.PersonImpl in project cu-kfs by CU-CommunityApps.

the class SubmitTripWebServiceImpl method buildDisbursementVoucher.

/**
 * @param dvDescription
 * @param dvExplanation
 * @param tripNumber
 * @param travelerNetId
 * @param initiatorNetId
 * @param totalAmount
 * @param checkStubText
 * @return
 * @throws Exception
 */
private String buildDisbursementVoucher(String dvDescription, String dvExplanation, String tripNumber, String travelerNetId, String initiatorNetId, double totalAmount, String checkStubText) throws Exception {
    try {
        if (!isValidDocumentInitiator(initiatorNetId, DISBURSEMENT_VOUCHER)) {
            throw new RuntimeException("Initiator identified does not have permission to create a DV.");
        }
    } catch (Exception ex) {
        throw new RuntimeException("Initiator identified does not have permission to create a DV.", ex);
    }
    // create and route doc as system user
    GlobalVariables.setUserSession(new UserSession(initiatorNetId));
    MessageMap documentErrorMap = new MessageMap();
    GlobalVariables.setMessageMap(documentErrorMap);
    // Create document with description provided
    CuDisbursementVoucherDocument dvDoc = null;
    try {
        dvDoc = (CuDisbursementVoucherDocument) SpringContext.getBean(DocumentService.class).getNewDocument(DisbursementVoucherDocument.class);
    } catch (WorkflowException e) {
        throw new RuntimeException("Error creating new disbursement voucher document: " + e.getMessage(), e);
    }
    if (dvDoc != null) {
        dvDoc.getDocumentHeader().setDocumentDescription(dvDescription);
        dvDoc.getDocumentHeader().setExplanation(dvExplanation);
        dvDoc.getDocumentHeader().setOrganizationDocumentNumber(tripNumber);
        dvDoc.initiateDocument();
        // Set vendor to traveler using netID provided
        Person traveler = SpringContext.getBean(PersonService.class).getPersonByPrincipalName(travelerNetId);
        for (EntityAffiliation entityAffiliation : ((PersonImpl) traveler).getAffiliations()) {
            if (entityAffiliation.isDefaultValue()) {
                if (StringUtils.equalsIgnoreCase(entityAffiliation.getAffiliationType().getCode(), CuDisbursementVoucherConstants.PayeeAffiliations.STUDENT)) {
                    dvDoc.templateStudent(traveler);
                } else if (StringUtils.equalsIgnoreCase(entityAffiliation.getAffiliationType().getCode(), CuDisbursementVoucherConstants.PayeeAffiliations.ALUMNI)) {
                    dvDoc.templateAlumni(traveler);
                } else if (StringUtils.equalsIgnoreCase(entityAffiliation.getAffiliationType().getCode(), CuDisbursementVoucherConstants.PayeeAffiliations.FACULTY) || StringUtils.equalsIgnoreCase(entityAffiliation.getAffiliationType().getCode(), CuDisbursementVoucherConstants.PayeeAffiliations.STAFF)) {
                    dvDoc.templateEmployee(traveler);
                }
            }
        }
        dvDoc.setPayeeAssigned(true);
        dvDoc.getDvPayeeDetail().setDisbVchrPaymentReasonCode("J");
        dvDoc.setDisbVchrCheckTotalAmount(new KualiDecimal(totalAmount));
        dvDoc.setDisbVchrPaymentMethodCode("P");
        dvDoc.setDisbVchrCheckStubText(checkStubText);
        dvDoc.setTripId(tripNumber);
        dvDoc.setTripAssociationStatusCode(CULegacyTravelServiceImpl.TRIP_ASSOCIATIONS.IS_TRIP_DOC);
        // Persist document
        SpringContext.getBean(DocumentService.class).saveDocument(dvDoc);
        return dvDoc.getDocumentNumber();
    } else {
        return "";
    }
}
Also used : CuDisbursementVoucherDocument(edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument) EntityAffiliation(org.kuali.kfs.kim.impl.identity.affiliation.EntityAffiliation) PersonImpl(org.kuali.kfs.kim.impl.identity.PersonImpl) UserSession(org.kuali.kfs.krad.UserSession) WorkflowException(org.kuali.kfs.kew.api.exception.WorkflowException) PersonService(org.kuali.kfs.kim.api.identity.PersonService) KualiDecimal(org.kuali.kfs.core.api.util.type.KualiDecimal) Person(org.kuali.kfs.kim.api.identity.Person) WorkflowException(org.kuali.kfs.kew.api.exception.WorkflowException) MessageMap(org.kuali.kfs.krad.util.MessageMap) DocumentService(org.kuali.kfs.krad.service.DocumentService)

Example 2 with PersonImpl

use of org.kuali.kfs.kim.impl.identity.PersonImpl in project cu-kfs by CU-CommunityApps.

the class CuBatchInputFileServiceImplTest method testIllegalArguments.

/*
     * test several potential IllegalArgumentException
     */
public void testIllegalArguments() {
    runTestIllegalArgument();
    user = new PersonImpl();
    runTestIllegalArgument();
    batchInputFileType = new VendorInactivateConvertBatchCsvInputFileType();
    runTestIllegalArgument();
    fileContents = new InputStream() {

        @Override
        public int read() throws IOException {
            return 0;
        }
    };
    // Only allow alphanumeric
    fileUserIdentifier = " 123.abc";
    runTestIllegalArgument();
}
Also used : PersonImpl(org.kuali.kfs.kim.impl.identity.PersonImpl) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) VendorInactivateConvertBatchCsvInputFileType(edu.cornell.kfs.vnd.batch.VendorInactivateConvertBatchCsvInputFileType) IOException(java.io.IOException)

Example 3 with PersonImpl

use of org.kuali.kfs.kim.impl.identity.PersonImpl in project cu-kfs by CU-CommunityApps.

the class MockDocumentUtils method buildMockAdHocRoutePerson.

/*
     * If you use this function you must add the following annotation to your unit test
     * @PrepareForTest({MockDocumentUtils.TestAdHocRoutePerson.class})
     */
public static AdHocRoutePerson buildMockAdHocRoutePerson() {
    PowerMockito.suppress(PowerMockito.constructor(AdHocRoutePerson.class));
    TestAdHocRoutePerson adHocPerson = PowerMockito.spy(new TestAdHocRoutePerson());
    adHocPerson.setType(AdHocRouteRecipient.PERSON_TYPE);
    adHocPerson.setPerson(new PersonImpl());
    return adHocPerson;
}
Also used : PersonImpl(org.kuali.kfs.kim.impl.identity.PersonImpl) AdHocRoutePerson(org.kuali.kfs.krad.bo.AdHocRoutePerson)

Example 4 with PersonImpl

use of org.kuali.kfs.kim.impl.identity.PersonImpl in project cu-kfs by CU-CommunityApps.

the class CuDisbursementPayeeLookupableHelperServiceImpl method getPersonAsPayees.

@Override
protected List<DisbursementPayee> getPersonAsPayees(Map<String, String> fieldValues) {
    List<DisbursementPayee> payeeList = new ArrayList<DisbursementPayee>();
    Map<String, String> fieldsForLookup = this.getPersonFieldValues(fieldValues);
    List<Person> persons = SpringContext.getBean(PersonService.class).findPeople(fieldsForLookup);
    boolean warningExists = false;
    for (Person personDetail : persons) {
        for (EntityAffiliation entityAffiliation : ((PersonImpl) personDetail).getAffiliations()) {
            if (entityAffiliation.isDefaultValue()) {
                if (StringUtils.equalsIgnoreCase(entityAffiliation.getAffiliationType().getCode(), CuDisbursementVoucherConstants.PayeeAffiliations.STUDENT)) {
                    CuDisbursementPayee payee = getPayeeFromPerson(personDetail, fieldValues, CuDisbursementVoucherConstants.DV_PAYEE_TYPE_STUDENT);
                    payeeList.add(payee);
                } else if (StringUtils.equalsIgnoreCase(entityAffiliation.getAffiliationType().getCode(), CuDisbursementVoucherConstants.PayeeAffiliations.ALUMNI)) {
                    CuDisbursementPayee payee = getPayeeFromPerson(personDetail, fieldValues, CuDisbursementVoucherConstants.DV_PAYEE_TYPE_ALUMNI);
                    payeeList.add(payee);
                } else if (StringUtils.equalsIgnoreCase(entityAffiliation.getAffiliationType().getCode(), CuDisbursementVoucherConstants.PayeeAffiliations.FACULTY) || StringUtils.equalsIgnoreCase(entityAffiliation.getAffiliationType().getCode(), CuDisbursementVoucherConstants.PayeeAffiliations.STAFF)) {
                    if (StringUtils.isNotBlank(personDetail.getEmployeeStatusCode()) && (personDetail.getEmployeeStatusCode().equals(ACTIVE)) || personDetail.getEmployeeStatusCode().equals(RETIRED)) {
                        CuDisbursementPayee payee = getPayeeFromPerson(personDetail, fieldValues, KFSConstants.PaymentPayeeTypes.EMPLOYEE);
                        payeeList.add(payee);
                    } else {
                        if (GlobalVariables.getMessageMap().containsMessageKey(CUKFSKeyConstants.WARNING_DV_PAYEE_MUST_BE_ACTIVE)) {
                            warningExists = true;
                            break;
                        }
                    }
                    if (!warningExists) {
                        GlobalVariables.getMessageMap().putWarningWithoutFullErrorPath(KFSPropertyConstants.PRINCIPAL_ID, CUKFSKeyConstants.WARNING_DV_PAYEE_MUST_BE_ACTIVE);
                    }
                }
                break;
            }
        }
    }
    return payeeList;
}
Also used : EntityAffiliation(org.kuali.kfs.kim.impl.identity.affiliation.EntityAffiliation) CuDisbursementPayee(edu.cornell.kfs.fp.businessobject.CuDisbursementPayee) PersonImpl(org.kuali.kfs.kim.impl.identity.PersonImpl) PersonService(org.kuali.kfs.kim.api.identity.PersonService) ArrayList(java.util.ArrayList) CuDisbursementPayee(edu.cornell.kfs.fp.businessobject.CuDisbursementPayee) DisbursementPayee(org.kuali.kfs.fp.businessobject.DisbursementPayee) Person(org.kuali.kfs.kim.api.identity.Person)

Example 5 with PersonImpl

use of org.kuali.kfs.kim.impl.identity.PersonImpl in project cu-kfs by CU-CommunityApps.

the class PersonInquirableImpl method getSections.

/**
 * Add Role Qualifier Attributes to Roles section of Person Inquiry.
 */
@Override
public List<Section> getSections(BusinessObject businessObject) {
    List<Section> sections = new ArrayList<>();
    if (getBusinessObjectClass() == null) {
        LOG.error("Business object class not set in inquirable.");
        throw new RuntimeException("Business object class not set in inquirable.");
    }
    InquiryRestrictions inquiryRestrictions = KNSServiceLocator.getBusinessObjectAuthorizationService().getInquiryRestrictions(businessObject, GlobalVariables.getUserSession().getPerson());
    Collection<InquirySectionDefinition> inquirySections = getBusinessObjectDictionaryService().getInquirySections(getBusinessObjectClass());
    for (InquirySectionDefinition inquirySection : inquirySections) {
        String sectionId = inquirySection.getId();
        if (!inquiryRestrictions.isHiddenSectionId(sectionId)) {
            Section section = SectionBridge.toSection(this, inquirySection, businessObject, inquiryRestrictions);
            if (StringUtils.equals(sectionId, "rolesSection") || StringUtils.equals(sectionId, "delegationsSection")) {
                int memberIndex = 0;
                for (Row containerRow : section.getRows()) {
                    List<Row> containerRows = containerRow.getFields().get(0).getContainerRows();
                    Row lastRow = containerRows.get(containerRows.size() - 1);
                    // we want the new fields added before any sub-sections (i.e. container fields)
                    if (Field.CONTAINER.equals(lastRow.getField(0).getFieldType())) {
                        containerRows.addAll(containerRows.size() - 1, buildRowsWithQualifierFields(sectionId, (PersonImpl) businessObject, memberIndex));
                    } else {
                        containerRows.addAll(buildRowsWithQualifierFields(sectionId, (PersonImpl) businessObject, memberIndex));
                    }
                    memberIndex++;
                }
            }
            sections.add(section);
        }
    }
    return sections;
}
Also used : InquirySectionDefinition(org.kuali.kfs.kns.datadictionary.InquirySectionDefinition) PersonImpl(org.kuali.kfs.kim.impl.identity.PersonImpl) ArrayList(java.util.ArrayList) InquiryRestrictions(org.kuali.kfs.kns.inquiry.InquiryRestrictions) Row(org.kuali.kfs.kns.web.ui.Row) Section(org.kuali.kfs.kns.web.ui.Section)

Aggregations

PersonImpl (org.kuali.kfs.kim.impl.identity.PersonImpl)6 ArrayList (java.util.ArrayList)3 Person (org.kuali.kfs.kim.api.identity.Person)2 PersonService (org.kuali.kfs.kim.api.identity.PersonService)2 EntityAffiliation (org.kuali.kfs.kim.impl.identity.affiliation.EntityAffiliation)2 CuDisbursementPayee (edu.cornell.kfs.fp.businessobject.CuDisbursementPayee)1 CuDisbursementVoucherDocument (edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument)1 VendorInactivateConvertBatchCsvInputFileType (edu.cornell.kfs.vnd.batch.VendorInactivateConvertBatchCsvInputFileType)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 KualiDecimal (org.kuali.kfs.core.api.util.type.KualiDecimal)1 DisbursementPayee (org.kuali.kfs.fp.businessobject.DisbursementPayee)1 WorkflowException (org.kuali.kfs.kew.api.exception.WorkflowException)1 InquirySectionDefinition (org.kuali.kfs.kns.datadictionary.InquirySectionDefinition)1 InquiryRestrictions (org.kuali.kfs.kns.inquiry.InquiryRestrictions)1 Row (org.kuali.kfs.kns.web.ui.Row)1 Section (org.kuali.kfs.kns.web.ui.Section)1 UserSession (org.kuali.kfs.krad.UserSession)1