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.task;
20  
21  import java.util.Optional;
22  import javax.persistence.EnumType;
23  import javax.persistence.Enumerated;
24  import javax.persistence.Lob;
25  import javax.persistence.ManyToOne;
26  import javax.persistence.MappedSuperclass;
27  import javax.validation.constraints.NotNull;
28  import org.apache.syncope.common.lib.types.MatchingRule;
29  import org.apache.syncope.common.lib.types.ThreadPoolSettings;
30  import org.apache.syncope.common.lib.types.UnmatchingRule;
31  import org.apache.syncope.core.persistence.api.entity.ExternalResource;
32  import org.apache.syncope.core.persistence.api.entity.task.ProvisioningTask;
33  import org.apache.syncope.core.persistence.api.entity.task.SchedTask;
34  import org.apache.syncope.core.persistence.jpa.entity.JPAExternalResource;
35  import org.apache.syncope.core.persistence.jpa.validation.entity.ProvisioningTaskCheck;
36  import org.apache.syncope.core.provisioning.api.serialization.POJOHelper;
37  
38  @MappedSuperclass
39  @ProvisioningTaskCheck
40  public abstract class AbstractProvisioningTask<T extends SchedTask>
41          extends JPASchedTask implements ProvisioningTask<T> {
42  
43      private static final long serialVersionUID = -4141057723006682562L;
44  
45      /**
46       * ExternalResource to which pull happens.
47       */
48      @ManyToOne
49      private JPAExternalResource resource;
50  
51      @NotNull
52      private Boolean performCreate = false;
53  
54      @NotNull
55      private Boolean performUpdate = false;
56  
57      @NotNull
58      private Boolean performDelete = false;
59  
60      @NotNull
61      private Boolean syncStatus = false;
62  
63      /**
64       * @see UnmatchingRule
65       */
66      @NotNull
67      @Enumerated(EnumType.STRING)
68      protected UnmatchingRule unmatchingRule;
69  
70      /**
71       * @see MatchingRule
72       */
73      @NotNull
74      @Enumerated(EnumType.STRING)
75      protected MatchingRule matchingRule;
76  
77      @Lob
78      protected String concurrentSettings;
79  
80      @Override
81      public ExternalResource getResource() {
82          return resource;
83      }
84  
85      @Override
86      public void setResource(final ExternalResource resource) {
87          checkType(resource, JPAExternalResource.class);
88          this.resource = (JPAExternalResource) resource;
89      }
90  
91      @Override
92      public boolean isPerformCreate() {
93          return performCreate;
94      }
95  
96      @Override
97  
98      public void setPerformCreate(final boolean performCreate) {
99          this.performCreate = performCreate;
100     }
101 
102     @Override
103 
104     public boolean isPerformUpdate() {
105         return performUpdate;
106     }
107 
108     @Override
109 
110     public void setPerformUpdate(final boolean performUpdate) {
111         this.performUpdate = performUpdate;
112     }
113 
114     @Override
115     public boolean isPerformDelete() {
116         return performDelete;
117     }
118 
119     @Override
120     public void setPerformDelete(final boolean performDelete) {
121         this.performDelete = performDelete;
122     }
123 
124     @Override
125     public boolean isSyncStatus() {
126         return syncStatus;
127     }
128 
129     @Override
130     public void setSyncStatus(final boolean syncStatus) {
131         this.syncStatus = syncStatus;
132     }
133 
134     @Override
135     public UnmatchingRule getUnmatchingRule() {
136         return this.unmatchingRule;
137     }
138 
139     @Override
140     public void setUnmatchingRule(final UnmatchingRule unmatchigRule) {
141         this.unmatchingRule = unmatchigRule;
142     }
143 
144     @Override
145     public MatchingRule getMatchingRule() {
146         return this.matchingRule;
147     }
148 
149     @Override
150     public void setMatchingRule(final MatchingRule matchigRule) {
151         this.matchingRule = matchigRule;
152     }
153 
154     @Override
155     public ThreadPoolSettings getConcurrentSettings() {
156         return Optional.ofNullable(concurrentSettings).
157                 map(s -> POJOHelper.deserialize(s, ThreadPoolSettings.class)).orElse(null);
158     }
159 
160     @Override
161     public void setConcurrentSettings(final ThreadPoolSettings settings) {
162         this.concurrentSettings = Optional.ofNullable(settings).map(POJOHelper::serialize).orElse(null);
163     }
164 }