View Javadoc
1   /**
2    * Copyright 2005-2016 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.rice.kns.service.impl;
17  
18  import org.apache.commons.collections.CollectionUtils;
19  import org.kuali.rice.kns.datadictionary.MaintainableSectionDefinition;
20  import org.kuali.rice.kns.util.documentserlializer.MaintenanceDocumentPropertySerializibilityEvaluator;
21  import org.kuali.rice.krad.datadictionary.MaintenanceDocumentEntry;
22  import org.kuali.rice.krad.util.documentserializer.AlwaysTruePropertySerializibilityEvaluator;
23  import org.kuali.rice.krad.util.documentserializer.PropertySerializabilityEvaluator;
24  
25  import java.util.List;
26  
27  /**
28   * @author Kuali Rice Team (rice.collab@kuali.org)
29   */
30  public class BusinessObjectSerializerServiceImpl extends org.kuali.rice.krad.service.impl.BusinessObjectSerializerServiceImpl {
31  
32      @Override
33      public PropertySerializabilityEvaluator getPropertySerizabilityEvaluator(Object businessObject) {
34          PropertySerializabilityEvaluator evaluator = null;
35  
36          String docTypeName = getDocumentDictionaryService().getMaintenanceDocumentTypeName(businessObject.getClass());
37          MaintenanceDocumentEntry maintenanceDocumentEntry =
38                  getDocumentDictionaryService().getMaintenanceDocumentEntry(docTypeName);
39  
40          if (maintenanceDocumentEntry instanceof org.kuali.rice.kns.datadictionary.MaintenanceDocumentEntry) {
41              List<MaintainableSectionDefinition> maintainableSectionDefinitions =
42                      ((org.kuali.rice.kns.datadictionary.MaintenanceDocumentEntry) maintenanceDocumentEntry).getMaintainableSections();
43              if (CollectionUtils.isEmpty(maintainableSectionDefinitions)) {
44                  evaluator = new AlwaysTruePropertySerializibilityEvaluator();
45              } else {
46                  evaluator = new MaintenanceDocumentPropertySerializibilityEvaluator();
47                  evaluator.initializeEvaluatorForDataObject(businessObject);
48              }
49          }
50          else {
51             evaluator = new AlwaysTruePropertySerializibilityEvaluator();
52          }
53  
54          return evaluator;
55      }
56  }