001    /*
002     * Copyright 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    /*
017     * Created on Aug 19, 2004
018     *
019     */
020    package org.kuali.kfs.pdp.dataaccess.impl;
021    
022    import java.sql.Timestamp;
023    import java.util.Calendar;
024    import java.util.Date;
025    import java.util.GregorianCalendar;
026    import java.util.List;
027    
028    import org.apache.ojb.broker.query.Criteria;
029    import org.apache.ojb.broker.query.QueryByCriteria;
030    import org.kuali.kfs.pdp.PdpPropertyConstants;
031    import org.kuali.kfs.pdp.businessobject.PaymentProcess;
032    import org.kuali.kfs.pdp.dataaccess.ProcessDao;
033    import org.kuali.rice.kim.bo.Person;
034    import org.kuali.rice.kns.dao.impl.PlatformAwareDaoBaseOjb;
035    import org.kuali.rice.kim.service.PersonService;
036    import org.kuali.rice.kns.util.KualiInteger;
037    
038    
039    /**
040     * 
041     */
042    public class ProcessDaoOjb extends PlatformAwareDaoBaseOjb implements ProcessDao {
043        private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(ProcessDaoOjb.class);
044    
045        private org.kuali.rice.kim.service.PersonService userService;
046    
047        public void setPersonService(org.kuali.rice.kim.service.PersonService u) {
048            userService = u;
049        }
050    
051        public ProcessDaoOjb() {
052            super();
053        }
054    
055        public PaymentProcess createProcessToRun(Integer procId) {
056            LOG.debug("createProcess() started");
057    
058            Date d = new Date();
059            Timestamp now = new Timestamp(d.getTime());
060    
061            PaymentProcess p = new PaymentProcess();
062            p.setProcessTimestamp(now);
063            p.setId(new KualiInteger(procId));
064            p.setExtractedInd(false);
065            
066            getPersistenceBrokerTemplate().store(p);
067            
068            return p;
069        }
070        
071        public List<PaymentProcess> getAllExtractsToRun() {
072            Criteria c = new Criteria();
073            c.addEqualTo(PdpPropertyConstants.PaymentProcess.EXTRACTED_IND, false);
074            c.addEqualTo(PdpPropertyConstants.PaymentProcess.FORMATTED_IND, true);
075            return (List<PaymentProcess>) getPersistenceBrokerTemplate().getCollectionByQuery(new QueryByCriteria(PaymentProcess.class, c));
076        }
077        
078        public void setExtractProcessAsComplete(PaymentProcess paymentProcess) {
079            paymentProcess.setExtractedInd(true);
080            getPersistenceBrokerTemplate().store(paymentProcess);
081        }
082        
083        public PaymentProcess get(Integer procId) {
084            LOG.debug("get() started");
085    
086            Criteria c = new Criteria();
087            c.addEqualTo("id", procId);
088    
089            PaymentProcess p = (PaymentProcess) getPersistenceBrokerTemplate().getObjectByQuery(new QueryByCriteria(PaymentProcess.class, c));
090            if (p != null) {
091                
092                return p;
093            }
094            else {
095                return null;
096            }
097        }
098    
099    }
100