View Javadoc

1   /*
2   Copyright 2010 James Pether Sörling Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 
3   	$Id
4   */
5   
6   package com.hack23.cia.model.application.impl.common;
7   
8   import gnu.trove.THashSet;
9   
10  import java.util.Set;
11  
12  import javax.persistence.CascadeType;
13  import javax.persistence.DiscriminatorValue;
14  import javax.persistence.Entity;
15  import javax.persistence.FetchType;
16  import javax.persistence.JoinTable;
17  import javax.persistence.ManyToOne;
18  import javax.persistence.OneToMany;
19  import javax.persistence.Transient;
20  
21  import org.hibernate.annotations.Cache;
22  import org.hibernate.annotations.CacheConcurrencyStrategy;
23  
24  /***
25   * The Class Portal.
26   */
27  @Entity
28  @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
29  @DiscriminatorValue("Portal")
30  public class Portal extends AbstractAgencyConfiguration {
31  
32      /***
33       * The Enum LanguageContentKey.
34       */
35      public enum LanguageContentKey {
36          
37      }
38  
39      /*** The Constant serialVersionUID. */
40      private static final long serialVersionUID = 1L;
41  
42      /*** The agency. */
43      private Agency agency;
44  
45      /*** The language content. */
46      private Set<LanguageContent> languageContent = new THashSet<LanguageContent>();
47  
48      /*** The matches url. */
49      private String matchesUrl;
50  
51      /*** The title description. */
52      private String titleDescription;
53  
54      /***
55       * Instantiates a new portal.
56       */
57      public Portal() {
58          super();
59          setResourceType(ResourceType.Configuration);
60      }
61  
62      /***
63       * Gets the agency.
64       *
65       * @return the agency
66       */
67      @ManyToOne
68      public Agency getAgency() {
69          return agency;
70          /***
71           * Sets the agency.
72           * 
73           * @param agency the new agency
74           */
75      }
76  
77      /***
78       * Gets the language content.
79       *
80       * @return the language content
81       */
82      @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
83      @JoinTable(name = "PortalLanguageContent")
84      public Set<LanguageContent> getLanguageContent() {
85          return languageContent;
86      }
87  
88      /***
89       * Gets the language content by language.
90       *
91       * @param language the language
92       * @return the language content by language
93       */
94      @Transient
95      public Set<LanguageContent> getLanguageContentByLanguage(final Language language) {
96          final Set<LanguageContent> languageSpecificContent= new THashSet<LanguageContent>();
97          
98          for (final LanguageContent languageContent :getLanguageContent()) {
99              if (language.getId().equals(languageContent.getLanguage().getId())) {
100                 languageSpecificContent.add(languageContent);
101             }
102             
103         }
104         return languageSpecificContent;
105     }
106 
107     /***
108      * Gets the matches url.
109      *
110      * @return the matches url
111      */
112     public String getMatchesUrl() {
113         return matchesUrl;
114     }
115 
116     /***
117      * Gets the title description.
118      *
119      * @return the title description
120      */
121     public String getTitleDescription() {
122         return titleDescription;
123     }
124 
125     /***
126      * Sets the agency.
127      *
128      * @param agency the new agency
129      */
130     public void setAgency(final Agency agency) {
131         this.agency = agency;
132     }
133 
134     /***
135      * Sets the language content.
136      *
137      * @param languageContent the new language content
138      */
139     public void setLanguageContent(final Set<LanguageContent> languageContent) {
140         this.languageContent = languageContent;
141     }
142 
143     /***
144      * Sets the matches url.
145      *
146      * @param matchesUrl the new matches url
147      */
148     public void setMatchesUrl(final String matchesUrl) {
149         this.matchesUrl = matchesUrl;
150     }
151 
152     
153     /***
154      * Sets the title description.
155      *
156      * @param titleDescription the new title description
157      */
158     public void setTitleDescription(final String titleDescription) {
159         this.titleDescription = titleDescription;
160     }    
161 }