Skip to content
This repository has been archived by the owner on Feb 22, 2024. It is now read-only.

Commit

Permalink
#102 improved error handling, ignore input files not found or empty
Browse files Browse the repository at this point in the history
  • Loading branch information
Falk Sippach authored and ascheman committed Feb 22, 2020
1 parent bb25eab commit 3027c3d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ class GenerateDukecon {
rawDataMapperClass.getConstructor(RawDataResources.class)
.newInstance(rawDataResources)
rawDataMapper.initMapper()
if (rawDataMapper.isEmpty()) {
log.error("Could not read input data")
System.exit(-1)
}
Class conferenceDataExtractorClass = conferenceConfig.extractorClass as Class
ConferenceDataExtractor conferenceDataExtractor =
conferenceDataExtractorClass.getConstructor(ConferencesConfiguration.Conference.class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,20 @@ import org.dukecon.adapter.ResourceWrapper
*
* @author Falk Sippach, [email protected], @sippsack
*/
interface RawDataMapper {
trait RawDataMapper {

void initMapper()
abstract void initMapper()

void useBackup(ResourceWrapper resourceWrapper)
abstract void useBackup(ResourceWrapper resourceWrapper)

/**
* Concrete subclasses implements this method and return input data as map converted from input resources (JSON, CSV, ...)
*
* @return raw data from input resources as Map
*/
Map<String, Object> asMap()
abstract Map<String, Object> asMap()

boolean isEmpty() {
false
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,12 @@ class DoagJsonMapper implements RawDataMapper {
Map<String, Object> asMap() {
return rawData
}

@Override
@TypeChecked(TypeCheckingMode.SKIP)
boolean isEmpty() {
return asMap().values().any {
!it || it.isEmpty()
}
}
}

0 comments on commit 3027c3d

Please sign in to comment.