当前位置: 首页>>代码示例>>Java>>正文


Java Note.getAttachment方法代码示例

本文整理汇总了Java中org.kuali.rice.krad.bo.Note.getAttachment方法的典型用法代码示例。如果您正苦于以下问题:Java Note.getAttachment方法的具体用法?Java Note.getAttachment怎么用?Java Note.getAttachment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.kuali.rice.krad.bo.Note的用法示例。


在下文中一共展示了Note.getAttachment方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: moveAttachmentWherePending

import org.kuali.rice.krad.bo.Note; //导入方法依赖的package包/类
@Override
public void moveAttachmentWherePending(Note note) {
   	if (note == null) {
   		throw new IllegalArgumentException("Note must be non-null");
   	}
   	if (StringUtils.isBlank(note.getObjectId())) {
   		throw new IllegalArgumentException("Note does not have a valid object id, object id was null or empty");
   	}
   	Attachment attachment = note.getAttachment();
   	if(attachment!=null){
   		try {
   			moveAttachmentFromPending(attachment, note.getRemoteObjectIdentifier());
   		}
   		catch (IOException e) {
   			throw new RuntimeException("Problem moving pending attachment to final directory");
   		}
   	}
   }
 
开发者ID:kuali,项目名称:kc-rice,代码行数:19,代码来源:AttachmentServiceImpl.java

示例2: save

import org.kuali.rice.krad.bo.Note; //导入方法依赖的package包/类
/**
    * @see org.kuali.rice.krad.service.NoteService#save(org.kuali.rice.krad.bo.Note)
    */
   @Override
public Note save(Note note) {
   	validateNoteNotNull(note);
   	if (StringUtils.isBlank(note.getRemoteObjectIdentifier())) {
   		throw new IllegalStateException("The remote object identifier must be established on a Note before it can be saved.  Given note had a null or empty remote object identifier.");
   	}
       if (note.getAttachment() != null && note.getAttachment().getAttachmentFileName() == null) {
           note.setAttachment(null);
       }
       if (note != null && note.getNoteIdentifier() == null && note.getAttachment() != null) {
           Attachment attachment = note.getAttachment();
           note.setAttachment(null);
           // store without attachment
           note = dataObjectService.save(note);
           attachment.setNoteIdentifier(note.getNoteIdentifier());
           // put attachment back
           note.setAttachment(attachment);
       }
       note = dataObjectService.save(note);
       // move attachment from pending directory
       if (note.getAttachment() != null) {
       	attachmentService.moveAttachmentWherePending(note);
       }
       return note;
   }
 
开发者ID:kuali,项目名称:kc-rice,代码行数:29,代码来源:NoteServiceImpl.java

示例3: downloadBOAttachment

import org.kuali.rice.krad.bo.Note; //导入方法依赖的package包/类
/**
 * Downloads the selected attachment to the user's browser
 *
 * @param mapping
 * @param form
 * @param request
 * @param response
 * @return ActionForward
 * @throws Exception
 */
public ActionForward downloadBOAttachment(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    Long noteIdentifier = Long.valueOf(request.getParameter(KRADConstants.NOTE_IDENTIFIER));

    Note note = this.getNoteService().getNoteByNoteId(noteIdentifier);
    if(note != null){
    	Attachment attachment = note.getAttachment();
    	if(attachment != null){
    		//make sure attachment is setup with backwards reference to note (rather then doing this we could also just call the attachment service (with a new method that took in the note)
    		attachment.setNote(note);
    		WebUtils.saveMimeInputStreamAsFile(response, attachment.getAttachmentMimeTypeCode(), attachment.getAttachmentContents(), attachment.getAttachmentFileName(), attachment.getAttachmentFileSize().intValue());
    	}
    	return null;
    }
    
    return mapping.findForward(RiceConstants.MAPPING_BASIC);
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:27,代码来源:KualiInquiryAction.java

示例4: downloadBOAttachment

import org.kuali.rice.krad.bo.Note; //导入方法依赖的package包/类
/**
 * Downloads the selected attachment to the user's browser
 *
 * @param mapping
 * @param form
 * @param request
 * @param response
 * @return ActionForward
 * @throws Exception
 */
public ActionForward downloadBOAttachment(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    KualiDocumentFormBase documentForm = (KualiDocumentFormBase) form;

    int attachmentIndex = selectedAttachmentIndex(request);
    if (attachmentIndex >= 0) {
        Note note = documentForm.getDocument().getNote(attachmentIndex);
        Attachment attachment = note.getAttachment();
        //make sure attachment is setup with backwards reference to note (rather then doing this we could also just call the attachment service (with a new method that took in the note)
        attachment.setNote(note);

        // since we're downloading a file, all of the editable properties from the previous request will continue to be editable.
        documentForm.copyPopulateEditablePropertiesToActionEditableProperties();

        WebUtils.saveMimeInputStreamAsFile(response, attachment.getAttachmentMimeTypeCode(), attachment.getAttachmentContents(), attachment.getAttachmentFileName(), attachment.getAttachmentFileSize().intValue());
        return null;
    }

    return mapping.findForward(RiceConstants.MAPPING_BASIC);
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:30,代码来源:KualiDocumentActionBase.java

示例5: getNewNoteAttachment

import org.kuali.rice.krad.bo.Note; //导入方法依赖的package包/类
/**
 * Builds an attachment for the file (if any) associated with the add note instance.
 *
 * @param form form instance containing the attachment file
 * @param document document instance the attachment should be associated with
 * @param newNote note instance the attachment should be associated with
 * @return Attachment instance for the note, or null if no attachment file was present
 */
protected Attachment getNewNoteAttachment(DocumentFormBase form, Document document, Note newNote) {
    MultipartFile attachmentFile = form.getAttachmentFile();

    if ((attachmentFile == null) || StringUtils.isBlank(attachmentFile.getOriginalFilename())) {
        return null;
    }

    if (attachmentFile.getSize() == 0) {
        GlobalVariables.getMessageMap().putError(String.format("%s.%s",
                KRADConstants.NEW_DOCUMENT_NOTE_PROPERTY_NAME, KRADConstants.NOTE_ATTACHMENT_FILE_PROPERTY_NAME),
                RiceKeyConstants.ERROR_UPLOADFILE_EMPTY, attachmentFile.getOriginalFilename());

        return null;
    }

    String attachmentTypeCode = null;
    if (newNote.getAttachment() != null) {
        attachmentTypeCode = newNote.getAttachment().getAttachmentTypeCode();
    }

    DocumentAuthorizer documentAuthorizer = getDocumentDictionaryService().getDocumentAuthorizer(document);
    if (!documentAuthorizer.canAddNoteAttachment(document, attachmentTypeCode,
            GlobalVariables.getUserSession().getPerson())) {
        throw buildAuthorizationException("annotate", document);
    }

    Attachment attachment;
    try {
        attachment = getAttachmentService().createAttachment(document.getNoteTarget(),
                attachmentFile.getOriginalFilename(), attachmentFile.getContentType(),
                (int) attachmentFile.getSize(), attachmentFile.getInputStream(), attachmentTypeCode);
    } catch (IOException e) {
        throw new RiceRuntimeException("Unable to store attachment", e);
    }

    return attachment;
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:46,代码来源:DocumentControllerServiceImpl.java

示例6: deleteNote

import org.kuali.rice.krad.bo.Note; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public ModelAndView deleteNote(DocumentFormBase form) {
    String selectedLineIndex = form.getActionParamaterValue(UifParameters.SELECTED_LINE_INDEX);

    Document document = form.getDocument();

    Note note = document.getNote(Integer.parseInt(selectedLineIndex));
    Attachment attachment = note.getAttachment();

    String attachmentTypeCode = null;
    if (attachment != null) {
        attachmentTypeCode = attachment.getAttachmentTypeCode();
    }

    // verify the user has permissions to delete the note
    Person user = GlobalVariables.getUserSession().getPerson();
    if (!getDocumentDictionaryService().getDocumentAuthorizer(document).canDeleteNoteAttachment(document,
            attachmentTypeCode, note.getAuthorUniversalIdentifier(), user)) {
        throw buildAuthorizationException("annotate", document);
    }

    if (attachment != null && attachment.isComplete()) {
        getAttachmentService().deleteAttachmentContents(attachment);
    }

    // if document is not saved there is no need to delete the note (it is not persisted)
    if (!document.getDocumentHeader().getWorkflowDocument().isInitiated()) {
        getNoteService().deleteNote(note);
    }

    return getCollectionControllerService().deleteLine(form);
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:36,代码来源:DocumentControllerServiceImpl.java

示例7: deleteNote

import org.kuali.rice.krad.bo.Note; //导入方法依赖的package包/类
/**
    * @see org.kuali.rice.krad.service.NoteService#deleteNote(org.kuali.rice.krad.bo.Note)
    */
   @Override
public void deleteNote(Note note) {
   	validateNoteNotNull(note);
   	if ( note.getAttachment() != null ) { // Not sure about this - might blow up when no attachment
   		dataObjectService.delete(note.getAttachment());
           note.setAttachment(null);
   	}
       dataObjectService.delete(note);
   }
 
开发者ID:kuali,项目名称:kc-rice,代码行数:13,代码来源:NoteServiceImpl.java

示例8: isReceiptAttached

import org.kuali.rice.krad.bo.Note; //导入方法依赖的package包/类
private boolean isReceiptAttached(TravelDocument document){
    for(Note note: document.getNotes()){
        if(note.getAttachment() != null && StringUtils.equalsIgnoreCase(note.getAttachment().getAttachmentTypeCode(), TemConstants.AttachmentTypeCodes.ATTACHMENT_TYPE_RECEIPT)){
            return true;
        }
    }
    return false;
}
 
开发者ID:kuali,项目名称:kfs,代码行数:9,代码来源:TravelDocumentRequiredInfoValidation.java

示例9: deleteNote

import org.kuali.rice.krad.bo.Note; //导入方法依赖的package包/类
/**
    * @see org.kuali.rice.krad.service.NoteService#deleteNote(org.kuali.rice.krad.bo.Note)
    */
   @Override
public void deleteNote(Note note) {
   	validateNoteNotNull(note);
   	if ( note.getAttachment() != null ) { // Not sure about this - might blow up when no attachment
   		dataObjectService.delete(note.getAttachment());
   	}
       dataObjectService.delete(note);
   }
 
开发者ID:kuali,项目名称:rice,代码行数:12,代码来源:NoteServiceImpl.java

示例10: deleteBONote

import org.kuali.rice.krad.bo.Note; //导入方法依赖的package包/类
/**
     * delete a note from the document
     *
     * @param mapping
     * @param form
     * @param request
     * @param response
     * @return ActionForward
     * @throws Exception
     */
    public ActionForward deleteBONote(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
        KualiDocumentFormBase kualiDocumentFormBase = (KualiDocumentFormBase) form;
        Document document = kualiDocumentFormBase.getDocument();


//        DataDictionary dataDictionary = getDataDictionaryService().getDataDictionary();
//        DocumentEntry entry = dataDictionary.getDocumentEntry(document.getClass().getName());

        // check authorization for adding notes
        //DocumentActionFlags flags = getDocumentActionFlags(document);
        //if (!kualiDocumentFormBase.getDocumentActions().containsKey(KRADConstants.KUALI_ACTION_CAN_ANNOTATE)) {
        //    buildAuthorizationException("annotate", document);
        //    return mapping.findForward(RiceConstants.MAPPING_BASIC);
        //}

        // ok to delete the note/attachment
        // derive the note property from the newNote on the form
        Note newNote = kualiDocumentFormBase.getNewNote();
        Note note = document.getNote(getLineToDelete(request));
        Attachment attachment = note.getAttachment();
        String attachmentTypeCode = null;
        if (attachment != null) {
            attachmentTypeCode = attachment.getAttachmentTypeCode();
        }
        String authorUniversalIdentifier = note.getAuthorUniversalIdentifier();
        if (!WebUtils.canDeleteNoteAttachment(document, attachmentTypeCode, authorUniversalIdentifier)) {
            throw buildAuthorizationException("annotate", document);
        }

        if (attachment != null) { // only do this if the note has been persisted
            //KFSMI-798 - refresh() changed to refreshNonUpdateableReferences()
            //All references for the business object Attachment are auto-update="none",
            //so refreshNonUpdateableReferences() should work the same as refresh()
            if (note.getNoteIdentifier() != null) { // KULRICE-2343 don't blow away note reference if the note wasn't persisted
                attachment.refreshNonUpdateableReferences();
            }
            getAttachmentService().deleteAttachmentContents(attachment);
        }
        // Removed the if check so it no longer checks if the document is initiated before deleting the BO's note per KULRICE- 12327
        getNoteService().deleteNote(note);

        document.removeNote(note);
        if(!document.getDocumentHeader().getWorkflowDocument().isInitiated() && document instanceof MaintenanceDocument && NoteType.BUSINESS_OBJECT.getCode().equals(note.getNoteTypeCode())) {
            // If this is a maintenance document and we're deleting a BO note then try to save the document so the note is removed from the content
            getDocumentService().saveDocument(document);
        }
        return mapping.findForward(RiceConstants.MAPPING_BASIC);
    }
 
开发者ID:kuali,项目名称:kc-rice,代码行数:59,代码来源:KualiDocumentActionBase.java

示例11: sendInvoicesViaEmail

import org.kuali.rice.krad.bo.Note; //导入方法依赖的package包/类
/**
 * This method is used to send emails to the agency
 *
 * @param invoices
 */
@Override
public boolean sendInvoicesViaEmail(Collection<ContractsGrantsInvoiceDocument> invoices) throws InvalidAddressException, MessagingException  {
    LOG.debug("sendInvoicesViaEmail() starting.");

    boolean success = true;
    Properties props = getConfigProperties();

    // Get session
    Session session = Session.getInstance(props, null);
    for (ContractsGrantsInvoiceDocument invoice : invoices) {
        List<InvoiceAddressDetail> invoiceAddressDetails = invoice.getInvoiceAddressDetails();
        for (InvoiceAddressDetail invoiceAddressDetail : invoiceAddressDetails) {
            if (ArConstants.InvoiceTransmissionMethod.EMAIL.equals(invoiceAddressDetail.getInvoiceTransmissionMethodCode())) {
                Note note = noteService.getNoteByNoteId(invoiceAddressDetail.getNoteId());

                if (ObjectUtils.isNotNull(note)) {
                    AttachmentMailMessage message = new AttachmentMailMessage();

                    String sender = parameterService.getParameterValueAsString(KFSConstants.OptionalModuleNamespaces.ACCOUNTS_RECEIVABLE, ArConstants.CONTRACTS_GRANTS_INVOICE_COMPONENT, ArConstants.FROM_EMAIL_ADDRESS);
                    message.setFromAddress(sender);

                    CustomerAddress customerAddress = invoiceAddressDetail.getCustomerAddress();
                    String recipients = invoiceAddressDetail.getCustomerEmailAddress();
                    if (StringUtils.isNotEmpty(recipients)) {
                        message.getToAddresses().add(recipients);
                    }
                    else {
                        LOG.warn("No recipients indicated.");
                    }

                    String subject = getSubject(invoice);
                    message.setSubject(subject);
                    if (StringUtils.isEmpty(subject)) {
                        LOG.warn("Empty subject being sent.");
                    }

                    String bodyText = getMessageBody(invoice, customerAddress);
                    message.setMessage(bodyText);
                    if (StringUtils.isEmpty(bodyText)) {
                        LOG.warn("Empty bodyText being sent.");
                    }

                    Attachment attachment = note.getAttachment();
                    if (ObjectUtils.isNotNull(attachment)) {
                        try {
                            message.setContent(IOUtils.toByteArray(attachment.getAttachmentContents()));
                        }
                        catch (IOException ex) {
                            LOG.error("Error setting attachment contents", ex);
                            throw new RuntimeException(ex);
                        }
                        message.setFileName(attachment.getAttachmentFileName());
                        message.setType(attachment.getAttachmentMimeTypeCode());
                    }

                    setupMailServiceForNonProductionInstance();
                    mailService.sendMessage(message);

                    invoiceAddressDetail.setInitialTransmissionDate(new Date(new java.util.Date().getTime()));
                    documentService.updateDocument(invoice);
                } else {
                    success = false;
                }
            }
        }
    }
    return success;
}
 
开发者ID:kuali,项目名称:kfs,代码行数:74,代码来源:AREmailServiceImpl.java


注:本文中的org.kuali.rice.krad.bo.Note.getAttachment方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。