View Javadoc
1   /*
2    * Copyright (c) 2002-2014, Mairie de Paris
3    * All rights reserved.
4    *
5    * Redistribution and use in source and binary forms, with or without
6    * modification, are permitted provided that the following conditions
7    * are met:
8    *
9    *  1. Redistributions of source code must retain the above copyright notice
10   *     and the following disclaimer.
11   *
12   *  2. Redistributions in binary form must reproduce the above copyright notice
13   *     and the following disclaimer in the documentation and/or other materials
14   *     provided with the distribution.
15   *
16   *  3. Neither the name of 'Mairie de Paris' nor 'Lutece' nor the names of its
17   *     contributors may be used to endorse or promote products derived from
18   *     this software without specific prior written permission.
19   *
20   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23   * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
24   * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25   * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26   * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27   * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28   * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30   * POSSIBILITY OF SUCH DAMAGE.
31   *
32   * License 1.0
33   */
34  package fr.paris.lutece.plugins.directory.modules.pdfproducerarchive.business.zipbasket;
35  
36  import fr.paris.lutece.plugins.directory.modules.pdfproducerarchive.service.DirectoryPDFProducerArchivePlugin;
37  import fr.paris.lutece.portal.service.plugin.Plugin;
38  import fr.paris.lutece.portal.service.spring.SpringContextService;
39  
40  import java.util.Date;
41  import java.util.List;
42  
43  
44  /**
45   *        ZipBasketHome
46   */
47  public final class ZipBasketHome
48  {
49      private static IZipBasketDAO _dao = (IZipBasketDAO) SpringContextService.getPluginBean( DirectoryPDFProducerArchivePlugin.PLUGIN_NAME,
50              "directoryZipBasketDAO" );
51  
52      /**
53       * Constructor
54       */
55      private ZipBasketHome(  )
56      {
57      }
58  
59      /**
60       * This method add a new zip in the basket
61       * @param strName the name of the futur zip
62       * @param nIdAdminUser id of admin user
63       * @param plugin plugin
64       * @param nIdDirectory id of directory
65       * @param nIdRecord id of record
66       * @param nArchiveItemKey id of the archive item
67       */
68      public static void addZipBasket( String strName, int nIdAdminUser, Plugin plugin, int nIdDirectory, int nIdRecord,
69          int nArchiveItemKey )
70      {
71          _dao.addZipBasket( strName, nIdAdminUser, plugin, nIdDirectory, nIdRecord, nArchiveItemKey );
72      }
73  
74      /**
75       * This SQL method check if the zip is already exists
76       * @param nIdAdminUser id of admin user
77       * @param plugin plugin
78       * @param nIdDirectory id directory
79       * @param nIdRecord id ercord
80       * @return true if the zip already exists
81       */
82      public static boolean existsZipBasket( int nIdAdminUser, Plugin plugin, int nIdDirectory, int nIdRecord )
83      {
84          return _dao.existsZipBasket( nIdAdminUser, plugin, nIdDirectory, nIdRecord );
85      }
86  
87      /**
88       * This method load all zipbasket
89       * @param plugin plugin
90       * @return list of ZipBasket
91       */
92      public static List<ZipBasket> loadAllZipBasket( Plugin plugin )
93      {
94          return _dao.loadAllZipBasket( plugin );
95      }
96  
97      /**
98       * This method load all element in basket by id admin user for a specific directory
99       * @param plugin plugin
100      * @param nIdAdminUser id of admin user
101      * @param nIdDirectory id of directory
102      * @return list of ZipBasket
103      */
104     public static List<ZipBasket> loadAllZipBasketByAdminUser( Plugin plugin, int nIdAdminUser, int nIdDirectory )
105     {
106         return _dao.loadAllZipBasketByAdminUser( plugin, nIdAdminUser, nIdDirectory );
107     }
108 
109     /**
110      * This method delete a ZipBasket
111      * @param plugin plugin
112      * @param nIdZipBasket id of the zipbasket
113      */
114     public static void deleteZipBasket( Plugin plugin, int nIdZipBasket )
115     {
116         _dao.deleteZipBasket( plugin, nIdZipBasket );
117     }
118 
119     /**
120      * This method delete multi ZipBasket
121      * @param plugin plugin
122      * @param listIdZipBasket list of id zipbasket
123      */
124     public static void deleteMultiZipBasket( Plugin plugin, List<Integer> listIdZipBasket )
125     {
126         _dao.deleteMultiZipBasket( plugin, listIdZipBasket );
127     }
128 
129     /**
130      * this method change de zip file status and modify the date
131      * @param plugin plugin
132      * @param nIdZipBasket id of the zipbasket
133      * @param strStatus the new status
134      */
135     public static void changeZipBasketStatus( Plugin plugin, int nIdZipBasket, String strStatus )
136     {
137         _dao.changeZipBasketStatus( plugin, nIdZipBasket, strStatus );
138     }
139 
140     /**
141      * this method change de zip file url and modify the date
142      * @param plugin plugin
143      * @param nIdZipBasket id of the zipbasket
144      * @param strUrl the new url
145      */
146     public static void changeZipBasketUrl( Plugin plugin, int nIdZipBasket, String strUrl )
147     {
148         _dao.changeZipBasketUrl( plugin, nIdZipBasket, strUrl );
149     }
150 
151     /**
152      * this method return a specific zipbasket by id
153      * @param plugin plugin
154      * @param nIdZipBasket id of the zipbasket
155      * @return the zipbasket by the id
156      */
157     public static ZipBasket loadZipBasket( Plugin plugin, int nIdZipBasket )
158     {
159         return _dao.loadZipBasket( plugin, nIdZipBasket );
160     }
161 
162     /**
163      * Find all zip baskets by date
164      * @param plugin the plugin
165      * @param dateExpiry the date expiry
166      * @return a list of {@link ZipBasket}
167      */
168     public static List<ZipBasket> loadZipBasketByDate( Plugin plugin, Date dateExpiry )
169     {
170         return _dao.loadZipBasketByDate( plugin, dateExpiry );
171     }
172 
173     /**
174      * This method load all element in basket by id admin user for a specific
175      * directory by order
176      * @param plugin plugin
177      * @param nIdAdminUser id of admin user
178      * @param nIdDirectory id of directory
179      * @return list of ZipBasket
180      */
181     public static List<ZipBasket> loadAllZipBasketByAdminUserOrder( Plugin plugin, int nIdAdminUser, int nIdDirectory )
182     {
183         return _dao.loadAllZipBasketByAdminUserOrder( plugin, nIdAdminUser, nIdDirectory );
184     }
185 }