View Javadoc
1   /*
2    * Copyright (c) 2002-2020, City of 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.blog.business;
35  
36  import java.util.List;
37  
38  import fr.paris.lutece.portal.service.plugin.Plugin;
39  import fr.paris.lutece.portal.service.plugin.PluginService;
40  import fr.paris.lutece.portal.service.spring.SpringContextService;
41  
42  /**
43   * This class provides instances management methods (create, find, ...) for Blog objects
44   */
45  public final class DocContentHome
46  {
47      // Static variable pointed at the DAO instance
48      private static DocContentDAO _dao = SpringContextService.getBean( "blog.docContentDAO" );
49      private static Plugin _plugin = PluginService.getPlugin( "blog" );
50  
51      /**
52       * Private constructor - this class need not be instantiated
53       */
54      private DocContentHome( )
55      {
56      }
57  
58      /**
59       * Create an instance of the DocContent class
60       * 
61       * @param docContent
62       *            The Document Content
63       *
64       */
65      public static void create( DocContent docContent )
66      {
67          _dao.insertDocContent( docContent, _plugin );
68      }
69  
70      /**
71       * @param nIdBlog
72       *            the blog id
73       * @param nIdDocument
74       *            the document id
75       * @param nPriority
76       *            the priority
77       * 
78       */
79      public static void insertInBlog( int nIdBlog, int nIdDocument, int nPriority )
80      {
81          _dao.insertDocContentInBlog( nIdBlog, nIdDocument, nPriority, _plugin );
82      }
83  
84      /**
85       * Update of the DocContent which is specified in parameter
86       * 
87       * @param docContent
88       *            the Document Content
89       * @return the instance of DocContent updated
90       */
91      public static DocContent/../../../../../fr/paris/lutece/plugins/blog/business/DocContent.html#DocContent">DocContent update( DocContent docContent )
92      {
93          _dao.store( docContent, _plugin );
94  
95          return docContent;
96      }
97  
98      /**
99       * Remove the DocContent whose identifier Blog is specified in parameter
100      * 
101      * @param nBlogId
102      *            the Id DocContent
103      */
104     public static void remove( int nBlogId )
105     {
106         _dao.delete( nBlogId, _plugin );
107     }
108 
109     /**
110      * Remove the correspondance beetween the document and the blog
111      * 
112      * @param nDocumentId
113      *            the document id
114      */
115     public static void removeInBlogById( int nDocumentId )
116     {
117         _dao.deleteInBlogById( nDocumentId, _plugin );
118 
119     }
120 
121     /**
122      * Remove the DocContent whose identifier is specified in parameter
123      * 
124      * @param nKey
125      *            the Id DocContent
126      */
127     public static void removeById( int nKey )
128     {
129         _dao.deleteById( nKey, _plugin );
130     }
131 
132     /**
133      * Returns an instance of a DocContent whose identifier is specified in parameter
134      * 
135      * @param nIdDocument
136      * @return an instance of DocContent
137      */
138     public static DocContent getDocsContent( int nIdDocument )
139     {
140         return _dao.loadDocContent( nIdDocument, _plugin );
141     }
142 
143     /**
144      * Returns an list of a DocContent whose htmldoc identifier is specified in parameter
145      * 
146      * @param nIdHtmlDoc
147      * @return an instance of DocContent
148      */
149     public static List<DocContent> getDocsContentByHtmlDoc( int nIdHtmlDoc )
150     {
151         return _dao.loadDocContentByIdHtemldoc( nIdHtmlDoc, _plugin );
152     }
153 
154     /**
155      * Returns a list of a ContentType
156      * 
157      * @return a list of a ContentType
158      */
159     public static List<ContentType> getListContentType( )
160     {
161         return _dao.loadListContentType( _plugin );
162     }
163 }