View Javadoc

1   package org.weda.model.impl;
2   
3   import java.util.HashMap;
4   import java.util.List;
5   import java.util.Map;
6   import org.apache.commons.logging.Log;
7   import org.apache.tapestry.services.ExpressionCache;
8   import org.apache.tapestry.services.ExpressionEvaluator;
9   import org.weda.property.ObjectDescriptorRegistry;
10  import org.weda.model.TableModelFactory;
11  import org.weda.model.TableModelRegistry;
12  import org.weda.model.TableModel;
13  import org.weda.model.impl.TableModelDataId;
14  import org.weda.model.impl.TableModelDataProvider;
15  import org.weda.data.DataProvider;
16  import org.weda.data.DataProviderFactory;
17  import org.weda.data.DataProviderServiceException;
18  import org.weda.store.ObjectSource;
19  import org.weda.store.ObjectSourceRegistry;
20  
21  public class TableModelRegistryImpl implements TableModelRegistry
22  {
23      private Log log;
24      
25      private HashMap<String, TableModel> tableModels =
26              new HashMap<String, TableModel>();
27      
28      public void setTableModelFactories(List<TableModelFactory> factories)
29          throws Exception
30      {        
31          log.debug("factories size: "+factories.size());
32          for (TableModelFactory fab: factories)
33              if (fab.getTableModels()!=null)
34                  for (TableModel model: fab.getTableModels()){
35                      log.debug("Adding model ("+model.getName()+") to registry");
36                      tableModels.put(model.getName(), model);
37                  }
38          /*
39          this.tableModels.putAll(tableModels);
40          for (TableModel model: tableModels.values()){
41              model.set
42              model.init();
43          }
44           */
45      }
46  
47      public TableModel getTableModel(String name) {
48          return tableModels.get(name);
49      }
50  
51      public void setLog(Log log) {
52          this.log = log;
53      }
54  
55      public DataProvider getDataProvider(Object dataIdentificator) 
56          throws DataProviderServiceException 
57      {
58          TableModelDataId id = (TableModelDataId)dataIdentificator;
59          TableModel model = getTableModel(id.getModelName());
60          return new TableModelDataProvider(model, id);
61      }
62  
63      public Class getDataIdentificatorClass() {
64          return TableModelDataId.class;
65      }
66  
67  }