Skip to content

Commit

Permalink
Merge branch 'release/2.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
blavenie committed Mar 15, 2023
2 parents a190446 + 082ea1b commit 68a560e
Show file tree
Hide file tree
Showing 167 changed files with 5,474 additions and 1,510 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<groupId>net.sumaris</groupId>
<artifactId>sumaris-pod</artifactId>
<version>2.0.6</version>
<version>2.1.0</version>
<packaging>pom</packaging>
<name>SUMARiS</name>
<description>SUMARiS :: Maven parent</description>
Expand Down
2 changes: 1 addition & 1 deletion sumaris-core-shared/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>net.sumaris</groupId>
<artifactId>sumaris-pod</artifactId>
<version>2.0.6</version>
<version>2.1.0</version>
</parent>

<artifactId>sumaris-core-shared</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,12 @@

import com.google.common.base.Charsets;
import com.google.common.base.Preconditions;
import com.google.common.base.Splitter;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists;
import lombok.NonNull;
import lombok.extern.slf4j.Slf4j;
import net.sumaris.core.dao.technical.Daos;
Expand All @@ -53,6 +56,7 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.util.*;
import java.util.stream.Collectors;

import static org.nuiton.i18n.I18n.t;

Expand Down Expand Up @@ -251,7 +255,11 @@ protected void addAlias(ApplicationConfig applicationConfig) {
applicationConfig.addAlias("-d", "--option", SumarisConfigurationOption.CLI_DAEMONIZE.getKey(), "true");
applicationConfig.addAlias("--output", "--option", SumarisConfigurationOption.CLI_OUTPUT_FILE.getKey());
applicationConfig.addAlias("-f", "--option", SumarisConfigurationOption.CLI_FORCE_OUTPUT.getKey(), "true");
applicationConfig.addAlias("--program", "--option", SumarisConfigurationOption.CLI_FILTER_PROGRAM_LABEL.getKey());
applicationConfig.addAlias("--year", "--option", SumarisConfigurationOption.CLI_FILTER_YEAR.getKey());
applicationConfig.addAlias("--trip", "--option", SumarisConfigurationOption.CLI_FILTER_TRIP_IDS.getKey());
applicationConfig.addAlias("--operation", "--option", SumarisConfigurationOption.CLI_FILTER_OPERATION_IDS.getKey());
// TODO : add --sale, --observed-location --landing

}

Expand Down Expand Up @@ -906,9 +914,17 @@ public Integer getCliFilterYear() {
return year == -1 ? null : year;
}

public Integer getCliFilterTripId() {
int tripId = applicationConfig.getOptionAsInt(SumarisConfigurationOption.CLI_FILTER_TRIP_ID.getKey());
return tripId == -1 ? null : tripId;
public String getCliFilterProgramLabel() {
String programLabel = applicationConfig.getOption(SumarisConfigurationOption.CLI_FILTER_PROGRAM_LABEL.getKey());
return StringUtils.isBlank(programLabel) ? null : programLabel;
}

public List<Integer> getCliFilterTripIds() {
return getConfigurationOptionAsNumbers(SumarisConfigurationOption.CLI_FILTER_TRIP_IDS.getKey());
}

public List<Integer> getCliFilterOperationIds() {
return getConfigurationOptionAsNumbers(SumarisConfigurationOption.CLI_FILTER_OPERATION_IDS.getKey());
}

/**
Expand Down Expand Up @@ -1090,4 +1106,39 @@ public String getColumnDefaultValue(String tableName, String columnName) {

return applicationConfig.getOption("sumaris." + tableName.toUpperCase() + "." + columnName.toUpperCase() + ".defaultValue");
}

public List<Integer> getConfigurationOptionAsNumbers(String optionKey) {
List<Integer> result = (List<Integer>) complexOptionsCache.getIfPresent(optionKey);

// Not exists in cache
if (result == null) {
String ids = applicationConfig.getOption(optionKey);
if (StringUtils.isBlank(ids)) {
result = ImmutableList.of();
} else {
final List<String> invalidIds = Lists.newArrayList();
result = Splitter.on(",").omitEmptyStrings().trimResults()
.splitToList(ids)
.stream()
.map(id -> {
try {
return Integer.parseInt(id);
} catch (Exception e) {
invalidIds.add(id);
return null;
}
})
.filter(Objects::nonNull)
.collect(Collectors.toList());

if (CollectionUtils.isNotEmpty(invalidIds)) {
log.error("Skipping invalid values found in configuration option '{}': {}", optionKey, invalidIds);
}
}

// Add to cache
complexOptionsCache.put(optionKey, result);
}
return result;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -528,13 +528,24 @@ public enum SumarisConfigurationOption implements ConfigOptionDef {
Integer.class,
false),

CLI_FILTER_TRIP_ID(
"sumaris.cli.filter.tripId",
n("sumaris.config.option.cli.filter.tripId.description"),
"-1",
CLI_FILTER_PROGRAM_LABEL(
"sumaris.cli.filter.programLabel",
n("sumaris.config.option.cli.filter.programLabel.description"),
"",
String.class,
false),
CLI_FILTER_TRIP_IDS(
"sumaris.cli.filter.tripIds",
n("sumaris.config.option.cli.filter.tripIds.description"),
"",
Integer.class,
false),
CLI_FILTER_OPERATION_IDS(
"sumaris.cli.filter.operationIds",
n("sumaris.config.option.cli.filter.operationIds.description"),
"",
Integer.class,
false),

CSV_SEPARATOR(
"sumaris.csv.separator",
n("sumaris.config.option.csv.separator.description"),
Expand Down Expand Up @@ -663,26 +674,6 @@ public enum SumarisConfigurationOption implements ConfigOptionDef {
Boolean.class,
false),

ENABLE_BATCH_TAXON_NAME(
"sumaris.trip.operation.batch.taxonName.enable",
n("sumaris.config.option.trip.operation.batch.taxonName.enable.description"),
Boolean.TRUE.toString(),
Boolean.class,
false),

ENABLE_BATCH_TAXON_GROUP(
"sumaris.trip.operation.batch.taxonGroup.enable",
n("sumaris.config.option.trip.operation.batch.taxonGroup.enable.description"),
Boolean.TRUE.toString(),
Boolean.class,
false),

BATCH_TAXON_GROUP_LABELS_NO_WEIGHT(
"sumaris.trip.operation.batch.taxonGroups.noWeight",
n("sumaris.config.option.trip.operation.batch.taxonGroups.noWeight.description"),
"",
String.class,
false),

DB_ADAGIO_SCHEMA(
"sumaris.persistence.adagio.schema",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package net.sumaris.core.dao.data;

/*-
* #%L
* SUMARiS:: Core
* %%
* Copyright (C) 2018 SUMARiS Consortium
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/gpl-3.0.html>.
* #L%
*/

public interface IPosition {


Double getLatitude();

void setLatitude(Double latitude);

Double getLongitude();

void setLongitude(Double longitude);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* #%L
* SUMARiS
* %%
* Copyright (C) 2019 SUMARiS Consortium
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/gpl-3.0.html>.
* #L%
*/

package net.sumaris.core.dao.data;

public abstract class Positions {

protected Positions() {
// Helper class
}

public static boolean isNotNullAndValid(IPosition position) {

if (position == null || position.getLatitude() == null || position.getLongitude() == null) return false;

// Invalid lat/lon
if (position.getLatitude() < -90 || position.getLatitude() > 90
|| position.getLongitude() < -180 || position.getLongitude() > 180) {
return false;
}

// OK: valid
return true;
}

public static boolean isNullOrInvalid(IPosition position) {
return !isNotNullAndValid(position);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -220,12 +220,11 @@ public static Geometry getGeometryFromMinuteSquareLabel(String label, int minute
* Compute the statistical rectangle from the 10x10 square.
* (See doc: square_10.md)
* @param squareLabel 10x10 square
* @return null if invalid square label
*/
public static String convertMinuteSquareToRectangle(final String squareLabel, final int minute) {
String calculRectangle = "";

if (squareLabel == null || squareLabel.length() != 8) {
return calculRectangle;
return null;
}

int cadran = Integer.parseInt(squareLabel.substring(0, 1));
Expand Down
Loading

0 comments on commit 68a560e

Please sign in to comment.