This project has retired. For details please refer to its Attic page.
AbstractTypeDefinition xref

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.chemistry.opencmis.commons.impl.dataobjects;
20  
21  import java.util.LinkedHashMap;
22  import java.util.Map;
23  
24  import org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition;
25  import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
26  import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
27  
28  /**
29   * Abstract type definition data implementation.
30   */
31  public abstract class AbstractTypeDefinition extends AbstractExtensionData implements TypeDefinition, Cloneable {
32  
33      private static final long serialVersionUID = 1L;
34  
35      private String id;
36      private String localName;
37      private String localNamespace;
38      private String queryName;
39      private String displayName;
40      private String description;
41      private BaseTypeId baseId;
42      private String parentId;
43      private Boolean isCreatable;
44      private Boolean isFileable;
45      private Boolean isQueryable;
46      private Boolean isIncludedInSupertypeQuery;
47      private Boolean isFulltextIndexed;
48      private Boolean isControllableACL;
49      private Boolean isControllablePolicy;
50      private Map<String, PropertyDefinition<?>> propertyDefinitions;
51  
52      public void initialize(TypeDefinition typeDefinition) {
53          setId(typeDefinition.getId());
54          setLocalName(typeDefinition.getLocalName());
55          setLocalNamespace(typeDefinition.getLocalNamespace());
56          setQueryName(typeDefinition.getQueryName());
57          setDisplayName(typeDefinition.getDisplayName());
58          setDescription(typeDefinition.getDescription());
59          setBaseTypeId(typeDefinition.getBaseTypeId());
60          setParentTypeId(typeDefinition.getParentTypeId());
61          setIsCreatable(typeDefinition.isCreatable());
62          setIsFileable(typeDefinition.isFileable());
63          setIsQueryable(typeDefinition.isQueryable());
64          setIsIncludedInSupertypeQuery(typeDefinition.isIncludedInSupertypeQuery());
65          setIsFulltextIndexed(typeDefinition.isFulltextIndexed());
66          setIsControllableAcl(typeDefinition.isControllableAcl());
67          setIsControllablePolicy(typeDefinition.isControllablePolicy());
68          setPropertyDefinitions(typeDefinition.getPropertyDefinitions());
69      }
70  
71      public String getId() {
72          return id;
73      }
74  
75      public void setId(String id) {
76          this.id = id;
77      }
78  
79      public String getLocalName() {
80          return localName;
81      }
82  
83      public void setLocalName(String localName) {
84          this.localName = localName;
85      }
86  
87      public String getLocalNamespace() {
88          return localNamespace;
89      }
90  
91      public void setLocalNamespace(String localNamespace) {
92          this.localNamespace = localNamespace;
93      }
94  
95      public String getQueryName() {
96          return queryName;
97      }
98  
99      public void setQueryName(String queryName) {
100         this.queryName = queryName;
101     }
102 
103     public String getDisplayName() {
104         return displayName;
105     }
106 
107     public void setDisplayName(String displayName) {
108         this.displayName = displayName;
109     }
110 
111     public String getDescription() {
112         return description;
113     }
114 
115     public void setDescription(String description) {
116         this.description = description;
117     }
118 
119     public BaseTypeId getBaseTypeId() {
120         return baseId;
121     }
122 
123     public void setBaseTypeId(BaseTypeId baseId) {
124         this.baseId = baseId;
125     }
126 
127     public String getParentTypeId() {
128         return parentId;
129     }
130 
131     public void setParentTypeId(String parentId) {
132         if (parentId == null || parentId.length() == 0) {
133             this.parentId = null;
134         } else {
135             this.parentId = parentId;
136         }
137     }
138 
139     public Boolean isCreatable() {
140         return isCreatable;
141     }
142 
143     public void setIsCreatable(Boolean isCreatable) {
144         this.isCreatable = isCreatable;
145     }
146 
147     public Boolean isFileable() {
148         return isFileable;
149     }
150 
151     public void setIsFileable(Boolean isFileable) {
152         this.isFileable = isFileable;
153     }
154 
155     public Boolean isQueryable() {
156         return isQueryable;
157     }
158 
159     public void setIsQueryable(Boolean isQueryable) {
160         this.isQueryable = isQueryable;
161     }
162 
163     public Boolean isIncludedInSupertypeQuery() {
164         return isIncludedInSupertypeQuery;
165     }
166 
167     public void setIsIncludedInSupertypeQuery(Boolean isIncludedInSupertypeQuery) {
168         this.isIncludedInSupertypeQuery = isIncludedInSupertypeQuery;
169     }
170 
171     public Boolean isFulltextIndexed() {
172         return isFulltextIndexed;
173     }
174 
175     public void setIsFulltextIndexed(Boolean isFulltextIndexed) {
176         this.isFulltextIndexed = isFulltextIndexed;
177     }
178 
179     public Boolean isControllableAcl() {
180         return isControllableACL;
181     }
182 
183     public void setIsControllableAcl(Boolean isControllableACL) {
184         this.isControllableACL = isControllableACL;
185     }
186 
187     public Boolean isControllablePolicy() {
188         return isControllablePolicy;
189     }
190 
191     public void setIsControllablePolicy(Boolean isControllablePolicy) {
192         this.isControllablePolicy = isControllablePolicy;
193     }
194 
195     public Map<String, PropertyDefinition<?>> getPropertyDefinitions() {
196         return propertyDefinitions;
197     }
198 
199     public void setPropertyDefinitions(Map<String, PropertyDefinition<?>> propertyDefinitions) {
200         this.propertyDefinitions = propertyDefinitions;
201     }
202 
203     /**
204      * Adds a property definition.
205      * 
206      * @param propertyDefinition
207      *            the property definition
208      */
209     public void addPropertyDefinition(PropertyDefinition<?> propertyDefinition) {
210         if (propertyDefinition == null) {
211             return;
212         }
213 
214         if (this.propertyDefinitions == null) {
215             this.propertyDefinitions = new LinkedHashMap<String, PropertyDefinition<?>>();
216         }
217 
218         this.propertyDefinitions.put(propertyDefinition.getId(), propertyDefinition);
219     }
220 
221     public AbstractTypeDefinition clone() {
222         try {
223             return (AbstractTypeDefinition) super.clone();
224         } catch (CloneNotSupportedException e) {
225             e.printStackTrace();
226             throw new RuntimeException("Clone not supported", e);
227         }
228     }
229 
230     @Override
231     public String toString() {
232         return "Type Definition [base id=" + baseId + ", id=" + id + ", display Name=" + displayName + ", description="
233                 + description + ", local name=" + localName + ", local namespace=" + localNamespace + ", query name="
234                 + queryName + ", parent id=" + parentId + ", is controllable ACL=" + isControllableACL
235                 + ", is controllable policy=" + isControllablePolicy + ", is creatable=" + isCreatable
236                 + ", is fileable=" + isFileable + ", is fulltext indexed=" + isFulltextIndexed
237                 + ", is included in supertype query=" + isIncludedInSupertypeQuery + ", is queryable=" + isQueryable
238                 + ", property definitions=" + propertyDefinitions + "]" + super.toString();
239     }
240 }