public Category findCategory( String categoryId ) { for ( Category category : getCategories() ) { if ( categoryId.equals( category.getId() ) ) { return category; } } return null; }
@Override public List<String> getUniqueId() { List<String> uid = new ArrayList<String>( getParent().getUniqueId() ); uid.add( CLASS_ID.concat( UID_TYPE_SEPARATOR ) + getId() ); return uid; }
@Override protected void addSelectionToDocument( Document doc, Selection selection, Element selectionElement ) { AliasedSelection aliasedSelection = (AliasedSelection) selection; Category view = selection.getCategory(); LogicalColumn column = selection.getLogicalColumn(); Element element = null; if ( view != null && column != null ) { element = doc.createElement( "view" ); //$NON-NLS-1$ element.appendChild( doc.createTextNode( view.getId() ) ); selectionElement.appendChild( element ); element = doc.createElement( "column" ); //$NON-NLS-1$ element.appendChild( doc.createTextNode( column.getId() ) ); selectionElement.appendChild( element ); if ( aliasedSelection.getAlias() != null ) { element = doc.createElement( "alias" ); //$NON-NLS-1$ element.appendChild( doc.createTextNode( aliasedSelection.getAlias() ) ); selectionElement.appendChild( element ); } } else if ( aliasedSelection.getFormula() != null ) { element = doc.createElement( "formula" ); //$NON-NLS-1$ element.appendChild( doc.createTextNode( aliasedSelection.getFormula() ) ); selectionElement.appendChild( element ); } }
if ( !selection.hasFormula() ) { element = doc.createElement( "view" ); //$NON-NLS-1$ element.appendChild( doc.createTextNode( selection.getCategory().getId() ) );
/** * Creates a lightweight, serializable category objects from a logical model category * * @param m * @param c * @return */ private Category createCategory( LogicalModel m, org.pentaho.metadata.model.Category c ) { // create a thin category object Category cat = new Category(); cat.setName( c.getName( getLocale() ) ); cat.setId( c.getId() ); List<Column> columns = new ArrayList<Column>(); for ( LogicalColumn col : c.getLogicalColumns() ) { columns.add( createColumn( m, col, c ) ); } cat.setColumns( columns.toArray( new Column[ columns.size() ] ) ); return cat; }
if ( businessColumn == null ) { throw new PentahoMetadataException( Messages.getErrorString( "QueryXmlHelper.ERROR_0013_BUSINESS_COL_NOT_FOUND", category.getId(), column ) ); //$NON-NLS-1$
public static WAQRTransport createFromMetadata( Domain domain ) { // this assumes a single logical model with a single logical category LogicalModel model = domain.getLogicalModels().get( 0 ); Iterator<String> iter = model.getName().getLocales().iterator(); String locale = iter.next(); Category category = model.getCategories().get( 0 ); String domainId = domain.getId(); String modelId = model.getId(); String modelName = model.getName() != null ? model.getName().getString( locale ) : null; String categoryId = category.getId(); String categoryName = category.getName() != null ? category.getName().getString( locale ) : null; String schemaName = model.getName( locale ); return createDomain( domainId, modelId, modelName, categoryId, categoryName, schemaName ); }
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 ) ); }
if ( col == null ) { logger.warn( Messages.getString( "XmiParser.ERROR_0010_UNABLE_TO_FIND_COL_FOR_CATEGORY", name, cat.getId() ) ); //$NON-NLS-1$ } else { cat.addLogicalColumn( col );
protected void addSelectionToDocument( Document doc, Selection selection, Element selectionElement ) { addTextElement( doc, selectionElement, "view", selection.getCategory().getId() ); //$NON-NLS-1$ addTextElement( doc, selectionElement, "column", selection.getLogicalColumn().getId() ); //$NON-NLS-1$ if ( selection.getAggregationType() != null ) { addTextElement( doc, selectionElement, "aggregation", selection.getAggregationType().toString() ); //$NON-NLS-1$ } }
for ( Category category : model.getCategories() ) { Element extent = doc.createElement( "CWM:Extent" ); //$NON-NLS-1$ extent.setAttribute( "name", category.getId() ); //$NON-NLS-1$ idstr = idGen.getNextId(); extent.setAttribute( "xmi.id", idstr ); //$NON-NLS-1$
protected void addOrderByToDocument( Document doc, Order order, Element orderElement ) { // test that this is lower case addTextElement( doc, orderElement, "direction", order.getType().toString() ); //$NON-NLS-1$ addTextElement( doc, orderElement, "view_id", order.getSelection().getCategory().getId() ); //$NON-NLS-1$ addTextElement( doc, orderElement, "column_id", order.getSelection().getLogicalColumn().getId() ); //$NON-NLS-1$ if ( order.getSelection().getAggregationType() != null ) { addTextElement( doc, orderElement, "aggregation", order.getSelection().getAggregationType().toString() ); //$NON-NLS-1$ } }
"<mql><domain_type>relational</domain_type><domain_id>" + domainName + "</domain_id><model_id>" + modelId + "</model_id>"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ if ( column.getProperty( "lookup" ) == null ) { //$NON-NLS-1$ mql += "<selection><view>" + view.getId() + "</view><column>" + column.getId() + "</column></selection>"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ mql += "<orders><order><direction>asc</direction><view_id>" + view.getId() + "</view_id><column_id>" + column.getId() + "</column_id></order></orders>"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
col.setCategory( category.getId() );
aggStr = aggregation.getCode(); impl.addOrderBy( order.getSelection().getCategory().getId(), order.getSelection().getLogicalColumn().getId(), aggStr, order.getType() == Order.Type.ASC );