Skip to content

Commit

Permalink
Merge pull request #22 from online-photo-submission/customFilePath
Browse files Browse the repository at this point in the history
Added ability to specify a custom file path
  • Loading branch information
jonnyhoffer authored Aug 13, 2024
2 parents 0c34b1f + f2b34c3 commit 6e402fe
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ class CSVManifestFileService implements ManifestFileService {
@Value('${CSVManifestFileService.dateFormat:}')
String dateFormat

@Value('${CSVManifestFileService.customFilePath:}')
String customFilePath

@Value('#{${CSVManifestFileService.headerAndColumnMap:}}')
Map<String,String> headerAndColumnMap

Expand All @@ -60,6 +63,7 @@ class CSVManifestFileService implements ManifestFileService {
log.info("CSV Manifest File Service escapeCharacter : $escapeCharacter")
log.info("CSV Manifest File Service dateFormat : $dateFormat")
log.info("CSV Manifest File Service headerAndColumnMap: $headerAndColumnMap")
log.info("CSV Manifest File Service customFilePath : $customFilePath")

}

Expand Down Expand Up @@ -109,6 +113,8 @@ class CSVManifestFileService implements ManifestFileService {

if (column == 'photo_fileName') { return "${file.baseName}.jpg" }

if (column == 'photo_customFilePath') { return "${customFilePath}${file.baseName}.jpg" }

def currentObject = photo

for (property in column.split('\\.')) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class TouchNetStorageService implements StorageService {
return []
}

List<PhotoFile> photoFiles = photos.collect { save(it, sessionId) }
List<PhotoFile> photoFiles = photos.findResults { save(it, sessionId) }

if (!touchNetClient.operatorLogout(sessionId)) {
log.warn("Failed to logout of the TouchNet API")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class CSVManifestFileServiceSpec extends Specification {
"PhotoLink": "bytes",
"DateSubmitted": "dateSubmitted"
]
csvManifestFileService.customFilePath = "//random/nonsense/"
}

def "test createManifestFile generates file with correct content"() {
Expand Down Expand Up @@ -76,6 +77,7 @@ class CSVManifestFileServiceSpec extends Specification {
"date property" | "dateCreated" | new Photo(id: 1, person: new Person(identifier: "123", email: "[email protected]"), bytes: null, dateCreated: parseDate("Fri Feb 16 11:41:44 EST 2024")) | null | "2024-02-16"
"custom Field property" | "person.customFields.Full Name" | new Photo(id: 1, person: new Person(identifier: "123", email: "[email protected]", customFields: ["Full Name": "James"]), bytes: null) | null | "James"
"photo full file path" | "photo_fullFilePath" | new Photo(id: 1, person: new Person(identifier: "123", email: "[email protected]"), bytes: null) | new PhotoFile("photo1", "/Users/Calvin/downloaded-photos/photo1.jpg", 1) | "/Users/Calvin/downloaded-photos/photo1.jpg"
"photo custom path" | "photo_customFilePath" | new Photo(id: 1, person: new Person(identifier: "123", email: "[email protected]"), bytes: null) | new PhotoFile("photo2", "photo2.jpg", 1) | "//random/nonsense/photo2.jpg"
"photo file name" | "photo_fileName" | new Photo(id: 1, person: new Person(identifier: "123", email: "[email protected]"), bytes: null) | new PhotoFile("photo2", "photo2.jpg", 1) | "photo2.jpg"
}

Expand Down Expand Up @@ -133,4 +135,4 @@ class CSVManifestFileServiceSpec extends Specification {
private static Date parseDate(String dateString) {
new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy").parse(dateString)
}
}
}

0 comments on commit 6e402fe

Please sign in to comment.