2
2
<Export generator =" Cache" version =" 25" zv =" Cache for Windows (x86-64) 2015.2 (Build 540)" ts =" 2015-04-28 19:50:48" >
3
3
<Class name =" UMLExplorer.ClassView" >
4
4
<Description >
5
- Class contains methods that return structured class data.</Description >
6
- <TimeChanged >63671,64479.682329 </TimeChanged >
5
+ Class contains methods that return structured classes/packages data.</Description >
6
+ <TimeChanged >63680,165.360933 </TimeChanged >
7
7
<TimeCreated >63653,67019.989197</TimeCreated >
8
8
9
9
<Method name =" getClassTree" >
@@ -47,21 +47,27 @@ Returns structured class tree with all classes available in current namespace</D
47
47
]]> </Implementation >
48
48
</Method >
49
49
50
- <Method name =" getClassData " >
50
+ <Method name =" setClassData " >
51
51
<Description >
52
- return structured data about class</Description >
52
+ Return structured data about class. </Description >
53
53
<ClassMethod >1</ClassMethod >
54
- <FormalSpec >oData:%ZEN.proxyObject,classDefinition:%Dictionary.ClassDefinition</FormalSpec >
54
+ <FormalSpec >oData:%ZEN.proxyObject,className:%String</FormalSpec >
55
+ <Private >1</Private >
55
56
<ReturnType >%ZEN.proxyObject</ReturnType >
56
57
<Implementation ><![CDATA[
57
- set oClass = ##class(%ZEN.proxyObject).%New()
58
-
59
- set basePack = $LISTTOSTRING($LIST($LISTFROMSTRING(classDefinition.Name, "."), 1, *-1),".")
58
+ set classDefinition = ##class(%Dictionary.ClassDefinition).%OpenId(className)
59
+ if (classDefinition = "") || (oData.classes.%DispatchGetProperty(classDefinition.Name) '= "") quit ""
60
60
61
+ set oClass = ##class(%ZEN.proxyObject).%New()
62
+ do oData.classes.%DispatchSetProperty(classDefinition.Name, oClass) // prevent from recursive setup
63
+ set package = $LISTTOSTRING($LIST($LISTFROMSTRING(classDefinition.Name, "."), 1, *-1),".")
61
64
set oProperties = ##class(%ZEN.proxyObject).%New()
62
65
set oClass.NAMESPACE = $NAMESPACE
63
66
set oClass.ABSTRACT = classDefinition.Abstract
64
67
set oClass.super = classDefinition.Super
68
+
69
+ if (oData.restrictPackage) && ('..inPackage(oData.basePackageName, package)) quit oClass
70
+
65
71
set oClass.properties = oProperties
66
72
set count = classDefinition.Properties.Count()
67
73
for i = 1:1:count {
@@ -71,8 +77,8 @@ return structured data about class</Description>
71
77
do oProp.%DispatchSetProperty("private", p.Private)
72
78
do oProp.%DispatchSetProperty("readOnly", p.ReadOnly)
73
79
do oProp.%DispatchSetProperty("type", p.Type)
74
- do ..collectAggregation(oData, classDefinition.Name , p.Type, p.Private)
75
- do ..collectAggregation(oData, classDefinition.Name, basePack _ "." _ p.Type, p.Private)
80
+ do ..collectAggregation(oData, classDefinition, p.Type, p.Private)
81
+ do ..collectAggregation(oData, classDefinition, package _ "." _ p.Type, p.Private)
76
82
}
77
83
78
84
set oMethods = ##class(%ZEN.proxyObject).%New()
@@ -97,121 +103,156 @@ return structured data about class</Description>
97
103
do oPar.%DispatchSetProperty("type", p.Type)
98
104
}
99
105
106
+ do ..collectInheritance(oData, classDefinition, package)
107
+
100
108
quit oClass
101
109
]]> </Implementation >
102
110
</Method >
103
111
112
+ <Method name =" inPackage" >
113
+ <Description ><![CDATA[
114
+ Returns if <var>packageName</var> is in <var>basePackageName</var>.]]> </Description >
115
+ <ClassMethod >1</ClassMethod >
116
+ <FormalSpec >basePackageName:%String,packageName:%String</FormalSpec >
117
+ <Private >1</Private >
118
+ <ReturnType >%Boolean</ReturnType >
119
+ <Implementation ><![CDATA[ quit $FIND(packageName, basePackageName) - $LENGTH(basePackageName) = 1
120
+ ]]> </Implementation >
121
+ </Method >
122
+
104
123
<Method name =" extendClassFromType" >
124
+ <Description >
125
+ Wrap registered types to class names</Description >
105
126
<ClassMethod >1</ClassMethod >
106
127
<FormalSpec >typeName:%String</FormalSpec >
128
+ <Private >1</Private >
107
129
<ReturnType >%String</ReturnType >
108
130
<Implementation ><![CDATA[
109
- return $CASE(typeName,
131
+ return typeName
132
+ /*$CASE(typeName,
110
133
"%String": "%Library.String",
111
134
"%Integer": "%Library.Integer",
112
135
"%DataType": "%Library.DataType",
113
136
"%Status": "%Library.Status",
114
137
"%CacheString": "%Library.CacheString",
115
138
"%Persistent": "%Library.Persistent",
116
- :typeName)
139
+ :typeName)*/
117
140
]]> </Implementation >
118
141
</Method >
119
142
120
143
<Method name =" collectInheritance" >
144
+ <Description >
145
+ Fill inheritance data</Description >
121
146
<ClassMethod >1</ClassMethod >
122
- <FormalSpec >oData:%ZEN.proxyObject,baseClassDefinition:%Dictionary.ClassDefinition</FormalSpec >
147
+ <FormalSpec >oData:%ZEN.proxyObject,baseClassDefinition:%Dictionary.ClassDefinition,basePack:%String</FormalSpec >
148
+ <Private >1</Private >
123
149
<ReturnType >%Status</ReturnType >
124
150
<Implementation ><![CDATA[
125
151
set superParts = $LISTFROMSTRING(baseClassDefinition.Super, ",")
126
- if (oData.inheritance.%DispatchGetProperty(baseClassDefinition.Name) = "") {
127
- do oData.inheritance.%DispatchSetProperty(baseClassDefinition.Name, ##class(%ZEN.proxyObject).%New())
128
- }
129
- set oInherit = oData.inheritance.%DispatchGetProperty(baseClassDefinition.Name)
152
+ set oInherit = ##class(%ZEN.proxyObject).%New()
153
+ do oData.inheritance.%DispatchSetProperty(baseClassDefinition.Name, oInherit)
130
154
for i=1:1:$LISTLENGTH(superParts) {
131
155
set className = ..extendClassFromType($LISTGET(superParts, i))
132
- do oInherit.%DispatchSetProperty(className, 1)
133
- if (oData.classes.%DispatchGetProperty(className) = "") {
134
- set cdef = ##class(%Dictionary.ClassDefinition).%OpenId(className)
135
- if (cdef '= "") {
136
- do oData.classes.%DispatchSetProperty(className, ..getClassData(oData, cdef))
137
- do ..collectInheritance(oData, cdef)
138
- }
156
+
157
+ // try to find class with base package, if not successfull - try to add class as it is
158
+ if (..classExists(basePack_"."_className)) {
159
+ set clsName = basePack_"."_className
160
+ } else {
161
+ set clsName = className
139
162
}
163
+
164
+ do oInherit.%DispatchSetProperty(clsName, 1)
165
+ do ..setClassData(oData, clsName)
140
166
}
141
167
quit $$$OK
142
168
]]> </Implementation >
143
169
</Method >
144
170
145
171
<Method name =" collectAggregation" >
172
+ <Description >
173
+ Fill aggregation/composition data</Description >
146
174
<ClassMethod >1</ClassMethod >
147
- <FormalSpec >oData:%ZEN.proxyObject,className:%String,type:%String,private:%String</FormalSpec >
175
+ <FormalSpec >oData:%ZEN.proxyObject,classDef:%Dictionary.ClassDefinition,aggClassName:%String,private:%String</FormalSpec >
176
+ <Private >1</Private >
148
177
<ReturnType >%Status</ReturnType >
149
178
<Implementation ><![CDATA[
150
- set classDef = ##class(%Dictionary.ClassDefinition).%OpenId(type )
151
- if (classDef '= "") {
179
+ set aggClassDef = ##class(%Dictionary.ClassDefinition).%OpenId(aggClassName )
180
+ if (aggClassDef '= "") {
152
181
if (private) { set t = "composition" } else { set t = "aggregation" }
153
- set oAgg = oData.%DispatchGetProperty(t).%DispatchGetProperty(className )
182
+ set oAgg = oData.%DispatchGetProperty(t).%DispatchGetProperty(classDef.Name )
154
183
if (oAgg = "") {
155
184
set oAgg = ##class(%ZEN.proxyObject).%New()
156
- do oData.%DispatchGetProperty(t).%DispatchSetProperty(className , oAgg)
185
+ do oData.%DispatchGetProperty(t).%DispatchSetProperty(classDef.Name , oAgg)
157
186
}
158
187
} else { quit $$$OK }
159
188
160
- do oAgg.%DispatchSetProperty(type , "1..1")
161
- do ..collectClass (oData, classDef )
189
+ do oAgg.%DispatchSetProperty(aggClassName , "1..1")
190
+ do ..setClassData (oData, aggClassName )
162
191
163
192
quit $$$OK
164
193
]]> </Implementation >
165
194
</Method >
166
195
167
- <Method name =" collectClass" >
196
+ <Method name =" getBaseOData" >
197
+ <Description >
198
+ Setup basic output data object</Description >
168
199
<ClassMethod >1</ClassMethod >
169
- <FormalSpec >oData:%ZEN.proxyObject,cdef:%Dictionary.ClassDefinition</FormalSpec >
170
- <ReturnType >%Status</ReturnType >
200
+ <FormalSpec >packageName:%String</FormalSpec >
201
+ <Private >1</Private >
202
+ <ReturnType >%ZEN.proxyObject</ReturnType >
171
203
<Implementation ><![CDATA[
172
- if (oData.classes.%DispatchGetProperty(cdef.Name) '= "") { quit $$$OK }
173
- do oData.classes.%DispatchSetProperty(cdef.Name, "IDLE")
174
- do oData.classes.%DispatchSetProperty(cdef.Name, ..getClassData(oData, cdef))
175
- do ..collectInheritance(oData, cdef)
204
+ set oData = ##class(%ZEN.proxyObject).%New()
205
+ set oData.basePackageName = packageName
206
+ set oData.restrictPackage = 1 // expand classes only in base package
207
+ set oData.classes = ##class(%ZEN.proxyObject).%New()
208
+ set oData.inheritance = ##class(%ZEN.proxyObject).%New()
209
+ set oData.aggregation = ##class(%ZEN.proxyObject).%New()
210
+ set oData.composition = ##class(%ZEN.proxyObject).%New()
211
+ quit oData
212
+ ]]> </Implementation >
213
+ </Method >
214
+
215
+ <Method name =" classExists" >
216
+ <Description >
217
+ Returns if class with given name exists.</Description >
218
+ <ClassMethod >1</ClassMethod >
219
+ <FormalSpec >className:%String</FormalSpec >
220
+ <ReturnType >%Boolean</ReturnType >
221
+ <Implementation ><![CDATA[ quit ##class(%Dictionary.ClassDefinition).%OpenId(className) '= ""
176
222
]]> </Implementation >
177
223
</Method >
178
224
179
225
<Method name =" getClassView" >
226
+ <Description >
227
+ Returns structured class data</Description >
180
228
<ClassMethod >1</ClassMethod >
181
- <FormalSpec >baseClassDefinition:%Dictionary.ClassDefinition </FormalSpec >
229
+ <FormalSpec >className:%String </FormalSpec >
182
230
<ReturnType >%ZEN.proxyObject</ReturnType >
183
231
<Implementation ><![CDATA[
184
- set oData = ##class(%ZEN.proxyObject).%New()
185
- set oData.classes = ##class(%ZEN.proxyObject).%New()
186
- set oData.inheritance = ##class(%ZEN.proxyObject).%New()
187
- set oData.aggregation = ##class(%ZEN.proxyObject).%New()
188
- do ..collectClass(oData, baseClassDefinition)
189
-
232
+ set package = $LISTTOSTRING($LIST($LISTFROMSTRING(className, "."), 1, *-1), ".")
233
+ set oData = ..getBaseOData(package)
234
+ do ..setClassData(oData, className)
190
235
quit oData
191
236
]]> </Implementation >
192
237
</Method >
193
238
194
239
<Method name =" getPackageView" >
240
+ <Description >
241
+ Returns structured package data</Description >
195
242
<ClassMethod >1</ClassMethod >
196
243
<FormalSpec >rootPackageName:%String</FormalSpec >
197
244
<ReturnType >%ZEN.proxyObject</ReturnType >
198
245
<Implementation ><![CDATA[
199
- set oData = ##class(%ZEN.proxyObject).%New()
200
- set oData.classes = ##class(%ZEN.proxyObject).%New()
201
- set oData.inheritance = ##class(%ZEN.proxyObject).%New()
202
- set oData.aggregation = ##class(%ZEN.proxyObject).%New()
203
- set oData.composition = ##class(%ZEN.proxyObject).%New()
204
-
246
+ set oData = ..getBaseOData(rootPackageName)
205
247
set classes = ##class(%ResultSet).%New("%Dictionary.ClassDefinition:Summary")
206
248
do classes.Execute()
207
- set listLen = $LISTLENGTH($LISTFROMSTRING(rootPackageName, "."))
249
+ set listLen = $LISTLENGTH($LISTFROMSTRING(rootPackageName, ".")) // bottom level of package to extract
250
+
208
251
while (classes.Next()) {
209
252
set className = classes.Data("Name")
210
253
set packageName = $LISTTOSTRING($LIST($LISTFROMSTRING(className, "."), 1, listLen), ".")
211
254
if (packageName = rootPackageName) {
212
- set classDef = ##class(%Dictionary.ClassDefinition).%OpenId(className)
213
- do oData.classes.%DispatchSetProperty(classDef.Name, ..getClassData(oData, classDef))
214
- do ..collectInheritance(oData, classDef)
255
+ do ..setClassData(oData, className)
215
256
}
216
257
}
217
258
@@ -221,7 +262,7 @@ return structured data about class</Description>
221
262
</Class >
222
263
223
264
224
- <Project name =" UMLExplorer" LastModified =" 2015-04-28 23:30:37.941872 " >
265
+ <Project name =" UMLExplorer" LastModified =" 2015-04-29 19:47:03.727613 " >
225
266
<Items >
226
267
<ProjectItem name =" UMLExplorer.ClassView" type =" CLS" ></ProjectItem >
227
268
<ProjectItem name =" UMLExplorer.Router" type =" CLS" ></ProjectItem >
@@ -234,7 +275,7 @@ return structured data about class</Description>
234
275
<Description >
235
276
REST interface for UMLExplorer</Description >
236
277
<Super >%CSP.REST</Super >
237
- <TimeChanged >63670,71431.319061 </TimeChanged >
278
+ <TimeChanged >63679,81701.423669 </TimeChanged >
238
279
<TimeCreated >63648,30450.187229</TimeCreated >
239
280
240
281
<XData name =" UrlMap" >
@@ -270,9 +311,7 @@ Returns classTree by given class name</Description>
270
311
<FormalSpec >className:%String</FormalSpec >
271
312
<ReturnType >%Status</ReturnType >
272
313
<Implementation ><![CDATA[
273
- set cdef = ##class(%Dictionary.ClassDefinition).%OpenId(className)
274
- if (cdef = "") quit ..Http404()
275
- set classData = ##class(UMLExplorer.ClassView).getClassView(cdef)
314
+ set classData = ##class(UMLExplorer.ClassView).getClassView(className)
276
315
do classData.%ToJSON(, "ou")
277
316
return $$$OK
278
317
]]> </Implementation >
0 commit comments