Java tutorial
/** * Copyright (C) 2008 University of Pittsburgh * * * This file is part of Open EpiCenter * * Open EpiCenter 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 3 of the License, or * (at your option) any later version. * * Open EpiCenter 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 Open EpiCenter. If not, see <http://www.gnu.org/licenses/>. * * * */ package com.hmsinc.epicenter.model.surveillance; import static javax.persistence.GenerationType.AUTO; import java.util.HashSet; import java.util.Properties; import java.util.Set; import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.ManyToMany; import javax.persistence.Table; import org.apache.commons.lang.builder.ToStringBuilder; import org.hibernate.annotations.GenericGenerator; import org.hibernate.annotations.Parameter; import org.hibernate.annotations.Type; /** * A SurveillanceMethod defines an Algorithm and it's parameters. * * @author <a href="mailto:steve.kondik@hmsinc.com">Steve Kondik</a> * @version $Id: SurveillanceMethod.java 1607 2008-05-07 13:19:37Z steve.kondik $ */ @Entity @Table(name = "SURVEILLANCE_METHOD") public class SurveillanceMethod implements SurveillanceObject { /** * */ private static final long serialVersionUID = 8828934303378138102L; private Long id; private String name; private String description; private Properties parameters; private Set<SurveillanceTask> tasks = new HashSet<SurveillanceTask>(0); /* * (non-Javadoc) * * @see com.hmsinc.epicenter.model.surveillance.SurveillanceObject#getId() */ @Id @Column(name = "ID", nullable = false, insertable = true, updatable = true) @GenericGenerator(name = "generator", strategy = "native", parameters = { @Parameter(name = "sequence", value = "SEQ_SURVEILLANCE_METHOD") }) @GeneratedValue(strategy = AUTO, generator = "generator") public Long getId() { return this.id; } /* * (non-Javadoc) * * @see com.hmsinc.epicenter.model.surveillance.SurveillanceObject#setId(java.lang.Long) */ public void setId(Long id) { this.id = id; } /** * @return the name */ @Column(name = "NAME", unique = false, nullable = false, insertable = true, updatable = true, length = 80) public String getName() { return name; } /** * @param name * the name to set */ public void setName(String name) { this.name = name; } /** * @return the description */ @Column(name = "DESCRIPTION", unique = false, nullable = true, insertable = true, updatable = true, length = 400) public String getDescription() { return description; } /** * @param description * the description to set */ public void setDescription(String description) { this.description = description; } /** * @return the tasks */ @ManyToMany(cascade = { CascadeType.PERSIST, CascadeType.MERGE }, mappedBy = "methods", targetEntity = SurveillanceTask.class) public Set<SurveillanceTask> getTasks() { return tasks; } /** * @param tasks * the tasks to set */ public void setTasks(Set<SurveillanceTask> tasks) { this.tasks = tasks; } /** * @return the parameters */ @Column(name = "PARAMETERS", unique = false, nullable = true, insertable = true, updatable = true, length = 1000) @Type(type = "com.hmsinc.hibernate.types.PropertiesUserType") public Properties getParameters() { return parameters; } /** * @param parameters the parameters to set */ public void setParameters(Properties parameters) { this.parameters = parameters; } /* (non-Javadoc) * @see java.lang.Object#toString() */ @Override public String toString() { return new ToStringBuilder(this).append("id", id).append("name", name).append("description", description) .append("parameters", parameters).toString(); } }