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