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> { ...@@ -201,7 +201,7 @@ public class ElasticQueryBuilder implements Visitor<Void, Void> {
private void handleEquals(Path<?> path, Expression<?> value) { private void handleEquals(Path<?> path, Expression<?> value) {
PathMetadata pmd = path.getMetadata(); PathMetadata pmd = path.getMetadata();
if (pmd.getPathType() == PathType.COLLECTION_ANY) { 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))); mustClauses.add(termsQuery(customizedPath(pmd.getParent().toString()), toValues(value)));
} else { } else {
mustClauses.add(termsQuery(customizedPath(getParentPath(pmd.getParent()) + "." + pmd.getName()), toValues(value))); mustClauses.add(termsQuery(customizedPath(getParentPath(pmd.getParent()) + "." + pmd.getName()), toValues(value)));
......
...@@ -57,6 +57,7 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; ...@@ -57,6 +57,7 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonUnwrapped; import com.fasterxml.jackson.annotation.JsonUnwrapped;
import com.fasterxml.jackson.annotation.JsonView; import com.fasterxml.jackson.annotation.JsonView;
import com.querydsl.core.annotations.QueryInit;
@MappedSuperclass @MappedSuperclass
public abstract class AccessionData extends AuditedVersionedModel implements IdUUID, AccessionIdentifier3, Serializable, SelfCleaning { public abstract class AccessionData extends AuditedVersionedModel implements IdUUID, AccessionIdentifier3, Serializable, SelfCleaning {
...@@ -68,6 +69,7 @@ public abstract class AccessionData extends AuditedVersionedModel implements IdU ...@@ -68,6 +69,7 @@ public abstract class AccessionData extends AuditedVersionedModel implements IdU
@JoinColumn(name = "id") @JoinColumn(name = "id")
@JsonUnwrapped @JsonUnwrapped
@Field(type=FieldType.Auto) @Field(type=FieldType.Auto)
@QueryInit({ "geo.*", "coll.*" })
private AccessionId accessionId; private AccessionId accessionId;
@Column(name = "doi") @Column(name = "doi")
...@@ -88,7 +90,7 @@ public abstract class AccessionData extends AuditedVersionedModel implements IdU ...@@ -88,7 +90,7 @@ public abstract class AccessionData extends AuditedVersionedModel implements IdU
@JsonView({ JsonViews.Minimal.class }) @JsonView({ JsonViews.Minimal.class })
@Field(type = FieldType.Object) @Field(type = FieldType.Object)
@JsonIgnoreProperties({"settings"}) @JsonIgnoreProperties({"settings"})
// @QueryInit({ "country.region.*" }) @QueryInit({ "country.*" })
private FaoInstitute institute; private FaoInstitute institute;
@Size(max = 128) @Size(max = 128)
......
...@@ -17,9 +17,12 @@ ...@@ -17,9 +17,12 @@
package org.genesys2.server.model.genesys; package org.genesys2.server.model.genesys;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.ConstraintMode;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.FetchType; import javax.persistence.FetchType;
import javax.persistence.Index; import javax.persistence.Index;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne; import javax.persistence.OneToOne;
import javax.persistence.PrePersist; import javax.persistence.PrePersist;
import javax.persistence.PreUpdate; import javax.persistence.PreUpdate;
...@@ -29,9 +32,13 @@ import javax.persistence.Version; ...@@ -29,9 +32,13 @@ import javax.persistence.Version;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.genesys.blocks.auditlog.annotations.Audited; import org.genesys.blocks.auditlog.annotations.Audited;
import org.genesys.blocks.model.BasicModel; import org.genesys.blocks.model.BasicModel;
import org.genesys.blocks.model.JsonViews;
import org.genesys.blocks.model.SelfCleaning; import org.genesys.blocks.model.SelfCleaning;
import org.genesys.worldclim.WorldClimUtil; import org.genesys.worldclim.WorldClimUtil;
import org.genesys2.server.model.impl.GeoReferencedEntity; import org.genesys2.server.model.impl.GeoReferencedEntity;
import org.genesys2.server.model.impl.TileClimate;
import com.fasterxml.jackson.annotation.JsonView;
@Entity @Entity
@Table(name = "accession_geo", indexes = { @Index(unique = false, columnList = "latitude, longitude"), @Index(unique = false, columnList = "tileIndex") }) @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 ...@@ -60,6 +67,11 @@ public class AccessionGeo extends BasicModel implements GeoReferencedEntity, Acc
private String method; private String method;
private Long tileIndex; 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 * Recalculate {@link #tileIndex} on insert and update
...@@ -158,6 +170,14 @@ public class AccessionGeo extends BasicModel implements GeoReferencedEntity, Acc ...@@ -158,6 +170,14 @@ public class AccessionGeo extends BasicModel implements GeoReferencedEntity, Acc
public void setTileIndex(final Long tileIndex) { public void setTileIndex(final Long tileIndex) {
this.tileIndex = tileIndex; this.tileIndex = tileIndex;
} }
public TileClimate getClimate() {
return climate;
}
public void setClimate(TileClimate climate) {
this.climate = climate;
}
public boolean isEmpty() { public boolean isEmpty() {
if (StringUtils.isNotBlank(datum)) { if (StringUtils.isNotBlank(datum)) {
......
This diff is collapsed.
...@@ -12,7 +12,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore; ...@@ -12,7 +12,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
*/ */
public class WorldclimJson { public class WorldclimJson {
// Monthlies // Monthlies
private Long[] precipitation = new Long[12]; private Double[] precipitation = new Double[12];
private Double[] tempMin = new Double[12]; private Double[] tempMin = new Double[12];
private Double[] tempMean = new Double[12]; private Double[] tempMean = new Double[12];
private Double[] tempMax = new Double[12]; private Double[] tempMax = new Double[12];
...@@ -20,7 +20,7 @@ public class WorldclimJson { ...@@ -20,7 +20,7 @@ public class WorldclimJson {
@JsonIgnore @JsonIgnore
private Map<DSDescriptor, Object> other = new HashMap<DSDescriptor, Object>(); private Map<DSDescriptor, Object> other = new HashMap<DSDescriptor, Object>();
public Long[] getPrecipitation() { public Double[] getPrecipitation() {
return precipitation; return precipitation;
} }
...@@ -43,4 +43,20 @@ public class WorldclimJson { ...@@ -43,4 +43,20 @@ public class WorldclimJson {
public Map<DSDescriptor, Object> getOther() { public Map<DSDescriptor, Object> getOther() {
return this.other; return this.other;
} }
public void setPrecipitation(Double[] doubles) {
this.precipitation = doubles;
}
public void setTempMin(Double[] doubles) {
this.tempMin = doubles;
}
public void setTempMean(Double[] doubles) {
this.tempMean = doubles;
}
public void setTempMax(Double[] doubles) {
this.tempMax = doubles;
}
} }
...@@ -30,8 +30,6 @@ import org.genesys.blocks.auditlog.service.AuditTrailService; ...@@ -30,8 +30,6 @@ import org.genesys.blocks.auditlog.service.AuditTrailService;
import org.genesys.catalog.service.DatasetService; import org.genesys.catalog.service.DatasetService;
import org.genesys.filerepository.InvalidRepositoryPathException; import org.genesys.filerepository.InvalidRepositoryPathException;
import org.genesys.filerepository.model.ImageGallery; import org.genesys.filerepository.model.ImageGallery;
import org.genesys.filerepository.service.ImageGalleryService;
import org.genesys2.server.model.dataset.DS;
import org.genesys2.server.model.elastic.AccessionDetails; import org.genesys2.server.model.elastic.AccessionDetails;
import org.genesys2.server.model.genesys.Accession; import org.genesys2.server.model.genesys.Accession;
import org.genesys2.server.model.genesys.AccessionCollect; import org.genesys2.server.model.genesys.AccessionCollect;
...@@ -41,7 +39,7 @@ import org.genesys2.server.model.genesys.Taxonomy2; ...@@ -41,7 +39,7 @@ import org.genesys2.server.model.genesys.Taxonomy2;
import org.genesys2.server.model.impl.Crop; import org.genesys2.server.model.impl.Crop;
import org.genesys2.server.model.impl.FaoInstitute; import org.genesys2.server.model.impl.FaoInstitute;
import org.genesys2.server.service.AccessionService; import org.genesys2.server.service.AccessionService;
import org.genesys2.server.service.DSService; import org.genesys2.server.service.ClimateDataService;
import org.genesys2.server.service.DownloadService; import org.genesys2.server.service.DownloadService;
import org.genesys2.server.service.FilterConstants; import org.genesys2.server.service.FilterConstants;
import org.genesys2.server.service.GenesysService; import org.genesys2.server.service.GenesysService;
...@@ -85,14 +83,11 @@ public class AccessionController extends BaseController { ...@@ -85,14 +83,11 @@ public class AccessionController extends BaseController {
@Autowired @Autowired
private TaxonomyService taxonomyService; private TaxonomyService taxonomyService;
@Autowired
private DSService dsService;
@Autowired @Autowired
private InstituteFilesService instituteFilesService; private InstituteFilesService instituteFilesService;
@Autowired @Autowired
private ImageGalleryService imageGalleryService; private ClimateDataService climateDataService;
@Autowired @Autowired
private DownloadService downloadService; private DownloadService downloadService;
...@@ -189,10 +184,7 @@ public class AccessionController extends BaseController { ...@@ -189,10 +184,7 @@ public class AccessionController extends BaseController {
// Worldclim data // Worldclim data
if (accessionGeo != null && accessionGeo.getTileIndex() != null) { if (accessionGeo != null && accessionGeo.getTileIndex() != null) {
DS worldClimDataset = dsService.loadDatasetByUuid(WORLDCLIM_DATASET_UUID); model.addAttribute("worldclimJson", climateDataService.jsonForTile(accessionGeo.getTileIndex()));
if (worldClimDataset != null) {
model.addAttribute("worldclimJson", dsService.jsonForTile(worldClimDataset, accessionGeo.getTileIndex()));
}
} }
model.addAttribute("pdci", accessionId.getPdci()); model.addAttribute("pdci", accessionId.getPdci());
......
...@@ -18,13 +18,11 @@ package org.genesys2.server.mvc; ...@@ -18,13 +18,11 @@ package org.genesys2.server.mvc;
import java.util.UUID; import java.util.UUID;
import org.genesys2.server.model.dataset.DS;
import org.genesys2.server.model.genesys.AccessionGeo; import org.genesys2.server.model.genesys.AccessionGeo;
import org.genesys2.server.model.genesys.AccessionHistoric; import org.genesys2.server.model.genesys.AccessionHistoric;
import org.genesys2.server.service.ClimateDataService;
import org.genesys2.server.service.CropService; import org.genesys2.server.service.CropService;
import org.genesys2.server.service.DSService;
import org.genesys2.server.service.GenesysService; import org.genesys2.server.service.GenesysService;
import org.genesys2.server.service.TaxonomyService;
import org.genesys2.server.service.TraitService; import org.genesys2.server.service.TraitService;
import org.genesys2.spring.ResourceNotFoundException; import org.genesys2.spring.ResourceNotFoundException;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -44,14 +42,11 @@ public class ArchiveController extends BaseController { ...@@ -44,14 +42,11 @@ public class ArchiveController extends BaseController {
@Autowired @Autowired
private TraitService traitService; private TraitService traitService;
@Autowired
private TaxonomyService taxonomyService;
@Autowired @Autowired
private CropService cropService; private CropService cropService;
@Autowired @Autowired
private DSService dsService; private ClimateDataService climateDataService;
@RequestMapping(value = "/{uuid:.{36}}", method = RequestMethod.GET) @RequestMapping(value = "/{uuid:.{36}}", method = RequestMethod.GET)
public String view(ModelMap model, @PathVariable(value = "uuid") UUID uuid) { public String view(ModelMap model, @PathVariable(value = "uuid") UUID uuid) {
...@@ -91,10 +86,7 @@ public class ArchiveController extends BaseController { ...@@ -91,10 +86,7 @@ public class ArchiveController extends BaseController {
// Worldclim data // Worldclim data
if (accessionGeo != null && accessionGeo.getTileIndex() != null) { if (accessionGeo != null && accessionGeo.getTileIndex() != null) {
DS worldClimDataset = dsService.loadDatasetByUuid(AccessionController.WORLDCLIM_DATASET_UUID); model.addAttribute("worldclimJson", climateDataService.jsonForTile(accessionGeo.getTileIndex()));
if (worldClimDataset != null) {
model.addAttribute("worldclimJson", dsService.jsonForTile(worldClimDataset, accessionGeo.getTileIndex()));
}
} }
} }
......
...@@ -29,7 +29,6 @@ import org.genesys2.server.service.ElasticsearchService.Term; ...@@ -29,7 +29,6 @@ import org.genesys2.server.service.ElasticsearchService.Term;
import org.genesys2.server.service.ElasticsearchService.TermResult; import org.genesys2.server.service.ElasticsearchService.TermResult;
import org.genesys2.server.service.FilterConstants; import org.genesys2.server.service.FilterConstants;
import org.genesys2.server.service.GeoService; import org.genesys2.server.service.GeoService;
import org.genesys2.server.service.filter.AccessionFilter;
import org.genesys2.server.service.filter.AppliedFiltersConverter; import org.genesys2.server.service.filter.AppliedFiltersConverter;
import org.genesys2.server.service.impl.FilterHandler; import org.genesys2.server.service.impl.FilterHandler;
import org.genesys2.server.service.impl.FilterHandler.AppliedFilters; import org.genesys2.server.service.impl.FilterHandler.AppliedFilters;
...@@ -89,7 +88,7 @@ public class ChartsController extends BaseController { ...@@ -89,7 +88,7 @@ public class ChartsController extends BaseController {
AppliedFilters appliedFilters = mapper.readValue(jsonFilter, AppliedFilters.class); AppliedFilters appliedFilters = mapper.readValue(jsonFilter, AppliedFilters.class);
// Load all term results // Load all term results
TermResult countryStatistics = elasticService.termStatisticsAuto(Accession.class, AccessionFilter.convert(appliedFilters), Integer.MAX_VALUE, AppliedFiltersConverter.convertTerm( TermResult countryStatistics = elasticService.termStatisticsAuto(Accession.class, AppliedFilters.convert(appliedFilters), Integer.MAX_VALUE, AppliedFiltersConverter.convertTerm(
FilterConstants.INSTITUTE_COUNTRY_ISO2)); FilterConstants.INSTITUTE_COUNTRY_ISO2));
List<Map<String, Object>> resultList = new ArrayList<>(); List<Map<String, Object>> resultList = new ArrayList<>();
......
...@@ -42,7 +42,6 @@ import org.genesys2.server.service.ElasticsearchService; ...@@ -42,7 +42,6 @@ import org.genesys2.server.service.ElasticsearchService;
import org.genesys2.server.service.FilterConstants; import org.genesys2.server.service.FilterConstants;
import org.genesys2.server.service.GenesysService; import org.genesys2.server.service.GenesysService;
import org.genesys2.server.service.ProjectService; import org.genesys2.server.service.ProjectService;
import org.genesys2.server.service.filter.AccessionFilter;
import org.genesys2.server.service.filter.AppliedFiltersConverter; import org.genesys2.server.service.filter.AppliedFiltersConverter;
import org.genesys2.server.service.impl.FilterHandler; import org.genesys2.server.service.impl.FilterHandler;
import org.genesys2.server.service.impl.FilterHandler.AppliedFilter; import org.genesys2.server.service.impl.FilterHandler.AppliedFilter;
...@@ -120,10 +119,10 @@ public class ProjectController extends BaseController { ...@@ -120,10 +119,10 @@ public class ProjectController extends BaseController {
model.addAttribute("jsonFilter", filters.toString()); model.addAttribute("jsonFilter", filters.toString());
try { try {
model.addAttribute("statisticsCrop", elasticService.termStatisticsAuto(Accession.class, AccessionFilter.convert(filters), 5, AppliedFiltersConverter.convertTerm(FilterConstants.CROPS))); model.addAttribute("statisticsCrop", elasticService.termStatisticsAuto(Accession.class, AppliedFilters.convert(filters), 5, AppliedFiltersConverter.convertTerm(FilterConstants.CROPS)));
model.addAttribute("statisticsGenus", elasticService.termStatisticsAuto(Accession.class, AccessionFilter.convert(filters), 5, AppliedFiltersConverter.convertTerm(FilterConstants.TAXONOMY_GENUS))); model.addAttribute("statisticsGenus", elasticService.termStatisticsAuto(Accession.class, AppliedFilters.convert(filters), 5, AppliedFiltersConverter.convertTerm(FilterConstants.TAXONOMY_GENUS)));
model.addAttribute("statisticsTaxonomy", elasticService.termStatisticsAuto(Accession.class, AccessionFilter.convert(filters), 5, AppliedFiltersConverter.convertTerm(FilterConstants.TAXONOMY_GENUSSPECIES))); model.addAttribute("statisticsTaxonomy", elasticService.termStatisticsAuto(Accession.class, AppliedFilters.convert(filters), 5, AppliedFiltersConverter.convertTerm(FilterConstants.TAXONOMY_GENUSSPECIES)));
model.addAttribute("statisticsOrigCty", elasticService.termStatisticsAuto(Accession.class, AccessionFilter.convert(filters), 100, AppliedFiltersConverter.convertTerm(FilterConstants.ORGCTY_ISO3))); model.addAttribute("statisticsOrigCty", elasticService.termStatisticsAuto(Accession.class, AppliedFilters.convert(filters), 100, AppliedFiltersConverter.convertTerm(FilterConstants.ORGCTY_ISO3)));
} catch (SearchException e) { } catch (SearchException e) {
LOG.warn(e.getMessage()); LOG.warn(e.getMessage());
} }
...@@ -260,7 +259,7 @@ public class ProjectController extends BaseController { ...@@ -260,7 +259,7 @@ public class ProjectController extends BaseController {
response.addHeader("Content-Disposition", String.format("attachment; filename=\"genesys-accessions-%1$s.zip\"", project.getCode())); response.addHeader("Content-Disposition", String.format("attachment; filename=\"genesys-accessions-%1$s.zip\"", project.getCode()));
final OutputStream outputStream = response.getOutputStream(); final OutputStream outputStream = response.getOutputStream();
genesysService.writeAccessions(AccessionFilter.convert(filters), outputStream); genesysService.writeAccessions(AppliedFilters.convert(filters), outputStream);
response.flushBuffer(); response.flushBuffer();
} }
...@@ -283,7 +282,7 @@ public class ProjectController extends BaseController { ...@@ -283,7 +282,7 @@ public class ProjectController extends BaseController {
final OutputStream outputStream = response.getOutputStream(); final OutputStream outputStream = response.getOutputStream();
try { try {
downloadService.writeXlsxMCPD(AccessionFilter.convert(filters), outputStream); downloadService.writeXlsxMCPD(AppliedFilters.convert(filters), outputStream);
response.flushBuffer(); response.flushBuffer();
} catch (EOFException e) { } catch (EOFException e) {
LOG.warn("Download was aborted", e); LOG.warn("Download was aborted", e);
...@@ -309,7 +308,7 @@ public class ProjectController extends BaseController { ...@@ -309,7 +308,7 @@ public class ProjectController extends BaseController {
final OutputStream outputStream = response.getOutputStream(); final OutputStream outputStream = response.getOutputStream();
try { try {
downloadService.writeXlsxPDCI(AccessionFilter.convert(filters), outputStream); downloadService.writeXlsxPDCI(AppliedFilters.convert(filters), outputStream);
response.flushBuffer(); response.flushBuffer();
} catch (EOFException e) { } catch (EOFException e) {
LOG.warn("Download was aborted", e); LOG.warn("Download was aborted", e);
......
...@@ -16,7 +16,11 @@ ...@@ -16,7 +16,11 @@
package org.genesys2.server.mvc.admin; package org.genesys2.server.mvc.admin;
import java.io.EOFException;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream;
import javax.servlet.http.HttpServletResponse;
import org.genesys2.server.model.dataset.DS; import org.genesys2.server.model.dataset.DS;
import org.genesys2.server.model.dataset.DSColumn; import org.genesys2.server.model.dataset.DSColumn;
...@@ -68,4 +72,25 @@ public class DS2Controller { ...@@ -68,4 +72,25 @@ public class DS2Controller {
} }
return "redirect:/admin/ds2/"; return "redirect:/admin/ds2/";
} }
@RequestMapping(value = "/worldclim/download", method = RequestMethod.POST)
public void worldclimDownload(HttpServletResponse response) throws IOException {
DS ds = dsService.loadDatasetByUuid(WorldClimUpdater.WORLDCLIM_DATASET);
// Write MCPD to the stream.
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.addHeader("Content-Disposition", String.format("attachment; filename=\"worldclim-%1s.xlsx\"", System.currentTimeMillis()));
// response.flushBuffer();
final OutputStream outputStream = response.getOutputStream();
try {
dsService.download(ds, outputStream);
response.flushBuffer();
} catch (EOFException e) {
LOG.warn("Download was aborted: {}", e.getMessage());
}
}
} }
/*
* 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.persistence;
import org.genesys2.server.model.impl.TileClimate;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.querydsl.QueryDslPredicateExecutor;
/**
* The JPA TileClimateRepository.
*/
public interface TileClimateRepository extends JpaRepository<TileClimate, Long>, QueryDslPredicateExecutor<TileClimate> {
}
/*
* 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.service;
import java.nio.MappedByteBuffer;
import java.util.HashSet;
import java.util.List;
import org.genesys2.server.model.genesys.AccessionGeo;
import org.genesys2.server.model.impl.TileClimate;
import org.genesys2.server.model.json.WorldclimJson;
/**
* The ClimateDataService interface.
*/
public interface ClimateDataService {
void worldclimUpdate(String variableName, HashSet<Long> ids, MappedByteBuffer buffer, short nullValue, double factor);
TileClimate climateForTile(Long tileIndex);
void updateAccessionTileIndex(List<AccessionGeo> toSave);
WorldclimJson jsonForTile(Long tileIndex);
}
/*
* 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.service; package org.genesys2.server.service;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.nio.MappedByteBuffer;
import java.util.List; import java.util.List;
import java.util.Set;
import java.util.UUID; import java.util.UUID;
import org.genesys2.server.model.dataset.DS; import org.genesys2.server.model.dataset.DS;
import org.genesys2.server.model.dataset.DSColumn; import org.genesys2.server.model.dataset.DSColumn;
import org.genesys2.server.model.dataset.DSQualifier;
import org.genesys2.server.model.dataset.DSDescriptor; import org.genesys2.server.model.dataset.DSDescriptor;
import org.genesys2.server.model.genesys.AccessionGeo; import org.genesys2.server.model.dataset.DSQualifier;
import org.genesys2.server.model.json.WorldclimJson;
/**
* The DSService interface.
*/
public interface DSService { public interface DSService {
/**
* Save dataset.
*
* @param ds the ds
* @return the ds
*/
DS saveDataset(DS ds); DS saveDataset(DS ds);
/**
* Adds the qualifier.
*
* @param ds the ds
* @param d1 the d 1
* @return the DS qualifier
*/
DSQualifier addQualifier(DS ds, DSDescriptor d1); DSQualifier addQualifier(DS ds, DSDescriptor d1);
/**
* Adds the descriptor.
*
* @param ds the ds
* @param dSDescriptor the d S descriptor
* @return the DS column
*/
DSColumn addDescriptor(DS ds, DSDescriptor dSDescriptor); DSColumn addDescriptor(DS ds, DSDescriptor dSDescriptor);
/**
* Load dataset by uuid.
*
* @param uuid the uuid
* @return the ds
*/
DS loadDatasetByUuid(UUID uuid); DS loadDatasetByUuid(UUID uuid);
/**
* Update row.
*
* @param ds the ds
* @param row the row
*/
void updateRow(DS ds, Object[] row); void updateRow(DS ds, Object[] row);
/**
* Update rows.
*
* @param ds the ds
* @param rows the rows
*/
void updateRows(DS ds, List<Object[]> rows); void updateRows(DS ds, List<Object[]> rows);
/**
* Update row.
*
* @param ds the ds
* @param qualifiers the qualifiers
* @param dsd the dsd
* @param value the value
*/
void updateRow(DS ds, Object[] qualifiers, DSColumn dsd, Object value); void updateRow(DS ds, Object[] qualifiers, DSColumn dsd, Object value);
void worldclimUpdate(DS dataset, DSColumn dsd, Set<Long> ids, MappedByteBuffer buffer, short nullValue, double factor); /**
* Download.
void updateAccessionTileIndex(List<AccessionGeo> toSave); *
* @param ds the ds
WorldclimJson jsonForTile(DS worldClimDataset, Long tileIndex); * @param outputStream the output stream
* @throws IOException Signals that an I/O exception has occurred.
*/
void download(DS ds, OutputStream outputStream) throws IOException; void download(DS ds, OutputStream outputStream) throws IOException;
/**
* Download.
*
* @param ds the ds
* @param dsds the dsds
* @param outputStream the output stream
* @throws IOException Signals that an I/O exception has occurred.
*/
void download(DS ds, List<DSColumn> dsds, OutputStream outputStream) throws IOException; void download(DS ds, List<DSColumn> dsds, OutputStream outputStream) throws IOException;
/**
* Delete dataset.
*
* @param ds the ds
*/
void deleteDataset(DS ds); void deleteDataset(DS ds);
/**
* Delete descriptor.
*
* @param dsd the dsd
*/
void deleteDescriptor(DSColumn dsd); void deleteDescriptor(DSColumn dsd);
/**