/* * The MIT License * * Copyright 2014 Miroslav Cupak (mirocupak@gmail.com). * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ package com.dnastack.bob.persistence.entity; import com.dnastack.bob.persistence.enumerated.Chromosome; import com.dnastack.bob.persistence.enumerated.Reference; import java.util.Objects; import javax.persistence.Entity; import javax.persistence.EnumType; import javax.persistence.Enumerated; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.ManyToOne; import javax.validation.constraints.Max; import javax.validation.constraints.Min; import javax.validation.constraints.NotNull; import javax.validation.constraints.Pattern; /** * Generalized beacon query representation. * * @author Miroslav Cupak (mirocupak@gmail.com) * @version 1.0 */ @Entity public class Query implements BasicEntity { private static final long serialVersionUID = -4843153796455403263L; @Id @GeneratedValue(strategy = GenerationType.SEQUENCE) private Long id; @NotNull @Enumerated(EnumType.STRING) private Chromosome chromosome; @NotNull @Min(0L) @Max(300000000L) private Long position; @NotNull @Pattern(regexp = "([D,I])|([A,C,T,G]+)") private String allele; @Enumerated(EnumType.STRING) private Reference reference; @ManyToOne private Dataset dataSet; public Query() { } public Query(Chromosome chromosome, Long position, String allele, Reference reference) { this.chromosome = chromosome; this.position = position; this.allele = allele; this.reference = reference; } public Long getId() { return id; } public void setId(Long id) { this.id = id; } public Chromosome getChromosome() { return chromosome; } public void setChromosome(Chromosome chromosome) { this.chromosome = chromosome; } public Long getPosition() { return position; } public void setPosition(Long position) { this.position = position; } public String getAllele() { return allele; } public void setAllele(String allele) { this.allele = allele; } public Reference getReference() { return reference; } public void setReference(Reference reference) { this.reference = reference; } @Override public int hashCode() { int hash = 3; hash = 89 * hash + Objects.hashCode(this.chromosome); hash = 89 * hash + Objects.hashCode(this.position); hash = 89 * hash + Objects.hashCode(this.allele); hash = 89 * hash + Objects.hashCode(this.reference); return hash; } @Override public boolean equals(Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final Query other = (Query) obj; if (this.chromosome != other.chromosome) { return false; } if (!Objects.equals(this.position, other.position)) { return false; } if (!Objects.equals(this.allele, other.allele)) { return false; } if (this.reference != other.reference) { return false; } return true; } @Override public String toString() { return "Query{" + "chromosome=" + chromosome + ", position=" + position + ", allele=" + allele + ", reference=" + reference + '}'; } }