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 ActionTakenDAOJpaImpl implements ActionTakenDAO {
 
 	@PersistenceContext(unitName="kew-unit")
 
     private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(ActionTakenDAOJpaImpl.class);
 
     public ActionTakenValue load(String id) {
         .debug("Loading Action Taken for the given id " + id);
         return .find(ActionTakenValue.classid);
     }
 
     public void deleteActionTaken(ActionTakenValue actionTaken) {
         .debug("deleting ActionTaken " + actionTaken.getActionTakenId());
         .remove(.find(ActionTakenValue.classactionTaken.getActionTakenId()));
     }
 
     public ActionTakenValue findByActionTakenId(String actionTakenId) {
         .debug("finding Action Taken by actionTakenId " + actionTakenId);
         Criteria crit = new Criteria(ActionTakenValue.class.getName());
         crit.eq("actionTakenId"actionTakenId);
         crit.eq("currentIndicator".);
         return (ActionTakenValuenew QueryByCriteria(crit).toQuery().getSingleResult();
     }
 
     public Collection<ActionTakenValuefindByDocIdAndAction(String documentIdString action) {
         .debug("finding Action Taken by documentId " + documentId + " and action " + action);
         Criteria crit = new Criteria(ActionTakenValue.class.getName());
         crit.eq("documentId"documentId);
         crit.eq("actionTaken"action);
         crit.eq("currentIndicator".);
         return (Collection<ActionTakenValue>) new QueryByCriteria(crit).toQuery().getResultList();
     }
 
     public Collection<ActionTakenValuefindByDocumentId(String documentId) {
         .debug("finding Action Takens by documentId " + documentId);
         Criteria crit = new Criteria(ActionTakenValue.class.getName());
         crit.eq("documentId"documentId);
         crit.eq("currentIndicator".);
         crit.orderBy("actionDate"true);
         return (Collection<ActionTakenValue>) new QueryByCriteria(crit).toQuery().getResultList();
     }
 
     public List<ActionTakenValuefindByDocumentIdWorkflowId(String documentIdString workflowId) {
         .debug("finding Action Takens by documentId " + documentId + " and workflowId" + workflowId);
         Criteria crit = new Criteria(ActionTakenValue.class.getName());
         crit.eq("documentId"documentId);
         crit.eq("principalId"workflowId);
         crit.eq("currentIndicator".);
         return (List<ActionTakenValue>) new QueryByCriteria(crit).toQuery().getResultList();
     }
 
     public List findByDocumentIdIgnoreCurrentInd(String documentId) {
         .debug("finding ActionsTaken ignoring currentInd by documentId:" + documentId);
         Criteria crit = new Criteria(ActionTakenValue.class.getName());
         crit.eq("documentId"documentId);
         return (Listnew QueryByCriteria(crit);
     }
 
     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.getPrincipalId(), "principal ID");
        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());
        if(actionTaken.getActionTakenId()==null){
        	.persist(actionTaken);
        }else{
        	OrmUtils.merge(actionTaken);
        }
    }
    //TODO perhaps runtime isn't the best here, maybe a dao runtime exception
    private void checkNull(Serializable valueString valueNamethrows RuntimeException {
        if (value == null) {
            throw new RuntimeException("Null value for " + valueName);
        }
    }
    public void deleteByDocumentId(String documentId){
	    Criteria crit = new Criteria(ActionRequestValue.class.getName());
	    crit.eq("documentId"documentId);
	    .remove(actionRequestValue);
    }
    public boolean hasUserTakenAction(String workflowIdString documentId) {
    	Criteria crit = new Criteria(ActionTakenValue.class.getName());
	    crit.eq("documentId"documentId);
	    crit.eq("principalId"workflowId);
	    crit.eq("currentIndicator".);
	    long count = (Longnew QueryByCriteria(crit).toCountQuery().getSingleResult();
        return count > 0;
    }
    @Override
    public Timestamp getLastActionTakenDate(String documentIdActionType actionType) {
        // TODO - fix this!
        throw new UnsupportedOperationException("The JPA version of this method still needs to be implemented!");
    }
    public EntityManager getEntityManager() {
        return this.;
    }
    public void setEntityManager(EntityManager entityManager) {
        this. = entityManager;
    }
New to GrepCode? Check out our FAQ X