Commit 0c6d6f8e authored by Matija Obreza's avatar Matija Obreza

Merge branch '402-filter-by-worldclim-data' into 'master'

Resolve "Filter by WorldClim data"

Closes #402

See merge request genesys-pgr/genesys-server!328
parents 553f019e 6d406e72
......@@ -201,7 +201,7 @@ public class ElasticQueryBuilder implements Visitor<Void, Void> {
private void handleEquals(Path<?> path, Expression<?> value) {
PathMetadata pmd = path.getMetadata();
if (pmd.getPathType() == PathType.COLLECTION_ANY) {
LOG.error("Path ANY for {}={}", pmd.getParent(), value);
LOG.debug("Path ANY for {}={}", pmd.getParent(), value);
mustClauses.add(termsQuery(customizedPath(pmd.getParent().toString()), toValues(value)));
} else {
mustClauses.add(termsQuery(customizedPath(getParentPath(pmd.getParent()) + "." + pmd.getName()), toValues(value)));
......
......@@ -57,6 +57,7 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonUnwrapped;
import com.fasterxml.jackson.annotation.JsonView;
import com.querydsl.core.annotations.QueryInit;
@MappedSuperclass
public abstract class AccessionData extends AuditedVersionedModel implements IdUUID, AccessionIdentifier3, Serializable, SelfCleaning {
......@@ -68,6 +69,7 @@ public abstract class AccessionData extends AuditedVersionedModel implements IdU
@JoinColumn(name = "id")
@JsonUnwrapped
@Field(type=FieldType.Auto)
@QueryInit({ "geo.*", "coll.*" })
private AccessionId accessionId;
@Column(name = "doi")
......@@ -88,7 +90,7 @@ public abstract class AccessionData extends AuditedVersionedModel implements IdU
@JsonView({ JsonViews.Minimal.class })
@Field(type = FieldType.Object)
@JsonIgnoreProperties({"settings"})
// @QueryInit({ "country.region.*" })
@QueryInit({ "country.*" })
private FaoInstitute institute;
@Size(max = 128)
......
......@@ -17,9 +17,12 @@
package org.genesys2.server.model.genesys;
import javax.persistence.Column;
import javax.persistence.ConstraintMode;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Index;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.PrePersist;
import javax.persistence.PreUpdate;
......@@ -29,9 +32,13 @@ import javax.persistence.Version;
import org.apache.commons.lang3.StringUtils;
import org.genesys.blocks.auditlog.annotations.Audited;
import org.genesys.blocks.model.BasicModel;
import org.genesys.blocks.model.JsonViews;
import org.genesys.blocks.model.SelfCleaning;
import org.genesys.worldclim.WorldClimUtil;
import org.genesys2.server.model.impl.GeoReferencedEntity;
import org.genesys2.server.model.impl.TileClimate;
import com.fasterxml.jackson.annotation.JsonView;
@Entity
@Table(name = "accession_geo", indexes = { @Index(unique = false, columnList = "latitude, longitude"), @Index(unique = false, columnList = "tileIndex") })
......@@ -60,6 +67,11 @@ public class AccessionGeo extends BasicModel implements GeoReferencedEntity, Acc
private String method;
private Long tileIndex;
@ManyToOne(cascade = {}, fetch = FetchType.LAZY, optional = true)
@JoinColumn(name = "tileIndex", nullable = true, insertable = false, updatable = false, foreignKey = @javax.persistence.ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT))
@JsonView({ JsonViews.Protected.class })
private TileClimate climate;
/**
* Recalculate {@link #tileIndex} on insert and update
......@@ -158,6 +170,14 @@ public class AccessionGeo extends BasicModel implements GeoReferencedEntity, Acc
public void setTileIndex(final Long tileIndex) {
this.tileIndex = tileIndex;
}
public TileClimate getClimate() {
return climate;
}
public void setClimate(TileClimate climate) {
this.climate = climate;
}
public boolean isEmpty() {
if (StringUtils.isNotBlank(datum)) {
......
/*
* Copyright 2018 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.model.impl;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Index;
import javax.persistence.Table;
/**
* The TileClimate entity maintains data from worldclim.org.
*/
@Entity
@Table(name = "tile_climate", indexes = { @Index(columnList = "alt"), @Index(columnList = "tmin1"), @Index(columnList = "tmax1"), @Index(columnList = "tmean1"),
@Index(columnList = "prec1"), @Index(columnList = "tmin2"), @Index(columnList = "tmax2"), @Index(columnList = "tmean2"), @Index(columnList = "prec2"),
@Index(columnList = "tmin3"), @Index(columnList = "tmax3"), @Index(columnList = "tmean3"), @Index(columnList = "prec3"), @Index(columnList = "tmin4"),
@Index(columnList = "tmax4"), @Index(columnList = "tmean4"), @Index(columnList = "prec4"), @Index(columnList = "tmin5"), @Index(columnList = "tmax5"),
@Index(columnList = "tmean5"), @Index(columnList = "prec5"), @Index(columnList = "tmin6"), @Index(columnList = "tmax6"), @Index(columnList = "tmean6"),
@Index(columnList = "prec6"), @Index(columnList = "tmin7"), @Index(columnList = "tmax7"), @Index(columnList = "tmean7"), @Index(columnList = "prec7"),
@Index(columnList = "tmin8"), @Index(columnList = "tmax8"), @Index(columnList = "tmean8"), @Index(columnList = "prec8"), @Index(columnList = "tmin9"),
@Index(columnList = "tmax9"), @Index(columnList = "tmean9"), @Index(columnList = "prec9"), @Index(columnList = "tmin10"), @Index(columnList = "tmax10"),
@Index(columnList = "tmean10"), @Index(columnList = "prec10"), @Index(columnList = "tmin11"), @Index(columnList = "tmax11"), @Index(columnList = "tmean11"),
@Index(columnList = "prec11"), @Index(columnList = "tmin12"), @Index(columnList = "tmax12"), @Index(columnList = "tmean12"), @Index(columnList = "prec12"),
@Index(columnList = "bio1"), @Index(columnList = "bio2"), @Index(columnList = "bio3"), @Index(columnList = "bio4"), @Index(columnList = "bio5"),
@Index(columnList = "bio6"), @Index(columnList = "bio7"), @Index(columnList = "bio8"), @Index(columnList = "bio9"), @Index(columnList = "bio10"),
@Index(columnList = "bio11"), @Index(columnList = "bio12"), @Index(columnList = "bio13"), @Index(columnList = "bio14"), @Index(columnList = "bio15") })
public class TileClimate {
@Id
private long tileIndex;
private Double alt;
private Double bio1;
private Double bio2;
private Double bio3;
private Double bio4;
private Double bio5;
private Double bio6;
private Double bio7;
private Double bio8;
private Double bio9;
private Double bio10;
private Double bio11;
private Double bio12;
private Double bio13;
private Double bio14;
private Double bio15;
private Double prec1;
private Double prec2;
private Double prec3;
private Double prec4;
private Double prec5;
private Double prec6;
private Double prec7;
private Double prec8;
private Double prec9;
private Double prec10;
private Double prec11;
private Double prec12;
private Double tmax1;
private Double tmax2;
private Double tmax3;
private Double tmax4;
private Double tmax5;
private Double tmax6;
private Double tmax7;
private Double tmax8;
private Double tmax9;
private Double tmax10;
private Double tmax11;
private Double tmax12;
private Double tmean1;
private Double tmean2;
private Double tmean3;
private Double tmean4;
private Double tmean5;
private Double tmean6;
private Double tmean7;
private Double tmean8;
private Double tmean9;
private Double tmean10;
private Double tmean11;
private Double tmean12;
private Double tmin1;
private Double tmin2;
private Double tmin3;
private Double tmin4;
private Double tmin5;
private Double tmin6;
private Double tmin7;
private Double tmin8;
private Double tmin9;
private Double tmin10;
private Double tmin11;
private Double tmin12;
public TileClimate() {
}
public TileClimate(Long tileIndex) {
this.tileIndex = tileIndex;
}
public long getTileIndex() {
return tileIndex;
}
public void setTileIndex(long tileIndex) {
this.tileIndex = tileIndex;
}
public Double getAlt() {
return alt;
}
public void setAlt(Double alt) {
this.alt = alt;
}
public Double getBio1() {
return bio1;
}
public void setBio1(Double bio1) {
this.bio1 = bio1;
}
public Double getBio2() {
return bio2;
}
public void setBio2(Double bio2) {
this.bio2 = bio2;
}
public Double getBio3() {
return bio3;
}
public void setBio3(Double bio3) {
this.bio3 = bio3;
}
public Double getBio4() {
return bio4;
}
public void setBio4(Double bio4) {
this.bio4 = bio4;
}
public Double getBio5() {
return bio5;
}
public void setBio5(Double bio5) {
this.bio5 = bio5;
}
public Double getBio6() {
return bio6;
}
public void setBio6(Double bio6) {
this.bio6 = bio6;
}
public Double getBio7() {
return bio7;
}
public void setBio7(Double bio7) {
this.bio7 = bio7;
}
public Double getBio8() {
return bio8;
}
public void setBio8(Double bio8) {
this.bio8 = bio8;
}
public Double getBio9() {
return bio9;
}
public void setBio9(Double bio9) {
this.bio9 = bio9;
}
public Double getBio10() {
return bio10;
}
public void setBio10(Double bio10) {
this.bio10 = bio10;
}
public Double getBio11() {
return bio11;
}
public void setBio11(Double bio11) {
this.bio11 = bio11;
}
public Double getBio12() {
return bio12;
}
public void setBio12(Double bio12) {
this.bio12 = bio12;
}
public Double getBio13() {
return bio13;
}
public void setBio13(Double bio13) {
this.bio13 = bio13;
}
public Double getBio14() {
return bio14;
}
public void setBio14(Double bio14) {
this.bio14 = bio14;
}
public Double getBio15() {
return bio15;
}
public void setBio15(Double bio15) {
this.bio15 = bio15;
}
public Double getPrec1() {
return prec1;
}
public void setPrec1(Double prec1) {
this.prec1 = prec1;
}
public Double getPrec2() {
return prec2;
}
public void setPrec2(Double prec2) {
this.prec2 = prec2;
}
public Double getPrec3() {
return prec3;
}
public void setPrec3(Double prec3) {
this.prec3 = prec3;
}
public Double getPrec4() {
return prec4;
}
public void setPrec4(Double prec4) {
this.prec4 = prec4;
}
public Double getPrec5() {
return prec5;
}
public void setPrec5(Double prec5) {
this.prec5 = prec5;
}
public Double getPrec6() {
return prec6;
}
public void setPrec6(Double prec6) {
this.prec6 = prec6;
}
public Double getPrec7() {
return prec7;
}
public void setPrec7(Double prec7) {
this.prec7 = prec7;
}
public Double getPrec8() {
return prec8;
}
public void setPrec8(Double prec8) {
this.prec8 = prec8;
}
public Double getPrec9() {
return prec9;
}
public void setPrec9(Double prec9) {
this.prec9 = prec9;
}
public Double getPrec10() {
return prec10;
}
public void setPrec10(Double prec10) {
this.prec10 = prec10;
}
public Double getPrec11() {
return prec11;
}
public void setPrec11(Double prec11) {
this.prec11 = prec11;
}
public Double getPrec12() {
return prec12;
}
public void setPrec12(Double prec12) {
this.prec12 = prec12;
}
public Double getTmax1() {
return tmax1;
}
public void setTmax1(Double tmax1) {
this.tmax1 = tmax1;
}
public Double getTmax2() {
return tmax2;
}
public void setTmax2(Double tmax2) {
this.tmax2 = tmax2;
}
public Double getTmax3() {
return tmax3;
}
public void setTmax3(Double tmax3) {
this.tmax3 = tmax3;
}
public Double getTmax4() {
return tmax4;
}
public void setTmax4(Double tmax4) {
this.tmax4 = tmax4;
}
public Double getTmax5() {
return tmax5;
}
public void setTmax5(Double tmax5) {
this.tmax5 = tmax5;
}
public Double getTmax6() {
return tmax6;
}
public void setTmax6(Double tmax6) {
this.tmax6 = tmax6;
}
public Double getTmax7() {
return tmax7;
}
public void setTmax7(Double tmax7) {
this.tmax7 = tmax7;
}
public Double getTmax8() {
return tmax8;
}
public void setTmax8(Double tmax8) {
this.tmax8 = tmax8;
}
public Double getTmax9() {
return tmax9;
}
public void setTmax9(Double tmax9) {
this.tmax9 = tmax9;
}
public Double getTmax10() {
return tmax10;
}
public void setTmax10(Double tmax10) {
this.tmax10 = tmax10;
}
public Double getTmax11() {
return tmax11;
}
public void setTmax11(Double tmax11) {
this.tmax11 = tmax11;
}
public Double getTmax12() {
return tmax12;
}
public void setTmax12(Double tmax12) {
this.tmax12 = tmax12;
}
public Double getTmean1() {
return tmean1;
}
public void setTmean1(Double tmean1) {
this.tmean1 = tmean1;
}
public Double getTmean2() {
return tmean2;
}
public void setTmean2(Double tmean2) {
this.tmean2 = tmean2;
}
public Double getTmean3() {
return tmean3;
}
public void setTmean3(Double tmean3) {
this.tmean3 = tmean3;
}
public Double getTmean4() {
return tmean4;
}
public void setTmean4(Double tmean4) {
this.tmean4 = tmean4;
}
public Double getTmean5() {
return tmean5;
}
public void setTmean5(Double tmean5) {
this.tmean5 = tmean5;
}
public Double getTmean6() {
return tmean6;
}
public void setTmean6(Double tmean6) {
this.tmean6 = tmean6;
}
public Double getTmean7() {
return tmean7;
}
public void setTmean7(Double tmean7) {
this.tmean7 = tmean7;
}
public Double getTmean8() {
return tmean8;
}
public void setTmean8(Double tmean8) {
this.tmean8 = tmean8;
}
public Double getTmean9() {
return tmean9;
}
public void setTmean9(Double tmean9) {
this.tmean9 = tmean9;
}
public Double getTmean10() {
return tmean10;
}
public void setTmean10(Double tmean10) {
this.tmean10 = tmean10;
}
public Double getTmean11() {
return tmean11;
}
public void setTmean11(Double tmean11) {
this.tmean11 = tmean11;
}
public Double getTmean12() {
return tmean12;
}
public void setTmean12(Double tmean12) {
this.tmean12 = tmean12;
}
public Double getTmin1() {
return tmin1;
}
public void setTmin1(Double tmin1) {
this.tmin1 = tmin1;
}
public Double getTmin2() {
return tmin2;
}
public void setTmin2(Double tmin2) {
this.tmin2 = tmin2;
}
public Double getTmin3() {
return tmin3;
}
public void setTmin3(Double tmin3) {
this.tmin3 = tmin3;
}
public Double getTmin4() {
return tmin4;
}
public void setTmin4(Double tmin4) {
this.tmin4 = tmin4;
}
public Double getTmin5() {
return tmin5;
}
public void setTmin5(Double tmin5) {
this.tmin5 = tmin5;
}
public Double getTmin6() {
return tmin6;
}
public void setTmin6(Double tmin6) {
this.tmin6 = tmin6;
}
public Double getTmin7() {
return tmin7;
}
public void setTmin7(Double tmin7) {
this.tmin7 = tmin7;
}
public Double getTmin8() {
return tmin8;
}
public void setTmin8(Double tmin8) {
this.tmin8 = tmin8;
}
public Double getTmin9() {