/*******************************************************************************
* Copyright 2013
* Ubiquitous Knowledge Processing (UKP) Lab
* Technische Universität Darmstadt
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/
package de.tudarmstadt.ukp.csniper.webapp.evaluation.model;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Lob;
@Entity
public class Query
implements Serializable
{
private static final long serialVersionUID = -5613376177142495552L;
@Id
@GeneratedValue
private long id;
@Column(nullable = false)
private String engine;
@Column(nullable = false)
@Lob
private String query;
@Column(nullable = false)
private String collectionId;
@Column(nullable = false)
private String type;
private String userId;
private String comment;
public Query()
{
// For JPA
}
public Query(String aEngine, String aQuery, String aCollectionId, String aType)
{
this(aEngine, aQuery, aCollectionId, aType, null);
}
public Query(String aEngine, String aQuery, String aCollectionId, String aType, String aUserId)
{
super();
engine = aEngine;
query = aQuery;
collectionId = aCollectionId;
type = aType;
userId = aUserId;
}
public long getId()
{
return id;
}
public String getEngine()
{
return engine;
}
public void setEngine(String aEngine)
{
engine = aEngine;
}
public String getQuery()
{
return query;
}
public void setQuery(String aQuery)
{
query = aQuery;
}
public String getCollectionId()
{
return collectionId;
}
public void setCollectionId(String aCollectionId)
{
collectionId = aCollectionId;
}
public String getType()
{
return type;
}
public void setType(String aType)
{
type = aType;
}
public String getUser()
{
return userId;
}
public void setUser(String aUserId)
{
userId = aUserId;
}
public String getComment()
{
return comment;
}
public void setComment(String aComment)
{
comment = aComment;
}
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + ((collectionId == null) ? 0 : collectionId.hashCode());
result = prime * result + ((comment == null) ? 0 : comment.hashCode());
result = prime * result + ((engine == null) ? 0 : engine.hashCode());
result = prime * result + ((query == null) ? 0 : query.hashCode());
result = prime * result + ((type == null) ? 0 : type.hashCode());
result = prime * result + ((userId == null) ? 0 : userId.hashCode());
return result;
}
@Override
public boolean equals(Object obj)
{
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
Query other = (Query) obj;
if (collectionId == null) {
if (other.collectionId != null) {
return false;
}
}
else if (!collectionId.equals(other.collectionId)) {
return false;
}
// if (comment == null) {
// if (other.comment != null) {
// return false;
// }
// }
// else if (!comment.equals(other.comment)) {
// return false;
// }
if (engine == null) {
if (other.engine != null) {
return false;
}
}
else if (!engine.equals(other.engine)) {
return false;
}
if (query == null) {
if (other.query != null) {
return false;
}
}
else if (!query.equals(other.query)) {
return false;
}
if (userId == null) {
if (other.userId != null) {
return false;
}
}
else if (!userId.equals(other.userId)) {
return false;
}
if (type == null) {
if (other.type != null) {
return false;
}
}
else if (!type.equals(other.type)) {
return false;
}
return true;
}
@Override
public String toString()
{
return "[Query|id=" + id + ", query=" + query + ", collectionId=" + collectionId
+ ", type=" + type + "]";
}
}