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.actionrequest.dao.impl;
 
 import java.util.List;
 
 
This is a description of what this class does - sgibson don't forget to fill this in.

Author(s):
Kuali Rice Team (rice.collab@kuali.org)
 
 public class ActionRequestDAOJpaImpl implements ActionRequestDAO {
     
     @PersistenceContext(name = "kew-unit")
     private EntityManager entityManager;

    

Returns:
the entityManager
 
 		return this.;
 	}

Parameters:
entityManager the entityManager to set
 
 	public void setEntityManager(EntityManager entityManager) {
 		this. = entityManager;
 	}
 
 	public void delete(String actionRequestId) {
         ActionRequestValue actionRequestValue = (ActionRequestValue.find(ActionRequestValue.classactionRequestId);
         .remove(actionRequestValue);
     }
 
     public void deleteByDocumentId(String documentId) {
         // FIXME should be jpa bulk update?
         Query query = .createNamedQuery("ActionRequestValue.FindByDocumentId");
         query.setParameter("documentId"documentId);
         List<ActionRequestValueactionRequestValues = (List<ActionRequestValue>) query.getSingleResult();
         for(ActionRequestValue arv : actionRequestValues) {
             .remove(arv);
         }
     }
 
     public boolean doesDocumentHaveUserRequest(String principalIdString documentId) {
         Query query = .createNamedQuery("ActionRequestValue.GetUserRequestCount");
         query.setParameter("principalId"principalId);
         query.setParameter("documentId"documentId);
         query.setParameter("recipientTypeCd"..getCode());
         query.setParameter("currentIndicator".);
         
         return ((Long)query.getSingleResult()) > 0;
     }
 
     public List<?> findActivatedByGroup(Group group) {
         
         Query query = .createNamedQuery("ActionRequestValue.FindActivatedByGroup");
         query.setParameter("groupId"group.getId());
         query.setParameter("currentIndicator".);
         query.setParameter("status"..getCode());
         
         return query.getResultList();
     }
 
     public List<ActionRequestValuefindAllByDocId(String documentId) {
         Query query = .createNamedQuery("ActionRequestValue.FindAllByDocId");
         query.setParameter("documentId"documentId);
         query.setParameter("currentIndicator".);
        
        return query.getResultList();
    }
    public List<ActionRequestValuefindAllPendingByDocId(String documentId) {
        Query query = .createNamedQuery("ActionRequestValue.FindAllPendingByDocId");
        query.setParameter("documentId"documentId);
        query.setParameter("currentIndicator".);
        query.setParameter("actionRequestStatus1"..getCode());
        query.setParameter("actionRequestStatus2"..getCode());
        
        return query.getResultList();
    }
    @SuppressWarnings("unchecked")
    public List<ActionRequestValuefindAllRootByDocId(String documentId) {
        Query query = .createNamedQuery("ActionRequestValue.FindAllRootByDocId");
        query.setParameter("documentId"documentId);
        query.setParameter("currentIndicator".);
        
        return (List<ActionRequestValue>) query.getResultList();
    }
        Query query = .createNamedQuery("ActionRequestValue.FindByDocumentId");
        query.setParameter("documentId"documentId);
        
        return query.getResultList();
    }
    @SuppressWarnings("unchecked")
    public List<ActionRequestValuefindByStatusAndDocId(String statusCdString documentId) {
        Query query = .createNamedQuery("ActionRequestValue.FindByStatusAndDocId");
        query.setParameter("documentId"documentId);
        query.setParameter("status"statusCd);
        query.setParameter("currentIndicator".);
        
        return (List<ActionRequestValue>)query.getResultList();
    }
    public List<ActionRequestValuefindPendingByActionRequestedAndDocId(String actionRequestedCdString documentId) {
        Query query = .createNamedQuery("ActionRequestValue.FindPendingByActionRequestedAndDocId");
        query.setParameter("documentId"documentId);
        query.setParameter("currentIndicator".);
        query.setParameter("actionRequested"actionRequestedCd);
        query.setParameter("actionRequestStatus1"..getCode());
        query.setParameter("actionRequestStatus2"..getCode());
        
        return query.getResultList();
    }
    public List<ActionRequestValuefindPendingByDocIdAtOrBelowRouteLevel(String documentIdInteger routeLevel) {
        Query query = .createNamedQuery("ActionRequestValue.FindPendingByDocIdAtOrBelowRouteLevel");
        query.setParameter("documentId"documentId);
        query.setParameter("currentIndicator".);
        query.setParameter("routeLevel"routeLevel);
        query.setParameter("status"..getCode());
        
        return query.getResultList();
    }
    public List<ActionRequestValuefindPendingByResponsibilityIds(Collection responsibilityIds) {
        if (responsibilityIds == null || responsibilityIds.size() == 0)
            return Collections.emptyList();
        Query query = .createNamedQuery("ActionRequestValue.FindPendingByDocIdAtOrBelowRouteLevel");
        query.setParameter("responsibilityIds"responsibilityIds);
        
        return query.getResultList();
    }
        Query query = .createNamedQuery("ActionRequestValue.FindPendingRootRequestsByDocIdAtOrBelowRouteLevel");
        query.setParameter("documentId"documentId);
        query.setParameter("currentIndicator".);
        query.setParameter("status"..getCode());
        query.setParameter("routeLevel"routeLevel);
        
        return query.getResultList();
    }
        Query query = .createNamedQuery("ActionRequestValue.FindPendingRootRequestsByDocIdAtRouteLevel");
        query.setParameter("documentId"documentId);
        query.setParameter("currentIndicator".);
        query.setParameter("status"..getCode());
        query.setParameter("routeLevel"routeLevel);
        
        return query.getResultList();
    }
    public List<ActionRequestValuefindPendingRootRequestsByDocIdAtRouteNode(String documentIdString nodeInstanceId) {
        Query query = .createNamedQuery("ActionRequestValue.FindPendingRootRequestsByDocIdAtRouteNode");
        query.setParameter("documentId"documentId);
        query.setParameter("currentIndicator".);
        query.setParameter("routeNodeInstanceId"nodeInstanceId);
        query.setParameter("actionRequestStatus1"..getCode());
        query.setParameter("actionRequestStatus2"..getCode());
        
        return query.getResultList();
    }
        Query query = .createNamedQuery("ActionRequestValue.FindPendingRootRequestsByDocumentType");
        query.setParameter("documentTypeId"documentTypeId);
        query.setParameter("currentIndicator".);
        query.setParameter("actionRequestStatus1"..getCode());
        query.setParameter("actionRequestStatus2"..getCode());
        
        return query.getResultList();
    }
    public List<ActionRequestValuefindRootRequestsByDocIdAtRouteNode(String documentIdString nodeInstanceId) {
        Query query = .createNamedQuery("ActionRequestValue.FindRootRequestsByDocIdAtRouteNode");
        query.setParameter("documentId"documentId);
        query.setParameter("currentIndicator".);
        query.setParameter("routeNodeInstanceId"nodeInstanceId);
        
        return query.getResultList();
    }
    public ActionRequestValue getActionRequestByActionRequestId(String actionRequestId) {
        return .find(ActionRequestValue.classactionRequestId);
    }
    @SuppressWarnings("unchecked")
    public List<StringgetRequestGroupIds(String documentId) {
        Query query = .createNamedQuery("ActionRequestValue.GetRequestGroupIds");
        query.setParameter("documentId"documentId);
        query.setParameter("currentIndicator".);
        query.setParameter("recipientTypeCd"..getCode());
        
        return query.getResultList();
    }
    public void saveActionRequest(ActionRequestValue actionRequest) {
        if ( actionRequest.getAnnotation() != null && actionRequest.getAnnotation().length() > 2000 ) {
        	actionRequest.setAnnotation( StringUtils.abbreviate(actionRequest.getAnnotation(), 2000) );
        }
    	if(actionRequest.getActionRequestId() == null) {
        	loadDefaultValues(actionRequest);
        	.persist(actionRequest);
        }else{
            OrmUtils.merge(actionRequest);
        }
    }
    private void loadDefaultValues(ActionRequestValue actionRequest) {
        checkNull(actionRequest.getActionRequested(), "action requested");
        checkNull(actionRequest.getResponsibilityId(), "responsibility ID");
        checkNull(actionRequest.getRouteLevel(), "route level");
        checkNull(actionRequest.getDocVersion(), "doc version");
        if (actionRequest.getForceAction() == null) {
            actionRequest.setForceAction(.);
        }
        if (actionRequest.getStatus() == null) {
            actionRequest.setStatus(..getCode());
        }
        if (actionRequest.getPriority() == null) {
            actionRequest.setPriority(.);
        }
        if (actionRequest.getCurrentIndicator() == null) {
            actionRequest.setCurrentIndicator(true);
        }
        actionRequest.setCreateDate(new Timestamp(System.currentTimeMillis()));
    }
    //TODO Runtime might not be the right thing to do here...
    private void checkNull(Serializable valueString valueNamethrows RuntimeException {
        if (value == null) {
            throw new RuntimeException("Null value for " + valueName);
        }
    }
    
		Query query = .createNamedQuery("ActionRequestValue.FindByStatusAndGroupId");
        query.setParameter("status"..getCode());
        query.setParameter("currentIndicator".);
        query.setParameter("groupId"groupId);
        
        return query.getResultList();
	}
    @Override
        throw new UnsupportedOperationException("not yet implemented");
    }
New to GrepCode? Check out our FAQ X