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