Package org.apache.slide.projector.value

Examples of org.apache.slide.projector.value.Value


        String username = parameter.get(USERNAME).toString();
        String retypedPassword = parameter.get(RETYPE_PASSWORD).toString();
        String password = parameter.get(PASSWORD).toString();
        String state = OK;
        // Check spelling
        Value user = NullValue.NULL;
        if ( !password.equals(retypedPassword) ) {
            context.addInformation(new Information(Information.ERROR, new ErrorMessage("register/passwordsNotIdentical"), new String[] { PASSWORD, RETYPE_PASSWORD }));
            state = FAILED;
        } else {
            try {
View Full Code Here


        });

    public Result process(Map parameter, Context context) throws Exception {
        String rolename = parameter.get(ROLENAME).toString();
        String state = OK;
        Value role = NullValue.NULL;
        try {
          role = Projector.getRepository().createRole(rolename, context.getCredentials())
        } catch ( RoleExistsException exception ) {
          context.addInformation(new Information(Information.ERROR, exception.getErrorMessage(), new String[] { ROLENAME }));
          state = FAILED;
View Full Code Here

    public Result process(Map parameter, Context context) throws Exception {
        StringBuffer buffer = new StringBuffer(1024);
        ArrayValue input = (ArrayValue)parameter.get(SimpleProcessor.INPUT);
        NumberValue offsetResource = (NumberValue)parameter.get(OFFSET);
        NumberValue itemsPerPageResource = (NumberValue)parameter.get(ITEMS_PER_PAGE);
        Value sortedByParameter = (Value)parameter.get(TableHandler.SORTED_BY);
        Value orderParameter = (Value)parameter.get(TableHandler.ORDER);
        String sortedBy = null, order = null;
        if ( sortedByParameter != NullValue.NULL ) sortedBy = sortedByParameter.toString();
        if ( orderParameter != NullValue.NULL ) order = orderParameter.toString();
        String id = parameter.get(TableHandler.ID).toString();
        Store store = context.getStore(StoreHelper.getStoreByName(parameter.get(TableHandler.STORE).toString()));
        MapValue idResource = (MapValue)store.get(id);
        Map tableMap;
        if ( idResource == null) {
            tableMap = new HashMap();
            MapValue tableState = new MapValue(tableMap);
            store.put(id, tableState);
        } else {
            tableMap = idResource.getMap();
            NumberValue offset = (NumberValue)idResource.getMap().get(TableHandler.CURRENT_POSITION);
            if ( offset != null ) offsetResource = offset;
            NumberValue itemsPerPage = (NumberValue)idResource.getMap().get(ITEMS_PER_PAGE);
            if ( itemsPerPage != null ) itemsPerPageResource = itemsPerPage;
            Value sortedByValue = (Value)idResource.getMap().get(TableHandler.SORTED_BY);
            if ( sortedByValue != null && sortedByValue != NullValue.NULL ) sortedBy = sortedByValue.toString();
            Value orderValue = (Value)idResource.getMap().get(TableHandler.ORDER);
            if ( orderValue != null  && orderValue != NullValue.NULL ) order = orderValue.toString();
        }
      // sort table
        if ( sortedBy != null && order != null ) {
          Comparator comparator = new RowComparator(sortedBy, order);
          Arrays.sort(input.getArray(), comparator);
View Full Code Here

        });
  private final static ParameterDescriptor[] parameterDescriptor = new ParameterDescriptor[]{ new ParameterDescriptor(INPUT, new ParameterMessage("exists/input"), new AnyValueDescriptor(), NullValue.NULL) };
   
    public Result process(Map parameter, Context context) throws Exception {
        Value input = (Value)parameter.get(INPUT);
        if ( input instanceof NullValue ) {
            return new Result(FALSE);
        }
        return new Result(TRUE);
    }
View Full Code Here

    public Result process(Map parameter, Context context) throws Exception {
        String id = parameter.get(ID).toString();
        Store store = context.getStore(StoreHelper.getStoreByName(parameter.get(STORE).toString()));
        MapValue idResource = (MapValue)store.get(id);
        Value targetPosition = (Value)parameter.get(TARGET_POSITION);
        Value sortedBy = (Value)parameter.get(SORTED_BY);
        Value order = (Value)parameter.get(ORDER);
        Value expand = (Value)parameter.get(EXPAND);
        Value collapse = (Value)parameter.get(COLLAPSE);
        Map tableMap;
        if ( idResource == null) {
            tableMap = new HashMap();
            idResource = new MapValue(tableMap);
            store.put(id, idResource);
        } else {
            tableMap = idResource.getMap();
        }
        if ( targetPosition != NullValue.NULL ) {
          tableMap.put(CURRENT_POSITION, targetPosition);
        }
        if ( sortedBy != NullValue.NULL ) {
            tableMap.put(SORTED_BY, sortedBy);
        }
        if ( order != NullValue.NULL ) {
            tableMap.put(ORDER, order);
        }
        if ( collapse != NullValue.NULL || expand != NullValue.NULL ) {
          MapValue sizeValue = (MapValue)tableMap.get(SIZE);
          Map size;
          if ( sizeValue == null ) {
            size = new HashMap();
            tableMap.put(SIZE, new MapValue(size));
          } else {
            size = sizeValue.getMap();
          }
          if ( collapse != NullValue.NULL ) {
            size.put(collapse.toString(), COLLAPSED);
          }
          if ( expand != NullValue.NULL ) {
            size.put(expand.toString(), EXPANDED);
          }
        }
View Full Code Here

    public abstract ParameterDescriptor getParameterDescriptor();

    public abstract ResultEntryDescriptor getResultEntryDescriptor();

    public Result process(Map parameter, Context context) throws Exception {
        Value input = (Value)parameter.get(INPUT);
        Value output = process(input, context);
        return new Result(StateDescriptor.OK, OUTPUT, output);
    }
View Full Code Here

    public Result process(Map parameter, Context context) throws Exception {
      Value[] controlDescriptions = ((ArrayValue)parameter.get(CONTROL_DESCRIPTIONS)).getArray();
      Value[] triggerDescriptions = ((ArrayValue)parameter.get(TRIGGER_DESCRIPTIONS)).getArray();
      URI actionUri = (URIValue)parameter.get(ACTION);
      Value errorsProcessorUri = (Value)parameter.get(ERRORS_PROCESSOR);
      Locale locale = ((LocaleValue)parameter.get(LOCALE)).getLocale();
        String state = DEFAULT_STATE;
        List informations = context.getInformations();
    MapValue mapResource = (MapValue)((FormStore)context.getStore(Store.FORM)).getDomain();
    List generatedControls = new ArrayList();
    List involvedParameters = new ArrayList();
    for (int i = 0; i < controlDescriptions.length; i++ ) {
          Map controlParameters = ((MapValue)controlDescriptions[i]).getMap();
          String controlName = controlParameters.get(CONTROL_NAME).toString();
          URI controlUri = (URI)controlParameters.get(CONTROL);
          Control control = (Control)ProcessorManager.getInstance().getProcessor(controlUri);
          Value controlActionUri = (Value)controlParameters.get(Control.ACTION);
          if ( controlActionUri == NullValue.NULL ) controlActionUri = actionUri;
           controlParameters.put(Control.ACTION, controlActionUri);
          try {
            ProcessorManager.prepareValues(control.getParameterDescriptors(), controlParameters, context);
          } catch ( ValidationException exception ) {
            throw new ValidationException(new ErrorMessage("controlComposer/controlParameterInvalid", new Object[] { controlUri }), exception);
          }
            Value controlContainerUri = (Value)controlParameters.get(CONTROL_CONTAINER);
            ParameterDescriptor parameterDescriptor = Control.getParameterDescriptor(controlParameters, context);
            String parameterName = parameterDescriptor.getName();
            involvedParameters.add(new StringValue(parameterName));
            ParameterMessage description = (ParameterMessage)parameterDescriptor.getDescription();
            boolean required = parameterDescriptor.isRequired();
            String controlState = Control.OPTIONAL_CONTROL;
            if ( required ) {
              controlState = Control.REQUIRED_CONTROL;
            }
            Object controlValue = null;
            boolean validate = false;
            if ( mapResource != null ) {
              controlValue = mapResource.getMap().get(parameterName);
              validate = false;
              BooleanValue validateResource = ((BooleanValue)mapResource.getMap().get(VALIDATE));
              if ( validateResource != null ) validate = validateResource.booleanValue();
            }
            if ( validate ) {
              try {
                controlValue = ProcessorManager.prepareValue(parameterDescriptor, controlValue, context);
              } catch ( ValidationException exception ) {
                controlValue = StringValueDescriptor.ANY.valueOf(controlValue, context).toString();
                context.addInformation(new Information(Information.ERROR, exception.getErrorMessage(), new String[] { parameterName }));
              }
              controlParameters.put(Control.VALUE, controlValue);
              if ( hasErrors(informations, parameterName) ) {
                if ( required ) {
                  controlState = Control.REQUIRED_INVALID_CONTROL;
                } else {
                  controlState = Control.OPTIONAL_INVALID_CONTROL;
                }
                explodeInformations(controlParameters, informations, parameterName, locale);
              } else {
                if ( required ) {
                  controlState = Control.REQUIRED_VALID_CONTROL;
                } else {
                  controlState = Control.OPTIONAL_VALID_CONTROL;
                }
              }
            }
            controlParameters.put(Control.STATE, controlState);
            controlParameters.put(Control.VALUE, controlValue);
            Result controlResult = control.process(controlParameters, context);
            if ( controlContainerUri != NullValue.NULL ) {
              Processor controlContainer = ProcessorManager.getInstance().getProcessor((URI)controlContainerUri);
              Map controlContainerParameters = new HashMap();
              controlContainerParameters.putAll(parameter);
              if ( hasErrors(informations, parameterName) ) {
                explodeInformations(controlContainerParameters, informations, parameterName, locale);
              }
              controlContainerParameters.put(Control.STATE, controlState);
              controlContainerParameters.put(CONTROL, controlResult.getResultEntries().get(OUTPUT));
              controlContainerParameters.put(TITLE, description.getTitle(locale, parameterName ));
              try {
                controlContainerParameters.put(TEXT, description.getText(locale));
                controlContainerParameters.put(PROMPT, description.getPrompt(locale));
              } catch ( MessageNotFoundException exception ) {
                controlContainerParameters.put(TEXT, NO_PARAMETER_MESSAGE_AVAILABLE.getText(locale, "&nbsp;"));
                controlContainerParameters.put(PROMPT, NO_PARAMETER_MESSAGE_AVAILABLE.getPrompt(locale, "&nbsp;"));
              }
              try {
                ProcessorManager.prepareValues(controlContainer.getParameterDescriptors(), controlContainerParameters, context);
              } catch ( ValidationException exception ) {
                throw new ValidationException(new ErrorMessage("controlComposer/controlContainerParameterInvalid", new Object[] { controlContainerUri }), exception);
              }
              Result controlContainerResult = controlContainer.process(controlContainerParameters, context);
              generatedControls.add(new MapValue(controlName, (Value)controlContainerResult.getResultEntries().get(OUTPUT)));
            } else {
              generatedControls.add(new MapValue(controlName, (Value)controlResult.getResultEntries().get(OUTPUT)));
            }
            if ( controlState == Control.OPTIONAL_INVALID_CONTROL || controlState == Control.REQUIRED_INVALID_CONTROL  ) {
              state = INVALID_STATE;
            } else if ( state == DEFAULT_STATE && ( controlState == Control.OPTIONAL_VALID_CONTROL || controlState == Control.REQUIRED_VALID_CONTROL ) ) {
              state = VALID_STATE;
            }
        }
        Result composerResult = new Result(state, GENERATED_CONTROLS, new ArrayValue((Value [])generatedControls.toArray(new Value[generatedControls.size()])));
    List generatedTriggers = new ArrayList();
    for (int i = 0; i < triggerDescriptions.length; i++ ) {
          Map triggerParameters = ((MapValue)triggerDescriptions[i]).getMap();
          String triggerName = triggerParameters.get(TRIGGER_NAME).toString();
          Value involvedTriggerParameters = (Value)triggerParameters.get(Trigger.INVOLVED_PARAMETERS);
          if ( involvedTriggerParameters == NullValue.NULL ) {
            involvedTriggerParameters = new ArrayValue((StringValue[])involvedParameters.toArray(new StringValue[involvedParameters.size()]));
          }
          triggerParameters.put(Trigger.INVOLVED_PARAMETERS, involvedTriggerParameters);
          URI triggerUri = (URI)triggerParameters.get(TRIGGER);
          Trigger trigger = (Trigger)ProcessorManager.getInstance().getProcessor(triggerUri);
          Value triggerActionUri = (Value)triggerParameters.get(Trigger.ACTION);
          if ( triggerActionUri == NullValue.NULL ) triggerActionUri = actionUri;
           triggerParameters.put(Trigger.ACTION, triggerActionUri);
          try {
            ProcessorManager.prepareValues(trigger.getParameterDescriptors(), triggerParameters, context);
          } catch ( ValidationException exception ) {
            throw new ValidationException(new ErrorMessage("controlComposer/triggerParameterInvalid", new Object[] { triggerUri }), exception);
          }
            Value triggerContainerUri = (Value)triggerParameters.get(TRIGGER_CONTAINER);
            Result triggerResult = trigger.process(triggerParameters, context);
            if ( triggerContainerUri != NullValue.NULL ) {
              Processor triggerContainer = ProcessorManager.getInstance().getProcessor((URI)triggerContainerUri);
              Map triggerContainerParameters = new HashMap();
              triggerContainerParameters.putAll(parameter);
View Full Code Here

        parameter.put(HANDLER, ProcessorManager.getInstance().process(ProcessorManager.URL, parameter.get(HANDLER), context));
        List controlDescriptions = new ArrayList();
        List triggerDescriptions = new ArrayList();
        for (int i = 0; i < parameterDescriptors.length; i++) {
          String parameterName = parameterDescriptors[i].getName();
          Value value = (Value)parameter.get(parameterName);
            if (parameterName.startsWith(CONTROL_IDENTIFIER)) {
              ((MapValue)value).getMap().put(CONTROL_NAME, parameterName);
              controlDescriptions.add(value);
            } else if (parameterName.startsWith(TRIGGER_IDENTIFIER)) {
              ((MapValue)value).getMap().put(TRIGGER_NAME, parameterName);
View Full Code Here

  };
 
  public Result process(Map parameter, Context context) throws Exception {
    URI processorUri = ProcessorManager.getInstance().getURI(this);
    context.setBookmark(processorUri);
    Value uri = (Value)parameter.get(PROCESSOR);
        if ( uri == null || uri == NullValue.NULL ) {
          uri = (URI)context.getStore(Store.SESSION).get(PROCESSOR);
        }
        if ( uri == null ) {
          throw new ProcessException(new ErrorMessage("test/noProcessorSpecified"));
        }
        context.setProcess((URI)uri);
      context.getStore(Store.SESSION).put(PROCESSOR, uri);
      Value stepResource = (Value)context.getStore(Store.FORM).get(Process.STEP);
      String step;
      if ( stepResource == null ) {
        step = FORM_STEP;
      } else {
        step = stepResource.toString();
      }
    context.setStep(step);
    Processor formProcessor = ProcessorManager.getInstance().getProcessor(FORM_PROCESSOR);
        Processor resultRenderer = ProcessorManager.getInstance().getProcessor(RESULT_RENDERER);
        Processor processor = ProcessorManager.getInstance().getProcessor((URI)uri);
View Full Code Here

  }
 
  static String getStep(String firstStep, Context context) {
    Store sessionStore = context.getStore(Store.SESSION);
    if ( sessionStore != null ) {
      Value stepParameter = (Value)StoreHelper.get(sessionStore, context.getProcess().toString(), STEP);
      if (stepParameter != null && stepParameter instanceof StringValue ) {
        return stepParameter.toString();
      }
    }
    return firstStep;
  }
View Full Code Here

TOP

Related Classes of org.apache.slide.projector.value.Value

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.