Skip to content

Commit

Permalink
- Added sortOrder column to Java class, SQL, and XML
Browse files Browse the repository at this point in the history
- Added sortOrder column to SNDTest.java
  • Loading branch information
spamhurts committed Sep 13, 2023
1 parent 850ea45 commit 4589296
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 10 deletions.
23 changes: 20 additions & 3 deletions api-src/org/labkey/api/snd/EventData.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public class EventData
private int _superPkgId;
private int _eventId;
private Integer _parentEventDataId;
private Integer _sortOrder;
private String _narrativeTemplate;
private String _objectURI;
private List<EventData> _subPackages;
Expand All @@ -57,22 +58,26 @@ public class EventData
public static final String EVENT_DATA_OBJECTURI = "objectURI";
public static final String EVENT_DATA_EVENTID = "eventId";
public static final String EVENT_DATA_PARENT_EVENTDATAID = "parentEventDataId";
public static final String EVENT_DATA_SORT_ORDER = "sortOrder";
public static final String EVENT_DATA_CONTAINER = "Container";

public static final String EVENT_DATA_CSS_CLASS = "snd-event-data";

public static final String EVENT_DATA_EXTRA_FIELDS = "extraFields";

public EventData(@Nullable Integer eventDataId, int superPkgId, @Nullable String narrative, @Nullable List<EventData> subPackages, @NotNull List<AttributeData> attributes)
{
this(eventDataId, superPkgId, narrative, subPackages, attributes, null);
}
public EventData(@Nullable Integer eventDataId, int superPkgId, @Nullable String narrative, @Nullable List<EventData> subPackages, @NotNull List<AttributeData> attributes , @Nullable Integer sortOrder)
{
_eventDataId = eventDataId;
_superPkgId = superPkgId;
_narrativeTemplate = narrative;
_subPackages = subPackages;
_sortOrder = sortOrder;

if (attributes != null)
_attributes = attributes;
}

public EventData() {}

@Nullable
Expand Down Expand Up @@ -150,6 +155,16 @@ public void setException(Event event, ValidationException exception)
event.updateExceptionCount(exception);
}

public Integer getSortOrder()
{
return _sortOrder;
}

public void setSortOrder(Integer sortOrder)
{
_sortOrder = sortOrder;
}

@Nullable
public List<EventData> getSubPackages()
{
Expand Down Expand Up @@ -193,6 +208,7 @@ public Map<String, Object> getEventDataRow(Container c)
eventDataValues.put(EVENT_DATA_EVENTID, getEventId());
eventDataValues.put(EVENT_DATA_PARENT_EVENTDATAID, getParentEventDataId());
eventDataValues.put(EVENT_DATA_CONTAINER, c);
eventDataValues.put(EVENT_DATA_SORT_ORDER, getSortOrder());

Map<GWTPropertyDescriptor, Object> extras = getExtraFields();
for (GWTPropertyDescriptor gpd : extras.keySet())
Expand All @@ -210,6 +226,7 @@ public JSONObject toJSON(Container c, User u)
json.put(EVENT_DATA_ID, getEventDataId());
json.put(EVENT_DATA_SUPER_PACKAGE_ID, getSuperPkgId());
json.put(EVENT_DATA_NARRATIVE_TEMPLATE, getNarrativeTemplate());
json.put(EVENT_DATA_SORT_ORDER, getSortOrder());

JSONArray subPackagesJson = new JSONArray();
if (getSubPackages() != null)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE snd.EventData ADD SortOrder INTEGER NULL;
1 change: 1 addition & 0 deletions resources/schemas/snd.xml
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@
<column columnName="EventId"/>
<column columnName="SuperPkgId"/>
<column columnName="ParentEventDataId"/>
<column columnName="SortOrder"/>
<column columnName="ObjectURI"/>
<column columnName="Container"/>
<column columnName="Lsid">
Expand Down
13 changes: 7 additions & 6 deletions src/org/labkey/snd/SNDController.java
Original file line number Diff line number Diff line change
Expand Up @@ -1064,21 +1064,22 @@ private List<EventData> parseEventData(JSONArray eventDataJson) throws IOExcepti
{
JSONObject eventDatumJson = (JSONObject) eventDataJson.get(i);

Integer eventDataId = eventDatumJson.has("eventDataId") ? eventDatumJson.getInt("eventDataId") : null;
int superPackageId = eventDatumJson.getInt("superPkgId");
Integer eventDataId = eventDatumJson.has(EventData.EVENT_DATA_ID) ? eventDatumJson.getInt(EventData.EVENT_DATA_ID) : null;
int superPackageId = eventDatumJson.getInt(EventData.EVENT_DATA_SUPER_PACKAGE_ID);
Integer sortOrder = eventDatumJson.has(EventData.EVENT_DATA_SORT_ORDER) ? eventDatumJson.getInt(EventData.EVENT_DATA_SORT_ORDER) : null;

List<EventData> eventDataChildren;
JSONArray eventDataChildrenJson = eventDatumJson.has("subPackages") ? eventDatumJson.getJSONArray("subPackages") : null;
JSONArray eventDataChildrenJson = eventDatumJson.has(EventData.EVENT_DATA_SUB_PACKAGES) ? eventDatumJson.getJSONArray(EventData.EVENT_DATA_SUB_PACKAGES) : null;
eventDataChildren = parseEventData(eventDataChildrenJson);

List<AttributeData> attributes;
JSONArray attributesJson = eventDatumJson.has("attributes") ? eventDatumJson.getJSONArray("attributes") : null;
JSONArray attributesJson = eventDatumJson.has(EventData.EVENT_DATA_ATTRIBUTES) ? eventDatumJson.getJSONArray(EventData.EVENT_DATA_ATTRIBUTES) : null;
attributes = parseAttributeData(attributesJson);

EventData eventData = new EventData(eventDataId, superPackageId, null, eventDataChildren, attributes);
EventData eventData = new EventData(eventDataId, superPackageId, null, eventDataChildren, attributes, sortOrder);

// Get extra fields
JSONArray jsonExtras = eventDatumJson.optJSONArray("extraFields");
JSONArray jsonExtras = eventDatumJson.optJSONArray(EventData.EVENT_DATA_EXTRA_FIELDS);
if (null != jsonExtras)
{
eventData.setExtraFields(getExtraFields(jsonExtras));
Expand Down
2 changes: 1 addition & 1 deletion src/org/labkey/snd/SNDModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public String getName()
@Override
public @Nullable Double getSchemaVersion()
{
return 23.003;
return 23.004;
}

@Override
Expand Down
1 change: 1 addition & 0 deletions test/src/org/labkey/test/tests/snd/SNDTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,7 @@ private static String getPackageWithId(String packageId)
" projectIdRev: '" + PKG_TEST_PROJECT_ID + "|0', \n" +
" eventData: [{ \n" +
" superPkgId: " + TEST_SUPER_PKG_START_ID5 + ", \n" +
" sortOrder: 1, \n" +
" extraFields: [], \n" +
" attributes: [] \n" +
" }] \n" +
Expand Down

0 comments on commit 4589296

Please sign in to comment.