001 /** 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018 package org.apache.oozie.executor.jpa; 019 020 import java.util.Date; 021 022 import javax.persistence.EntityManager; 023 import javax.persistence.Query; 024 025 import org.apache.oozie.CoordinatorActionBean; 026 import org.apache.oozie.ErrorCode; 027 import org.apache.oozie.util.ParamChecker; 028 029 /** 030 * Updates the action status, pending status, last modified time, push 031 * missingDependencies of CoordinatorAction and persists it. It executes SQL 032 * update query and return type is Void. 033 */ 034 public class CoordActionUpdatePushInputCheckJPAExecutor implements JPAExecutor<Void> { 035 036 private CoordinatorActionBean coordAction = null; 037 038 public CoordActionUpdatePushInputCheckJPAExecutor(CoordinatorActionBean coordAction) { 039 ParamChecker.notNull(coordAction, "coordAction"); 040 this.coordAction = coordAction; 041 } 042 043 /* 044 * (non-Javadoc) 045 * 046 * @see org.apache.oozie.executor.jpa.JPAExecutor#execute(javax.persistence. 047 * EntityManager) 048 */ 049 @Override 050 public Void execute(EntityManager em) throws JPAExecutorException { 051 try { 052 Query q = em.createNamedQuery("UPDATE_COORD_ACTION_FOR_PUSH_INPUTCHECK"); 053 q.setParameter("id", coordAction.getId()); 054 q.setParameter("status", coordAction.getStatus().toString()); 055 q.setParameter("lastModifiedTime", new Date()); 056 q.setParameter("actionXml", coordAction.getActionXml()); 057 q.setParameter("pushMissingDependencies", coordAction.getPushMissingDependencies()); 058 q.executeUpdate(); 059 // Since the return type is Void, we have to return null 060 return null; 061 } 062 catch (Exception e) { 063 throw new JPAExecutorException(ErrorCode.E0603, e); 064 } 065 } 066 067 /* 068 * (non-Javadoc) 069 * 070 * @see org.apache.oozie.executor.jpa.JPAExecutor#getName() 071 */ 072 @Override 073 public String getName() { 074 return "CoordActionUpdatePushInputCheckJPAExecutor"; 075 } 076 }