Package org.drools.template.parser

Examples of org.drools.template.parser.DecisionTableParseException


        // list
        {
            actionTypeMap.put( new Integer( column ),
                               new ActionType( ActionType.DESCRIPTION ) );
        } else {
            throw new DecisionTableParseException( "Invalid column header (ACTION type), " + "should be CONDITION or ACTION (etc..) row number:" + (row + 1) + " cell number:" + (column + 1) + " - does not contain a leading C or A identifer." );
        }
    }
View Full Code Here


                                  _listeners.get( sheetName ) );

                }
            }
        } catch ( InvalidFormatException e ) {
            throw new DecisionTableParseException( "An error occurred opening the workbook. It is possible that the encoding of the document did not match the encoding of the reader.",
                                                   e );

        } catch ( IOException e ) {
            throw new DecisionTableParseException( "Failed to open Excel stream, " + "please check that the content is xls97 format.",
                                                   e );
        }

    }
View Full Code Here

            case Cell.CELL_TYPE_ERROR:
                cachedValue = String.valueOf( cell.getErrorCellValue() );
                break;

            default:
                throw new DecisionTableParseException( format( "Can't read cached value for cell[row=%d, col=%d, value=%s]!",
                                                               cell.getRowIndex(), cell.getColumnIndex(), cell ) );
        }
        return cachedValue;
    }
View Full Code Here

                              String value ) {
        this.hasValues = true;
        Integer key = new Integer( column );
        String content = (String) this.constraints.get( key );
        if ( content == null ) {
            throw new DecisionTableParseException( "No code snippet for CONDITION in cell " +
                                                           RuleSheetParserUtil.rc2name( this.headerRow + 2, this.headerCol ) );
        }
        SnippetBuilder snip = new SnippetBuilder( content );
        String result = snip.build( fixValue( value ) );
        this.values.add( result );
View Full Code Here

    /* (non-Javadoc)
     * @see org.drools.decisiontable.parser.RuleSheetListener#getRuleSet()
     */
    public Package getRuleSet() {
        if ( this._ruleList.isEmpty() ) {
            throw new DecisionTableParseException( "No RuleTable cells in spreadsheet." );
        }
        final Package ruleset = buildRuleSet();
        return ruleset;
    }
View Full Code Here

        for( Code code: ActionType.ATTRIBUTE_CODE_SET ){
            List<String> values = getProperties().getProperty( code.getColHeader() );
            if( values != null ){
                if( values.size() > 1 ){
                    List<String> cells = getProperties().getPropertyCells( code.getColHeader() );
                    throw new DecisionTableParseException( "Multiple values for " + code.getColHeader() +
                            " in cells " + cells.toString() );
                }
                String value = values.get( 0 );
                switch( code ){
                case SALIENCE:
                    try {
                        ruleset.setSalience( new Integer( value ) );
                    } catch( NumberFormatException nfe ){
                        throw new DecisionTableParseException( "Priority is not an integer literal, in cell " +
                                getProperties().getSinglePropertyCell( code.getColHeader() ) );
                    }
                    break;
                case DURATION:
                    try {
                        ruleset.setDuration( new Long( value ) );
                    } catch( NumberFormatException nfe ){
                        throw new DecisionTableParseException( "Duration is not an integer literal, in cell " +
                                getProperties().getSinglePropertyCell( code.getColHeader() )  );
                    }
                    break;
                case TIMER:
                    ruleset.setTimer( value );
View Full Code Here

    private void objectTypeRow(final int row,
            final int column,
            final String value,
            final int mergedColStart) {
        if ( value.indexOf( "$param" ) > -1 || value.indexOf( "$1" ) > -1 ) {
            throw new DecisionTableParseException( "It looks like you have snippets in the row that is " +
                    "meant for object declarations." + " Please insert an additional row before the snippets, " +
                    "at cell " + RuleSheetParserUtil.rc2name( row, column ) );
        }
        ActionType action = getActionForColumn( row, column );
        if ( mergedColStart == RuleSheetListener.NON_MERGED ) {
View Full Code Here

        if ( value.trim().equals( "" ) &&
            (actionType.getCode() == Code.ACTION ||
             actionType.getCode() == Code.CONDITION ||
             actionType.getCode() == Code.METADATA) ) {
            throw new DecisionTableParseException( "Code description in cell " +
                    RuleSheetParserUtil.rc2name( row, column ) +
            " does not contain any code specification. It should!" );
        }

        actionType.addTemplate( row, column, value );
View Full Code Here

    private ActionType getActionForColumn(final int row,
            final int column) {
        final ActionType actionType = this._actions.get( new Integer( column ) );

        if ( actionType == null ) {
            throw new DecisionTableParseException( "Code description in cell " +
                    RuleSheetParserUtil.rc2name( row, column ) +
            " does not have an 'ACTION' or 'CONDITION' column header." );
        }

        return actionType;
View Full Code Here

        switch( actionType.getCode() ){
        case CONDITION:
        case ACTION:
        case METADATA:
            if (actionType.getSourceBuilder() == null) {
                throw new DecisionTableParseException( "Data cell " +
                        RuleSheetParserUtil.rc2name( row, column ) +
                        " has an empty column header." );
            }
            actionType.addCellValue( row, column, value, _currentEscapeQuotesFlag );
            break;
        case SALIENCE:
            // Only if rule set is not sequential!
            if( ! this._currentSequentialFlag ){
                if( value.startsWith( "(" ) && value.endsWith( ")" ) ){
                    this._currentRule.setSalience( value );
                } else {
                    try {
                        this._currentRule.setSalience( new Integer( value ) );
                    } catch( NumberFormatException nfe ){
                        throw new DecisionTableParseException( "Priority is not an integer literal, in cell " +
                                RuleSheetParserUtil.rc2name( row, column ) );
                    }
                }
            }
            break;
        case NAME:
            this._currentRule.setName( value );
            break;
        case DESCRIPTION:
            this._currentRule.setDescription( value );
            break;
        case ACTIVATIONGROUP:
            this._currentRule.setActivationGroup( value );
            break;
        case AGENDAGROUP:
            this._currentRule.setAgendaGroup( value );
            break;
        case RULEFLOWGROUP:
            this._currentRule.setRuleFlowGroup( value );
            break;
        case NOLOOP:
            this._currentRule.setNoLoop( RuleSheetParserUtil.isStringMeaningTrue( value ) );
            break;
        case LOCKONACTIVE:
            this._currentRule.setLockOnActive( RuleSheetParserUtil.isStringMeaningTrue( value ) );
            break;
        case AUTOFOCUS:
            this._currentRule.setAutoFocus( RuleSheetParserUtil.isStringMeaningTrue( value ) );
            break;
        case DURATION:
            try {
                this._currentRule.setDuration( new Long( value ) );
            } catch( NumberFormatException nfe ){
                throw new DecisionTableParseException( "Duration is not an integer literal, in cell " +
                        RuleSheetParserUtil.rc2name( row, column ) );
            }
            break;
        case TIMER:
            this._currentRule.setTimer( value );
View Full Code Here

TOP

Related Classes of org.drools.template.parser.DecisionTableParseException

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.