001 /**
002 * Copyright 2005-2013 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 */
016 package org.kuali.rice.edl.impl.xml.export;
017
018 import java.util.ArrayList;
019 import java.util.List;
020
021 import javax.xml.namespace.QName;
022
023 import org.kuali.rice.core.api.impex.ExportDataSet;
024 import org.kuali.rice.edl.impl.bo.EDocLiteAssociation;
025
026 /**
027 * A utility class for managing an {@link ExportDataSet} containing EDocLite
028 * data. Provides a mechanism to convert instances of this class to a
029 * populated {@link ExportDataSet}.
030 *
031 * @see ExportDataSet
032 *
033 * @author Kuali Rice Team (rice.collab@kuali.org)
034 */
035 public class EdlExportDataSet {
036
037 public static final QName EDOCLITES = new QName("EDL", "eDocLites");
038
039 private List<EDocLiteAssociation> edocLites = new ArrayList<EDocLiteAssociation>();
040
041 public List<EDocLiteAssociation> getEdocLites() {
042 return edocLites;
043 }
044
045 /**
046 * Populates the given {@link ExportDataSet} with the data from this data set.
047 *
048 * @param exportDataSet the data set to populate the data into
049 */
050 public void populateExportDataSet(ExportDataSet exportDataSet) {
051 if (edocLites != null && !edocLites.isEmpty()) {
052 exportDataSet.addDataSet(EDOCLITES, edocLites);
053 }
054 }
055
056 /**
057 * Converts this data set to a standard {@link ExportDataSet}, populating
058 * it with the data from this data set.
059 *
060 * @return the populated ExportDataSet
061 */
062 public ExportDataSet createExportDataSet() {
063 ExportDataSet exportDataSet = new ExportDataSet();
064 populateExportDataSet(exportDataSet);
065 return exportDataSet;
066 }
067
068 /**
069 * A static utility for creating a {@link EdlExportDataSet} from an
070 * {@link ExportDataSet}. This method will only populate the returned
071 * EdocLite data set with EdocLite data from the given export data set. The
072 * rest of the data in the given export data set will be ignored.
073 *
074 * @param exportDataSet the ExportDataSet to pull EdocLite data from
075 * @return a StyleExportDataSet with any EdocLite data from the given exportDataSet populated
076 */
077 public static EdlExportDataSet fromExportDataSet(ExportDataSet exportDataSet) {
078 EdlExportDataSet edlExportDataSet = new EdlExportDataSet();
079
080 List<EDocLiteAssociation> edocLites = (List<EDocLiteAssociation>)exportDataSet.getDataSets().get(EDOCLITES);
081 if (edocLites != null) {
082 edlExportDataSet.getEdocLites().addAll(edocLites);
083 }
084
085 return edlExportDataSet;
086 }
087
088 }