use of org.activiti.workflow.simple.definition.form.DatePropertyDefinition in project Activiti by Activiti.
the class FormPopupWindow method getFormPropertyDefinition.
protected FormPropertyDefinition getFormPropertyDefinition(Item item) {
String type = (String) ((ComboBox) item.getItemProperty(PropertyTable.ID_PROPERTY_TYPE).getValue()).getValue();
FormPropertyDefinition result = null;
if (type.equals("number")) {
result = new NumberPropertyDefinition();
} else if (type.equals("date")) {
result = new DatePropertyDefinition();
} else {
result = new TextPropertyDefinition();
}
// Set generic properties
result.setName((String) item.getItemProperty(PropertyTable.ID_PROPERTY_NAME).getValue());
result.setMandatory((Boolean) ((CheckBox) item.getItemProperty(PropertyTable.ID_PROPERTY_REQUIRED).getValue()).getValue());
return result;
}
use of org.activiti.workflow.simple.definition.form.DatePropertyDefinition in project Activiti by Activiti.
the class AlfrescoDatePropertyConverter method convertProperty.
@Override
public void convertProperty(M2Type contentType, String formSet, Form form, FormPropertyDefinition propertyDefinition, WorkflowDefinitionConversion conversion) {
DatePropertyDefinition dateDefinition = (DatePropertyDefinition) propertyDefinition;
String propertyName = getPropertyName(propertyDefinition, conversion);
// Add to content model
M2Property property = new M2Property();
property.setMandatory(new M2Mandatory(dateDefinition.isMandatory()));
property.setName(propertyName);
if (dateDefinition.isShowTime()) {
property.setPropertyType(AlfrescoConversionConstants.PROPERTY_TYPE_DATETIME);
} else {
property.setPropertyType(AlfrescoConversionConstants.PROPERTY_TYPE_DATE);
}
M2Model model = AlfrescoConversionUtil.getContentModel(conversion);
M2Aspect aspect = model.getAspect(propertyName);
if (aspect != null) {
// do this here
if (aspect.getProperties().isEmpty()) {
aspect.getProperties().add(property);
}
contentType.getMandatoryAspects().add(propertyName);
} else {
contentType.getProperties().add(property);
}
// Add form configuration
form.getFormFieldVisibility().addShowFieldElement(propertyName);
FormField formField = form.getFormAppearance().addFormField(propertyName, dateDefinition.getName(), formSet);
if (dateDefinition.isWritable()) {
// Use custom date-control
FormFieldControl control = new FormFieldControl();
control.setTemplate(AlfrescoConversionConstants.FORM_DATE_TEMPLATE);
control.addControlParameter(AlfrescoConversionConstants.FORM_DATE_PARAM_SHOW_TIME, Boolean.toString(dateDefinition.isShowTime()));
control.addControlParameter(AlfrescoConversionConstants.FORM_DATE_PARAM_SUBMIT_TIME, Boolean.toString(dateDefinition.isShowTime()));
formField.setControl(control);
} else {
// Read-only properties should always be rendered using an info-template
FormFieldControl control = new FormFieldControl();
control.setTemplate(AlfrescoConversionConstants.FORM_READONLY_TEMPLATE);
formField.setControl(control);
}
if (!form.isStartForm()) {
// Add to output properties, if needed
addOutputProperty(propertyDefinition, propertyName, contentType.getName(), conversion);
}
}
use of org.activiti.workflow.simple.definition.form.DatePropertyDefinition in project Activiti by Activiti.
the class BaseStepDefinitionConverter method convertProperties.
/**
* Converts form properties. Multiple step types can contain forms,
* hence why it it a shared method here.
*/
protected List<FormProperty> convertProperties(FormDefinition formDefinition) {
List<FormProperty> formProperties = new ArrayList<FormProperty>();
for (FormPropertyDefinition propertyDefinition : formDefinition.getFormPropertyDefinitions()) {
FormProperty formProperty = new FormProperty();
formProperties.add(formProperty);
formProperty.setId(propertyDefinition.getName());
formProperty.setName(propertyDefinition.getName());
formProperty.setRequired(propertyDefinition.isMandatory());
String type = null;
if (propertyDefinition instanceof NumberPropertyDefinition) {
type = "long";
} else if (propertyDefinition instanceof DatePropertyDefinition) {
type = "date";
} else if (propertyDefinition instanceof BooleanPropertyDefinition) {
type = "boolean";
} else if (propertyDefinition instanceof ListPropertyDefinition) {
type = "enum";
ListPropertyDefinition listDefinition = (ListPropertyDefinition) propertyDefinition;
if (!listDefinition.getEntries().isEmpty()) {
List<FormValue> formValues = new ArrayList<FormValue>(listDefinition.getEntries().size());
for (ListPropertyEntry entry : listDefinition.getEntries()) {
FormValue formValue = new FormValue();
// We're using same value for id and name for the moment
formValue.setId(entry.getValue());
formValue.setName(entry.getName());
formValues.add(formValue);
}
formProperty.setFormValues(formValues);
}
} else {
// Fallback to simple text
type = "string";
}
formProperty.setType(type);
}
return formProperties;
}
Aggregations