-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathEuro2016ResultService.cls
145 lines (106 loc) · 4.99 KB
/
Euro2016ResultService.cls
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/**********************************************************************
* Copyright (C) 2006-2016 by Consultingwerk Ltd. ("CW") - *
* www.consultingwerk.de and other contributors as listed *
* below. All Rights Reserved. *
* *
* Software is distributed on an "AS IS", WITHOUT WARRANTY OF ANY *
* KIND, either express or implied. *
* *
* Contributors: *
* *
**********************************************************************/
/*------------------------------------------------------------------------
File : Euro2016ResultService
Purpose : Example for a domain specific application service
Syntax :
Description :
Author(s) : Mike Fechner / Consultingwerk Ltd.
Created : Wed Jun 22 01:04:29 CEST 2016
Notes :
----------------------------------------------------------------------*/
BLOCK-LEVEL ON ERROR UNDO, THROW.
USING Ccs.BusinessLogic.* FROM PROPATH .
USING Ccs.Common.* FROM PROPATH .
USING Consultingwerk.* FROM PROPATH .
USING Consultingwerk.CcsSamples.BusinessEntity.* FROM PROPATH .
USING Consultingwerk.CcsSamples.CustomService.* FROM PROPATH .
USING Consultingwerk.CcsSamples.Framework.BusinessLogic.* FROM PROPATH .
USING Progress.Lang.* FROM PROPATH .
CLASS Consultingwerk.CcsSamples.CustomService.Euro2016ResultService
IMPLEMENTS IEuro2016ResultService:
{Consultingwerk/CcsSamples/BusinessEntity/Euro2016/dsMatches.i}
/**
* Purpose: Disposes the object instance
* Notes:
*/
METHOD PUBLIC VOID dispose ():
/* noop */
END METHOD.
/**
* Purpose: Returns the match results of the given date
* Notes:
* @param pdtDate The date to return results from
* @return The array of MatchResult's
*/
METHOD PUBLIC MatchResult EXTENT GetMatchResultsByDate (pdtDate AS DATE):
DEFINE VARIABLE oMatches AS IBusinessEntity NO-UNDO .
oMatches = CAST (Application:ServiceManager:getService(GET-CLASS (IBusinessEntity), BusinessEntities:Matches:ToString()), IBusinessEntity) .
oMatches:getData (NEW GetDataRequest (NEW NamedQuery ("date", "date", NEW DateHolder (pdtDate))),
OUTPUT DATASET dsMatches BY-REFERENCE) .
RETURN THIS-OBJECT:MatchResultExtent() .
END METHOD.
/**
* Purpose: Returns the match results of the given team
* Notes:
* @param poTeam The team to return results from
* @return The array of MatchResult's
*/
METHOD PUBLIC MatchResult EXTENT GetMatchResultsByTeam (poTeam AS TeamEnum):
DEFINE VARIABLE oMatches AS IBusinessEntity NO-UNDO .
oMatches = CAST (Application:ServiceManager:getService(GET-CLASS (IBusinessEntity), BusinessEntities:Matches:ToString()), IBusinessEntity) .
oMatches:getData (NEW GetDataRequest (NEW NamedQuery ("team", "team", NEW CharacterHolder (poTeam:ToString()))),
OUTPUT DATASET dsMatches BY-REFERENCE) .
RETURN THIS-OBJECT:MatchResultExtent() .
END METHOD.
/**
* Purpose: Returns the match results of today
* Notes:
* @return The array of MatchResult's
*/
METHOD PUBLIC MatchResult EXTENT GetTodaysMatchResults ():
DEFINE VARIABLE oMatches AS IBusinessEntity NO-UNDO .
oMatches = CAST (Application:ServiceManager:getService(GET-CLASS (IBusinessEntity), BusinessEntities:Matches:ToString()), IBusinessEntity) .
oMatches:getData (NEW GetDataRequest (NEW NamedQuery ("today")),
OUTPUT DATASET dsMatches BY-REFERENCE) .
RETURN THIS-OBJECT:MatchResultExtent() .
END METHOD.
/**
* Purpose:
* Notes:
*
*/
METHOD PUBLIC VOID initialize():
/* noop */
END METHOD.
/**
* Purpose: Returns an array of match results based on the current dsMatches
* Notes:
* @return The MatchResult array
*/
METHOD PRIVATE MatchResult EXTENT MatchResultExtent():
DEFINE QUERY qQuery FOR eMatches .
DEFINE VARIABLE oResult AS MatchResult EXTENT .
DEFINE VARIABLE i AS INTEGER NO-UNDO.
OPEN QUERY qQuery PRESELECT EACH eMatches .
IF QUERY qQuery:NUM-RESULTS > 0 THEN DO:
EXTENT (oResult) = QUERY qQuery:NUM-RESULTS .
GET FIRST qQuery .
DO WHILE NOT QUERY qQuery:QUERY-OFF-END:
ASSIGN i = i + 1
oResult [i] = NEW MatchResult(BUFFER eMatches:HANDLE) .
GET NEXT qQuery .
END.
END.
RETURN oResult.
END METHOD.
END CLASS.