/** * * geo-platform * Rich webgis framework * http://geo-platform.org * ==================================================================== * * Copyright (C) 2008-2017 geoSDI Group (CNR IMAA - Potenza - ITALY). * * 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 3 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, see http://www.gnu.org/licenses/ * * ==================================================================== * * Linking this library statically or dynamically with other modules is * making a combined work based on this library. Thus, the terms and * conditions of the GNU General Public License cover the whole combination. * * As a special exception, the copyright holders of this library give you permission * to link this library with independent modules to produce an executable, regardless * of the license terms of these independent modules, and to copy and distribute * the resulting executable under terms of your choice, provided that you also meet, * for each linked independent module, the terms and conditions of the license of * that module. An independent module is a module which is not derived from or * based on this library. If you modify this library, you may extend this exception * to your version of the library, but you are not obligated to do so. If you do not * wish to do so, delete this exception statement from your version. */ package org.geosdi.geoplatform.persistence.search.demo.model; import java.io.Serializable; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.SequenceGenerator; import org.apache.lucene.analysis.core.LowerCaseFilterFactory; import org.apache.lucene.analysis.snowball.SnowballPorterFilterFactory; import org.apache.lucene.analysis.standard.StandardTokenizerFactory; import org.hibernate.annotations.NaturalId; import org.hibernate.search.annotations.Analyze; import org.hibernate.search.annotations.Analyzer; import org.hibernate.search.annotations.AnalyzerDef; import org.hibernate.search.annotations.DocumentId; import org.hibernate.search.annotations.Field; import org.hibernate.search.annotations.Indexed; import org.hibernate.search.annotations.Parameter; import org.hibernate.search.annotations.Store; import org.hibernate.search.annotations.TokenFilterDef; import org.hibernate.search.annotations.TokenizerDef; /** * * @author Giuseppe La Scaleia - CNR IMAA geoSDI Group * @email giuseppe.lascaleia@geosdi.org */ @Entity @AnalyzerDef(name = "customanalyzer", tokenizer = @TokenizerDef(factory = StandardTokenizerFactory.class), filters = { @TokenFilterDef(factory = LowerCaseFilterFactory.class), @TokenFilterDef(factory = SnowballPorterFilterFactory.class, params = { @Parameter(name = "language", value = "English") }) }) @Indexed(index = "CarSearchIndex") public class CarSearch implements Serializable { private static final long serialVersionUID = -492671838741301712L; // @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "CAR_SEQ") @SequenceGenerator(name = "CAR_SEQ", sequenceName = "CAR_SEQ") @DocumentId private Long id; // @NaturalId private String plate; // @Column(name = "model") private String model; /** * @return the id */ public Long getId() { return id; } /** * @param id the id to set */ public void setId(Long id) { this.id = id; } /** * @return the plate */ public String getPlate() { return plate; } /** * @param plate the plate to set */ public void setPlate(String plate) { this.plate = plate; } /** * @return the model */ @Field(name = "model", store = Store.YES, analyze = Analyze.YES) @Analyzer(definition = "customanalyzer") public String getModel() { return model; } /** * @param model the model to set */ public void setModel(String model) { this.model = model; } @Override public int hashCode() { int hash = 7; hash = 71 * hash + (this.id != null ? this.id.hashCode() : 0); hash = 71 * hash + (this.plate != null ? this.plate.hashCode() : 0); return hash; } @Override public boolean equals(Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final CarSearch other = (CarSearch) obj; if (this.id != other.id && (this.id == null || !this.id.equals(other.id))) { return false; } if ((this.plate == null) ? (other.plate != null) : !this.plate.equals( other.plate)) { return false; } return true; } @Override public String toString() { return "CarSearch{ " + "id = " + id + ", plate = " + plate + ", model = " + model + '}'; } }