View Javadoc
1   /*
2    * Copyright (c) 2002-2022, 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.pluginwizard.business.model;
35  
36  import org.hibernate.validator.constraints.URL;
37  
38  import java.util.ArrayList;
39  import java.util.List;
40  import java.util.Locale;
41  
42  import javax.validation.constraints.NotEmpty;
43  import javax.validation.constraints.Pattern;
44  import javax.validation.constraints.Size;
45  
46  import com.fasterxml.jackson.annotation.JsonIgnore;
47  
48  /**
49   * This is the business class for the object PluginModel
50   */
51  public class PluginModel
52  {
53      // Variables declarations
54      private int _nIdPlugin;
55      private String _strPluginName;
56      private String _strPluginClass;
57      @NotEmpty( message = "pluginwizard.error.plugin.description.notEmpty" )
58      @Size( min = 5, max = 255, message = "pluginwizard.error.plugin.description.size" )
59      private String _strPluginDescription;
60      private String _strPluginDocumentation;
61      private String _strType;
62      private String _strPluginInstallation;
63      private String _strPluginChanges;
64      private String _strPluginUserGuide;
65      @NotEmpty( message = "pluginwizard.error.plugin.version.notEmpty" )
66      @Pattern( regexp = "[0-9].[0-9].[0-9]", message = "pluginwizard.error.plugin.version.pattern" )
67      private String _strPluginVersion;
68      @NotEmpty( message = "pluginwizard.error.plugin.copyright.notEmpty" )
69      private String _strPluginCopyright;
70      private String _strPluginIconUrl;
71      @NotEmpty( message = "pluginwizard.error.plugin.provider.notEmpty" )
72      @Size( min = 5, max = 255, message = "pluginwizard.error.plugin.description.size" )
73      private String _strPluginProvider;
74      @NotEmpty( message = "pluginwizard.error.plugin.urlProvider.notEmpty" )
75      @URL( message = "pluginwizard.error.plugin.urlProvider.url" )
76      private String _strPluginProviderUrl;
77      private String _strPluginDbPoolRequired;
78      private Locale _locale;
79      private List<Application> _listPluginApplications;
80      private List<Feature> _listPluginFeatures;
81      private List<Portlet> _listPluginPortlets;
82      private List<BusinessClass> _listBusinessClasses;
83      private Rest _rest;
84      private boolean _bIsModule;
85  
86      /**
87       *
88       */
89      public PluginModel( )
90      {
91          _listPluginApplications = new ArrayList<>( );
92          _listPluginFeatures = new ArrayList<>( );
93          _listPluginPortlets = new ArrayList<>( );
94          _listBusinessClasses = new ArrayList<>( );
95          _rest = new Rest( );
96      }
97  
98      /**
99       * Returns the IdPlugin
100      * 
101      * @return The IdPlugin
102      */
103     public int getIdPlugin( )
104     {
105         return _nIdPlugin;
106     }
107 
108     /**
109      * Sets the IdPlugin
110      * 
111      * @param nIdPlugin
112      *            The IdPlugin
113      */
114     public void setIdPlugin( int nIdPlugin )
115     {
116         _nIdPlugin = nIdPlugin;
117     }
118 
119     /**
120      * Returns the PluginName
121      * 
122      * @return The PluginName
123      */
124     public String getPluginName( )
125     {
126         return _strPluginName;
127     }
128 
129     /**
130      * Returns the Plugin or Module name formatted with dots as package
131      * 
132      * @return The PluginName
133      */
134     @JsonIgnore
135     public String getPluginNameAsRadicalPackage( )
136     {
137         if ( isModule( ) )
138         {
139             return _strPluginName.split( "-" ) [0] + ".modules." + _strPluginName.split( "-" ) [1];
140         }
141         else
142         {
143             return _strPluginName;
144         }
145 
146     }
147 
148     /**
149      * Returns the Plugin or Module name formatted with slashes as Path
150      *
151      * @return The PluginName
152      */
153     @JsonIgnore
154     public String getPluginNameAsRadicalPath( )
155     {
156         if ( isModule( ) )
157         {
158             return _strPluginName.split( "-" ) [0] + "/modules/" + _strPluginName.split( "-" ) [1];
159         }
160         else
161         {
162             return _strPluginName;
163         }
164     }
165 
166     /**
167      * Returns the Plugin or Module name for i18n keys
168      * 
169      * @return The PluginName
170      */
171     @JsonIgnore
172     public String getPluginNameAsPackage( )
173     {
174         if ( isModule( ) )
175         {
176             return "module." + _strPluginName.replace( "-", "." );
177         }
178         else
179         {
180             return _strPluginName;
181         }
182 
183     }
184 
185     /**
186      * Returns the Plugin or Module name for Ressource
187      * 
188      * @return The PluginName
189      */
190     @JsonIgnore
191     public String getPluginNameForRessource( )
192     {
193         if ( isModule( ) )
194         {
195             return getModuleName( ).toLowerCase( );
196         }
197         else
198         {
199             return _strPluginName.toLowerCase( );
200         }
201 
202     }
203 
204     /**
205      * Returns the Plugin or Module name
206      * 
207      * @return The PluginName
208      */
209     @JsonIgnore
210     public String getModuleName( )
211     {
212         if ( isModule( ) )
213         {
214             return getPluginName( ).split( "-" ) [1];
215         }
216         else
217         {
218             return "";
219         }
220     }
221 
222     /**
223      * Sets the PluginName
224      * 
225      * @param strPluginName
226      *            The PluginName
227      */
228     public void setPluginName( String strPluginName )
229     {
230         _strPluginName = strPluginName;
231     }
232 
233     /**
234      * Returns the PluginClass
235      * 
236      * @return The PluginClass
237      */
238     public String getPluginClass( )
239     {
240         return _strPluginClass;
241     }
242 
243     /**
244      * Sets the PluginClass
245      * 
246      * @param strPluginClass
247      *            The PluginClass
248      */
249     public void setPluginClass( String strPluginClass )
250     {
251         _strPluginClass = strPluginClass;
252     }
253 
254     /**
255      * Returns the PluginDescription
256      * 
257      * @return The PluginDescription
258      */
259     public String getPluginDescription( )
260     {
261         return _strPluginDescription;
262     }
263 
264     /**
265      * Sets the PluginDescription
266      * 
267      * @param strPluginDescription
268      *            The PluginDescription
269      */
270     public void setPluginDescription( String strPluginDescription )
271     {
272         _strPluginDescription = strPluginDescription;
273     }
274 
275     /**
276      * Returns the PluginDocumentation
277      * 
278      * @return The PluginDocumentation
279      */
280     public String getPluginDocumentation( )
281     {
282         return _strPluginDocumentation;
283     }
284 
285     /**
286      * Sets the PluginDocumentation
287      * 
288      * @param strPluginDocumentation
289      *            The PluginDocumentation
290      */
291     public void setPluginDocumentation( String strPluginDocumentation )
292     {
293         _strPluginDocumentation = strPluginDocumentation;
294     }
295 
296     /**
297      * Returns the PluginInstallation
298      * 
299      * @return The PluginInstallation
300      */
301     public String getPluginInstallation( )
302     {
303         return _strPluginInstallation;
304     }
305 
306     /**
307      * Sets the PluginInstallation
308      * 
309      * @param strPluginInstallation
310      *            The PluginInstallation
311      */
312     public void setPluginInstallation( String strPluginInstallation )
313     {
314         _strPluginInstallation = strPluginInstallation;
315     }
316 
317     /**
318      * Returns the PluginChanges
319      * 
320      * @return The PluginChanges
321      */
322     public String getPluginChanges( )
323     {
324         return _strPluginChanges;
325     }
326 
327     /**
328      * Sets the PluginChanges
329      * 
330      * @param strPluginChanges
331      *            The PluginChanges
332      */
333     public void setPluginChanges( String strPluginChanges )
334     {
335         _strPluginChanges = strPluginChanges;
336     }
337 
338     /**
339      * Returns the PluginUserGuide
340      * 
341      * @return The PluginUserGuide
342      */
343     public String getPluginUserGuide( )
344     {
345         return _strPluginUserGuide;
346     }
347 
348     /**
349      * Sets the PluginUserGuide
350      * 
351      * @param strPluginUserGuide
352      *            The PluginUserGuide
353      */
354     public void setPluginUserGuide( String strPluginUserGuide )
355     {
356         _strPluginUserGuide = strPluginUserGuide;
357     }
358 
359     /**
360      * Returns the PluginVersion
361      * 
362      * @return The PluginVersion
363      */
364     public String getPluginVersion( )
365     {
366         return _strPluginVersion;
367     }
368 
369     /**
370      * Sets the PluginVersion
371      * 
372      * @param strPluginVersion
373      *            The PluginVersion
374      */
375     public void setPluginVersion( String strPluginVersion )
376     {
377         _strPluginVersion = strPluginVersion;
378     }
379 
380     /**
381      * Returns the PluginCopyright
382      * 
383      * @return The PluginCopyright
384      */
385     public String getPluginCopyright( )
386     {
387         return _strPluginCopyright;
388     }
389 
390     /**
391      * Sets the PluginCopyright
392      * 
393      * @param strPluginCopyright
394      *            The PluginCopyright
395      */
396     public void setPluginCopyright( String strPluginCopyright )
397     {
398         _strPluginCopyright = strPluginCopyright;
399     }
400 
401     /**
402      * Returns the PluginIconUrl
403      * 
404      * @return The PluginIconUrl
405      */
406     public String getPluginIconUrl( )
407     {
408         return _strPluginIconUrl;
409     }
410 
411     /**
412      * Sets the PluginIconUrl
413      * 
414      * @param strPluginIconUrl
415      *            The PluginIconUrl
416      */
417     public void setPluginIconUrl( String strPluginIconUrl )
418     {
419         _strPluginIconUrl = strPluginIconUrl;
420     }
421 
422     /**
423      * Returns the PluginProvider
424      * 
425      * @return The PluginProvider
426      */
427     public String getPluginProvider( )
428     {
429         return _strPluginProvider;
430     }
431 
432     /**
433      * Sets the PluginProvider
434      * 
435      * @param strPluginProvider
436      *            The PluginProvider
437      */
438     public void setPluginProvider( String strPluginProvider )
439     {
440         _strPluginProvider = strPluginProvider;
441     }
442 
443     /**
444      * Returns the PluginProviderUrl
445      * 
446      * @return The PluginProviderUrl
447      */
448     public String getPluginProviderUrl( )
449     {
450         return _strPluginProviderUrl;
451     }
452 
453     /**
454      * Sets the PluginProviderUrl
455      * 
456      * @param strPluginProviderUrl
457      *            The PluginProviderUrl
458      */
459     public void setPluginProviderUrl( String strPluginProviderUrl )
460     {
461         _strPluginProviderUrl = strPluginProviderUrl;
462     }
463 
464     /**
465      * Returns the PluginDbPoolRequired
466      * 
467      * @return The PluginDbPoolRequired
468      */
469     public String getPluginDbPoolRequired( )
470     {
471         return _strPluginDbPoolRequired;
472     }
473 
474     /**
475      * Sets the PluginDbPoolRequired
476      * 
477      * @param strPluginDbPoolRequired
478      *            The PluginDbPoolRequired
479      */
480     public void setPluginDbPoolRequired( String strPluginDbPoolRequired )
481     {
482         _strPluginDbPoolRequired = strPluginDbPoolRequired;
483     }
484 
485     /**
486      * Gets the locale of the plugin
487      * 
488      * @return The Locale
489      */
490     public Locale getLocale( )
491     {
492         return _locale;
493     }
494 
495     /**
496      * Gets the locale of the plugin
497      * 
498      * @param locale
499      *            The locale
500      */
501     public void setLocale( Locale locale )
502     {
503         _locale = locale;
504     }
505 
506     /**
507      * Sets the list of plugin applications
508      * 
509      * @param listPluginApplications
510      *            The list of plugin applications
511      */
512     public void setApplications( List<Application> listPluginApplications )
513     {
514         if ( listPluginApplications != null )
515         {
516             _listPluginApplications = new ArrayList<>( listPluginApplications );
517         }
518         else
519         {
520             _listPluginApplications = null;
521         }
522     }
523 
524     /**
525      * Returns the list of plugin applications
526      * 
527      * @return The collection of applications
528      */
529     public List<Application> getApplications( )
530     {
531         return new ArrayList<>( _listPluginApplications );
532     }
533 
534     /**
535      * Sets the rest
536      * 
537      * @param rest
538      *            The rest
539      */
540     public void setRest( Rest rest )
541     {
542         _rest = rest;
543     }
544 
545     /**
546      * Returns the rest
547      * 
548      * @return The rest
549      */
550     public Rest getRest( )
551     {
552         return _rest;
553     }
554 
555     /**
556      * Sets the list of plugin features
557      * 
558      * @param listPluginFeatures
559      *            The list of plugi features
560      */
561     public void setFeatures( List<Feature> listPluginFeatures )
562     {
563         if ( listPluginFeatures != null )
564         {
565             _listPluginFeatures = new ArrayList<>( listPluginFeatures );
566         }
567         else
568         {
569             _listPluginFeatures = null;
570         }
571     }
572 
573     /**
574      * Returns the list of plugin features
575      * 
576      * @return The plugin features
577      */
578     public List<Feature> getFeatures( )
579     {
580         return new ArrayList<>( _listPluginFeatures );
581     }
582 
583     /**
584      * Sets the list of plugin portlets
585      * 
586      * @param listPluginPortlets
587      *            The list of plugin portlets
588      */
589     public void setPortlets( List<Portlet> listPluginPortlets )
590     {
591         if ( listPluginPortlets != null )
592         {
593             _listPluginPortlets = new ArrayList<>( listPluginPortlets );
594         }
595         else
596         {
597             _listPluginPortlets = null;
598         }
599     }
600 
601     /**
602      * Returns the list of plugin portlets
603      * 
604      * @return The list of portlets
605      */
606     public List<Portlet> getPortlets( )
607     {
608         return new ArrayList<>( _listPluginPortlets );
609     }
610 
611     /**
612      * Returns the list of business classes attached to the generated plugin
613      * 
614      * @return The list of business classes
615      */
616     public List<BusinessClass> getBusinessClasses( )
617     {
618         return new ArrayList<>( _listBusinessClasses );
619     }
620 
621     public void setBusinessClasses( List<BusinessClass> listBusinessClasses )
622     {
623         _listBusinessClasses = new ArrayList<>( listBusinessClasses );
624     }
625 
626     public List<Feature> BusinessClass( )
627     {
628         throw new UnsupportedOperationException( "Not supported yet." ); // To change body of generated methods, choose Tools | Templates.
629     }
630 
631     /**
632      * Returns the Type (module or plugin)
633      * 
634      * @return The Type
635      */
636     public String getType( )
637     {
638         return _strType;
639     }
640 
641     /**
642      * Sets the Type
643      * 
644      * @param The
645      *            Type
646      */
647     public void setType( String strType )
648     {
649         _strType = strType;
650     }
651 
652     /**
653      * Returns the isModule boolean value
654      * 
655      * @return The isModule
656      */
657     public boolean isModule( )
658     {
659         return ( _bIsModule || "MODULE".equals( _strType ) );
660     }
661 
662     /**
663      * Returns the isModule boolean value
664      * 
665      * @return The isModule
666      */
667     @JsonIgnore
668     public boolean getModule( )
669     {
670         return _bIsModule;
671     }
672 
673     /**
674      * Sets the isModule flag
675      * 
676      * @param _bIsModule
677      *            The isModule boolean value
678      */
679     public void setModule( boolean bIsModule )
680     {
681         this._bIsModule = bIsModule;
682     }
683 
684 }