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   package org.directdemocracyportal.democracy.service;
6   
7   import java.util.Date;
8   import java.util.List;
9   
10  import org.directdemocracyportal.democracy.model.application.Event;
11  import org.directdemocracyportal.democracy.model.application.OnlinePoliticalParty;
12  import org.directdemocracyportal.democracy.model.application.Portal;
13  import org.directdemocracyportal.democracy.model.application.User;
14  import org.directdemocracyportal.democracy.model.application.UserSession;
15  import org.directdemocracyportal.democracy.model.core.GroupAgent;
16  import org.directdemocracyportal.democracy.model.core.Role;
17  import org.directdemocracyportal.democracy.model.world.Country;
18  import org.directdemocracyportal.democracy.model.world.Election;
19  import org.directdemocracyportal.democracy.model.world.ElectionType;
20  import org.directdemocracyportal.democracy.model.world.Government;
21  import org.directdemocracyportal.democracy.model.world.GovernmentType;
22  import org.directdemocracyportal.democracy.model.world.Issue;
23  import org.directdemocracyportal.democracy.model.world.Organisation;
24  import org.directdemocracyportal.democracy.model.world.OrganisationType;
25  import org.directdemocracyportal.democracy.model.world.Person;
26  import org.directdemocracyportal.democracy.model.world.PoliticalParty;
27  import org.directdemocracyportal.democracy.model.world.Region;
28  import org.directdemocracyportal.democracy.model.world.Resolution;
29  import org.directdemocracyportal.democracy.model.world.VoteResult;
30  import org.directdemocracyportal.democracy.service.command.CreatePartyCommand;
31  import org.springframework.dao.DataAccessException;
32  
33  /***
34   * The Interface PortalService.
35   */
36  public interface PortalService
37  {
38  
39      /***
40       * Gets the active user sessions.
41       *
42       * @return the active user sessions
43       */
44      List<UserSession> getActiveUserSessions();
45  
46      /***
47       * Gets the users.
48       *
49       * @return the users
50       */
51      List<User> getUsers();
52  
53      /***
54       * Gets the events.
55       *
56       * @return the events
57       */
58      List<Event> getEvents();
59  
60      /***
61       * Gets the elections.
62       *
63       * @return the elections
64       */
65      List<Election> getElections();
66  
67      /***
68       * Gets the governments.
69       *
70       * @return the governments
71       */
72      List<Government> getGovernments();
73  
74      /***
75       * Gets the portals.
76       *
77       * @return the portals
78       */
79      List<Portal> getPortals();
80  
81      /***
82       * Gets the countries.
83       *
84       * @return the countries
85       */
86      List<Country> getCountries();
87  
88      /***
89       * Creates the party.
90       *
91       * @param command the command
92       * @param userId the user id
93       * @return the political party
94       * @throws PartyAlreadyExistException the party already exist exception
95       */
96      PoliticalParty createParty(CreatePartyCommand command, Long userId)
97              throws PartyAlreadyExistException;
98  
99      /***
100      * Gets the political parties.
101      *
102      * @return the political parties
103      */
104     List<PoliticalParty> getPoliticalParties();
105 
106     /***
107      * Gets the online political parties.
108      *
109      * @return the online political parties
110      */
111     List<OnlinePoliticalParty> getOnlinePoliticalParties();
112 
113     /***
114      * Gets the political party.
115      *
116      * @param partyId the party id
117      * @return the political party
118      */
119     PoliticalParty getPoliticalParty(Long partyId);
120 
121     /***
122      * Join party.
123      *
124      * @param partyId the party id
125      * @param userId the user id
126      * @return the online political party
127      */
128     OnlinePoliticalParty joinParty(Long partyId, Long userId);
129 
130     /***
131      * Gets the government.
132      *
133      * @param governmentId the government id
134      * @return the government
135      */
136     Government getGovernment(Long governmentId);
137 
138     /***
139      * Gets the organisation.
140      *
141      * @param organisationId the organisation id
142      * @return the organisation
143      */
144     GroupAgent getOrganisation(Long organisationId);
145 
146     /***
147      * Creates the government.
148      *
149      * @param name the name
150      * @param countryId the country id
151      * @param governmentType the government type
152      * @param headOfState the head of state
153      * @return the government
154      */
155     Government createGovernment(String name, Long countryId,
156             GovernmentType governmentType, String headOfState);
157 
158     /***
159      * Creates the regional government.
160      *
161      * @param name the name
162      * @param country the country
163      * @param region the region
164      * @param organisationType the organisation type
165      * @param parentGovernment the parent government
166      * @return the government
167      */
168     Government createRegionalGovernment(String name, Country country,
169             Region region, OrganisationType organisationType,
170             Government parentGovernment);
171 
172     /***
173      * Creates the political party.
174      *
175      * @param name the name
176      * @param shortCode the short code
177      * @param country the country
178      * @param region the region
179      * @return the political party
180      */
181     PoliticalParty createPoliticalParty(String name, String shortCode,
182             Country country, Region region);
183 
184     /***
185      * Creates the organisation.
186      *
187      * @param name the name
188      * @param abbr the abbr
189      * @param country the country
190      * @param region the region
191      * @param organisationType the organisation type
192      * @param parent the parent
193      * @return the organisation
194      * @throws OrganisationAlreadyExistException the organisation already exist exception
195      */
196     Organisation createOrganisation(String name, String abbr,
197             Country country, Region region,
198             OrganisationType organisationType, Organisation parent) throws OrganisationAlreadyExistException;
199 
200     /***
201      * Adds the member.
202      *
203      * @param organisation the organisation
204      * @param person the person
205      */
206     void addMember(Organisation organisation, Person person);
207 
208     /***
209      * Adds the role played.
210      *
211      * @param role the role
212      * @param person the person
213      */
214     void addRolePlayed(Role role, Person person);
215 
216     /***
217      * Creates the role in org.
218      *
219      * @param roleName the role name
220      * @param organisation the organisation
221      * @return the role
222      */
223     Role createRoleInOrg(String roleName, Organisation organisation);
224 
225     /***
226      * Gets the global portal.
227      *
228      * @return the global portal
229      */
230     public Portal getGlobalPortal();
231 
232     /***
233      * Creates the resolution.
234      *
235      * @param resolution the resolution
236      */
237     void createResolution(Resolution resolution);
238 
239     /***
240      * Sets the resolution decided date.
241      *
242      * @param resolution the resolution
243      * @param parseDate the parse date
244      */
245     void setResolutionDecidedDate(Resolution resolution, Date parseDate);
246 
247     /***
248      * Gets the decided resolutions.
249      *
250      * @return the decided resolutions
251      */
252     public List<Resolution> getDecidedResolutions();
253 
254     /***
255      * Adds the resolution issue.
256      *
257      * @param resolution the resolution
258      * @param issue the issue
259      * @param voteResult the vote result
260      */
261     void addResolutionIssue(Resolution resolution, Issue issue,
262             VoteResult voteResult);
263 
264     /***
265      * Update vote result.
266      *
267      * @param voteResult the vote result
268      */
269     void updateVoteResult(VoteResult voteResult);
270 
271     /***
272      * Find org by name.
273      *
274      * @param sverigesRiksdag the sveriges riksdag
275      * @return the organisation
276      */
277     Organisation findOrgByName(String sverigesRiksdag);
278 
279     /***
280      * Creates the org unit.
281      *
282      * @param orgName the org name
283      * @param shortName the short name
284      * @param internal the internal
285      * @param orgId the org id
286      * @return the organisation
287      * @throws OrganisationAlreadyExistException the organisation already exist exception
288      */
289     Organisation createOrgUnit(String orgName, String shortName,
290             OrganisationType internal, Long orgId) throws OrganisationAlreadyExistException;
291 
292     /***
293      * Find member by name in org.
294      *
295      * @param orgId the org id
296      * @param presidentName the president name
297      * @return the person
298      */
299     Person findMemberByNameInOrg(Long orgId, String presidentName);
300 
301     /***
302      * Adds the member by id.
303      *
304      * @param orgId the org id
305      * @param personId the person id
306      */
307     void addMemberById(Long orgId, Long personId);
308 
309     /***
310      * Adds the role played by id.
311      *
312      * @param roleId the role id
313      * @param agentId the agent id
314      */
315     void addRolePlayedById(Long roleId, Long agentId);
316 
317     /***
318      * Find country by name.
319      *
320      * @param country the country
321      * @return the country
322      */
323     Country findCountryByName(String country);
324 
325     /***
326      * Creates the country.
327      *
328      * @param sverige the sverige
329      * @return the country
330      */
331     Country createCountry(String sverige);
332 
333     /***
334      * Creates the election.
335      *
336      * @param name the name
337      * @param electionType the election type
338      * @param id the id
339      */
340     void createElection(String name,ElectionType electionType, Long id);
341 
342     /***
343      * Creates the political party by id.
344      *
345      * @param name the name
346      * @param shortCode the short code
347      * @param countryId the country id
348      * @return the political party
349      */
350     PoliticalParty createPoliticalPartyById(String name, String shortCode,
351             Long countryId);
352 
353     /***
354      * Creates the organisation by id.
355      *
356      * @param name the name
357      * @param abbr the abbr
358      * @param countryId the country id
359      * @param regionId the region id
360      * @param type the type
361      * @param orgId the org id
362      * @throws DataAccessException the data access exception
363      * @throws OrganisationAlreadyExistException the organisation already exist exception
364      */
365     void createOrganisationById(String name,String abbr, Long countryId,Long regionId,
366             OrganisationType type, Long orgId) throws DataAccessException, OrganisationAlreadyExistException;
367 
368     /***
369      * Find party by short code.
370      *
371      * @param trim the trim
372      * @return the political party
373      */
374     PoliticalParty findPartyByShortCode(String trim);
375 
376     /***
377      * Creates the person.
378      *
379      * @param name the name
380      * @return the person
381      */
382     Person createPerson(String name);
383 
384     /***
385      * Find region by name.
386      *
387      * @param name the name
388      * @return the region
389      */
390     Region findRegionByName(String name);
391 }