...
 
Commits (671)
......@@ -2,6 +2,19 @@ variables:
GENESYS_VERSION: "2.3"
DOCKER_HOST: genesys1.swarm.genesys-pgr.org
DOCKER_VERSION: latest
# This will suppress any download for dependencies and plugins or upload messages which would clutter the console log.
# `showDateTime` will show the passed time in milliseconds. You need to specify `--batch-mode` to make this work.
MAVEN_OPTS: "-Dhttps.protocols=TLSv1.2 -Dmaven.repo.local=$CI_PROJECT_DIR/.m2/repository -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Dorg.slf4j.simpleLogger.showDateTime=true -Djava.awt.headless=true"
# As of Maven 3.3.0 instead of this you may define these options in `.mvn/maven.config` so the same config is used
# when running from the command line.
# `installAtEnd` and `deployAtEnd` are only effective with recent version of the corresponding plugins.
MAVEN_CLI_OPTS: "--batch-mode --errors --fail-at-end --show-version -DinstallAtEnd=true -DdeployAtEnd=true"
# Cache downloaded dependencies and plugins between builds.
# To keep cache across branches add 'key: "$CI_JOB_NAME"'
cache:
paths:
- .m2/repository
stages:
# - compile
......@@ -19,12 +32,12 @@ stages:
# script:
# - echo "CI_COMMIT_REF_SLUG ${CI_COMMIT_REF_SLUG}"
# - echo "CI_ENVIRONMENT_SLUG ${CI_ENVIRONMENT_SLUG}"
# - MAVEN_OPTS="${MAVEN_OPTS} -Dorg.slf4j.simpleLogger.defaultLogLevel=warn" mvn compile test -B -U
# - mvn compile test -B -U
.package_template: &maven_package
image: dockerhub.croptrust.org/docker/custom/maven-with-compass:latest
script:
- MAVEN_OPTS="${MAVEN_OPTS} -Dorg.slf4j.simpleLogger.defaultLogLevel=warn" mvn package -B -U
- mvn package -B -U
artifacts:
name: "${CI_PROJECT_NAME}-${CI_COMMIT_REF_NAME}"
expire_in: 1 day
......@@ -209,6 +222,10 @@ deploy to production:
- ${DOCKER_CMD} service update --image ${CI_REGISTRY_IMAGE}:${GENESYS_VERSION}-${CI_COMMIT_REF_SLUG} genesys_server
- sleep 180
- ${DOCKER_CMD} service update --image ${CI_REGISTRY_IMAGE}:${GENESYS_VERSION}-${CI_COMMIT_REF_SLUG} genesys_standby
# Restart the server to sync with standby
- sleep 120
- docker service scale genesys_server=0
- docker service scale genesys_server=1
environment:
name: production
url: https://www.genesys-pgr.org
......@@ -78,24 +78,6 @@ module.exports = function(grunt) {
cwd : 'node_modules/notosans-fontface/fonts/',
src : '*',
dest : '<%= app.dist1 %>/styles/fonts'
}, {
// tinyMCE
expand : true,
cwd : 'node_modules/tinymce/skins',
src : [ '**' ],
dest : '<%= app.dist1 %>/js/skins'
}, {
// leaflet
expand : true,
cwd : 'node_modules/leaflet/dist/',
src : [ 'leaflet.css', 'images/*.png' ],
dest : '<%= app.dist1 %>/styles'
}, {
// simplecolorpicker
expand : true,
cwd : 'node_modules/jquery-simplecolorpicker/',
src : [ 'jquery.simplecolorpicker.css', 'jquery.simplecolorpicker-regularfont.css' ],
dest : '<%= app.dist1 %>/styles'
}, {
expand : true,
cwd : 'node_modules/jquery-ui-dist/',
......@@ -103,13 +85,6 @@ module.exports = function(grunt) {
dest : '<%= app.dist1 %>/styles'
} ]
}
// styles : {
// expand : true,
// cwd : '<%= app.source %>/styles',
// dest : '.tmp/styles/',
// src : '{,*/}*.css'
// }
},
// Make sure code styles are up to par and there are no obvious mistakes
......@@ -133,21 +108,8 @@ module.exports = function(grunt) {
dist1 : {
src : [
'node_modules/jquery/dist/jquery.js',
'node_modules/jquery-flot/jquery.flot.js',
'node_modules/jquery-flot/jquery.flot.pie.js',
'node_modules/jquery-flot/jquery.flot.fillbetween.js',
'node_modules/jquery-simplecolorpicker/jquery.simplecolorpicker.js',
'node_modules/tinymce/tinymce.js',
'node_modules/tinymce/tinymce.jquery.js',
'node_modules/tinymce/themes/modern/theme.js',
'node_modules/tinymce/plugins/link/plugin.js',
'node_modules/tinymce/plugins/autolink/plugin.js',
'node_modules/tinymce/plugins/code/plugin.js',
'node_modules/leaflet/dist/leaflet.js',
'node_modules/leaflet.locationfilter/src/locationfilter.js',
'node_modules/bootstrap-sass/assets/javascripts/bootstrap.js',
'node_modules/jquery-ui-dist/jquery-ui.js',
'node_modules/jstree/dist/jstree.js',
'node_modules/modernizr/bin/modernizr.js',
'node_modules/form-serializer/jquery.serialize-object.js'
],
......@@ -157,18 +119,9 @@ module.exports = function(grunt) {
src : [
'<%= app.source1 %>/js/prologue.js',
'<%= app.source1 %>/js/crophub.js',
'<%= app.source1 %>/js/browse.js',
'<%= app.source1 %>/js/epilogue.js'
],
dest : '<%= app.dist1 %>/js/genesys.js'
},
world1 : {
src : [
'node_modules/highmaps-release/highmaps.src.js',
'node_modules/highcharts/lib/modules/data.src.js',
'<%= app.source1 %>/js/world.js'
],
dest : '<%= app.dist1 %>/js/genesyshighcharts.js'
}
},
......@@ -196,18 +149,12 @@ module.exports = function(grunt) {
'<%= app.dist1 %>/styles/other.min.css' : [
'<%= app.dist1 %>/styles/jquery-ui.css',
'<%= app.dist1 %>/styles/forza.css',
'<%= app.dist1 %>/styles/leaflet.css',
'<%= app.dist1 %>/styles/jquery.simplecolorpicker.css',
'<%= app.dist1 %>/styles/jquery.simplecolorpicker-regularfont.css'
],
'<%= app.dist1 %>/styles/genesys.min.css' : [ '<%= app.dist1 %>/styles/genesys.css' ],
'<%= app.dist1 %>/styles/all.min.css' : [
'<%= app.dist1 %>/styles/bootstrap.css',
'<%= app.dist1 %>/styles/jquery-ui.css',
'<%= app.dist1 %>/styles/forza.css',
'<%= app.dist1 %>/styles/leaflet.css',
'<%= app.dist1 %>/styles/jquery.simplecolorpicker.css',
'<%= app.dist1 %>/styles/jquery.simplecolorpicker-regularfont.css',
'<%= app.dist1 %>/styles/genesys.css'
]
}
......@@ -251,7 +198,7 @@ module.exports = function(grunt) {
},
js1 : {
files : [ 'src/main/sourceapp/1/{,*/}*.js' ],
tasks : [ 'newer:jshint:dist1', 'concat:world1', 'concat:app1' ],
tasks : [ 'newer:jshint:dist1', 'concat:app1' ],
options : {
livereload : true
}
......@@ -265,7 +212,6 @@ module.exports = function(grunt) {
{ src : [ '<%= app.dist1 %>/js/libraries.min.js'], dest : '<%= app.dist1 %>/js/libraries.min.' + buildNumber + '.js' },
{ src : [ '<%= app.dist1 %>/js/libraries.js'], dest : '<%= app.dist1 %>/js/libraries.' + buildNumber + '.js' },
{ src : [ '<%= app.dist1 %>/js/genesys.js'], dest : '<%= app.dist1 %>/js/genesys.' + buildNumber + '.js' },
{ src : [ '<%= app.dist1 %>/js/genesyshighcharts.min.js'], dest : '<%= app.dist1 %>/js/genesyshighcharts.min.' + buildNumber + '.js' },
{ src : [ '<%= app.dist1 %>/styles/bootstrap.css'], dest : '<%= app.dist1 %>/styles/bootstrap.' + buildNumber + '.css' },
{ src : [ '<%= app.dist1 %>/styles/bootstrap.min.css'], dest : '<%= app.dist1 %>/styles/bootstrap.min.' + buildNumber + '.css' },
......@@ -283,7 +229,7 @@ module.exports = function(grunt) {
// grunt.loadNpmTasks('grunt-contrib-watch');
// grunt.loadNpmTasks('grunt-newer');
grunt.registerTask('build1', [ 'newer:jshint:dist1', 'compass:dist1', 'copy:dist1', 'concat:dist1', 'concat:world1', 'concat:app1', 'autoprefixer:dist1', 'uglify:dist1', 'cssmin:dist1' ]);
grunt.registerTask('build1', [ 'newer:jshint:dist1', 'compass:dist1', 'copy:dist1', 'concat:dist1', 'concat:app1', 'autoprefixer:dist1', 'uglify:dist1', 'cssmin:dist1' ]);
// grunt.registerTask('js', [ 'jshint:all', 'copy:dist', 'concat',
// 'autoprefixer', 'uglify:dist' ]);
// grunt.registerTask('css', [ 'compass:dist', 'copy:dist', 'concat',
......
#
# Build Genesys server on top of jetty-alpine
#
FROM jetty:9.4.11
FROM jetty:9-jre8
LABEL maintainer "Matija Obreza <matija.obreza@croptrust.org>"
......
......@@ -1384,16 +1384,6 @@
"integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=",
"dev": true
},
"highcharts": {
"version": "4.1.10",
"resolved": "https://registry.npmjs.org/highcharts/-/highcharts-4.1.10.tgz",
"integrity": "sha1-6TgCiIp76RHRI+2VO+CqqTl/0ew="
},
"highmaps-release": {
"version": "1.1.10",
"resolved": "https://registry.npmjs.org/highmaps-release/-/highmaps-release-1.1.10.tgz",
"integrity": "sha1-6oDB29dOe0Z292LNVfAfl1LHwf8="
},
"hooker": {
"version": "0.2.3",
"resolved": "https://registry.npmjs.org/hooker/-/hooker-0.2.3.tgz",
......@@ -1566,16 +1556,6 @@
"resolved": "https://registry.npmjs.org/jquery/-/jquery-2.1.4.tgz",
"integrity": "sha1-IoveaYoMYUMdwmMKahVPFYkNIxc="
},
"jquery-flot": {
"version": "0.8.3",
"resolved": "https://registry.npmjs.org/jquery-flot/-/jquery-flot-0.8.3.tgz",
"integrity": "sha1-onOs9D8TGQ9ueHAYae4kv+8Swio="
},
"jquery-simplecolorpicker": {
"version": "0.3.1",
"resolved": "https://registry.npmjs.org/jquery-simplecolorpicker/-/jquery-simplecolorpicker-0.3.1.tgz",
"integrity": "sha1-T2vv04CrBUcPWF1UguUYBVbkYOs="
},
"jquery-ui-dist": {
"version": "1.12.1",
"resolved": "https://registry.npmjs.org/jquery-ui-dist/-/jquery-ui-dist-1.12.1.tgz",
......@@ -1654,16 +1634,6 @@
"invert-kv": "^1.0.0"
}
},
"leaflet": {
"version": "0.7.7",
"resolved": "https://registry.npmjs.org/leaflet/-/leaflet-0.7.7.tgz",
"integrity": "sha1-HjUrpU5j0HZFH6NjyQCJDLLPde4="
},
"leaflet.locationfilter": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/leaflet.locationfilter/-/leaflet.locationfilter-0.1.0.tgz",
"integrity": "sha1-nqiQKVNkJhwKUvMcj34satVHOP4="
},
"livereload-js": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/livereload-js/-/livereload-js-2.3.0.tgz",
......@@ -2618,11 +2588,6 @@
}
}
},
"tinymce": {
"version": "4.1.10",
"resolved": "https://registry.npmjs.org/tinymce/-/tinymce-4.1.10.tgz",
"integrity": "sha1-XozIu2+9/+igw4eQb/RB96t49aA="
},
"tmp": {
"version": "0.0.28",
"resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.28.tgz",
......
This diff is collapsed.
This diff is collapsed.
......@@ -82,7 +82,7 @@ To add images to an accession you must first upload the image to Genesys with a
[source,bash]
----
$ curl 'https://sandbox.genesys-pgr.org/api/v0/img/XXX001/acn/ACC001/?originalFilename=IMG0012.jpg' -i -X PUT -H 'Content-Type: image/jpeg' -d @path/to/IMG0012.jpg
$ curl 'https://api.sandbox.genesys-pgr.org/api/v0/img/XXX001/acn/ACC001/?originalFilename=IMG0012.jpg' -i -X PUT -H 'Content-Type: image/jpeg' -d @path/to/IMG0012.jpg
----
The request `Content-Type` header must be set to the image content type (e.g.
......
......@@ -53,7 +53,7 @@ initiated by opening the authorization URL in a browser (please substitute `CLIE
with valid data):
----
https://sandbox.genesys-pgr.org/oauth/authorize?client_id=CLIENTID&client_secret=SECRET&response_type=code&redirect_uri=oob&scope=write
https://api.sandbox.genesys-pgr.org/oauth/authorize?client_id=CLIENTID&client_secret=SECRET&response_type=code&redirect_uri=oob&scope=write
----
The server will prompt you to authorize the access to your protected resources on Genesys.
......@@ -61,7 +61,7 @@ After your confirmation, the server will present an authorization code (which wi
From a shell, execute the following `curl` command, with your authorization code in place of `THECODE`:
----
$ curl 'https://sandbox.genesys-pgr.org/oauth/token?grant_type=authorization_code&client_id=CLIENTID&client_secret=SECRET&redirect_uri=oob&code=THECODE'
$ curl 'https://api.sandbox.genesys-pgr.org/oauth/token?grant_type=authorization_code&client_id=CLIENTID&client_secret=SECRET&redirect_uri=oob&code=THECODE'
----
==== Username and password
......@@ -71,7 +71,7 @@ applications) where the user's password will not be captured or stored -- i.e.
it will be used once. A password grant can be used as follows:
----
$ curl 'https://sandbox.genesys-pgr.org/oauth/token' --data 'scope=write+read&grant_type=password&username=USERNAME&password=PASSWORD&client_id=CLIENT_ID&client_secret=CLIENT_SECRET'
$ curl 'https://api.sandbox.genesys-pgr.org/oauth/token' --data 'scope=write+read&grant_type=password&username=USERNAME&password=PASSWORD&client_id=CLIENT_ID&client_secret=CLIENT_SECRET'
----
==== Client credentials
......@@ -93,7 +93,7 @@ To obtain a valid (but short-lived) access token, a simple `POST` request to
Genesys is required:
----
$ curl -X POST 'https://sandbox.genesys-pgr.org/oauth/token?grant_type=client_credentials&client_id=CLIENTID&client_secret=SECRET&redirect_uri=oob'
$ curl -X POST 'https://api.sandbox.genesys-pgr.org/oauth/token?grant_type=client_credentials&client_id=CLIENTID&client_secret=SECRET&redirect_uri=oob'
----
This type of grant takes out the *user* authentication and authenticates the
......@@ -132,7 +132,7 @@ or by including it in the request URL as a query string parameter:
[source,bash]
----
$ curl 'https://sandbox.genesys-pgr.org/api/v0/me?access_token=OAUTH-ACCESS-TOKEN'
$ curl 'https://api.sandbox.genesys-pgr.org/api/v0/me?access_token=OAUTH-ACCESS-TOKEN'
----
=== Using the refresh token
......@@ -156,7 +156,7 @@ The refresh token must be securely persisted and can be used to request a new ac
when the previous access token expires:
----
$ curl 'https://sandbox.genesys-pgr.org/oauth/token?grant_type=refresh_token&client_id=CLIENTID&client_secret=SECRET&redirect_uri=oob&refresh_token=OAUTH-REFRESH-TOKEN'
$ curl 'https://api.sandbox.genesys-pgr.org/oauth/token?grant_type=refresh_token&client_id=CLIENTID&client_secret=SECRET&redirect_uri=oob&refresh_token=OAUTH-REFRESH-TOKEN'
----
......
......@@ -13,9 +13,9 @@ December 2015: Documentation commit {buildNumber}
All API access is over HTTPS, and accessed from the https://www.genesys-pgr.org domain or
through https://sandbox.genesys-pgr.org for testing purposes. All data is sent and received as JSON.
In this manual, all URLs are pointing to the Genesys sandbox environment at https://sandbox.genesys-pgr.org.
All API access is over HTTPS, and accessed from the https://api.genesys-pgr.org domain or
through https://api.sandbox.genesys-pgr.org for testing purposes. All data is sent and received as JSON.
In this manual, all URLs are pointing to the Genesys sandbox environment at https://api.sandbox.genesys-pgr.org.
include::api/security.adoc[]
......
......@@ -14,9 +14,9 @@ March 2017: Documentation commit {buildNumber}
Genesys implements basic <<brapiv1, BrAPI v1 specification>>
All API access is over HTTPS, and accessed from the https://www.genesys-pgr.org domain or
through https://sandbox.genesys-pgr.org for testing purposes. All data is sent and received as JSON.
In this manual, all URLs are pointing to the Genesys sandbox environment at https://sandbox.genesys-pgr.org.
All API access is over HTTPS, and accessed from the https://api.genesys-pgr.org domain or
through https://api.sandbox.genesys-pgr.org for testing purposes. All data is sent and received as JSON.
In this manual, all URLs are pointing to the Genesys sandbox environment at https://api.sandbox.genesys-pgr.org.
include::brapi/auth.adoc[]
......
......@@ -2,12 +2,16 @@
== Authentication
All BrAPI requests can be made anonymously, without providing the OAuth2
*Bearer: <TOKEN>* authentication header.
All BrAPI requests require OAuth2 authentication header in HTTP requests:
----
Authorization: Bearer <TOKEN>
----
=== Login
Genesys does not support the `/login` endpoint.
Genesys does not support the `/login` endpoint. You must obtain the OAuth access token as described
in Genesys API manual.
=== Logout
......
......@@ -34,7 +34,7 @@ Genesys returns the standard BrAPI Germplasm response:
},
"result": <1> [{
"defaultDisplayName": "DJUG 16",
"germplasmPUI": null,
"germplasmPUI": "10.0000/ABCD*",
"pedigree": null,
"seedSource": null,
"synonyms": ["DJUG 16"],
......
......@@ -3,7 +3,8 @@
== Multi-crop Passport Descriptors
The http://www.bioversityinternational.org/e-library/publications/detail/faobioversity-multi-crop-passport-descriptors-v21-mcpd-v21/[Multi-crop Passport Descriptors (MCPD) V.2.1]
were released in 2012 as an update to the MCPD V.2. The MCPD V.2, in turn, was a 2001 revision of the first FAO/IPGRI publication,
were released in 2015 as an update to the MCPD V.2 from 2012.
The MCPD V.2, in turn, was a 2001 revision of the first FAO/IPGRI publication,
expanded to accommodate emerging needs such as the broader use of GPS tools and the
implementation of the http://www.planttreaty.org[International Treaty on Plant Genetic Resources for
Food and Agriculture] Multilateral System for access and benefit sharing.
......
......@@ -51,6 +51,13 @@ public class MapColorsFilter extends PointFilter {
public int filterRGB(int x, int y, int rgb) {
if (rgb == oldColor) {
return newColor;
} else if (rgb != 0) {
int alpha = (rgb >> 24) & 0xFF; // isolate alpha
alpha &= 0xff; //keeps alpha in 0-255 range
int newRGB = newColor;
newRGB &= 0x00ffffff; //remove old alpha info
newRGB |= (alpha << 24); //add new alpha info
return newRGB;
}
return rgb;
}
......
......@@ -13,19 +13,18 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.genesys2.server.service.filter;
import org.elasticsearch.index.query.QueryBuilder;
package org.apache.poi.xssf.streaming;
/**
* Filters able to generate Elasticsearch queries.
* IRowGenerator for Super-streaming XSSF sheets
*/
public interface ElasticsearchFilter {
public interface IRowGenerator {
/**
* Elastic query.
* Generate rows
*
* @return the query builder
* @param sheet the sheet
* @throws Exception the exception
*/
public QueryBuilder elasticQuery();
void generateRows(SXSSFSheet sheet) throws Exception;
}
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You 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.apache.poi.xssf.streaming;
import org.apache.poi.ss.formula.EvaluationCell;
import org.apache.poi.ss.formula.IStabilityClassifier;
import org.apache.poi.ss.formula.WorkbookEvaluator;
import org.apache.poi.ss.formula.udf.UDFFinder;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger;
import org.apache.poi.xssf.usermodel.BaseXSSFFormulaEvaluator;
/**
* Streaming-specific Formula Evaluator, which is able to
* lookup cells within the current Window.
*/
public final class SXSSFFormulaEvaluator extends BaseXSSFFormulaEvaluator {
private static final POILogger logger = POILogFactory.getLogger(SXSSFFormulaEvaluator.class);
private SXSSFWorkbook wb;
public SXSSFFormulaEvaluator(SXSSFWorkbook workbook) {
this(workbook, null, null);
}
private SXSSFFormulaEvaluator(SXSSFWorkbook workbook, IStabilityClassifier stabilityClassifier, UDFFinder udfFinder) {
this(workbook, new WorkbookEvaluator(SXSSFEvaluationWorkbook.create(workbook), stabilityClassifier, udfFinder));
}
private SXSSFFormulaEvaluator(SXSSFWorkbook workbook, WorkbookEvaluator bookEvaluator) {
super(bookEvaluator);
this.wb = workbook;
}
/**
* @param stabilityClassifier used to optimise caching performance. Pass <code>null</code>
* for the (conservative) assumption that any cell may have its definition changed after
* evaluation begins.
* @param udfFinder pass <code>null</code> for default (AnalysisToolPak only)
*/
public static SXSSFFormulaEvaluator create(SXSSFWorkbook workbook, IStabilityClassifier stabilityClassifier, UDFFinder udfFinder) {
return new SXSSFFormulaEvaluator(workbook, stabilityClassifier, udfFinder);
}
/**
* Turns a SXSSFCell into a SXSSFEvaluationCell
*/
@Override
protected EvaluationCell toEvaluationCell(Cell cell) {
if (!(cell instanceof SXSSFCell)){
throw new IllegalArgumentException("Unexpected type of cell: " + cell.getClass() + "." +
" Only SXSSFCells can be evaluated.");
}
return new SXSSFEvaluationCell((SXSSFCell)cell);
}
@Override
public SXSSFCell evaluateInCell(Cell cell) {
return (SXSSFCell) super.evaluateInCell(cell);
}
/**
* For active worksheets only, will loop over rows and
* cells, evaluating formula cells there.
* If formula cells are outside the window for that sheet,
* it can either skip them silently, or give an exception
*/
public static void evaluateAllFormulaCells(SXSSFWorkbook wb, boolean skipOutOfWindow) {
SXSSFFormulaEvaluator eval = new SXSSFFormulaEvaluator(wb);
// Check they're all available
for (Sheet sheet : wb) {
if (sheet instanceof SXSSFSheet && ((SXSSFSheet)sheet).areAllRowsFlushed()) {
throw new SheetsFlushedException();
}
}
// Process the sheets as best we can
for (Sheet sheet : wb) {
if (sheet instanceof SXSSFSheet) {
// Check if any rows have already been flushed out
int lastFlushedRowNum = ((SXSSFSheet) sheet).getLastFlushedRowNum();
if (lastFlushedRowNum > -1) {
if (! skipOutOfWindow) throw new RowFlushedException(0);
logger.log(POILogger.INFO, "Rows up to " + lastFlushedRowNum + " have already been flushed, skipping");
}
}
// Evaluate what we have
for (Row r : sheet) {
for (Cell c : r) {
if (c.getCellTypeEnum() == CellType.FORMULA) {
eval.evaluateFormulaCellEnum(c);
}
}
}
}
}
/**
* Loops over rows and cells, evaluating formula cells there.
* If any sheets are inactive, or any cells outside of the window,
* will give an Exception.
* For SXSSF, you generally don't want to use this method, instead
* evaluate your formulas as you go before they leave the window.
*/
public void evaluateAll() {
// Have the evaluation done, with exceptions
evaluateAllFormulaCells(wb, false);
}
public static class SheetsFlushedException extends IllegalStateException {
protected SheetsFlushedException() {
super("One or more sheets have been flushed, cannot evaluate all cells");
}
}
public static class RowFlushedException extends IllegalStateException {
protected RowFlushedException(int rowNum) {
super("Row " + rowNum + " has been flushed, cannot evaluate all cells");
}
}
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/*
* 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.apache.poi.xssf.streaming;
import java.io.BufferedWriter;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Writer;
import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger;
public class StreamingSheetWriter extends SheetDataWriter {
private static final POILogger logger = POILogFactory.getLogger(StreamingSheetWriter.class);
public StreamingSheetWriter() throws IOException {
throw new RuntimeException("StreamingSheetWriter requires OutputStream");
}
public StreamingSheetWriter(OutputStream out) throws IOException {
super(createWriter(out));
logger.log(POILogger.DEBUG, "Preparing SSXSSF sheet writer");
}
@Override
public File createTempFile() throws IOException {
throw new RuntimeException("Not supported with StreamingSheetWriter");
}
@Override
public Writer createWriter(File fd) throws IOException {
throw new RuntimeException("Not supported with StreamingSheetWriter");
}
/**
* Create a writer for the sheet data.
*
* @param out the output stream to write to
*/
protected static Writer createWriter(OutputStream out) throws IOException {
return new BufferedWriter(
new OutputStreamWriter(out, "UTF-8"));
}
@Override
public void close() throws IOException {
_out.flush();
}
@Override
public InputStream getWorksheetXMLInputStream() throws IOException {
throw new RuntimeException("Not supported with StreamingSheetWriter");
}
@Override
protected void finalize() throws Throwable {
// super.finalize();
}
@Override
boolean dispose() throws IOException {
try {
_out.close();
} finally {
}
return true;
}
}
/**
* Copyright 2014 Global Crop Diversity Trust
/*
* 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.
......@@ -12,43 +12,47 @@
* 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.apache.poi.xssf.streaming;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;
import java.util.Map;
import org.genesys2.server.model.genesys.AccessionId;
import org.genesys2.server.model.genesys.Metadata;
import org.genesys2.server.model.impl.FaoInstitute;
import org.springframework.data.repository.query.Param;
import org.springframework.security.access.prepost.PreAuthorize;
public interface DatasetService {
@PreAuthorize("isAuthenticated()")
List<Metadata> listMyMetadata();
@PreAuthorize("isAuthenticated()")
Metadata addDataset(FaoInstitute institute, String title, String description);
Metadata getDataset(long metadataId);
@PreAuthorize("hasRole('ADMINISTRATOR') or hasPermission(#metadata, 'WRITE')")
void touch(@Param("metadata") Metadata metadata);
void upsertAccessionData(Metadata metadata, AccessionId accession, Map<Long, List<Object>> methodValues);
/**
* Writes a Darwin Core Archive to the specified output stream
*
* @param metadata
* @param outputStream
* @throws IOException
*/
void writeDataset(Metadata metadata, OutputStream outputStream) throws IOException;
import org.apache.poi.xssf.usermodel.XSSFSheet;
public class SuperSXSSFSheet extends SXSSFSheet {
private IRowGenerator rowGenerator;
public SuperSXSSFSheet(SuperSXSSFWorkbook workbook, XSSFSheet xSheet) throws IOException {
super(workbook, xSheet, workbook.getRandomAccessWindowSize());
}
@Override
public InputStream getWorksheetXMLInputStream() throws IOException {
throw new RuntimeException("Not supported by SuperSXSSFSheet");
}
public void setRowGenerator(IRowGenerator rowGenerator) {
this.rowGenerator = rowGenerator;
}
public void writeRows(OutputStream out) throws IOException {
// delayed creation of SheetDataWriter
_writer = ((SuperSXSSFWorkbook)_workbook).createSheetDataWriter(out);
try {
if (this.rowGenerator != null) {
this.rowGenerator.generateRows(this);
}
} catch (Exception e) {
throw new IOException("Error generating Excel rows", e);
} finally {
// flush buffered rows
flushRows(0);
// flush writer buffer
_writer.close();
out.flush();
}
}
}
/*
* 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.apache.poi.xssf.streaming;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.util.Enumeration;