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.backend.jpa.objectinfo;
20  
21  import java.time.Instant;
22  
23  import org.mycore.backend.jpa.MCRObjectIDPK;
24  import org.mycore.datamodel.metadata.MCRObjectID;
25  import org.mycore.datamodel.objectinfo.MCRObjectInfo;
26  
27  import jakarta.persistence.Column;
28  import jakarta.persistence.Entity;
29  import jakarta.persistence.Id;
30  import jakarta.persistence.IdClass;
31  import jakarta.persistence.Table;
32  
33  @Entity
34  @IdClass(MCRObjectIDPK.class)
35  @Table(name = "MCRObject")
36  public class MCRObjectInfoEntity implements MCRObjectInfo {
37  
38      private MCRObjectID id;
39  
40      private String state;
41  
42      private String createdBy;
43  
44      private String modifiedBy;
45  
46      private String deletedBy;
47  
48      private Instant createDate;
49  
50      private Instant modifyDate;
51  
52      private Instant deleteDate;
53  
54      @Override
55      @Id
56      public MCRObjectID getId() {
57          return id;
58      }
59  
60      public void setId(MCRObjectID id) {
61          this.id = id;
62      }
63  
64      @Override
65      @Column(name = "objectproject")
66      public String getObjectProject() {
67          return this.id.getProjectId();
68      }
69  
70      /**
71       * This method does nothing and is only to satisfy JPA
72       * @param objectProject ignored parameter
73       */
74      public void setObjectProject(String objectProject) {
75          // read only value
76      }
77  
78      @Override
79      @Column(name = "objecttype")
80      public String getObjectType() {
81          return this.id.getTypeId();
82      }
83  
84      /**
85       * This method does nothing and is only to satisfy JPA
86       * @param objectType ignored parameter
87       */
88      public void setObjectType(String objectType) {
89          // read only value
90      }
91  
92      @Column(name = "objectnumber")
93      public int getObjectNumber() {
94          return this.id.getNumberAsInteger();
95      }
96  
97      /**
98       * This method does nothing and is only to satisfy JPA
99       * @param objectNumber ignored parameter
100      */
101     public void setObjectNumber(int objectNumber) {
102         // read only value
103     }
104 
105     @Override
106     @Column(name = "createdate")
107     public Instant getCreateDate() {
108         return createDate;
109     }
110 
111     /**
112      * Updates the creation date of object in the Database
113      * @param createDate the creation date
114      */
115     public void setCreateDate(Instant createDate) {
116         this.createDate = createDate;
117     }
118 
119     @Override
120     @Column(name = "modifydate")
121     public Instant getModifyDate() {
122         return modifyDate;
123     }
124 
125     /**
126      * Updates the last modify date of object in the Database
127      * @param modifyDate the last modify date
128      */
129     public void setModifyDate(Instant modifyDate) {
130         this.modifyDate = modifyDate;
131     }
132 
133     @Override
134     @Column(name = "modifiedby")
135     public String getModifiedBy() {
136         return modifiedBy;
137     }
138 
139     /**
140      * Changes the user which last modified the object in the Database
141      * @param modifiedBy the user
142      */
143     public void setModifiedBy(String modifiedBy) {
144         this.modifiedBy = modifiedBy;
145     }
146 
147     @Override
148     @Column(name = "createdby")
149     public String getCreatedBy() {
150         return createdBy;
151     }
152 
153     /**
154      * Changes the user which created the object in the Database
155      * @param createdBy the user
156      */
157     public void setCreatedBy(String createdBy) {
158         this.createdBy = createdBy;
159     }
160 
161     @Override
162     @Column(name = "deletedby")
163     public String getDeletedBy() {
164         return deletedBy;
165     }
166 
167     /**
168      * Changes the user which deleted the object in the Database
169      * @param deletedBy the user
170      */
171     public void setDeletedBy(String deletedBy) {
172         this.deletedBy = deletedBy;
173     }
174 
175     @Override
176     @Column(name = "state")
177     public String getState() {
178         return state;
179     }
180 
181     /**
182      * Changes the state of the object in the Database
183      * @param state the state classification category id
184      */
185     public void setState(String state) {
186         this.state = state;
187     }
188 
189     @Override
190     @Column(name = "deletedate")
191     public Instant getDeleteDate() {
192         return deleteDate;
193     }
194 
195     /**
196      * changes the date when the object was deleted.
197      * @param deleteddate the date
198      */
199     public void setDeleteDate(Instant deleteddate) {
200         this.deleteDate = deleteddate;
201     }
202 
203     @Override
204     public String toString() {
205         return "MCRObjectInfoEntity{" +
206             "id=" + id +
207             ", state='" + state + '\'' +
208             ", createdBy='" + createdBy + '\'' +
209             ", modifiedBy='" + modifiedBy + '\'' +
210             ", deletedBy='" + deletedBy + '\'' +
211             ", createDate=" + createDate +
212             ", modifyDate=" + modifyDate +
213             ", deleteDate=" + deleteDate +
214             '}';
215     }
216 }