public Category findCategory( String categoryId ) { for ( Category category : getCategories() ) { if ( categoryId.equals( category.getId() ) ) { return category; } } return null; }
/** * Returns the full category object for a given column within the logical model * * @param columnId * @param logicalModel * @return */ protected org.pentaho.metadata.model.Category getCategory( String columnId, LogicalModel logicalModel ) { for ( org.pentaho.metadata.model.Category category : logicalModel.getCategories() ) { if ( category.findLogicalColumn( columnId ) != null ) { return category; } } return null; }
/** * finds a logical column within the model. * * @param columnId the column to find * @return a logical column object. */ public LogicalColumn findLogicalColumnInCategories( String columnId ) { for ( Category cat : getCategories() ) { for ( LogicalColumn column : cat.getLogicalColumns() ) { if ( columnId.equals( column.getId() ) ) { return column; } } } return null; }
Iterator<Category> catiter = model.getCategories().iterator(); while ( catiter.hasNext() ) { Category category = catiter.next();
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 ); }
/** * Creates a lightweight, serializable model object from a logical model * * @param m * @param domainId * @return */ public Model createThinModel( LogicalModel m, String domainId ) { // create the model object Model model = new Model(); model.setName( m.getName( getLocale() ) ); model.setId( m.getId() ); model.setDomainId( domainId ); model.setDescription( m.getDescription( getLocale() ) ); // add the categories to the model List<Category> categories = new ArrayList<Category>(); for ( org.pentaho.metadata.model.Category cat : m.getCategories() ) { categories.add( createCategory( m, cat ) ); } model.setCategories( categories.toArray( new Category[ categories.size() ] ) ); return model; }
/** * This is a utility method that looks into an old domain for the same column ids, and then copies over the old * metadata into the new. * * @param oldDomain * @param newDomain */ public void copyOverMetadata( Domain oldDomain, Domain newDomain ) { Category category = newDomain.getLogicalModels().get( 0 ).getCategories().get( 0 ); LogicalModel oldModel = oldDomain.getLogicalModels().get( 0 ); for ( LogicalColumn column : category.getLogicalColumns() ) { LogicalColumn oldColumn = oldModel.findLogicalColumn( column.getId() ); if ( oldColumn != null ) { column.setDataType( oldColumn.getDataType() ); column.setName( oldColumn.getName() ); column.setAggregationList( oldColumn.getAggregationList() ); column.setAggregationType( oldColumn.getAggregationType() ); } } }
protected void populateCategories( ModelerWorkspace workspace ) { RelationalModelNode model = workspace.getRelationalModel(); LogicalModel logicalModel = workspace.getDomain().getLogicalModels().get( 0 ); logicalModel.getCategories().clear(); for ( CategoryMetaData catMeta : model.getCategories() ) { Category cat = new Category(); cat.setName( new LocalizedString( this.getLocale(), catMeta.getName() ) ); cat.setId( catMeta.getName() ); for ( FieldMetaData fieldMeta : catMeta ) { LogicalColumn lCol = fieldMeta.getLogicalColumn(); LogicalTable lTable = lCol.getLogicalTable(); if ( !lTable.getLogicalColumns().contains( lCol ) ) { lTable.addLogicalColumn( lCol ); } lCol.setName( new LocalizedString( locale, fieldMeta.getName() ) ); AggregationType type = fieldMeta.getDefaultAggregation(); lCol.setAggregationType( type ); setLogicalColumnFormat( fieldMeta.getFormat(), lCol ); Set<AggregationType> possibleAggs = new HashSet<AggregationType>(); possibleAggs.add( fieldMeta.getDefaultAggregation() ); possibleAggs.addAll( fieldMeta.getSelectedAggregations() ); lCol.setAggregationList( Arrays.<AggregationType>asList( possibleAggs .toArray( new AggregationType[possibleAggs.size()] ) ) ); cat.addLogicalColumn( lCol ); } logicalModel.addCategory( cat ); } }
for ( Category category : model.getCategories() ) { Element extent = doc.createElement( "CWM:Extent" ); //$NON-NLS-1$ extent.setAttribute( "name", category.getId() ); //$NON-NLS-1$
for ( Category cat : model.getCategories() ) { if ( cat.findLogicalColumn( column.getId() ) != null ) { category = cat;
logicalModel.getCategories().add( mainCategory );
for ( Category cat : lModel.getCategories() ) { String catName = BaseModelerWorkspaceHelper.getCleanCategoryName( cat.getName( workspaceHelper.getLocale() ), this, i++ );
for ( Category category : model.getCategories() ) { for ( LogicalColumn col : category.getLogicalColumns() ) { if ( col.getId().equals( column.getId() ) ) {
logicalModel.getCategories().add( mainCategory );
logicalModel.getCategories().add( category );
model.setRootCategory( root ); for ( Category category : logicalModel.getCategories() ) { BusinessCategory cat = new BusinessCategory(); convertConceptToLegacy( category, cat );
for ( Category category : model.getCategories() ) { tableNode = modelNode.addElement( "view" ); //$NON-NLS-1$ if ( category.getId() != null ) {