Skip to content

Commit

Permalink
Merge pull request #20 from online-photo-submission/CSVManifestFileSe…
Browse files Browse the repository at this point in the history
…rvice-new-features

Csv manifest file service new features
  • Loading branch information
slackboxster authored Jun 6, 2024
2 parents 3774160 + 87f9ac0 commit 5ce6c95
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -443,8 +443,10 @@ The `CSVManifestFileService` is responsible for generating a CSV file containing
- `headerAndColumnMap`
- Description: A map defining the CSV file headers and the corresponding object properties to use for their values. Values available are derived from the [Photo class](https://github.com/online-photo-submission/cloudcard-photo-downloader/blob/master/src/main/groovy/com/cloudcard/photoDownloader/Photo.groovy)
- Default Value: `{'Cardholder_ID':'person.identifier','Photo_Status': 'status','Photo_Date_Submitted':'dateCreated'}`
- Optional: You can also specify a static field in this map by prefixing the value with `static_`.
- Optional: You can specify a static field in this map by prefixing the value with `static_`.
- Example: `'Source':'static_CloudCard'`
- Optional: You can specify the photo file name with the value `photo_fileName` OR the full photo file path with `photo_fullFilePath`.
- Examples: `'Photo':'photo_fileName`, `'Photo Path':'photo_fullFilePath'`

### Encrypting application properties ([Video](https://video.drift.com/v/abZMpJLIB5O/))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ class CSVManifestFileService implements ManifestFileService {
photosToDownload.each { photo ->
if (photoFiles.collect { it.photoId }.contains(photo.id)) {

List record = headerAndColumnMap.values().collect { column -> resolveValue(column, photo) }
PhotoFile file = photoFiles.find {it.photoId == photo.id}

List record = headerAndColumnMap.values().collect { column -> resolveValue(column, photo, file) }

csvPrinter.printRecord(record)
}
Expand All @@ -96,9 +98,13 @@ class CSVManifestFileService implements ManifestFileService {
log.info("========== Manifest File Generated ==========")
}

def resolveValue(String column, Photo photo) {
def resolveValue(String column, Photo photo, PhotoFile file) {
if (column.startsWith('static_')) { return column.split('_', 2)[1] }

if (column == 'photo_fullFilePath') { return file.fileName }

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

def currentObject = photo

for (property in column.split('\\.')) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/logback-spring.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<!-- encoders are assigned the type ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
<encoder>
<pattern>%cyan(%d{HH:mm:ss.SSS}) %highlight(%-5level) %magenta(%logger{36}) - %msg%n</pattern>
<pattern>%cyan(%d{yyyy-MM-dd HH:mm:ss.SSS}) %highlight(%-5level) %magenta(%logger{36}) - %msg%n</pattern>
</encoder>
</appender>

Expand Down

0 comments on commit 5ce6c95

Please sign in to comment.