package org.helios.apmrouter.catalog.domain; // Generated Oct 27, 2012 1:30:47 PM by Hibernate Tools 3.6.0 import java.util.Date; import javax.management.Notification; import org.helios.apmrouter.catalog.jdbc.h2.AbstractTrigger; import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; /** * Host generated by hbm2java */ //@Document public class Host implements java.io.Serializable, DomainObject { @SerializedName("hostId") //@Indexed(unique=true) //@Id private Integer hostId; @SerializedName("name") private String name; @SerializedName("domain") private String domain; @SerializedName("ip") private String ip; @Expose(serialize=false) private String fqn; @Expose(serialize=false) private Date firstConnected; @Expose(serialize=false) private Date lastConnected; @Expose(serialize=false) private int agentsConnected; @SerializedName("conn") private Date connected; public Host() { } public Host(String name, String domain, Date firstConnected, Date lastConnected, int agentsConnected) { this.name = name; this.domain = domain; this.firstConnected = firstConnected; this.lastConnected = lastConnected; this.agentsConnected = agentsConnected; } public Host(String name, String domain, String ip, String fqn, Date firstConnected, Date lastConnected, int agentsConnected, Date connected) { this.name = name; this.domain = domain; this.ip = ip; this.fqn = fqn; this.firstConnected = firstConnected; this.lastConnected = lastConnected; this.agentsConnected = agentsConnected; this.connected = connected; } /** * Creates a new Host from a new host notification * @param notif The new host notification emitted from the H2 catalog DB */ public Host(Notification notif) { if(notif==null) throw new IllegalArgumentException("The passed notification was null", new Throwable()); if(!AbstractTrigger.NEW_HOST.equals(notif.getType())) throw new IllegalArgumentException("The passed notification was not the right type [" + notif.getType() + "] for a host", new Throwable()); Object[] rowData = (Object[])notif.getUserData(); if(rowData==null) { throw new IllegalArgumentException("The passed host notification has a null UserData", new Throwable()); } if(rowData.length!=9) { throw new IllegalArgumentException("Unexpected rowData length [" + rowData.length + "] for host notification has a null UserData", new Throwable()); } this.hostId = (Integer)rowData[0]; this.name = (String)rowData[1]; this.domain = (String)rowData[2]; this.ip = (String)rowData[3]; this.fqn = (String)rowData[4]; this.firstConnected = new Date(((java.sql.Timestamp)rowData[5]).getTime()); this.lastConnected = new Date(((java.sql.Timestamp)rowData[6]).getTime());; this.agentsConnected = (Integer)rowData[7]; this.connected = rowData[8]==null ? null : new Date(((java.sql.Timestamp)rowData[8]).getTime());; } public Integer getHostId() { return this.hostId; } public void setHostId(Integer hostId) { this.hostId = hostId; } public String getName() { return this.name; } public void setName(String name) { this.name = name; } public String getIp() { return this.ip; } public void setIp(String ip) { this.ip = ip; } public String getFqn() { return this.fqn; } public void setFqn(String fqn) { this.fqn = fqn; } public Date getFirstConnected() { return this.firstConnected; } public void setFirstConnected(Date firstConnected) { this.firstConnected = firstConnected; } public Date getLastConnected() { return this.lastConnected; } public void setLastConnected(Date lastConnected) { this.lastConnected = lastConnected; } public Date getConnected() { return this.connected; } public void setConnected(Date connected) { this.connected = connected; } /** * {@inheritDoc} * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder builder = new StringBuilder(); builder.append("Host [hostId="); builder.append(hostId); builder.append(", name="); builder.append(name); builder.append(", domain="); builder.append(domain); builder.append(", ip="); builder.append(ip); builder.append(", fqn="); builder.append(fqn); builder.append(", connected="); builder.append(connected); builder.append("]"); return builder.toString(); } /** * Returns the domain * @return the domain */ public String getDomain() { return domain; } /** * Sets the domain * @param domain the domain to set */ public void setDomain(String domain) { this.domain = domain; } /** * Returns * @return the agentsConnected */ public int getAgentsConnected() { return agentsConnected; } /** * Sets * @param agentsConnected the agentsConnected to set */ public void setAgentsConnected(int agentsConnected) { this.agentsConnected = agentsConnected; } }