Java Code Examples for org.pentaho.metadata.model.LogicalColumn#getProperty()

The following examples show how to use org.pentaho.metadata.model.LogicalColumn#getProperty() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StarModelDialog.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
private void addLogicalColumnToFactAttributesList(LogicalColumn column) {
  TableItem item = new TableItem(wFactAttributes.table, SWT.NONE);

  //  name, description, physical column name, data type, length, precision, source db, source table, source column, conversion remarks
  //
  int col=1;
  item.setText(col++, Const.NVL(ConceptUtil.getName(column,locale), ""));
  item.setText(col++, Const.NVL(ConceptUtil.getDescription(column, locale), ""));
  item.setText(col++, ConceptUtil.getAttributeType(column).name());
  item.setText(col++, Const.NVL((String)column.getProperty(DefaultIDs.LOGICAL_COLUMN_PHYSICAL_COLUMN_NAME), ""));
  DataType dataType = (DataType) column.getProperty(DefaultPropertyID.DATA_TYPE.getId());
  item.setText(col++, dataType==null ? "" : dataType.name() );
  item.setText(col++, Const.NVL(ConceptUtil.getString(column, DefaultIDs.LOGICAL_COLUMN_DIMENSION_NAME), ""));
  item.setText(col++, Const.NVL(ConceptUtil.getString(column, DefaultIDs.LOGICAL_COLUMN_LENGTH), ""));
  item.setText(col++, Const.NVL(ConceptUtil.getString(column, DefaultIDs.LOGICAL_COLUMN_PRECISION), ""));
  item.setText(col++, Const.NVL(ConceptUtil.getString(column, DefaultIDs.LOGICAL_COLUMN_SOURCE_DB), ""));
  item.setText(col++, Const.NVL(ConceptUtil.getString(column, DefaultIDs.LOGICAL_COLUMN_SOURCE_TABLE), ""));
  item.setText(col++, Const.NVL(ConceptUtil.getString(column, DefaultIDs.LOGICAL_COLUMN_SOURCE_COLUMN), ""));
  item.setText(col++, Const.NVL(ConceptUtil.getString(column, DefaultIDs.LOGICAL_COLUMN_CONVERSION_REMARKS), ""));
}
 
Example 2
Source File: DimensionTableDialog.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
private void addLogicalColumnToAttributesList(LogicalColumn column) {
  TableItem item = new TableItem(wAttributes.table, SWT.NONE);

  //  name, description, physical column name, data type, length, precision, source db, source table, source column, conversion remarks
  //
  int col=1;
  item.setText(col++, Const.NVL(ConceptUtil.getName(column,locale), ""));
  item.setText(col++, Const.NVL(ConceptUtil.getDescription(column, locale), ""));
  item.setText(col++, ConceptUtil.getAttributeType(column).name());
  item.setText(col++, Const.NVL((String)column.getProperty(DefaultIDs.LOGICAL_COLUMN_PHYSICAL_COLUMN_NAME), ""));
  DataType dataType = (DataType) column.getProperty(DefaultPropertyID.DATA_TYPE.getId());
  item.setText(col++, dataType==null ? "" : dataType.name() );
  item.setText(col++, Const.NVL(ConceptUtil.getString(column, DefaultIDs.LOGICAL_COLUMN_LENGTH), ""));
  item.setText(col++, Const.NVL(ConceptUtil.getString(column, DefaultIDs.LOGICAL_COLUMN_PRECISION), ""));
  item.setText(col++, Const.NVL(ConceptUtil.getString(column, DefaultIDs.LOGICAL_COLUMN_SOURCE_DB), ""));
  item.setText(col++, Const.NVL(ConceptUtil.getString(column, DefaultIDs.LOGICAL_COLUMN_SOURCE_TABLE), ""));
  item.setText(col++, Const.NVL(ConceptUtil.getString(column, DefaultIDs.LOGICAL_COLUMN_SOURCE_COLUMN), ""));
  item.setText(col++, Const.NVL(ConceptUtil.getString(column, DefaultIDs.LOGICAL_COLUMN_CONVERSION_REMARKS), ""));
}
 
Example 3
Source File: QueryModelMetaData.java    From pentaho-metadata with GNU Lesser General Public License v2.1 5 votes vote down vote up
public Object getAttribute( int rowNo, int columnNo, String attributeName ) {
  // TODO support OLAP
  if ( rowNo == 0 && columnNo < columns.size() ) {
    LogicalColumn column = columns.get( columnNo ).getLogicalColumn();
    return column.getProperty( attributeName );
  }
  return null;
}
 
Example 4
Source File: InlineEtlQueryExecutor.java    From pentaho-metadata with GNU Lesser General Public License v2.1 5 votes vote down vote up
protected void doInputWiring( Query query, TransMeta transMeta ) {
  //
  // CSV FILE LOCATION AND FIELDS
  //

  InlineEtlPhysicalModel physicalModel = (InlineEtlPhysicalModel) query.getLogicalModel().getPhysicalModel();

  CsvInputMeta csvinput = (CsvInputMeta) getStepMeta( transMeta, "CSV file input" ).getStepMetaInterface(); //$NON-NLS-1$

  // the file name might need to be translated to the correct location here
  if ( csvFileLoc != null ) {
    csvinput.setFilename( csvFileLoc + physicalModel.getFileLocation() );
  } else {
    csvinput.setFilename( physicalModel.getFileLocation() );
  }

  csvinput.setDelimiter( physicalModel.getDelimiter() );
  csvinput.setEnclosure( physicalModel.getEnclosure() );
  csvinput.setHeaderPresent( physicalModel.getHeaderPresent() );

  // update fields

  LogicalTable table = query.getLogicalModel().getLogicalTables().get( 0 );

  csvinput.allocate( table.getLogicalColumns().size() );

  for ( int i = 0; i < csvinput.getInputFields().length; i++ ) {
    // Update csv input

    LogicalColumn col = table.getLogicalColumns().get( i );
    csvinput.getInputFields()[i] = new TextFileInputField();
    String fieldName = (String) col.getProperty( InlineEtlPhysicalColumn.FIELD_NAME );
    if ( logger.isDebugEnabled() ) {
      logger.debug( "FROM CSV: " + fieldName ); //$NON-NLS-1$
    }
    csvinput.getInputFields()[i].setName( fieldName );
    csvinput.getInputFields()[i].setType( convertType( col.getDataType() ) );
  }

}
 
Example 5
Source File: MQLEditorServiceDelegate.java    From mql-editor with GNU Lesser General Public License v2.1 5 votes vote down vote up
private Category createCategory( LogicalModel m, org.pentaho.metadata.model.Category c ) {
  Category cat = new Category();
  cat.setName( c.getName( getLocale() ) );
  cat.setId( c.getId() );
  for ( LogicalColumn col : c.getLogicalColumns() ) {
    boolean isHidden = ( col.getProperty( "hidden" ) != null ) ? (Boolean) col.getProperty( "hidden" ) : false;
    if ( !isHidden ) {
      cat.getBusinessColumns().add( createColumn( m, col ) );
    }
  }
  return cat;
}
 
Example 6
Source File: InlineEtlQueryExecutor.java    From pentaho-metadata with GNU Lesser General Public License v2.1 4 votes vote down vote up
public List<QueryConstraint> parseConstraints( Query query, Map<String, Object> parameters ) {
  List<QueryConstraint> constraints = new ArrayList<QueryConstraint>();
  for ( Constraint constraint : query.getConstraints() ) {
    QueryConstraint qc = new QueryConstraint();
    qc.orig = constraint;

    // parse out all the [] fields
    Pattern p = Pattern.compile( "\\[([^\\]]*)\\]" ); //$NON-NLS-1$
    Matcher m = p.matcher( constraint.getFormula() );
    StringBuffer sb = new StringBuffer();
    while ( m.find() ) {
      String match = m.group( 1 );
      if ( match.startsWith( "param:" ) ) { //$NON-NLS-1$
        String paramName = match.substring( 6 );
        Object paramValue = parameters.get( paramName );
        String openFormulaValue = ""; //$NON-NLS-1$
        if ( paramValue instanceof Boolean ) {
          // need to get and then render either true or false function.
          if ( ( (Boolean) paramValue ).booleanValue() ) {
            openFormulaValue = "TRUE()"; //$NON-NLS-1$
          } else {
            openFormulaValue = "FALSE()"; //$NON-NLS-1$
          }
        } else if ( paramValue instanceof Double ) {
          openFormulaValue = paramValue.toString();
        } else {
          // assume a string, string literal quote
          openFormulaValue = "\"" + paramValue + "\""; //$NON-NLS-1$ //$NON-NLS-2$
        }
        m.appendReplacement( sb, openFormulaValue );
      } else {
        String[] seg = match.split( "\\." ); //$NON-NLS-1$
        if ( seg != null && seg.length > 1 ) {
          Category cat = query.getLogicalModel().findCategory( seg[0] );
          LogicalColumn col = cat.findLogicalColumn( seg[1] );
          if ( col == null ) {
            logger.error( Messages.getErrorString(
                "InlineEtlQueryExecutor.ERROR_0001_FAILED_TO_LOCATE_COLUMN", seg[0], seg[1] ) ); //$NON-NLS-1$
          }
          String fieldName = (String) col.getProperty( InlineEtlPhysicalColumn.FIELD_NAME );
          AggregationType agg = null;
          if ( seg.length > 2 ) {
            agg = AggregationType.valueOf( seg[2].toUpperCase() );
          }
          Selection sel = new Selection( cat, col, agg );
          if ( !qc.selections.contains( sel ) ) {
            qc.selections.add( sel );
            if ( sel.getActiveAggregationType() != null && sel.getActiveAggregationType() != AggregationType.NONE ) {
              qc.groupby = true;
            }
          }
          // this may be different in the group by context.

          m.appendReplacement( sb, "[" + fieldName + "]" ); //$NON-NLS-1$ //$NON-NLS-2$
        } else {
          logger
              .error( Messages.getErrorString( "InlineEtlQueryExecutor.ERROR_0002_FAILED_TO_PARSE_FORMULA", match ) ); //$NON-NLS-1$
        }
      }
    }
    m.appendTail( sb );
    qc.formula = sb.toString();
    if ( logger.isDebugEnabled() ) {
      logger.debug( "PARSED FORMULA: " + qc.formula ); //$NON-NLS-1$
    }
    constraints.add( qc );
  }
  return constraints;
}