Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AER-3210 Added ProjectCategory enum #304

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public class NCACalculationOptions implements Serializable {

private static final long serialVersionUID = 1L;

private ProjectCategory projectCategory = ProjectCategory.AGRICULTURE;
MichielJanssen-DAT marked this conversation as resolved.
Show resolved Hide resolved

/**
* Regional area for which a permit calculation would apply to.
*/
Expand All @@ -40,7 +42,7 @@ public class NCACalculationOptions implements Serializable {
/**
* List of meteo years to calculate.
*/
private List<String> meteoYears = new ArrayList<>();
private final List<String> meteoYears = new ArrayList<>();
MichielJanssen-DAT marked this conversation as resolved.
Show resolved Hide resolved

/**
* ADMS version to use.
Expand All @@ -67,6 +69,15 @@ public class NCACalculationOptions implements Serializable {
*/
private Double roadLocalFractionNO2;


public ProjectCategory getProjectCategory() {
return projectCategory;
}

public void setProjectCategory(final ProjectCategory projectCategory) {
this.projectCategory = projectCategory;
}

public String getPermitArea() {
return permitArea;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright the State of the Netherlands
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see http://www.gnu.org/licenses/.
*/
package nl.overheid.aerius.shared.domain.calculation;

import java.util.Locale;

/**
* The project category the calculation is for.
*/
public enum ProjectCategory {
AGRICULTURE,
COMBUSTION_PLANT,
ROADS;

public static ProjectCategory safeValueOf(final String value) {
try {
return value == null ? null : valueOf(value.toUpperCase(Locale.ROOT));
} catch (final IllegalArgumentException e) {
return null;
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import nl.overheid.aerius.shared.domain.calculation.NCACalculationOptions;
import nl.overheid.aerius.shared.domain.calculation.OPSOptions;
import nl.overheid.aerius.shared.domain.calculation.OwN2000CalculationOptions;
import nl.overheid.aerius.shared.domain.calculation.ProjectCategory;
import nl.overheid.aerius.shared.domain.calculation.RoadLocalFractionNO2Option;

/**
Expand Down Expand Up @@ -90,6 +91,7 @@ public enum Option {

/* ADMS options related */
ADMS_VERSION,
ADMS_PROJECT_CATEGORY,
ADMS_PERMIT_AREA,
ADMS_MIN_MONIN_OBUKHOV_LENGTH,
ADMS_SURFACE_ALBEDO,
Expand Down Expand Up @@ -238,6 +240,7 @@ private static void opsOptionsToMap(final OPSOptions options, final Map<String,

private static void ncaOptionsFromMap(final NCACalculationOptions options, final Map<Option, String> map,
final Map<String, Map<Option, String>> prefixedOptionsMap) {
options.setProjectCategory(ProjectCategory.safeValueOf(map.get(Option.ADMS_PROJECT_CATEGORY)));
options.setPermitArea(map.get(Option.ADMS_PERMIT_AREA));
options.setRoadLocalFractionNO2ReceptorsOption(RoadLocalFractionNO2Option.safeValueOf(map.get(Option.ROAD_LOCAL_FRACTION_NO2_RECEPTORS_OPTION)));
options.setRoadLocalFractionNO2PointsOption(RoadLocalFractionNO2Option.safeValueOf(map.get(Option.ROAD_LOCAL_FRACTION_NO2_POINTS_OPTION)));
Expand Down Expand Up @@ -315,6 +318,7 @@ private static void ncaParseMetYears(final ADMSOptions admsOptions, final Map<Op
private static void ncaOptionsToMap(final Map<String, String> mapToAddTo, final NCACalculationOptions options, final boolean addDefaults) {
if (options != null) {
addValue(mapToAddTo, Option.ADMS_VERSION, options.getAdmsVersion(), addDefaults);
addValue(mapToAddTo, Option.ADMS_PROJECT_CATEGORY, options.getProjectCategory(), addDefaults);
addValue(mapToAddTo, Option.ADMS_PERMIT_AREA, options.getPermitArea(), addDefaults);
addValue(mapToAddTo, Option.ROAD_LOCAL_FRACTION_NO2_RECEPTORS_OPTION, options.getRoadLocalFractionNO2ReceptorsOption(), addDefaults);
addValue(mapToAddTo, Option.ROAD_LOCAL_FRACTION_NO2_POINTS_OPTION, options.getRoadLocalFractionNO2PointsOption(), addDefaults);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import nl.overheid.aerius.shared.domain.calculation.NCACalculationOptions;
import nl.overheid.aerius.shared.domain.calculation.OPSOptions;
import nl.overheid.aerius.shared.domain.calculation.OwN2000CalculationOptions;
import nl.overheid.aerius.shared.domain.calculation.ProjectCategory;
import nl.overheid.aerius.shared.domain.calculation.RoadLocalFractionNO2Option;
import nl.overheid.aerius.shared.domain.calculation.SubReceptorsMode;
import nl.overheid.aerius.shared.domain.meteo.Meteo;
Expand Down Expand Up @@ -198,6 +199,7 @@ void testNcaOptions() {
final NCACalculationOptions ncaOptions = options.getNcaCalculationOptions();

ncaOptions.setAdmsVersion("5.0.0.1");
ncaOptions.setProjectCategory(ProjectCategory.AGRICULTURE);
MichielJanssen-DAT marked this conversation as resolved.
Show resolved Hide resolved
ncaOptions.setPermitArea("London");
ncaOptions.setRoadLocalFractionNO2ReceptorsOption(RoadLocalFractionNO2Option.ONE_CUSTOM_VALUE);
ncaOptions.setRoadLocalFractionNO2PointsOption(RoadLocalFractionNO2Option.ONE_CUSTOM_VALUE);
Expand Down Expand Up @@ -281,6 +283,7 @@ void testNcaOptionsRoundtrip() {
final NCACalculationOptions ncaOptions = options.getNcaCalculationOptions();

ncaOptions.setPermitArea("London");
ncaOptions.setProjectCategory(ProjectCategory.ROADS);
ncaOptions.setRoadLocalFractionNO2ReceptorsOption(RoadLocalFractionNO2Option.ONE_CUSTOM_VALUE);
ncaOptions.setRoadLocalFractionNO2PointsOption(RoadLocalFractionNO2Option.ONE_CUSTOM_VALUE);
ncaOptions.setRoadLocalFractionNO2(0.4);
Expand Down
Loading