View Javadoc
1   package fr.paris.lutece.plugins.grustoragedb.business;
2   
3   import fr.paris.lutece.plugins.grubusiness.business.demand.Demand;
4   import fr.paris.lutece.plugins.grubusiness.business.demand.IDemandDAO;
5   import fr.paris.lutece.plugins.grubusiness.business.notification.NotificationFilter;
6   import fr.paris.lutece.portal.service.plugin.Plugin;
7   import fr.paris.lutece.portal.service.plugin.PluginService;
8   import fr.paris.lutece.portal.service.spring.SpringContextService;
9   
10  import java.util.Collection;
11  import java.util.List;
12  
13  /**
14   * This class provides instances management methods (create, find, ...) for Project objects
15   */
16  public final class DemandHome
17  {
18      // Static variable pointed at the DAO instance
19      private static IDemandDAO _dao = SpringContextService.getBean( "grustoragedb.DemandDAO" );
20      private static Plugin _plugin = PluginService.getPlugin( "grustoragedb" );
21  
22      /**
23       * Private constructor - this class need not be instantiated
24       */
25      private DemandHome(  )
26      {
27      }
28      
29      /**
30       * Finds all the demands 
31       * @return all the demands. An empty collection is returned if no demands has been found.
32       */
33      public static List<Demand> getByIds( List<Integer> listIds)
34      {
35          return _dao.loadByIds( listIds);
36      }
37   
38      /**
39       * search demands by filter
40       * 
41       * @param strKey
42       * @return 
43       */
44      public static List<Integer> searchIdsByFilter( NotificationFilter filter )
45      {
46          return _dao.loadIdsByFilter( filter );
47      }
48   
49      /**
50       * search demands by filter
51       * 
52       * @param strKey
53       * @return 
54       */
55      public static Collection<Demand> searchByFilter( NotificationFilter filter )
56      {
57          return _dao.loadByFilter( filter );
58      }
59   
60  
61      /**
62       * Finds a demand with the specified id and type id
63       * @param nKey The project primary key
64       * @return an instance of Project
65       */
66      public static Demand findByPrimaryKey( String strKey, String strDemandTypeId )
67      {
68          return _dao.load(strKey, strDemandTypeId);
69      }
70      
71      /**
72       * Finds the demands associated to the specified customer id
73       * @return the list which contains the id of all the project objects
74       */
75      public static Collection<Demand> getDemandIdCustomer(String strCustomerId )
76      {
77          return _dao.loadByCustomerId(strCustomerId);
78      }
79      
80      /**
81       * Load demand ids ordered by date notification
82       * @param strCustomerId
83       * @param strNotificationType
84       * @param strIdDemandType (Optional can be null)
85       * @return The list of demand ids
86       */
87      public static List<Integer> getIdsByCustomerIdAndDemandTypeId( String strCustomerId,  String strNotificationType, String strIdDemandType  )
88      {
89          return _dao.loadIdsByCustomerIdAndIdDemandType( strCustomerId, strNotificationType, strIdDemandType );
90      }
91      
92      /**
93       * Load demand ids by status
94       * @param strCustomerId
95       * @param listStatus
96       * @param strNotificationType
97       * @param strIdDemandType
98       * @return The list of demand ids
99       */
100     public static List<Integer> getIdsByStatus( String strCustomerId, List<String> listStatus, String strNotificationType, String strIdDemandType )
101     {
102         return _dao.loadIdsByStatus( strCustomerId, listStatus, strNotificationType, strIdDemandType );
103     }
104     
105     /**
106      * Updates a demand
107      * 
108      * @param demand
109      *            the demand to update
110      * @return the updated demand
111      */
112     public static Demand update( Demand demand )
113     {
114         return _dao.store( demand );
115     }
116 }