View Javadoc
1   /*
2    * This file is part of ***  M y C o R e  ***
3    * See http://www.mycore.de/ for details.
4    *
5    * MyCoRe is free software: you can redistribute it and/or modify
6    * it under the terms of the GNU General Public License as published by
7    * the Free Software Foundation, either version 3 of the License, or
8    * (at your option) any later version.
9    *
10   * MyCoRe is distributed in the hope that it will be useful,
11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13   * GNU General Public License for more details.
14   *
15   * You should have received a copy of the GNU General Public License
16   * along with MyCoRe.  If not, see <http://www.gnu.org/licenses/>.
17   */
18  
19  package org.mycore.orcid.user;
20  
21  import java.io.IOException;
22  
23  import org.jdom2.JDOMException;
24  import org.mycore.datamodel.metadata.MCRObjectID;
25  import org.mycore.orcid.MCRORCIDProfile;
26  import org.mycore.orcid.works.MCRWorksSection;
27  import org.xml.sax.SAXException;
28  
29  public class MCRPublicationStatus {
30  
31      private MCRUserStatus user;
32  
33      private String objectID;
34  
35      private boolean isUsersPublication = false;
36  
37      private boolean isInORCIDProfile = false;
38  
39      private String putCode = null;
40  
41      MCRPublicationStatus(MCRORCIDUser orcidUser, MCRObjectID oid)
42          throws JDOMException, IOException, SAXException {
43          this.user = orcidUser.getStatus();
44  
45          this.objectID = oid.toString();
46  
47          if (user.isORCIDUser()) {
48              isUsersPublication = orcidUser.isMyPublication(oid);
49  
50              MCRORCIDProfile profile = orcidUser.getProfile();
51              MCRWorksSection works = profile.getWorksSection();
52              isInORCIDProfile = works.containsWork(oid); // Maybe containsOwnWork(oid);
53  
54              if (isInORCIDProfile) {
55                  putCode = works.findWork(oid).get().getPutCode(); // Maybe findOwnWork(oid)
56              }
57          }
58      }
59  
60      public MCRUserStatus getUserStatus() {
61          return user;
62      }
63  
64      public String getObjectID() {
65          return objectID;
66      }
67  
68      public boolean isUsersPublication() {
69          return isUsersPublication;
70      }
71  
72      public boolean isInORCIDProfile() {
73          return isInORCIDProfile;
74      }
75  
76      public String getPutCode() {
77          return putCode;
78      }
79  }