public boolean querySave(DominoDocument doc) throws NotesException {
    // Create the encoded ID for the snippet
    String category = doc.getItemValueString("Category");
    String name = doc.getItemValueString("Name");
    doc.replaceItemValue("Id", AbstractNode.encodeSnippet(category, name));

    return true;
  }
Exemple #2
0
 public void remove(DominoDocument doc, String fieldName, int idx) throws Exception {
   String json = doc.getItemValueString(fieldName);
   if (!StringUtil.isSpace(json)) {
     List<Object> array = (List<Object>) JsonParser.fromJson(JsonJavaFactory.instance, json);
     if (idx < array.size()) {
       array.remove(idx);
       doc.replaceItemValue(fieldName, JsonGenerator.toJson(JsonJavaFactory.instance, array));
     }
   }
 }
Exemple #3
0
 public boolean isEmpty(DominoDocument doc, String fieldName) throws Exception {
   if (doc != null) {
     Item item = doc.getDocument().getFirstItem(fieldName);
     if (item != null) {
       String content;
       MIMEEntity e = item.getMIMEEntity();
       if (e != null) {
         content = e.getContentAsText();
       } else {
         content = item.getText();
       }
       if (!StringUtil.isSpace(content)) {
         // Should handle empty json objects/arrays as well
         content = content.trim();
         return content.equals("[]") || content.equals("{}");
       }
     }
   }
   return true;
 }