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

New superPackages database function #148

Merged
merged 3 commits into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
79 changes: 79 additions & 0 deletions resources/schemas/dbscripts/sqlserver/snd-23.004-23.005.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
EXEC core.fn_dropifexists 'fGetAllSuperPkgs', 'snd', 'function';
go

CREATE FUNCTION [snd].[fGetAllSuperPkgs]
()
RETURNS @expandedSuperPackages TABLE
(
TopLevelPkgId INTEGER NOT NULL,
SuperPkgId INTEGER NOT NULL,
ParentSuperPkgId INTEGER NULL,
PkgId INTEGER NOT NULL,
TreePath VARCHAR(MAX) NOT NULL,
SuperPkgPath INTEGER NOT NULL,
SortOrder INTEGER NULL,
Required INTEGER NULL,
DESCRIPTION VARCHAR(MAX) NOT NULL,
Narrative VARCHAR(MAX) NOT NULL,
Active INTEGER NOT NULL,
Repeatable INTEGER NOT NULL,
Level INTEGER NOT NULL
)
AS
BEGIN
DECLARE @loopCursor CURSOR;
DECLARE @topLevelPkgId INTEGER;

SET @loopCursor = CURSOR LOCAL FOR
SELECT PkgId AS topLevelPackageId
FROM snd.SuperPkgs AS tl
WHERE ParentSuperPkgId IS NULL
FOR READ ONLY;

OPEN @loopCursor;
FETCH @loopCursor
INTO @topLevelPkgId;

WHILE (@@FETCH_STATUS = 0)
BEGIN
INSERT INTO @expandedSuperPackages
(
TopLevelPkgId,
SuperPkgId,
ParentSuperPkgId,
PkgId,
TreePath,
SuperPkgPath,
SortOrder,
Required,
DESCRIPTION,
Narrative,
Active,
Repeatable,
Level
)
(SELECT TopLevelPkgId,
SuperPkgId,
ParentSuperPkgId,
PkgId,
TreePath,
SuperPkgPath,
SortOrder,
Required,
Description,
Narrative,
Active,
Repeatable,
Level
FROM snd.fGetSuperPkg(@topLevelPkgId) );

FETCH NEXT FROM @loopCursor
INTO @topLevelPkgId;

END; -- WHILE LOOP

CLOSE @loopCursor;
DEALLOCATE @loopCursor;

RETURN;
END;
2 changes: 1 addition & 1 deletion src/org/labkey/snd/SNDController.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ private Map<GWTPropertyDescriptor, Object> getExtraFields(JSONArray jsonExtras)
for (int e = 0; e < jsonExtras.length(); e++)
{
extra = jsonExtras.getJSONObject(e);
extras.put(SNDServiceImpl.jsonToPropertyDescriptor(extra), extra.get("value"));
extras.put(SNDServiceImpl.jsonToPropertyDescriptor(extra), extra.optString("value", null));
}

return extras;
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.004;
return 23.005;
}

@Override
Expand Down
1 change: 1 addition & 0 deletions src/org/labkey/snd/SNDSchema.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public class SNDSchema
public static final String LOOKUPS_TABLE_NAME = "Lookups";
public static final String LOOKUPSETS_TABLE_NAME = "LookupSets";
public static final String SUPERPKGS_FUNCTION_NAME = "fGetSuperPkg";
public static final String ALL_SUPERPKGS_FUNCTION_NAME = "fGetAllSuperPkgs";
public static final String PROJECTS_FUNCTION_NAME = "fGetProjectItems";
public static final String EVENTSCACHE_TABLE_NAME = "EventsCache";

Expand Down