@Override public void completeTaskFromContext(String ctxUID, String serverTemplateId, String containerId, Long taskId) { Map<String, Object> params = formRenderContextManager.getFormRenderContext(ctxUID).getOutputData(); formRenderContextManager.removeContext(ctxUID); taskService.completeTask(serverTemplateId, containerId, taskId, params); }
@Override public Long startProcessFromRenderContext(String ctxUID, String serverTemplateId, String domainId, String processId, String correlationKey, Long parentProcessInstanceId) { Map<String, Object> params = formRenderContextManager.getFormRenderContext(ctxUID).getOutputData(); formRenderContextManager.removeContext(ctxUID); return processService.startProcess(serverTemplateId, domainId, processId, correlationKey, params); }
@Override public Long saveTaskStateFromRenderContext(String ctxUID, String serverTemplateId, String containerId, Long taskId, boolean clearStatus) { Map<String, Object> params = formRenderContextManager.getFormRenderContext(ctxUID).getOutputData(); if (clearStatus) { formRenderContextManager.removeContext(ctxUID); } taskService.saveTaskContent(serverTemplateId, containerId, taskId, params); return -1l; }
protected FormStatus createContextFormStatus(FormRenderContext context) throws Exception { Map<String, Object> loadedObjects = new HashMap<String, Object>(); Map values = readValuesToLoad(context.getForm(), context.getInputData(), context.getOutputData(), loadedObjects, context.getUID()); return getFormStatus(context.getForm(), context.getUID(), values, loadedObjects); }
public void persist(FormRenderContext context) throws Exception { Form form = context.getForm(); Map mapToPersist = getFilteredMapRepresentationToPersist(form, context.getUID()); Map<String, Object> result = context.getOutputData(); for (Iterator it = mapToPersist.keySet().iterator(); it.hasNext();) { String fieldName = (String) it.next(); Field field = form.getField(fieldName); if (field != null) { DataHolder holder = form.getDataHolderByField(field); String bindingString = field.getOutputBinding(); if (StringUtils.isEmpty(bindingString)) continue; Object value = persistField(field, mapToPersist, holder, context.getUID()); bindingString = bindingExpressionUtil.extractBindingExpression(bindingString); boolean simpleBinding = StringUtils.isEmpty(bindingString) || bindingString.indexOf("/") == -1; if (holder == null || simpleBinding) result.put(bindingString, value); else { String holderFieldId = bindingString.substring((holder.getOuputId() + "/").length()); Object holderOutputValue = result.get(holder.getOuputId()); if (holderOutputValue == null || !holder.isAssignableValue(holderOutputValue)) { holderOutputValue = context.getInputData().get(holder.getInputId()); if (holderOutputValue == null || !holder.isAssignableValue(holderOutputValue)) holderOutputValue = holder.createInstance(context); result.put(holder.getOuputId(), holderOutputValue); } holder.writeValue(holderOutputValue, holderFieldId, value); } } } }
@Test public void testPersistDataWithoutInputs() throws Exception { initContext(); FormStatusData data = processor.read(CTX_UID); assertNotNull(data); assertEquals(1, data.getCurrentValues().size()); Object actualHobbies = data.getCurrentValue(HOBBIES_FIELD); assertNotNull(actualHobbies); assertTrue(actualHobbies instanceof Map[]); assertEquals(0, ((Map[]) actualHobbies).length); when(processor.getFilteredMapRepresentationToPersist(context.getForm(), context.getUID())).thenReturn(generateExpectedValuesMap()); processor.persist(CTX_UID); assertNotNull(context.getOutputData().get(HOBBIES_FIELD)); assertTrue(context.getOutputData().get(HOBBIES_FIELD) instanceof List); List<Hobby> resultHobbies = (List<Hobby>) context.getOutputData().get(HOBBIES_FIELD); assertFalse(resultHobbies.isEmpty()); assertEquals(expectedHobbies.size(), resultHobbies.size()); assertEquals(expectedHobbies, resultHobbies); }
assertNotNull(context.getOutputData().get(HOBBIES_FIELD)); assertTrue(context.getOutputData().get(HOBBIES_FIELD) instanceof List); List<Hobby> resultHobbies = (List<Hobby>) context.getOutputData().get(HOBBIES_FIELD); assertFalse(resultHobbies.isEmpty()); assertEquals(expectedHobbies.size(),
Object value = context.getOutputData().get(field.getFieldName()); assertNotNull(value); assertEquals(modifiedValues.get(field.getFieldName()),
@Test public void testPersistComplexDataWithoutInputs() throws Exception { initContext(); FormStatusData data = processor.read(CTX_UID); assertNotNull(data); Object name = data.getCurrentValue(NAME_FIELD); assertNull(name); Object surname = data.getCurrentValue(SURNAME_FIELD); assertNull(surname); Object birthday = data.getCurrentValue(BIRTHDAY_FIELD); assertNull(birthday); Object address = data.getCurrentValue(ADDRESS_FIELD); assertNotNull(address); assertTrue(address instanceof Map); assertTrue(((Map) address).isEmpty()); Object hobbies = data.getCurrentValue(HOBBIES_FIELD); assertNotNull(hobbies); assertTrue(hobbies instanceof Map[]); assertEquals(0, ((Map[]) hobbies).length); when(processor.getFilteredMapRepresentationToPersist(context.getForm(), context.getUID())).thenReturn(generateExpectedValuesMap()); processor.persist(CTX_UID); assertNotNull(context.getOutputData().get(PERSON_DATAHOLDER)); assertTrue(context.getOutputData().get(PERSON_DATAHOLDER) instanceof Person); Person person = (Person) context.getOutputData().get(PERSON_DATAHOLDER); assertEquals(expectedPerson, person); }
assertNotNull(context.getOutputData().get(PERSON_DATAHOLDER)); assertTrue(context.getOutputData().get(PERSON_DATAHOLDER) instanceof Person); Person person = (Person) context.getOutputData().get(PERSON_DATAHOLDER);