Package org.apache.slide.projector.value

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


        } else {
          value = requirementDescriptor[i].getDefaultValue();
          store.put(requirementDescriptor[i].getName(), value);
        }
      }
      Value castedValue = requirementDescriptor[i].getValueDescriptor().valueOf(value, context);
      requirementDescriptor[i].getValueDescriptor().validate(castedValue, context);
      if ( castedValue != value ) {
        store.put(requirementDescriptor[i].getName(), castedValue);
      }
    }
View Full Code Here


  public static void saveResults(Step step, Result stepResult, Store stepStore, Result result, ResultEntryDescriptor[] resultEntryDescriptors, Context context) throws ProcessException {
    // save results by using result configuration
    for (Iterator i = step.getResultConfigurations().entrySet().iterator(); i.hasNext();) {
      Map.Entry entry = (Map.Entry)i.next();
      String resultName = (String)entry.getKey();
      Value resultValue = (Value)stepResult.getResultEntries().get(resultName);
      ((ResultConfiguration)entry.getValue()).storeValue(resultValue, stepStore, result, resultEntryDescriptors, context);
    }
  }
View Full Code Here

    Result processResult = new Result(state);
    // copy defined results from context store to result
    ResultEntryDescriptor[] resultEntryDescriptors = getResultDescriptor().getResultEntryDescriptors();
    for (int i = 0; i < resultEntryDescriptors.length; i++) {
      ResultEntryDescriptor descriptor = resultEntryDescriptors[i];
      Value resultValue = (Value)result.getResultEntries().get(descriptor.getName());
      if (resultValue != null) {
        processResult.addResultEntry(descriptor.getName(), resultValue);
      }
    }
    return processResult;
View Full Code Here

    int storeId = StoreHelper.getStoreByName(store);
        String key = element.getAttributeValue("key");
        String domain = element.getAttributeValue("domain");
        URI processorUri = ( processor == null ? null : new URIValue(processor) );
        Iterator children = element.getChildren().iterator();
      Value input = null;
        if ( children.hasNext() ) {
          Element childElement = (Element)children.next();
          input = ValueFactoryManager.getInstance().loadValue(childElement);
        }
        return new AnyValue(processor, input, result, storeId, key, domain);
View Full Code Here

            });

    public Result process(Map parameter, Context context) throws Exception {
        Map map = ((MapValue)parameter.get(MAP)).getMap();
        String key = ((StringValue)parameter.get(KEY)).toString();
        Value entry = (Value)map.get(key);
        if ( entry == null ) return new Result(KEY_NOT_FOUND);
        return new Result(StateDescriptor.OK, SimpleProcessor.OUTPUT, entry);
    }
View Full Code Here

import org.apache.slide.projector.value.StringValue;
import org.apache.slide.projector.value.Value;

public class URL extends SimpleProcessor {
    public Value process(Value input, Context context) throws Exception {
        Value output;
        if ( context instanceof HttpContext ) {
            output = new StringValue(((HttpContext)context).getContextPath() + "/" + ((StringValue)input).toString());
        } else {
            throw new ProcessException(new ErrorMessage("httpContextRequired"));
        }
View Full Code Here

            tableMap = new HashMap();
            MapValue tableState = new MapValue(tableMap);
            store.put(id, tableState);
        } else {
            tableMap = idResource.getMap();
            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();
            Value sizeValue = (Value)idResource.getMap().get(TableHandler.SIZE);
            if ( sizeValue != null  && sizeValue != NullValue.NULL ) size = ((MapValue)sizeValue).getMap();
        }
        // create headers and columns and call super...
      StringBuffer headersBuffer = new StringBuffer(1024);
      Value []columns = ((ArrayValue)parameter.get(COLUMNS_PARAMETER)).getArray();
      for ( int i = 0; i < columns.length; i++ ) {
        Map columnMap = ((MapValue)columns[i]).getMap();
        boolean sortable = ((BooleanValue)columnMap.get(SORTABLE)).booleanValue();
        if ( ascendingHeaderColumnTemplate == null || descendingHeaderColumnTemplate == null ) sortable = false;
        boolean resizable = ((BooleanValue)columnMap.get(RESIZABLE)).booleanValue();
        Value header = (Value)columnMap.get(HEADER);
        Map columnHeaderParameters = new HashMap();
        columnHeaderParameters.putAll(parameter);
        columnHeaderParameters.putAll(columnMap);
        Template template = headerColumnTemplate;
        String key = columnMap.get(KEY).toString();
      template = headerColumnTemplate;
        if ( resizable && collapsedColumnTemplate != null && collapsedHeaderColumnTemplate != null ) {
            if ( size != null && TableHandler.COLLAPSED.equals(size.get(key))) {
              createResizableHandler(key, TableHandler.EXPAND, handlerUrl, storeName, id, columnHeaderParameters, parameters);
              template = collapsedHeaderColumnTemplate;
            } else {
              createResizableHandler(key, TableHandler.COLLAPSE, handlerUrl, storeName, id, columnHeaderParameters, parameters);
            }
        }
        if ( sortable && template != collapsedHeaderColumnTemplate ) {
            String requestedOrder = TableHandler.ASCENDING;
            if ( sortedBy != null && sortedBy.equals(key) ) {
              if ( order.equals(TableHandler.ASCENDING) ) {
                template = ascendingHeaderColumnTemplate;
                    requestedOrder = TableHandler.DESCENDING;
              } else {
                template = descendingHeaderColumnTemplate;
                    requestedOrder = TableHandler.ASCENDING;
              }
            }
            createSortableHandler(key, requestedOrder, handlerUrl, storeName, id, columnHeaderParameters, parameters);
        }
        template.evaluate(headersBuffer, columnHeaderParameters);
      }
      parameter.put(HEADERS, new StringValue(headersBuffer.toString()));
      Value []input = ((ArrayValue)parameter.get(SimpleProcessor.INPUT)).getArray();
      for ( int i = 0; i < input.length; i++ ) {
          StringBuffer columnsBuffer = new StringBuffer(1024);
            Map inputParameter = ((MapValue)input[i]).getMap();
        for ( int j = 0; j < columns.length; j++ ) {
            Map columnMap = ((MapValue)columns[j]).getMap();
            boolean replaceColumn = ((BooleanValue)columnMap.get(REPLACE_COLUMN)).booleanValue();
            Value processorUri = (Value)columnMap.get(PROCESSOR);
            Map columnParameters = new HashMap();
            columnParameters.putAll(parameter);
            String key = columnMap.get(KEY).toString();
            String name = columnMap.get(NAME).toString();
            Object value = columnMap.get(VALUE);
            if ( value == null || value == NullValue.NULL ) {
              value = inputParameter.get(key);
            }
            columnParameters.put(name, value);
            if ( processorUri != NullValue.NULL ) {
                  Processor processor = ProcessorManager.getInstance().getProcessor((URI)processorUri);
                  Value processorParameters = (Value)columnMap.get(PARAMETERS);
                  if ( processorParameters instanceof MapValue ) {
                    columnParameters.putAll(((MapValue)processorParameters).getMap());
                  }
                Result processorResult = ProcessorManager.process(processor, columnParameters, context);
                String resultKey = columnMap.get(RESULT).toString();
                Value resultEntry = (Value)processorResult.getResultEntries().get(resultKey);
                if ( resultEntry instanceof PrintableValue ) {
                  if ( replaceColumn ) {
                    ((PrintableValue)resultEntry).print(columnsBuffer);
                  } else {
                    StringBuffer resultBuffer = new StringBuffer();
View Full Code Here

                // check for SimpleProcessor to avoid HashMap creation
                if ( processor instanceof EnvironmentConsumer ) {
                    Process.checkRequirements((EnvironmentConsumer)processor, context);
                }
                if ( processor instanceof SimpleProcessor ) {
                    Value preparedValue = prepareValue(parameterDescriptors[0], input, context);
                    input = ((SimpleProcessor)processor).process(preparedValue, context);
                } else {
                    Map parameters = new HashMap();
                    if ( parameterDescriptors.length == 1 ) {
                        parameters.put(parameterDescriptors[0].getName(), prepareValue(parameterDescriptors[0], input, context));
View Full Code Here

    public static void prepareValues(ParameterDescriptor[] parameterDescriptors, Map parameters, Context context) throws Exception {
      for ( int i = 0; i < parameterDescriptors.length; i++ ) {
        String parameterName = parameterDescriptors[i].getName();
        Object parameterValue = parameters.get(parameterName);
        Value preparedValue = prepareValue(parameterDescriptors[i], parameterValue, context);
        parameters.put(parameterName, preparedValue);
      }
    }
View Full Code Here

        parameters.put(parameterName, preparedValue);
      }
    }
   
    public static Value prepareValue(ParameterDescriptor parameterDescriptor, Object value, Context context) throws Exception {
      Value preparedValue;
      if ( value instanceof AnyValue ) {
         value = ((AnyValue)value).load(context);
      }
      if ( value == null || value instanceof NullValue ) {
            if ( parameterDescriptor.isRequired() ) {
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.