View Javadoc

1   /*
2    * Copyright (C) 2017-2019 Centre National d'Etudes Spatiales (CNES).
3    *
4    * This library is free software; you can redistribute it and/or
5    * modify it under the terms of the GNU Lesser General Public
6    * License as published by the Free Software Foundation; either
7    * version 3.0 of the License, or (at your option) any later version.
8    *
9    * This library is distributed in the hope that it will be useful,
10   * but WITHOUT ANY WARRANTY; without even the implied warranty of
11   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12   * Lesser General Public License for more details.
13   *
14   * You should have received a copy of the GNU Lesser General Public
15   * License along with this library; if not, write to the Free Software
16   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17   * MA 02110-1301  USA
18   */
19  package fr.cnes.doi.db;
20  
21  import fr.cnes.doi.db.model.DOIProject;
22  import fr.cnes.doi.db.model.DOIUser;
23  import fr.cnes.doi.exception.DOIDbException;
24  import fr.cnes.doi.utils.spec.Requirement;
25  import java.util.List;
26  
27  /**
28   * Interface for handling the project suffix database.
29   *
30   * @author Jean-Christophe Malapert (jean-christophe.malapert@cnes.fr)
31   */
32  @Requirement(reqId = Requirement.DOI_INTER_030, reqName = Requirement.DOI_INTER_030_NAME)
33  public abstract class AbstractProjectSuffixDBHelper {
34  
35      /**
36       * Adds a suffix project in the database.
37       *
38       * @param projectID suffix project
39       * @param projectName project name
40       * @return True when the suffix project is added otherwise False
41       */
42      public abstract boolean addProjectSuffix(int projectID, String projectName);
43  
44      /**
45       * Rename a project in the database.
46       *
47       * @param projectID suffix project to be renamed
48       * @param newProjectName the new project name
49       * @return True when the project has been renamed otherwise False
50       */
51      public abstract boolean renameProject(int projectID, String newProjectName);
52  
53      /**
54       * Deletes a suffix project from the database.
55       *
56       * @param projectID the suffix project
57       * @return True when the suffix project has been deleted otherwise False
58       */
59      public abstract boolean deleteProject(int projectID);
60  
61      /**
62       * Tests is a suffix project exists in the database.
63       *
64       * @param projectID suffix project
65       * @return True when the suffix project exists otherwise False
66       */
67      public abstract boolean isExistID(int projectID);
68  
69      /**
70       * Tests is the project name exists in the database.
71       *
72       * @param projectName the project name
73       * @return True when the project name exists otherwise False.
74       */
75      public abstract boolean isExistProjectName(String projectName);
76  
77      /**
78       * Returns the project name based on the suffix project.
79       *
80       * @param projectID the suffix project
81       * @return the project name
82       * @throws fr.cnes.doi.exception.DOIDbException when an error occurs
83       */
84      public abstract String getProjectFrom(int projectID) throws DOIDbException;
85  
86      /**
87       * Returns the project suffix based on the project name.
88       *
89       * @param projectName the project name
90       * @return the suffix project
91       * @throws fr.cnes.doi.exception.DOIDbException When an error occurs
92       */
93      public abstract int getIDFrom(String projectName) throws DOIDbException;
94  
95      /**
96       * Returns the database records.
97       *
98       * @return the database records
99       * @throws fr.cnes.doi.exception.DOIDbException When an error occurs
100      */
101     public abstract List<DOIProject> getProjects() throws DOIDbException;
102 
103     /**
104      * Returns the projects related to a specific user.
105      *
106      * @param userName username
107      * @return the projected to an user
108      * @throws fr.cnes.doi.exception.DOIDbException When an error occurs
109      */
110     public abstract List<DOIProject> getProjectsFromUser(final String userName) throws
111             DOIDbException;
112 
113     /**
114      * Returns the users related to a project.
115      *
116      * @param doiSuffix project
117      * @return the users
118      * @throws fr.cnes.doi.exception.DOIDbException When an error occurs.
119      */
120     public abstract List<DOIUser> getAllDOIUsersForProject(final int doiSuffix) throws
121             DOIDbException;
122 
123 }