Skip to content

Commit affc449

Browse files
committed
Converted dynamic sql to embedded
1 parent 3d842a5 commit affc449

File tree

1 file changed

+39
-31
lines changed

1 file changed

+39
-31
lines changed

cls/SourceControl/Git/Utils.cls

Lines changed: 39 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2845,45 +2845,53 @@ ClassMethod SetConfiguredRemote(url) As %String
28452845

28462846
ClassMethod ConfigureFavoriteNamespaces(username As %String, newNamespaces As %String)
28472847
{
2848-
// Delete all the GIT favorite links for the user
2849-
set iterator = newNamespaces.%GetIterator()
2850-
while iterator.%GetNext(.key, .value) {
2851-
set sql = "delete from %SYS_Portal.Users where Username='"_username_"' and Page like '%Git%'"
2852-
set statement = ##class(%SQL.Statement).%New()
2853-
do ##class(%SQL.Statement).%ExecDirect(statement,sql)
2854-
}
2848+
// Delete all the GIT favorite links for the user
2849+
&sql(DELETE FROM %SYS_Portal.Users WHERE Username = :username AND Page LIKE '%Git%')
28552850

28562851
set iterator = newNamespaces.%GetIterator()
28572852
while iterator.%GetNext(.key, .value) {
28582853
set installNamespace = value
2859-
new $Namespace
2860-
set $Namespace = "%SYS"
2861-
set sql = "insert or update into %SYS_Portal.Users (Username, Page, Data) "_
2862-
"select ID,?,? from Security.Users where ID='"_username_"'"
2863-
set caption = "Git: "_installNamespace
2864-
set link = "/isc/studio/usertemplates/gitsourcecontrol/webuidriver.csp/"_installNamespace_"/"
2865-
set statement = ##class(%SQL.Statement).%New()
2866-
set statement.%SelectMode = 0
2867-
do ##class(%SQL.Statement).%ExecDirect(statement,sql,caption,link)
2868-
set caption = "Git Pull: "_installNamespace
2869-
set link = "/isc/studio/usertemplates/gitsourcecontrol/pull.csp?$NAMESPACE="_installNamespace
2870-
do ##class(%SQL.Statement).%ExecDirect(statement,sql,caption,link)
2871-
set sql = "update Security.Applications set GroupById='%ISCMgtPortal' where ID = '/isc/studio/usertemplates'"
2872-
do ##class(%SQL.Statement).%ExecDirect(statement,sql)
2873-
}
2874-
}
2875-
2876-
ClassMethod GetFavoriteNamespaces(ByRef favNamespaces As %DynamicArray, ByRef nonFavNamespaces As %DynamicArray) {
2854+
2855+
// Insert Git link
2856+
set caption = "Git: " _ installNamespace
2857+
set link = "/isc/studio/usertemplates/gitsourcecontrol/webuidriver.csp/" _ installNamespace _ "/"
2858+
&sql(INSERT OR UPDATE INTO %SYS_Portal.Users (Username, Page, Data) VALUES (:username, :caption, :link))
2859+
2860+
// Insert Git Pull link
2861+
set caption = "Git Pull: " _ installNamespace
2862+
set link = "/isc/studio/usertemplates/gitsourcecontrol/pull.csp?$NAMESPACE=" _ installNamespace
2863+
&sql(INSERT OR UPDATE INTO %SYS_Portal.Users (Username, Page, Data) VALUES (:username, :caption, :link))
2864+
}
2865+
2866+
// Update Security.Applications
2867+
&sql(UPDATE Security.Applications SET GroupById = '%ISCMgtPortal' WHERE ID = '/isc/studio/usertemplates')
2868+
}
2869+
2870+
ClassMethod GetFavoriteNamespaces(ByRef favNamespaces As %DynamicArray, ByRef nonFavNamespaces As %DynamicArray)
2871+
{
28772872
set allNamespaces = ..GetContexts(1)
28782873
set iterator = allNamespaces.%GetIterator()
28792874

2875+
set username = $USERNAME
2876+
set pagePrefix = "Git:"
2877+
&sql(DECLARE FavCursor CURSOR FOR SELECT Page into :page from %SYS_Portal.Users where username = :username and page %STARTSWITH :pagePrefix)
2878+
28802879
while iterator.%GetNext(.key, .value) {
2881-
set sql = "select * from %SYS_Portal.Users where username='"_$username_"' and page='Git: "_value_"'"
2882-
set statement = ##class(%SQL.Statement).%New()
2883-
set res = ##class(%SQL.Statement).%ExecDirect(statement,sql)
2884-
if (res.%Next()) {
2885-
do favNamespaces.%Push(value)
2886-
} else {
2880+
set foundFlag = 0
2881+
&sql(OPEN FavCursor)
2882+
throw:SQLCODE<0 ##class(%Exception.SQL).CreateFromSQLCODE(SQLCODE, %msg)
2883+
&sql(FETCH FavCursor)
2884+
while (SQLCODE = 0) {
2885+
set pageValue = "Git: "_value
2886+
if (page = pageValue) {
2887+
do favNamespaces.%Push(value)
2888+
set foundFlag = 1
2889+
}
2890+
&sql(FETCH FavCursor)
2891+
}
2892+
&sql(CLOSE FavCursor)
2893+
2894+
if ('foundFlag) {
28872895
do nonFavNamespaces.%Push(value)
28882896
}
28892897
}

0 commit comments

Comments
 (0)