@Override public Progress process(Processing processing) { if ( ! doProcessOuterDocument(processing.getVariable(contextFieldName), documentTypeName)) { return Progress.DONE; } DocumentPut outerDoc = (DocumentPut)processing.getVariable(contextFieldName); @SuppressWarnings("unchecked") Array<Document> innerDocuments = (Array<Document>) outerDoc.getDocument().getFieldValue(arrayFieldName); if (innerDocuments == null) { @SuppressWarnings("unchecked") Array<Document> empty = (Array<Document>) outerDoc.getDocument().getDataType().getField(arrayFieldName).getDataType().createFieldValue(); innerDocuments = empty; } for (DocumentOperation op : processing.getDocumentOperations()) { if (op instanceof DocumentPut) { innerDocuments.add(((DocumentPut)op).getDocument()); } else { log.log(LogLevel.DEBUG, "Skipping: " + op); } } processing.getDocumentOperations().clear(); processing.getDocumentOperations().add(outerDoc); processing.removeVariable(contextFieldName); return Progress.DONE; }