View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.syncope.core.persistence.jpa.entity;
20  
21  import java.time.OffsetDateTime;
22  import javax.persistence.Column;
23  import javax.persistence.FetchType;
24  import javax.persistence.ManyToOne;
25  import javax.persistence.MappedSuperclass;
26  import org.apache.syncope.core.persistence.api.entity.Any;
27  import org.apache.syncope.core.persistence.api.entity.PlainAttr;
28  import org.apache.syncope.core.persistence.api.entity.Realm;
29  import org.apache.syncope.core.persistence.jpa.validation.entity.AnyCheck;
30  
31  @AnyCheck
32  @MappedSuperclass
33  public abstract class AbstractAny<P extends PlainAttr<?>> extends AbstractGeneratedKeyEntity implements Any<P> {
34  
35      private static final long serialVersionUID = -2666540708092702810L;
36  
37      /**
38       * Username of the user that has created the related instance.
39       */
40      private String creator;
41  
42      /**
43       * Creation date.
44       */
45      private OffsetDateTime creationDate;
46  
47      /**
48       * Context information about create.
49       */
50      private String creationContext;
51  
52      /**
53       * Username of the user that has performed the last modification to the related instance.
54       */
55      private String lastModifier;
56  
57      private OffsetDateTime lastChangeDate;
58  
59      /**
60       * Context information about last update.
61       */
62      private String lastChangeContext;
63  
64      @ManyToOne(fetch = FetchType.EAGER, optional = false)
65      private JPARealm realm;
66  
67      @Column(nullable = true)
68      private String status;
69  
70      @Override
71      public String getCreator() {
72          return creator;
73      }
74  
75      @Override
76      public void setCreator(final String creator) {
77          this.creator = creator;
78      }
79  
80      @Override
81      public OffsetDateTime getCreationDate() {
82          return creationDate;
83      }
84  
85      @Override
86      public void setCreationDate(final OffsetDateTime creationDate) {
87          this.creationDate = creationDate;
88      }
89  
90      @Override
91      public String getCreationContext() {
92          return creationContext;
93      }
94  
95      @Override
96      public void setCreationContext(final String creationContext) {
97          this.creationContext = creationContext;
98      }
99  
100     @Override
101     public String getLastModifier() {
102         return lastModifier;
103     }
104 
105     @Override
106     public void setLastModifier(final String lastModifier) {
107         this.lastModifier = lastModifier;
108     }
109 
110     @Override
111     public OffsetDateTime getLastChangeDate() {
112         if (lastChangeDate != null) {
113             return lastChangeDate;
114         } else if (creationDate != null) {
115             return creationDate;
116         }
117 
118         return null;
119     }
120 
121     @Override
122     public void setLastChangeDate(final OffsetDateTime lastChangeDate) {
123         this.lastChangeDate = lastChangeDate;
124     }
125 
126     @Override
127     public String getLastChangeContext() {
128         return lastChangeContext;
129     }
130 
131     @Override
132     public void setLastChangeContext(final String lastChangeContext) {
133         this.lastChangeContext = lastChangeContext;
134     }
135 
136     @Override
137     public Realm getRealm() {
138         return realm;
139     }
140 
141     @Override
142     public void setRealm(final Realm realm) {
143         checkType(realm, JPARealm.class);
144         this.realm = (JPARealm) realm;
145     }
146 
147     @Override
148     public String getStatus() {
149         return status;
150     }
151 
152     @Override
153     public void setStatus(final String status) {
154         this.status = status;
155     }
156 }