Coverage Report - org.kuali.rice.krad.service.impl.BusinessObjectSerializerServiceImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
BusinessObjectSerializerServiceImpl
0%
0/21
0%
0/4
1.5
 
 1  
 /*
 2  
  * Copyright 2007-2009 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.krad.service.impl;
 17  
 
 18  
 
 19  
 import org.kuali.rice.krad.datadictionary.MaintenanceDocumentEntry;
 20  
 import org.kuali.rice.krad.service.BusinessObjectSerializerService;
 21  
 import org.kuali.rice.krad.service.DocumentDictionaryService;
 22  
 import org.kuali.rice.krad.service.KRADServiceLocatorWeb;
 23  
 import org.kuali.rice.krad.util.documentserializer.AlwaysTruePropertySerializibilityEvaluator;
 24  
 import org.kuali.rice.krad.util.documentserializer.PropertySerializabilityEvaluator;
 25  
 import org.kuali.rice.krad.util.documentserializer.SerializationState;
 26  
 
 27  0
 public class BusinessObjectSerializerServiceImpl extends SerializerServiceBase implements BusinessObjectSerializerService {
 28  
 
 29  
     private DocumentDictionaryService documentDictionaryService;
 30  
 
 31  
     /**
 32  
      * Serializes a document for routing
 33  
      *
 34  
      * @see org.kuali.rice.krad.service.DocumentSerializerService#serializeDocumentToXml(org.kuali.rice.krad.document.Document)
 35  
      */
 36  
     public String serializeBusinessObjectToXml(Object businessObject) {
 37  0
         PropertySerializabilityEvaluator propertySerizabilityEvaluator =
 38  
                 getPropertySerizabilityEvaluator(businessObject);
 39  0
         evaluators.set(propertySerizabilityEvaluator);
 40  0
         SerializationState state = new SerializationState(); //createNewDocumentSerializationState(document);
 41  0
         serializationStates.set(state);
 42  
 
 43  
         //Object xmlWrapper = null;//wrapDocumentWithMetadata(document);
 44  
         String xml;
 45  0
         if (propertySerizabilityEvaluator instanceof AlwaysTruePropertySerializibilityEvaluator) {
 46  0
             xml = getXmlObjectSerializerService().toXml(businessObject);
 47  
         } else {
 48  0
             xml = xstream.toXML(businessObject);
 49  
         }
 50  
 
 51  0
         evaluators.set(null);
 52  0
         serializationStates.set(null);
 53  0
         return xml;
 54  
     }
 55  
 
 56  
     public PropertySerializabilityEvaluator getPropertySerizabilityEvaluator(Object businessObject) {
 57  0
         PropertySerializabilityEvaluator evaluator = null;
 58  
 
 59  0
         String docTypeName = getDocumentDictionaryService().getMaintenanceDocumentTypeName(businessObject.getClass());
 60  0
         MaintenanceDocumentEntry maintenanceDocumentEntry =
 61  
                 getDocumentDictionaryService().getMaintenanceDocumentEntry(docTypeName);
 62  
 
 63  
         // TODO: need to determine view properties to serialize
 64  0
         evaluator = new AlwaysTruePropertySerializibilityEvaluator();
 65  
 
 66  0
         return evaluator;
 67  
     }
 68  
 
 69  
     protected DocumentDictionaryService getDocumentDictionaryService() {
 70  0
         if (documentDictionaryService == null) {
 71  0
             this.documentDictionaryService = KRADServiceLocatorWeb.getDocumentDictionaryService();
 72  
         }
 73  0
         return documentDictionaryService;
 74  
     }
 75  
 
 76  
     public void setDocumentDictionaryService(DocumentDictionaryService documentDictionaryService) {
 77  0
         this.documentDictionaryService = documentDictionaryService;
 78  0
     }
 79  
 }