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.library.business;
35  
36  import fr.paris.lutece.plugins.document.business.Document;
37  
38  import java.util.Map;
39  
40  
41  public class SelectedMedia implements Comparable<SelectedMedia>
42  {
43      private int _nMediaTypeId;
44      private int _nDocumentId;
45      private int _nMappingId;
46      private int _nOrder;
47      private Document _document;
48      private Map<String, String> _attributesFromMapping;
49  
50      /**
51       * Default constructor
52       */
53      public SelectedMedia(  )
54      {
55          // Default constructor
56      }
57  
58      /**
59       * Constructor with every parameters initialized
60       * @param nMediaTypeId The id of the media type
61       * @param nDocumentId The document id
62       * @param nMappingId The mapping id
63       */
64      public SelectedMedia( int nMediaTypeId, int nDocumentId, int nMappingId )
65      {
66          this._nMediaTypeId = nMediaTypeId;
67          this._nDocumentId = nDocumentId;
68          this._nMappingId = nMappingId;
69      }
70  
71      /**
72       * Get the id of the media type
73       * @return The id of the media type
74       */
75      public int getMediaTypeId(  )
76      {
77          return _nMediaTypeId;
78      }
79  
80      /**
81       * Set the id of the media type
82       * @param nMediaTypeId The id of the media type
83       */
84      public void setMediaTypeId( int nMediaTypeId )
85      {
86          this._nMediaTypeId = nMediaTypeId;
87      }
88  
89      /**
90       * Get the document id
91       * @return The document id
92       */
93      public int getDocumentId(  )
94      {
95          return _nDocumentId;
96      }
97  
98      /**
99       * Set the document id
100      * @param nDocumentId The document id
101      */
102     public void setDocumentId( int nDocumentId )
103     {
104         this._nDocumentId = nDocumentId;
105     }
106 
107     /**
108      * Get the mapping id
109      * @return The mapping id
110      */
111     public int getMappingId(  )
112     {
113         return _nMappingId;
114     }
115 
116     /**
117      * Set the mapping id
118      * @param nMappingId The mapping id
119      */
120     public void setMappingId( int nMappingId )
121     {
122         this._nMappingId = nMappingId;
123     }
124 
125     /**
126      * Get the order of the item
127      * @return The order of the item
128      */
129     public int getOrder(  )
130     {
131         return _nOrder;
132     }
133 
134     /**
135      * Set the order of the item
136      * @param nOrder The order of the item
137      */
138     public void setOrder( int nOrder )
139     {
140         this._nOrder = nOrder;
141     }
142 
143     /**
144      * Get the document associated with this media
145      * @return The document
146      */
147     public Document getDocument(  )
148     {
149         return _document;
150     }
151 
152     /**
153      * Set the document
154      * @param document The document
155      */
156     public void setDocument( Document document )
157     {
158         this._document = document;
159     }
160 
161     public Map<String, String> getAttributesFromMapping(  )
162     {
163         return _attributesFromMapping;
164     }
165 
166     public void setAttributesFromMapping( Map<String, String> attributesFromMapping )
167     {
168         this._attributesFromMapping = attributesFromMapping;
169     }
170 
171     /**
172      * {@inheritDoc}
173      */
174     @Override
175     public int compareTo( SelectedMedia o )
176     {
177         if ( o == null )
178         {
179             return -1;
180         }
181 
182         return getOrder(  ) - o.getOrder(  );
183     }
184 }