Skip to content
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
*.e
/oe117/Sports/PASOEContent/WEB-INF/openedge/Business/UnitTest/ApsvTest.p
/oe117/Sports/tools/testApsvHello.p
*.prof
Binary file modified docs/Spark Quick-Start Guide.docx
Binary file not shown.
Binary file modified oe117/DynSports/AppServer/Spark.pl
Binary file not shown.
16 changes: 12 additions & 4 deletions oe117/DynSports/PASOEContent/WEB-INF/openedge/Business/HelloProc.p
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,8 @@
Notes :
----------------------------------------------------------------------*/

/* *************************** Definitions ************************** */

block-level on error undo, throw.

/* *************************** Main Block *************************** */

procedure sayHello:
define input parameter toWhom as character no-undo.
define output parameter greeting as character no-undo.
Expand All @@ -33,3 +29,15 @@ procedure sayHello2Many:

assign greeting = trim(left-trim(greeting, ",")).
end procedure.

procedure sayHelloExtent:
define input parameter recipients as character no-undo extent.
define output parameter greeting as character no-undo.

define variable ix as integer no-undo.
do ix = 1 to extent(recipients):
assign greeting = substitute("&1, Hello &2", greeting, recipients[ix]).
end.

assign greeting = trim(left-trim(greeting, ",")).
end procedure.
Original file line number Diff line number Diff line change
Expand Up @@ -177,17 +177,23 @@ class Spark.Core.Handler.DOHEventHandler use-widget-pool final:
/* Register all known services for this application. */
oCatalogManager:registerAllServices(ServiceRegistry:Registry).

/* Create a master catalog for all services (caches output). */
/* Create a master catalog for all services and cache the output. */
oCatalogManager:getCatalog("", "").
end. /* valid-object */

/* Discover any file-based DOH services if ROOT.map exists. */
define variable cServiceMapPath as character no-undo.
file-info:file-name = "ROOT.map". /* Look for a ROOT.map file on disk. */
if file-info:full-pathname ne ? then /* File is present, so obtain the base path of the file. */
assign cServiceMapPath = replace(substring(file-info:full-pathname, 1, length(file-info:full-pathname) - 8), "~\", "/").

file-info:file-name = "ROOT.map". /* Look initially for a ROOT.map file on disk. */

if file-info:full-pathname eq ? then /* File is not present, so try a different common file. */
file-info:file-name = "catalog.map". /* Try looking for a catalog.map file on disk. */

if file-info:full-pathname ne ? then /* When file is present, obtain the base path of the file. */
assign cServiceMapPath = replace(substring(file-info:full-pathname, 1, length(file-info:full-pathname) - length(file-info:file-name)), "~\", "/").

if (cServiceMapPath gt "") eq true then do:
/* Use the base path of the ROOT.map file to know where to look for similar .MAP files. */
/* Use the base path of the ROOT.map file to know where to look for other available .MAP files. */
oLoggingManager:logMessage(substitute("Loading Service Registry data from &1", cServiceMapPath), "SPARK-STRT", 3).
OpenEdge.Web.DataObject.ServiceRegistry:RegisterAllFromFolder(cServiceMapPath).
end. /* cServiceMapPath */
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,74 @@ using Spark.Core.Manager.ICatalogManager from propath.

block-level on error undo, throw.

class Spark.Core.Service.Catalog implements Spark.Core.Service.ICatalog:
class Spark.Core.Service.Catalog inherits Spark.Diagnostic.Util.OSPath implements Spark.Core.Service.ICatalog use-widget-pool:

/* Tracks the last time the CB props file was loaded from the file system. */
define protected variable dCBPropsLastLoaded as datetime no-undo initial ?.

/* Find a better default port in use with this instance. */
define protected variable iPort as integer no-undo.

method public void initialize ( ):
this-object:Discovery(). /* Perform local discovery of server info. */
end method. /* initialize */

method public void dispose ( ):
end method. /* dispose */

method protected void Discovery ( ):
define variable cLine as character no-undo.
define variable cAppName as character no-undo.
define variable cAppNames as character no-undo.
define variable cWebApp as character no-undo.
define variable cTransport as character no-undo.
define variable lcConfigTemp as longchar no-undo.
define variable iLines as integer no-undo.
define variable iLine as integer no-undo.
define variable iX as integer no-undo.
define variable iHttpPort as integer no-undo.
define variable iHttpsPort as integer no-undo.
define variable lFound as logical no-undo.
define variable dLastDate as datetime no-undo.
define variable oWebAppList as JsonArray no-undo.

/* Examine the catalina.properties for info about the available ports. */
file-info:file-name = substitute("&1/conf/catalina.properties", this-object:CatalinaBase).
if file-info:full-pathname ne ? then do:
/* Get the current date/time that the file was last modified. */
assign dLastDate = datetime(file-info:file-mod-date, file-info:file-mod-time * 1000).

if dLastDate ne dCBPropsLastLoaded then do:
/* Mark down the current modified date/time for this file. */
assign dCBPropsLastLoaded = dLastDate.

/* Read the file into a longchar value (avoids keeping the file open). */
copy-lob from file file-info:full-pathname to lcConfigTemp no-error.

assign iLines = num-entries(lcConfigTemp, "~n").
if iLines ge 1 then cfgblk:
do iLine = 1 to iLines:
assign cLine = trim(entry(iLine, lcConfigTemp, "~n")).

case true:
when cLine begins "psc.as.http.port=" then
assign iHttpPort = integer(trim(entry(2, cLine, "="))).
when cLine begins "psc.as.https.port=" then
assign iHttpsPort = integer(trim(entry(2, cLine, "="))).
end case.
end. /* do iLines */

/* Look to the same server at either the HTTP or HTTPS port for OEManager. */
if iHttpPort gt 0 then
this-object:iPort = iHttpPort.
else if iHttpsPort gt 0 then
this-object:iPort = iHttpsPort.

assign lcConfigTemp = ?. /* Reset the variable. */
end. /* file updated */
end. /* catalina.properties */
end method. /* Discovery */

method protected JsonObject getDataObjectServiceCatalogs ( ):
define variable oServices as DataObjectService no-undo extent.
define variable oOperation as MappedOperation no-undo.
Expand All @@ -46,9 +106,10 @@ class Spark.Core.Service.Catalog implements Spark.Core.Service.ICatalog:
assign oOperation = oServices[iX]:GetOperation("/", MethodEnum:Get).
if valid-object(oOperation) and oOperation:TargetName matches "*.json" then do:
assign
cFilename = replace(oOperation:TargetName, "$CATALINA_BASE", os-getenv("CATALINA_BASE"))
cFilename = replace(oOperation:TargetName, "$CATALINA_BASE", this-object:CatalinaBase)
cFilename = replace(cFilename, "$oepas-webapp", trim(web-context:get-cgi-value("env", "CONTEXT_PATH"), "/"))
.

file-info:file-name = cFilename.
if file-info:full-pathname ne ? then do:
define variable oParser as ObjectModelParser no-undo.
Expand All @@ -64,6 +125,7 @@ class Spark.Core.Service.Catalog implements Spark.Core.Service.ICatalog:
end. /* Operation Not Available */
end. /* No Catalog */
else if oServices[iX]:Catalog:Has("services") then
/* Each service should only have one defined catalog for that service. */
oSvcArray:Add(oServices[iX]:Catalog:GetJsonArray("services"):GetJsonObject(1)).
end. /* do ix */

Expand All @@ -82,6 +144,7 @@ class Spark.Core.Service.Catalog implements Spark.Core.Service.ICatalog:
end method. /* getDataObjectServiceCatalogs */

method public void getOpenApiCatalog ( output catalog as JsonObject ):
/* Specialized method to return an Open API v3.0 formatted description of resource endpoints. */
define variable oServiceWriter as OpenAPI30ServiceWriter no-undo.
assign oServiceWriter = new OpenAPI30ServiceWriter().
if valid-object(oServiceWriter) then do:
Expand All @@ -90,6 +153,16 @@ class Spark.Core.Service.Catalog implements Spark.Core.Service.ICatalog:
oServiceWriter:close().

assign catalog = cast(oServiceWriter:Value, JsonObject).
if valid-object(catalog) then do:
define variable oVars as JsonObject no-undo.

assign oVars = catalog:GetJsonArray("servers"):GetJsonObject(1):GetJsonObject("variables").
oVars:GetJsonObject("port"):Set("default", string(iPort)). /* Use the discovered port for the instance. */
oVars:GetJsonObject("basePath"):Set("default", "/api"). /* Use the default typically set for a Spark-based application. */

assign oVars = catalog:GetJsonArray("servers"):GetJsonObject(2):GetJsonObject("variables").
oVars:GetJsonObject("basePath"):Set("default", "/api"). /* Use the default typically set for a Spark-based application. */
end.
delete object oServiceWriter no-error.
end.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,9 @@ class Spark.Core.Util.Reflection final:

assign oParamSig = new Progress.Json.ObjectModel.JsonObject().
oParamSig:Add("mode", oParamInt:Mode:toString()).
oParamSig:Add("type", cDataType).
oParamSig:Add("name", oParamInt:Name).
if oParamInt:Extent gt 0 then
oParamSig:Add("extent", oParamInt:Extent).
oParamSig:Add("type", cDataType).
oParamSig:Add("extent", oParamInt:Extent).

oParamArr:Add(oParamSig).
end. /* oParamExt */
Expand Down Expand Up @@ -109,8 +108,7 @@ class Spark.Core.Util.Reflection final:
oElementSig:Add("readable", oPropsInt:CanRead).
oElementSig:Add("writable", oPropsInt:CanWrite).
oElementSig:Add("type", cDataType).
if oPropsInt:Extent gt 0 then
oElementSig:Add("extent", oPropsInt:Extent).
oElementSig:Add("extent", oPropsInt:Extent).

oProperties:Add(oPropsInt:Name, oElementSig).
end. /* oPropsExt */
Expand Down Expand Up @@ -154,8 +152,8 @@ class Spark.Core.Util.Reflection final:
oElementSig:Add("mode", oVarsInt:AccessMode:toString()).
oElementSig:Add("static", oVarsInt:IsStatic).
oElementSig:Add("type", cDataType).
if oVarsInt:Extent gt 0 then
oElementSig:Add("extent", oVarsInt:Extent).
oElementSig:Add("extent", oVarsInt:Extent).

oVariables:Add(oVarsInt:Name, oElementSig).
end. /* oVarsExt */

Expand Down Expand Up @@ -229,8 +227,7 @@ class Spark.Core.Util.Reflection final:
oParamSig:Add("mode", oParamInt:Mode:toString()).
oParamSig:Add("name", oParamInt:Name).
oParamSig:Add("type", cDataType).
if oParamInt:Extent gt 0 then
oParamSig:Add("extent", oParamInt:Extent).
oParamSig:Add("extent", oParamInt:Extent).

oParamArr:Add(oParamSig).
end. /* oParamExt */
Expand All @@ -239,9 +236,10 @@ class Spark.Core.Util.Reflection final:
oElementSig:Add("origin", oMethodInt:OriginatingClass:TypeName).
oElementSig:Add("defined", oMethodInt:DeclaringClass:TypeName).
oElementSig:Add("return", cReturnType).
oElementSig:Add("params", oParamArr).
if oMethodInt:ReturnExtent gt 0 then
if cReturnType ne "void" then
oElementSig:Add("extent", oMethodInt:ReturnExtent).
oElementSig:Add("params", oParamArr).

oMethods:Add(oMethodInt:name, oElementSig).
end. /* oMethodExt */

Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
&GLOBAL-DEFINE SPARK_VERSION 5.0.0-2019.11.22.124437 (11.7.5)
&GLOBAL-DEFINE SPARK_VERSION 5.0.1-2019.12.19.032446 (11.7.5)
83 changes: 83 additions & 0 deletions oe117/DynSports/tests/EntityTests.cls
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/*------------------------------------------------------------------------
File : EntityTests
Purpose :
Description :
Author(s) : pjudge
Created : Mon Jun 18 10:05:30 EDT 2018
Notes :
----------------------------------------------------------------------*/

/* *************************** Definitions ************************** */

using Ccs.BusinessLogic.* from propath.
using OpenEdge.BusinessLogic.Filter.* from propath.
using OpenEdge.BusinessLogic.Query.* from propath.
using OpenEdge.Core.String from propath.
using OpenEdge.Web.DataObject.* from propath.
using Progress.Lang.* from propath.
using Progress.Json.ObjectModel.* from propath.
using Spark.Core.Manager.ICatalogManager from propath.

block-level on error undo, throw.

class tests.EntityTests inherits tests.SparkUnit:

define private variable oCatalogManager as ICatalogManager no-undo.
define private variable oServices as DataObjectService no-undo extent.

/*------------------------------------------------------------------------------
Purpose: Start up the Spark stack similar to a session of the MSAS agent.
Notes:
------------------------------------------------------------------------------*/
@Before.
method public void before ( ):
this-object:StartSpark("service").

assign oCatalogManager = cast(this-object:GetManager("Spark.Core.Manager.ICatalogManager"), ICatalogManager).
end method.

/*------------------------------------------------------------------------------
Purpose: Shut down the Spark stack similar to a session of the MSAS agent.
Notes:
------------------------------------------------------------------------------*/
@After.
method public void after ( ):
delete object oCatalogManager no-error.

this-object:StopSpark().
end method.

@Test.
method public void hasServices ( ):
/* Services should have been created/loaded as part of the Spark startup logic run in the "before" method. */
assign oServices = ServiceRegistry:GetServices().
log-manager:write-message(substitute("Found &1 services in registry.", extent(oServices))).

define variable oOps as MappedOperation no-undo extent.
define variable iX as integer no-undo.
do iX = 1 to extent(oServices):
extent(oOps) = ?. /* Reset extent. */
assign oOps = oServices[iX]:GetOperations().
log-manager:write-message(substitute("Service #&1: &2 with &3 operations.", iX, oServices[iX]:Name, extent(oOps))).
end.

OpenEdge.Core.Assert:NonZero(extent(oServices)). /* Should be a non-zero number of services. */

catch err as Progress.Lang.Error:
log-manager:write-message(substitute("Error: &1", err:GetMessage(1))).
end catch.
end method.

@Test.
method public void writeMappings ( ):
define variable iX as integer no-undo.
do iX = 1 to extent(oServices):

end.

catch err as Progress.Lang.Error:
log-manager:write-message(substitute("Error: &1", err:GetMessage(1))).
end catch.
end method.

end class.
10 changes: 5 additions & 5 deletions oe117/DynSports/tests/FilterTests.cls
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*------------------------------------------------------------------------
File : test_filter_parser.p
File : FilterTests
Purpose :
Description :
Author(s) : pjudge
Author(s) : pjudge & dugrau
Created : Mon Jun 18 10:05:30 EDT 2018
Notes :
----------------------------------------------------------------------*/
Expand Down Expand Up @@ -134,7 +134,7 @@ class tests.FilterTests:
this-object:showOutput("Option1b").

catch err as Progress.Lang.Error:
message substitute("Error: &1", err:GetMessage(1)).
log-manager:write-message(substitute("Error: &1", err:GetMessage(1))).
end catch.
end method.

Expand All @@ -156,7 +156,7 @@ class tests.FilterTests:
this-object:showOutput("Option2").

catch err as Progress.Lang.Error:
message substitute("Error: &1", err:GetMessage(1)).
log-manager:write-message(substitute("Error: &1", err:GetMessage(1))).
end catch.
end method.

Expand Down Expand Up @@ -202,7 +202,7 @@ class tests.FilterTests:
this-object:showOutput("Option3c").

catch err as Progress.Lang.Error:
message substitute("Error: &1", err:GetMessage(1)).
log-manager:write-message(substitute("Error: &1", err:GetMessage(1))).
end catch.
end method.

Expand Down
1 change: 1 addition & 0 deletions oe117/DynSports/tests/MainSuite.cls
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ block-level on error undo, throw.
@TestSuite(classes="tests.ParameterTests").
@TestSuite(classes="tests.UtilityTests").
@TestSuite(classes="tests.FilterTests").
@TestSuite(classes="tests.EntityTests").

class tests.MainSuite:

Expand Down
4 changes: 0 additions & 4 deletions oe117/DynSports/tests/ParameterTests.cls
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,6 @@ class tests.ParameterTests inherits tests.SparkUnit:
------------------------------------------------------------------------------*/
@Test.
method public void testCreateCPO ( ):
define variable cMessage as character no-undo.
define variable lResult as logical no-undo.
define variable rCP as raw no-undo.

create client-principal hCPO.
hCPO:initialize("{&test_username}").
hCPO:roles = "{&allowed_roles}".
Expand Down
Loading