Skip to content

Commit

Permalink
Updated Marine Location to use allow multiple paths
Browse files Browse the repository at this point in the history
  • Loading branch information
quca3108 committed Aug 5, 2024
1 parent bb3a86c commit f3d37f0
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package edu.colorado.cires.pace.data.object.dataset.base.metadata.location;

import jakarta.validation.constraints.NotBlank;
import java.nio.file.Path;
import java.util.List;

import lombok.Builder;
import lombok.Data;
import lombok.extern.jackson.Jacksonized;
Expand All @@ -15,7 +18,8 @@ public class MobileMarineLocation implements MarineLocation {
private final String vessel;
@NotBlank
private final String locationDerivationDescription;


private final List<Path> fileList;
// TODO: Add file list (List<Path>)

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class MobileMarineLocationTranslator implements LocationDetailTranslator
private final String seaArea;
private final String vessel;
private final String locationDerivationDescription;
private final String singleStringFiles;
// TODO: Add file list mapping (String, value is semi-colon delimited): file-1.txt;file-2.txt;file-3.txt

}
Original file line number Diff line number Diff line change
Expand Up @@ -239,13 +239,29 @@ public static String stringFromMap(Map<String, ValueWithColumnNumber> properties
propertyFromMap(properties, propertyName)
);
}

public static String pathListFromMap(Map<String, ValueWithColumnNumber> properties, String propertyName) {
return stringFromProperty(
propertyFromMap(properties, propertyName)
);
}

public static String stringFromProperty(ValueWithColumnNumber value) {
return value.value()
.map(string -> StringUtils.isBlank(string) ? null : string.trim())
.orElse(null);
}

public static List<Path> pathListFromString(String string) {
if (string == null)
return null;
List<String> strings = Arrays.asList(string.split(";"));
List<Path> paths = strings.stream()
.map(o -> Paths.get(o))
.toList();
return paths;
}

public static Double latitudeFromMap(Map<String, ValueWithColumnNumber> properties, String propertyName, int row, RuntimeException runtimeException) {

String latitudeString = stringFromMap(properties, propertyName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import static edu.colorado.cires.pace.translator.converter.ConversionUtils.stringFromProperty;
import static edu.colorado.cires.pace.translator.converter.ConversionUtils.stringListFromMap;
import static edu.colorado.cires.pace.translator.converter.ConversionUtils.uuidFromMap;
import static edu.colorado.cires.pace.translator.converter.ConversionUtils.pathListFromString;

import edu.colorado.cires.pace.data.object.dataset.audio.AudioPackage;
import edu.colorado.cires.pace.data.object.dataset.audio.CPODPackage;
Expand Down Expand Up @@ -335,6 +336,7 @@ private static MobileMarineLocation mobileMarineLocationFromMap(MobileMarineLoca
.locationDerivationDescription(stringFromMap(properties, mobileMarineLocationTranslator.getLocationDerivationDescription()))
.vessel(stringFromMap(properties, mobileMarineLocationTranslator.getVessel()))
.seaArea(stringFromMap(properties, mobileMarineLocationTranslator.getSeaArea()))
.fileList(pathListFromString(stringFromMap(properties, mobileMarineLocationTranslator.getSingleStringFiles())))
// TODO handle file lists here (split by ;)
.build();
}
Expand Down

0 comments on commit f3d37f0

Please sign in to comment.