Skip to content

Commit 8e21625

Browse files
Merge remote-tracking branch 'upstream/master'
2 parents feb1487 + cc7a38c commit 8e21625

14 files changed

+445
-101
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# CacheUMLExplorer
2-
An UML Class explorer for InterSystems Caché. It can build UML class diagram for any class in Caché.
2+
An UML Class explorer for InterSystems Caché. It can build UML class diagram for any class or even for whole package in Caché.
33

44
## Screenshots
55

cache/projectTemplate.xml

Lines changed: 116 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,55 @@
44
<Class name="UMLExplorer.ClassView">
55
<Description>
66
Class contains methods that return structured class data.</Description>
7-
<TimeChanged>63663,69939</TimeChanged>
7+
<TimeChanged>63668,773.59952</TimeChanged>
88
<TimeCreated>63653,67019.989197</TimeCreated>
99

10+
<Method name="getClassTree">
11+
<ClassMethod>1</ClassMethod>
12+
<ReturnType>%ZEN.proxyObject</ReturnType>
13+
<Implementation><![CDATA[
14+
set resp = ##class(%ZEN.proxyObject).%New()
15+
16+
set classes = ##class(%ResultSet).%New("%Dictionary.ClassDefinition:Summary")
17+
set objects = ##class(%Library.ArrayOfObjects).%New()
18+
set lastParts = $LB()
19+
20+
set level = 1
21+
do objects.SetAt(resp, level)
22+
23+
do classes.Execute()
24+
while (classes.Next()) {
25+
set name = classes.Data("Name")
26+
set parts = $LISTFROMSTRING(name, ".")
27+
set i = 0
28+
while (i < $LISTLENGTH(parts)) && ($LISTGET(lastParts, i + 1) = $LISTGET(parts, i + 1)) {
29+
set i = i + 1
30+
}
31+
set level = i + 1
32+
set resp = objects.GetAt(level)
33+
while ($LISTLENGTH(parts) > level) {
34+
set level = level + 1
35+
set resp = ##class(%ZEN.proxyObject).%New()
36+
do objects.GetAt(level - 1).%DispatchSetProperty($LISTGET(parts, level - 1), resp)
37+
do objects.SetAt(resp, level)
38+
}
39+
if ($LISTLENGTH(parts) = level) {
40+
do resp.%DispatchSetProperty($LISTGET(parts, level), classes.Data("Hidden"))
41+
}
42+
set lastParts = parts
43+
}
44+
45+
quit objects.GetAt(1)
46+
]]></Implementation>
47+
</Method>
48+
1049
<Method name="getClassData">
1150
<ClassMethod>1</ClassMethod>
1251
<FormalSpec>classDefinition:%Dictionary.ClassDefinition</FormalSpec>
1352
<ReturnType>%ZEN.proxyObject</ReturnType>
1453
<Implementation><![CDATA[
1554
set oClass = ##class(%ZEN.proxyObject).%New()
55+
1656
set oProperties = ##class(%ZEN.proxyObject).%New()
1757
set oClass.super = classDefinition.Super
1858
set oClass.properties = oProperties
@@ -35,7 +75,31 @@ Class contains methods that return structured class data.</Description>
3575
do oMeth.%DispatchSetProperty("returns", classDefinition.Methods.GetAt(i).ReturnType)
3676
}
3777
38-
return oClass
78+
set oParameters = ##class(%ZEN.proxyObject).%New()
79+
set oClass.parameters = oParameters
80+
set count = classDefinition.Parameters.Count()
81+
for i = 1:1:count {
82+
set oPar = ##class(%ZEN.proxyObject).%New()
83+
do oParameters.%DispatchSetProperty(classDefinition.Parameters.GetAt(i).Name, oPar)
84+
do oPar.%DispatchSetProperty("type", classDefinition.Parameters.GetAt(i).Type)
85+
}
86+
87+
quit oClass
88+
]]></Implementation>
89+
</Method>
90+
91+
<Method name="extendClassFromType">
92+
<ClassMethod>1</ClassMethod>
93+
<FormalSpec>typeName:%String</FormalSpec>
94+
<ReturnType>%String</ReturnType>
95+
<Implementation><![CDATA[
96+
return $CASE(typeName,
97+
"%String": "%Library.String",
98+
"%Integer": "%Library.Integer",
99+
"%DataType": "%Library.DataType",
100+
"%Status": "%Library.Status",
101+
"%CacheString": "%Library.CacheString",
102+
:typeName)
39103
]]></Implementation>
40104
</Method>
41105

@@ -50,7 +114,7 @@ Class contains methods that return structured class data.</Description>
50114
}
51115
set oInherit = oData.inheritance.%DispatchGetProperty(baseClassDefinition.Name)
52116
for i=1:1:$LISTLENGTH(superParts) {
53-
set className = $LISTGET(superParts, i)
117+
set className = ..extendClassFromType($LISTGET(superParts, i))
54118
do oInherit.%DispatchSetProperty(className, 1)
55119
if (oData.classes.%DispatchGetProperty(className) = "") {
56120
set cdef = ##class(%Dictionary.ClassDefinition).%OpenId(className)
@@ -60,13 +124,14 @@ Class contains methods that return structured class data.</Description>
60124
}
61125
}
62126
}
63-
return $$$OK
127+
quit $$$OK
64128
]]></Implementation>
65129
</Method>
66130

67131
<Method name="getClassView">
68132
<ClassMethod>1</ClassMethod>
69133
<FormalSpec>baseClassDefinition:%Dictionary.ClassDefinition</FormalSpec>
134+
<ReturnType>%ZEN.proxyObject</ReturnType>
70135
<Implementation><![CDATA[
71136
set oData = ##class(%ZEN.proxyObject).%New()
72137
set oData.classes = ##class(%ZEN.proxyObject).%New()
@@ -75,17 +140,43 @@ Class contains methods that return structured class data.</Description>
75140
76141
do ..collectInheritance(oData, baseClassDefinition)
77142
78-
return oData
143+
quit oData
144+
]]></Implementation>
145+
</Method>
146+
147+
<Method name="getPackageView">
148+
<ClassMethod>1</ClassMethod>
149+
<FormalSpec>rootPackageName:%String</FormalSpec>
150+
<ReturnType>%ZEN.proxyObject</ReturnType>
151+
<Implementation><![CDATA[
152+
set oData = ##class(%ZEN.proxyObject).%New()
153+
set oData.classes = ##class(%ZEN.proxyObject).%New()
154+
set oData.inheritance = ##class(%ZEN.proxyObject).%New()
155+
156+
set classes = ##class(%ResultSet).%New("%Dictionary.ClassDefinition:Summary")
157+
do classes.Execute()
158+
set listLen = $LISTLENGTH($LISTFROMSTRING(rootPackageName, "."))
159+
while (classes.Next()) {
160+
set className = classes.Data("Name")
161+
set packageName = $LISTTOSTRING($LIST($LISTFROMSTRING(className, "."), 1, listLen), ".")
162+
if (packageName = rootPackageName) {
163+
set classDef = ##class(%Dictionary.ClassDefinition).%OpenId(className)
164+
do oData.classes.%DispatchSetProperty(classDef.Name, ..getClassData(classDef))
165+
do ..collectInheritance(oData, classDef)
166+
}
167+
}
168+
169+
quit oData
79170
]]></Implementation>
80171
</Method>
81172
</Class>
82173

83174

84-
<Project name="UMLExplorer" LastModified="2015-04-12 19:03:12.221887">
175+
<Project name="UMLExplorer" LastModified="2015-04-25 15:46:50.605954">
85176
<Items>
86-
<ProjectItem name="UMLExplorer.Router" type="CLS"></ProjectItem>
87-
<ProjectItem name="UMLExplorer.ClassView" type="CLS"></ProjectItem>
88-
<ProjectItem name="UMLExplorer.StaticContent" type="CLS"></ProjectItem>
177+
<ProjectItem name="UMLExplorer.ClassView" type="CLS"/>
178+
<ProjectItem name="UMLExplorer.Router" type="CLS"/>
179+
<ProjectItem name="UMLExplorer.StaticContent" type="CLS"/>
89180
</Items>
90181
</Project>
91182

@@ -94,7 +185,7 @@ Class contains methods that return structured class data.</Description>
94185
<Description>
95186
REST interface for UMLExplorer</Description>
96187
<Super>%CSP.REST</Super>
97-
<TimeChanged>63663,76166.562046</TimeChanged>
188+
<TimeChanged>63667,85509.960346</TimeChanged>
98189
<TimeCreated>63648,30450.187229</TimeCreated>
99190

100191
<XData name="UrlMap">
@@ -107,6 +198,7 @@ REST interface for UMLExplorer</Description>
107198
<Route Url="/Test" Method="GET" Call="Test"/>
108199
<Route Url="/GetClassTree" Method="GET" Call="GetClassTree"/>
109200
<Route Url="/GetClassView/:ClassName" Method="GET" Call="GetClassView"/>
201+
<Route Url="/GetPackageView/:PackageName" Method="GET" Call="GetPackageView"/>
110202
</Routes>
111203
]]></Data>
112204
</XData>
@@ -117,37 +209,7 @@ Method returns whole class tree visible in the current namespace.</Description>
117209
<ClassMethod>1</ClassMethod>
118210
<ReturnType>%Status</ReturnType>
119211
<Implementation><![CDATA[
120-
set resp = ##class(%ZEN.proxyObject).%New()
121-
set classes = ##class(%ResultSet).%New("%Dictionary.ClassDefinition:Summary")
122-
set objects = ##class(%Library.ArrayOfObjects).%New()
123-
set lastParts = $LB()
124-
125-
set level = 1
126-
do objects.SetAt(resp, level)
127-
128-
do classes.Execute()
129-
While (classes.Next()) {
130-
set name = classes.Data("Name")
131-
set parts = $LISTFROMSTRING(name, ".")
132-
set i = 0
133-
while (i < $LISTLENGTH(parts)) && ($LISTGET(lastParts, i + 1) = $LISTGET(parts, i + 1)) {
134-
set i = i + 1
135-
}
136-
set level = i + 1
137-
set resp = objects.GetAt(level)
138-
while ($LISTLENGTH(parts) > level) {
139-
set level = level + 1
140-
set resp = ##class(%ZEN.proxyObject).%New()
141-
do objects.GetAt(level - 1).%DispatchSetProperty($LISTGET(parts, level - 1), resp)
142-
do objects.SetAt(resp, level)
143-
}
144-
if ($LISTLENGTH(parts) = level) {
145-
do resp.%DispatchSetProperty($LISTGET(parts, level), classes.Data("Hidden"))
146-
}
147-
set lastParts = parts
148-
}
149-
150-
do objects.GetAt(1).%ToJSON(, "ou")
212+
do ##class(UMLExplorer.ClassView).getClassTree().%ToJSON(, "ou")
151213
return $$$OK
152214
]]></Implementation>
153215
</Method>
@@ -167,6 +229,19 @@ Returns classTree by given class name</Description>
167229
]]></Implementation>
168230
</Method>
169231

232+
<Method name="GetPackageView">
233+
<Description>
234+
Returns all package class trees by given package name</Description>
235+
<ClassMethod>1</ClassMethod>
236+
<FormalSpec>packageName:%String</FormalSpec>
237+
<ReturnType>%Status</ReturnType>
238+
<Implementation><![CDATA[
239+
set classData = ##class(UMLExplorer.ClassView).getPackageView(packageName)
240+
do classData.%ToJSON(, "ou")
241+
return $$$OK
242+
]]></Implementation>
243+
</Method>
244+
170245
<Method name="Test">
171246
<Description>
172247
Method to test accessibility of REST interface.</Description>

gulpfile.js

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ var gulp = require("gulp"),
44
concat = require("gulp-concat"),
55
uglify = require("gulp-uglify"),
66
wrap = require("gulp-wrap"),
7+
stripComments = require("gulp-strip-comments"),
78
addsrc = require('gulp-add-src'),
89
minifyCSS = require("gulp-minify-css"),
910
htmlReplace = require("gulp-html-replace"),
@@ -14,6 +15,7 @@ var gulp = require("gulp"),
1415
rename = require("gulp-rename");
1516

1617
var banner = [
18+
"",
1719
"/** <%= pkg.name %>",
1820
" ** <%= pkg.description %>",
1921
" ** @author <%= pkg.author %>",
@@ -29,24 +31,40 @@ gulp.task("clean", function () {
2931
.pipe(clean());
3032
});
3133

32-
gulp.task("gatherScripts", ["clean"], function () {
33-
return gulp.src("web/js/*.js")
34-
.pipe(concat("CacheUMLExplorer.js"))
35-
.pipe(replace(/\/\*\{\{replace:version}}\*\//, "\"" + pkg["version"] + "\""))
36-
.pipe(wrap("CacheUMLExplorer = (function(){<%= contents %> return CacheUMLExplorer;}());"))
34+
gulp.task("gatherLibs", ["clean"], function () {
35+
return gulp.src([
36+
"web/jsLib/joint.shapes.uml.js"
37+
])
3738
.pipe(uglify({
3839
output: {
3940
ascii_only: true,
4041
width: 30000,
4142
max_line_len: 30000
4243
}
4344
}))
44-
.pipe(header(banner, { pkg: pkg }))
4545
.pipe(addsrc.prepend([
4646
"web/jsLib/joint.min.js",
47-
"web/jsLib/joint.shapes.uml.js",
4847
"web/jsLib/joint.layout.DirectedGraph.min.js"
4948
]))
49+
.pipe(stripComments({ safe: true }))
50+
.pipe(concat("CacheUMLExplorer.js"))
51+
.pipe(gulp.dest("build/web/js/"));
52+
});
53+
54+
gulp.task("gatherScripts", ["clean", "gatherLibs"], function () {
55+
return gulp.src("web/js/*.js")
56+
.pipe(concat("CacheUMLExplorer.js"))
57+
.pipe(replace(/[^\s]+\/\*build.replace:(.*)\*\//g, "$1"))
58+
.pipe(wrap("CacheUMLExplorer = (function(){<%= contents %> return CacheUMLExplorer;}());"))
59+
.pipe(uglify({
60+
output: {
61+
ascii_only: true,
62+
width: 30000,
63+
max_line_len: 30000
64+
}
65+
}))
66+
.pipe(header(banner, { pkg: pkg }))
67+
.pipe(addsrc.prepend("build/web/js/CacheUMLExplorer.js"))
5068
.pipe(concat("CacheUMLExplorer.js"))
5169
.pipe(gulp.dest("build/web/js/"));
5270
});
@@ -90,7 +108,7 @@ gulp.task("exportCacheXML", [
90108
/\{\{replace:js}}/,
91109
function () { return fs.readFileSync("build/web/js/CacheUMLExplorer.js", "utf-8"); }
92110
))
93-
.pipe(rename(function (path) { path.basename += "-v" + pkg["version"]; }))
111+
.pipe(rename(function (path) { path.basename = "CacheUMLExplorer-v" + pkg["version"]; }))
94112
.pipe(gulp.dest("build/Cache"));
95113
});
96114

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "CacheUMLExplorer",
3-
"version": "0.2",
3+
"version": "0.3.0",
44
"description": "An UML Class explorer for InterSystems Caché",
55
"directories": {
66
"test": "test"
@@ -17,6 +17,7 @@
1717
"gulp-minify-css": "^0.3.11",
1818
"gulp-rename": "^1.2.0",
1919
"gulp-replace": "^0.5.0",
20+
"gulp-strip-comments": "^1.0.1",
2021
"gulp-uglify": "^1.0.1",
2122
"gulp-wrap": "^0.5.0",
2223
"gulp-zip": "^2.0.2"

0 commit comments

Comments
 (0)