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.appcenter.modules.sources.business;
35  
36  import java.util.HashMap;
37  import java.util.List;
38  import java.util.Locale;
39  import java.util.Map;
40  
41  import org.hibernate.validator.constraints.NotEmpty;
42  
43  import com.fasterxml.jackson.annotation.JsonIgnore;
44  
45  import fr.paris.lutece.plugins.appcenter.business.Demand;
46  import fr.paris.lutece.plugins.appcenter.modules.sources.service.SourcesUtil;
47  import fr.paris.lutece.portal.service.template.AppTemplateService;
48  
49  public class SourcesDemand extends Demand
50  {
51      
52      
53      
54      public static final String DEMAND_TYPE = "sources";
55      public static final String ID_DEMAND_TYPE = "sources";
56      
57      private static final String TEMPLATE_SOURCES_DEMAND_INFOS = "skin/plugins/appcenter/modules/sources/sources_demand_infos.html";
58      @NotEmpty( message = "#i18n{module.appcenter.sources.validation.repositoryType.notEmpty}" )
59      private String _strRepositoryType;
60      @NotEmpty( message = "#i18n{module.appcenter.sources.validation.repositoryName.notEmpty}" )
61      private String _strRepositoryName;
62      private boolean _bPublicRepository;
63      private String _strCategory;
64      private List<SourceUserDemand> _listSourceUserDemand;
65      
66       
67      /**
68       * {@inheritDoc}
69       */
70      @Override
71      public String getComplementaryInfos( )
72      {
73          Map<String, Object> model = new HashMap<String, Object>( );
74          model.put( MARK_DEMAND, this );
75          model.put(SourcesUtil.MARK_REPOSITORY_TYPES_MAP, SourcesUtil.getAllRepositoryType(Locale.FRENCH).toMap());
76          
77          return AppTemplateService.getTemplate( TEMPLATE_SOURCES_DEMAND_INFOS, Locale.FRENCH, model ).getHtml( );
78      }
79  
80      /**
81       * Get the demand type id
82       * 
83       * @return the demand type id
84       */
85      @JsonIgnore
86      @Override
87      public String getIdDemandType( )
88      {
89          return ID_DEMAND_TYPE;
90      }
91  
92      /**
93       * Get the demand type id
94       * 
95       * @return the demand type id
96       */
97      @JsonIgnore
98      @Override
99      public String getDemandType( )
100     {
101         return DEMAND_TYPE;
102     }
103 
104     @JsonIgnore
105     @Override
106     public boolean isDependingOfEnvironment()
107     {
108         return false;
109     }
110 
111     public String getRepositoryType( )
112     {
113         return _strRepositoryType;
114     }
115 
116     public void setRepositoryType( String _strRepositoryType )
117     {
118         this._strRepositoryType = _strRepositoryType;
119     }
120 
121     public String getRepositoryName( )
122     {
123         return _strRepositoryName;
124     }
125 
126     public void setRepositoryName( String _strRepositoryName )
127     {
128         this._strRepositoryName = _strRepositoryName;
129     }
130 
131     public boolean isPublicRepository( )
132     {
133         return _bPublicRepository;
134     }
135 
136     public void setPublicRepository( boolean bPublicRepository )
137     {
138         this._bPublicRepository = bPublicRepository;
139     }
140 
141     public String getCategory( )
142     {
143         return _strCategory;
144     }
145 
146     public void setCategory( String _strCategory )
147     {
148         this._strCategory = _strCategory;
149     }
150 
151     public List<SourceUserDemand> getListSourceUserDemand( )
152     {
153         return _listSourceUserDemand;
154     }
155 
156     public void setListSourceUserDemand( List<SourceUserDemand> _listSourceUserDemand )
157     {
158         this._listSourceUserDemand = _listSourceUserDemand;
159 
160     }
161 
162 }