Commit 3d5ca3f7 authored by igoshin's avatar igoshin

Merge branch 'upstream-master'

Conflicts:
	src/main/java/org/genesys2/spring/config/ApplicationConfig.java
	src/main/resources/spring/spring.properties
parents 65ddb5cd b9a4073d
......@@ -333,11 +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>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-jdbc</artifactId>
......@@ -420,6 +415,18 @@
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-elasticsearch</artifactId>
<version>1.0.2.RELEASE</version>
</dependency>
<dependency>
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path</artifactId>
......@@ -604,6 +611,8 @@
<include>leaflet.locationfilter.min.js</include>
<include>crophub.min.js</include>
<include>syronex-colorpicker.min.js</include>
<include>jquery.flot.min.js</include>
<include>jquery.flot.pie.min.js</include>
</includes>
</aggregation>
......@@ -657,6 +666,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>
......
......@@ -60,7 +60,9 @@ import com.hazelcast.logging.Logger;
import com.hazelcast.nio.serialization.Data;
/**
* Request dispatcher forward+inclue not wrapping incoming request
* Request dispatcher forward+include not wrapping incoming request.
* See https://github.com/hazelcast/hazelcast/pull/1981
* https://github.com/hazelcast/hazelcast/issues/540
*
* @author matijaobreza
*/
......
/**
* 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);
}
}
......@@ -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;
......
package org.genesys2.server.servlet.controller.rest;
package org.genesys2.server.model.elastic;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.genesys2.server.model.genesys.Accession;
import org.genesys2.server.model.genesys.AccessionAlias;
import org.genesys2.server.model.genesys.AccessionBreeding;
......@@ -14,117 +15,97 @@ import org.genesys2.server.model.genesys.AccessionCollect;
import org.genesys2.server.model.genesys.AccessionExchange;
import org.genesys2.server.model.genesys.AccessionGeo;
import org.genesys2.server.model.genesys.AccessionRemark;
import org.genesys2.server.model.genesys.ExperimentTrait;
import org.genesys2.server.model.genesys.Method;
import org.genesys2.server.model.genesys.SvalbardData;
import org.genesys2.server.model.genesys.Taxonomy2;
import org.genesys2.server.model.impl.Crop;
import org.genesys2.server.model.impl.FaoInstitute;
import org.springframework.data.annotation.Id;
import org.springframework.data.annotation.Version;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldIndex;
import org.springframework.data.elasticsearch.annotations.FieldType;
@Document(indexName = "genesys", type = "mcpd", refreshInterval = "60s")
public class AccessionDetails {
public long version;
public Long id;
public String uuid;
public String acceNumb;
public String acqDate;
public String acqSrc;
public Boolean availability;
public Date createdDate;
public String duplSite;
public Boolean mlsStatus;
public Integer sampStat;
public List<Integer> storage;
public Institute institute;
public Country orgCty;
public Taxonomy taxonomy;
public ArrayList<Alias> aliases;
public Svalbard sgsv;
public ArrayList<Remark> remarks;
public ArrayList<String> crops;
public Geo geo;
public Collect coll;
public String pedigree;
public String donorCode;
public String donorName;
public String donorNumb;
public HashMap<String, List<Object>> traits;
private static final Logger LOG = Logger.getLogger(AccessionDetails.class);
static Pattern mcpdSplit = Pattern.compile("\\w*;\\w*");
@Version
private Long version;
@Id
private Long id;
@Field(index = FieldIndex.not_analyzed, type = FieldType.String)
private String uuid;
@Field(type = FieldType.String)
private String acceNumb;
@Field(index = FieldIndex.not_analyzed, type = FieldType.String)
private String acqDate;
@Field(index = FieldIndex.not_analyzed, type = FieldType.String)
private String acqSrc;
private Boolean available;
private Date createdDate;
private List<String> duplSite;
private Boolean mlsStatus;
private Boolean art15;
private Integer sampStat;
private List<Integer> storage;
@Field(type = FieldType.Object)
private Institute institute;
@Field(type = FieldType.Object)
private Country orgCty;
@Field(type = FieldType.Object)
private Taxonomy taxonomy;
@Field(type = FieldType.Nested)
private ArrayList<Alias> aliases;
private Svalbard sgsv;
@Field(type = FieldType.Nested, store = false)
private ArrayList<Remark> remarks;
@Field(index = FieldIndex.not_analyzed, type = FieldType.String)
private ArrayList<String> crops;
@Field(type = FieldType.Object)
private Geo geo;
@Field(type = FieldType.Object)
private Collect coll;
private String pedigree;
@Field(index = FieldIndex.not_analyzed, type = FieldType.String)
private String donorCode;
private String donorName;
@Field(index = FieldIndex.not_analyzed, type = FieldType.String)
private String donorNumb;
private Date modifiedDate;
private Date acqusitionDate;
public static AccessionDetails from(Accession accession) {
AccessionDetails ad = new AccessionDetails();
ad.version = accession.getVersion();
ad.id = accession.getId();
ad.uuid = accession.getUuid();
ad.createdDate = accession.getCreatedDate();
ad.modifiedDate = accession.getLastModifiedDate();
ad.acceNumb = accession.getAccessionName();
ad.acqDate = accession.getAcquisitionDate();
ad.acqSrc = accession.getAcquisitionSource();
ad.availability = accession.getAvailability();
ad.available = accession.getAvailability();
ad.orgCty = Country.from(accession.getCountryOfOrigin());
ad.createdDate = accession.getCreatedDate();
ad.duplSite = accession.getDuplSite();
ad.institute = AccessionDetails.Institute.from(accession.getInstitute());
if (StringUtils.isNotBlank(accession.getDuplSite()))
ad.duplSite = Arrays.asList(mcpdSplit.split(accession.getDuplSite()));
ad.institute = Institute.from(accession.getInstitute());
ad.mlsStatus = accession.getMlsStatus();
ad.art15 = accession.getInTrust();
ad.sampStat = accession.getSampleStatus();
ad.storage = accession.getStoRage();
ad.taxonomy = Taxonomy.from(accession.getTaxonomy());
return ad;
}
public static class Institute {
public Long id;
public String acronym;
public String code;
public Country country;
public String fullName;
public static Institute from(FaoInstitute institute) {
Institute i = new Institute();
i.id = institute.getId();
i.acronym = institute.getAcronym();
i.code = institute.getCode();
i.country = Country.from(institute.getCountry());
i.fullName = institute.getFullName();
return i;
}
}
public static class Country {
public String iso3;
public String iso2;
public String name;
public static Country from(org.genesys2.server.model.impl.Country country) {
Country c = new Country();
c.iso3 = country.getCode3();
c.iso2 = country.getCode2();
c.name = country.getName();
return c;
}
}
public static class Taxonomy {
public String sciName;
public String genus;
public String species;
public String spAuthor;
public String subtax;
public String subtAuthor;
public static Taxonomy from(Taxonomy2 taxonomy) {
Taxonomy t = new Taxonomy();
t.sciName = taxonomy.getTaxonName();
t.genus = taxonomy.getGenus();
t.species = taxonomy.getSpecies();
t.spAuthor = StringUtils.defaultIfBlank(taxonomy.getSpAuthor(), null);
t.subtax = StringUtils.defaultIfBlank(taxonomy.getSubtaxa(), null);
t.subtAuthor = StringUtils.defaultIfBlank(taxonomy.getSubtAuthor(), null);
return t;
if (ad.taxonomy == null) {
LOG.warn("Go check " + ad.id);
}
return ad;
}
public void aliases(List<AccessionAlias> listAccessionAliases) {
......@@ -136,44 +117,10 @@ public class AccessionDetails {
}
}
public static class Alias {
public String name;
public String lang;
public String usedBy;
public static Alias from(AccessionAlias aa) {
Alias a = new Alias();
a.name = aa.getName();
a.lang = StringUtils.defaultIfBlank(aa.getLang(), null);
a.usedBy = StringUtils.defaultIfBlank(aa.getUsedBy(), null);
return a;
}
}
public void svalbard(SvalbardData svalbardData) {
this.sgsv = Svalbard.from(svalbardData);
}
public static class Svalbard {
public Float qty;
public String boxNo;
public String depositDate;
public static Svalbard from(SvalbardData svalbardData) {
if (svalbardData == null)
return null;
Svalbard s = new Svalbard();
s.boxNo = svalbardData.getBoxNumber();
s.qty = svalbardData.getQuantity();
s.depositDate = svalbardData.getDepositDate();
return s;
}
}
public void remarks(List<AccessionRemark> listAccessionRemarks) {
if (listAccessionRemarks == null || listAccessionRemarks.isEmpty())
return;
......@@ -183,20 +130,6 @@ public class AccessionDetails {
}
}
public static class Remark {
public String field;
public String remark;
public static Remark from(AccessionRemark ar) {
Remark r = new Remark();
r.field = StringUtils.defaultIfBlank(ar.getFieldName(), null);
r.remark = StringUtils.defaultIfBlank(ar.getRemark(), null);
return r;
}
}
public void crops(List<Crop> crops) {
if (crops == null || crops.isEmpty())
return;
......@@ -212,65 +145,10 @@ public class AccessionDetails {
this.geo = Geo.from(ag);
}
public static class Geo {
public String method;
public Double uncertainty;
public Double latitude;
public Double longitude;
public Double[] coordinates;
public Double elevation;
public String datum;