001/**
002 * Copyright 2005-2015 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.edl.impl.extract;
017
018import java.util.Iterator;
019
020import org.kuali.rice.edl.framework.extract.DumpDTO;
021import org.kuali.rice.edl.framework.extract.ExtractService;
022import org.kuali.rice.edl.impl.extract.dao.ExtractDAO;
023
024
025public class ExtractServiceImpl implements ExtractService {
026
027        private ExtractDAO extractDAO;
028
029        public DumpDTO getDumpByDocumentId(String documentId) {
030                return Dump.to(getExtractDAO().getDumpByDocumentId(documentId));
031        }
032
033        public void saveDump(DumpDTO dumpDTO) {
034                try {
035                        Dump dump = Dump.from(dumpDTO);
036                        getExtractDAO().saveDump(dump);
037                        if (! dump.getFields().isEmpty()){
038                                for (Iterator iter = dump.getFields().iterator(); iter.hasNext();) {
039                                        Fields field = (Fields) iter.next();
040                                        getExtractDAO().saveField(field);
041                                }
042                        }
043                } catch (Exception e) {
044                        throw new RuntimeException(e);
045                }
046        }
047
048        public void setExtractDAO(ExtractDAO extractDAO) {
049                this.extractDAO = extractDAO;
050        }
051
052
053        public void deleteDump(String docId) {
054                try {
055                        getExtractDAO().deleteDump(docId);
056                } catch (Exception e) {
057                        throw new RuntimeException(e);
058                }
059        }
060
061        public ExtractDAO getExtractDAO() {
062                return extractDAO;
063        }
064}