001/** 002 * Copyright 2005-2016 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.kuali.rice.kns.service.impl; 017 018import org.apache.commons.collections.CollectionUtils; 019import org.kuali.rice.kns.datadictionary.MaintainableSectionDefinition; 020import org.kuali.rice.kns.util.documentserlializer.MaintenanceDocumentPropertySerializibilityEvaluator; 021import org.kuali.rice.krad.datadictionary.MaintenanceDocumentEntry; 022import org.kuali.rice.krad.service.BusinessObjectSerializerService; 023import org.kuali.rice.krad.service.DocumentDictionaryService; 024import org.kuali.rice.krad.service.KRADServiceLocatorWeb; 025import org.kuali.rice.krad.service.impl.SerializerServiceBase; 026import org.kuali.rice.krad.util.documentserializer.AlwaysTruePropertySerializibilityEvaluator; 027import org.kuali.rice.krad.util.documentserializer.PropertySerializabilityEvaluator; 028 029import java.util.List; 030 031/** 032 * @author Kuali Rice Team (rice.collab@kuali.org) 033 * 034 * @deprecated Use {@link org.kuali.rice.krad.service.impl.DataObjectSerializerServiceImpl}. 035 */ 036@Deprecated 037public class BusinessObjectSerializerServiceImpl extends SerializerServiceBase implements BusinessObjectSerializerService { 038 039 private DocumentDictionaryService documentDictionaryService; 040 041 @Override 042 public PropertySerializabilityEvaluator getPropertySerizabilityEvaluator(Object businessObject) { 043 PropertySerializabilityEvaluator evaluator = null; 044 045 String docTypeName = getDocumentDictionaryService().getMaintenanceDocumentTypeName(businessObject.getClass()); 046 MaintenanceDocumentEntry maintenanceDocumentEntry = 047 getDocumentDictionaryService().getMaintenanceDocumentEntry(docTypeName); 048 049 if (maintenanceDocumentEntry instanceof org.kuali.rice.kns.datadictionary.MaintenanceDocumentEntry) { 050 List<MaintainableSectionDefinition> maintainableSectionDefinitions = 051 ((org.kuali.rice.kns.datadictionary.MaintenanceDocumentEntry) maintenanceDocumentEntry).getMaintainableSections(); 052 if (CollectionUtils.isEmpty(maintainableSectionDefinitions)) { 053 evaluator = new AlwaysTruePropertySerializibilityEvaluator(); 054 } else { 055 evaluator = new MaintenanceDocumentPropertySerializibilityEvaluator(); 056 evaluator.initializeEvaluatorForDataObject(businessObject); 057 } 058 } 059 else { 060 evaluator = new AlwaysTruePropertySerializibilityEvaluator(); 061 } 062 063 return evaluator; 064 } 065 066 protected DocumentDictionaryService getDocumentDictionaryService() { 067 if (documentDictionaryService == null) { 068 this.documentDictionaryService = KRADServiceLocatorWeb.getDocumentDictionaryService(); 069 } 070 return documentDictionaryService; 071 } 072 073 public void setDocumentDictionaryService(DocumentDictionaryService documentDictionaryService) { 074 this.documentDictionaryService = documentDictionaryService; 075 } 076}