Commit bf2e677e authored by Andrey Lugovskiy's avatar Andrey Lugovskiy
Browse files

-Need some adjustments for viewing

parent a4d9039b
Pipeline #491 passed with stage
in 40 seconds
/target/
/taxonomy_data/
taxonomy_data/
.classpath
/bin/
.settings
......
package org.genesys2.gringlobal.taxonomy.config;
import org.genesys2.gringlobal.taxonomy.component.InMemoryTaxonomyDatabase;
import org.genesys2.gringlobal.taxonomy.component.TaxonomyChecker;
import org.genesys2.gringlobal.taxonomy.service.CachingInMemoryTaxonomyDatabase;
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
......@@ -13,7 +16,6 @@ import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import org.springframework.web.servlet.i18n.CookieLocaleResolver;
import org.springframework.web.servlet.i18n.LocaleChangeInterceptor;
import org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping;
import org.springframework.web.servlet.view.InternalResourceViewResolver;
import org.springframework.web.servlet.view.JstlView;
......@@ -75,4 +77,13 @@ public class WebConfiguration extends WebMvcConfigurerAdapter {
return resource;
}
@Bean(name = "taxonomyDatabase")
public InMemoryTaxonomyDatabase getTaxonomyDatabase() {
return new CachingInMemoryTaxonomyDatabase();
}
@Bean(name = "taxonomyChecker")
public TaxonomyChecker getTaxonomyChecker() {
return new TaxonomyChecker();
}
}
......@@ -34,11 +34,15 @@ public class ApplicationController {
@RequestMapping(value = "process", method = RequestMethod.POST)
public String process(@RequestParam MultipartFile file,
@RequestParam(name = "separator", required = false, defaultValue = ",") String separator,
@RequestParam(name = "separator", required = false, defaultValue = ",") Character separator,
@RequestParam(name = "quoteChar", required = false, defaultValue = "\"") Character quoteChar,
@RequestParam(name = "escapeChar", required = false, defaultValue = "0") Character escapeChar,
@RequestParam(name = "coyFromExcel", required = false, defaultValue = "") String coyFromExcel,
@RequestParam(name = "toCurrentTaxa", required = false) Boolean toCurrentTaxa,
ModelMap model) throws IOException, ParseException, TaxonomyException {
model.addAttribute("result", processService.process(file, separator, coyFromExcel, toCurrentTaxa));
model.addAttribute("result", processService.process(file, separator, quoteChar, escapeChar, coyFromExcel, toCurrentTaxa).toString());
model.addAttribute("newLineSymbol", "\n");
model.addAttribute("symbolQuote", "\"");
return "result";
}
}
/*
* Copyright 2016 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.gringlobal.taxonomy.service;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import org.genesys2.gringlobal.taxonomy.component.InMemoryTaxonomyDatabase;
import org.genesys2.gringlobal.taxonomy.model.SpeciesRow;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
/**
* Guava cache supported in-memory taxonomy database.
*/
public class CachingInMemoryTaxonomyDatabase extends InMemoryTaxonomyDatabase {
// private final static Logger LOG = LoggerFactory.getLogger(CachingInMemoryTaxonomyDatabase.class);
/** The cache genus species. */
private Cache<String, List<SpeciesRow>> cacheGenusSpecies = CacheBuilder.newBuilder().maximumSize(100).build();
/** The cache genus suggestions. */
private Cache<String, List<String>> cacheGenusSuggestions = CacheBuilder.newBuilder().maximumSize(100).build();
/** The cache species suggestions. */
private Cache<String, List<String>> cacheSpeciesSuggestions = CacheBuilder.newBuilder().maximumSize(100).build();
/*
* (non-Javadoc)
*
* @see org.genesys2.gringlobal.taxonomy.component.InMemoryTaxonomyDatabase#getAllGenusSpecies(java.lang.String)
*/
@Override
protected List<SpeciesRow> getAllGenusSpecies(String genus) {
try {
return cacheGenusSpecies.get(genus, new Callable<List<SpeciesRow>>() {
@Override
public List<SpeciesRow> call() throws Exception {
return CachingInMemoryTaxonomyDatabase.super.getAllGenusSpecies(genus);
}
});
} catch (ExecutionException e) {
throw new RuntimeException(e);
}
}
/*
* (non-Javadoc)
*
* @see org.genesys2.gringlobal.taxonomy.component.InMemoryTaxonomyDatabase#findSimilarGenus(java.lang.String, int)
*/
@Override
public List<String> findSimilarGenus(String genus, int maxSize) {
try {
return cacheGenusSuggestions.get(genus + "-" + maxSize, new Callable<List<String>>() {
@Override
public List<String> call() throws Exception {
return CachingInMemoryTaxonomyDatabase.super.findSimilarGenus(genus, maxSize);
}
});
} catch (ExecutionException e) {
throw new RuntimeException(e);
}
}
/*
* (non-Javadoc)
*
* @see org.genesys2.gringlobal.taxonomy.component.InMemoryTaxonomyDatabase#findSimilarSpecies(java.lang.String, java.lang.String, int)
*/
@Override
public List<String> findSimilarSpecies(String genus, String species, int maxSize) {
try {
return cacheSpeciesSuggestions.get(genus + "-" + species + "-" + maxSize, new Callable<List<String>>() {
@Override
public List<String> call() throws Exception {
return CachingInMemoryTaxonomyDatabase.super.findSimilarSpecies(genus, species, maxSize);
}
});
} catch (ExecutionException e) {
throw new RuntimeException(e);
}
}
}
package org.genesys2.gringlobal.taxonomy.service;
import org.genesys2.gringlobal.taxonomy.component.TaxonomyException;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.io.StringWriter;
import java.text.ParseException;
/**
* Created by Lugovskoy Andrey.
*/
......@@ -11,6 +16,7 @@ public interface ProcessService {
* Method parse csv.
* @return String result
*/
String process(MultipartFile file, String separator, String coyFromExcel, Boolean toCurrentTaxa);
StringWriter process(MultipartFile file, Character separator, Character quoteChar, Character escapeChar,
String coyFromExcel, Boolean toCurrentTaxa) throws ParseException, IOException, TaxonomyException;
}
package org.genesys2.gringlobal.taxonomy.service.impl;
import com.opencsv.CSVReader;
import com.opencsv.CSVWriter;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.genesys2.gringlobal.taxonomy.component.InMemoryTaxonomyDatabase;
import org.genesys2.gringlobal.taxonomy.component.TaxonomyChecker;
import org.genesys2.gringlobal.taxonomy.component.TaxonomyException;
import org.genesys2.gringlobal.taxonomy.component.TaxonomyReader;
import org.genesys2.gringlobal.taxonomy.config.ApplicationProperties;
import org.genesys2.gringlobal.taxonomy.model.GenusRow;
import org.genesys2.gringlobal.taxonomy.model.SpeciesRow;
import org.genesys2.gringlobal.taxonomy.service.ProcessService;
import org.genesys2.gringlobal.taxonomy.util.ApplicationUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import java.io.*;
import java.text.ParseException;
import java.util.*;
/**
* Created by Lugovskoy Andrey.
*/
@Service
public class ProcessServiceImpl implements ProcessService{
public class ProcessServiceImpl implements ProcessService {
private final static Logger LOG = LoggerFactory.getLogger(ProcessServiceImpl.class);
@Autowired
private ApplicationProperties applicationProperties;
@Autowired
private InMemoryTaxonomyDatabase taxonomyDatabase;
@Autowired
private TaxonomyChecker taxonomyChecker;
@Override
public String process(MultipartFile file, String separator, String coyFromExcel, Boolean toCurrentTaxa) {
public StringWriter process(MultipartFile file, Character separator, Character quoteChar, Character escapeChar,
String coyFromExcel, Boolean toCurrentTaxa) throws ParseException, IOException, TaxonomyException {
LOG.info("Start process with file: '{}', separator: '{}', coyFromExcel: '{}', toCurrentTaxa: '{}'",
file.getOriginalFilename(), separator, coyFromExcel, toCurrentTaxa);
return "Parse result";
readDatabase(applicationProperties.getDatabaseFolderPath());
return run(file.getInputStream(), separator, quoteChar, escapeChar, coyFromExcel, toCurrentTaxa);
}
private void readDatabase(String path) throws UnsupportedEncodingException, FileNotFoundException, IOException, ParseException, TaxonomyException {
File rootDir = new File(path);
LOG.info("Loading TAXONOMY_GENUS.txt");
// read TAXONOMY_GENUS.txt
try (CSVReader reader = TaxonomyReader.openCsvReader(new InputStreamReader(new FileInputStream(new File(rootDir, "TAXONOMY_GENUS.txt")), "UTF-8"), 1)) {
GenusRow genusRow = null;
while ((genusRow = TaxonomyReader.toGenus(reader.readNext())) != null) {
taxonomyDatabase.registerGenus(genusRow.getGenusId(), genusRow.getGenusName());
}
}
LOG.info("Loading TAXONOMY_SPECIES.txt");
// read TAXONOMY_SPECIES.txt
try (CSVReader reader = TaxonomyReader.openCsvReader(new InputStreamReader(new FileInputStream(new File(rootDir, "TAXONOMY_SPECIES.txt")), "UTF-8"), 1)) {
SpeciesRow speciesRow = null;
while ((speciesRow = TaxonomyReader.toSpecies(reader.readNext())) != null) {
taxonomyDatabase.registerSpecies(speciesRow);
}
}
}
private StringWriter run(InputStream inputStream, Character separator, Character quoteChar, Character escapeChar,
String coyFromExcel, Boolean toCurrentTaxa)
throws UnsupportedEncodingException, FileNotFoundException, IOException {
StringWriter stringWriter = new StringWriter();
taxonomyChecker.setTaxonomyDatabase(taxonomyDatabase);
LOG.info("Running the validation against {}", taxonomyDatabase);
try (CSVReader reader = new CSVReader(new InputStreamReader(inputStream, "UTF-8"), separator,
quoteChar, escapeChar, 0, false, true, false)) {
String[] headers = reader.readNext();
LOG.debug("Input CSV headers: {}", Arrays.toString(headers));
{
// Check for _check headers and exit if necessary
boolean err = false;
for (String header : new String[]{ApplicationUtils.HEADER_GENUS_CHECK,
ApplicationUtils.HEADER_SPECIES_CHECK, ApplicationUtils.HEADER_SPAUTHOR_CHECK,
ApplicationUtils.HEADER_SUBTAXA_CHECK, ApplicationUtils.HEADER_SUBTAUTHOR_CHECK}) {
LOG.info("Must not find header {} in {}", header, Arrays.asList(headers));
int pos = ArrayUtils.indexOf(headers, header);
if (pos >= 0) {
LOG.error("Header {} found in input CSV.", header);
err = true;
}
}
if (err) {
throw new IOException("_check headers found in input file. Refusing to run.");
}
}
List<String> outputHeaders = new ArrayList<>(Arrays.asList(headers));
LOG.debug("Starting output headers: {}", outputHeaders);
final String[] checkerHeaders = {
ApplicationUtils.HEADER_GENUS, ApplicationUtils.HEADER_SPECIES,
ApplicationUtils.HEADER_SPAUTHOR, ApplicationUtils.HEADER_SUBTAXA, ApplicationUtils.HEADER_SUBTAUTHOR
};
Map<String, Integer> sourceMapping = new HashMap<>();
List<Integer> outputMapping = new ArrayList<>();
{
int col = 0;
for (String header : headers) {
LOG.debug("Mapping output column={} to index={}", header, col);
outputMapping.add(col++);
}
}
LOG.debug("Source mapping indexes: {}", outputMapping);
LOG.debug("1 Output headers: {}", outputHeaders);
Arrays.stream(checkerHeaders).forEach(header -> {
LOG.debug("Looking for header {} in {}", header, Arrays.asList(headers));
int pos = ArrayUtils.indexOf(headers, header);
if (pos >= 0) {
LOG.debug("Header {} is in position {}", header, pos);
sourceMapping.put(header, pos);
} else {
LOG.info("No header {}", header);
}
pos = outputHeaders.indexOf(header);
if (pos >= 0) {
LOG.info("Adding {}_check at pos={}", header, pos + 1);
outputHeaders.add(pos + 1, header + "_check");
outputMapping.add(pos + 1, null);
LOG.info("Output headers: {}", outputHeaders);
}
});
// Insert extras
if (outputHeaders.contains(ApplicationUtils.HEADER_GENUS) && outputHeaders.contains(
ApplicationUtils.HEADER_SPECIES)) {
if (!outputHeaders.contains(ApplicationUtils.HEADER_SPAUTHOR_CHECK)) {
LOG.debug("Adding {} because it's missing", ApplicationUtils.HEADER_SPAUTHOR_CHECK);
outputHeaders.add(outputHeaders.indexOf(ApplicationUtils.HEADER_SPECIES) + 1,
ApplicationUtils.HEADER_SPAUTHOR_CHECK);
outputMapping.add(outputHeaders.indexOf(ApplicationUtils.HEADER_SPAUTHOR_CHECK) + 1, null);
}
if (outputHeaders.contains(ApplicationUtils.HEADER_SUBTAXA)) {
if (!outputHeaders.contains(ApplicationUtils.HEADER_SUBTAUTHOR_CHECK)) {
LOG.debug("Adding {} because it's missing", ApplicationUtils.HEADER_SUBTAUTHOR_CHECK);
outputHeaders.add(outputHeaders.size(), ApplicationUtils.HEADER_SUBTAUTHOR_CHECK);
outputMapping.add(outputHeaders.indexOf(ApplicationUtils.HEADER_SUBTAUTHOR_CHECK) + 1, null);
}
}
LOG.debug("Adding {}", ApplicationUtils.HEADER_GRINTAX_SPECIESCURRENT);
outputHeaders.add(outputHeaders.indexOf(ApplicationUtils.HEADER_SPECIES_CHECK) + 1,
ApplicationUtils.HEADER_GRINTAX_SPECIESCURRENT);
outputMapping.add(outputHeaders.indexOf(ApplicationUtils.HEADER_SPECIES_CHECK) + 1, null);
LOG.debug("Adding {}", ApplicationUtils.HEADER_GRINTAX_SPECIESID);
outputHeaders.add(outputHeaders.indexOf(ApplicationUtils.HEADER_SPECIES_CHECK) + 1,
ApplicationUtils.HEADER_GRINTAX_SPECIESID);
outputMapping.add(outputHeaders.indexOf(ApplicationUtils.HEADER_SPECIES_CHECK) + 1, null);
}
LOG.info("Output headers: {}", outputHeaders);
LOG.info("Source mapping indexes: {}", outputMapping);
try (CSVWriter writer = new CSVWriter(stringWriter, separator, quoteChar, escapeChar, "\n")) {
writer.writeNext(outputHeaders.toArray(ArrayUtils.EMPTY_STRING_ARRAY));
String[] sourceLine;
while ((sourceLine = reader.readNext()) != null) {
if (LOG.isDebugEnabled()) {
LOG.debug("\n\n");
LOG.debug(Arrays.toString(sourceLine));
}
String[] outputLine = new String[outputHeaders.size()];
for (int outputCol = 0; outputCol < outputMapping.size(); outputCol++) {
Integer mapped = outputMapping.get(outputCol);
if (mapped != null)
try {
outputLine[outputCol] = sourceLine[mapped];
} catch (IndexOutOfBoundsException e) {
outputLine[outputCol] = "";
}
}
String genus = sourceMapping.get(ApplicationUtils.HEADER_GENUS) == null ? null : sourceLine[sourceMapping.get(ApplicationUtils.HEADER_GENUS)];
String species = sourceMapping.get(ApplicationUtils.HEADER_SPECIES) == null ? null : sourceLine[sourceMapping.get(ApplicationUtils.HEADER_SPECIES)];
String subtaxa = sourceMapping.get(ApplicationUtils.HEADER_SUBTAXA) == null ? null : sourceLine[sourceMapping.get(ApplicationUtils.HEADER_SUBTAXA)];
String spAuthor = sourceMapping.get(ApplicationUtils.HEADER_SPAUTHOR) == null ? null : sourceLine[sourceMapping.get(ApplicationUtils.HEADER_SPAUTHOR)];
String subtAuthor = sourceMapping.get(ApplicationUtils.HEADER_SUBTAUTHOR) == null ? null : sourceLine[sourceMapping.get(ApplicationUtils.HEADER_SUBTAUTHOR)];
if (outputHeaders.indexOf(ApplicationUtils.HEADER_GENUS_CHECK) >= 0) {
String genus_check = taxonomyChecker.suggestGenus(genus, 5).stream().reduce(null,
(prev, suggestion) -> prev == null ? suggestion : prev + ";" + suggestion);
if (LOG.isTraceEnabled())
LOG.trace("GENUS_check: {}", StringUtils.defaultIfBlank(genus_check, "NULL"));
outputLine[outputHeaders.indexOf(ApplicationUtils.HEADER_GENUS_CHECK)] = StringUtils.equals(genus, genus_check) ? ApplicationUtils.CHECK_PASSED : genus_check;
}
if (outputHeaders.indexOf(ApplicationUtils.HEADER_SPECIES_CHECK) >= 0) {
String species_check = taxonomyChecker.suggestSpecies(genus, species, 5).stream().reduce(null,
(prev, suggestion) -> prev == null ? suggestion : prev + ";" + suggestion);
if (LOG.isTraceEnabled())
LOG.trace("SPECIES_check: {}", StringUtils.defaultIfBlank(species_check, "NULL"));
outputLine[outputHeaders.indexOf(ApplicationUtils.HEADER_SPECIES_CHECK)] = StringUtils.equals(species, species_check) ? ApplicationUtils.CHECK_PASSED : species_check;
}
if (outputHeaders.indexOf(ApplicationUtils.HEADER_SPAUTHOR_CHECK) >= 0) {
String spauthor_check = taxonomyChecker.getSpeciesAuthority(genus, species);
if (LOG.isTraceEnabled())
LOG.trace("SPAUTHOR_check: {}", StringUtils.defaultIfBlank(spauthor_check, "NULL"));
// Add if needed
if (sourceMapping.get(ApplicationUtils.HEADER_SPAUTHOR) != null) {
// System.err.println(spAuthor + " " + spauthor_check);
outputLine[outputHeaders.indexOf(ApplicationUtils.HEADER_SPAUTHOR_CHECK)] = StringUtils.equals(spAuthor, spauthor_check) ? ApplicationUtils.CHECK_PASSED : spauthor_check;
} else {
// System.err.println("Not here " + sourceMapping.get(HEADER_SPAUTHOR) + " " +
// spauthor_check);
outputLine[outputHeaders.indexOf(ApplicationUtils.HEADER_SPAUTHOR_CHECK)] = spauthor_check;
}
}
if (outputHeaders.indexOf(ApplicationUtils.HEADER_SUBTAXA_CHECK) >= 0) {
String subtaxa_check = taxonomyChecker.suggestSubtaxa(genus, species, subtaxa, 5).stream().reduce(null,
(prev, suggestion) -> prev == null ? suggestion : prev + ";" + suggestion);
if (LOG.isTraceEnabled())
LOG.trace("SPECIES_check: {}", StringUtils.defaultIfBlank(subtaxa_check, "NULL"));
outputLine[outputHeaders.indexOf(ApplicationUtils.HEADER_SUBTAXA_CHECK)] = StringUtils.equals(subtaxa, subtaxa_check) ? ApplicationUtils.CHECK_PASSED : subtaxa_check;
}
if (outputHeaders.indexOf(ApplicationUtils.HEADER_SUBTAUTHOR_CHECK) >= 0) {
String subtauthor_check = taxonomyChecker.getSubtaxaAuthority(genus, species, subtaxa);
if (LOG.isTraceEnabled())
LOG.trace("SUBTAUTHOR_check: {}", StringUtils.defaultIfBlank(subtauthor_check, "NULL"));
// Add if needed
if (sourceMapping.get(ApplicationUtils.HEADER_SUBTAUTHOR) != null) {
outputLine[outputHeaders.indexOf(ApplicationUtils.HEADER_SUBTAUTHOR_CHECK)] = StringUtils.equals(subtAuthor, subtauthor_check) ? ApplicationUtils.CHECK_PASSED : subtauthor_check;
} else {
outputLine[outputHeaders.indexOf(ApplicationUtils.HEADER_SUBTAUTHOR_CHECK)] = subtauthor_check;
}
}
if (outputHeaders.indexOf(ApplicationUtils.HEADER_GRINTAX_SPECIESID) >= 0) {
List<SpeciesRow> speciesRows = taxonomyDatabase.findSpeciesRow(genus, species, StringUtils.defaultIfBlank(subtaxa, null));
if (speciesRows.size() == 1) {
SpeciesRow speciesRow = speciesRows.get(0);
outputLine[outputHeaders.indexOf(ApplicationUtils.HEADER_GRINTAX_SPECIESID)] = speciesRow.getSpeciesId().toString();
outputLine[outputHeaders.indexOf(ApplicationUtils.HEADER_GRINTAX_SPECIESCURRENT)] = Boolean.toString(speciesRow.isCurrent());
if (!speciesRow.isCurrent() && toCurrentTaxa) {
LOG.debug("{} is not current", speciesRow);
SpeciesRow currentSpecies = taxonomyDatabase.getSpeciesRow(speciesRow.getCurrentSpeciesId());
String currentGenus = taxonomyDatabase.getGenus(currentSpecies.getGenusId());
// LOG.warn("Result: {}", Arrays.toString(outputLine));
updateOutputColumn(outputLine, outputHeaders.indexOf(ApplicationUtils.HEADER_GENUS_CHECK), currentGenus, genus, ApplicationUtils.CURRENT_SUFFIX);
updateOutputColumn(outputLine, outputHeaders.indexOf(ApplicationUtils.HEADER_SPECIES_CHECK), currentSpecies.getSpeciesName(), species, ApplicationUtils.CURRENT_SUFFIX);
updateOutputColumn(outputLine, outputHeaders.indexOf(ApplicationUtils.HEADER_SPAUTHOR_CHECK),
StringUtils.defaultIfBlank(currentSpecies.getSpeciesAuthority(), ApplicationUtils.SUGGESTION_BLANK), spAuthor, ApplicationUtils.CURRENT_SUFFIX);
updateOutputColumn(outputLine, outputHeaders.indexOf(ApplicationUtils.HEADER_SUBTAXA_CHECK),
StringUtils.defaultIfBlank(currentSpecies.getSubtaxa(), ApplicationUtils.SUGGESTION_BLANK), subtaxa, ApplicationUtils.CURRENT_SUFFIX);
updateOutputColumn(outputLine, outputHeaders.indexOf(ApplicationUtils.HEADER_SUBTAUTHOR_CHECK),
StringUtils.defaultIfBlank(currentSpecies.getSubtaxaAuthority(), ApplicationUtils.SUGGESTION_BLANK), subtAuthor, ApplicationUtils.CURRENT_SUFFIX);
}
} else {
LOG.debug("Multiple speciesRows match genus={} species={} subtaxa={}", genus, species, subtaxa);
}
}
LOG.trace("Source and result:\n\n\t{}\n\t{}\n", Arrays.toString(sourceLine), Arrays.toString(outputLine));
writer.writeNext(outputLine);
}
}
}
return stringWriter;
}
/**
* Replace the value in the outputRow at index
*
* @param outputLine the line
* @param index column index
* @param newValue new value
* @param suffix suffix to append if writing the value
*/
private void updateOutputColumn(String[] outputLine, int index, String newValue, String ignoreIfMatches, String suffix) {
if (index == -1)
return;
if (newValue == null) {
return;
}
if (ignoreIfMatches != null && (ignoreIfMatches.equals(outputLine[index]) || ignoreIfMatches.equals(newValue))) {
// do nothing
} else if (ignoreIfMatches == null || ApplicationUtils.CHECK_PASSED.equals(outputLine[index])) {
outputLine[index] = newValue + suffix;
} else {
outputLine[index] += ";" + newValue + suffix;
}
}
}
package org.genesys2.gringlobal.taxonomy.util;
/**
* Created by Lugovskoy Andrey .
*/
public class ApplicationUtils {
public static final String SUGGESTION_BLANK = "_blank_";
public static final String CHECK_PASSED = "OK";
public static final String CURRENT_SUFFIX = " [current]";
public static final String HEADER_GENUS = "GENUS";
public static final String HEADER_GENUS_CHECK = "GENUS_check";
public static final String HEADER_SPECIES = "SPECIES";
public static final String HEADER_SPECIES_CHECK = "SPECIES_check";