Search in sources :

Example 41 with Note

use of org.kuali.kfs.krad.bo.Note in project cu-kfs by CU-CommunityApps.

the class AmazonWebServicesBillingServiceImpl method buildDINote.

private Note buildDINote() {
    Note diNote = new Note();
    diNote.setNoteText(getHelpNoteText());
    diNote.setAuthorUniversalIdentifier(GlobalVariables.getUserSession().getPerson().getPrincipalId());
    diNote.setNotePostedTimestampToCurrent();
    return diNote;
}
Also used : Note(org.kuali.kfs.krad.bo.Note)

Example 42 with Note

use of org.kuali.kfs.krad.bo.Note in project cu-kfs by CU-CommunityApps.

the class RecurringDisbursementVoucherDocumentServiceImpl method noteChangeOnRecurringDV.

private void noteChangeOnRecurringDV(RecurringDisbursementVoucherDocument recurringDV, String noteText, Set<String> setOfStrings) {
    if (!setOfStrings.isEmpty()) {
        Note note = buildNoteBase();
        note.setNoteText(noteText + StringUtils.join(setOfStrings, ", "));
        ;
        recurringDV.addNote(note);
        try {
            getDocumentService().saveDocument(recurringDV);
        } catch (WorkflowException e) {
            throw new RuntimeException("noteChangeOnRecurringDV() Unable to save note.", e);
        }
    }
}
Also used : Note(org.kuali.kfs.krad.bo.Note) WorkflowException(org.kuali.rice.kew.api.exception.WorkflowException)

Example 43 with Note

use of org.kuali.kfs.krad.bo.Note in project cu-kfs by CU-CommunityApps.

the class RecurringDisbursementVoucherDocumentServiceImpl method buildNoteBase.

private Note buildNoteBase() {
    Note noteBase = new Note();
    noteBase.setAuthorUniversalIdentifier(GlobalVariables.getUserSession().getPerson().getPrincipalId());
    noteBase.setNotePostedTimestampToCurrent();
    return noteBase;
}
Also used : Note(org.kuali.kfs.krad.bo.Note)

Example 44 with Note

use of org.kuali.kfs.krad.bo.Note in project cu-kfs by CU-CommunityApps.

the class PurchaseOrderDocument method appSpecificRouteDocumentToUser.

/**
 * Sends FYI workflow request to the given user on this document.
 *
 * @param workflowDocument the associated workflow document.
 * @param routePrincipalId the network ID of the user to be sent to.
 * @param annotation the annotation notes contained in this document.
 * @param responsibility the responsibility specified in the request.
 * @throws WorkflowException
 */
public void appSpecificRouteDocumentToUser(WorkflowDocument workflowDocument, String routePrincipalId, String annotation, String responsibility) throws WorkflowException {
    if (ObjectUtils.isNotNull(workflowDocument)) {
        boolean isActiveUser = this.isActiveUser(routePrincipalId);
        Map<String, String> permissionDetails = new HashMap<String, String>();
        permissionDetails.put(KimConstants.AttributeConstants.DOCUMENT_TYPE_NAME, workflowDocument.getDocumentTypeName());
        permissionDetails.put(KimConstants.AttributeConstants.ACTION_REQUEST_CD, KewApiConstants.ACTION_REQUEST_FYI_REQ);
        boolean canReceiveAdHocRequest = KimApiServiceLocator.getPermissionService().isAuthorizedByTemplate(routePrincipalId, KewApiConstants.KEW_NAMESPACE, KewApiConstants.AD_HOC_REVIEW_PERMISSION, permissionDetails, new HashMap<String, String>());
        if (!isActiveUser || !canReceiveAdHocRequest) {
            String principalName = SpringContext.getBean(PersonService.class).getPerson(routePrincipalId).getName();
            String errorText = "cannot send FYI to the user: " + principalName + "; Annotation: " + annotation;
            LOG.info(errorText);
            Note note = SpringContext.getBean(DocumentService.class).createNoteFromDocument(this, errorText);
            this.addNote(SpringContext.getBean(NoteService.class).save(note));
        } else {
            String annotationNote = (ObjectUtils.isNull(annotation)) ? "" : annotation;
            String responsibilityNote = (ObjectUtils.isNull(responsibility)) ? "" : responsibility;
            String currentNodeName = getCurrentRouteNodeName(workflowDocument);
            workflowDocument.adHocToPrincipal(ActionRequestType.FYI, currentNodeName, annotationNote, routePrincipalId, responsibilityNote, true);
        }
    }
}
Also used : HashMap(java.util.HashMap) Note(org.kuali.kfs.krad.bo.Note) WorkflowDocumentService(org.kuali.kfs.krad.workflow.service.WorkflowDocumentService) DocumentService(org.kuali.kfs.krad.service.DocumentService)

Example 45 with Note

use of org.kuali.kfs.krad.bo.Note in project cu-kfs by CU-CommunityApps.

the class VendorBatchServiceImpl method loadDocumentAttachments.

/*
	 * add 'attachments' to vendor document.  attachment file names is in input csv file.
	 * Attachment files are upload to "staging.directory"/vendorBatch/attachment folder
	 */
private void loadDocumentAttachments(Document document, List<String> attachments) {
    String attachmentsPath = new File(batchInputFileTypes.get(0).getDirectoryPath()).toString() + "/attachment";
    for (String attachment : attachments) {
        Note note = new Note();
        note.setNoteText("Procurement vendor batch process - add attachment");
        note.setRemoteObjectIdentifier(document.getObjectId());
        note.setAuthorUniversalIdentifier(getSystemUser().getPrincipalId());
        note.setNoteTypeCode(KFSConstants.NoteTypeEnum.BUSINESS_OBJECT_NOTE_TYPE.getCode());
        note.setNotePostedTimestampToCurrent();
        // attempt to load file
        String fileName = attachmentsPath + "/" + attachment;
        File attachmentFile = new File(fileName);
        if (!attachmentFile.exists()) {
            continue;
        }
        try {
            FileInputStream fileInputStream = new FileInputStream(fileName);
            Integer fileSize = Integer.parseInt(Long.toString(attachmentFile.length()));
            // TODO : Files.probeContentType is supported by java 7.  Not sure if this will be an issue
            String mimeTypeCode = getMimeTypeFromAttachmentFile(attachmentFile);
            // TODO : urlconnection is working for java 7 and under, but it return null for 'docx/pptx/xslx'
            // String type = URLConnection.guessContentTypeFromName(attachmentFile.getAbsolutePath());
            LOG.info("Mime type " + fileName + " " + mimeTypeCode);
            String attachType = KFSConstants.EMPTY_STRING;
            Attachment noteAttachment = attachmentService.createAttachment(document.getDocumentHeader(), attachment, mimeTypeCode, fileSize, fileInputStream, attachType);
            note.addAttachment(noteAttachment);
            document.addNote(note);
        } catch (FileNotFoundException e) {
            continue;
        } catch (IOException e1) {
            throw new RuntimeException("Unable to create attachment for File: " + fileName, e1);
        }
    }
}
Also used : Note(org.kuali.kfs.krad.bo.Note) VendorBatchAdditionalNote(edu.cornell.kfs.vnd.businessobject.VendorBatchAdditionalNote) FileNotFoundException(java.io.FileNotFoundException) Attachment(org.kuali.kfs.krad.bo.Attachment) IOException(java.io.IOException) File(java.io.File) FileInputStream(java.io.FileInputStream)

Aggregations

Note (org.kuali.kfs.krad.bo.Note)76 Attachment (org.kuali.kfs.krad.bo.Attachment)14 WorkflowException (org.kuali.rice.kew.api.exception.WorkflowException)12 IOException (java.io.IOException)9 FileNotFoundException (java.io.FileNotFoundException)7 ArrayList (java.util.ArrayList)7 NoteService (org.kuali.kfs.krad.service.NoteService)7 FileInputStream (java.io.FileInputStream)6 KualiDocumentFormBase (org.kuali.kfs.kns.web.struts.form.KualiDocumentFormBase)6 NonTransactional (org.kuali.kfs.sys.service.NonTransactional)6 File (java.io.File)5 Iterator (java.util.Iterator)5 DocumentService (org.kuali.kfs.krad.service.DocumentService)5 Person (org.kuali.rice.kim.api.identity.Person)5 NoteExtendedAttribute (edu.cornell.kfs.sys.businessobject.NoteExtendedAttribute)4 SimpleDateFormat (java.text.SimpleDateFormat)4 Document (org.kuali.kfs.krad.document.Document)4 PurchaseOrderDocument (org.kuali.kfs.module.purap.document.PurchaseOrderDocument)4 HashMap (java.util.HashMap)3 List (java.util.List)3