use of edu.cornell.kfs.sys.businessobject.NoteExtendedAttribute in project cu-kfs by CU-CommunityApps.
the class PurchasingActionBase method populateIdentifierOnNoteAndExtension.
private void populateIdentifierOnNoteAndExtension(Note note) {
Long nextNoteId = getSequenceAccessorService().getNextAvailableSequenceNumber(CUKFSConstants.NOTE_SEQUENCE_NAME);
NoteExtendedAttribute extension = (NoteExtendedAttribute) note.getExtension();
note.setNoteIdentifier(nextNoteId);
extension.setNoteIdentifier(nextNoteId);
}
use of edu.cornell.kfs.sys.businessobject.NoteExtendedAttribute in project cu-kfs by CU-CommunityApps.
the class CuPurchaseOrderServiceImpl method copyNotesAndAttachmentsToPO.
// mjmc *************************************************************************************************
private PurchaseOrderDocument copyNotesAndAttachmentsToPO(RequisitionDocument reqDoc, PurchaseOrderDocument poDoc) {
purapService.saveDocumentNoValidation(poDoc);
List<Note> notes = (List<Note>) reqDoc.getNotes();
int noteLength = notes.size();
if (noteLength > 0) {
for (Note note : notes) {
try {
Note copyingNote = SpringContext.getBean(DocumentService.class).createNoteFromDocument(poDoc, note.getNoteText());
purapService.saveDocumentNoValidation(poDoc);
copyingNote.setNotePostedTimestamp(note.getNotePostedTimestamp());
copyingNote.setAuthorUniversalIdentifier(note.getAuthorUniversalIdentifier());
copyingNote.setNoteTopicText(note.getNoteTopicText());
Attachment originalAttachment = SpringContext.getBean(AttachmentService.class).getAttachmentByNoteId(note.getNoteIdentifier());
NoteExtendedAttribute noteExtendedAttribute = (NoteExtendedAttribute) note.getExtension();
if (originalAttachment != null || (ObjectUtils.isNotNull(noteExtendedAttribute) && noteExtendedAttribute.isCopyNoteIndicator())) {
if (originalAttachment != null) {
// new Attachment();
Attachment newAttachment = SpringContext.getBean(AttachmentService.class).createAttachment((PersistableBusinessObject) copyingNote, originalAttachment.getAttachmentFileName(), originalAttachment.getAttachmentMimeTypeCode(), originalAttachment.getAttachmentFileSize().intValue(), originalAttachment.getAttachmentContents(), originalAttachment.getAttachmentTypeCode());
if (ObjectUtils.isNotNull(originalAttachment) && ObjectUtils.isNotNull(newAttachment)) {
copyingNote.addAttachment(newAttachment);
}
}
poDoc.addNote(copyingNote);
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
purapService.saveDocumentNoValidation(poDoc);
return poDoc;
}
use of edu.cornell.kfs.sys.businessobject.NoteExtendedAttribute in project cu-kfs by CU-CommunityApps.
the class CuRequisitionAction method insertBONote.
@Override
public ActionForward insertBONote(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
KualiDocumentFormBase kualiDocumentFormBase = (KualiDocumentFormBase) form;
Note newNote = kualiDocumentFormBase.getNewNote();
NoteExtendedAttribute extendedAttribute = (NoteExtendedAttribute) newNote.getExtension();
ActionForward forward = super.insertBONote(mapping, form, request, response);
if (newNote != kualiDocumentFormBase.getNewNote()) {
Note addedNote = kualiDocumentFormBase.getDocument().getNotes().get(kualiDocumentFormBase.getDocument().getNotes().size() - 1);
extendedAttribute.setNoteIdentifier(addedNote.getNoteIdentifier());
addedNote.setExtension(extendedAttribute);
SpringContext.getBean(BusinessObjectService.class).save(extendedAttribute);
addedNote.refreshReferenceObject("extension");
}
return forward;
}
use of edu.cornell.kfs.sys.businessobject.NoteExtendedAttribute in project cu-kfs by CU-CommunityApps.
the class CuRequisitionDocument method prepareForSave.
/**
* Overridden to also pre-populate note IDs on unsaved notes lacking attachments,
* to avoid persistence problems with note extended attributes. This is necessary
* because of the OJB behavior of trying to persist the 1-1 reference object
* prior to the parent object, which can interfere with saving auto-generated
* notes (like "copied from document" notes).
*
* @see org.kuali.kfs.module.purap.document.PurchasingDocumentBase#prepareForSave(org.kuali.kfs.krad.rules.rule.event.KualiDocumentEvent)
*/
@Override
public void prepareForSave(KualiDocumentEvent event) {
super.prepareForSave(event);
SequenceAccessorService sequenceAccessorService = SpringContext.getBean(SequenceAccessorService.class);
for (Note note : getNotes()) {
if (note.getNoteIdentifier() == null && ObjectUtils.isNull(note.getAttachment())) {
// Pre-populate IDs on unsaved notes without attachments, as well as their extended attributes.
Long newNoteId = sequenceAccessorService.getNextAvailableSequenceNumber(CUKFSConstants.NOTE_SEQUENCE_NAME);
note.setNoteIdentifier(newNoteId);
((NoteExtendedAttribute) note.getExtension()).setNoteIdentifier(newNoteId);
}
}
}
use of edu.cornell.kfs.sys.businessobject.NoteExtendedAttribute in project cu-kfs by CU-CommunityApps.
the class IWantDocumentServiceImpl method copyIWantDocAttachments.
/**
* Copies all attachments from the I Want document to the accounting document
*
* NOTE: A true extCopyNoteIndicator value will cause the copied notes to also
* include an extended attribute with copyNoteIndicator set to true.
*
* @param document
* @param iWantDocument
* @param copyConfidentialAttachments
* @param extCopyNoteIndicator
* @throws Exception
*/
private void copyIWantDocAttachments(AccountingDocument document, IWantDocument iWantDocument, boolean copyConfidentialAttachments, boolean extCopyNoteIndicator) throws Exception {
purapService.saveDocumentNoValidation(document);
if (iWantDocument.getNotes() != null && iWantDocument.getNotes().size() > 0) {
for (Iterator iterator = iWantDocument.getNotes().iterator(); iterator.hasNext(); ) {
Note note = (Note) iterator.next();
try {
Note copyingNote = documentService.createNoteFromDocument(document, note.getNoteText());
purapService.saveDocumentNoValidation(document);
copyingNote.setNotePostedTimestamp(note.getNotePostedTimestamp());
copyingNote.setAuthorUniversalIdentifier(note.getAuthorUniversalIdentifier());
copyingNote.setNoteTopicText(note.getNoteTopicText());
Attachment originalAttachment = attachmentService.getAttachmentByNoteId(note.getNoteIdentifier());
if (originalAttachment != null && (copyConfidentialAttachments || !ConfidentialAttachmentTypeCodes.CONFIDENTIAL_ATTACHMENT_TYPE.equals(originalAttachment.getAttachmentTypeCode()))) {
// new Attachment();
Attachment newAttachment = attachmentService.createAttachment((PersistableBusinessObject) copyingNote, originalAttachment.getAttachmentFileName(), originalAttachment.getAttachmentMimeTypeCode(), originalAttachment.getAttachmentFileSize().intValue(), originalAttachment.getAttachmentContents(), originalAttachment.getAttachmentTypeCode());
if (ObjectUtils.isNotNull(originalAttachment) && ObjectUtils.isNotNull(newAttachment)) {
copyingNote.addAttachment(newAttachment);
}
document.addNote(copyingNote);
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
purapService.saveDocumentNoValidation(document);
// If specified, auto-construct extended attributes on the document notes at this point. (Doing so before initial persistence can cause save problems.)
if (extCopyNoteIndicator && CollectionUtils.isNotEmpty(document.getNotes())) {
for (Note copiedNote : document.getNotes()) {
NoteExtendedAttribute noteExtension = (NoteExtendedAttribute) copiedNote.getExtension();
noteExtension.setNoteIdentifier(copiedNote.getNoteIdentifier());
noteExtension.setCopyNoteIndicator(true);
}
purapService.saveDocumentNoValidation(document);
}
}
Aggregations