Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright 2005-2013 The Kuali Foundation Licensed under the Educational Community License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.opensource.org/licenses/ecl2.php Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 
 package org.kuali.rice.kew.actiontaken.dao.impl;
 
 
 import java.util.List;


OJB implementation of the org.kuali.rice.kew.actiontaken.dao.ActionTakenDAO.

Author(s):
Kuali Rice Team (rice.collab@kuali.org)
 
 public class ActionTakenDAOOjbImpl extends PersistenceBrokerDaoSupport implements ActionTakenDAO {
 
     private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(ActionTakenDAOOjbImpl.class);
 
     public ActionTakenValue load(String id) {
         .debug("Loading Action Taken for the given id " + id);
         Criteria crit = new Criteria();
         crit.addEqualTo("actionTakenId"id);
     }
 
     public void deleteActionTaken(ActionTakenValue actionTaken) {
         .debug("deleting ActionTaken " + actionTaken.getActionTakenId());
         this.getPersistenceBrokerTemplate().delete(actionTaken);
     }
 
     public ActionTakenValue findByActionTakenId(String actionTakenId) {
         .debug("finding Action Taken by actionTakenId " + actionTakenId);
         Criteria crit = new Criteria();
         crit.addEqualTo("actionTakenId"actionTakenId);
         crit.addEqualTo("currentIndicator".);
     }
 
     public Collection<ActionTakenValuefindByDocIdAndAction(String documentIdString action) {
         .debug("finding Action Taken by documentId " + documentId + " and action " + action);
         Criteria crit = new Criteria();
         crit.addEqualTo("documentId"documentId);
         crit.addEqualTo("actionTaken"action);
         crit.addEqualTo("currentIndicator".);
     }
 
     public Collection<ActionTakenValuefindByDocumentId(String documentId) {
         .debug("finding Action Takens by documentId " + documentId);
         Criteria crit = new Criteria();
         crit.addEqualTo("documentId"documentId);
         crit.addEqualTo("currentIndicator".);
 
         QueryByCriteria qByCrit = new QueryByCriteria(ActionTakenValue.classcrit);
 
        qByCrit.addOrderByAscending("actionDate");
 
     }
 
     public List<ActionTakenValuefindByDocumentIdWorkflowId(String documentIdString principalId) {
         .debug("finding Action Takens by documentId " + documentId + " and principalId" + principalId);
         Criteria crit = new Criteria();
         crit.addEqualTo("documentId"documentId);
         crit.addEqualTo("principalId"principalId);
         crit.addEqualTo("currentIndicator".);
     }
 
     public List findByDocumentIdIgnoreCurrentInd(String documentId) {
         .debug("finding ActionsTaken ignoring currentInd by documentId:" + documentId);
        Criteria crit = new Criteria();
        crit.addEqualTo("documentId"documentId);
        QueryByCriteria qByCrit = new QueryByCriteria(ActionTakenValue.classcrit);
       qByCrit.addOrderByAscending("actionDate");
        return (Listthis.getPersistenceBrokerTemplate().getCollectionByQuery(qByCrit);
    }
    public void saveActionTaken(ActionTakenValue actionTaken) {
        .debug("saving ActionTaken");
        checkNull(actionTaken.getDocumentId(), "Document ID");
        checkNull(actionTaken.getActionTaken(), "action taken code");
        checkNull(actionTaken.getDocVersion(), "doc version");
        checkNull(actionTaken.getPrincipal(), "user principalId");
        if (actionTaken.getActionDate() == null) {
            actionTaken.setActionDate(new Timestamp(System.currentTimeMillis()));
        }
        if (actionTaken.getCurrentIndicator() == null) {
            actionTaken.setCurrentIndicator(.);
        }
        .debug("saving ActionTaken: routeHeader " + actionTaken.getDocumentId() +
                ", actionTaken " + actionTaken.getActionTaken() + ", principalId " + actionTaken.getPrincipalId());
        this.getPersistenceBrokerTemplate().store(actionTaken);
    }
    //TODO perhaps runtime isn't the best here, maybe a dao runtime exception
    private void checkNull(Object valueString valueNamethrows RuntimeException {
        if (value == null) {
            throw new RuntimeException("Null value for " + valueName);
        }
    }
    public void deleteByDocumentId(String documentId){
	    Criteria crit = new Criteria();
	    crit.addEqualTo("documentId"documentId);
    }
    public boolean hasUserTakenAction(String principalIdString documentId) {
    	Criteria crit = new Criteria();
	    crit.addEqualTo("documentId"documentId);
	    crit.addEqualTo("principalId"principalId);
	    crit.addEqualTo("currentIndicator".);
        int count = getPersistenceBrokerTemplate().getCount(new QueryByCriteria(ActionTakenValue.classcrit));
        return count > 0;
    }
    private static final String LAST_ACTION_TAKEN_DATE_QUERY =
            "select max(ACTN_DT) from KREW_ACTN_TKN_T where DOC_HDR_ID=? and ACTN_CD=?";
    public Timestamp getLastActionTakenDate(final String documentIdfinal ActionType actionType) {
            public Object doInPersistenceBroker(PersistenceBroker broker) {
                PreparedStatement statement = null;
                ResultSet resultSet = null;
                try {
                    Connection connection = broker.serviceConnectionManager().getConnection();
                    statement = connection.prepareStatement();
                    statement.setString(1, documentId);
                    statement.setString(2, actionType.getCode());
                    resultSet = statement.executeQuery();
                    if (!resultSet.next()) {
                        return null;
                    } else {
                        return resultSet.getTimestamp(1);
                    }
                } catch (Exception e) {
                    throw new WorkflowRuntimeException("Error determining Last Action Taken Date."e);
                } finally {
                    if (statement != null) {
                        try {
                            statement.close();
                        } catch (SQLException e) {
                        }
                    }
                    if (resultSet != null) {
                        try {
                            resultSet.close();
                        } catch (SQLException e) {
                        }
                    }
                }
            }
        });
    }
New to GrepCode? Check out our FAQ X