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 java.util.Optional;
23  import javax.persistence.Column;
24  import javax.persistence.Lob;
25  import javax.persistence.MappedSuperclass;
26  import javax.validation.constraints.NotNull;
27  import org.apache.syncope.core.persistence.api.entity.Exec;
28  
29  @MappedSuperclass
30  public abstract class AbstractExec extends AbstractGeneratedKeyEntity implements Exec {
31  
32      private static final long serialVersionUID = -812344822970166317L;
33  
34      @NotNull
35      protected String status;
36  
37      @NotNull
38      protected String executor;
39  
40      /**
41       * Any information to be accompanied to this execution's result.
42       */
43      @Lob
44      protected String message;
45  
46      /**
47       * Start instant of this execution.
48       */
49      @NotNull
50      @Column(name = "startDate", nullable = false)
51      protected OffsetDateTime start;
52  
53      /**
54       * End instant of this execution.
55       */
56      @Column(name = "endDate")
57      protected OffsetDateTime end;
58  
59      @Override
60      public String getStatus() {
61          return status;
62      }
63  
64      @Override
65      public void setStatus(final String status) {
66          this.status = status;
67      }
68  
69      @Override
70      public String getExecutor() {
71          return this.executor;
72      }
73  
74      @Override
75      public void setExecutor(final String executor) {
76          this.executor = executor;
77      }
78  
79      @Override
80      public String getMessage() {
81          return message;
82      }
83  
84      @Override
85      public void setMessage(final String message) {
86          this.message = Optional.ofNullable(message).map(s -> s.replace('\0', '\n')).orElse(null);
87      }
88  
89      @Override
90      public OffsetDateTime getStart() {
91          return start;
92      }
93  
94      @Override
95      public void setStart(final OffsetDateTime start) {
96          this.start = start;
97      }
98  
99      @Override
100     public OffsetDateTime getEnd() {
101         return end;
102     }
103 
104     @Override
105     public void setEnd(final OffsetDateTime end) {
106         this.end = end;
107     }
108 }