Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
nikitaeverywhere committed Apr 25, 2015
2 parents feb1487 + cc7a38c commit 8e21625
Show file tree
Hide file tree
Showing 14 changed files with 445 additions and 101 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# CacheUMLExplorer
An UML Class explorer for InterSystems Caché. It can build UML class diagram for any class in Caché.
An UML Class explorer for InterSystems Caché. It can build UML class diagram for any class or even for whole package in Caché.

## Screenshots

Expand Down
157 changes: 116 additions & 41 deletions cache/projectTemplate.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,55 @@
<Class name="UMLExplorer.ClassView">
<Description>
Class contains methods that return structured class data.</Description>
<TimeChanged>63663,69939</TimeChanged>
<TimeChanged>63668,773.59952</TimeChanged>
<TimeCreated>63653,67019.989197</TimeCreated>

<Method name="getClassTree">
<ClassMethod>1</ClassMethod>
<ReturnType>%ZEN.proxyObject</ReturnType>
<Implementation><![CDATA[
set resp = ##class(%ZEN.proxyObject).%New()
set classes = ##class(%ResultSet).%New("%Dictionary.ClassDefinition:Summary")
set objects = ##class(%Library.ArrayOfObjects).%New()
set lastParts = $LB()
set level = 1
do objects.SetAt(resp, level)
do classes.Execute()
while (classes.Next()) {
set name = classes.Data("Name")
set parts = $LISTFROMSTRING(name, ".")
set i = 0
while (i < $LISTLENGTH(parts)) && ($LISTGET(lastParts, i + 1) = $LISTGET(parts, i + 1)) {
set i = i + 1
}
set level = i + 1
set resp = objects.GetAt(level)
while ($LISTLENGTH(parts) > level) {
set level = level + 1
set resp = ##class(%ZEN.proxyObject).%New()
do objects.GetAt(level - 1).%DispatchSetProperty($LISTGET(parts, level - 1), resp)
do objects.SetAt(resp, level)
}
if ($LISTLENGTH(parts) = level) {
do resp.%DispatchSetProperty($LISTGET(parts, level), classes.Data("Hidden"))
}
set lastParts = parts
}
quit objects.GetAt(1)
]]></Implementation>
</Method>

<Method name="getClassData">
<ClassMethod>1</ClassMethod>
<FormalSpec>classDefinition:%Dictionary.ClassDefinition</FormalSpec>
<ReturnType>%ZEN.proxyObject</ReturnType>
<Implementation><![CDATA[
set oClass = ##class(%ZEN.proxyObject).%New()
set oProperties = ##class(%ZEN.proxyObject).%New()
set oClass.super = classDefinition.Super
set oClass.properties = oProperties
Expand All @@ -35,7 +75,31 @@ Class contains methods that return structured class data.</Description>
do oMeth.%DispatchSetProperty("returns", classDefinition.Methods.GetAt(i).ReturnType)
}
return oClass
set oParameters = ##class(%ZEN.proxyObject).%New()
set oClass.parameters = oParameters
set count = classDefinition.Parameters.Count()
for i = 1:1:count {
set oPar = ##class(%ZEN.proxyObject).%New()
do oParameters.%DispatchSetProperty(classDefinition.Parameters.GetAt(i).Name, oPar)
do oPar.%DispatchSetProperty("type", classDefinition.Parameters.GetAt(i).Type)
}
quit oClass
]]></Implementation>
</Method>

<Method name="extendClassFromType">
<ClassMethod>1</ClassMethod>
<FormalSpec>typeName:%String</FormalSpec>
<ReturnType>%String</ReturnType>
<Implementation><![CDATA[
return $CASE(typeName,
"%String": "%Library.String",
"%Integer": "%Library.Integer",
"%DataType": "%Library.DataType",
"%Status": "%Library.Status",
"%CacheString": "%Library.CacheString",
:typeName)
]]></Implementation>
</Method>

Expand All @@ -50,7 +114,7 @@ Class contains methods that return structured class data.</Description>
}
set oInherit = oData.inheritance.%DispatchGetProperty(baseClassDefinition.Name)
for i=1:1:$LISTLENGTH(superParts) {
set className = $LISTGET(superParts, i)
set className = ..extendClassFromType($LISTGET(superParts, i))
do oInherit.%DispatchSetProperty(className, 1)
if (oData.classes.%DispatchGetProperty(className) = "") {
set cdef = ##class(%Dictionary.ClassDefinition).%OpenId(className)
Expand All @@ -60,13 +124,14 @@ Class contains methods that return structured class data.</Description>
}
}
}
return $$$OK
quit $$$OK
]]></Implementation>
</Method>

<Method name="getClassView">
<ClassMethod>1</ClassMethod>
<FormalSpec>baseClassDefinition:%Dictionary.ClassDefinition</FormalSpec>
<ReturnType>%ZEN.proxyObject</ReturnType>
<Implementation><![CDATA[
set oData = ##class(%ZEN.proxyObject).%New()
set oData.classes = ##class(%ZEN.proxyObject).%New()
Expand All @@ -75,17 +140,43 @@ Class contains methods that return structured class data.</Description>
do ..collectInheritance(oData, baseClassDefinition)
return oData
quit oData
]]></Implementation>
</Method>

<Method name="getPackageView">
<ClassMethod>1</ClassMethod>
<FormalSpec>rootPackageName:%String</FormalSpec>
<ReturnType>%ZEN.proxyObject</ReturnType>
<Implementation><![CDATA[
set oData = ##class(%ZEN.proxyObject).%New()
set oData.classes = ##class(%ZEN.proxyObject).%New()
set oData.inheritance = ##class(%ZEN.proxyObject).%New()
set classes = ##class(%ResultSet).%New("%Dictionary.ClassDefinition:Summary")
do classes.Execute()
set listLen = $LISTLENGTH($LISTFROMSTRING(rootPackageName, "."))
while (classes.Next()) {
set className = classes.Data("Name")
set packageName = $LISTTOSTRING($LIST($LISTFROMSTRING(className, "."), 1, listLen), ".")
if (packageName = rootPackageName) {
set classDef = ##class(%Dictionary.ClassDefinition).%OpenId(className)
do oData.classes.%DispatchSetProperty(classDef.Name, ..getClassData(classDef))
do ..collectInheritance(oData, classDef)
}
}
quit oData
]]></Implementation>
</Method>
</Class>


<Project name="UMLExplorer" LastModified="2015-04-12 19:03:12.221887">
<Project name="UMLExplorer" LastModified="2015-04-25 15:46:50.605954">
<Items>
<ProjectItem name="UMLExplorer.Router" type="CLS"></ProjectItem>
<ProjectItem name="UMLExplorer.ClassView" type="CLS"></ProjectItem>
<ProjectItem name="UMLExplorer.StaticContent" type="CLS"></ProjectItem>
<ProjectItem name="UMLExplorer.ClassView" type="CLS"/>
<ProjectItem name="UMLExplorer.Router" type="CLS"/>
<ProjectItem name="UMLExplorer.StaticContent" type="CLS"/>
</Items>
</Project>

Expand All @@ -94,7 +185,7 @@ Class contains methods that return structured class data.</Description>
<Description>
REST interface for UMLExplorer</Description>
<Super>%CSP.REST</Super>
<TimeChanged>63663,76166.562046</TimeChanged>
<TimeChanged>63667,85509.960346</TimeChanged>
<TimeCreated>63648,30450.187229</TimeCreated>

<XData name="UrlMap">
Expand All @@ -107,6 +198,7 @@ REST interface for UMLExplorer</Description>
<Route Url="/Test" Method="GET" Call="Test"/>
<Route Url="/GetClassTree" Method="GET" Call="GetClassTree"/>
<Route Url="/GetClassView/:ClassName" Method="GET" Call="GetClassView"/>
<Route Url="/GetPackageView/:PackageName" Method="GET" Call="GetPackageView"/>
</Routes>
]]></Data>
</XData>
Expand All @@ -117,37 +209,7 @@ Method returns whole class tree visible in the current namespace.</Description>
<ClassMethod>1</ClassMethod>
<ReturnType>%Status</ReturnType>
<Implementation><![CDATA[
set resp = ##class(%ZEN.proxyObject).%New()
set classes = ##class(%ResultSet).%New("%Dictionary.ClassDefinition:Summary")
set objects = ##class(%Library.ArrayOfObjects).%New()
set lastParts = $LB()
set level = 1
do objects.SetAt(resp, level)
do classes.Execute()
While (classes.Next()) {
set name = classes.Data("Name")
set parts = $LISTFROMSTRING(name, ".")
set i = 0
while (i < $LISTLENGTH(parts)) && ($LISTGET(lastParts, i + 1) = $LISTGET(parts, i + 1)) {
set i = i + 1
}
set level = i + 1
set resp = objects.GetAt(level)
while ($LISTLENGTH(parts) > level) {
set level = level + 1
set resp = ##class(%ZEN.proxyObject).%New()
do objects.GetAt(level - 1).%DispatchSetProperty($LISTGET(parts, level - 1), resp)
do objects.SetAt(resp, level)
}
if ($LISTLENGTH(parts) = level) {
do resp.%DispatchSetProperty($LISTGET(parts, level), classes.Data("Hidden"))
}
set lastParts = parts
}
do objects.GetAt(1).%ToJSON(, "ou")
do ##class(UMLExplorer.ClassView).getClassTree().%ToJSON(, "ou")
return $$$OK
]]></Implementation>
</Method>
Expand All @@ -167,6 +229,19 @@ Returns classTree by given class name</Description>
]]></Implementation>
</Method>

<Method name="GetPackageView">
<Description>
Returns all package class trees by given package name</Description>
<ClassMethod>1</ClassMethod>
<FormalSpec>packageName:%String</FormalSpec>
<ReturnType>%Status</ReturnType>
<Implementation><![CDATA[
set classData = ##class(UMLExplorer.ClassView).getPackageView(packageName)
do classData.%ToJSON(, "ou")
return $$$OK
]]></Implementation>
</Method>

<Method name="Test">
<Description>
Method to test accessibility of REST interface.</Description>
Expand Down
34 changes: 26 additions & 8 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ var gulp = require("gulp"),
concat = require("gulp-concat"),
uglify = require("gulp-uglify"),
wrap = require("gulp-wrap"),
stripComments = require("gulp-strip-comments"),
addsrc = require('gulp-add-src'),
minifyCSS = require("gulp-minify-css"),
htmlReplace = require("gulp-html-replace"),
Expand All @@ -14,6 +15,7 @@ var gulp = require("gulp"),
rename = require("gulp-rename");

var banner = [
"",
"/** <%= pkg.name %>",
" ** <%= pkg.description %>",
" ** @author <%= pkg.author %>",
Expand All @@ -29,24 +31,40 @@ gulp.task("clean", function () {
.pipe(clean());
});

gulp.task("gatherScripts", ["clean"], function () {
return gulp.src("web/js/*.js")
.pipe(concat("CacheUMLExplorer.js"))
.pipe(replace(/\/\*\{\{replace:version}}\*\//, "\"" + pkg["version"] + "\""))
.pipe(wrap("CacheUMLExplorer = (function(){<%= contents %> return CacheUMLExplorer;}());"))
gulp.task("gatherLibs", ["clean"], function () {
return gulp.src([
"web/jsLib/joint.shapes.uml.js"
])
.pipe(uglify({
output: {
ascii_only: true,
width: 30000,
max_line_len: 30000
}
}))
.pipe(header(banner, { pkg: pkg }))
.pipe(addsrc.prepend([
"web/jsLib/joint.min.js",
"web/jsLib/joint.shapes.uml.js",
"web/jsLib/joint.layout.DirectedGraph.min.js"
]))
.pipe(stripComments({ safe: true }))
.pipe(concat("CacheUMLExplorer.js"))
.pipe(gulp.dest("build/web/js/"));
});

gulp.task("gatherScripts", ["clean", "gatherLibs"], function () {
return gulp.src("web/js/*.js")
.pipe(concat("CacheUMLExplorer.js"))
.pipe(replace(/[^\s]+\/\*build.replace:(.*)\*\//g, "$1"))
.pipe(wrap("CacheUMLExplorer = (function(){<%= contents %> return CacheUMLExplorer;}());"))
.pipe(uglify({
output: {
ascii_only: true,
width: 30000,
max_line_len: 30000
}
}))
.pipe(header(banner, { pkg: pkg }))
.pipe(addsrc.prepend("build/web/js/CacheUMLExplorer.js"))
.pipe(concat("CacheUMLExplorer.js"))
.pipe(gulp.dest("build/web/js/"));
});
Expand Down Expand Up @@ -90,7 +108,7 @@ gulp.task("exportCacheXML", [
/\{\{replace:js}}/,
function () { return fs.readFileSync("build/web/js/CacheUMLExplorer.js", "utf-8"); }
))
.pipe(rename(function (path) { path.basename += "-v" + pkg["version"]; }))
.pipe(rename(function (path) { path.basename = "CacheUMLExplorer-v" + pkg["version"]; }))
.pipe(gulp.dest("build/Cache"));
});

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "CacheUMLExplorer",
"version": "0.2",
"version": "0.3.0",
"description": "An UML Class explorer for InterSystems Caché",
"directories": {
"test": "test"
Expand All @@ -17,6 +17,7 @@
"gulp-minify-css": "^0.3.11",
"gulp-rename": "^1.2.0",
"gulp-replace": "^0.5.0",
"gulp-strip-comments": "^1.0.1",
"gulp-uglify": "^1.0.1",
"gulp-wrap": "^0.5.0",
"gulp-zip": "^2.0.2"
Expand Down
Loading

0 comments on commit 8e21625

Please sign in to comment.