View Javadoc

1   /* (c) Copyright 2003 Caleigo AB, All rights reserved. 
2    * 
3    * This library is free software; you can redistribute it and/or
4    * modify it under the terms of the GNU Lesser General Public
5    * License as published by the Free Software Foundation; either
6    * version 2.1 of the License, or (at your option) any later version.
7    * 
8    * This library is distributed in the hope that it will be useful,
9    * but WITHOUT ANY WARRANTY; without even the implied warranty of
10   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11   * Lesser General Public License for more details.
12   * 
13   * You should have received a copy of the GNU Lesser General Public
14   * License along with this library; if not, write to the Free Software
15   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16   *  
17   */
18  
19  package org.caleigo.core;
20  
21  /*** Basic implementation of IDataSource that wraps a IDataService.
22   *
23   * @author  Dennis Zikovic
24   * @version 1.00
25   *
26   *//* 
27   *
28   * WHEN        WHO               WHY & WHAT
29   * -----------------------------------------------------------------------------
30   * 2001-10-31  Dennis Zikovic    Creation
31   */
32  public class SingleServiceDataSource implements IDataSource 
33  {
34      // Data members ------------------------------------------------------------
35      private IDataService mDataService;
36      private IDataSourceDescriptor mDataSourceDescriptor;
37      
38      // Constructors ------------------------------------------------------------
39      
40      /*** Creates new AbstractDataSource
41       */
42      public SingleServiceDataSource(IDataService dataService) 
43      {
44          mDataService = dataService;
45          mDataSourceDescriptor = mDataService.getDataSourceDescriptor();
46      }
47      
48      // IDataSource implementation ----------------------------------------------
49      
50      /*** Returns the IDataSourceDescriptor for this data source.
51       */
52      public IDataSourceDescriptor getDataSourceDescriptor()
53      {
54          return mDataSourceDescriptor;
55      }
56      
57      /*** Returns the IDataService for this data source.
58       */
59      public IDataService getDataService()
60      {
61          return mDataService;
62      }
63      
64      /*** Creates a new entity and lets the data source be the manafer of that
65       * entity. This method can be used to create an entity with a data source
66       * that is not the default data source for the entitys realated
67       * IDataSourceDescriptor.
68       */
69      public IEntity createEntity(IEntityDescriptor entityDescriptor)
70      {
71          return entityDescriptor.createEntity();
72      }
73      
74      /*** The load method returnes a single entity object intentified by the 
75       * provided indentity qualifier that must be able to uniquely identify
76       * a single entity instance.
77       */
78      public IEntity loadEntity(IEntityDescriptor entityDescriptor, Qualifier identityQualifier)
79      {
80          return mDataService.load(entityDescriptor, identityQualifier);
81      }
82      
83      /*** Loads a selection of entities identyfied by the provided qualifier.
84       */
85      public ISelection loadSelection(IEntityDescriptor entityDescriptor, Qualifier qualifier)
86      {
87          return mDataService.loadSelection(entityDescriptor, qualifier);
88      }
89  
90      /*** Creates a new entity and lets the data source be the manafer of that
91       * entity. This method can be used to create an entity with a data source
92       * that is not the default data source for the entitys realated
93       * IDataSourceDescriptor. The entity is loaded  with data from the provided 
94       * property source.
95       */
96      public IEntity createEntity(IEntityDescriptor entityDescriptor, IDataProvider propertySource)
97      {
98          return entityDescriptor.createEntity(propertySource);
99      }
100     
101     /*** Instucts the data source object to take over the control of an entity.
102      * The entity will henceforth belong to this data source and will have its
103      * PERSISTENT flag reset. This method is optional and may throw an
104      * UnsupportedOperationException.
105      */
106     public IEntity manageEntity(IEntity entity)
107     {
108         throw new UnsupportedOperationException();
109     }
110     
111     // Action methods ----------------------------------------------------------
112     
113     // Access methods ----------------------------------------------------------
114     
115     // Help methods ------------------------------------------------------------
116     
117     // Nested classes ----------------------------------------------------------
118 }