Commit 4b72db56 authored by Matija Obreza's avatar Matija Obreza

Removed hibernate-search

parent c11fb1cf
......@@ -333,17 +333,6 @@
<artifactId>sitemesh</artifactId>
<version>3.0-alpha-2</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-search</artifactId>
<version>4.5.1.Final</version>
<exclusions>
<exclusion>
<artifactId>solr-analysis-extras</artifactId>
<groupId>org.apache.solr</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-jdbc</artifactId>
......@@ -431,10 +420,10 @@
<artifactId>spring-data-elasticsearch</artifactId>
<version>1.0.2.RELEASE</version>
<exclusions>
<exclusion>
<!-- <exclusion>
<artifactId>lucene-core</artifactId>
<groupId>org.apache.lucene</groupId>
</exclusion>
</exclusion> -->
<exclusion>
<artifactId>lucene-sandbox</artifactId>
<groupId>org.apache.lucene</groupId>
......@@ -725,6 +714,41 @@
<filtering>true</filtering>
</resource>
</resources>
<pluginManagement>
<plugins>
<!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
net.alchim31.maven
</groupId>
<artifactId>
yuicompressor-maven-plugin
</artifactId>
<versionRange>
[1.4.0,)
</versionRange>
<goals>
<goal>compress</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<version>0.9.1</version>
......
/**
* Copyright 2014 Global Crop Diversity Trust
*
* 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 org.genesys2.server.lucene.genesys;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.genesys2.server.model.genesys.Accession;
import org.genesys2.server.model.genesys.Taxonomy2;
import org.genesys2.server.model.impl.Country;
import org.genesys2.server.model.impl.FaoInstitute;
import org.hibernate.search.bridge.FieldBridge;
import org.hibernate.search.bridge.LuceneOptions;
public class AccessionBridge implements FieldBridge {
public static final Log LOG = LogFactory.getLog(AccessionBridge.class);
@Override
public void set(String name, Object value, Document document, LuceneOptions luceneOptions) {
// In this particular class the name of the new field was passed
// from the name field of the ClassBridge Annotation. This is not
// a requirement. It just works that way in this instance. The
// actual name could be supplied by hard coding it below.
final Accession accession = (Accession) value;
final StringDocument sd = new StringDocument();
sd.append(accession.getAccessionName());
sd.append(accession.getAcquisitionSource());
// sb.append(accession.getGenus());
sd.append(accession.getInstituteCode());
sd.append(accession.getOrigin());
final Country countryOfOrigin = accession.getCountryOfOrigin();
if (countryOfOrigin != null) {
sd.append(countryOfOrigin.getName());
}
final Taxonomy2 taxonomy = accession.getTaxonomy();
if (taxonomy != null) {
sd.append(taxonomy.getTaxonName());
}
final FaoInstitute institute = accession.getInstitute();
if (institute != null) {
sd.append(institute.getAcronym());
sd.append(institute.getFullName());
if (institute.getCountry() != null) {
sd.append(institute.getCountry().getName());
}
}
// AllAccnames accNames = accession.getAccessionNames();
// if (accNames != null) {
// sd.append(accNames.getOtherIds());
// sd.append(accNames.getAccNames());
// }
//
// AllAcqBreeding accBreeding = accession.getAccessionBreeding();
// if (accBreeding != null) {
// sd.append(accBreeding.getPedigree());
// sd.append(accBreeding.getBreederCode());
// }
//
// AllAcqCollect accCollect = accession.getAccessionCollection();
// if (accCollect != null) {
// sd.append(accCollect.getCollectSite());
// sd.append(accCollect.getCollectorsNumb());
// sd.append(accCollect.getCollectingInstitute());
// }
//
// AllAcqExchange accExchange = accession.getAccessionExchange();
// if (accExchange != null) {
// sd.append(accExchange.getDonorInstitute());
// sd.append(accExchange.getAccNumbDonor());
// }
//
LOG.debug("IDX." + name + " = " + sd.toString());
final Field field = new Field(name, sd.toString(), luceneOptions.getStore(), luceneOptions.getIndex(), luceneOptions.getTermVector());
field.setBoost(luceneOptions.getBoost());
document.add(field);
}
}
/**
* Copyright 2014 Global Crop Diversity Trust
*
* 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 org.genesys2.server.lucene.genesys;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.genesys2.server.model.impl.FaoInstitute;
import org.hibernate.search.bridge.FieldBridge;
import org.hibernate.search.bridge.LuceneOptions;
public class FaoInstituteBridge implements FieldBridge {
public static final Log LOG = LogFactory.getLog(FaoInstituteBridge.class);
@Override
public void set(String name, Object value, Document document, LuceneOptions luceneOptions) {
// In this particular class the name of the new field was passed
// from the name field of the ClassBridge Annotation. This is not
// a requirement. It just works that way in this instance. The
// actual name could be supplied by hard coding it below.
final FaoInstitute institute = (FaoInstitute) value;
final StringDocument sd = new StringDocument();
sd.append(institute.getAcronym());
sd.append(institute.getCode());
sd.append(institute.getFullName());
if (institute.getCountry() != null) {
sd.append(institute.getCountry().getName());
}
LOG.debug("IDX." + name + " = " + sd.toString());
final Field field = new Field(name, sd.toString(), luceneOptions.getStore(), luceneOptions.getIndex(), luceneOptions.getTermVector());
field.setBoost(luceneOptions.getBoost());
if (institute.getAccessionCount() > 0) {
field.setBoost(2 * luceneOptions.getBoost());
}
document.add(field);
}
}
/**
* Copyright 2014 Global Crop Diversity Trust
*
* 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 org.genesys2.server.lucene.genesys;
import org.apache.commons.lang.StringUtils;
public class StringDocument {
private final StringBuffer sb = new StringBuffer();
public StringDocument append(String value) {
if (StringUtils.isNotBlank(value)) {
sb.append(value);
sb.append(" ");
}
return this;
}
@Override
public String toString() {
return sb.toString();
}
}
......@@ -22,8 +22,6 @@ import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import org.hibernate.search.annotations.DocumentId;
@SuppressWarnings("serial")
@MappedSuperclass
public abstract class BusinessModel implements EntityId, HibernateModel {
......@@ -33,7 +31,6 @@ public abstract class BusinessModel implements EntityId, HibernateModel {
*/
private static final long serialVersionUID = 1059280831389222969L;
@Id
@DocumentId
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id", unique = true, nullable = false, length = 20)
protected Long id;
......
......@@ -30,20 +30,15 @@ import javax.persistence.ManyToOne;
import javax.persistence.OrderBy;
import javax.persistence.Table;
import org.genesys2.server.lucene.genesys.AccessionBridge;
import org.genesys2.server.model.VersionedAuditedModel;
import org.genesys2.server.model.impl.Country;
import org.genesys2.server.model.impl.FaoInstitute;
import org.hibernate.search.annotations.ClassBridge;
import org.hibernate.search.annotations.Indexed;
@Entity
@Table(name = "accession")
// TODO FIXME Reenable
// @Table(name = "accession", uniqueConstraints = {
// @UniqueConstraint(columnNames = { "instCode", "acceNumb", "taxGenus" }) })
@Indexed
@ClassBridge(name = "body", impl = AccessionBridge.class)
public class Accession extends VersionedAuditedModel {
private static final long serialVersionUID = -7630113633534038876L;
......
......@@ -25,16 +25,12 @@ import javax.persistence.Table;
import javax.persistence.Version;
import org.genesys2.server.model.BusinessModel;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.Store;
/**
* Accession "alias"
*/
@Entity
@Table(name = "accessionalias")
@Indexed
public class AccessionAlias extends BusinessModel {
/**
......@@ -78,7 +74,6 @@ public class AccessionAlias extends BusinessModel {
private Accession accession;
@Column(name = "name", length = 150)
@Field(name = "title", store = Store.NO)
private String name;
@Column(length = 10)
......
......@@ -26,16 +26,12 @@ import javax.persistence.Table;
import javax.persistence.Version;
import org.genesys2.server.model.BusinessModel;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.Store;
/**
* Accession "alias"
*/
@Entity
@Table(name = "accessionremark")
@Indexed
public class AccessionRemark extends BusinessModel {
@Version
......@@ -47,7 +43,6 @@ public class AccessionRemark extends BusinessModel {
@Lob
@Column(name = "remark")
@Field(name = "body", store = Store.NO)
private String remark;
@Column(length = 30)
......
......@@ -29,13 +29,9 @@ import org.genesys2.server.model.AclAwareModel;
import org.genesys2.server.model.VersionedAuditedModel;
import org.genesys2.server.model.impl.GeoReferencedEntity;
import org.hibernate.annotations.Type;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.Store;
@Entity
@Table(name = "metadata")
@Indexed
public class Metadata extends VersionedAuditedModel implements AclAwareModel, GeoReferencedEntity {
/**
......@@ -47,7 +43,6 @@ public class Metadata extends VersionedAuditedModel implements AclAwareModel, Ge
private String instituteCode;
@Column(nullable = false, length = 128)
@Field(name = "title", store = Store.NO)
private String title;
@Column(name = "startDate", length = 10)
......@@ -57,7 +52,6 @@ public class Metadata extends VersionedAuditedModel implements AclAwareModel, Ge
private String EDate;
@Column(length = 128)
@Field(store = Store.NO)
private String location;
private Double longitude;
......@@ -66,12 +60,10 @@ public class Metadata extends VersionedAuditedModel implements AclAwareModel, Ge
@Lob
@Type(type = "org.hibernate.type.TextType")
@Field(store = Store.NO)
private String citation;
@Lob
@Type(type = "org.hibernate.type.TextType")
@Field(name = "body", store = Store.NO)
private String description;
@Column(length = 36, unique = true, nullable = false)
......
......@@ -24,14 +24,10 @@ import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import org.genesys2.server.model.BusinessModel;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.Store;
@Entity
// Add index on genus, genus+species
@Table(name = "taxonomy", uniqueConstraints = { @UniqueConstraint(columnNames = { "genus", "species" }) })
@Indexed
public class Taxonomy extends BusinessModel {
private static final long serialVersionUID = 8881324404490162933L;
......@@ -43,7 +39,6 @@ public class Taxonomy extends BusinessModel {
private String species;
@Column(name = "taxonName", nullable = false, length = 200)
@Field(name = "title", store = Store.NO)
private String taxonName;
public String getGenus() {
......
......@@ -32,7 +32,6 @@ import org.apache.commons.lang3.StringUtils;
import org.genesys2.server.model.GlobalVersionedAuditedModel;
import org.genesys2.server.model.impl.CropTaxonomy;
import org.hibernate.annotations.Type;
import org.hibernate.search.annotations.Indexed;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
......@@ -40,7 +39,6 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
@Entity
// Add index on all fields
@Table(name = "taxonomy2", uniqueConstraints = { @UniqueConstraint(columnNames = { "genus", "species", "spAuthor", "subtaxa", "subtAuthor" }) })
@Indexed
@JsonIgnoreProperties(ignoreUnknown=true)
public class Taxonomy2 extends GlobalVersionedAuditedModel {
......
......@@ -27,24 +27,18 @@ import javax.persistence.TemporalType;
import org.genesys2.server.model.AuditedModel;
import org.hibernate.annotations.Type;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.Store;
@Entity
@Table(name = "activitypost")
@Indexed
public class ActivityPost extends AuditedModel {
private static final long serialVersionUID = 8690395020204070378L;
@Column(nullable = false, length = 500)
@Field(name = "title", store = Store.NO)
private String title;
@Lob
@Type(type = "org.hibernate.type.TextType")
@Field(name = "body", store = Store.NO)
private String body;
@Temporal(TemporalType.TIMESTAMP)
......
......@@ -29,13 +29,9 @@ import javax.persistence.TemporalType;
import org.genesys2.server.model.AuditedModel;
import org.hibernate.annotations.Type;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.Store;
@Entity
@Table(name = "article")
@Indexed
public class Article extends AuditedModel {
private static final long serialVersionUID = 8690395020204070378L;
......@@ -58,13 +54,11 @@ public class Article extends AuditedModel {
@Lob
@Type(type = "org.hibernate.type.TextType")
@Field(name = "title", store = Store.NO)
private String title;
@Lob
@Type(type = "org.hibernate.type.TextType")
@Column(length = 100000)
@Field(name = "body", store = Store.NO)
private String body;
@Temporal(TemporalType.TIMESTAMP)
......
......@@ -34,9 +34,6 @@ import javax.persistence.Transient;
import org.genesys2.server.model.BusinessModel;
import org.genesys2.server.servlet.controller.rest.serialization.CountrySerializer;
import org.hibernate.annotations.Type;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.Store;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
......@@ -44,15 +41,12 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize;
@Entity
@Table(name = "country")
// TODO Fix indexer by i18n names!
@Indexed
@JsonSerialize(using = CountrySerializer.class)
public class Country extends BusinessModel {
private static final long serialVersionUID = -1688723909298769804L;
@Column(nullable = false, unique = true, length = 3)
@Field(name = "title")
private String code3;
@Column(unique = false, length = 2)
......@@ -71,7 +65,6 @@ public class Country extends BusinessModel {
*/
@Lob
@Type(type = "org.hibernate.type.TextType")
@Field(name = "body", store = Store.NO)
private String nameL;
@Lob
......
......@@ -38,9 +38,6 @@ import org.apache.commons.logging.LogFactory;
import org.genesys2.server.model.AclAwareModel;
import org.genesys2.server.model.GlobalVersionedAuditedModel;
import org.hibernate.annotations.Type;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.Store;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.JsonNode;
......@@ -48,7 +45,6 @@ import com.fasterxml.jackson.databind.ObjectMapper;
@Entity
@Table(name = "crop")
@Indexed
public class Crop extends GlobalVersionedAuditedModel implements AclAwareModel {
private static final long serialVersionUID = -2686341831839109257L;
......@@ -62,12 +58,10 @@ public class Crop extends GlobalVersionedAuditedModel implements AclAwareModel {
private String shortName;
@Column(nullable = false, length = 200)
@Field(name = "title", store = Store.NO)
private String name;
@Lob
@Type(type = "org.hibernate.type.TextType")
@Field(name = "body", store = Store.NO)
private String description;
@Lob
......
......@@ -22,6 +22,7 @@ import java.util.Map;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Index;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.MapKey;
......@@ -29,26 +30,16 @@ import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import org.genesys2.server.lucene.genesys.FaoInstituteBridge;
import org.genesys2.server.model.AclAwareModel;
import org.genesys2.server.model.BusinessModel;
import org.genesys2.server.model.EntityId;
import org.genesys2.server.servlet.controller.rest.serialization.FaoInstituteSerializer;
import org.hibernate.annotations.Index;
import org.hibernate.search.annotations.Boost;
import org.hibernate.search.annotations.ClassBridge;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.Store;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
@Entity
@Table(name = "faoinstitute", uniqueConstraints = @UniqueConstraint(columnNames = { "code" }))
@org.hibernate.annotations.Table(appliesTo = "faoinstitute", indexes = { @Index(columnNames = { "code" }, name = "code_FAOINSTITUTE") })
@Indexed
@ClassBridge(name = "body", boost = @Boost(1.3f), impl = FaoInstituteBridge.class)
@Table(name = "faoinstitute", uniqueConstraints = @UniqueConstraint(columnNames = { "code" }), indexes = { @Index(columnList = "code", name = "code_FAOINSTITUTE") })
@JsonSerialize(using = FaoInstituteSerializer.class)
public class FaoInstitute extends BusinessModel implements GeoReferencedEntity, AclAwareModel, EntityId {
......@@ -58,11 +49,9 @@ public class FaoInstitute extends BusinessModel implements GeoReferencedEntity,
private static final long serialVersionUID = -8773002513838748431L;
@Column(unique = true, nullable = false, length = 10)
@Field(store = Store.NO)
private String code;
@Column(length = 300)
@Field(name = "title", store = Store.YES)
private String fullName;
@Column(length = 11)
......
......@@ -31,26 +31,20 @@ import javax.persistence.Table;
import org.genesys2.server.model.AuditedModel;
import org.hibernate.annotations.Type;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.Store;
import com.fasterxml.jackson.annotation.JsonIgnore;
@Entity
@Table(name = "organization")
@Indexed
public class Organization extends AuditedModel {
private static final long serialVersionUID = 2710908645431936666L;
@Column(nullable = false, length = 150)
@Field(name = "title", store = Store.NO)
private String slug;