1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.edl.impl.extract.dao.impl; |
17 | |
|
18 | |
import java.util.List; |
19 | |
|
20 | |
import org.apache.ojb.broker.query.Criteria; |
21 | |
import org.apache.ojb.broker.query.QueryByCriteria; |
22 | |
import org.kuali.rice.edl.impl.extract.Dump; |
23 | |
import org.kuali.rice.edl.impl.extract.Fields; |
24 | |
import org.kuali.rice.edl.impl.extract.dao.ExtractDAO; |
25 | |
import org.kuali.rice.kew.notes.Note; |
26 | |
import org.springmodules.orm.ojb.support.PersistenceBrokerDaoSupport; |
27 | |
|
28 | |
|
29 | 0 | public class ExtractDAOOjbImpl extends PersistenceBrokerDaoSupport implements ExtractDAO { |
30 | |
|
31 | 0 | private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(ExtractDAOOjbImpl.class); |
32 | |
|
33 | |
public Dump getDumpByDocumentId(String docId) { |
34 | 0 | LOG.debug("finding Document Extract by documentId " + docId); |
35 | 0 | Criteria crit = new Criteria(); |
36 | 0 | crit.addEqualTo("docId", docId); |
37 | 0 | return (Dump) getPersistenceBrokerTemplate().getObjectByQuery(new QueryByCriteria(Dump.class, crit)); |
38 | |
} |
39 | |
|
40 | |
public List getFieldsByDocumentId(String docId) { |
41 | 0 | LOG.debug("finding Extract Fileds by documentId " + docId); |
42 | 0 | Criteria crit = new Criteria(); |
43 | 0 | crit.addEqualTo("documentId", docId); |
44 | 0 | QueryByCriteria query = new QueryByCriteria(Fields.class, crit); |
45 | 0 | query.addOrderByAscending("docId"); |
46 | 0 | return (List) getPersistenceBrokerTemplate().getCollectionByQuery(query); |
47 | |
} |
48 | |
|
49 | |
public void saveDump(Dump dump) { |
50 | 0 | LOG.debug("check for null values in Extract document"); |
51 | 0 | checkNull(dump.getDocId() , "Document ID"); |
52 | 0 | checkNull(dump.getDocCreationDate(), "Creation Date"); |
53 | 0 | checkNull(dump.getDocCurrentNodeName(), "Current Node Name"); |
54 | 0 | checkNull(dump.getDocModificationDate(), "Modification Date"); |
55 | 0 | checkNull(dump.getDocRouteStatusCode(), "Route Status Code"); |
56 | 0 | checkNull(dump.getDocInitiatorId(), "Initiator ID"); |
57 | 0 | checkNull(dump.getDocTypeName(), "Doc Type Name"); |
58 | 0 | LOG.debug("saving EDocLite document: routeHeader " + dump.getDocId()); |
59 | 0 | getPersistenceBrokerTemplate().store(dump); |
60 | 0 | } |
61 | |
|
62 | |
public void saveField(Fields field) { |
63 | 0 | LOG.debug("saving EDocLite Extract fields"); |
64 | 0 | checkNull(field.getDocId() , "Document ID"); |
65 | 0 | checkNull(field.getFieldValue(), "Field Value"); |
66 | 0 | checkNull(field.getFiledName(), "Field Name"); |
67 | 0 | LOG.debug("saving Fields: routeHeader " + field.getFieldId()); |
68 | 0 | getPersistenceBrokerTemplate().store(field); |
69 | 0 | } |
70 | |
|
71 | |
private void checkNull(Object value, String valueName) throws RuntimeException { |
72 | 0 | if (value == null) { |
73 | 0 | throw new RuntimeException("Null value for " + valueName); |
74 | |
} |
75 | 0 | } |
76 | |
|
77 | |
public void deleteDump(String documentId) { |
78 | 0 | LOG.debug("deleting record form Extract Dump table"); |
79 | 0 | Criteria crit = new Criteria(); |
80 | 0 | crit.addEqualTo("docId", documentId); |
81 | 0 | getPersistenceBrokerTemplate().deleteByQuery(new QueryByCriteria(Note.class, crit)); |
82 | 0 | } |
83 | |
} |