Search in sources :

Example 81 with Person

use of org.kuali.kfs.kim.api.identity.Person in project cu-kfs by CU-CommunityApps.

the class PaymentApplicationForm method userCanInitiateAppAdjustment.

private boolean userCanInitiateAppAdjustment() {
    final Document document = getDocument();
    final DocumentAuthorizer documentAuthorizer = SpringContext.getBean(DocumentHelperService.class).getDocumentAuthorizer(document);
    final Person person = GlobalVariables.getUserSession().getPerson();
    return documentAuthorizer.canInitiate(ArConstants.PAYMENT_APPLICATION_ADJUSTMENT_DOCUMENT_TYPE_CODE, person);
}
Also used : DocumentAuthorizer(org.kuali.kfs.kns.document.authorization.DocumentAuthorizer) Document(org.kuali.kfs.krad.document.Document) CustomerInvoiceDocument(org.kuali.kfs.module.ar.document.CustomerInvoiceDocument) PaymentApplicationDocument(org.kuali.kfs.module.ar.document.PaymentApplicationDocument) CashControlDocument(org.kuali.kfs.module.ar.document.CashControlDocument) WorkflowDocument(org.kuali.kfs.kew.api.WorkflowDocument) Person(org.kuali.kfs.kim.api.identity.Person) DocumentHelperService(org.kuali.kfs.kns.service.DocumentHelperService)

Example 82 with Person

use of org.kuali.kfs.kim.api.identity.Person in project cu-kfs by CU-CommunityApps.

the class ContractsGrantsInvoiceDocumentServiceImpl method addInvoiceTransmissionNote.

@Override
public void addInvoiceTransmissionNote(ContractsGrantsInvoiceDocument document, String invoiceTransmissionMethod) {
    Note note = new Note();
    note.setNotePostedTimestampToCurrent();
    String transmissionNotePattern = getConfigurationService().getPropertyValueAsString(ArKeyConstants.INVOICE_ADDRESS_TRANSMISSION_NOTE);
    note.setNoteText(MessageFormat.format(transmissionNotePattern, GlobalVariables.getUserSession().getPrincipalName(), invoiceTransmissionMethod.toLowerCase(Locale.US)));
    note.setNoteTypeCode(document.getNoteType().getCode());
    Person systemUser = personService.getPersonByPrincipalName(KFSConstants.SYSTEM_USER);
    note = noteService.createNote(note, document.getNoteTarget(), systemUser.getPrincipalId());
    noteService.save(note);
    document.addNote(note);
}
Also used : Note(org.kuali.kfs.krad.bo.Note) Person(org.kuali.kfs.kim.api.identity.Person)

Example 83 with Person

use of org.kuali.kfs.kim.api.identity.Person in project cu-kfs by CU-CommunityApps.

the class ContractsGrantsInvoiceDocumentServiceImpl method buildAndAddInvoiceNote.

private Long buildAndAddInvoiceNote(ContractsGrantsInvoiceDocument document, byte[] reportStream, String customerAddressName, String outputFileName, String invoiceAddressPdfFinalNote, String watermarkText) throws IOException {
    Note note = new Note();
    note.setNotePostedTimestampToCurrent();
    final String finalNotePattern = getConfigurationService().getPropertyValueAsString(invoiceAddressPdfFinalNote);
    note.setNoteText(MessageFormat.format(finalNotePattern, document.getDocumentNumber(), customerAddressName));
    note.setNoteTypeCode(KFSConstants.NoteTypeEnum.BUSINESS_OBJECT_NOTE_TYPE.getCode());
    Person systemUser = personService.getPersonByPrincipalName(KFSConstants.SYSTEM_USER);
    note = noteService.createNote(note, document.getNoteTarget(), systemUser.getPrincipalId());
    if (StringUtils.isNotBlank(watermarkText)) {
        try {
            reportStream = PdfFormFillerUtil.createWatermarkOnFile(reportStream, watermarkText);
        } catch (DocumentException e) {
            addNoteForInvoiceReportFail(document);
        }
    }
    Attachment attachment = attachmentService.createAttachment(note, outputFileName, ArConstants.TemplateUploadSystem.TEMPLATE_MIME_TYPE, reportStream.length, new ByteArrayInputStream(reportStream), KFSConstants.EMPTY_STRING);
    note.setAttachment(attachment);
    noteService.save(note);
    attachment.setNoteIdentifier(note.getNoteIdentifier());
    businessObjectService.save(attachment);
    document.addNote(note);
    return note.getNoteIdentifier();
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) Note(org.kuali.kfs.krad.bo.Note) DocumentException(com.lowagie.text.DocumentException) Attachment(org.kuali.kfs.krad.bo.Attachment) Person(org.kuali.kfs.kim.api.identity.Person)

Example 84 with Person

use of org.kuali.kfs.kim.api.identity.Person in project cu-kfs by CU-CommunityApps.

the class MaintenanceUtils method checkDocumentBlockingDocumentId.

public static void checkDocumentBlockingDocumentId(String blockingDocId, boolean throwExceptionIfLocked) {
    // if we got nothing, then no docs are blocking, and we're done
    if (StringUtils.isBlank(blockingDocId)) {
        return;
    }
    if (MaintenanceUtils.LOG.isInfoEnabled()) {
        MaintenanceUtils.LOG.info("Locking document found:  docId = " + blockingDocId + ".");
    }
    // load the blocking locked document
    WorkflowDocument lockedDocument = null;
    try {
        // occur, even though the exception would be caught here
        if (KewApiServiceLocator.getWorkflowDocumentService().doesDocumentExist(blockingDocId)) {
            /*
                 * CU Customization KFSPTS-23120 investigate NPE
                 * Moved the getPerson to a variable to more clearly see what aspect is causing the NPE
                 */
            try {
                Person person = GlobalVariables.getUserSession().getPerson();
                lockedDocument = KewApiServiceLocator.getWorkflowDocumentService().loadWorkflowDocument(blockingDocId, person);
            } catch (NullPointerException npe) {
                LOG.error("checkDocumentBlockingDocumentId, caught an NPE getting the locked document with blockingDocId: " + blockingDocId, npe);
                throw npe;
            }
        }
    } catch (Exception ex) {
        // clean up the lock and notify the admins
        MaintenanceUtils.LOG.error("Unable to retrieve locking document specified in the maintenance lock " + "table: " + blockingDocId, ex);
        cleanOrphanLocks(blockingDocId, ex);
        return;
    }
    if (lockedDocument == null) {
        MaintenanceUtils.LOG.warn("Locking document header for " + blockingDocId + "came back null.");
        cleanOrphanLocks(blockingDocId, null);
    }
    // if we can ignore the lock (see method notes), then exit cause we're done
    if (lockCanBeIgnored(lockedDocument)) {
        return;
    }
    // build the link URL for the blocking document
    Map<String, String> parameters = new HashMap<>();
    parameters.put(KRADConstants.PARAMETER_DOC_ID, blockingDocId);
    parameters.put(KRADConstants.PARAMETER_COMMAND, KRADConstants.METHOD_DISPLAY_DOC_SEARCH_VIEW);
    String blockingUrl = UrlFactory.parameterizeUrl(KRADServiceLocator.getKualiConfigurationService().getPropertyValueAsString(KFSConstants.APPLICATION_URL_KEY) + "/" + KRADConstants.DOC_HANDLER_ACTION, parameters);
    if (MaintenanceUtils.LOG.isDebugEnabled()) {
        MaintenanceUtils.LOG.debug("blockingUrl = '" + blockingUrl + "'");
        MaintenanceUtils.LOG.debug("Maintenance record: " + lockedDocument.getApplicationDocumentId() + "is locked.");
    }
    String[] errorParameters = { blockingUrl, blockingDocId };
    // ErrorMap instead.
    if (throwExceptionIfLocked) {
        // post an error about the locked document
        GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS, KFSKeyConstants.ERROR_MAINTENANCE_LOCKED, errorParameters);
        throw new ValidationException("Maintenance Record is locked by another document.");
    } else {
        // Post a warning about the locked document.
        GlobalVariables.getMessageMap().putWarning(KRADConstants.GLOBAL_MESSAGES, WARNING_MAINTENANCE_LOCKED, errorParameters);
    }
}
Also used : ValidationException(org.kuali.kfs.krad.exception.ValidationException) WorkflowDocument(org.kuali.kfs.kew.api.WorkflowDocument) HashMap(java.util.HashMap) Person(org.kuali.kfs.kim.api.identity.Person) ValidationException(org.kuali.kfs.krad.exception.ValidationException)

Aggregations

Person (org.kuali.kfs.kim.api.identity.Person)84 ArrayList (java.util.ArrayList)11 PersonService (org.kuali.kfs.kim.api.identity.PersonService)11 HashMap (java.util.HashMap)9 Note (org.kuali.kfs.krad.bo.Note)9 CuDisbursementVoucherDocument (edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument)8 WorkflowDocument (org.kuali.kfs.kew.api.WorkflowDocument)6 AdHocRoutePerson (org.kuali.kfs.krad.bo.AdHocRoutePerson)6 DateTimeService (org.kuali.kfs.core.api.datetime.DateTimeService)5 KualiDecimal (org.kuali.kfs.core.api.util.type.KualiDecimal)5 VendorDetail (org.kuali.kfs.vnd.businessobject.VendorDetail)5 DisbursementVoucherDocument (org.kuali.kfs.fp.document.DisbursementVoucherDocument)4 WorkflowException (org.kuali.kfs.kew.api.exception.WorkflowException)4 CustomerProfile (org.kuali.kfs.pdp.businessobject.CustomerProfile)4 IWantDocument (edu.cornell.kfs.module.purap.document.IWantDocument)3 PayeeACHAccount (org.kuali.kfs.pdp.businessobject.PayeeACHAccount)3 Bank (org.kuali.kfs.sys.businessobject.Bank)3 ChartOrgHolder (org.kuali.kfs.sys.businessobject.ChartOrgHolder)3 AccountingXmlDocumentNote (edu.cornell.kfs.fp.batch.xml.AccountingXmlDocumentNote)2 CuDisbursementPayee (edu.cornell.kfs.fp.businessobject.CuDisbursementPayee)2