//
// This file is part of the OpenNMS(R) Application.
//
// OpenNMS(R) is Copyright (C) 2006 The OpenNMS Group, Inc. All rights
// reserved.
// OpenNMS(R) is a derivative work, containing both original code, included
// code and modified
// code that was published under the GNU General Public License. Copyrights
// for modified
// and included code are below.
//
// OpenNMS(R) is a registered trademark of The OpenNMS Group, Inc.
//
// Original code base Copyright (C) 1999-2001 Oculan Corp. All rights
// reserved.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// 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.
//
// For more information contact:
// OpenNMS Licensing <license@opennms.org>
// http://www.opennms.org/
// http://www.opennms.com/
//

package org.opennms.netmgt.model;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Transient;

/**
 * @author <a href="mailto:brozow@opennms.org">Mathew Brozowski</a>
 * @author <a href="mailto:david@opennms.org">David Hustace</a>
 */
@Entity
@Table(name = "location_monitors")
public class OnmsLocationMonitor {

    private Integer m_id;

    private String m_name;

    // needed for locating XML configured location definition and
    // creating m_locationDefintion.
    private String m_definitionName;

    private OnmsMonitoringLocationDefinition m_locationDefinition;

    private List<OnmsLocationSpecificStatus> m_mostRecentStatusChanges;

    @Id
    @SequenceGenerator(name = "opennmsSequence", sequenceName = "opennmsNxtId")
    @GeneratedValue(generator = "opennmsSequence")
    public Integer getId() {
        return m_id;
    }

    public void setId(Integer id) {
        m_id = id;
    }

    @Column(name = "name", length = 63, nullable = false)
    public String getName() {
        return m_name;
    }

    public void setName(String label) {
        m_name = label;
    }

    @Transient
    public OnmsMonitoringLocationDefinition getLocationDefinition() {
        return m_locationDefinition;
    }

    public void setLocationDefinition(
            OnmsMonitoringLocationDefinition locationDefinition) {
        m_locationDefinition = locationDefinition;
    }

    @Column(name = "definitionName", length = 31, nullable = false)
    public String getDefinitionName() {
        return m_definitionName;
    }

    public void setDefinitionName(String definitionName) {
        m_definitionName = definitionName;
    }

    // public List<OnmsLocationSpecificStatusChange>
    // getMostRecentStatusChanges() {
    // return m_mostRecentStatusChanges;
    // }
    //
    // public void setMostRecentStatusChanges(
    // List<OnmsLocationSpecificStatusChange> mostRecentStatusChanges) {
    //        m_mostRecentStatusChanges = mostRecentStatusChanges;
    //    }

}

@@ -1400,16 +1400,39 @@
 model;%0A%0A
+import java.util.Date;%0A
 import j
@@ -1513,16 +1513,88 @@
 Entity;%0A
+import javax.persistence.EnumType;%0Aimport javax.persistence.Enumerated;%0A
 import j
@@ -1731,16 +1731,90 @@
 .Table;%0A
+import javax.persistence.Temporal;%0Aimport javax.persistence.TemporalType;%0A
 import j
@@ -2064,59 +2064,316 @@
 r %7B%0A
-%0A    private Integer m_id;%0A%0A    private String m_na
+    %0A    public static enum MonitorStatus %7B%0A        NEW,%0A        REGISTERED,%0A        STARTED,%0A        STOPPED,%0A        UNRESPONSIVE,%0A        DELETED%0A    %7D%0A%0A    private Integer m_id;%0A%0A    private String m_name;%0A    %0A    private MonitorStatus m_status = MonitorStatus.NEW;%0A    %0A    private Date m_lastCheckInTi
 me;%0A
@@ -2586,81 +2586,8 @@
 n;%0A%0A
-    private List%3COnmsLocationSpecificStatus%3E m_mostRecentStatusChanges;%0A%0A
     
@@ -3587,89 +3587,126 @@
     
-// public List%3COnmsLocationSpecificStatusChange%3E%0A    // getMostRecentStatusChange
+@Enumerated(EnumType.STRING)%0A    @Column(name = %22status%22, length=13, nullable=false)%0A    public MonitorStatus getStatu
 s() 
@@ -3711,18 +3711,19 @@
 ) %7B%0A    
-//
+   
  return 
@@ -3728,55 +3728,26 @@
 n m_
-mostRecentStatusChanges;%0A    // %7D%0A    //
+status;%0A    %7D%0A
 %0A   
- //
  pub
@@ -3762,110 +3762,196 @@
  set
-MostRecentStatusChanges(%0A    // List%3COnmsLocationSpecificStatusChange%3E mostRecentStatusChanges
+Status(MonitorStatus status) %7B%0A        m_status = status;%0A    %7D%0A    %0A    @Temporal(TemporalType.TIMESTAMP)%0A    @Column(name = %22lastCheckInTime%22)%0A    public Date getLastCheckInTime(
 ) %7B%0A    
 //  
@@ -3950,82 +3950,162 @@
     
+   
-//
+ return m_lastCheckInTime;%0A    %7D%0A
     
+%0A
     
-m_mostRecentStatusChanges = mostRecentStatusChanges
+public void setLastCheckInTime(Date lastCheckInTime) %7B%0A        m_lastCheckInTime = lastCheckInTime
 ;%0A    
-//
+%7D%0A
     
-%7D%0A
 %0A%7D%0A

add new properties to locationMonitor for state tracking