001/*
002// This software is subject to the terms of the Eclipse Public License v1.0
003// Agreement, available at the following URL:
004// http://www.eclipse.org/legal/epl-v10.html.
005// You must accept the terms of that agreement to use this software.
006//
007// Copyright (C) 2005-2009 Pentaho
008// All Rights Reserved.
009*/
010package mondrian.spi.impl;
011
012import mondrian.olap.MondrianDef;
013import mondrian.rolap.RolapHierarchy;
014import mondrian.rolap.agg.AggregationKey;
015import mondrian.spi.DataSourceChangeListener;
016
017
018/**
019 * Default implementation of a data source change listener
020 * that always returns that the datasource is changed.
021 *
022 * A change listener can be specified in the connection string.  It is used
023 * to ask what is changed in the datasource (e.g. database).
024 *
025 * Everytime mondrian has to decide whether it will use data from cache, it
026 * will call the change listener.  When the change listener tells mondrian
027 * the datasource has changed for a dimension, cube, ... then mondrian will
028 * flush the cache and read from database again.
029 *
030 * It is specified in the connection string, like this:
031 *
032 * <blockquote><code>
033 * Jdbc=jdbc:odbc:MondrianFoodMart; JdbcUser=ziggy; JdbcPassword=stardust;
034 * DataSourceChangeListener=com.acme.MyChangeListener;
035 * </code></blockquote>
036 *
037 * This class should be called in mondrian before any data is read, so
038 * even before cache is build.  This way, the plugin is able to register
039 * the first timestamp mondrian tries to read the datasource.
040 *
041 * @author Bart Pappyn
042 * @since Dec 12, 2006
043 */
044
045public class DataSourceChangeListenerImpl3 implements DataSourceChangeListener {
046
047    /** Creates a new instance of DataSourceChangeListenerImpl2 */
048    public DataSourceChangeListenerImpl3() {
049    }
050
051
052    public synchronized boolean isHierarchyChanged(RolapHierarchy hierarchy) {
053        return true;
054    }
055
056    public synchronized boolean isAggregationChanged(
057        AggregationKey aggregation)
058    {
059        return true;
060    }
061
062    public String getTableName(RolapHierarchy hierarchy) {
063        MondrianDef.RelationOrJoin relation = hierarchy.getRelation();
064        if (relation instanceof MondrianDef.Table) {
065            MondrianDef.Table tableRelation = (MondrianDef.Table)relation;
066            return tableRelation.name;
067        } else {
068            return null;
069        }
070    }
071}
072
073// End DataSourceChangeListenerImpl3.java