Coverage Report - org.kuali.rice.edl.impl.xml.export.EdlDataExporter
 
Classes in this File Line Coverage Branch Coverage Complexity
EdlDataExporter
0%
0/16
0%
0/6
2
 
 1  
 /*
 2  
  * Copyright 2007-2008 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.edl.impl.xml.export;
 17  
 
 18  
 import java.io.IOException;
 19  
 import java.io.OutputStream;
 20  
 import java.util.ArrayList;
 21  
 import java.util.List;
 22  
 
 23  
 import org.kuali.rice.core.api.impex.ExportDataSet;
 24  
 import org.kuali.rice.core.api.services.CoreApiServiceLocator;
 25  
 import org.kuali.rice.core.impl.style.StyleBo;
 26  
 import org.kuali.rice.edl.impl.bo.EDocLiteAssociation;
 27  
 import org.kuali.rice.kew.doctype.bo.DocumentType;
 28  
 import org.kuali.rice.kew.help.HelpEntry;
 29  
 import org.kuali.rice.kew.rule.RuleBaseValues;
 30  
 import org.kuali.rice.kew.rule.RuleDelegation;
 31  
 import org.kuali.rice.kew.rule.bo.RuleAttribute;
 32  
 import org.kuali.rice.kew.rule.bo.RuleTemplate;
 33  
 import org.kuali.rice.kim.bo.impl.GroupImpl;
 34  
 import org.kuali.rice.kns.bo.BusinessObject;
 35  
 import org.kuali.rice.kns.bo.Exporter;
 36  
 import org.kuali.rice.kns.exception.ExportNotSupportedException;
 37  
 import org.kuali.rice.kns.util.KNSConstants;
 38  
 
 39  
 /**
 40  
  * An implementation of the {@link Exporter} class which facilitates exporting
 41  
  * of EDocLite data from the GUI.
 42  
  * 
 43  
  * @see ExportDataSet
 44  
  *
 45  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 46  
  */
 47  
 public class EdlDataExporter implements Exporter {
 48  
 
 49  0
         private List<String> supportedFormats = new ArrayList<String>();
 50  
 
 51  0
         public EdlDataExporter() {
 52  0
                 supportedFormats.add(KNSConstants.XML_FORMAT);
 53  0
         }
 54  
 
 55  
         @Override
 56  
         public List<String> getSupportedFormats(Class<?> dataObjectClass) {
 57  0
                 return supportedFormats;
 58  
         }
 59  
 
 60  
         /**
 61  
          * Builds the ExportDataSet based on the BusinessObjects passed in.
 62  
          */
 63  
         protected ExportDataSet buildExportDataSet(Class<?> dataObjectClass, List<? extends Object> dataObjects) {
 64  0
                 EdlExportDataSet dataSet = new EdlExportDataSet();
 65  0
                 for (Object dataObject : dataObjects) {
 66  0
                         if (dataObjectClass.equals(EDocLiteAssociation.class)) {
 67  0
                                 dataSet.getEdocLites().add((EDocLiteAssociation)dataObject);
 68  
                         }   
 69  
                 }
 70  
 
 71  0
                 return  dataSet.createExportDataSet();
 72  
         }
 73  
 
 74  
         /**
 75  
          * This overridden method ...
 76  
          * 
 77  
          * @see org.kuali.rice.kns.bo.Exporter#export(java.lang.Class, java.util.List, java.lang.String, java.io.OutputStream)
 78  
          */
 79  
         @Override
 80  
         public void export(Class<?> dataObjectClass, List<? extends Object> dataObjects, String exportFormat, OutputStream outputStream) throws IOException,
 81  
                         ExportNotSupportedException {
 82  0
                 if (!KNSConstants.XML_FORMAT.equals(exportFormat)) {
 83  0
                         throw new ExportNotSupportedException("The given export format of " + exportFormat + " is not supported by the EDocLite XML Exporter!");
 84  
                 }
 85  0
                 ExportDataSet dataSet = buildExportDataSet(dataObjectClass, dataObjects);
 86  0
                 outputStream.write(CoreApiServiceLocator.getXmlExporterService().export(dataSet));
 87  0
                 outputStream.flush();
 88  
                 
 89  0
         }
 90  
 }