Package org.apache.slide.projector

Examples of org.apache.slide.projector.Result


        int firstInt = ((NumberValue) parameter.get(FIRST_NUMBER))
                .getNumber().intValue();
        int secondInt = ((NumberValue) parameter.get(SECOND_NUMBER))
                .getNumber().intValue();
        int calculatedResult = firstInt + secondInt;
        return new Result(StateDescriptor.OK, CALCULATED_RESULT,
                new NumberValue(new Integer(calculatedResult)));
    }
View Full Code Here


        if ( template == null ) throw new ProcessException(new ErrorMessage("templateArrayRenderer/fragmentNotFound", new String[] { fragment }));
        StringBuffer buffer = new StringBuffer(template.getLength());
        for ( int i = 0; i < getMaxIndex(parameter); i++ ) {
            template.evaluate(buffer, parameter, i);
        }
        return new Result(OK, OUTPUT, new StringValue(buffer.toString(), template.getContentType(), false));
    }
View Full Code Here

          if ( !(entry.getValue() instanceof NullValue) ) {
            parameterMap.put(entry.getKey(), entry.getValue());
          }
        }
        template.evaluate(buffer, parameterMap);
        return new Result(OK, OUTPUT, new StringValue(buffer.toString(), template.getContentType(), false));
    }
View Full Code Here

        javax.naming.Context ctx = new InitialContext();

        if ( ctx == null ) throw new ProcessException(new ErrorMessage("noInitialContextAvailable"));

        DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/TestDB");
        Result result = new Result(StateDescriptor.OK);
        if (ds != null) {
            ResultSet resultSet = null;
            PreparedStatement preparedStatement = null;
            Connection conn = null;
            try {
                conn = ds.getConnection();
                if(conn != null)  {
                    preparedStatement = conn.prepareStatement(statemenet);
                    for ( int i = 0; i < values.length; i++ ) {
                        // FIXME: We need a mapping for every sql type that should be supported
                        if ( values[i] instanceof StringValue ) {
                            preparedStatement.setString(i+1, values[i].toString());
                        } else if ( values[i] instanceof NumberValue ) {
                            preparedStatement.setInt(i+1, ((NumberValue)values[i]).getNumber().intValue());
                        } else if ( values[i] instanceof StreamableValue ) {
                            preparedStatement.setBinaryStream(i+1, ((StreamableValue)values[i]).getInputStream(), ((StreamableValue)values[i]).getContentLength());
                        }
                    }
                    if ( preparedStatement.execute() ) {
                        resultSet = preparedStatement.getResultSet();
                        List resultSetResources = new ArrayList();
                        ResultSetMetaData metaData = resultSet.getMetaData();
                        while ( resultSet.next() ) {
                            Map rowMap = new HashMap();
                            int columnCount = metaData.getColumnCount();
                            for ( int i = 0; i < columnCount; i++ ) {
                                String key = metaData.getColumnLabel(i+1);
                                Object object = resultSet.getObject(i+1);
                                if ( object instanceof String ) {
                                    rowMap.put(key, new StringValue((String)object));
                                } else if ( object instanceof Integer ) {
                                    rowMap.put(key, new NumberValue((Integer)object));
                                }
                            }
                            resultSetResources.add(new MapValue(rowMap));
                        }
                        Value[] resultEntries = new Value[resultSetResources.size()];
                        result.addResultEntry(RESULT, new ArrayValue((Value[] )resultSetResources.toArray(resultEntries)));
                    } else {
                        result.addResultEntry(ROW_COUNT, new NumberValue(new BigDecimal(preparedStatement.getUpdateCount())));
                    }
                    conn.close();
                }
            } catch (SQLException e) {
                throw new ProcessException(new ErrorMessage("sqlException"), e);
View Full Code Here

    public Result process(Map parameter, Context context) throws Exception {
        String id = parameter.get(ID).toString();
        String key = parameter.get(KEY).toString();
        Value[] arguments = ((ArrayValue)parameter.get(ARGUMENTS)).getArray();
        Locale locale = ((LocaleValue)context.getStore(Store.SESSION).get(LOCALE)).getLocale();
        return new Result(StateDescriptor.OK, SimpleProcessor.OUTPUT, new StringValue(MessageManager.getText(id, key, arguments, locale, id)));
    }
View Full Code Here

        }
        if ( user == null ) {
            context.addInformation(new Information(Information.ERROR, new ErrorMessage("register/failed"), new String[0]));
            state = FAILED;
        }
        return new Result(state, USER, user);
    }
View Full Code Here

                    defaultTemplate.evaluate(buffer, rowParameter);
                }
            }
            if ( footerTemplate != null ) footerTemplate.evaluate(buffer, parameter);
        }
        return new Result(OK, OUTPUT, new StringValue(buffer.toString(), defaultTemplate.getContentType(), false ));
    }
View Full Code Here

    public Result process(Map parameter, Context context) throws Exception {
        String fragment = ((StringValue)parameter.get(FRAGMENT)).toString();
        Template template = getRequiredFragment(fragment);
        StringBuffer buffer = new StringBuffer(template.getLength());
        template.evaluate(buffer, parameter);
        return new Result(OK, OUTPUT, new StringValue(buffer.toString(), template.getContentType(), template.isDocument() ));
    }
View Full Code Here

            new StateDescriptor(FALSE, new DefaultMessage("authenticated/state/false"))
         });

    public Result process(Map parameter, Context context) throws Exception {
        if ( context.getCredentials() == Projector.getCredentials() ) {
          return new Result(FALSE);
        }
        return new Result(TRUE);
    }
View Full Code Here

        }
        if ( role == null ) {
            context.addInformation(new Information(Information.ERROR, new ErrorMessage("createRole/failed"), new String[0]));
            state = FAILED;
        }
        return new Result(state, ROLE, role);
    }
View Full Code Here

TOP

Related Classes of org.apache.slide.projector.Result

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.