...
 
Commits (572)
......@@ -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
#
# Build Genesys server on top of jetty-alpine
#
FROM jetty:9.4.11
FROM jetty:9.4.12
LABEL maintainer "Matija Obreza <matija.obreza@croptrust.org>"
......
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.fasterxml.jackson</groupId>
<artifactId>jackson-base</artifactId>
<version>2.9.8</version>
</parent>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-hibernate-parent</artifactId>
<name>Hibernate module parent</name>
<version>2.9.9-SNAPSHOT</version>
<packaging>pom</packaging>
<description>Parent pom for shared settings for project sub-modules
</description>
<modules>
<module>hibernate3</module>
<module>hibernate4</module>
<module>hibernate5</module>
<!--
<module>hibernate5_2-test</module>
-->
</modules>
<url>https://github.com/FasterXML/jackson-datatype-hibernate</url>
<scm>
<connection>scm:git:git@github.com:FasterXML/jackson-datatype-hibernate.git</connection>
<developerConnection>scm:git:git@github.com:FasterXML/jackson-datatype-hibernate.git</developerConnection>
<url>http://github.com/FasterXML/jackson-datatype-hibernate</url>
<tag>HEAD</tag>
</scm>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<!-- But there are also some well-known test dependencies we may as well add directly -->
<!-- and for testing, JUnit is needed, as well as annotations -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<!-- Alas, need to include snapshot reference since otherwise can not find
snapshot of parent... -->
<repositories>
<repository>
<id>sonatype-nexus-snapshots</id>
<name>Sonatype Nexus Snapshots</name>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
<releases><enabled>false</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
<build>
<pluginManagement>
<plugins>
<plugin>
<!-- Inherited from oss-base. Generate PackageVersion.java.-->
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>replacer</artifactId>
<executions>
<execution>
<id>process-packageVersion</id>
<phase>generate-sources</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<excludes>
<exclude>com/fasterxml/jackson/**/failing/*.java</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-hibernate-parent</artifactId>
<version>2.9.9-SNAPSHOT</version>
</parent>
<artifactId>jackson-datatype-hibernate4</artifactId>
<name>Jackson-datatype-Hibernate4</name>
<packaging>bundle</packaging>
<description>Add-on module for Jackson (http://jackson.codehaus.org) to support
Hibernate (http://hibernate.org) version 4.x data types.
</description>
<url>https://github.com/FasterXML/jackson-datatype-hibernate</url>
<properties>
<!-- Generate PackageVersion.java into this directory. -->
<packageVersion.dir>com/fasterxml/jackson/datatype/hibernate4</packageVersion.dir>
<packageVersion.package>${project.groupId}.hibernate4</packageVersion.package>
<!-- Hibernate with JPA 2.0 -->
<hibernate.version>4.1.0.Final</hibernate.version>
<surefire.version>2.12</surefire.version>
<osgi.export>${project.groupId}.hibernate4</osgi.export>
</properties>
<dependencies>
<!-- what would be the best scope to use here? -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>${hibernate.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>${hibernate.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.6.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.3.155</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<!-- Inherited from oss-base. Generate PackageVersion.java.-->
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>replacer</artifactId>
<executions>
<execution>
<id>process-packageVersion</id>
<phase>generate-sources</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
......@@ -58,7 +58,7 @@
<snippetsDirectory>${project.build.directory}/generated-snippets</snippetsDirectory>
<junit.version>4.12</junit.version>
<application.blocks.version>1.4-SNAPSHOT</application.blocks.version>
<application.blocks.version>1.6-SNAPSHOT</application.blocks.version>
<commons.beanutils.version>1.9.2</commons.beanutils.version>
<commons.collections.version>3.2.1</commons.collections.version>
<commons.io.version>2.4</commons.io.version>
......@@ -76,11 +76,11 @@
<spring.security.oauth2.version>2.3.3.RELEASE</spring.security.oauth2.version>
<spring-security-jwt>1.0.8.RELEASE</spring-security-jwt>
<org.springframework.social-version>1.1.4.RELEASE</org.springframework.social-version>
<org.springframework.social-google-version>1.0.0.RELEASE</org.springframework.social-google-version>
<querydsl.version>4.1.4</querydsl.version>
<hibernate.version>4.3.11.Final</hibernate.version>
<hsqldb.version>2.3.6</hsqldb.version>
<hibernate.validator.version>5.2.5.Final</hibernate.validator.version>
<hsqldb.version>2.4.1</hsqldb.version>
<ehcache.version>2.7.4</ehcache.version>
<slf4j.version>1.7.25</slf4j.version>
......@@ -91,13 +91,13 @@
<hazelcast.version>3.8.1</hazelcast.version>
<oval.version>1.81</oval.version>
<jackson.version>2.9.6</jackson.version>
<jackson.version>2.9.8</jackson.version>
<jaxb-api.version>2.2.12</jaxb-api.version>
<liquibase.version>3.6</liquibase.version>
<swagger.version>2.9.2</swagger.version>
<!--Container -->
<jetty.version>9.4.11.v20180605</jetty.version>
<jetty.version>9.4.12.v20180830</jetty.version>
<maven.test.skip>false</maven.test.skip>
......@@ -124,6 +124,12 @@
<version>2.6</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
<version>1.5</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
......@@ -165,7 +171,7 @@
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.10</version>
<version>1.11</version>
</dependency>
<dependency>
......@@ -197,7 +203,7 @@
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>javax.servlet.jsp-api</artifactId>
<version>2.3.1</version>
<version>2.3.2-b01</version>
<scope>provided</scope>
</dependency>
<dependency>
......@@ -227,10 +233,16 @@
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-jsonSchema</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-hibernate4</artifactId>
<version>${jackson.version}</version>
<version>2.9.9-SNAPSHOT</version>
</dependency>
......@@ -301,6 +313,16 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.javacrumbs.shedlock</groupId>
<artifactId>shedlock-spring</artifactId>
<version>2.2.0</version>
</dependency>
<dependency>
<groupId>net.javacrumbs.shedlock</groupId>
<artifactId>shedlock-provider-hazelcast</artifactId>
<version>0.18.2</version>
</dependency>
<dependency>
<groupId>com.querydsl</groupId>
<artifactId>querydsl-jpa</artifactId>
......@@ -375,12 +397,12 @@
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-jdbc</artifactId>
<version>7.0.42</version>
<version>7.0.47</version>
</dependency>
<dependency>
<groupId>com.googlecode.owasp-java-html-sanitizer</groupId>
<artifactId>owasp-java-html-sanitizer</artifactId>
<version>r209</version>
<version>r223</version>
</dependency>
<dependency>
<groupId>org.springframework.security.oauth</groupId>
......@@ -390,12 +412,12 @@
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.9.3</version>
<version>2.9.4</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
<version>4.0</version>
<version>4.2</version>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
......@@ -428,7 +450,7 @@
<dependency>
<groupId>org.jamel.dbf</groupId>
<artifactId>dbf-reader</artifactId>
<version>0.1.0</version>
<version>0.2.0</version>
<scope>test</scope>
</dependency>
<dependency>
......@@ -437,11 +459,16 @@
<version>${jetty.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>2.4.6</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-elasticsearch</artifactId>
<version>2.1.12.RELEASE</version>
<version>2.1.16.RELEASE</version>
</dependency>
<dependency>
......@@ -458,12 +485,12 @@
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.10.1</version>
<version>3.17</version>
</dependency>
<dependency>
<groupId>org.ocpsoft.prettytime</groupId>
<artifactId>prettytime</artifactId>
<version>3.2.5.Final</version>
<version>3.2.7.Final</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
......@@ -478,7 +505,7 @@
<dependency>
<groupId>org.genesys-pgr</groupId>
<artifactId>worldclim-reader</artifactId>
<version>0.0.4</version>
<version>0.0.5-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.genesys-pgr</groupId>
......@@ -488,7 +515,7 @@
<dependency>
<groupId>org.genesys-pgr</groupId>
<artifactId>file-repository-ftpserver</artifactId>
<version>1.0-SNAPSHOT</version>
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.freemarker</groupId>
......@@ -498,12 +525,12 @@
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.8.3</version>
<version>1.9.1</version>
</dependency>
<dependency>
<groupId>com.opencsv</groupId>
<artifactId>opencsv</artifactId>
<version>3.7</version>
<version>3.8</version>
</dependency>
<dependency>
<groupId>org.liquibase.ext</groupId>
......@@ -519,7 +546,7 @@
<dependency>
<groupId>org.genesys-pgr</groupId>
<artifactId>glis-client-resttemplate</artifactId>
<version>1.1-SNAPSHOT</version>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>org.apache-extras.beanshell</groupId>
......@@ -529,7 +556,7 @@
<dependency>
<groupId>com.vladsch.flexmark</groupId>
<artifactId>flexmark-all</artifactId>
<version>0.28.34</version>
<version>0.28.38</version>
</dependency>
<dependency>
<groupId>com.vdurmont</groupId>
......@@ -538,23 +565,16 @@
</dependency>
<dependency>
<groupId>org.springframework.social</groupId>
<artifactId>spring-social-google</artifactId>
<version>${org.springframework.social-google-version}</version>
<groupId>com.google.api-client</groupId>
<artifactId>google-api-client</artifactId>
<version>1.27.0</version>
</dependency>
<dependency>
<groupId>org.springframework.social</groupId>
<artifactId>spring-social-web</artifactId>
<version>${org.springframework.social-version}</version>
</dependency>
<dependency>
<groupId>org.springframework.social</groupId>
<artifactId>spring-social-core</artifactId>
<version>${org.springframework.social-version}</version>
</dependency>
<!--Test dependencies -->
<dependency>
<groupId>org.hamcrest</groupId>
......@@ -565,7 +585,7 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>2.19.0</version>
<version>2.19.1</version>
<scope>test</scope>
</dependency>
<dependency>
......@@ -577,13 +597,13 @@
<dependency>
<groupId>org.springframework.restdocs</groupId>
<artifactId>spring-restdocs-mockmvc</artifactId>
<version>1.2.4.RELEASE</version>
<version>1.2.5.RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path</artifactId>
<version>2.0.0</version>
<version>2.1.0</version>
<scope>test</scope>
</dependency>
<dependency>
......@@ -595,7 +615,42 @@
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId>
<version>4.5.2</version>
<version>5.0.0</version>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.1.0.Final</version>
</dependency>
<dependency>
<groupId>javax.el</groupId>
<artifactId>javax.el-api</artifactId>
<version>3.0.1-b01</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>${hibernate.validator.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator-annotation-processor</artifactId>
<version>${hibernate.validator.version}</version>
</dependency>
<dependency>
<groupId>cz.jirutka.validator</groupId>
<artifactId>validator-collection</artifactId>
<version>2.2.0</version>
</dependency>
<dependency>
<groupId>org.genesys-pgr</groupId>
<artifactId>amphibian-client-resttemplate</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.hashids</groupId>
<artifactId>hashids</artifactId>
<version>1.0.3</version>
</dependency>
</dependencies>
......@@ -941,6 +996,10 @@
</build>
<repositories>
<repository>
<id>my-local-repo</id>
<url>file://${basedir}/lib</url>
</repository>
<repository>
<id>central</id>
<url>https://repo.maven.apache.org/maven2</url>
......
......@@ -2,8 +2,11 @@
== 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
......
......@@ -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,15 +13,18 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.genesys2.server.api;
package org.apache.poi.xssf.streaming;
/**
* Used sometimes
* IRowGenerator for Super-streaming XSSF sheets
*/
public class ApiResult {
public boolean result = false;
public ApiResult(boolean b) {
result = b;
}
public interface IRowGenerator {
/**
* Generate rows
*
* @param sheet the sheet
* @throws Exception the exception
*/
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.