protected void addNotes(
     String documentNumber,
     List<SubObjectCode> listOfSubObjects,
     String messageKey,
     PersistableBusinessObject noteParent,
     Note noteTemplate) {
   for (int i = 0; i < listOfSubObjects.size(); i += getNumSubObjectsPerNote()) {
     try {
       String subAccountString =
           createSubObjectChunk(listOfSubObjects, i, i + getNumSubObjectsPerNote());
       if (StringUtils.isNotBlank(subAccountString)) {
         String noteTextTemplate = kualiConfigurationService.getPropertyValueAsString(messageKey);
         String noteText = MessageFormat.format(noteTextTemplate, subAccountString);
         Note note =
             noteService.createNote(
                 noteTemplate, noteParent, GlobalVariables.getUserSession().getPrincipalId());
         note.setNoteText(noteText);
         note.setNotePostedTimestampToCurrent();
         noteService.save(note);
       }
     } catch (Exception e) {
       LOG.error("Unable to create/save notes for document " + documentNumber, e);
       throw new RuntimeException("Unable to create/save notes for document " + documentNumber, e);
     }
   }
 }
  /**
   * @see
   *     org.kuali.rice.krad.service.DocumentService#createNoteFromDocument(org.kuali.rice.krad.document.Document,
   *     java.lang.String)
   */
  @Override
  public Note createNoteFromDocument(Document document, String text) {
    Note note = new Note();

    note.setNotePostedTimestamp(getDateTimeService().getCurrentTimestamp());
    note.setNoteText(text);
    note.setNoteTypeCode(document.getNoteType().getCode());

    PersistableBusinessObject bo = document.getNoteTarget();
    // TODO gah! this is awful
    Person kualiUser = GlobalVariables.getUserSession().getPerson();
    if (kualiUser == null) {
      throw new IllegalStateException("Current UserSession has a null Person.");
    }
    return bo == null ? null : getNoteService().createNote(note, bo, kualiUser.getPrincipalId());
  }
 protected void addMaintenanceLockedNotes(
     String documentNumber,
     Map<SubObjectCode, String> lockedSubObjects,
     String messageKey,
     PersistableBusinessObject noteParent,
     Note noteTemplate) {
   for (Map.Entry<SubObjectCode, String> entry : lockedSubObjects.entrySet()) {
     try {
       SubObjectCode subObjCd = entry.getKey();
       String subObjectString =
           subObjCd.getUniversityFiscalYear()
               + " - "
               + subObjCd.getChartOfAccountsCode()
               + " - "
               + subObjCd.getAccountNumber()
               + " - "
               + subObjCd.getFinancialObjectCode()
               + " - "
               + subObjCd.getFinancialSubObjectCode();
       if (StringUtils.isNotBlank(subObjectString)) {
         String noteTextTemplate = kualiConfigurationService.getPropertyValueAsString(messageKey);
         String noteText =
             MessageFormat.format(noteTextTemplate, subObjectString, entry.getValue());
         Note note =
             noteService.createNote(
                 noteTemplate, noteParent, GlobalVariables.getUserSession().getPrincipalId());
         note.setNoteText(noteText);
         note.setNotePostedTimestampToCurrent();
         noteService.save(note);
       }
     } catch (Exception e) {
       LOG.error("Unable to create/save notes for document " + documentNumber, e);
       throw new RuntimeException("Unable to create/save notes for document " + documentNumber, e);
     }
   }
 }
 private Note truncateNoteTextTo800(Note note) {
   if (note.getNoteText().length() > 800) {
     note.setNoteText(note.getNoteText().substring(0, 799));
   }
   return note;
 }