本文整理汇总了Java中org.activiti.engine.form.FormProperty类的典型用法代码示例。如果您正苦于以下问题:Java FormProperty类的具体用法?Java FormProperty怎么用?Java FormProperty使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FormProperty类属于org.activiti.engine.form包,在下文中一共展示了FormProperty类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkForm
import org.activiti.engine.form.FormProperty; //导入依赖的package包/类
@Test
public void checkForm() {
Map<String, Object> variables = mapper.mapToVariables(formResource);
Assert.assertEquals(1, variables.size());
Assert.assertEquals(Boolean.TRUE, variables.get("approved"));
TestForm resourceCopy = new TestForm();
mapper.mapFromVariables(resourceCopy, variables);
checkFormResource(resourceCopy);
List<FormProperty> formProperties = new ArrayList<>();
FormProperty formProperty = Mockito.mock(FormProperty.class);
Mockito.when(formProperty.getId()).thenReturn("approved");
Mockito.when(formProperty.getValue()).thenReturn("true");
formProperties.add(formProperty);
TaskFormData formData = Mockito.mock(TaskFormData.class);
Mockito.when(formData.getFormProperties()).thenReturn(formProperties);
Task task = Mockito.mock(Task.class);
Mockito.when(task.getId()).thenReturn("someTask");
Mockito.when(formData.getTask()).thenReturn(task);
TestForm formCopy = mapper.mapToResource(TestForm.class, formData);
checkFormResource(formCopy);
Assert.assertEquals("someTask", formCopy.getId());
}
示例2: getVariable
import org.activiti.engine.form.FormProperty; //导入依赖的package包/类
@Override
public Object getVariable(FormProperty formProperty, String value) {
value = StrUtil.isEmpty(value) ? formProperty.getValue() : value;
FormType formType = formProperty.getType();
if (formType.getClass().equals(DateFormType.class)) {
DateFormType dateType = (DateFormType) formType;
return dateType.convertFormValueToModelValue(value);
} else if (formType.getClass().equals(BooleanFormType.class)) {
BooleanFormType boolType = (BooleanFormType) formType;
return boolType.convertFormValueToModelValue(value);
} else if (formType.getClass().equals(EnumFormType.class)) {
EnumFormType enumType = (EnumFormType) formType;
return enumType.convertFormValueToModelValue(value);
} else if (formType.getClass().equals(DoubleFormType.class)) {
DoubleFormType doubleType = (DoubleFormType) formType;
return doubleType.convertFormValueToModelValue(value);
} else if (formType.getClass().equals(LongFormType.class)) {
LongFormType longType = (LongFormType) formType;
return longType.convertFormValueToModelValue(value);
} else {
return value;
}
}
示例3: convertFormData
import org.activiti.engine.form.FormProperty; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private List<FormAttribute> convertFormData(FormData formData) {
List<FormAttribute> props = new ArrayList<FormAttribute>();
for (FormProperty formProperty : formData.getFormProperties()) {
FormAttribute fa = new FormAttribute(formProperty.getId(), formProperty.getName(), formProperty.getValue(),
formProperty.getType().getName());
fa.setDatePattern(Objects.toString(formProperty.getType().getInformation("datePattern")));
fa.setItems((Map<String, String>) formProperty.getType().getInformation("values"));
fa.setReadable(formProperty.isReadable());
fa.setWriteable(formProperty.isWritable());
fa.setRequired(formProperty.isRequired());
props.add(fa);
}
return props;
}
示例4: setFormProperties
import org.activiti.engine.form.FormProperty; //导入依赖的package包/类
public void setFormProperties(List<FormProperty> formProperties) {
this.formProperties = formProperties;
form.removeAllProperties();
// Clear current components in the grid
if(formProperties != null) {
for(FormProperty formProperty : formProperties) {
FormPropertyRenderer renderer = getRenderer(formProperty);
Field editorComponent = renderer.getPropertyField(formProperty);
if(editorComponent != null) {
// Get label for editor component.
form.addField(formProperty.getId(), editorComponent);
}
}
}
}
示例5: getFormPropertyValues
import org.activiti.engine.form.FormProperty; //导入依赖的package包/类
/**
* Returns all values filled in in the writable fields on the form.
*
* @throws InvalidValueException when a validation error occurs.
*/
public Map<String, String> getFormPropertyValues() throws InvalidValueException {
// Commit the form to ensure validation is executed
form.commit();
Map<String, String> formPropertyValues = new HashMap<String, String>();
// Get values from fields defined for each form property
for(FormProperty formProperty : formProperties) {
if(formProperty.isWritable()) {
Field field = form.getField(formProperty.getId());
FormPropertyRenderer renderer = getRenderer(formProperty);
String fieldValue = renderer.getFieldValue(formProperty, field);
formPropertyValues.put(formProperty.getId(), fieldValue);
}
}
return formPropertyValues;
}
示例6: getPropertyField
import org.activiti.engine.form.FormProperty; //导入依赖的package包/类
@Override
public Field getPropertyField(FormProperty formProperty) {
final TextField textField = new TextField(getPropertyLabel(formProperty));
textField.setRequired(formProperty.isRequired());
textField.setEnabled(formProperty.isWritable());
textField.setRequiredError(getMessage(Messages.FORM_FIELD_REQUIRED, getPropertyLabel(formProperty)));
if (formProperty.getValue() != null) {
textField.setValue(formProperty.getValue());
}
// Add validation of numeric value
textField.addValidator(new LongValidator("Value must be a long"));
textField.setImmediate(true);
return textField;
}
示例7: getPropertyField
import org.activiti.engine.form.FormProperty; //导入依赖的package包/类
@Override
public Field getPropertyField(FormProperty formProperty) {
// Writable string
PopupDateField dateField = new PopupDateField(getPropertyLabel(formProperty));
String datePattern = (String) formProperty.getType().getInformation("datePattern");
dateField.setDateFormat(datePattern);
dateField.setRequired(formProperty.isRequired());
dateField.setRequiredError(getMessage(Messages.FORM_FIELD_REQUIRED, getPropertyLabel(formProperty)));
dateField.setEnabled(formProperty.isWritable());
if (formProperty.getValue() != null) {
// Try parsing the current value
SimpleDateFormat dateFormat = new SimpleDateFormat(datePattern);
try {
Date date = dateFormat.parse(formProperty.getValue());
dateField.setValue(date);
} catch (ParseException e) {
// TODO: what happens if current value is illegal date?
}
}
return dateField;
}
示例8: getPropertyField
import org.activiti.engine.form.FormProperty; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public Field getPropertyField(FormProperty formProperty) {
ComboBox comboBox = new ComboBox(getPropertyLabel(formProperty));
comboBox.setRequired(formProperty.isRequired());
comboBox.setRequiredError(getMessage(Messages.FORM_FIELD_REQUIRED, getPropertyLabel(formProperty)));
comboBox.setEnabled(formProperty.isWritable());
Map<String, String> values = (Map<String, String>) formProperty.getType().getInformation("values");
if (values != null) {
for (Entry<String, String> enumEntry : values.entrySet()) {
// Add value and label (if any)
comboBox.addItem(enumEntry.getKey());
if (enumEntry.getValue() != null) {
comboBox.setItemCaption(enumEntry.getKey(), enumEntry.getValue());
}
}
}
return comboBox;
}
示例9: createFormProperty
import org.activiti.engine.form.FormProperty; //导入依赖的package包/类
public FormProperty createFormProperty(ExecutionEntity execution) {
FormPropertyImpl formProperty = new FormPropertyImpl(this);
if (execution!=null) {
Object modelValue = null;
if (variableName != null) {
modelValue = execution.getVariable(variableName);
} else if (variableExpression != null) {
modelValue = variableExpression.getValue(execution);
} else {
modelValue = execution.getVariable(id);
}
if (type != null) {
String formValue = type.convertModelValueToFormValue(modelValue);
formProperty.setValue(formValue);
} else if (modelValue != null) {
formProperty.setValue(modelValue.toString());
}
}
return formProperty;
}
示例10: getTaskProperties
import org.activiti.engine.form.FormProperty; //导入依赖的package包/类
@Get
public ObjectNode getTaskProperties() {
if(authenticate() == false) return null;
String taskId = (String) getRequest().getAttributes().get("taskId");
List<FormProperty> properties = ActivitiUtil.getFormService().getTaskFormData(taskId).getFormProperties();
ObjectNode responseJSON = new ObjectMapper().createObjectNode();
ArrayNode propertiesJSON = new ObjectMapper().createArrayNode();
for (FormProperty property : properties) {
ObjectNode propertyJSON = new ObjectMapper().createObjectNode();
propertyJSON.put("id", property.getId());
propertyJSON.put("name", property.getName());
propertyJSON.put("value", property.getValue());
propertyJSON.put("type", property.getType().getName());
propertyJSON.put("required", property.isRequired());
propertyJSON.put("readable", property.isReadable());
propertyJSON.put("writable", property.isWritable());
propertiesJSON.add(propertyJSON);
}
responseJSON.put("data", propertiesJSON);
return responseJSON;
}
示例11: mapToResource
import org.activiti.engine.form.FormProperty; //导入依赖的package包/类
public <T extends FormResource> T mapToResource(Class<T> resourceClass, TaskFormData formData) {
T resource = io.crnk.core.engine.internal.utils.ClassUtils.newInstance(resourceClass);
Map<String, Object> formPropertyMap = new HashMap<>();
List<FormProperty> formProperties = formData.getFormProperties();
for (FormProperty formProperty : formProperties) {
formPropertyMap.put(formProperty.getId(), formProperty.getValue());
}
copyInternal(resource, null, formPropertyMap, true, Optional.empty());
resource.setId(formData.getTask().getId());
return resource;
}
示例12: formPropertiesAsMap
import org.activiti.engine.form.FormProperty; //导入依赖的package包/类
public static Map<String,FormProperty> formPropertiesAsMap(List<FormProperty> properties) {
Map<String,FormProperty> retval = new HashMap<String,FormProperty>();
for (FormProperty property : properties) {
retval.put(property.getId(), property);
}
return retval;
}
示例13: FormPropertyVo
import org.activiti.engine.form.FormProperty; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public FormPropertyVo(FormProperty formProperty) {
this.id = formProperty.getId();
this.name = formProperty.getName();
this.value = formProperty.getValue();
this.type = formProperty.getType().getName();
this.datePattern = StringUtils.toString(formProperty.getType().getInformation("datePattern"));
this.setItems(((Map<String, String>) formProperty.getType().getInformation("values")));
this.readable = formProperty.isReadable();
this.writeable = formProperty.isWritable();
this.required = formProperty.isRequired();
}
示例14: submitTask
import org.activiti.engine.form.FormProperty; //导入依赖的package包/类
/**
* 提交流程
* @param taskId
* @param formData
* @return
*/
@Override
public Result submitTask(String taskId, Map<String, String> formData) {
Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
String formKey = formService.getTaskFormKey(task.getProcessDefinitionId(), task.getTaskDefinitionKey());
Object renderForm = null;
if (!StrUtil.isEmpty(formKey) && formKey.endsWith(".form"))
renderForm = formService.getRenderedTaskForm(taskId);
if (renderForm != null) {
//通过formKey获取的数据
taskService.setVariablesLocal(task.getId(), formData);
//委托人处理
if (DelegationState.PENDING == task.getDelegationState()) {
taskService.resolveTask(taskId);
}
Map<String,Object> variables=new HashMap<>();
for (String s : formData.keySet()) {
variables.put(s,formData.get(s));
}
taskService.complete(taskId,variables);
} else {
//获取的数据为formProperties
List<FormProperty> formProperties = formService.getTaskFormData(task.getId()).getFormProperties();
Map<String, Object> taskVariables = runtimePageService.getTaskVariables(formProperties, formData);
taskService.setVariablesLocal(taskId, taskVariables);
if (DelegationState.PENDING == task.getDelegationState()) {
taskService.resolveTask(taskId);
}
taskService.complete(taskId,taskVariables);
}
//任务完成后,由TaskCreatedListener设置委托
System.out.println(formData);
return new Result(true);
}
示例15: getTaskVariables
import org.activiti.engine.form.FormProperty; //导入依赖的package包/类
@Override
public Map<String, Object> getTaskVariables(List<FormProperty> formProperties, Map<String, String> formData) {
Map<String, Object> map = new HashMap<>();
for (FormProperty formProperty : formProperties) {
String id = formProperty.getId();
if (!StrUtil.isEmpty(formData.get(id))) {
map.put(id, this.getVariable(formProperty, formData.get(id)));
}
}
return map;
}