NIHVIVO-2479 Small improvements to dump output
This commit is contained in:
parent
8f0b6f7b01
commit
0926e5cc30
6 changed files with 39 additions and 17 deletions
|
@ -49,10 +49,15 @@ public class PropertyGroupTemplateModel extends BaseTemplateModel {
|
|||
properties.remove(ptm);
|
||||
}
|
||||
|
||||
/* Freemarker doesn't consider this a getter, because it takes a parameter, so to call it as group.name
|
||||
* in the templates the method name must be simply "name" and not "getName."
|
||||
*/
|
||||
public String name(String otherGroupName) {
|
||||
|
||||
/* Accessor methods for templates */
|
||||
// Add this so it's included in dumps for debugging. The templates will want to display
|
||||
// name using getName(String)
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getName(String otherGroupName) {
|
||||
String displayName = name;
|
||||
if (displayName == null) {
|
||||
displayName = "";
|
||||
|
|
|
@ -53,8 +53,6 @@ public abstract class BaseDumpDirective implements TemplateDirectiveModel {
|
|||
private static final String TEMPLATE_DEFAULT = "dump1.ftl"; // change to dump.ftl when old dump is removed
|
||||
private static final Pattern PROPERTY_NAME_PATTERN = Pattern.compile("^(get|is)\\w");
|
||||
|
||||
protected static final String VALUE_UNDEFINED = "Undefined";
|
||||
|
||||
enum Key {
|
||||
DATE_TYPE("dateType"),
|
||||
HELP("help"),
|
||||
|
@ -74,6 +72,21 @@ public abstract class BaseDumpDirective implements TemplateDirectiveModel {
|
|||
}
|
||||
}
|
||||
|
||||
enum Value {
|
||||
NULL("[null]"),
|
||||
UNDEFINED("[undefined]");
|
||||
|
||||
private final String value;
|
||||
|
||||
Value(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
enum Type {
|
||||
BOOLEAN("Boolean"),
|
||||
COLLECTION("Collection"),
|
||||
|
@ -129,7 +142,7 @@ public abstract class BaseDumpDirective implements TemplateDirectiveModel {
|
|||
Map<String, Object> value = new HashMap<String, Object>();
|
||||
|
||||
if (model == null) {
|
||||
value.put(Key.VALUE.toString(), VALUE_UNDEFINED);
|
||||
value.put(Key.VALUE.toString(), Value.UNDEFINED);
|
||||
|
||||
// TemplateMethodModel and TemplateDirectiveModel objects can only be
|
||||
// included in the data model at the top level.
|
||||
|
@ -196,7 +209,7 @@ public abstract class BaseDumpDirective implements TemplateDirectiveModel {
|
|||
map.putAll( getTemplateModelDump( (TemplateModel)model ) );
|
||||
}
|
||||
} else {
|
||||
map.put(Key.VALUE.toString(), "null");
|
||||
map.put(Key.VALUE.toString(), Value.NULL);
|
||||
}
|
||||
|
||||
return map;
|
||||
|
|
|
@ -32,6 +32,7 @@ import freemarker.core.Environment;
|
|||
import freemarker.ext.beans.BeansWrapper;
|
||||
import freemarker.ext.dump.BaseDumpDirective.DateType;
|
||||
import freemarker.ext.dump.BaseDumpDirective.Key;
|
||||
import freemarker.ext.dump.BaseDumpDirective.Value;
|
||||
import freemarker.ext.dump.BaseDumpDirective.Type;
|
||||
import freemarker.template.Configuration;
|
||||
import freemarker.template.SimpleCollection;
|
||||
|
@ -78,7 +79,7 @@ public class DumpDirectiveTest {
|
|||
Map<String, Object> dataModel = new HashMap<String, Object>();
|
||||
|
||||
Map<String, Object> expectedDumpValue = new HashMap<String, Object>();
|
||||
expectedDumpValue.put(Key.VALUE.toString(), BaseDumpDirective.VALUE_UNDEFINED);
|
||||
expectedDumpValue.put(Key.VALUE.toString(), Value.UNDEFINED);
|
||||
|
||||
Map<String, Object> expectedDump = new HashMap<String, Object>();
|
||||
expectedDump.put(varName, expectedDumpValue);
|
||||
|
@ -1038,7 +1039,7 @@ public class DumpDirectiveTest {
|
|||
propertiesExpectedDump.put("nickname", nicknameExpectedDump);
|
||||
|
||||
Map<String, Object> middleNameExpectedDump = new HashMap<String, Object>();
|
||||
middleNameExpectedDump.put(Key.VALUE.toString(), "null");
|
||||
middleNameExpectedDump.put(Key.VALUE.toString(), Value.NULL);
|
||||
propertiesExpectedDump.put("middleName", middleNameExpectedDump);
|
||||
|
||||
Map<String, Object> marriedExpectedDump = new HashMap<String, Object>();
|
||||
|
@ -1122,7 +1123,7 @@ public class DumpDirectiveTest {
|
|||
propertiesExpectedDump.put("nickname", nicknameExpectedDump);
|
||||
|
||||
Map<String, Object> middleNameExpectedDump = new HashMap<String, Object>();
|
||||
middleNameExpectedDump.put(Key.VALUE.toString(), "null");
|
||||
middleNameExpectedDump.put(Key.VALUE.toString(), Value.NULL);
|
||||
propertiesExpectedDump.put("middleName", middleNameExpectedDump);
|
||||
|
||||
Map<String, Object> marriedExpectedDump = new HashMap<String, Object>();
|
||||
|
@ -1131,7 +1132,7 @@ public class DumpDirectiveTest {
|
|||
propertiesExpectedDump.put("married", marriedExpectedDump);
|
||||
|
||||
Map<String, Object> supervisorExpectedDump = new HashMap<String, Object>();
|
||||
supervisorExpectedDump.put(Key.VALUE.toString(), "null");
|
||||
supervisorExpectedDump.put(Key.VALUE.toString(), Value.NULL);
|
||||
propertiesExpectedDump.put("supervisor", supervisorExpectedDump);
|
||||
|
||||
Map<String, Object> favoriteColorsExpectedDump = new HashMap<String, Object>();
|
||||
|
|
|
@ -120,7 +120,7 @@ div.dump {
|
|||
</@liItem>
|
||||
</#list>
|
||||
</ul>
|
||||
<#else>no values
|
||||
<#else>[none]
|
||||
</#if>
|
||||
</#macro>
|
||||
|
||||
|
@ -134,14 +134,17 @@ div.dump {
|
|||
</@liItem>
|
||||
</#list>
|
||||
</ul>
|
||||
<#else>no values
|
||||
<#else>[none]
|
||||
</#if>
|
||||
</#macro>
|
||||
|
||||
<#macro doScalarValue value>
|
||||
<strong>Value:</strong>
|
||||
|
||||
<#if value?is_string>${value}
|
||||
<#if value?is_string>
|
||||
<#if value?has_content>${value}
|
||||
<#else>[empty]
|
||||
</#if>
|
||||
<#elseif value?is_number>${value?c}
|
||||
<#elseif value?is_boolean>${value?string}
|
||||
<#elseif value?is_date>${value?string("EEEE, MMMM dd, yyyy hh:mm:ss a zzz")}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<#import "lib-properties.ftl" as p>
|
||||
|
||||
<#list propertyGroups.all as group>
|
||||
<#assign groupName = group.name(nameForOtherGroup)>
|
||||
<#assign groupName = group.getName(nameForOtherGroup)>
|
||||
|
||||
<section class="property-group" role="region">
|
||||
<nav class="scroll-up" role="navigation">
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
<nav id="property-group-menu" role="navigation">
|
||||
<ul role="list">
|
||||
<#list groups as group>
|
||||
<#assign groupname = group.name(nameForOtherGroup)>
|
||||
<#assign groupname = group.getName(nameForOtherGroup)>
|
||||
<#if groupname?has_content>
|
||||
<#-- capitalize will capitalize each word in the name; cap_first only the first. We may need a custom
|
||||
function to capitalize all except function words. -->
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue