Search in sources :

Example 11 with OptionElementImpl

use of org.asqatasun.entity.option.OptionElementImpl in project Asqatasun by Asqatasun.

the class AuditSetUpFormFieldHelper method applyRestrictionToAuditSetUpFormField.

/**
 * A restriction can be applied to an AuditSetUpFormField when an option
 * matches with a parameter (by its code). In this case, regarding the type
 * of the FormField, the value of the option override the default
 *
 * @param ap
 * @param optionElementSet
 */
public void applyRestrictionToAuditSetUpFormField(AuditSetUpFormField ap, Collection<OptionElementImpl> optionElementSet) {
    if (ap.getFormField() instanceof NumericalFormField) {
        OptionElementImpl optionElement = getOptionFromOptionSet(optionElementSet, ap.getParameterElement().getParameterElementCode());
        if (optionElement != null) {
            ((NumericalFormField) ap.getFormField()).setMaxValue(optionElement.getValue());
            ap.getFormField().setValue(optionElement.getValue());
        }
    } else if (ap.getFormField() instanceof SelectFormField) {
        activateSelectFormField((SelectFormField) ap.getFormField(), optionElementSet);
    } else if (ap.getFormField() instanceof TextualFormField) {
        OptionElementImpl optionElement = getOptionFromOptionSet(optionElementSet, ap.getParameterElement().getParameterElementCode());
        if (optionElement != null) {
            (ap.getFormField()).setValue(optionElement.getValue());
        }
    }
}
Also used : TextualFormField(org.asqatasun.webapp.ui.form.TextualFormField) OptionElementImpl(org.asqatasun.entity.option.OptionElementImpl) NumericalFormField(org.asqatasun.webapp.ui.form.NumericalFormField) SelectFormField(org.asqatasun.webapp.ui.form.SelectFormField)

Aggregations

OptionElementImpl (org.asqatasun.entity.option.OptionElementImpl)11 NumberFormat (java.text.NumberFormat)1 Set (java.util.Set)1 NoResultException (javax.persistence.NoResultException)1 NonUniqueResultException (javax.persistence.NonUniqueResultException)1 Query (javax.persistence.Query)1 Option (org.asqatasun.entity.option.Option)1 OptionImpl (org.asqatasun.entity.option.OptionImpl)1 Parameter (org.asqatasun.entity.parameterization.Parameter)1 Test (org.asqatasun.entity.reference.Test)1 User (org.asqatasun.entity.user.User)1 ChangeTestWeightCommand (org.asqatasun.webapp.command.ChangeTestWeightCommand)1 NumericalFormField (org.asqatasun.webapp.ui.form.NumericalFormField)1 SelectElement (org.asqatasun.webapp.ui.form.SelectElement)1 SelectFormField (org.asqatasun.webapp.ui.form.SelectFormField)1 TextualFormField (org.asqatasun.webapp.ui.form.TextualFormField)1 Test (org.junit.Test)1