Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2011 JBoss Inc
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *      http://www.apache.org/licenses/LICENSE-2.0
   *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 
 package org.drools.workbench.screens.guided.dtable.client.widget.analysis;
 
 
 import java.util.List;
 
 public class DecisionTableAnalyzer {
 
     private final PackageDataModelOracle oracle;
 
     public DecisionTableAnalyzerfinal PackageDataModelOracle oracle ) {
         this. = oracle;
     }
 
     @SuppressWarnings("rawtypes")
     public List<Analysisanalyzefinal GuidedDecisionTable52 model ) {
         final GuidedDecisionTableUtils utils = new GuidedDecisionTableUtils,
                                                                              model );
         final List<List<DTCellValue52>> data = model.getData();
         final List<AnalysisanalysisData = new ArrayList<Analysis>( data.size() );
         final List<RowDetectorrowDetectorList = new ArrayList<RowDetector>( data.size() );
 
         for ( List<DTCellValue52row : data ) {
             final Integer rowNumber = ( (Integerrow.get( 0 ).getNumericValue() ) - 1;
             RowDetector rowDetector = new RowDetectorrowNumber );
             for ( Pattern52 pattern : model.getPatterns() ) {
                 for ( ConditionCol52 conditionCol : pattern.getChildColumns() ) {
                     int columnIndex = model.getExpandedColumns().indexOfconditionCol );
                     DTCellValue52 visibleCellValue = row.getcolumnIndex );
                     DTCellValue52 realCellValue;
                     boolean cellIsNotBlank;
                     if ( conditionCol instanceof LimitedEntryCol ) {
                         realCellValue = ( (LimitedEntryColconditionCol ).getValue();
                         cellIsNotBlank = visibleCellValue.getBooleanValue();
                     } else {
                         realCellValue = visibleCellValue;
                         cellIsNotBlank = visibleCellValue.hasValue();
                     }
                     // Blank cells are ignored
                     if ( cellIsNotBlank ) {
                         ConditionDetector conditionDetector = buildConditionDetectorutils,
                                                                                       pattern,
                                                                                       conditionCol,
                                                                                       realCellValue );
                         rowDetector.putOrMergeConditionDetectorconditionDetector );
                     }
                 }
            }
            for ( ActionCol52 actionCol : model.getActionCols() ) {
                //BRLActionColumns cannot be analysed
                if ( actionCol instanceof BRLActionColumn ) {
                    continue;
                }
                int columnIndex = model.getExpandedColumns().indexOfactionCol );
                DTCellValue52 visibleCellValue = row.getcolumnIndex );
                DTCellValue52 realCellValue;
                boolean cellIsNotBlank;
                if ( actionCol instanceof LimitedEntryCol ) {
                    realCellValue = ( (LimitedEntryColactionCol ).getValue();
                    cellIsNotBlank = visibleCellValue.getBooleanValue();
                } else {
                    realCellValue = visibleCellValue;
                    cellIsNotBlank = visibleCellValue.hasValue();
                }
                // Blank cells are ignored
                if ( cellIsNotBlank ) {
                    ActionDetector actionDetector = buildActionDetectormodel,
                                                                         actionCol,
                                                                         realCellValue );
                    rowDetector.putOrMergeActionDetectoractionDetector );
                }
            }
            rowDetectorList.addrowDetector );
        }
        for ( RowDetector rowDetector : rowDetectorList ) {
            analysisData.addrowDetector.buildAnalysisrowDetectorList ) );
        }
        return analysisData;
    }
    @SuppressWarnings("rawtypes")
                                                      Pattern52 pattern,
                                                      ConditionCol52 conditionCol,
                                                      DTCellValue52 realCellValue ) {
        String factField = conditionCol.getFactField();
        String operator = conditionCol.getOperator();
        String type = utils.getTypeconditionCol );
        // Retrieve "Guvnor" enums
        String[] allValueList = utils.getValueListconditionCol );
        ConditionDetector newDetector;
        if ( allValueList.length != 0 ) {
            // Guvnor enum
            newDetector = new EnumConditionDetectorpattern,
                                                     factField,
                                                     Arrays.asListallValueList ),
                                                     realCellValue.getStringValue(),
                                                     operator );
        } else if ( type == null ) {
            // type null means the field is free-format
            newDetector = new UnrecognizedConditionDetectorpattern,
                                                             factField,
                                                             operator );
        } else if ( type.equals. ) ) {
            newDetector = new StringConditionDetectorpattern,
                                                       factField,
                                                       realCellValue.getStringValue(),
                                                       operator );
        } else if ( type.equals. ) ) {
            newDetector = new NumericConditionDetectorpattern,
                                                        factField,
                                                        (BigDecimalrealCellValue.getNumericValue(),
                                                        operator );
        } else if ( type.equals. ) ) {
            newDetector = new NumericBigDecimalConditionDetectorpattern,
                                                                  factField,
                                                                  (BigDecimalrealCellValue.getNumericValue(),
                                                                  operator );
        } else if ( type.equals. ) ) {
            newDetector = new NumericBigIntegerConditionDetectorpattern,
                                                                  factField,
                                                                  (BigIntegerrealCellValue.getNumericValue(),
                                                                  operator );
        } else if ( type.equals. ) ) {
            newDetector = new NumericByteConditionDetectorpattern,
                                                            factField,
                                                            (ByterealCellValue.getNumericValue(),
                                                            operator );
        } else if ( type.equals. ) ) {
            newDetector = new NumericDoubleConditionDetectorpattern,
                                                              factField,
                                                              (DoublerealCellValue.getNumericValue(),
                                                              operator );
        } else if ( type.equals. ) ) {
            newDetector = new NumericFloatConditionDetectorpattern,
                                                             factField,
                                                             (FloatrealCellValue.getNumericValue(),
                                                             operator );
        } else if ( type.equals. ) ) {
            newDetector = new NumericIntegerConditionDetectorpattern,
                                                               factField,
                                                               (IntegerrealCellValue.getNumericValue(),
                                                               operator );
        } else if ( type.equals. ) ) {
            newDetector = new NumericLongConditionDetectorpattern,
                                                            factField,
                                                            (LongrealCellValue.getNumericValue(),
                                                            operator );
        } else if ( type.equals. ) ) {
            newDetector = new NumericShortConditionDetectorpattern,
                                                             factField,
                                                             (ShortrealCellValue.getNumericValue(),
                                                             operator );
        } else if ( type.equals. ) ) {
            newDetector = new BooleanConditionDetectorpattern,
                                                        factField,
                                                        realCellValue.getBooleanValue(),
                                                        operator );
        } else if ( type.equals. ) ) {
            newDetector = new DateConditionDetectorpattern,
                                                     factField,
                                                     realCellValue.getDateValue(),
                                                     operator );
        } else {
            newDetector = new UnrecognizedConditionDetectorpattern,
                                                             factField,
                                                             operator );
        }
        return newDetector;
    }
                                                ActionCol52 actionCol,
                                                DTCellValue52 realCellValue ) {
        ActionDetectorKey key;
        if ( actionCol instanceof ActionSetFieldCol52 ) {
            key = new SetFieldColActionDetectorKey( (ActionSetFieldCol52actionCol );
        } else if ( actionCol instanceof ActionInsertFactCol52 ) {
            key = new InsertFactActionDetectorKey( (ActionInsertFactCol52actionCol );
        } else {
            key = new UnrecognizedActionDetectorKeyactionCol );
        }
        return new ActionDetectorkey,
                                   realCellValue );
    }
New to GrepCode? Check out our FAQ X