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.common.lib.to;
20  
21  import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
22  import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
23  import java.io.Serializable;
24  import java.util.ArrayList;
25  import java.util.List;
26  import org.apache.commons.lang3.builder.EqualsBuilder;
27  import org.apache.commons.lang3.builder.HashCodeBuilder;
28  import org.apache.syncope.common.lib.types.MappingPurpose;
29  
30  public class Item implements Serializable {
31  
32      private static final long serialVersionUID = 2983498836767176862L;
33  
34      /**
35       * Attribute schema to be mapped. Consider other we can associate tha same attribute schema more than once, with
36       * different aliases, to different resource attributes.
37       */
38      private String intAttrName;
39  
40      /**
41       * External resource's field to be mapped.
42       */
43      private String extAttrName;
44  
45      /**
46       * Specify if the mapped target resource's field is the key.
47       */
48      private boolean connObjectKey;
49  
50      /**
51       * Specify if the mapped target resource's field is the password.
52       */
53      private boolean password;
54  
55      /**
56       * Specify if the mapped target resource's field is nullable.
57       */
58      private String mandatoryCondition = "false";
59  
60      /**
61       * Mapping purposes.
62       */
63      private MappingPurpose purpose;
64  
65      /**
66       * (Optional) JEXL expression to apply to values before propagation.
67       */
68      private String propagationJEXLTransformer;
69  
70      /**
71       * (Optional) JEXL expression to apply to values before pull.
72       */
73      private String pullJEXLTransformer;
74  
75      private final List<String> transformers = new ArrayList<>();
76  
77      public boolean isConnObjectKey() {
78          return connObjectKey;
79      }
80  
81      public void setConnObjectKey(final boolean connObjectKey) {
82          this.connObjectKey = connObjectKey;
83      }
84  
85      public String getExtAttrName() {
86          return extAttrName;
87      }
88  
89      public void setExtAttrName(final String extAttrName) {
90          this.extAttrName = extAttrName;
91      }
92  
93      public String getMandatoryCondition() {
94          return mandatoryCondition;
95      }
96  
97      public void setMandatoryCondition(final String mandatoryCondition) {
98          this.mandatoryCondition = mandatoryCondition;
99      }
100 
101     public boolean isPassword() {
102         return password;
103     }
104 
105     public void setPassword(final boolean password) {
106         this.password = password;
107     }
108 
109     public String getIntAttrName() {
110         return intAttrName;
111     }
112 
113     public void setIntAttrName(final String intAttrName) {
114         this.intAttrName = intAttrName;
115     }
116 
117     public MappingPurpose getPurpose() {
118         return purpose;
119     }
120 
121     public void setPurpose(final MappingPurpose purpose) {
122         this.purpose = purpose;
123     }
124 
125     public String getPropagationJEXLTransformer() {
126         return propagationJEXLTransformer;
127     }
128 
129     public void setPropagationJEXLTransformer(final String propagationJEXLTransformer) {
130         this.propagationJEXLTransformer = propagationJEXLTransformer;
131     }
132 
133     public String getPullJEXLTransformer() {
134         return pullJEXLTransformer;
135     }
136 
137     public void setPullJEXLTransformer(final String pullJEXLTransformer) {
138         this.pullJEXLTransformer = pullJEXLTransformer;
139     }
140 
141     @JacksonXmlElementWrapper(localName = "transformers")
142     @JacksonXmlProperty(localName = "transformer")
143     public List<String> getTransformers() {
144         return transformers;
145     }
146 
147     @Override
148     public boolean equals(final Object obj) {
149         if (this == obj) {
150             return true;
151         }
152         if (obj == null) {
153             return false;
154         }
155         if (getClass() != obj.getClass()) {
156             return false;
157         }
158         Item other = (Item) obj;
159         return new EqualsBuilder().
160                 append(connObjectKey, other.connObjectKey).
161                 append(password, other.password).
162                 append(intAttrName, other.intAttrName).
163                 append(extAttrName, other.extAttrName).
164                 append(mandatoryCondition, other.mandatoryCondition).
165                 append(purpose, other.purpose).
166                 append(propagationJEXLTransformer, other.propagationJEXLTransformer).
167                 append(pullJEXLTransformer, other.pullJEXLTransformer).
168                 append(transformers, other.transformers).
169                 build();
170     }
171 
172     @Override
173     public int hashCode() {
174         return new HashCodeBuilder().
175                 append(intAttrName).
176                 append(extAttrName).
177                 append(connObjectKey).
178                 append(password).
179                 append(mandatoryCondition).
180                 append(purpose).
181                 append(propagationJEXLTransformer).
182                 append(pullJEXLTransformer).
183                 append(transformers).
184                 build();
185     }
186 }