001    package org.apache.oozie.executor.jpa;
002    
003    import javax.persistence.EntityManager;
004    import org.apache.oozie.CoordinatorJobBean;
005    import org.apache.oozie.ErrorCode;
006    import org.apache.oozie.util.ParamChecker;
007    
008    /**
009     * Update the CoordinatorJob into a Bean and persist it.
010     */
011    public class CoordJobUpdateJPAExecutor implements JPAExecutor<Void> {
012    
013        private CoordinatorJobBean coordJob = null;
014    
015        /**
016         * @param coordJob
017         */
018        public CoordJobUpdateJPAExecutor(CoordinatorJobBean coordJob) {
019            ParamChecker.notNull(coordJob, "CoordinatorJobBean");
020            this.coordJob = coordJob;
021        }
022    
023        /*
024         * (non-Javadoc)
025         *
026         * @see org.apache.oozie.executor.jpa.JPAExecutor#execute(javax.persistence.
027         * EntityManager)
028         */
029        @Override
030        public Void execute(EntityManager em) throws JPAExecutorException {
031            try {
032                em.merge(coordJob);
033                return null;
034            }
035            catch (Exception e) {
036                throw new JPAExecutorException(ErrorCode.E0603, e);
037            }
038        }
039    
040        /*
041         * (non-Javadoc)
042         *
043         * @see org.apache.oozie.executor.jpa.JPAExecutor#getName()
044         */
045        @Override
046        public String getName() {
047            return "CoordinatorUpdateJobJPAExecutor";
048        }
049    
050    }