/** * 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 ); } }
olapCol.setAggregationList( col.getPhysicalColumn().getAggregationList() );
lCol.setDataType( field.getPhysicalColumn().getDataType() ); if ( field.getPhysicalColumn().getAggregationList() != null ) { lCol.setAggregationList( field.getPhysicalColumn().getAggregationList() );