本文整理汇总了Java中org.pentaho.metadata.model.concept.types.AggregationType.valueOf方法的典型用法代码示例。如果您正苦于以下问题:Java AggregationType.valueOf方法的具体用法?Java AggregationType.valueOf怎么用?Java AggregationType.valueOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.pentaho.metadata.model.concept.types.AggregationType
的用法示例。
在下文中一共展示了AggregationType.valueOf方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addOrderBy
import org.pentaho.metadata.model.concept.types.AggregationType; //导入方法依赖的package包/类
protected void addOrderBy( Query query, Category category, String columnId, String aggregation, Order.Type orderType )
throws PentahoMetadataException {
if ( category == null ) {
throw new PentahoMetadataException( Messages.getErrorString( "QueryXmlHelper.ERROR_0016_BUSINESS_CATEGORY_NULL" ) ); //$NON-NLS-1$
}
LogicalColumn column = category.findLogicalColumn( columnId );
if ( column == null ) {
throw new PentahoMetadataException( Messages.getErrorString(
"QueryXmlHelper.ERROR_0013_BUSINESS_COL_NOT_FOUND", category.getId(), columnId ) ); //$NON-NLS-1$
}
// this code verifies the aggregation setting provided is a
// valid option
AggregationType aggsetting = null;
if ( aggregation != null ) {
AggregationType setting = AggregationType.valueOf( aggregation.toUpperCase() );
if ( ( column.getAggregationType() == setting ) || column.getAggregationList() != null
&& column.getAggregationList().contains( setting ) ) {
aggsetting = setting;
}
}
query.getOrders().add( new Order( new Selection( category, column, aggsetting ), orderType ) );
}
示例2: addSelectionFromXmlNode
import org.pentaho.metadata.model.concept.types.AggregationType; //导入方法依赖的package包/类
protected void addSelectionFromXmlNode( Query query, Element selectionElement ) {
NodeList viewnodes = selectionElement.getElementsByTagName( "view" ); //$NON-NLS-1$
NodeList nodes = selectionElement.getElementsByTagName( "column" ); //$NON-NLS-1$
if ( nodes.getLength() == 0 ) {
// should throw exception here
return;
}
String columnId = XMLHandler.getNodeValue( nodes.item( 0 ) );
String viewId = null;
Category category = null;
if ( viewnodes.getLength() != 0 ) {
// this is due to legacy reasons, the query doesn't really need the category.
viewId = XMLHandler.getNodeValue( viewnodes.item( 0 ) );
category = query.getLogicalModel().findCategory( viewId );
}
LogicalColumn column = null;
if ( category != null ) {
column = category.findLogicalColumn( columnId );
} else {
column = query.getLogicalModel().findLogicalColumnInCategories( columnId );
}
if ( column != null ) {
AggregationType aggsetting = null;
NodeList aggnodes = selectionElement.getElementsByTagName( "aggregation" ); //$NON-NLS-1$
if ( aggnodes.getLength() > 0 ) {
String aggvalue = XMLHandler.getNodeValue( aggnodes.item( 0 ) );
AggregationType setting = AggregationType.valueOf( aggvalue.toUpperCase() );
if ( setting == null ) {
Messages.getErrorString( "QueryXmlHelper.ERROR_0011_AGG_NOT_RECOGNIZED", columnId, aggvalue ); //$NON-NLS-1$
} else {
// verify that the setting is one of the options for this business column
if ( ( column.getAggregationType() == setting ) || column.getAggregationList() != null
&& column.getAggregationList().contains( setting ) ) {
aggsetting = setting;
} else {
Messages.getErrorString( "QueryXmlHelper.ERROR_0012_INVALID_AGG_FOR_BUSINESS_COL", columnId, aggvalue ); //$NON-NLS-1$
}
}
}
query.getSelections().add( new Selection( category, column, aggsetting ) );
} else {
// print a warning message
Messages.getErrorString( "QueryXmlHelper.ERROR_0013_BUSINESS_COL_NOT_FOUND", viewId, columnId ); //$NON-NLS-1$
}
}
示例3: parseConstraints
import org.pentaho.metadata.model.concept.types.AggregationType; //导入方法依赖的package包/类
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;
}