protected void addAssociation( Form form, String formSet, ReferencePropertyDefinition referenceDefinition, M2Type contentType, WorkflowDefinitionConversion conversion) { M2Model model = AlfrescoConversionUtil.getContentModel(conversion); // Check if model contains an aspect for the property String propertyName = getPropertyName(referenceDefinition, conversion); M2ClassAssociation association = new M2ClassAssociation(); association.setName(propertyName); association.setTitle(referenceDefinition.getName()); M2AssociationSource source = new M2AssociationSource(); source.setMany(false); source.setMandatory(true); M2AssociationTarget target = new M2AssociationTarget(); target.setClassName(referenceDefinition.getType()); target.setMandatory(referenceDefinition.isMandatory()); // Determine whether or not it's allowed to select multiple targets boolean isTargetMany = extractBooleanFromParameters( referenceDefinition.getParameters(), AlfrescoConversionConstants.PARAMETER_REFERENCE_MANY, false); target.setMany(isTargetMany); association.setTarget(target); association.setSource(source); M2Aspect aspect = model.getAspect(propertyName); if (aspect != null) { if (aspect.getAssociations().isEmpty()) { aspect.getAssociations().add(association); } contentType.getMandatoryAspects().add(propertyName); } else { contentType.getAssociations().add(association); } // Add field to form form.getFormFieldVisibility().addShowFieldElement(propertyName); FormField field = new FormField(); form.getFormAppearance().addFormAppearanceElement(field); field.setId(propertyName); field.setSet(formSet); }
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"); } M2Model model = AlfrescoConversionUtil.getContentModel(conversion); // Check if model contains an aspect for the property String propertyName = getPropertyName(definition, conversion); if (model.getAspect(propertyName) == null) { throw new AlfrescoSimpleWorkflowException( "The property '" + definition.getName() + "' is not used in a from prior to this form: " + contentType.getName() + " - " + propertyName); } // 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)); }