Skip to content

Commit

Permalink
Rename ES field RuleParam.VALUE to DEFAULT_VALUE
Browse files Browse the repository at this point in the history
  • Loading branch information
simonbrandhof committed May 5, 2014
1 parent 819e650 commit 592c1cb
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public String description() {

@Override
public String defaultValue() {
return (String) param.get(RuleNormalizer.RuleParamField.VALUE.key());
return (String) param.get(RuleNormalizer.RuleParamField.DEFAULT_VALUE.key());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public static enum RuleParamField {
NAME("name"),
TYPE("type"),
DESCRIPTION("description"),
VALUE("value");
DEFAULT_VALUE("defaultValue");

private final String key;

Expand Down Expand Up @@ -127,6 +127,26 @@ public String toString() {
}
}

public static enum ActiveRuleParamField {
NAME("name"),
VALUE("value");

private final String key;

private ActiveRuleParamField(final String key) {
this.key = key;
}

public String key() {
return key;
}

@Override
public String toString() {
return key;
}
}

public RuleNormalizer(RuleDao ruleDao, ActiveRuleDao activeRuleDao, RuleTagDao ruleTagDao) {
this.ruleDao = ruleDao;
this.activeRuleDao = activeRuleDao;
Expand Down Expand Up @@ -179,7 +199,7 @@ public UpdateRequest normalize(RuleDto rule) throws IOException {
document.startObject(ActiveRuleField.PARAMS.key());
for (ActiveRuleParamDto param : activeRuleParams) {
document.startObject(param.getKey());
indexField(RuleParamField.VALUE.key(), param.getValue(), document);
indexField(ActiveRuleParamField.VALUE.key(), param.getValue(), document);
document.endObject();
}
document.endObject();
Expand All @@ -206,7 +226,7 @@ public UpdateRequest normalize(RuleParamDto param, RuleKey key) throws IOExcepti
indexField(RuleParamField.NAME.key(), param.getName(), document);
indexField(RuleParamField.TYPE.key(), param.getType(), document);
indexField(RuleParamField.DESCRIPTION.key(), param.getDescription(), document);
indexField(RuleParamField.VALUE.key(), param.getDefaultValue(), document);
indexField(RuleParamField.DEFAULT_VALUE.key(), param.getDefaultValue(), document);
document.endObject();
document.endObject();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ public void handle(Request request, Response response) {

private void writeStatistics(Results results, JsonWriter json) {
json.prop("total", results.getTotal());
// TODO replace ES time by complete time
json.prop("time", results.getTime());
}

Expand All @@ -204,8 +205,7 @@ private void writeHits(Results results, JsonWriter json) {
for (Hit hit : results.getHits()) {
json.beginObject();
for (Map.Entry<String, Object> entry : hit.getFields().entrySet()) {
Object value = entry.getValue();
json.prop(entry.getKey(), value == null ? null : value.toString());
json.name(entry.getKey()).valueObject(entry.getValue());
}
json.endObject();
}
Expand Down

0 comments on commit 592c1cb

Please sign in to comment.