Skip to content

Commit 7766e64

Browse files
author
Larry Gouger
committed
it's ok if the field name doesn't exist as long a formatter with the name exists.
1 parent 18361c6 commit 7766e64

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/groovy/de/andreasschmitt/export/exporter/AbstractExporter.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ abstract class AbstractExporter implements Exporter {
3737
}
3838

3939
protected Object getValue(Object domain, String field){
40-
return formatValue(domain, ExporterUtil.getNestedValue(domain, field), field)
40+
return formatValue(domain, ExporterUtil.getNestedValue(domain, field, formatters?.containsKey(field)), field)
4141
}
4242

4343
protected Writer getOutputStreamWriter(OutputStream outputStream) {

src/groovy/de/andreasschmitt/export/exporter/ExporterUtil.groovy

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class ExporterUtil {
2424
throw new AssertionError()
2525
}
2626

27-
public static Object getNestedValue(Object domain, String field){
27+
public static Object getNestedValue(Object domain, String field, boolean hasFormatter){
2828
try {
2929
// Doesn't work for dynamic properties such as tags used in taggable
3030
return PropertyUtils.getProperty(domain, field)
@@ -35,25 +35,30 @@ class ExporterUtil {
3535

3636
int i = 0
3737
def lastProp
38+
def lastE
3839
for(prop in subProps){
3940
if(i == 0){
4041
try {
4142
lastProp = domain?."$prop"
4243
}
4344
catch(Exception e){
44-
log.info("Couldn't retrieve property ${prop}", e)
45+
lastE = e
4546
}
4647
}
4748
else {
4849
try {
4950
lastProp = lastProp?."$prop"
5051
}
5152
catch(Exception e){
52-
log.info("Couldn't retrieve property ${prop}", e)
53+
lastE = e
5354
}
5455
}
5556
i += 1
5657
}
58+
59+
if (lastE && !hasFormatter) {
60+
log.info("Couldn't retrieve property ${field}", lastE)
61+
}
5762

5863
return lastProp
5964
}

0 commit comments

Comments
 (0)