getSubProjectsOf(Job,?> project);
40 | }
41 |
--------------------------------------------------------------------------------
/src/main/java/hudson/plugins/depgraph_view/model/operations/DeleteEdgeOperation.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2012 Stefan Wolf
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | * THE SOFTWARE.
21 | */
22 |
23 | package hudson.plugins.depgraph_view.model.operations;
24 |
25 | import hudson.model.Result;
26 | import hudson.tasks.BuildTrigger;
27 | import jenkins.model.Jenkins;
28 |
29 | import java.io.IOException;
30 |
31 | public class DeleteEdgeOperation extends EdgeOperation {
32 |
33 | public DeleteEdgeOperation(String sourceJobName, String targetJobName) {
34 | super(sourceJobName, targetJobName);
35 | }
36 |
37 | public void perform() throws IOException {
38 | if (source != null && target != null) {
39 | final BuildTrigger buildTrigger = source.getPublishersList().get(BuildTrigger.class);
40 | if (buildTrigger != null) {
41 | final String childProjectsValue = normalizeChildProjectValue(buildTrigger.getChildProjectsValue().replace(target.getName(), ""));
42 | final Result threshold = buildTrigger.getThreshold();
43 | source.getPublishersList().remove(buildTrigger);
44 | if (!childProjectsValue.isEmpty()) {
45 | source.getPublishersList().add(new BuildTrigger(childProjectsValue, threshold));
46 | }
47 | source.save();
48 | target.save();
49 | Jenkins.get().rebuildDependencyGraph();
50 | }
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/src/main/java/hudson/plugins/depgraph_view/model/operations/EdgeOperation.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2012 Stefan Wolf
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | * THE SOFTWARE.
21 | */
22 |
23 | package hudson.plugins.depgraph_view.model.operations;
24 |
25 | import java.io.IOException;
26 |
27 | import org.acegisecurity.AccessDeniedException;
28 |
29 | import hudson.model.AbstractProject;
30 | import hudson.security.Permission;
31 | import jenkins.model.Jenkins;
32 |
33 | public abstract class EdgeOperation {
34 | protected final AbstractProject, ?> source;
35 | protected final AbstractProject, ?> target;
36 |
37 | public EdgeOperation(String sourceJobName, String targetJobName) {
38 | source = Jenkins.get().getItemByFullName(sourceJobName.trim(), AbstractProject.class);
39 | target = Jenkins.get().getItemByFullName(targetJobName, AbstractProject.class);
40 | if (source == null) { throw new UnsupportedOperationException("editing not supported for upstream job type."); }
41 | if (target == null) { throw new UnsupportedOperationException("editing not supported for downstream job type."); }
42 | if (!source.hasPermission(Permission.CONFIGURE)) {
43 | throw new AccessDeniedException("no permission to configure upstream job.");
44 | }
45 | }
46 |
47 | /**
48 | * Removes double commas and also trailing and leading commas.
49 | * @param actualValue the actual value to be normalized
50 | * @return the value with no unrequired commas
51 | */
52 | public static String normalizeChildProjectValue(String actualValue){
53 | actualValue = actualValue.replaceAll("(,[ ]*,)", ", ");
54 | actualValue = actualValue.replaceAll("(^,|,$)", "");
55 | return actualValue.trim();
56 | }
57 |
58 | public abstract void perform() throws IOException;
59 | }
60 |
--------------------------------------------------------------------------------
/src/main/java/hudson/plugins/depgraph_view/model/operations/PutEdgeOperation.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2012 Stefan Wolf
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | * THE SOFTWARE.
21 | */
22 |
23 | package hudson.plugins.depgraph_view.model.operations;
24 |
25 | import hudson.tasks.BuildTrigger;
26 | import jenkins.model.Jenkins;
27 |
28 | import java.io.IOException;
29 |
30 | public class PutEdgeOperation extends EdgeOperation {
31 |
32 | public PutEdgeOperation(String sourceJobName, String targetJobName) {
33 | super(sourceJobName, targetJobName);
34 | }
35 |
36 | public void perform() throws IOException {
37 | if (source != null && target != null) {
38 | final BuildTrigger buildTrigger = source.getPublishersList().get(BuildTrigger.class);
39 | if (buildTrigger == null) {
40 | source.getPublishersList().add(new BuildTrigger(target.getName(), true));
41 | } else {
42 | final String childProjectsValue = normalizeChildProjectValue(buildTrigger.getChildProjectsValue() + ", " + target.getName());
43 | source.getPublishersList().remove(buildTrigger);
44 | source.getPublishersList().add(new BuildTrigger(childProjectsValue, true));
45 | }
46 | source.save();
47 | target.save();
48 | Jenkins.get().rebuildDependencyGraph();
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/src/main/resources/hudson/plugins/depgraph_view/AbstractDependencyGraphAction/index.jelly:
--------------------------------------------------------------------------------
1 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 | ${it.title}
42 |
43 |
44 |
45 |
46 |
47 |
48 | ${%Graph in graphviz format}
49 |
50 | ${%Legend}
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
--------------------------------------------------------------------------------
/src/main/resources/hudson/plugins/depgraph_view/AbstractDependencyGraphAction/index_de.properties:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jenkinsci/depgraph-view-plugin/aef4b5ff552257e3914716351f14b3f1af7d1545/src/main/resources/hudson/plugins/depgraph_view/AbstractDependencyGraphAction/index_de.properties
--------------------------------------------------------------------------------
/src/main/resources/hudson/plugins/depgraph_view/AbstractDependencyGraphAction/jsplumb.jelly:
--------------------------------------------------------------------------------
1 |
22 |
23 |
24 |
25 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 | ${it.title}
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 | ${%Json format}
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
67 |
68 |
69 |
70 |
71 |
--------------------------------------------------------------------------------
/src/main/resources/hudson/plugins/depgraph_view/AbstractDependencyGraphAction/sidepanel.jelly:
--------------------------------------------------------------------------------
1 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/src/main/resources/hudson/plugins/depgraph_view/DependencyGraphProperty/global.jelly:
--------------------------------------------------------------------------------
1 |
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 |
--------------------------------------------------------------------------------
/src/main/resources/hudson/plugins/depgraph_view/DependencyGraphProperty/global.properties:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright (c) 2012 Dominik Bartholdi
3 | #
4 | # Permission is hereby granted, free of charge, to any person obtaining a copy
5 | # of this software and associated documentation files (the "Software"), to deal
6 | # in the Software without restriction, including without limitation the rights
7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | # copies of the Software, and to permit persons to whom the Software is
9 | # furnished to do so, subject to the following conditions:
10 | #
11 | # The above copyright notice and this permission notice shall be included in
12 | # all copies or substantial portions of the Software.
13 | #
14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | # THE SOFTWARE.
21 | #
22 |
23 | editFunctionInJSViewEnabled=Enable edit functiononality in jsplumb view
24 | projectNameStripRegex=Strip the project names
25 | graphRankDirection=Graphviz rank direction
--------------------------------------------------------------------------------
/src/main/resources/hudson/plugins/depgraph_view/DependencyGraphProperty/global_de.properties:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jenkinsci/depgraph-view-plugin/aef4b5ff552257e3914716351f14b3f1af7d1545/src/main/resources/hudson/plugins/depgraph_view/DependencyGraphProperty/global_de.properties
--------------------------------------------------------------------------------
/src/main/resources/hudson/plugins/depgraph_view/DependencyGraphProperty/help-dotExe.html:
--------------------------------------------------------------------------------
1 |
22 |
23 |
24 | Configure the location of the dot binary. If not set, defaults to dot (or dot.exe on Windows).
25 |
--------------------------------------------------------------------------------
/src/main/resources/hudson/plugins/depgraph_view/DependencyGraphProperty/help-dotExe_de.html:
--------------------------------------------------------------------------------
1 |
22 |
23 |
24 | Konfiguriation des Orts des dot Befehls. Wenn nichts gesetzt ist, dann wird
25 | als Standard dot (oder dot.exe bei Windows) verwendet.
26 |
--------------------------------------------------------------------------------
/src/main/resources/hudson/plugins/depgraph_view/DependencyGraphProperty/help-editFunctionInJSViewEnabled.html:
--------------------------------------------------------------------------------
1 |
22 |
23 |
24 | The graph rendered with jsplumb also allows creation and deletion of dependencies between the jobs via drag and drop. This functionality might not be requested in every setup, therefore one is able to disable it.
25 |
--------------------------------------------------------------------------------
/src/main/resources/hudson/plugins/depgraph_view/DependencyGraphProperty/help-graphRankDirection.html:
--------------------------------------------------------------------------------
1 |
22 |
23 |
24 | The direction used by graphviz to layout graph nodes.
25 | Can be set to TB
(top to bottom) or LR
(left to right), default is TB
.
26 |
--------------------------------------------------------------------------------
/src/main/resources/hudson/plugins/depgraph_view/DependencyGraphProperty/help-projectNameStripRegex.html:
--------------------------------------------------------------------------------
1 |
22 |
23 |
24 | Some companies have naming conventions, this often results in long names which take to much space when displayed. This setting lets you define a global regular expression to define what part of the full name should be shown in the graphs. Default is .*
, which shows the full name.
25 | com.comp.proj.(.*)
will strip 'com.comp.proj' from every project name.
26 | With the group definition one can define the group of the given regex to be used.
27 |
--------------------------------------------------------------------------------
/src/main/resources/hudson/plugins/depgraph_view/DependencyGraphProperty/help-projectNameStripRegexGroup.html:
--------------------------------------------------------------------------------
1 |
22 |
23 |
24 | Allows to define the group of regular expression to be used for to display as the job name, defaults to 1
.
25 |
--------------------------------------------------------------------------------
/src/main/resources/hudson/plugins/depgraph_view/DependencyGraphProperty/help-projectNameStripRegexGroup_de.html:
--------------------------------------------------------------------------------
1 |
22 |
23 |
24 | Erlaubt es zu definieren welche Gruppe aus der RegularExpression als Job Name im DependencyGraph angezeigt werden soll, Defaults ist 1
.
25 |
--------------------------------------------------------------------------------
/src/main/resources/hudson/plugins/depgraph_view/DependencyGraphProperty/help-projectNameStripRegex_de.html:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jenkinsci/depgraph-view-plugin/aef4b5ff552257e3914716351f14b3f1af7d1545/src/main/resources/hudson/plugins/depgraph_view/DependencyGraphProperty/help-projectNameStripRegex_de.html
--------------------------------------------------------------------------------
/src/main/resources/hudson/plugins/depgraph_view/DependencyGraphProperty/help-projectNameSuperscriptRegexGroup.html:
--------------------------------------------------------------------------------
1 |
22 |
23 |
24 | Allows to define the group of regular expression to be used for to display as small caps superscript over the job name, defaults to -1
(disabled).
25 |
--------------------------------------------------------------------------------
/src/main/resources/hudson/plugins/depgraph_view/Messages.properties:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright (c) 2010 Stefan Wolf
3 | #
4 | # Permission is hereby granted, free of charge, to any person obtaining a copy
5 | # of this software and associated documentation files (the "Software"), to deal
6 | # in the Software without restriction, including without limitation the rights
7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | # copies of the Software, and to permit persons to whom the Software is
9 | # furnished to do so, subject to the following conditions:
10 | #
11 | # The above copyright notice and this permission notice shall be included in
12 | # all copies or substantial portions of the Software.
13 | #
14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | # THE SOFTWARE.
21 | #
22 |
23 | AbstractDependencyGraphAction.DependencyGraphOf=Dependency Graph of {0}
24 | AbstractDependencyGraphAction.DependencyGraph=Dependency Graph
25 | DependencyGraphProperty.DependencyGraphViewer=Dependency Graph Viewer
26 | DependencyGraphProperty.ProjectNameStripRegex.Required=A Regular Expression is required
27 | DependencyGraphProperty.ProjectNameStripRegex.Invalid=The given expression is not valid
--------------------------------------------------------------------------------
/src/main/resources/hudson/plugins/depgraph_view/Messages_de.properties:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jenkinsci/depgraph-view-plugin/aef4b5ff552257e3914716351f14b3f1af7d1545/src/main/resources/hudson/plugins/depgraph_view/Messages_de.properties
--------------------------------------------------------------------------------
/src/main/resources/index.jelly:
--------------------------------------------------------------------------------
1 |
22 |
23 |
24 |
25 |
30 |
31 |
32 | This plugin shows a dependency graph of the projects.
33 | It uses dot (from graphviz) or jsPlumb for drawing.
34 |
35 |
--------------------------------------------------------------------------------
/src/main/webapp/css/depview.css:
--------------------------------------------------------------------------------
1 | #paper {
2 | position: relative;
3 | top: 0px;
4 | left: 0px;
5 | height: 1000px;
6 | width: auto;
7 | overflow: scroll
8 | }
9 |
10 | .window {
11 | border: 1px solid #346789;
12 | box-shadow: 2px 2px 19px #aaa;
13 | -o-box-shadow: 2px 2px 19px #aaa;
14 | -webkit-box-shadow: 2px 2px 19px #aaa;
15 | -moz-box-shadow: 2px 2px 19px #aaa;
16 | -moz-border-radius: 0.5em;
17 | border-radius: 0.5em;
18 | opacity: 0.8;
19 | filter: alpha(opacity = 80);
20 | width: auto;
21 | overflow: auto;
22 | min-width: 6em;
23 | max-width: 14em;
24 | min-height: 4em;
25 | height: auto;
26 | line-height: 4em;
27 | text-align: center;
28 | z-index: 20;
29 | position: absolute;
30 | background-color: #eeeeef;
31 | color: black;
32 | font-family: helvetica;
33 | padding: 0.5em 1em;
34 | font-size: 0.9em;
35 | white-space: nowrap;
36 | }
37 |
38 | .window:hover {
39 | box-shadow: 2px 2px 19px #444;
40 | -o-box-shadow: 2px 2px 19px #444;
41 | -webkit-box-shadow: 2px 2px 19px #444;
42 | -moz-box-shadow: 2px 2px 19px #444;
43 | opacity: 0.6;
44 | filter: alpha(opacity = 60);
45 | }
46 |
47 | .ep {
48 | float:right;
49 | width:1em;
50 | height:1em;
51 | background-color:#994466;
52 | cursor:pointer;
53 | display: block;
54 | }
55 |
56 | .active {
57 | border: 1px dotted green;
58 | }
59 |
60 | .hover {
61 | border: 1px dotted red;
62 | }
63 |
64 | ._jsPlumb_connector {
65 | z-index: 4;
66 | }
67 |
68 | ._jsPlumb_endpoint,.endpointTargetLabel,.endpointSourceLabel {
69 | z-index: 21;
70 | cursor: pointer;
71 | }
72 |
73 | .hl {
74 | border: 3px solid red;
75 | }
76 |
77 | #debug {
78 | position: absolute;
79 | background-color: black;
80 | color: red;
81 | z-index: 5000
82 | }
83 |
84 | .aLabel {
85 | background-color: white;
86 | padding: 0.4em;
87 | font: 12px sans-serif;
88 | color: #444;
89 | z-index: 21;
90 | border: 1px dotted gray;
91 | opacity: 0.8;
92 | filter: alpha(opacity = 80);
93 | }
--------------------------------------------------------------------------------
/src/main/webapp/css/graph.css:
--------------------------------------------------------------------------------
1 | #canvas
2 | {
3 | width: 400px;
4 | height: 300px
5 | }
6 |
--------------------------------------------------------------------------------
/src/main/webapp/help-globalConfig.html:
--------------------------------------------------------------------------------
1 |
22 |
23 |
24 |
25 | Put the name of the dot executable from the graphviz project here.
26 |
27 |
28 |
--------------------------------------------------------------------------------
/src/main/webapp/js/jsPlumb_depview.js:
--------------------------------------------------------------------------------
1 | ;
2 | (function() {
3 | function escapeId(id) {
4 | // replace all characters except numbers and letters
5 | // As soon as someone opens a bug that they have a problem with a name conflict
6 | // rethink the strategy
7 | return id.replace(/[^a-zA-Z0-9]/g,'-');
8 | }
9 |
10 | function stripName(name) {
11 | if(window.depview.projectNameStripRegex) {
12 | match = window.depview.projectNameStripRegex.exec(name);
13 | if(match && match[window.depview.projectNameStripRegexGroup]){
14 | return match[window.depview.projectNameStripRegexGroup];
15 | }
16 | return name;
17 | }
18 | }
19 |
20 | function getJobDiv(jobName) {
21 | return jQuery('#' + escapeId(jobName));
22 | }
23 |
24 | window.depview = {
25 | paper: jQuery("#paper"),
26 | colordep: '#FF0000', // red
27 | colorcopy: '#32CD32', // green
28 | init : function() {
29 | jsPlumb.importDefaults({
30 | Connector : ["StateMachine", { curviness: 10 }],// Straight, Flowchart, Straight, Bezier
31 | // default to blue at one end and green at the other
32 | EndpointStyles : [ {
33 | fillStyle : '#225588'
34 | }, {
35 | fillStyle : '#558822'
36 | } ],
37 | // blue endpoints 7px; green endpoints 7px.
38 | Endpoints : [ [ "Dot", {
39 | radius : 5
40 | } ], [ "Dot", {
41 | radius : 5
42 | } ] ],
43 | Anchors : [ "Continuous", "Continuous" ],
44 | // def for new connector (drag n' drop)
45 | // - line 2px
46 | PaintStyle : {
47 | lineWidth : 2,
48 | strokeStyle : window.depview.colordep,
49 | joinstyle:"round"},
50 | // the overlays to decorate each connection with. note that the
51 | // label overlay uses a function to generate the label text; in
52 | // this case it returns the 'labelText' member that we set on each
53 | // connection in the 'init' method below.
54 | ConnectionOverlays : [ [ "Arrow", {
55 | location : 1.0,
56 | foldback:0.5
57 | } ] ],
58 | ConnectionsDetachable:false
59 | });
60 | jQuery.getJSON('graph.json', function(data) {
61 |
62 | var top = 3;
63 | var space = 150;
64 | var xOverall = 90;
65 |
66 | var clusters = data["clusters"];
67 | // iterate clusters
68 | jQuery.each(clusters, function(i, cluster) {
69 | jQuery.each(cluster.nodes, function(i,node) {
70 | var nodeString = ''
71 | if (window.depview.editEnabled) {
72 | nodeString = nodeString + '
';
73 | }
74 | nodeString = nodeString + '
' + stripName(node.name) + ' '
75 | var jnode = jQuery(nodeString);
76 | var width = jnode.addClass('window').
77 | attr('id', escapeId(node.name)).
78 | attr('data-jobname', node.fullName).
79 | css('top', node.y + top).
80 | css('left', node.x).
81 | appendTo(window.depview.paper).width();
82 | jnode.css('left', node.x - width/2 + xOverall);
83 | })
84 | top = top + cluster.vSize + space
85 | });
86 | // definitions for drag/drop connections
87 | jQuery(".ep").each(function(idx, current) {
88 | var p = jQuery(current).parent()
89 | if(window.depview.editEnabled) {
90 | jsPlumb.makeSource(current, {
91 | parent: p,
92 | scope: "dep"
93 | });
94 | }
95 | })
96 | jsPlumb.makeTarget(jsPlumb.getSelector('.window'), {scope: "dep"});
97 |
98 | var edges = data["edges"];
99 | jQuery.each(edges, function(i, edge) {
100 | from = getJobDiv(edge["from"]);
101 | to = getJobDiv(edge["to"]);
102 | // creates/defines the look and feel of the loaded connections: red="dep", green="copy"
103 | var connection;
104 | var connOptions = {
105 | source : from,
106 | target : to,
107 | scope: edge["type"],
108 | paintStyle:{lineWidth : 2}
109 | }
110 | if("copy" == edge["type"]){
111 | connOptions.paintStyle.strokeStyle = window.depview.colorcopy;
112 | connOptions.overlays = [[ "Label", { label: "copy", id: from+'.'+to } ]];
113 | connection = jsPlumb.connect(connOptions);
114 | } else {
115 | connOptions.paintStyle.strokeStyle = window.depview.colordep;
116 | connection = jsPlumb.connect(connOptions);
117 | // only allow deletion of "dep" connections
118 | if(window.depview.editEnabled) {
119 | connection.bind("click", function(conn) {
120 | var sourceJobName = conn.source.attr('data-jobname');
121 | var targetJobName = conn.target.attr('data-jobname')
122 | jQuery.ajax({
123 | url : encodeURI('edge/' + sourceJobName + '/' + targetJobName),
124 | type : 'DELETE',
125 | success : function(response) {
126 | jsPlumb.detach(conn);
127 | },
128 | error: function (request, status, error) {
129 | alert(status+": "+error);
130 | }
131 | });
132 | });
133 | }
134 | }
135 | });
136 |
137 | if(window.depview.editEnabled) {
138 | jsPlumb.bind("jsPlumbConnection", function(info) {
139 | var connections = jsPlumb.getConnections({ scope: "dep", source: info.sourceId, target: info.targetId });
140 | if ((info.sourceId == info.targetId) || connections.length > 1) {
141 | jsPlumb.detach(info);
142 | return;
143 | }
144 | jQuery.ajax({
145 | url: encodeURI('edge/'+info.source.attr('data-jobname') +'/'+info.target.attr('data-jobname')),
146 | type: 'PUT',
147 | success: function( response ) {
148 | // alert('Load was performed.');
149 | },
150 | error: function (request, status, error) {
151 | alert(status+": "+error);
152 | jsPlumb.detach(info);
153 | }
154 | });
155 | // allow deletion of newly created connection
156 | info.connection.bind("click", function(conn) {
157 | var sourceJobName = conn.source.attr('data-jobname');
158 | var targetJobName = conn.target.attr('data-jobname');
159 | jQuery.ajax({
160 | url : encodeURI('edge/' + sourceJobName + '/' + targetJobName),
161 | type : 'DELETE',
162 | success : function(response) {
163 | jsPlumb.detach(conn);
164 | },
165 | error: function (request, status, error) {
166 | alert(status+": "+error);
167 | }
168 | });
169 | });
170 | });
171 | }
172 |
173 | // make all the window divs draggable
174 | jsPlumb.draggable(jsPlumb.getSelector(".window"));
175 | });
176 | }
177 | };
178 | })();
179 |
180 | // start jsPlumb
181 | jsPlumb.bind("ready", function() {
182 | // chrome fix.
183 | document.onselectstart = function () { return false; };
184 |
185 | jsPlumb.setRenderMode(jsPlumb.SVG);
186 | depview.init();
187 | });
188 |
189 |
--------------------------------------------------------------------------------
/src/test/java/hudson/plugins/depgraph_view/model/graph/GraphCalculatorTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2010 Stefan Wolf
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | * THE SOFTWARE.
21 | */
22 |
23 | package hudson.plugins.depgraph_view.model.graph;
24 |
25 | import com.google.common.collect.ImmutableSet;
26 | import com.google.common.collect.Lists;
27 | import hudson.model.Job;
28 | import hudson.plugins.depgraph_view.model.graph.edge.DependencyGraphEdgeProvider;
29 | import hudson.plugins.depgraph_view.model.graph.edge.EdgeProvider;
30 | import hudson.model.FreeStyleProject;
31 | import hudson.tasks.BuildTrigger;
32 | import org.junit.Rule;
33 | import org.junit.Test;
34 | import org.jvnet.hudson.test.JenkinsRule;
35 |
36 | import java.io.IOException;
37 | import java.util.Arrays;
38 | import java.util.Collection;
39 | import java.util.Collections;
40 |
41 | import static hudson.plugins.depgraph_view.model.graph.ProjectNode.node;
42 | import static org.junit.Assert.assertTrue;
43 |
44 | public class GraphCalculatorTest {
45 | private FreeStyleProject project1;
46 | private FreeStyleProject project2;
47 |
48 | @Rule
49 | public JenkinsRule j = new JenkinsRule();
50 |
51 | @Test
52 | public void testCalculateDepsDownstream() throws IOException {
53 | createProjects();
54 | addDependency(project1, project2);
55 | j.jenkins.rebuildDependencyGraph();
56 | DependencyGraph graph = generateGraph(project1);
57 | assertGraphContainsProjects(graph, project1, project2);
58 | assertTrue(graph.findEdgeSet(node(project1), node(project2)).size() == 1);
59 | }
60 |
61 | private void assertGraphContainsProjects(DependencyGraph graph, Job,?>... projects) {
62 | Collection projectNodes = Lists.newArrayList(GraphCalculator.jobSetToProjectNodeSet(Arrays.asList(projects)));
63 | assertTrue(graph.getNodes().containsAll(projectNodes));
64 | assertTrue(graph.getNodes().size() == projectNodes.size());
65 | }
66 |
67 | private DependencyGraph generateGraph(Job,?> from) {
68 | return new GraphCalculator(getDependencyGraphEdgeProviders()).generateGraph(Collections.singleton(node(from)));
69 | }
70 |
71 | @Test
72 | public void testCalculateDepsUpstream() throws IOException {
73 | createProjects();
74 | addDependency(project1, project2);
75 | j.getInstance().rebuildDependencyGraph();
76 | DependencyGraph graph = generateGraph(project2);
77 | assertGraphContainsProjects(graph, project1, project2);
78 | assertTrue(graph.findEdgeSet(node(project1), node(project2)).size() == 1);
79 | }
80 |
81 | private void assertHasOneDependencyEdge(DependencyGraph graph, Job,?> from, Job,?> to) {
82 | assertTrue(graph.findEdgeSet(node(from), node(to)).size() == 1);
83 | }
84 |
85 | @Test
86 | public void testCalculateDepsTransitive() throws IOException {
87 | createProjects();
88 | FreeStyleProject project3 = j.createFreeStyleProject();
89 | addDependency(project2, project1);
90 | addDependency(project2, project3);
91 | j.getInstance().rebuildDependencyGraph();
92 |
93 | DependencyGraph graph = generateGraph(project1);
94 | assertGraphContainsProjects(graph, project1, project2);
95 | assertHasOneDependencyEdge(graph, project2, project1);
96 |
97 | graph = generateGraph(project2);
98 | assertGraphContainsProjects(graph, project1, project2, project3);
99 | assertHasOneDependencyEdge(graph, project2, project1);
100 | assertHasOneDependencyEdge(graph, project2, project3);
101 | }
102 |
103 | private void createProjects() throws IOException {
104 | project1 = j.createFreeStyleProject();
105 | project2 = j.createFreeStyleProject();
106 | }
107 |
108 | private ImmutableSet getDependencyGraphEdgeProviders() {
109 | return ImmutableSet.of(new DependencyGraphEdgeProvider(j.getInstance()));
110 | }
111 |
112 | private void addDependency(FreeStyleProject project1, FreeStyleProject project2) throws IOException {
113 | project1.getPublishersList().add(new BuildTrigger(project2.getName(), false));
114 | }
115 | }
116 |
--------------------------------------------------------------------------------
/src/test/java/hudson/plugins/depgraph_view/model/graph/NormalizeTest.java:
--------------------------------------------------------------------------------
1 | package hudson.plugins.depgraph_view.model.graph;
2 |
3 | import static org.junit.Assert.*;
4 |
5 | import hudson.plugins.depgraph_view.model.operations.EdgeOperation;
6 |
7 | import org.junit.Test;
8 |
9 | public class NormalizeTest {
10 |
11 | @Test
12 | public void test() {
13 | String childProjectsValue = "abc, ,ccc";
14 | childProjectsValue = EdgeOperation.normalizeChildProjectValue(childProjectsValue);
15 | assertEquals("abc, ccc", childProjectsValue);
16 | }
17 | @Test
18 | public void test1() {
19 | String childProjectsValue = "abc, ,ccc";
20 | childProjectsValue = EdgeOperation.normalizeChildProjectValue(childProjectsValue);
21 | assertEquals("abc, ccc", childProjectsValue);
22 | }
23 | @Test
24 | public void test2() {
25 | String childProjectsValue = "abc, ccc";
26 | childProjectsValue = EdgeOperation.normalizeChildProjectValue(childProjectsValue);
27 | assertEquals("abc, ccc", childProjectsValue);
28 | }
29 |
30 | @Test
31 | public void test3() {
32 | String childProjectsValue = ",abc, ,ccc,";
33 | childProjectsValue = EdgeOperation.normalizeChildProjectValue(childProjectsValue);
34 | assertEquals("abc, ccc", childProjectsValue);
35 | }
36 |
37 | @Test
38 | public void test4() {
39 | String childProjectsValue = ",abc,,ccc,";
40 | childProjectsValue = EdgeOperation.normalizeChildProjectValue(childProjectsValue);
41 | assertEquals("abc, ccc", childProjectsValue);
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/src/test/java/hudson/plugins/depgraph_view/model/graph/StripProjectNameTest.java:
--------------------------------------------------------------------------------
1 | package hudson.plugins.depgraph_view.model.graph;
2 |
3 | import static hudson.plugins.depgraph_view.model.graph.ProjectNode.node;
4 | import static org.junit.Assert.assertTrue;
5 | import hudson.model.AbstractProject;
6 | import hudson.model.FreeStyleProject;
7 | import hudson.plugins.depgraph_view.DependencyGraphProperty.DescriptorImpl;
8 | import hudson.plugins.depgraph_view.model.graph.edge.DependencyGraphEdgeProvider;
9 | import hudson.plugins.depgraph_view.model.graph.edge.EdgeProvider;
10 | import hudson.plugins.depgraph_view.model.graph.project.SubProjectProvider;
11 | import hudson.plugins.depgraph_view.model.display.DotStringGenerator;
12 |
13 | import java.util.Collections;
14 |
15 | import jenkins.model.JenkinsLocationConfiguration;
16 |
17 | import org.junit.Rule;
18 | import org.junit.Test;
19 | import org.jvnet.hudson.test.JenkinsRule;
20 |
21 | import com.google.common.collect.ImmutableSet;
22 | import com.google.common.collect.ListMultimap;
23 |
24 | public class StripProjectNameTest {
25 |
26 | @Rule
27 | public JenkinsRule j = new JenkinsRule();
28 |
29 | @Test
30 | public void projectNameShouldBeStriped() throws Exception {
31 | JenkinsLocationConfiguration.get().setUrl("http://localhost");
32 | j.getInstance().getDescriptorByType(DescriptorImpl.class).setProjectNameStripRegex("com.comp.(.*)");
33 | j.getInstance().getDescriptorByType(DescriptorImpl.class).setProjectNameStripRegexGroup(1);
34 |
35 | final FreeStyleProject myJob = j.createFreeStyleProject("com.comp.myJob");
36 | j.getInstance().rebuildDependencyGraph();
37 | DependencyGraph graph = generateGraph(myJob);
38 | final SubprojectCalculator subprojectCalculator = new SubprojectCalculator(Collections.emptySet());
39 | final ListMultimap subProjects = subprojectCalculator.generate(graph);
40 | final DotStringGenerator dotStringGenerator = new DotStringGenerator(j.getInstance(), graph, subProjects);
41 | final String dotString = dotStringGenerator.generate();
42 | System.err.println(dotString);
43 | // we can't test for not existing of the original name, because that one is still required for linking,
44 | // so we explicitly check for the short/striped version only
45 | assertTrue("node label should contain stripped job name", dotString.contains(">myJob<"));
46 |
47 | }
48 |
49 | @Test
50 | public void projectNameShouldBeRelabeled() throws Exception {
51 | JenkinsLocationConfiguration.get().setUrl("http://localhost");
52 | j.getInstance().getDescriptorByType(DescriptorImpl.class).setProjectNameStripRegex("(com[.]comp[.])(.*)");
53 | j.getInstance().getDescriptorByType(DescriptorImpl.class).setProjectNameStripRegexGroup(2);
54 | j.getInstance().getDescriptorByType(DescriptorImpl.class).setProjectNameSuperscriptRegexGroup(1);
55 |
56 | final FreeStyleProject myJob = j.createFreeStyleProject("com.comp.myJob");
57 | j.getInstance().rebuildDependencyGraph();
58 | DependencyGraph graph = generateGraph(myJob);
59 | final SubprojectCalculator subprojectCalculator = new SubprojectCalculator(Collections.emptySet());
60 | final ListMultimap subProjects = subprojectCalculator.generate(graph);
61 | final DotStringGenerator dotStringGenerator = new DotStringGenerator(j.getInstance(), graph, subProjects);
62 | final String dotString = dotStringGenerator.generate();
63 | System.err.println(dotString);
64 | // we can't test for not existing of the original name, because that one is still required for linking,
65 | // so we explicitly check for the short/striped version only
66 | assertTrue("node label should contain superscript and stripped name", dotString.contains("com.comp. myJob"));
67 |
68 | }
69 |
70 | private DependencyGraph generateGraph(AbstractProject,?> from) {
71 | return new GraphCalculator(getDependencyGraphEdgeProviders()).generateGraph(Collections.singleton(node(from)));
72 | }
73 |
74 | private ImmutableSet getDependencyGraphEdgeProviders() {
75 | return ImmutableSet.of(new DependencyGraphEdgeProvider(j.getInstance()));
76 | }
77 | }
78 |
--------------------------------------------------------------------------------