本文整理汇总了Java中org.kuali.rice.krad.bo.Note.setAttachment方法的典型用法代码示例。如果您正苦于以下问题:Java Note.setAttachment方法的具体用法?Java Note.setAttachment怎么用?Java Note.setAttachment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.kuali.rice.krad.bo.Note
的用法示例。
在下文中一共展示了Note.setAttachment方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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);
}
示例3: generateInvoicesForInvoiceAddresses
import org.kuali.rice.krad.bo.Note; //导入方法依赖的package包/类
/**
* This method generates the attached invoices for the agency addresses in the Contracts & Grants Invoice Document.
*/
@Override
public void generateInvoicesForInvoiceAddresses(ContractsGrantsInvoiceDocument document) {
InvoiceTemplate invoiceTemplate = null;
Iterator<InvoiceAddressDetail> iterator = document.getInvoiceAddressDetails().iterator();
while (iterator.hasNext()) {
InvoiceAddressDetail invoiceAddressDetail = iterator.next();
byte[] reportStream;
byte[] copyReportStream;
// validating the invoice template
if (ObjectUtils.isNotNull(invoiceAddressDetail.getCustomerInvoiceTemplateCode())) {
invoiceTemplate = businessObjectService.findBySinglePrimaryKey(InvoiceTemplate.class, invoiceAddressDetail.getCustomerInvoiceTemplateCode());
// generate invoices from templates.
if (ObjectUtils.isNotNull(invoiceTemplate) && invoiceTemplate.isActive() && StringUtils.isNotBlank(invoiceTemplate.getFilename())) {
ModuleConfiguration systemConfiguration = kualiModuleService.getModuleServiceByNamespaceCode(KFSConstants.OptionalModuleNamespaces.ACCOUNTS_RECEIVABLE).getModuleConfiguration();
String templateFolderPath = ((FinancialSystemModuleConfiguration) systemConfiguration).getTemplateFileDirectories().get(KFSConstants.TEMPLATES_DIRECTORY_KEY);
String templateFilePath = templateFolderPath + File.separator + invoiceTemplate.getFilename();
File templateFile = new File(templateFilePath);
File outputDirectory = null;
String outputFileName;
try {
// generating original invoice
outputFileName = document.getDocumentNumber() + "_" + invoiceAddressDetail.getCustomerAddressName() + getDateTimeService().toDateStringForFilename(getDateTimeService().getCurrentDate()) + ArConstants.TemplateUploadSystem.EXTENSION;
Map<String, String> replacementList = getTemplateParameterList(document);
replacementList.put(ArPropertyConstants.CustomerInvoiceDocumentFields.CUSTOMER+"."+ArPropertyConstants.FULL_ADDRESS, contractsGrantsBillingUtilityService.buildFullAddress(invoiceAddressDetail.getCustomerAddress()));
reportStream = PdfFormFillerUtil.populateTemplate(templateFile, replacementList);
// creating and saving the original note with an attachment
if (ObjectUtils.isNotNull(document.getInvoiceGeneralDetail()) && document.getInvoiceGeneralDetail().isFinalBillIndicator()) {
reportStream = PdfFormFillerUtil.createFinalmarkOnFile(reportStream, getConfigurationService().getPropertyValueAsString(ArKeyConstants.INVOICE_ADDRESS_PDF_WATERMARK_FINAL));
}
Note note = new Note();
note.setNotePostedTimestampToCurrent();
final String finalNotePattern = getConfigurationService().getPropertyValueAsString(ArKeyConstants.INVOICE_ADDRESS_PDF_FINAL_NOTE);
note.setNoteText(MessageFormat.format(finalNotePattern, document.getDocumentNumber(), invoiceAddressDetail.getCustomerAddressName()));
note.setNoteTypeCode(KFSConstants.NoteTypeEnum.BUSINESS_OBJECT_NOTE_TYPE.getCode());
Person systemUser = personService.getPersonByPrincipalName(KFSConstants.SYSTEM_USER);
note = noteService.createNote(note, document.getNoteTarget(), systemUser.getPrincipalId());
Attachment attachment = attachmentService.createAttachment(note, outputFileName, ArConstants.TemplateUploadSystem.TEMPLATE_MIME_TYPE, reportStream.length, new ByteArrayInputStream(reportStream), KFSConstants.EMPTY_STRING);
// adding attachment to the note
note.setAttachment(attachment);
noteService.save(note);
attachment.setNoteIdentifier(note.getNoteIdentifier());
businessObjectService.save(attachment);
document.addNote(note);
// generating Copy invoice
outputFileName = document.getDocumentNumber() + "_" + invoiceAddressDetail.getCustomerAddressName() + getDateTimeService().toDateStringForFilename(getDateTimeService().getCurrentDate()) + getConfigurationService().getPropertyValueAsString(ArKeyConstants.INVOICE_ADDRESS_PDF_COPY_FILENAME_SUFFIX) + ArConstants.TemplateUploadSystem.EXTENSION;
copyReportStream = PdfFormFillerUtil.createWatermarkOnFile(reportStream, getConfigurationService().getPropertyValueAsString(ArKeyConstants.INVOICE_ADDRESS_PDF_WATERMARK_COPY));
// creating and saving the copy note with an attachment
Note copyNote = new Note();
copyNote.setNotePostedTimestampToCurrent();
final String copyNotePattern = getConfigurationService().getPropertyValueAsString(ArKeyConstants.INVOICE_ADDRESS_PDF_COPY_NOTE);
copyNote.setNoteText(MessageFormat.format(copyNotePattern, document.getDocumentNumber(), invoiceAddressDetail.getCustomerAddressName()));
copyNote.setNoteTypeCode(KFSConstants.NoteTypeEnum.BUSINESS_OBJECT_NOTE_TYPE.getCode());
copyNote = noteService.createNote(copyNote, document.getNoteTarget(), systemUser.getPrincipalId());
Attachment copyAttachment = attachmentService.createAttachment(copyNote, outputFileName, ArConstants.TemplateUploadSystem.TEMPLATE_MIME_TYPE, copyReportStream.length, new ByteArrayInputStream(copyReportStream), KFSConstants.EMPTY_STRING);
// adding attachment to the note
copyNote.setAttachment(copyAttachment);
noteService.save(copyNote);
copyAttachment.setNoteIdentifier(copyNote.getNoteIdentifier());
businessObjectService.save(copyAttachment);
document.addNote(copyNote);
invoiceAddressDetail.setNoteId(note.getNoteIdentifier());
// saving the note to the document header
documentService.updateDocument(document);
} catch (IOException | DocumentException ex) {
addNoteForInvoiceReportFail(document);
}
} else {
addNoteForInvoiceReportFail(document);
}
} else {
addNoteForInvoiceReportFail(document);
}
}
}