View Javadoc
1   /**
2    * Copyright 2005-2014 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.service.BusinessObjectSerializerService;
23  import org.kuali.rice.krad.service.DocumentDictionaryService;
24  import org.kuali.rice.krad.service.KRADServiceLocatorWeb;
25  import org.kuali.rice.krad.service.impl.SerializerServiceBase;
26  import org.kuali.rice.krad.util.documentserializer.AlwaysTruePropertySerializibilityEvaluator;
27  import org.kuali.rice.krad.util.documentserializer.PropertySerializabilityEvaluator;
28  
29  import java.util.List;
30  
31  /**
32   * @author Kuali Rice Team (rice.collab@kuali.org)
33   *
34   * @deprecated Use {@link org.kuali.rice.krad.service.impl.DataObjectSerializerServiceImpl}.
35   */
36  @Deprecated
37  public class BusinessObjectSerializerServiceImpl extends SerializerServiceBase implements BusinessObjectSerializerService {
38  
39      private DocumentDictionaryService documentDictionaryService;
40  
41      @Override
42      public PropertySerializabilityEvaluator getPropertySerizabilityEvaluator(Object businessObject) {
43          PropertySerializabilityEvaluator evaluator = null;
44  
45          String docTypeName = getDocumentDictionaryService().getMaintenanceDocumentTypeName(businessObject.getClass());
46          MaintenanceDocumentEntry maintenanceDocumentEntry =
47                  getDocumentDictionaryService().getMaintenanceDocumentEntry(docTypeName);
48  
49          if (maintenanceDocumentEntry instanceof org.kuali.rice.kns.datadictionary.MaintenanceDocumentEntry) {
50              List<MaintainableSectionDefinition> maintainableSectionDefinitions =
51                      ((org.kuali.rice.kns.datadictionary.MaintenanceDocumentEntry) maintenanceDocumentEntry).getMaintainableSections();
52              if (CollectionUtils.isEmpty(maintainableSectionDefinitions)) {
53                  evaluator = new AlwaysTruePropertySerializibilityEvaluator();
54              } else {
55                  evaluator = new MaintenanceDocumentPropertySerializibilityEvaluator();
56                  evaluator.initializeEvaluatorForDataObject(businessObject);
57              }
58          }
59          else {
60             evaluator = new AlwaysTruePropertySerializibilityEvaluator();
61          }
62  
63          return evaluator;
64      }
65  
66      protected DocumentDictionaryService getDocumentDictionaryService() {
67          if (documentDictionaryService == null) {
68              this.documentDictionaryService = KRADServiceLocatorWeb.getDocumentDictionaryService();
69          }
70          return documentDictionaryService;
71      }
72  
73      public void setDocumentDictionaryService(DocumentDictionaryService documentDictionaryService) {
74          this.documentDictionaryService = documentDictionaryService;
75      }
76  }