List of usage examples for javax.persistence EntityExistsException getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:com.clustercontrol.calendar.factory.ModifyCalendar.java
/** * /* w w w . ja va2 s . c o m*/ * * @param info * @param userName * @return * @throws HinemosUnknown * @throws CalendarDuplicate * @throws CalendarNotFound */ public void addCalendar(CalendarInfo info, String userName) throws HinemosUnknown, CalendarDuplicate, CalendarNotFound { JpaTransactionManager jtm = new JpaTransactionManager(); HinemosEntityManager em = jtm.getEntityManager(); //? try { //?? Long now = HinemosTime.currentTimeMillis(); // ?? jtm.checkEntityExists(CalendarInfo.class, info.getCalendarId()); info.setRegDate(now); info.setRegUser(userName); info.setUpdateDate(now); info.setUpdateUser(userName); em.persist(info); // for (int i = 0; i < info.getCalendarDetailList().size(); i++) { CalendarDetailInfo calDetailInfoEntity = info.getCalendarDetailList().get(i); calDetailInfoEntity.setCalendarId(info.getCalendarId()); calDetailInfoEntity.setOrderNo(i + 1); em.persist(calDetailInfoEntity); calDetailInfoEntity.relateToCalInfoEntity(info); } } catch (EntityExistsException e) { m_log.info("addCalendar() : " + e.getClass().getSimpleName() + ", " + e.getMessage()); throw new CalendarDuplicate(e.getMessage(), e); } catch (Exception e) { m_log.warn("addCalendar() : " + e.getClass().getSimpleName() + ", " + e.getMessage(), e); throw new HinemosUnknown(e.getMessage(), e); } }
From source file:com.clustercontrol.monitor.run.factory.ModifyMonitor.java
/** * ????// w ww .ja va2s . co m * <p> * <ol> * <li>?????????</li> * <li>??????????????{@link #addJudgementInfo()}</li> * <li>????????????????{@link #addCheckInfo()}</li> * <li>Quartz????/???</li> * </ol> * * @param user ?? * @return ???????</code> true </code> * @throws MonitorNotFound * @throws TriggerSchedulerException * @throws EntityExistsException * @throws HinemosUnknown * @throws InvalidRole * * @see com.clustercontrol.monitor.run.ejb.entity.MonitorInfoBean * @see #addJudgementInfo() * @see #addCheckInfo() * @see com.clustercontrol.monitor.run.factory.ModifySchedule#addSchedule(MonitorInfo, String, Calendar) */ protected boolean addMonitorInfo(String user) throws MonitorNotFound, TriggerSchedulerException, EntityExistsException, HinemosUnknown, InvalidRole { long now = HinemosTime.currentTimeMillis(); JpaTransactionManager jtm = new JpaTransactionManager(); try { // ?? jtm.checkEntityExists(MonitorInfo.class, m_monitorInfo.getMonitorId()); m_monitorInfo.setDelayTime(getDelayTime()); m_monitorInfo.setNotifyGroupId(NotifyGroupIdGenerator.generate(m_monitorInfo)); m_monitorInfo.setRegDate(now); m_monitorInfo.setRegUser(user); m_monitorInfo.setTriggerType(getTriggerType().name()); m_monitorInfo.setUpdateDate(now); m_monitorInfo.setUpdateUser(user); jtm.getEntityManager().persist(m_monitorInfo); // ? String notifyGroupId = NotifyGroupIdGenerator.generate(m_monitorInfo); m_monitorInfo.setNotifyGroupId(notifyGroupId); if (m_monitorInfo.getNotifyRelationList() != null && m_monitorInfo.getNotifyRelationList().size() > 0) { for (NotifyRelationInfo notifyRelationInfo : m_monitorInfo.getNotifyRelationList()) { notifyRelationInfo.setNotifyGroupId(notifyGroupId); } // new ModifyNotifyRelation().add(m_monitorInfo.getNotifyRelationList()); } // if (addJudgementInfo()) { // ?? if (addCheckInfo()) { // Quartz?(runInterval = 0 -> ???) if (m_monitorInfo.getRunInterval() > 0) { ModifySchedule quartz = new ModifySchedule(); quartz.updateSchedule(m_monitorInfo.getMonitorId()); } return true; } } return false; } catch (EntityExistsException e) { m_log.info("addMonitorInfo() : " + e.getClass().getSimpleName() + ", " + e.getMessage()); throw e; } catch (MonitorNotFound e) { throw e; } catch (HinemosUnknown e) { throw e; } catch (InvalidRole e) { throw e; } }
From source file:com.clustercontrol.jobmanagement.factory.ModifyJobKick.java
/** * DB??????// w w w.j a v a2 s . c om * ???????<BR> * * @param info * @param user ID * @param jobkickType * @throws HinemosUnknown * @throws JobKickDuplicate * * @see com.clustercontrol.jobmanagement.bean.QuartzConstant * @see com.clustercontrol.jobmanagement.bean.JobTriggerInfo * @see com.clustercontrol.jobmanagement.util.QuartzUtil#getQuartzManager() */ public void addJobKick(final JobKick info, String loginUser, Integer jobkickType) throws HinemosUnknown, JobKickDuplicate { m_log.debug("addJobKick() : id=" + info.getId() + ", jobId=" + info.getJobId() + ", jobkickType=" + jobkickType); JpaTransactionManager jtm = new JpaTransactionManager(); // long now = HinemosTime.currentTimeMillis(); // DB?? try { // ID??? String id = info.getId(); jtm.checkEntityExists(JobKickEntity.class, id); // JobKickEntity jobKickEntity = new JobKickEntity(info.getId()); jobKickEntity.setJobkickName(info.getName()); jobKickEntity.setJobkickType(jobkickType); jobKickEntity.setJobunitId(info.getJobunitId()); jobKickEntity.setJobId(info.getJobId()); // if (info.getJobRuntimeParamList() != null && info.getJobRuntimeParamList().size() > 0) { for (JobRuntimeParam jobRuntimeParam : info.getJobRuntimeParamList()) { JobRuntimeParamEntity jobRuntimeParamEntity = new JobRuntimeParamEntity(jobKickEntity, jobRuntimeParam.getParamId()); jobRuntimeParamEntity.setParamType(jobRuntimeParam.getParamType()); jobRuntimeParamEntity.setDefaultValue(jobRuntimeParam.getValue()); jobRuntimeParamEntity.setDescription(jobRuntimeParam.getDescription()); jobRuntimeParamEntity.setRequiredFlg(jobRuntimeParam.getRequiredFlg()); // if (jobRuntimeParam.getJobRuntimeParamDetailList() != null && jobRuntimeParam.getJobRuntimeParamDetailList().size() > 0) { int detailIdx = 0; for (JobRuntimeParamDetail jobRuntimeParamDetail : jobRuntimeParam .getJobRuntimeParamDetailList()) { JobRuntimeParamDetailEntity jobRuntimeParamDetailEntity = new JobRuntimeParamDetailEntity( jobRuntimeParamEntity, detailIdx); jobRuntimeParamDetailEntity.setParamValue(jobRuntimeParamDetail.getParamValue()); jobRuntimeParamDetailEntity.setDescription(jobRuntimeParamDetail.getDescription()); detailIdx++; } } } } if (jobkickType == JobKickConstant.TYPE_SCHEDULE) { // if (!(info instanceof JobSchedule)) { throw new HinemosUnknown("type error : " + info.getClass() + "!=JobSchedule"); } JobSchedule jobSchedule = (JobSchedule) info; if (!"".equals(jobSchedule.getCalendarId())) { jobKickEntity.setCalendarId(jobSchedule.getCalendarId()); } jobKickEntity.setValidFlg(info.isValid()); jobKickEntity.setScheduleType(jobSchedule.getScheduleType()); jobKickEntity.setWeek(jobSchedule.getWeek()); jobKickEntity.setHour(jobSchedule.getHour()); jobKickEntity.setMinute(jobSchedule.getMinute()); jobKickEntity.setFromXMinutes(jobSchedule.getFromXminutes()); jobKickEntity.setEveryXMinutes(jobSchedule.getEveryXminutes()); } else if (jobkickType == JobKickConstant.TYPE_FILECHECK) { // ? if (!(info instanceof JobFileCheck)) { throw new HinemosUnknown("type error : " + info.getClass() + "!=JobFileCheck"); } JobFileCheck jobFileCheck = (JobFileCheck) info; if (!"".equals(jobFileCheck.getCalendarId())) { jobKickEntity.setCalendarId(jobFileCheck.getCalendarId()); } jobKickEntity.setValidFlg(info.isValid()); jobKickEntity.setFacilityId(jobFileCheck.getFacilityId()); jobKickEntity.setFileName(jobFileCheck.getFileName()); jobKickEntity.setDirectory(jobFileCheck.getDirectory()); jobKickEntity.setEventType(jobFileCheck.getEventType()); jobKickEntity.setModifyType(jobFileCheck.getModifyType()); } else if (jobkickType == JobKickConstant.TYPE_MANUAL) { jobKickEntity.setCalendarId(null); jobKickEntity.setValidFlg(true); } jobKickEntity.setOwnerRoleId(info.getOwnerRoleId()); jobKickEntity.setRegDate(now); jobKickEntity.setUpdateDate(now); jobKickEntity.setRegUser(loginUser); jobKickEntity.setUpdateUser(loginUser); } catch (EntityExistsException e) { m_log.info("addJobKick() JobKickEntity.create() : " + e.getClass().getSimpleName() + ", " + e.getMessage()); throw new JobKickDuplicate(e.getMessage(), e); } catch (Exception e) { m_log.warn( "addJobKick() JobKickEntity.create() : " + e.getClass().getSimpleName() + ", " + e.getMessage(), e); throw new HinemosUnknown(e.getMessage(), e); } if (jobkickType == JobKickConstant.TYPE_SCHEDULE) { // ????? JobTriggerInfo triggerInfo = new JobTriggerInfo(); triggerInfo.setTrigger_type(JobTriggerTypeConstant.TYPE_SCHEDULE); triggerInfo.setTrigger_info(info.getName() + "(" + info.getId() + ")"); //JobDetail???? Serializable[] jdArgs = new Serializable[QuartzConstant.ARGS_NUM]; @SuppressWarnings("unchecked") Class<? extends Serializable>[] jdArgsType = new Class[QuartzConstant.ARGS_NUM]; //ID jdArgs[QuartzConstant.INDEX_JOBUNIT_ID] = info.getJobunitId(); jdArgsType[QuartzConstant.INDEX_JOBUNIT_ID] = String.class; //ID jdArgs[QuartzConstant.INDEX_JOB_ID] = info.getJobId(); jdArgsType[QuartzConstant.INDEX_JOB_ID] = String.class; //ID jdArgs[QuartzConstant.INDEX_CALENDAR_ID] = info.getCalendarId(); jdArgsType[QuartzConstant.INDEX_CALENDAR_ID] = String.class; // jdArgs[QuartzConstant.INDEX_TRIGGER_TYPE] = triggerInfo.getTrigger_type(); jdArgsType[QuartzConstant.INDEX_TRIGGER_TYPE] = Integer.class; // jdArgs[QuartzConstant.INDEX_TRIGGER_INFO] = triggerInfo.getTrigger_info(); jdArgsType[QuartzConstant.INDEX_TRIGGER_INFO] = String.class; //?? jdArgs[QuartzConstant.INDEX_TRIGGER_FILENAME] = triggerInfo.getFilename(); jdArgsType[QuartzConstant.INDEX_TRIGGER_FILENAME] = String.class; //?? jdArgs[QuartzConstant.INDEX_TRIGGER_DIRECTORY] = triggerInfo.getDirectory(); jdArgsType[QuartzConstant.INDEX_TRIGGER_DIRECTORY] = String.class; //???? jdArgs[QuartzConstant.INDEX_TRIGGER_JOB_WAIT_TIME] = triggerInfo.getJobWaitTime(); jdArgsType[QuartzConstant.INDEX_TRIGGER_JOB_WAIT_TIME] = Boolean.class; //????? jdArgs[QuartzConstant.INDEX_TRIGGER_JOB_WAIT_MINUTE] = triggerInfo.getJobWaitTime(); jdArgsType[QuartzConstant.INDEX_TRIGGER_JOB_WAIT_MINUTE] = Boolean.class; //???? jdArgs[QuartzConstant.INDEX_TRIGGER_JOB_COMMAND] = triggerInfo.getJobCommand(); jdArgsType[QuartzConstant.INDEX_TRIGGER_JOB_COMMAND] = Boolean.class; //???? jdArgs[QuartzConstant.INDEX_TRIGGER_JOB_COMMAND_TEXT] = triggerInfo.getJobCommandText(); jdArgsType[QuartzConstant.INDEX_TRIGGER_JOB_COMMAND_TEXT] = String.class; //ID jdArgs[QuartzConstant.INDEX_TRIGGER_JOBKICK_ID] = info.getId(); jdArgsType[QuartzConstant.INDEX_TRIGGER_JOBKICK_ID] = String.class; //Cron?? String cronString = QuartzUtil.getCronString(((JobSchedule) info).getScheduleType(), ((JobSchedule) info).getWeek(), ((JobSchedule) info).getHour(), ((JobSchedule) info).getMinute(), ((JobSchedule) info).getFromXminutes(), ((JobSchedule) info).getEveryXminutes()); m_log.trace("CronString =" + cronString); // try { if (info.isValid().booleanValue()) { SchedulerPlugin.scheduleCronJob(SchedulerType.DBMS, info.getId(), QuartzConstant.GROUP_NAME, HinemosTime.currentTimeMillis() + 15 * 1000, cronString, true, JobControllerBean.class.getName(), QuartzConstant.METHOD_NAME, jdArgsType, jdArgs); } else { SchedulerPlugin.deleteJob(SchedulerType.DBMS, info.getId(), QuartzConstant.GROUP_NAME); } } catch (HinemosUnknown e) { m_log.error(e); } } }
From source file:com.clustercontrol.plugin.factory.ModifyDbmsScheduler.java
/** * @param jobDetail/*from w w w. j a v a 2 s .c om*/ * @param trigger * @return * @throws EntityExistsException * @throws InvalidClassException */ public void addDbmsScheduler(JobDetail jobDetail, Trigger trigger) throws EntityExistsException, InvalidClassException { JpaTransactionManager jtm = null; try { jtm = new JpaTransactionManager(); jtm.begin(); // ?? jtm.checkEntityExists(DbmsSchedulerEntity.class, new DbmsSchedulerEntityPK(jobDetail.getName(), jobDetail.getGroup())); DbmsSchedulerEntity entity = new DbmsSchedulerEntity(jobDetail.getName(), jobDetail.getGroup()); setEntityInfo(entity, jobDetail, trigger); HinemosEntityManager em = jtm.getEntityManager(); em.persist(entity); jtm.commit(); } catch (EntityExistsException e) { m_log.error("DbmsSchedulerEntity entity is already exists. (name = " + jobDetail.getName() + ", group = " + jobDetail.getGroup() + ")"); if (jtm != null) jtm.rollback(); throw e; } catch (DatabaseException e) { m_log.error("addDbmsScheduler() DatabaseException: (name = " + jobDetail.getName() + ", group = " + jobDetail.getGroup() + ")"); if (jtm != null) jtm.rollback(); throw e; } catch (Exception e) { m_log.error("modifyDbmsScheduler() Exception. (name = " + jobDetail.getName() + ", group = " + jobDetail.getGroup() + ")"); m_log.error("modifyDbmsScheduler(): " + e.getClass().getSimpleName() + ", " + e.getMessage(), e); if (jtm != null) jtm.rollback(); throw e; } finally { if (jtm != null) jtm.close(); } }
From source file:com.clustercontrol.performance.session.PerformanceCollectMasterControllerBean.java
/** * ???//from w w w. j av a2 s. c o m * * @param data * @return ??????true * @throws HinemosUnknown */ public boolean addCollectCalcMaster(CollectorCalcMethodMstData data) throws HinemosUnknown { JpaTransactionManager jtm = null; // OperateCollectCalcMaster ope = new OperateCollectCalcMaster(); boolean ret = false; try { jtm = new JpaTransactionManager(); jtm.begin(); ret = ope.add(data); jtm.commit(); } catch (EntityExistsException e) { if (jtm != null) jtm.rollback(); throw new HinemosUnknown(e.getMessage(), e); } catch (Exception e) { m_log.warn("addCollectCalcMaster() : " + e.getClass().getSimpleName() + ", " + e.getMessage(), e); if (jtm != null) jtm.rollback(); throw new HinemosUnknown(e.getMessage(), e); } finally { if (jtm != null) jtm.close(); } return ret; }
From source file:com.clustercontrol.performance.session.PerformanceCollectMasterControllerBean.java
/** * ??????//from w w w . j a va 2 s .c o m * * @param data ??? * @return ??????true * @throws HinemosUnknown */ public boolean addCollectPollingMaster(CollectorPollingMstData data) throws HinemosUnknown { JpaTransactionManager jtm = null; // ??? OperateCollectPollingMaster ope = new OperateCollectPollingMaster(); boolean ret = false; try { jtm = new JpaTransactionManager(); jtm.begin(); ret = ope.add(data); jtm.commit(); } catch (EntityExistsException e) { if (jtm != null) jtm.rollback(); throw new HinemosUnknown(e.getMessage(), e); } catch (Exception e) { m_log.warn("addCollectPollingMaster() : " + e.getClass().getSimpleName() + ", " + e.getMessage(), e); if (jtm != null) jtm.rollback(); throw new HinemosUnknown(e.getMessage(), e); } finally { if (jtm != null) jtm.close(); } return ret; }
From source file:com.clustercontrol.performance.session.PerformanceCollectMasterControllerBean.java
/** * ????// w w w . ja v a 2 s . com * * @param data ? * @return ??????true * @throws HinemosUnknown */ public boolean addCollectCategoryMaster(CollectorCategoryMstData data) throws HinemosUnknown { JpaTransactionManager jtm = null; // ? OperateCollectCategoryMaster ope = new OperateCollectCategoryMaster(); boolean ret = false; try { jtm = new JpaTransactionManager(); jtm.begin(); ret = ope.add(data); jtm.commit(); } catch (EntityExistsException e) { if (jtm != null) jtm.rollback(); throw new HinemosUnknown(e.getMessage(), e); } catch (Exception e) { m_log.warn("addCollectCategoryMaster() : " + e.getClass().getSimpleName() + ", " + e.getMessage(), e); if (jtm != null) jtm.rollback(); throw new HinemosUnknown(e.getMessage(), e); } finally { if (jtm != null) jtm.close(); } return ret; }
From source file:com.clustercontrol.performance.session.PerformanceCollectMasterControllerBean.java
/** * ????// w w w .j av a2 s . co m * * @param data ? * @return ??????true * @throws HinemosUnknown */ public boolean addCollectItemCodeMaster(CollectorItemCodeMstData data) throws HinemosUnknown { JpaTransactionManager jtm = null; // ? OperateCollectItemCodeMaster ope = new OperateCollectItemCodeMaster(); boolean ret = false; try { jtm = new JpaTransactionManager(); jtm.begin(); ret = ope.add(data); jtm.commit(); } catch (EntityExistsException e) { if (jtm != null) jtm.rollback(); throw new HinemosUnknown(e.getMessage(), e); } catch (Exception e) { m_log.warn("addCollectItemCodeMaster() : " + e.getClass().getSimpleName() + ", " + e.getMessage(), e); if (jtm != null) jtm.rollback(); throw new HinemosUnknown(e.getMessage(), e); } finally { if (jtm != null) jtm.close(); } return ret; }
From source file:com.clustercontrol.performance.session.PerformanceCollectMasterControllerBean.java
/** * ?????//from w w w.j a v a 2 s. c o m * * @param data ?? * @return ??????true * @throws HinemosUnknown */ public boolean addCollectItemCalcMethodMaster(CollectorItemCalcMethodMstData data) throws HinemosUnknown { JpaTransactionManager jtm = null; // ?? OperateCollectItemCalcMethodMaster ope = new OperateCollectItemCalcMethodMaster(); boolean ret = false; try { jtm = new JpaTransactionManager(); jtm.begin(); ret = ope.add(data); jtm.commit(); } catch (EntityExistsException e) { if (jtm != null) jtm.rollback(); throw new HinemosUnknown(e.getMessage(), e); } catch (Exception e) { m_log.warn("addCollectItemCalcMethodMaster() : " + e.getClass().getSimpleName() + ", " + e.getMessage(), e); if (jtm != null) jtm.rollback(); throw new HinemosUnknown(e.getMessage(), e); } finally { if (jtm != null) jtm.close(); } return ret; }
From source file:com.clustercontrol.performance.session.PerformanceCollectMasterControllerBean.java
/** * ?????/*from w w w . j a v a 2 s . co m*/ * * @param data ?? * @return ??????true * @throws HinemosUnknown */ public boolean addCollectCategoryCollectMaster(CollectorCategoryCollectMstData data) throws HinemosUnknown { JpaTransactionManager jtm = null; //?? OperateCollectCategoryCollectMaster ope = new OperateCollectCategoryCollectMaster(); boolean ret = false; try { jtm = new JpaTransactionManager(); jtm.begin(); ret = ope.add(data); jtm.commit(); } catch (EntityExistsException e) { if (jtm != null) jtm.rollback(); throw new HinemosUnknown(e.getMessage(), e); } catch (Exception e) { m_log.warn( "addCollectCategoryCollectMaster() : " + e.getClass().getSimpleName() + ", " + e.getMessage(), e); if (jtm != null) jtm.rollback(); throw new HinemosUnknown(e.getMessage(), e); } finally { if (jtm != null) jtm.close(); } return ret; }