Skip to content

Commit 3d9b15a

Browse files
authored
Merge pull request #105 from intersystems-community/stage
changed the way code extension
2 parents 336b9b1 + a135d19 commit 3d9b15a

File tree

3 files changed

+48
-7
lines changed

3 files changed

+48
-7
lines changed

.github/workflows/trigger-deploy.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ on:
1414
jobs:
1515
trigger-zpm-deployment:
1616
name: Trigger zpm-registry-deployment via REST API
17-
runs-on: ubuntu-latest
18-
17+
runs-on: ubuntu-22.04
1918
steps:
2019
- name: REST POST call
2120
run: |-
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/// To execute your code immediately after the event occurs,
2+
/// you need to create a subclass of this class and override the Process() method in it.
3+
Class ZPM.Analytics.AbstractEventProcessor [ Abstract ]
4+
{
5+
6+
Parameter SubClasses As CONFIGVALUE;
7+
8+
/// Override this method to run your code when event occurs
9+
ClassMethod Process(event as ZPM.Analytics.Event) As %Status [ Abstract ]
10+
{
11+
Return $$$OK
12+
}
13+
14+
/// Do not change or override this method
15+
ClassMethod getSubClasses() As %String [ CodeMode = objectgenerator ]
16+
{
17+
Set list = ""
18+
19+
Set rs = ##class(%Dictionary.ClassDefinitionQuery).SubclassOfFunc("ZPM.Analytics.AbstractEventProcessor")
20+
While (rs.%Next()) {
21+
Set list = list _ $listbuild( rs.%GetData(1) )
22+
}
23+
24+
Do $system.OBJ.UpdateConfigParam("ZPM.Analytics.AbstractEventProcessor","SubClasses",$listtostring(list,","))
25+
Do %code.WriteLine(" return $PARAMETER(""ZPM.Analytics.AbstractEventProcessor"",""SubClasses"") ")
26+
Return $$$OK
27+
}
28+
29+
}

src/cls/ZPM/Analytics/Event.cls

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Class ZPM.Analytics.Event Extends (%Persistent, %JSON.Adaptor)
33

44
Parameter DSTIME = "AUTO";
55

6-
/// Server date and time, saving the data
6+
/// Server date and time, saving the data
77
Property TS As %PosixTime(%JSONINCLUDE = "none") [ SqlComputeCode = {set {*}=##class(%Library.PosixTime).CurrentTimeStamp()}, SqlComputed, SqlComputeOnChange = %%INSERT ];
88

99
/// Event type: download, install, uninstall
@@ -40,6 +40,22 @@ Property Region As %String(%JSONINCLUDE = "none");
4040

4141
Property City As %String(%JSONINCLUDE = "none");
4242

43+
ClassMethod ExecuteEventProcessors(event As ZPM.Analytics.Event) As %Status
44+
{
45+
Set subclasses = $PARAMETER("ZPM.Analytics.AbstractEventProcessor","SubClasses")
46+
Set list = $ListFromString(subclasses,",")
47+
For i=1:1:$listlength(list){
48+
Try {
49+
$$$ThrowOnError($Classmethod($listget(list,i), "Process", event))
50+
} Catch ex {
51+
If (ex.Name '= "<CLASS DOES NOT EXIST>") {
52+
Throw ex
53+
}
54+
}
55+
}
56+
return $$$OK
57+
}
58+
4359
ClassMethod SaveEvent(action As %String, ip As %String = "", json As %DynamicObject) As %Status
4460
{
4561
Try {
@@ -48,10 +64,7 @@ ClassMethod SaveEvent(action As %String, ip As %String = "", json As %DynamicObj
4864
Set event.IP = ip
4965
Do event.%JSONImport(json)
5066
$$$ThrowOnError(event.%Save())
51-
If ##class(%Dictionary.CompiledClass).%ExistsId("ZPM.Analytics.IP") {
52-
Do ##class(ZPM.Analytics.IP).SetGeo(event, ip)
53-
}
54-
$$$ThrowOnError(event.%Save())
67+
$$$ThrowOnError(..ExecuteEventProcessors(event))
5568
Return $$$OK
5669
} Catch ex {
5770
Do ex.Log()

0 commit comments

Comments
 (0)