View Javadoc

1   /**
2    * Copyright 2005-2013 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.extract;
17  
18  import java.util.Iterator;
19  
20  import org.kuali.rice.edl.framework.extract.DumpDTO;
21  import org.kuali.rice.edl.framework.extract.ExtractService;
22  import org.kuali.rice.edl.impl.extract.dao.ExtractDAO;
23  
24  
25  public class ExtractServiceImpl implements ExtractService {
26  
27  	private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(ExtractServiceImpl.class);
28  
29  	private ExtractDAO extractDAO;
30  
31  	public DumpDTO getDumpByDocumentId(String documentId) {
32  		return Dump.to(getExtractDAO().getDumpByDocumentId(documentId));
33  	}
34  
35  	public void saveDump(DumpDTO dumpDTO) {
36  		try {
37  			Dump dump = Dump.from(dumpDTO);
38  			getExtractDAO().saveDump(dump);
39  			if (! dump.getFields().isEmpty()){
40  				for (Iterator iter = dump.getFields().iterator(); iter.hasNext();) {
41  					Fields field = (Fields) iter.next();
42  					getExtractDAO().saveField(field);
43  				}
44  			}
45  		} catch (Exception e) {
46  			throw new RuntimeException(e);
47  		}
48  	}
49  
50  	public void setExtractDAO(ExtractDAO extractDAO) {
51  		this.extractDAO = extractDAO;
52  	}
53  
54  
55  	public void deleteDump(String docId) {
56  		try {
57  			getExtractDAO().deleteDump(docId);
58  		} catch (Exception e) {
59  			throw new RuntimeException(e);
60  		}
61  	}
62  
63  	public ExtractDAO getExtractDAO() {
64  		return extractDAO;
65  	}
66  }