/** * NOTE: This copyright does *not* cover user programs that use HQ * program services by normal system calls through the application * program interfaces provided as part of the Hyperic Plug-in Development * Kit or the Hyperic Client Development Kit - this is merely considered * normal use of the program, and does *not* fall under the heading of * "derived work". * * Copyright (C) [2004-2010], VMware, Inc. * This file is part of HQ. * * HQ is free software; you can redistribute it and/or modify * it under the terms version 2 of the GNU General Public License as * published by the Free Software Foundation. This program is distributed * in the hope that it will be useful, but WITHOUT ANY WARRANTY; without * even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * USA. * */ package org.hyperic.hq.control.server.session; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import org.hyperic.hibernate.PersistedObject; import org.hyperic.hq.scheduler.ScheduleValue; public class ControlSchedule extends PersistedObject { // Fields private Integer entityType; private Integer entityId; private String subject; private byte[] scheduleValueBytes; private long nextFireTime; private String triggerName; private String jobName; private String jobOrderData; private String action; // Constructors /** * default constructor */ public ControlSchedule() { } // Property accessors public Integer getEntityType() { return this.entityType; } protected void setEntityType(Integer entityType) { this.entityType = entityType; } public Integer getEntityId() { return this.entityId; } protected void setEntityId(Integer entityId) { this.entityId = entityId; } public String getSubject() { return this.subject; } protected void setSubject(String subject) { this.subject = subject; } public byte[] getScheduleValueBytes() { return this.scheduleValueBytes; } protected void setScheduleValueBytes(byte[] scheduleValueBytes) { this.scheduleValueBytes = scheduleValueBytes; } public long getNextFireTime() { return this.nextFireTime; } protected void setNextFireTime(long nextFireTime) { this.nextFireTime = nextFireTime; } public String getTriggerName() { return this.triggerName; } protected void setTriggerName(String triggerName) { this.triggerName = triggerName; } public String getJobName() { return this.jobName; } protected void setJobName(String jobName) { this.jobName = jobName; } public String getJobOrderData() { return this.jobOrderData; } protected void setJobOrderData(String jobOrderData) { this.jobOrderData = jobOrderData; } public String getAction() { return this.action; } protected void setAction(String action) { this.action = action; } protected void setScheduleValue(ScheduleValue schedule) throws IOException { ByteArrayOutputStream os = new ByteArrayOutputStream(); ObjectOutputStream o = new ObjectOutputStream(os); o.writeObject(schedule); o.flush(); os.close(); setScheduleValueBytes(os.toByteArray()); } public ScheduleValue getScheduleValue() throws IOException, ClassNotFoundException { ByteArrayInputStream is = new ByteArrayInputStream(getScheduleValueBytes()); ObjectInputStream o = new ObjectInputStream(is); ScheduleValue schedule = (ScheduleValue)o.readObject(); return schedule; } public boolean equals(Object obj) { return (obj instanceof ControlSchedule) && super.equals(obj); } }