001 /** 002 * Copyright (c) 2010 Yahoo! Inc. All rights reserved. 003 * Licensed under the Apache License, Version 2.0 (the "License"); 004 * you may not use this file except in compliance with the License. 005 * You may obtain a copy of the License at 006 * 007 * http://www.apache.org/licenses/LICENSE-2.0 008 * 009 * Unless required by applicable law or agreed to in writing, software 010 * distributed under the License is distributed on an "AS IS" BASIS, 011 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 012 * See the License for the specific language governing permissions and 013 * limitations under the License. See accompanying LICENSE file. 014 */ 015 package org.apache.oozie.executor.jpa; 016 017 import java.util.List; 018 019 import javax.persistence.EntityManager; 020 import javax.persistence.Query; 021 022 import org.apache.oozie.ErrorCode; 023 import org.apache.oozie.WorkflowActionBean; 024 import org.apache.oozie.util.ParamChecker; 025 026 public class WorkflowActionRetryManualGetJPAExecutor implements JPAExecutor<List<WorkflowActionBean>> { 027 028 private String wfId = null; 029 List<WorkflowActionBean> actions; 030 031 /** 032 * This creates the WorkflowActionRetryManualGetJPAExecutor executor object. 033 * 034 * @param wfId 035 */ 036 public WorkflowActionRetryManualGetJPAExecutor(String wfId) { 037 ParamChecker.notNull(wfId, "wfId"); 038 this.wfId = wfId; 039 this.actions = null; 040 } 041 042 /* (non-Javadoc) 043 * @see org.apache.oozie.executor.jpa.JPAExecutor#execute(javax.persistence.EntityManager) 044 */ 045 @Override 046 public List<WorkflowActionBean> execute(EntityManager em) throws JPAExecutorException { 047 try { 048 Query q = em.createNamedQuery("GET_RETRY_MANUAL_ACTIONS"); 049 q.setParameter("wfId", wfId); 050 actions = q.getResultList(); 051 } 052 catch (IllegalStateException e) { 053 throw new JPAExecutorException(ErrorCode.E0601, e.getMessage(), e); 054 } 055 return actions; 056 } 057 058 /* (non-Javadoc) 059 * @see org.apache.oozie.executor.jpa.JPAExecutor#getName() 060 */ 061 @Override 062 public String getName() { 063 return "WorkflowActionRetryManualGetJPAExecutor"; 064 } 065 }