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

Removed hibernate-search

parent c11fb1cf
...@@ -333,17 +333,6 @@ ...@@ -333,17 +333,6 @@
<artifactId>sitemesh</artifactId> <artifactId>sitemesh</artifactId>
<version>3.0-alpha-2</version> <version>3.0-alpha-2</version>
</dependency> </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> <dependency>
<groupId>org.apache.tomcat</groupId> <groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-jdbc</artifactId> <artifactId>tomcat-jdbc</artifactId>
...@@ -431,10 +420,10 @@ ...@@ -431,10 +420,10 @@
<artifactId>spring-data-elasticsearch</artifactId> <artifactId>spring-data-elasticsearch</artifactId>
<version>1.0.2.RELEASE</version> <version>1.0.2.RELEASE</version>
<exclusions> <exclusions>
<exclusion> <!-- <exclusion>
<artifactId>lucene-core</artifactId> <artifactId>lucene-core</artifactId>
<groupId>org.apache.lucene</groupId> <groupId>org.apache.lucene</groupId>
</exclusion> </exclusion> -->
<exclusion> <exclusion>
<artifactId>lucene-sandbox</artifactId> <artifactId>lucene-sandbox</artifactId>
<groupId>org.apache.lucene</groupId> <groupId>org.apache.lucene</groupId>
...@@ -725,6 +714,41 @@ ...@@ -725,6 +714,41 @@
<filtering>true</filtering> <filtering>true</filtering>
</resource> </resource>
</resources> </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> </build>
<version>0.9.1</version> <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; ...@@ -22,8 +22,6 @@ import javax.persistence.GenerationType;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.MappedSuperclass; import javax.persistence.MappedSuperclass;
import org.hibernate.search.annotations.DocumentId;
@SuppressWarnings("serial") @SuppressWarnings("serial")
@MappedSuperclass @MappedSuperclass
public abstract class BusinessModel implements EntityId, HibernateModel { public abstract class BusinessModel implements EntityId, HibernateModel {
...@@ -33,7 +31,6 @@ public abstract class BusinessModel implements EntityId, HibernateModel { ...@@ -33,7 +31,6 @@ public abstract class BusinessModel implements EntityId, HibernateModel {
*/ */
private static final long serialVersionUID = 1059280831389222969L; private static final long serialVersionUID = 1059280831389222969L;
@Id @Id
@DocumentId
@GeneratedValue(strategy = GenerationType.AUTO) @GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id", unique = true, nullable = false, length = 20) @Column(name = "id", unique = true, nullable = false, length = 20)
protected Long id; protected Long id;
......
...@@ -30,20 +30,15 @@ import javax.persistence.ManyToOne; ...@@ -30,20 +30,15 @@ import javax.persistence.ManyToOne;
import javax.persistence.OrderBy; import javax.persistence.OrderBy;
import javax.persistence.Table; import javax.persistence.Table;
import org.genesys2.server.lucene.genesys.AccessionBridge;
import org.genesys2.server.model.VersionedAuditedModel; import org.genesys2.server.model.VersionedAuditedModel;
import org.genesys2.server.model.impl.Country; import org.genesys2.server.model.impl.Country;
import org.genesys2.server.model.impl.FaoInstitute; import org.genesys2.server.model.impl.FaoInstitute;
import org.hibernate.search.annotations.ClassBridge;
import org.hibernate.search.annotations.Indexed;
@Entity @Entity
@Table(name = "accession") @Table(name = "accession")
// TODO FIXME Reenable // TODO FIXME Reenable
// @Table(name = "accession", uniqueConstraints = { // @Table(name = "accession", uniqueConstraints = {
// @UniqueConstraint(columnNames = { "instCode", "acceNumb", "taxGenus" }) }) // @UniqueConstraint(columnNames = { "instCode", "acceNumb", "taxGenus" }) })
@Indexed
@ClassBridge(name = "body", impl = AccessionBridge.class)
public class Accession extends VersionedAuditedModel { public class Accession extends VersionedAuditedModel {
private static final long serialVersionUID = -7630113633534038876L; private static final long serialVersionUID = -7630113633534038876L;
......
...@@ -25,16 +25,12 @@ import javax.persistence.Table; ...@@ -25,16 +25,12 @@ import javax.persistence.Table;
import javax.persistence.Version; import javax.persistence.Version;
import org.genesys2.server.model.BusinessModel; 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" * Accession "alias"
*/ */
@Entity @Entity
@Table(name = "accessionalias") @Table(name = "accessionalias")
@Indexed
public class AccessionAlias extends BusinessModel { public class AccessionAlias extends BusinessModel {
/** /**
...@@ -78,7 +74,6 @@ public class AccessionAlias extends BusinessModel { ...@@ -78,7 +74,6 @@ public class AccessionAlias extends BusinessModel {
private Accession accession; private Accession accession;
@Column(name = "name", length = 150) @Column(name = "name", length = 150)
@Field(name = "title", store = Store.NO)
private String name; private String name;
@Column(length = 10) @Column(length = 10)
......
...@@ -26,16 +26,12 @@ import javax.persistence.Table; ...@@ -26,16 +26,12 @@ import javax.persistence.Table;
import javax.persistence.Version; import javax.persistence.Version;
import org.genesys2.server.model.BusinessModel; 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" * Accession "alias"
*/ */
@Entity @Entity
@Table(name = "accessionremark") @Table(name = "accessionremark")
@Indexed
public class AccessionRemark extends BusinessModel { public class AccessionRemark extends BusinessModel {
@Version @Version
...@@ -47,7 +43,6 @@ public class AccessionRemark extends BusinessModel { ...@@ -47,7 +43,6 @@ public class AccessionRemark extends BusinessModel {
@Lob @Lob
@Column(name = "remark") @Column(name = "remark")
@Field(name = "body", store = Store.NO)
private String remark; private String remark;
@Column(length = 30) @Column(length = 30)
......
...@@ -29,13 +29,9 @@ import org.genesys2.server.model.AclAwareModel; ...@@ -29,13 +29,9 @@ import org.genesys2.server.model.AclAwareModel;
import org.genesys2.server.model.VersionedAuditedModel; import org.genesys2.server.model.VersionedAuditedModel;
import org.genesys2.server.model.impl.GeoReferencedEntity; import org.genesys2.server.model.impl.GeoReferencedEntity;
import org.hibernate.annotations.Type; import org.hibernate.annotations.Type;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.Store;
@Entity @Entity
@Table(name = "metadata") @Table(name = "metadata")
@Indexed
public class Metadata extends VersionedAuditedModel implements AclAwareModel, GeoReferencedEntity { public class Metadata extends VersionedAuditedModel implements AclAwareModel, GeoReferencedEntity {
/** /**
...@@ -47,7 +43,6 @@ public class Metadata extends VersionedAuditedModel implements AclAwareModel, Ge ...@@ -47,7 +43,6 @@ public class Metadata extends VersionedAuditedModel implements AclAwareModel, Ge
private String instituteCode; private String instituteCode;
@Column(nullable = false, length = 128) @Column(nullable = false, length = 128)
@Field(name = "title", store = Store.NO)
private String title; private String title;
@Column(name = "startDate", length = 10) @Column(name = "startDate", length = 10)
...@@ -57,7 +52,6 @@ public class Metadata extends VersionedAuditedModel implements AclAwareModel, Ge ...@@ -57,7 +52,6 @@ public class Metadata extends VersionedAuditedModel implements AclAwareModel, Ge
private String EDate; private String EDate;
@Column(length = 128) @Column(length = 128)
@Field(store = Store.NO)
private String location; private String location;
private Double longitude; private Double longitude;
...@@ -66,12 +60,10 @@ public class Metadata extends VersionedAuditedModel implements AclAwareModel, Ge ...@@ -66,12 +60,10 @@ public class Metadata extends VersionedAuditedModel implements AclAwareModel, Ge
@Lob @Lob
@Type(type = "org.hibernate.type.TextType") @Type(type = "org.hibernate.type.TextType")
@Field(store = Store.NO)
private String citation; private String citation;
@Lob @Lob
@Type(type = "org.hibernate.type.TextType") @Type(type = "org.hibernate.type.TextType")
@Field(name = "body", store = Store.NO)
private String description; private String description;
@Column(length = 36, unique = true, nullable = false) @Column(length = 36, unique = true, nullable = false)
......
...@@ -24,14 +24,10 @@ import javax.persistence.Table; ...@@ -24,14 +24,10 @@ import javax.persistence.Table;
import javax.persistence.UniqueConstraint; import javax.persistence.UniqueConstraint;
import org.genesys2.server.model.BusinessModel; 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 @Entity
// Add index on genus, genus+species // Add index on genus, genus+species
@Table(name = "taxonomy", uniqueConstraints = { @UniqueConstraint(columnNames = { "genus", "species" }) }) @Table(name = "taxonomy", uniqueConstraints = { @UniqueConstraint(columnNames = { "genus", "species" }) })
@Indexed
public class Taxonomy extends BusinessModel { public class Taxonomy extends BusinessModel {
private static final long serialVersionUID = 8881324404490162933L; private static final long serialVersionUID = 8881324404490162933L;
...@@ -43,7 +39,6 @@ public class Taxonomy extends BusinessModel { ...@@ -43,7 +39,6 @@ public class Taxonomy extends BusinessModel {
private String species; private String species;
@Column(name = "taxonName", nullable = false, length = 200) @Column(name = "taxonName", nullable = false, length = 200)
@Field(name = "title", store = Store.NO)
private String taxonName; private String taxonName;
public String getGenus() { public String getGenus() {
......
...@@ -32,7 +32,6 @@ import org.apache.commons.lang3.StringUtils; ...@@ -32,7 +32,6 @@ import org.apache.commons.lang3.StringUtils;
import org.genesys2.server.model.GlobalVersionedAuditedModel; import org.genesys2.server.model.GlobalVersionedAuditedModel;
import org.genesys2.server.model.impl.CropTaxonomy; import org.genesys2.server.model.impl.CropTaxonomy;
import org.hibernate.annotations.Type; import org.hibernate.annotations.Type;
import org.hibernate.search.annotations.Indexed;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
...@@ -40,7 +39,6 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; ...@@ -40,7 +39,6 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
@Entity @Entity
// Add index on all fields // Add index on all fields
@Table(name = "taxonomy2", uniqueConstraints = { @UniqueConstraint(columnNames = { "genus", "species", "spAuthor", "subtaxa", "subtAuthor" }) }) @Table(name = "taxonomy2", uniqueConstraints = { @UniqueConstraint(columnNames = { "genus", "species", "spAuthor", "subtaxa", "subtAuthor" }) })
@Indexed
@JsonIgnoreProperties(ignoreUnknown=true) @JsonIgnoreProperties(ignoreUnknown=true)
public class Taxonomy2 extends GlobalVersionedAuditedModel { public class Taxonomy2 extends GlobalVersionedAuditedModel {
......
...@@ -27,24 +27,18 @@ import javax.persistence.TemporalType; ...@@ -27,24 +27,18 @@ import javax.persistence.TemporalType;
import org.genesys2.server.model.AuditedModel; import org.genesys2.server.model.AuditedModel;
import org.hibernate.annotations.Type; import org.hibernate.annotations.Type;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.Store;
@Entity @Entity
@Table(name = "activitypost") @Table(name = "activitypost")
@Indexed
public class ActivityPost extends AuditedModel { public class ActivityPost extends AuditedModel {
private static final long serialVersionUID = 8690395020204070378L; private static final long serialVersionUID = 8690395020204070378L;
@Column(nullable = false, length = 500) @Column(nullable = false, length = 500)
@Field(name = "title", store = Store.NO)
private String title; private String title;
@Lob @Lob
@Type(type = "org.hibernate.type.TextType") @Type(type = "org.hibernate.type.TextType")
@Field(name = "body", store = Store.NO)
private String body; private String body;
@Temporal(TemporalType.TIMESTAMP) @Temporal(TemporalType.TIMESTAMP)
......
...@@ -29,13 +29,9 @@ import javax.persistence.TemporalType; ...@@ -29,13 +29,9 @@ import javax.persistence.TemporalType;
import org.genesys2.server.model.AuditedModel; import org.genesys2.server.model.AuditedModel;
import org.hibernate.annotations.Type; import org.hibernate.annotations.Type;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.Store;
@Entity @Entity
@Table(name = "article") @Table(name = "article")
@Indexed
public class Article extends AuditedModel { public class Article extends AuditedModel {
private static final long serialVersionUID = 8690395020204070378L; private static final long serialVersionUID = 8690395020204070378L;
...@@ -58,13 +54,11 @@ public class Article extends AuditedModel { ...@@ -58,13 +54,11 @@ public class Article extends AuditedModel {
@Lob @Lob
@Type(type = "org.hibernate.type.TextType") @Type(type = "org.hibernate.type.TextType")
@Field(name = "title", store = Store.NO)
private String title; private String title;