Package org.amplafi.flow

Examples of org.amplafi.flow.FlowPropertyDefinition


     */
    @Test(enabled=false) // for now #2179, #2192 forces these to be defined in FlowImpl
    public void testMergingWithStandardFlowPropertyDefinition() {
        FlowPropertyDefinitionImpl flowPropertyDefinition = new FlowPropertyDefinitionImpl(FSHIDE_FLOW_CONTROL);
        assertEquals(flowPropertyDefinition.getDataClass(), String.class);
        FlowPropertyDefinition standardFlowPropertyDefinition =
                this.getFlowTranslatorResolver().getFlowPropertyDefinition(FSHIDE_FLOW_CONTROL);
        assertEquals(standardFlowPropertyDefinition.getDataClass(), boolean.class);
        getFlowTranslatorResolver().resolve("", flowPropertyDefinition);
        assertEquals(flowPropertyDefinition.getDataClass(), boolean.class);
        assertNotSame(standardFlowPropertyDefinition, flowPropertyDefinition);
        standardFlowPropertyDefinition =
                this.getFlowTranslatorResolver().getFlowPropertyDefinition(FSHIDE_FLOW_CONTROL);
View Full Code Here


        if (object instanceof FlowPropertyProvider) {
            getFlowTranslatorResolver().resolve((FlowPropertyProvider)object);
        }
        if ( object instanceof FlowPropertyDefinition) {
            // HACK : really should be handling the wiring issue without special casing.
            FlowPropertyDefinition flowPropertyDefinition = (FlowPropertyDefinition) object;
            for(FlowPropertyValueChangeListener flowPropertyValueChangeListener: flowPropertyDefinition.getFlowPropertyValueChangeListeners()) {
                wireDependencies(flowPropertyValueChangeListener);
            }
            wireDependencies(flowPropertyDefinition.getTranslator());
            wireDependencies(flowPropertyDefinition.getFlowPropertyValuePersister());
            wireDependencies(flowPropertyDefinition.getFlowPropertyValueProvider());
        }
    }
View Full Code Here

    /**
     * TODO -- copied from FlowActivityImpl -- not certain this is good idea.
     * Need somewhat to find statically defined properties - not enough to always be looking at the flowState.
     */
    protected <T> FlowPropertyDefinition getFlowPropertyDefinitionWithCreate(String key, Class<T> expected, T sampleValue) {
        FlowPropertyDefinition flowPropertyDefinition = getFlowPropertyDefinition(key);
        if (flowPropertyDefinition == null) {
            flowPropertyDefinition = getFlowManagement().createFlowPropertyDefinition(this, key, expected, sampleValue);
        }
        return flowPropertyDefinition;
    }
View Full Code Here

                }
            } else {
                this.propertyDefinitions = new LinkedHashMap<String, FlowPropertyDefinition>();
            }
        }
        FlowPropertyDefinition current = this.propertyDefinitions.get(flowPropertyDefinition.getName());
        if ( current != null ) {
            if ( !flowPropertyDefinition.merge(current) ) {
                throw new ApplicationIllegalArgumentException(flowPropertyDefinition,": cannot be merged with ",current);
            }
        }
View Full Code Here


    @Deprecated
    @Override
    public boolean setRawProperty(String key, String value) {
        FlowPropertyDefinition flowPropertyDefinition = getFlowPropertyDefinitionWithCreate(key, null, value);
        return setRawProperty(null, flowPropertyDefinition, value);
    }
View Full Code Here

    public <T> T getProperty(String key, Class<? extends T> expected) {
        if (isActive()) {
            FlowActivity currentActivity = getCurrentActivity();
            return currentActivity.getProperty(key, expected);
        } else {
            FlowPropertyDefinition flowPropertyDefinition = getFlowPropertyDefinitionWithCreate(key, expected, null);
            return (T) getPropertyWithDefinition(this, flowPropertyDefinition);
        }
    }
View Full Code Here

            return getFlowManagement().getLog();
        }
    }

    protected String getRawProperty(FlowPropertyProvider flowPropertyProvider, String key) {
        FlowPropertyDefinition propertyDefinition = getFlowPropertyDefinitionWithCreate(key, null, null);
        return getRawProperty(flowPropertyProvider, propertyDefinition);
    }
View Full Code Here

            flowActivity.setFlowPropertyProviderName(activityName);
            for (PropertyScope propertyScope: PropertyScope.values()) {
                for(PropertyUsage propertyUsage: PropertyUsage.values()) {
                    String name= propertyScope+"_"+propertyUsage;
                    String externalInitial = "ext_"+name;
                    FlowPropertyDefinition flowPropertyDefinition = new FlowPropertyDefinitionImpl(name).initAccess(propertyScope, propertyUsage);
                    flowActivity.addPropertyDefinitions(flowPropertyDefinition);
                    initialFlowState.put(name, externalInitial);
                }
            }
            flowTestingUtils.addFlowDefinition(flowTypeName, flowActivity);
View Full Code Here

     * explicit test to make sure that only properties that should be exported are exported.
     */
    @Test(enabled=TEST_ENABLED, dataProvider="exportingPropertiesData")
    public void testExportingProperties(PropertyUsage propertyUsage, PropertyScope propertyScope) {
        FlowTestingUtils flowTestingUtils = new FlowTestingUtils();
        FlowPropertyDefinition flowPropertyDefinition = new FlowPropertyDefinitionImpl("testProp", boolean.class).initAccess(propertyScope, propertyUsage);
        FlowActivityImpl flowActivity =newFlowActivity();
        flowActivity.addPropertyDefinitions(flowPropertyDefinition);
        String flowTypeName = flowTestingUtils.addFlowDefinition(flowActivity);
        FlowState flowState = flowTestingUtils.getFlowManagement().startFlowState(flowTypeName, false, null, null);
        flowState.setProperty("not-a-property", true);
View Full Code Here

    private void addValidation(FlowActivity activity, IRender render) {
        if (render instanceof AbstractFormComponent && render instanceof ValidatableField) {
            AbstractFormComponent formComponent = (AbstractFormComponent) render;
            IBinding alreadyBinding = formComponent.getBinding(ALREADY_ADDED_BINDING);
            if ( alreadyBinding == null) {
                FlowPropertyDefinition definition = activity.getFlowPropertyDefinition(this.key);
                if ( definition != null) {
                    IBinding validatorsBinding = formComponent.getBinding(VALIDATORS);
                    if (definition.isDynamic()) {
                        IBinding htmlClassBinding = formComponent.getBinding(HTML_CLASS);
                        IBinding htmlOnBlurBinding = formComponent.getBinding(HTML_ONBLUR);
                        String htmlClassToAdd = "refresh-" + formComponent.getClientId();
                        String htmlClass = null;
                        if ( htmlClassBinding == null) {
                            htmlClass= htmlClassToAdd;
                        } else if (htmlClassBinding instanceof LiteralBinding) {
                            htmlClass =(String)htmlClassBinding.getObject(String.class) + " "+htmlClassToAdd;
                        } else {
                            getLog().debug(activity.getFullActivityInstanceNamespace()+ ": cannot add class to component="+formComponent);
                        }
                        if (htmlClass != null) {
                            formComponent.setBinding(HTML_CLASS, new LiteralBinding("html class", valueConverter, location, htmlClass));
                        }
                        if (htmlOnBlurBinding == null) {
                            String htmlOnBlurValue = "javascript:amplafi.util.refreshIfChanged(this);";
                            formComponent.setBinding(HTML_ONBLUR, new LiteralBinding("html on blur", valueConverter, location, htmlOnBlurValue));

                        } else {
                            getLog().debug(activity.getFullActivityInstanceNamespace()+ ": cannot add onblur to component="+formComponent);
                        }
                    }
                    if (validatorsBinding == null) {
                        String validators = definition.getValidators();
                        if ( definition.getPropertyRequired() == FlowActivityPhase.advance) {
                            if ( isBlank(validators)) {
                                validators = REQUIRED;
                            } else {
                                // may re-add required if already present - seems like a minor issue
                                validators = REQUIRED + "," + validators;
View Full Code Here

TOP

Related Classes of org.amplafi.flow.FlowPropertyDefinition

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.