use of org.activiti.workflow.simple.alfresco.conversion.exception.AlfrescoSimpleWorkflowException in project Activiti by Activiti.
the class AlfrescoFormCreator method createForm.
public void createForm(M2Type contentType, Form formConfig, FormDefinition formDefinition, WorkflowDefinitionConversion conversion) {
if (formDefinition != null && formDefinition.getFormGroups() != null) {
for (FormPropertyGroup group : formDefinition.getFormGroups()) {
// Create a group in the form-config
String groupId = null;
if (group.getId() != null) {
groupId = AlfrescoConversionUtil.getValidIdString(group.getId());
} else {
groupId = AlfrescoConversionUtil.getValidIdString(group.getTitle());
}
FormSet formSet = formConfig.getFormAppearance().addFormSet(groupId, getAppearanceForGroup(group), group.getTitle(), getTemplateForGroup(group));
// Convert all properties
AlfrescoFormPropertyConverter converter = null;
for (FormPropertyDefinition property : group.getFormPropertyDefinitions()) {
converter = propertyConverters.get(property.getClass());
if (converter == null) {
throw new AlfrescoSimpleWorkflowException("Unsupported property type: " + property.getClass().getName());
}
converter.convertProperty(contentType, formSet.getId(), formConfig, property, conversion);
}
}
}
if (formDefinition != null && formDefinition.getFormPropertyDefinitions() != null && !formDefinition.getFormPropertyDefinitions().isEmpty()) {
for (FormPropertyDefinition def : formDefinition.getFormPropertyDefinitions()) {
if (def instanceof AlfrescoTransitionsPropertyDefinition) {
AlfrescoFormPropertyConverter converter = propertyConverters.get(def.getClass());
if (converter != null) {
converter.convertProperty(contentType, null, formConfig, def, conversion);
}
}
}
}
// Finally, add default "transitions" if not already added to the model
if (formConfig.getFormAppearance().getFormSet(AlfrescoConversionConstants.FORM_SET_RESPONSE) == null) {
formConfig.getFormAppearance().addFormSet(AlfrescoConversionConstants.FORM_SET_RESPONSE, null, null, null);
formConfig.getFormFieldVisibility().addShowFieldElement(AlfrescoConversionConstants.FORM_FIELD_TRANSITIONS);
formConfig.getFormAppearance().addFormField(AlfrescoConversionConstants.FORM_FIELD_TRANSITIONS, null, AlfrescoConversionConstants.FORM_SET_RESPONSE);
}
}
use of org.activiti.workflow.simple.alfresco.conversion.exception.AlfrescoSimpleWorkflowException in project Activiti by Activiti.
the class AlfrescoReferencePropertyConverter method addFieldReference.
protected void addFieldReference(Form form, String formSet, ReferencePropertyDefinition definition, M2Type contentType, WorkflowDefinitionConversion conversion) {
if (form.isStartForm()) {
throw new AlfrescoSimpleWorkflowException("Field references cannot be used on start-forms");
}
// Check if model contains an aspect for the property
String propertyName = getPropertyName(definition, conversion);
// Add property-reference to the context to be validated
PropertyReference reference = new PropertyReference(definition.getName());
AlfrescoConversionUtil.getPropertyReferences(conversion).add(reference);
// Add aspect to content-type
contentType.getMandatoryAspects().add(propertyName);
// Add read-only field to form
form.getFormFieldVisibility().addShowFieldElement(propertyName);
FormField field = new FormField();
form.getFormAppearance().addFormAppearanceElement(field);
field.setId(propertyName);
field.setLabelId(definition.getName());
field.setSet(formSet);
field.setControl(new FormFieldControl(AlfrescoConversionConstants.FORM_READONLY_TEMPLATE));
}
use of org.activiti.workflow.simple.alfresco.conversion.exception.AlfrescoSimpleWorkflowException in project Activiti by Activiti.
the class AlfrescoArtifactExporter method exportArtifacts.
/**
* Export all artifacts and configuration-files needed to run the process that is converted in the given
* {@link WorkflowDefinitionConversion}.
*
* @param conversion the conversion object to be exported
* @param repositoryFolder the folder where all repository-artifacts and configurations are exported to
* @param shareFolder the folder where all share-artifacts and configurations are exported to
*/
public void exportArtifacts(WorkflowDefinitionConversion conversion, File repositoryFolder, File shareFolder, boolean asExtension) {
validateArtifactTargets(repositoryFolder, shareFolder);
String processId = conversion.getProcess().getId();
try {
// Export process BPMN
File processFile = new File(repositoryFolder, getBpmnFileName(conversion));
processFile.createNewFile();
FileOutputStream processStream = new FileOutputStream(processFile);
writeBpmnModel(processStream, conversion);
processStream.close();
// Export content model
File contentModelFile = new File(repositoryFolder, getContentModelFileName(conversion));
contentModelFile.createNewFile();
FileOutputStream modelStream = new FileOutputStream(contentModelFile);
writeContentModel(modelStream, conversion);
modelStream.close();
// Export workflow deployer context XML
File springContextFile = new File(repositoryFolder, processId + SPRING_CONTEXT_FILE_SUFFIX);
springContextFile.createNewFile();
FileOutputStream springContextStream = new FileOutputStream(springContextFile);
writeWorkflowDeployerBean(springContextStream, processId, processFile.getName(), contentModelFile.getName());
springContextStream.close();
// Export share config
File shareConfigFile = new File(shareFolder, getShareConfigFileName(conversion));
shareConfigFile.createNewFile();
FileOutputStream shareConfigStream = new FileOutputStream(shareConfigFile);
writeShareConfig(shareConfigStream, conversion, asExtension);
shareConfigStream.close();
if (asExtension) {
File shareModuleDeploymentFile = new File(shareFolder, getShareModuleDeploymentFileName(conversion));
shareModuleDeploymentFile.createNewFile();
FileOutputStream shareModuleStream = new FileOutputStream(shareModuleDeploymentFile);
writeShareExtensionModule(shareModuleStream, conversion);
shareModuleStream.close();
}
// Export share custom context
File shareContextFile = new File(shareFolder, processId + SHARE_CONTEXT_FILE_SUFFIX);
shareContextFile.createNewFile();
FileOutputStream shareContextStream = new FileOutputStream(shareContextFile);
writeShareCustomConfigBean(shareContextStream, processId, shareConfigFile.getName());
shareContextStream.close();
} catch (IOException ioe) {
throw new AlfrescoSimpleWorkflowException("Error while exporting artifacts", ioe);
}
}
Aggregations