/** * 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; }
public RowLevelSecurity getRowLevelSecurity() { return (RowLevelSecurity) getProperty( ROW_LEVEL_SECURITY ); }
LogicalModel olapModel = new LogicalModel(); duplicateProperties( combinedModel, olapModel ); olapModel.setName( appendOlap( combinedModel.getName() ) ); olapModel.setDescription( appendOlap( combinedModel.getName() ) ); olapModel.setId( combinedModel.getId() + BaseModelerWorkspaceHelper.OLAP_SUFFIX ); olapModel.setPhysicalModel( combinedModel.getPhysicalModel() ); olapModel.setDomain( combinedModel.getDomain() ); if ( combinedModel.getRowLevelSecurity() != null ) { olapModel.setRowLevelSecurity( combinedModel.getRowLevelSecurity() ); olapModel.setProperty( "AGILE_BI_GENERATED_SCHEMA", "TRUE" ); olapModel.setProperty( "MODELING_SCHEMA", "OLAP" ); olapModel.setProperty( "DUAL_MODELING_SCHEMA", "true" ); olapModel.setProperty( "visible", "false" ); for ( LogicalTable table : combinedModel.getLogicalTables() ) { if ( table.getId().endsWith( BaseModelerWorkspaceHelper.OLAP_SUFFIX ) ) { table.setLogicalModel( olapModel ); combinedModel.getLogicalTables().clear(); combinedModel.getLogicalTables().addAll( relationalTables ); olapModel.getLogicalTables().addAll( olapTables ); if ( combinedModel.getLogicalRelationships().size() > 0 ) { splitOlapRelationships( combinedModel, olapModel );
private String getSchemaName() { String name = businessModel.getName( locale ); if ( businessModel.getProperty( "AGILE_BI_GENERATED_SCHEMA" ) != null ) { // clean up the _OLAP suffix on the name name = name.replace( "_OLAP", "" ); } return name; }
public static void duplicateRelationshipsForOlap( LogicalModel relationalModel, LogicalModel olapModel ) { if ( olapModel.getLogicalRelationships() != null ) { olapModel.getLogicalRelationships().clear(); } if ( relationalModel.getLogicalRelationships() != null ) { for ( LogicalRelationship rel : relationalModel.getLogicalRelationships() ) { olapModel.addLogicalRelationship( duplicateRelationshipForOlap( rel, olapModel ) ); } } }
private void setSchemaName( String catalogName ) { String newName = catalogName; if ( businessModel.getProperty( "AGILE_BI_GENERATED_SCHEMA" ) != null ) { newName = catalogName.concat( "_OLAP" ); } if ( businessModel.getName() == null ) { businessModel.setId( newName ); } else { businessModel.getName().setString( locale, newName ); } }
model.getPhysicalTables().add( table ); LogicalModel logicalModel = new LogicalModel(); logicalModel.setPhysicalModel( model ); logicalModel.setId( "MODEL_1" ); //$NON-NLS-1$ logicalModel.setName( new LocalizedString( locale.getCode(), modelName ) ); logicalModel.getLogicalTables().add( logicalTable ); logicalModel.getCategories().add( mainCategory ); security.putOwnerRights( owner, defaultAcls ); logicalModel.setProperty( Concept.SECURITY_PROPERTY, security );
LogicalModel logicalModel = new LogicalModel(); convertConceptFromLegacy( model, logicalModel ); LogicalTable logicalTable = new LogicalTable(); IPhysicalTable physicalTable = domain.findPhysicalTable( businessTable.getPhysicalTable().getId() ); if ( physicalTable != null && logicalModel.getPhysicalModel() == null ) { logicalModel.setPhysicalModel( physicalTable.getPhysicalModel() ); logicalModel.getLogicalTables().add( logicalTable ); toTable = logicalModel.findLogicalTable( rel.getTableTo().getId() ); fromTable = logicalModel.findLogicalTable( rel.getTableFrom().getId() ); toColumn = logicalModel.findLogicalColumn( rel.getFieldTo().getId() ); fromColumn = logicalModel.findLogicalColumn( rel.getFieldFrom().getId() ); logicalModel.getLogicalRelationships().add( logical ); category.getLogicalColumns().add( logicalModel.findLogicalColumn( businessColumn.getId() ) ); logicalModel.getCategories().add( category );
LogicalModel logicalModel = new LogicalModel(); logicalModel.setId( schema.getAttribute( "name" ) ); //$NON-NLS-1$ xmiConceptMap.put( schema.getAttribute( "xmi.id" ), logicalModel ); //$NON-NLS-1$ if ( physTable != null && logicalModel.getPhysicalModel() == null ) { logicalModel.setPhysicalModel( physTable.getPhysicalModel() ); logicalModel.addLogicalTable( table ); String biztbl = nvp.get( "BUSINESS_COLUMN_BUSINESS_TABLE" ); //$NON-NLS-1$ String pcol = nvp.get( "BUSINESS_COLUMN_PHYSICAL_COLUMN_NAME" ); //$NON-NLS-1$ LogicalTable parent = logicalModel.findLogicalTable( biztbl ); if ( parent != null ) { col.setLogicalTable( parent ); Element column = (Element) columns.item( j ); String name = column.getAttribute( "name" ); //$NON-NLS-1$ LogicalColumn col = logicalModel.findLogicalColumn( name ); if ( col == null ) { logger.warn( Messages.getString( logicalModel.addCategory( cat ); relation.setFromTable( logicalModel.findLogicalTable( tableparent ) ); if ( fieldparent != null ) { relation.setFromColumn( logicalModel.findLogicalColumn( fieldparent ) ); relation.setToTable( logicalModel.findLogicalTable( tablechild ) );
mdbSchema.setAttribute( "name", model.getId() ); //$NON-NLS-1$ String idstr = idGen.getNextId(); mdbSchema.setAttribute( "xmi.id", idstr ); //$NON-NLS-1$ List<OlapCube> cubes = (List<OlapCube>) model.getProperty( "olap_cubes" ); if ( cubes != null ) { StringBuffer buffer = new StringBuffer(); for ( Category category : model.getCategories() ) { Element extent = doc.createElement( "CWM:Extent" ); //$NON-NLS-1$ extent.setAttribute( "name", category.getId() ); //$NON-NLS-1$ for ( LogicalRelationship rel : model.getLogicalRelationships() ) { Element keyRel = doc.createElement( "CWM:KeyRelationship" ); //$NON-NLS-1$ keyRel.setAttribute( "xmi.id", idGen.getNextId() ); //$NON-NLS-1$ mdbSchema.appendChild( sdo ); mdbSchema.appendChild( sd ); for ( LogicalTable table : model.getLogicalTables() ) { Element dim = doc.createElement( "CWMMDB:Dimension" ); //$NON-NLS-1$ sd.appendChild( dim ); if ( model.getParentConcept() != null ) { Element modelElement = doc.createElement( "CWM:ModelElement.taggedValue" ); //$NON-NLS-1$ modelElement.appendChild( createTaggedValue( doc, "CONCEPT_PARENT_NAME", model.getParentConcept().getId(), idGen.getNextId() ) ); //$NON-NLS-1$ mdbSchema.appendChild( modelElement );
String vis = (String) model.getProperty( "visible" ); if ( vis != null ) { String[] visibleContexts = vis.split( "," ); .add( new LogicalModelSummary( domainId, model.getId(), model.getName().getString( locale ) ) );
for ( LogicalTable logicalTable : logicalModel.getLogicalTables() ) { logicalTable.setName( new LocalizedString( locale, datasourceName ) ); businessModel.setProperty( "AGILE_BI_GENERATED_SCHEMA", "TRUE" ); businessModel.setProperty( "DUAL_MODELING_SCHEMA", "" + dualModelingMode ); businessModel.setName( new LocalizedString( locale, tableName ) ); businessModel.setDescription( new LocalizedString( locale, "This is the data model for " + datasourceName ) ); LogicalTable businessTable = businessModel.getLogicalTables().get( 0 ); businessTable.setName( new LocalizedString( locale, businessTable.getPhysicalTable().getName( locale ) ) );
String vis = (String) model.getProperty( "visible" ); if ( vis != null ) { String[] visibleContexts = vis.split( "," ); if ( model.getId() != null ) { modelNode.addElement( "model_id" ).setText( model.getId() ); //$NON-NLS-1$ String modelName = model.getName( locale ); if ( modelName != null ) { modelNode.addElement( "model_name" ).setText( modelName ); //$NON-NLS-1$ if ( model.getDescription() != null ) { String modelDescription = model.getDescription( locale ); if ( modelDescription != null ) { modelNode.addElement( "model_description" ).setText( modelDescription ); //$NON-NLS-1$
logicalModel.setId( "MODEL_1" ); logicalModel.setName( new LocalizedString( locale, model.getModelName() ) ); logicalModel.setProperty( "AGILE_BI_VERSION", AGILE_BI_VERSION ); logicalModel.setId( "MODEL_1" + BaseModelerWorkspaceHelper.OLAP_SUFFIX ); logicalModel .setName( new LocalizedString( locale, model.getModelName() + BaseModelerWorkspaceHelper.OLAP_SUFFIX ) ); logicalModel.setProperty( "AGILE_BI_VERSION", AGILE_BI_VERSION ); if ( logicalModel.getLogicalTables().size() == 1 ) { factTable = logicalModel.getLogicalTables().get( 0 ); } else { // otherwise we're in a multi-table situation, find the table flagged as the fact table Object prop; for ( LogicalTable lTable : logicalModel.getLogicalTables() ) { prop = lTable.getPhysicalTable().getProperty( "FACT_TABLE" ); if ( prop == null ) { if ( logicalModel.getLogicalTables().size() > 1 ) { // only do this for multi-table situations hierarchy.setPrimaryKey( findPrimaryKeyFor( logicalModel, factTable, olapCloneLTable ) ); List<OlapCube> existingCubes = (List<OlapCube>) logicalModel.getProperty( "olap_cubes" ); OlapCube cube = existingCubes == null || existingCubes.isEmpty() ? new OlapCube() : existingCubes.get( 0 ); cube.setLogicalTable( factTable ); logicalModel.setProperty( "olap_dimensions", olapDimensions ); //$NON-NLS-1$ logicalModel.setProperty( "olap_cubes", cubes ); //$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 ); }
@Override public Object clone() { LogicalModel clone = new LogicalModel(); // configure concept properties clone( clone ); // shallow references clone.logicalRelationships = logicalRelationships; clone.setParent( getParent() ); clone.setPhysicalConcept( getPhysicalConcept() ); // actual clones clone.logicalTables = new ArrayList<LogicalTable>(); for ( LogicalTable table : logicalTables ) { clone.addLogicalTable( (LogicalTable) table.clone() ); } clone.categories = new ArrayList<Category>(); for ( Category category : categories ) { clone.addCategory( (Category) category.clone() ); } return clone; }
public void removeDSW( String dswId ) throws PentahoAccessControlException { try { ensureDataAccessPermissionCheck(); } catch ( ConnectionServiceException e ) { throw new PentahoAccessControlException(); } Domain domain = metadataDomainRepository.getDomain( dswId ); ModelerWorkspace model = createModelerWorkspace(); model.setDomain( domain ); LogicalModel logicalModel = model.getLogicalModel( ModelerPerspective.ANALYSIS ); if ( logicalModel == null ) { logicalModel = model.getLogicalModel( ModelerPerspective.REPORTING ); } if ( logicalModel.getProperty( MONDRIAN_CATALOG_REF ) != null ) { String catalogRef = (String) logicalModel.getProperty( MONDRIAN_CATALOG_REF ); try { mondrianCatalogService.removeCatalog( catalogRef, getSession() ); } catch ( MondrianCatalogServiceException e ) { logger.warn( "Failed to remove mondrian catalog", e ); } } try { dswService.deleteLogicalModel( domain.getId(), logicalModel.getId() ); } catch ( DatasourceServiceException ex ) { logger.warn( "Failed to remove logical model", ex ); } metadataDomainRepository.removeDomain( dswId ); }
/** * finds a logical table within the model. * * @param tableId the table to find * @return a logical table object. */ public LogicalTable findLogicalTable( String tableId ) { for ( LogicalTable table : getLogicalTables() ) { if ( tableId.equals( table.getId() ) ) { return table; } } return null; }
setModelName( lModel.getName( workspaceHelper.getLocale() ) ); setRelationalModelName( lModel.getName( workspaceHelper.getLocale() ) ); List<OlapDimension> theDimensions = null; if ( lModel != null ) { theDimensions = (List) lModel.getProperty( LogicalModel.PROPERTY_OLAP_DIMS ); //$NON-NLS-1$ theCubes = (List) lModel.getProperty( LogicalModel.PROPERTY_OLAP_CUBES ); //$NON-NLS-1$ for ( Category cat : lModel.getCategories() ) { String catName = BaseModelerWorkspaceHelper.getCleanCategoryName( cat.getName( workspaceHelper.getLocale() ), this, i++ );
/** * Returns a list of ModelInfo objects for the specified domain. These objects are small and this list is intended to * allow a client to provide a list of models to a user so the user can pick which one they want to work with. * * @param domain * @param models */ private void getModelInfos( final String domain, List<ModelInfo> models ) { IMetadataDomainRepository repo = getMetadataRepository(); Domain domainObject = repo.getDomain( domain ); // find the best locale String locale = LocaleHelper.getClosestLocale( LocaleHelper.getLocale().toString(), domainObject.getLocaleCodes() ); // iterate over all of the models in this domain for ( LogicalModel model : domainObject.getLogicalModels() ) { // create a new ModelInfo object and give it the envelope information about the model ModelInfo modelInfo = new ModelInfo(); modelInfo.setDomainId( domain ); modelInfo.setModelId( model.getId() ); modelInfo.setModelName( model.getName( locale ) ); if ( model.getDescription() != null ) { String modelDescription = model.getDescription( locale ); modelInfo.setModelDescription( modelDescription ); } models.add( modelInfo ); } return; }