@Test public void shouldAddDifferentEntryIntoList() throws Exception { operation.xpath = "lists:double"; operation.value = 1.0; operation.run(doc); operation.value = 2.0; operation.run(doc); Double[] doubleValues = (Double[]) doc.getPropertyValue("lists:double"); assertEquals(2, doubleValues.length); assertEquals(1.0, doubleValues[0]); assertEquals(2.0, doubleValues[1]); operation.xpath = "lists:boolean"; operation.value = true; operation.run(doc); operation.value = false; operation.run(doc); Boolean[] booleanValues = (Boolean[]) doc.getPropertyValue("lists:boolean"); assertEquals(2, booleanValues.length); assertEquals(Boolean.TRUE, booleanValues[0]); assertEquals(Boolean.FALSE, booleanValues[1]); operation.xpath = "lists:integer"; operation.value = 1; operation.run(doc); operation.value = 2; operation.run(doc); Long[] longValues = (Long[]) doc.getPropertyValue("lists:integer"); assertEquals(2, longValues.length); assertEquals(Long.valueOf(1), longValues[0]); assertEquals(Long.valueOf(2), longValues[1]); operation.xpath = "lists:date"; Calendar now1 = Calendar.getInstance(); Thread.sleep(10); Calendar now2 = Calendar.getInstance(); operation.value = now1; operation.run(doc); operation.value = now2; operation.run(doc); Calendar[] dateValues = (Calendar[]) doc.getPropertyValue("lists:date"); assertEquals(2, dateValues.length); assertEquals(now1, dateValues[0]); assertEquals(now2, dateValues[1]); }
@OperationMethod(collector = DocumentModelCollector.class) public DocumentModel run(DocumentModel doc) throws OperationException { Property p = doc.getProperty(xpath); Type type = p.getType(); checkFieldType(type, value); List<Serializable> array = p.getValue() != null ? Arrays.asList((Serializable[]) p.getValue()) : null; Serializable newValue = addValueIntoList(array, value); p.setValue(newValue); if (save) { doc = session.saveDocument(doc); session.save(); } return doc; }
AddEntryToMultiValuedProperty extends AbstractOperationMultiValuedProperty { @OperationMethod(collector = DocumentModelCollector.class) public DocumentModel run(DocumentModel doc) throws OperationException { Property p = doc.getProperty(xpath); Type type = p.getType(); checkFieldType(type, value); List<Serializable> array = p.getValue() != null ? Arrays.asList((Serializable[]) p.getValue()) : null; Serializable newValue = addValueIntoList(array, value); p.setValue(newValue); if (save) { doc = session.saveDocument(doc); session.save(); } return doc; } }
AddEntryToMultiValuedProperty extends AbstractOperationMultiValuedProperty { @OperationMethod(collector = DocumentModelCollector.class) public DocumentModel run(DocumentModel doc) throws OperationException { Property p = doc.getProperty(xpath); Type type = p.getType(); checkFieldType(type, value); List<Serializable> array = p.getValue() != null ? Arrays.asList((Serializable[]) p.getValue()) : null; Serializable newValue = addValueIntoList(array, value); p.setValue(newValue); if (save) { doc = session.saveDocument(doc); session.save(); } return doc; }  }
AddEntryToMultiValuedProperty extends AbstractOperationMultiValuedProperty { @OperationMethod(collector = DocumentModelCollector.class) public DocumentModel run(DocumentModel doc) throws OperationException { Property p = doc.getProperty(xpath); Type type = p.getType(); checkFieldType(type, value); List<Serializable> array = p.getValue() != null ? Arrays.asList((Serializable[]) p.getValue()) : null; Serializable newValue = addValueIntoList(array, value); p.setValue(newValue); if (save) { doc = session.saveDocument(doc); session.save(); } return doc; }  @OperationMethod(collector = DocumentModelCollector.class) DocumentModel run(DocumentModel doc); }
AddEntryToMultiValuedProperty extends AbstractOperationMultiValuedProperty { @OperationMethod(collector = DocumentModelCollector.class) public DocumentModel run(DocumentModel doc) throws OperationException { Property p = doc.getProperty(xpath); Type type = p.getType(); checkFieldType(type, value); List<Serializable> array = p.getValue() != null ? Arrays.asList((Serializable[]) p.getValue()) : null; Serializable newValue = addValueIntoList(array, value); p.setValue(newValue); if (save) { doc = session.saveDocument(doc); session.save(); } return doc; }  @OperationMethod(collector = DocumentModelCollector.class) DocumentModel run(DocumentModel doc); static final String ID; }