Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reporter build tracking #72

Merged
merged 5 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions Model/lib/rng/wdkModel.rng
Original file line number Diff line number Diff line change
Expand Up @@ -1383,6 +1383,7 @@
<attribute name="displayName" />
<attribute name="scopes" />
<attribute name="implementation" />
<ref name="buildTracking" />
<optional>
<attribute name="inReportMaker">
<data type="boolean" />
Expand All @@ -1400,6 +1401,15 @@
</element>
</define>

<define name="buildTracking">
<optional>
<choice>
<attribute name="newBuild" />
<attribute name="reviseBuild" />
</choice>
</optional>
</define>

<!-- Question -->
<define name="question">
<element name="question">
Expand Down Expand Up @@ -1430,12 +1440,7 @@
<data type="boolean" />
</attribute>
</optional>
<optional>
<choice>
<attribute name="newBuild" />
<attribute name="reviseBuild" />
</choice>
</optional>
<ref name="buildTracking" />

<zeroOrMore>
<choice>
Expand Down
38 changes: 38 additions & 0 deletions Model/src/main/java/org/gusdb/wdk/model/BuildTracking.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package org.gusdb.wdk.model;

public interface BuildTracking {

WdkModel getWdkModel();

String getNewBuild();

void setNewBuild(String newBuild);

String getReviseBuild();

void setReviseBuild(String reviseBuild);

/**
* @return if the object is newly introduced in the current build
*/
default boolean isNew() {
return buildMatches(getNewBuild());
}

/**
* @return if the object is revised in the current build
*/
default boolean isRevised() {
return buildMatches(getReviseBuild());
}

default boolean buildMatches(String trackedBuild) {
String currentBuild = getWdkModel().getBuildNumber();
if (currentBuild == null)
return false; // current release is not set
else
return currentBuild.equals(trackedBuild);

}

}
29 changes: 6 additions & 23 deletions Model/src/main/java/org/gusdb/wdk/model/question/Question.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.gusdb.fgputil.Named;
import org.gusdb.fgputil.Named.NamedObject;
import org.gusdb.fgputil.functional.Functions;
import org.gusdb.wdk.model.BuildTracking;
import org.gusdb.wdk.model.Utilities;
import org.gusdb.wdk.model.WdkModel;
import org.gusdb.wdk.model.WdkModelBase;
Expand Down Expand Up @@ -65,7 +66,7 @@
* @version $Revision$ $Date: 2007-01-10 14:54:53 -0500 (Wed, 10 Jan
* 2007) $ $Author$
*/
public class Question extends WdkModelBase implements AttributeFieldContainer, StepAnalysisContainer, NamedObject {
public class Question extends WdkModelBase implements AttributeFieldContainer, StepAnalysisContainer, NamedObject, BuildTracking {

public static final String DYNAMIC_QUERY_SUFFIX = "_dynamic";

Expand Down Expand Up @@ -214,44 +215,26 @@ protected static String getInternalQuestionName(String prefix, RecordClass recor
return prefix + recordClass.getFullName().replace('.', '_');
}

@Override
public String getNewBuild() {
return _newBuild;
}

@Override
public void setNewBuild(String newBuild) {
_newBuild = newBuild;
}

@Override
public String getReviseBuild() {
return _reviseBuild;
}

@Override
public void setReviseBuild(String reviseBuild) {
_reviseBuild = reviseBuild;
}

/**
* @return if the question a newly introduced in the current build.
*/
public boolean isNew() {
String currentBuild = _wdkModel.getBuildNumber();
if (currentBuild == null)
return false; // current release is not set
else
return (currentBuild.equals(_newBuild));
}

/**
* @return if the question is revised in the current build.
*/
public boolean isRevised() {
String currentBuild = _wdkModel.getBuildNumber();
if (currentBuild == null)
return false; // current release is not set
else
return (currentBuild.equals(_reviseBuild));
}

public void addSuggestion(QuestionSuggestion suggestion) {
_suggestions.add(suggestion);
}
Expand Down
35 changes: 34 additions & 1 deletion Model/src/main/java/org/gusdb/wdk/model/report/ReporterRef.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.util.Map;

import org.apache.log4j.Logger;
import org.gusdb.wdk.model.BuildTracking;
import org.gusdb.wdk.model.RngAnnotations.RngOptional;
import org.gusdb.wdk.model.RngAnnotations.RngUndefined;
import org.gusdb.wdk.model.WdkModel;
Expand All @@ -24,7 +25,7 @@
* @author xingao
*
*/
public class ReporterRef extends WdkModelBase implements ScopedField, PropertiesProvider {
public class ReporterRef extends WdkModelBase implements ScopedField, PropertiesProvider, BuildTracking {

private static final Logger LOG = Logger.getLogger(ReporterRef.class);

Expand All @@ -37,6 +38,16 @@ public class ReporterRef extends WdkModelBase implements ScopedField, Properties
private List<WdkModelText> _propertyList = new ArrayList<>();
private Map<String, String> _properties = new LinkedHashMap<>();

/**
* new build flag on what build this question is introduced.
*/
private String _newBuild;

/**
* revise build flag on what build this question is revised.
*/
private String _reviseBuild;

@Override
public WdkModel getWdkModel() {
return _wdkModel;
Expand Down Expand Up @@ -150,6 +161,28 @@ public String getDescription() {
return (_description == null ? _displayName : _description);
}

@Override
public String getNewBuild() {
return _newBuild;
}

@Override
@RngOptional
public void setNewBuild(String newBuild) {
_newBuild = newBuild;
}

@Override
public String getReviseBuild() {
return _reviseBuild;
}

@Override
@RngOptional
public void setReviseBuild(String reviseBuild) {
_reviseBuild = reviseBuild;
}

public void addProperty(WdkModelText property) {
_propertyList.add(property);
}
Expand Down
6 changes: 6 additions & 0 deletions Service/doc/schema/wdk/includes/record-reporter.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@
},
"type": {
"type": "string"
},
"newBuild": {
"type": "string"
},
"reviseBuild": {
"type": "string"
}
},
"required": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ public static JSONArray getAnswerFormatsJson(Collection<? extends ReporterRef> r
.put(JsonKeys.DISPLAY_NAME, reporter.getDisplayName())
.put(JsonKeys.DESCRIPTION, reporter.getDescription())
.put(JsonKeys.IS_IN_REPORT, FieldScope.REPORT_MAKER.isFieldInScope(reporter))
.put(JsonKeys.SCOPES, reporter.getScopesList());
.put(JsonKeys.SCOPES, reporter.getScopesList())
.put(JsonKeys.NEW_BUILD, reporter.getNewBuild())
.put(JsonKeys.REVISE_BUILD, reporter.getReviseBuild());
array.put(obj);
}
}
Expand Down
Loading