Skip to content

Commit

Permalink
Add a searchVisibleHelp attribute to questions
Browse files Browse the repository at this point in the history
  • Loading branch information
jernestmyers committed Apr 10, 2024
1 parent 7982b74 commit dc30553
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Model/lib/rng/wdkModel.rng
Original file line number Diff line number Diff line change
Expand Up @@ -1461,6 +1461,11 @@
<text />
</element>

<element name="searchVisibleHelp">
<ref name="IncludeExclude" />
<text />
</element>

<ref name="attributesList" />

<element name="dynamicAttributes">
Expand Down
1 change: 1 addition & 0 deletions Model/src/main/java/org/gusdb/wdk/core/api/JsonKeys.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ public class JsonKeys {
public static final String PARAM_NAMES = "paramNames";
public static final String QUERY_NAME = "queryName";
public static final String IS_CACHEABLE = "isCacheable";
public static final String SEARCH_VISIBLE_HELP = "searchVisibleHelp";

// record class specific keys
public static final String HAS_ALL_RECORDS_QUERY = "hasAllRecordsQuery";
Expand Down
3 changes: 3 additions & 0 deletions Model/src/main/java/org/gusdb/wdk/model/ModelXmlParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -904,6 +904,9 @@ private static void configureQuestionSet(Digester digester) {
configureNode(digester, "wdkModel/questionSet/question/summary", WdkModelText.class, "addSummary");
digester.addCallMethod("wdkModel/questionSet/question/summary", "setText", 0);

configureNode(digester, "wdkModel/questionSet/question/searchVisibleHelp", WdkModelText.class, "addSearchVisibleHelp");
digester.addCallMethod("wdkModel/questionSet/question/searchVisibleHelp", "setText", 0);

// question's property list
configureNode(digester, "wdkModel/questionSet/question/propertyList", PropertyList.class,
"addPropertyList");
Expand Down
27 changes: 27 additions & 0 deletions Model/src/main/java/org/gusdb/wdk/model/question/Question.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ public class Question extends WdkModelBase implements AttributeFieldContainer, S
private List<WdkModelText> _helps = new ArrayList<>();
private String _help;

private List<WdkModelText> _searchVisibleHelps = new ArrayList<>();
private String _searchVisibleHelp;

private QuestionSet _questionSet;

private Query _query;
Expand Down Expand Up @@ -187,6 +190,7 @@ public Question(Question question) {
_dynamicAttributeSet = question._dynamicAttributeSet;

_help = question._help;
_searchVisibleHelp = question._searchVisibleHelp;

// need to deep-copy query as well
_query = question._query;
Expand Down Expand Up @@ -260,6 +264,10 @@ public void addHelp(WdkModelText help) {
_helps.add(help);
}

public void addSearchVisibleHelp(WdkModelText searchVisibleHelp) {
_searchVisibleHelps.add(searchVisibleHelp);
}

public void setRecordClassRef(String recordClassRef) {
_recordClassRef = recordClassRef;
}
Expand Down Expand Up @@ -330,6 +338,10 @@ public String getHelp() {
return _help;
}

public String getSearchVisibleHelp() {
return _searchVisibleHelp;
}

public String getDisplayName() {
return _displayName != null ? _displayName : _name;
}
Expand Down Expand Up @@ -719,6 +731,21 @@ public void excludeResources(String projectId) throws WdkModelException {
}
_helps = null;

// exclude searchVisibleHelps
boolean hasSearchVisibleHelp = false;
for (WdkModelText searchVisibleHelp : _searchVisibleHelps) {
if (searchVisibleHelp.include(projectId)) {
if (hasSearchVisibleHelp) {
throw new WdkModelException("The question " + getFullName()
+ " has more than one searchVisibleHelp for project " + projectId);
} else {
_searchVisibleHelp = searchVisibleHelp.getText();
hasSearchVisibleHelp = true;
}
}
}
_searchVisibleHelps = null;

// exclude summary and sorting attribute list
boolean hasAttributeList = false;
for (AttributeList attributeList : _attributeLists) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ private static JSONObject getQuestionJsonWithoutParams(Question q) {
.put(JsonKeys.ICON_NAME, q.getIconName())
.put(JsonKeys.SUMMARY, q.getSummary())
.put(JsonKeys.HELP, q.getHelp())
.put(JsonKeys.SEARCH_VISIBLE_HELP, q.getSearchVisibleHelp())
.put(JsonKeys.NEW_BUILD, q.getNewBuild())
.put(JsonKeys.REVISE_BUILD, q.getReviseBuild())
.put(JsonKeys.IS_CACHEABLE, !q.getQuery().hasParamWithUncacheableQuery())
Expand Down

0 comments on commit dc30553

Please sign in to comment.