Project

General

Profile

« Previous | Next » 

Revision 63124

Added by Michele Artini 8 months ago

[maven-release-plugin] copy for tag dnet-modular-workflows-ui-5.0.2

View differences:

modules/dnet-modular-workflows-ui/tags/dnet-modular-workflows-ui-5.0.2/pom.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3
	<parent>
4
		<groupId>eu.dnetlib</groupId>
5
		<artifactId>dnet45-parent</artifactId>
6
		<version>1.0.0</version>
7
	</parent>
8
	<modelVersion>4.0.0</modelVersion>
9
	<groupId>eu.dnetlib</groupId>
10
	<artifactId>dnet-modular-workflows-ui</artifactId>
11
	<packaging>jar</packaging>
12
	<version>5.0.2</version>
13
	<scm>
14
		<developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet45/modules/dnet-modular-workflows-ui/tags/dnet-modular-workflows-ui-5.0.2</developerConnection>
15
	</scm>
16
	<dependencies>
17
		<dependency>
18
			<groupId>eu.dnetlib</groupId>
19
			<artifactId>dnet-modular-ui</artifactId>
20
			<version>[3.0.0,4.0.0)</version>
21
		</dependency>
22
		<dependency>
23
			<groupId>eu.dnetlib</groupId>
24
			<artifactId>dnet-msro-service</artifactId>
25
			<version>[4.0.0,5.0.0)</version>
26
		</dependency>
27
		<dependency>
28
			<groupId>joda-time</groupId>
29
			<artifactId>joda-time</artifactId>
30
			<version>2.3</version>
31
		</dependency>
32
		<dependency>
33
			<groupId>javax.servlet</groupId>
34
			<artifactId>javax.servlet-api</artifactId>
35
			<version>${javax.servlet.version}</version>
36
			<scope>provided</scope>
37
		</dependency>
38
		<dependency>
39
			<groupId>org.apache.httpcomponents</groupId>
40
			<artifactId>httpclient</artifactId>
41
			<version>4.5.3</version>
42
		</dependency>
43
		<dependency>
44
			<groupId>junit</groupId>
45
			<artifactId>junit</artifactId>
46
			<version>${junit.version}</version>
47
			<scope>test</scope>
48
		</dependency>
49
	</dependencies>
50

  
51
	<properties>
52
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
53
	</properties>
54

  
55
</project>
modules/dnet-modular-workflows-ui/tags/dnet-modular-workflows-ui-5.0.2/src/main/java/eu/dnetlib/functionality/modular/ui/workflows/objects/NodeInfo.java
1
package eu.dnetlib.functionality.modular.ui.workflows.objects;
2

  
3
import java.util.List;
4

  
5
import eu.dnetlib.msro.workflows.util.WorkflowParam;
6

  
7
public class NodeInfo {
8
	private String name;
9
	private String description;
10
	private List<WorkflowParam> params;
11
		
12
	public NodeInfo(String name, String description, List<WorkflowParam> params) {
13
		this.name = name;
14
		this.description = description;
15
		this.params = params;
16
	}
17

  
18
	public String getName() {
19
		return name;
20
	}
21

  
22
	public void setName(String name) {
23
		this.name = name;
24
	}
25

  
26
	public String getDescription() {
27
		return description;
28
	}
29

  
30
	public void setDescription(String description) {
31
		this.description = description;
32
	}
33

  
34
	public List<WorkflowParam> getParams() {
35
		return params;
36
	}
37

  
38
	public void setParams(List<WorkflowParam> params) {
39
		this.params = params;
40
	}
41

  
42
}
modules/dnet-modular-workflows-ui/tags/dnet-modular-workflows-ui-5.0.2/src/main/resources/eu/dnetlib/web/resources/js/dnet_wf_journal.js
1
var module = angular.module('wfJournalUI', ['ngGrid','ui.bootstrap']);
2

  
3
module.directive('sliderDateRange', function($compile) {
4
	var months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sept", "Oct", "Nov", "Dec"];
5
	
6
	return {
7
		restrict: 'A',
8
		scope: {
9
			min   : '=',
10
			max   : '=',
11
			start : '=',
12
			end   : '=',
13
			updateFunction: '='
14
		},
15
		link: function(scope, elem, attrs) {
16
    		$(elem).dateRangeSlider({
17
    			valueLabels: "change",
18
    			delayOut: 1000,
19
    			"bounds" : {
20
					min: scope.min,
21
					max: scope.max
22
				},
23
				"defaultValues" : {
24
					min: scope.start,
25
					max: scope.end
26
				},
27
				"scales": [{
28
					first: function(value) {
29
						return value;
30
					},
31
					end: function(value) {
32
						return value;
33
					},
34
					next: function(value) {
35
						var next = new Date(value);
36
						return new Date(next.setMonth(value.getMonth() + 1));
37
					},
38
					label: function(value) {
39
						return months[value.getMonth()];
40
					},
41
					format:	function(tickContainer, tickStart, tickEnd) {
42
						tickContainer.addClass("myCustomClass");
43
					}
44
				}]
45
    		});
46
    		$(elem).bind("valuesChanged", function(e, data){
47
    			scope.updateFunction(data.values.min, data.values.max);
48
    		});
49
    	}
50
    }
51
});
52

  
53
function wfJournalCtrl($scope, $http, $sce) {
54
	
55
	commonInitialize($scope, $http, $sce);
56
	
57
	initSpinner();
58
	
59
	$scope.journal = [];
60
	
61
	$scope.currentProcId = '';
62
	
63
	$scope.family = getFamily();
64
	
65
	$scope.filterJournal = { filterText: '' };
66
		
67
	$scope.maxDate = new Date();
68
	$scope.minDate = new Date($scope.maxDate.getTime() - 31536000000); // 1 YEAR AGO
69
	
70
	$scope.endDate = new Date();
71
	$scope.startDate = new Date();
72
	
73
	$scope.updateDates = function(start, end) {
74
		$scope.startDate = start;
75
		$scope.endDate = end;
76
		$scope.$apply();
77
		$scope.refresh();
78
	}
79
	
80
	// Set date range to [7 days before today, today] inclusive
81
	$scope.startDate.setDate($scope.endDate.getDate()-7);
82
	
83
	// Grid configuration
84
	$scope.gridWfJournal = { 
85
			data: 'journal',
86
			enableCellSelection: false,
87
			enableRowSelection: false,
88
			enableCellEditOnFocus: false,
89
			enablePaging: false,
90
			enableHighlighting: true,
91
			sortInfo: { fields: ['date'], directions: ['desc']},
92
			filterOptions: $scope.filterJournal,
93
			columnDefs: [{field: 'procId', displayName: 'Process ID'      , width: '15%', cellTemplate: '<div class="ngCellText"><a href="javascript:void(0)" ng-click="showProcess(row.getProperty(col.field))">{{row.getProperty(col.field)}}</a></div>'},
94
			             {field: 'name'  , displayName: 'Workflow name'   , width: '20%',},
95
			             {field: 'family', displayName: 'Workflow family' , width: '15%' },
96
			             {field: 'repo'  , displayName: 'Datasource', cellTemplate: '<div class="ngCellText"><a href="repoApis.do#/api/{{row.getProperty(\'repoId\')}}/{{row.getProperty(\'apiId\')}}/ALL/ALL" ng-if="row.getProperty(\'repoId\') && row.getProperty(\'apiId\') && row.getProperty(\'repo\')">{{row.getProperty(col.field)}}</a><span ng-if="!(row.getProperty(\'repoId\') && row.getProperty(\'apiId\'))">{{row.getProperty(col.field)}}</span></div>'},
97
			             {field: 'status', displayName: 'Status'          , width: '10%', cellTemplate: '<div class="ngCellText"><span class="label label-default" ng-class="{ \'label-success\': row.getProperty(col.field) == \'SUCCESS\', \'label-danger\': row.getProperty(col.field) == \'FAILURE\', \'label-info\': row.getProperty(col.field) == \'EXECUTING\'}">{{row.getProperty(col.field)}}</span></div>'},
98
			             {field: 'date'  , displayName: 'Date'            , width: '10%', cellTemplate: '<div class="ngCellText">{{ (row.getProperty("date") > 0 && row.getProperty("date") < 9999999999999) ? (row.getProperty("date") | date:"yyyy-MM-dd HH:mm:ss") : "not yet started" }}</div>'}
99
			            ]
100
	};
101
	
102
	$scope.formatDate = function(date) {
103
		var year = date.getFullYear();
104
		var month = ("00" + (date.getMonth() + 1)).slice(-2);
105
		var day = ("00" + date.getDate()).slice(-2);
106
		return year + '-' + month + '-' + day;
107
	}
108
	
109
	$scope.refresh = function() {
110
		$scope.showSpinner();
111
		var url = '';
112
		
113
		if ($scope.family) {
114
			url = 'wf_journal_byFamily.find?family=' + $scope.family;
115
		} else {
116
			url = 'wf_journal.range?start=' + $scope.formatDate($scope.startDate) + '&end=' + $scope.formatDate($scope.endDate);
117
		}
118
		$http.get(url).success(
119
			function(data) {
120
				$scope.journal = data;
121
				$scope.hideSpinner();
122
			}
123
		).error(
124
			function(err) {
125
				$scope.showError(err.message);
126
				$scope.hideSpinner();
127
			}
128
		);
129
	}
130
	
131
	$scope.resizeMainElement = function(elem) {
132
		var height = 0;
133
		var body = window.document.body;
134
		if (window.innerHeight) {
135
			height = window.innerHeight;
136
		} else if (body.parentElement.clientHeight) {
137
			height = body.parentElement.clientHeight;
138
		} else if (body && body.clientHeight) {
139
			height = body.clientHeight;
140
		}
141
		elem.style.height = ((height - elem.offsetTop - 280) + "px");
142
	}
143
	
144
	$scope.refresh();
145
	$scope.resizeMainElement(document.getElementById('wfJournalTable'));
146
	
147
	if (initProcId()) {
148
		$scope.showProcess(initProcId());
149
	}
150
}
151

  
152
window.onresize = function() {
153
	var elem = document.getElementById('wfJournalTable');
154
    angular.element(elem).scope().resizeMainElement(elem);
155
};
modules/dnet-modular-workflows-ui/tags/dnet-modular-workflows-ui-5.0.2/src/main/java/eu/dnetlib/functionality/modular/ui/workflows/objects/AdvancedMetaWorkflowDescriptor.java
1
package eu.dnetlib.functionality.modular.ui.workflows.objects;
2

  
3
import java.util.Set;
4

  
5
import com.google.common.collect.Sets;
6

  
7
import eu.dnetlib.msro.workflows.util.WorkflowsConstants.WorkflowStatus;
8

  
9
public class AdvancedMetaWorkflowDescriptor extends MetaWorkflowDescriptor {
10
	private String email;
11
	private boolean scheduled;
12
	private String cronExpression;
13
	private int minInterval;
14
	private Set<String> innerWfs = Sets.newHashSet();
15
	private String html;
16

  
17
	public AdvancedMetaWorkflowDescriptor(final String id, final String name, final String email,
18
			final boolean scheduled, final String cronExpression, final int minInterval, final WorkflowStatus statusEnum, final String family, final Set<String> innerWfs, final String html) {
19
		super(id, name, statusEnum, family);
20
		this.email = email;
21
		this.scheduled = scheduled;
22
		this.cronExpression = cronExpression;
23
		this.minInterval = minInterval;
24
		this.innerWfs = innerWfs;
25
		this.setHtml(html);
26
	}
27

  
28
	public boolean isScheduled() {
29
		return scheduled;
30
	}
31

  
32
	public void setScheduled(final boolean scheduled) {
33
		this.scheduled = scheduled;
34
	}
35

  
36
	public String getCronExpression() {
37
		return cronExpression;
38
	}
39

  
40
	public void setCronExpression(final String cronExpression) {
41
		this.cronExpression = cronExpression;
42
	}
43

  
44
	public int getMinInterval() {
45
		return minInterval;
46
	}
47

  
48
	public void setMinInterval(final int minInterval) {
49
		this.minInterval = minInterval;
50
	}
51

  
52
	public String getEmail() {
53
		return email;
54
	}
55

  
56
	public void setEmail(final String email) {
57
		this.email = email;
58
	}
59
	
60
	public Set<String> getInnerWfs() {
61
		return innerWfs;
62
	}
63

  
64
	public void setInnerWfs(Set<String> innerWfs) {
65
		this.innerWfs = innerWfs;
66
	}
67

  
68
	public String getHtml() {
69
		return html;
70
	}
71

  
72
	public void setHtml(String html) {
73
		this.html = html;
74
	}
75

  
76
}
modules/dnet-modular-workflows-ui/tags/dnet-modular-workflows-ui-5.0.2/src/main/resources/eu/dnetlib/web/resources/js/dnet_wf_timeline.js
1
var module = angular.module('wfTimelineUI', ['ngGrid']);
2

  
3
function wfTimelineCtrl($scope, $http, $sce, $filter) {
4
	
5
	commonInitialize($scope, $http, $sce);
6
	
7
	initSpinner();
8
	
9
	// Set date range to [3 days before today, today] inclusive
10
	$scope.endDate = new Date();
11
	$scope.startDate = new Date();
12
	$scope.startDate.setDate($scope.endDate.getDate()-3);
13
	
14
	$scope.data= [];
15
	$scope.timeline = new links.Timeline(document.getElementById('divTimeline'));		
16
	$scope.timelineData = [];
17
	$scope.currentLog = [];
18
	$scope.currentLogTitle = '';
19
	
20
	$scope.formatDate = function(date) {
21
		var year = date.getFullYear();
22
		var month = ("00" + (date.getMonth() + 1)).slice(-2);
23
		var day = ("00" + date.getDate()).slice(-2);
24
		return year + '-' + month + '-' + day;
25
	}
26
	
27
	$scope.gridLogDetails = { 
28
			data: 'currentLog',
29
			enableCellSelection: false,
30
			enableRowSelection: false,
31
			enableCellEditOnFocus: false,
32
			enablePaging: false,
33
			sortInfo: { fields: ['name'], directions: ['asc'] },
34
			columnDefs: [{field: 'name', displayName: 'Key', width: '20%' },
35
			             {field: 'value', displayName: 'Value' }]
36
	};
37
	
38
	$scope.registerListener = function() {
39
		links.events.addListener($scope.timeline, 'select', function() {
40
	        var sel = $scope.timeline.getSelection();
41
	        if (sel.length) {
42
	            if (sel[0].row != undefined) {
43
	                var row = sel[0].row;
44
	                $scope.showProcess($scope.timelineData[row].procId);
45
	            }
46
	        }
47
	    });
48

  
49
        // attach an event listener using the links events handler
50
		links.events.addListener($scope.timeline, 'rangechanged', function(properties) {
51
			if ($scope.formatDate($scope.endDate) != $scope.formatDate(properties.end) || $scope.formatDate($scope.startDate) != $scope.formatDate(properties.start)) {
52
				$scope.endDate = properties.end;
53
				$scope.startDate = properties.start;
54
				$scope.refresh();
55
			}
56
		});
57
	}
58
		
59
	$scope.refresh = function() {
60
		$scope.showSpinner();
61
		$http.get('wf_journal.range?start=' + $scope.formatDate($scope.startDate) + '&end=' + $scope.formatDate($scope.endDate))
62
        .success(
63
            function(data) {
64
            	$scope.data = data;
65
                $scope.drawVisualization($scope.data);
66
                $scope.hideSpinner();
67
            }
68
        ).error(
69
            function(err) {
70
            	$scope.showError(err.message);
71
            	$scope.hideSpinner();
72
            }
73
        );
74
	}
75
	
76
	$scope.resizeMainElement = function(elem) {
77
		var height = 0;
78
		var body = window.document.body;
79
		if (window.innerHeight) {
80
			height = window.innerHeight;
81
		} else if (body.parentElement.clientHeight) {
82
			height = body.parentElement.clientHeight;
83
		} else if (body && body.clientHeight) {
84
			height = body.clientHeight;
85
		}
86
		elem.style.height = ((height - elem.offsetTop - 160) + "px");
87
	}
88
	
89
	
90
	$scope.drawVisualization = function(entries) {
91
		$scope.timelineData = [];
92

  
93
		angular.forEach(entries, function(value, key) {
94
			var clazz = 'text-success';
95
			if (value.status == 'FAILURE') {
96
				clazz = 'text-danger';
97
			}
98
			
99
			var s = "";
100
			if (value.repo) {
101
				s += value.repo + " (" + value.name + ")";
102
			} else {
103
				var s = value.name;
104
			}
105
			
106
			var prettyDate = "not yet started";
107
			if (value.date > 0 && value.date < 9999999999999) { // sabato 20 novembre 2286 17.46.39 GMT
108
				prettyDate = $filter('date')(new Date(value.date),'yyyy-MM-dd HH:mm:ss');
109
			}
110
						
111
			$scope.timelineData.push({
112
				'title': value.name + " (" + prettyDate + ")",
113
				'procId': value.procId,
114
                'start': new Date(value.date),
115
                'content': s,
116
                'className': clazz
117
            });
118
		});
119
		
120
		$scope.timeline = new links.Timeline(document.getElementById('divTimeline'));
121
		$scope.registerListener();
122
		var opts = {'width': '100%', 
123
					'height': '99%', 
124
					'style': 'dot',
125
					'zoomMin': 1000000,
126
					'zoomMax': 1314000000, // a half month
127
					'start': $scope.startDate,
128
					'end': $scope.endDate};
129
		$scope.timeline.draw($filter('filter')($scope.timelineData, $scope.filterText), opts);
130
    }
131
	
132

  
133
	$scope.refresh();
134
	//$scope.timeline.setScale(links.Timeline.StepDate.SCALE.DAY, 1);
135
	$scope.resizeMainElement(document.getElementById('divTimeline'));
136
	
137
}
138

  
139
window.onresize = function() {
140
	var elem = document.getElementById('divTimeline');
141
    angular.element(elem).scope().resizeMainElement(elem);
142
    angular.element(elem).scope().timeline.redraw();
143
};
modules/dnet-modular-workflows-ui/tags/dnet-modular-workflows-ui-5.0.2/src/main/java/eu/dnetlib/functionality/modular/ui/workflows/objects/AbstractWorkflowDescriptor.java
1
package eu.dnetlib.functionality.modular.ui.workflows.objects;
2

  
3
import com.google.gson.Gson;
4

  
5
public abstract class AbstractWorkflowDescriptor implements Comparable<AbstractWorkflowDescriptor> {
6

  
7
	private String wfId;
8
	private String name;
9
	private String cssClass;
10

  
11
	public AbstractWorkflowDescriptor(final String wfId, final String name, final String cssClass) {
12
		super();
13
		this.wfId = wfId;
14
		this.name = name;
15
		this.cssClass = cssClass;
16
	}
17

  
18
	public String getName() {
19
		return name;
20
	}
21

  
22
	public void setName(final String name) {
23
		this.name = name;
24
	}
25

  
26
	public String getCssClass() {
27
		return cssClass;
28
	}
29

  
30
	public void setCssClass(final String cssClass) {
31
		this.cssClass = cssClass;
32
	}
33

  
34
	public String toJson() {
35
		return (new Gson()).toJson(this);
36
	}
37

  
38
	public String getWfId() {
39
		return wfId;
40
	}
41

  
42
	public void setWfId(final String wfId) {
43
		this.wfId = wfId;
44
	}
45

  
46
	@Override
47
	public int compareTo(final AbstractWorkflowDescriptor o) {
48
		return getName().compareTo(o.getName());
49
	}
50

  
51
}
modules/dnet-modular-workflows-ui/tags/dnet-modular-workflows-ui-5.0.2/src/main/resources/eu/dnetlib/web/resources/js/dnet_workflows_common.js
1
function getScope(selector) {
2
	return angular.element($(selector)).scope();
3
}
4

  
5
function addCommonDirectives(module) {
6
	module.directive('compileTemplate', function($compile, $parse){
7
	    return {
8
	            link: function(scope, element, attr){
9
	                    var parsed = $parse(attr.ngBindHtml);
10
	        
11
	                    function getStringValue() { return (parsed(scope) || '').toString(); }
12

  
13
	                    //Recompile if the template changes
14
	                    scope.$watch(getStringValue, function() {
15
	            $compile(element, null, -9999)(scope);  //The -9999 makes it skip directives so that we do not recompile ourselves
16
	                    });
17
	            }         
18
	    }
19
	});
20

  
21
	module.directive('tooltip', function() {
22
		return {
23
			restrict : 'A',
24
			link : function(scope, element, attrs) {
25
				$(element).tooltip();
26
			}
27
		}
28
	});
29
	
30
	module.filter('sprintf', function() {
31
		function parse(str) {
32
			var args = [].slice.call(arguments, 1),
33
			i = 0;
34
			return str.replace(/%s/g, function() {
35
				return args[i++];
36
			});
37
		}
38
		 
39
		return function(str) {
40
			return parse(str, arguments[1], arguments[2], arguments[3], arguments[4], arguments[5]);
41
		};
42
	});
43
}
44

  
45
function commonInitialize($scope, $http, $sce) {
46

  
47
	$scope.currentProc = {};
48
	$scope.currentProcNode = {};
49
	$scope.currentValue = {};
50
	$scope.currentNode = null;
51

  
52
	$scope.currentLog = [];
53
	$scope.currentSimpleLog = [];
54
	$scope.currentAdvancedLog = [];
55
	$scope.currentStartWf = '-';
56
	$scope.currentEndWf = '-';
57
	
58
	$scope.gridCurrentLogDetails = {
59
		data : 'currentLog',
60
		enableCellSelection : false,
61
		enableRowSelection : false,
62
		enableColumnResize : true,
63
		enableCellEditOnFocus : false,
64
		enablePaging : false,
65
		enableHighlighting: true,
66
		sortInfo : { fields : [ 'name' ], directions : [ 'asc' ] },
67
		columnDefs : [ 
68
		              {	field : 'name', displayName : 'Key', width : '25%', cellTemplate : '<div class="ngCellText" ng-class="col.colIndex()"><span ng-cell-text><a href="javascript:void(0)" ng-click="setCurrentValue(row.entity)">{{row.getProperty(col.field).replace(\"mainlog:\", \"\")}}</a></span></div>' },
69
		              {	field : 'value', displayName : 'Value' } 
70
		             ],        
71
		filterOptions: {filterText: '', useExternalFilter: false},
72
		showFilter: true
73
	};
74
	
75
	$scope.gridCurrentProcNodeEnvParams = {
76
			data : 'currentProcNode.params',
77
			enableCellSelection : false,
78
			enableRowSelection : false,
79
			enableCellEditOnFocus : false,
80
			enablePaging : false,
81
			enableHighlighting: true,
82
			sortInfo : { fields : [ 'name' ], directions : [ 'asc' ] },
83
			columnDefs : [ 
84
			              {	field : 'name', displayName : 'Env Parameter Name', width : '25%', cellTemplate : '<div class="ngCellText" ng-class="col.colIndex()"><span ng-cell-text><a href="javascript:void(0)" ng-click="setCurrentValue(row.entity)">{{row.getProperty(col.field)}}</a></span></div>' },
85
			              {	field : 'value', displayName : 'Env Parameter Value' } 
86
			             ],        
87
			filterOptions: {filterText: '', useExternalFilter: false},
88
			showFilter: true
89
		};
90
	
91
	$scope.to_trusted = function(html_code) {
92
		return $sce.trustAsHtml(html_code);
93
	}
94

  
95
	$scope.showError = function(error) {
96
		show_notification("error", error);
97
	}
98

  
99
	$scope.showNotification = function(message) {
100
		show_notification("info", message);
101
	}
102

  
103
	$scope.showSpinner = function() {
104
		showSpinner();
105
	}
106

  
107
	$scope.hideSpinner = function() {
108
		hideSpinner();
109
	}
110

  
111
	initSpinner();
112

  
113
	$scope.getNodeDetails = function(wf, node) {
114
		$scope.currentNode = null;
115
		$scope.showSpinner();
116
		$http
117
				.get('wf_workflow_node.json?wf=' + wf + '&node=' + node)
118
				.success(function(data) {
119
					$scope.currentNode = data;
120
					$scope.hideSpinner();
121
					$('#nodeEditModal').modal('show');
122
				})
123
				.error(
124
						function(err) {
125
							$scope.showError(err.message);
126
							$scope.hideSpinner();
127
						});
128
	}
129

  
130
	$scope.setCurrentValue  = function(row) {
131
		$scope.currentValue = row;
132
	}
133
	
134
	$scope.showProcess = function(id) {
135
		$('#journalWfModal').modal('hide');
136
		$('#monitorWfModal').modal('hide');
137

  
138
		$scope.showSpinner();
139
		
140
		if (!$('#monitorProcWfModal').hasClass('in')) {
141
			$scope.currentStartWf = 0;
142
			$scope.currentEndWf = 0;
143
			$scope.currentValue = {};
144
			
145
			$scope.currentLog = null;
146
			$scope.currentAdvancedLog = null;
147
			$scope.currentSimpleLog = null;
148
			$scope.currentProc = null;
149
		}
150
		
151
		$http.get('wf_journal.get?id=' + id).success(function(data) {
152
			if (data.graph) {
153
				$scope.currentProc = data.graph;
154
			}
155

  
156
			if (!$('#monitorProcWfModal').hasClass('in')) {
157
				if (data.journal) {
158
					$scope.currentAdvancedLog = data.journal;
159
					$scope.currentSimpleLog = [];
160
	
161
					angular.forEach($scope.currentAdvancedLog, function(value, key){
162
						if ((/^dataprovider\:/).test(value.name) || (/^mainlog\:/).test(value.name) || ((/error/).test(value.name) && (value.value))) {
163
							$scope.currentSimpleLog.push(value);
164
						} else if (value.name == 'system:startDate') {
165
							$scope.currentStartWf = value.value;
166
						} else if (value.name == 'system:endDate') {
167
							$scope.currentEndWf = value.value;
168
						}
169
					});
170
				
171
					$scope.currentLog = $scope.currentSimpleLog;
172
					$scope.hideSpinner();
173
					
174
					$('#currentLogDetailsModal').modal('show');
175
					
176
				} else if ($scope.currentProc) {
177
					$('#monitorProcWfModal').modal('show');
178
				}
179
			}
180

  
181
			$scope.hideSpinner();
182

  
183
		}).error(function(err) {
184
			$scope.showError(err.message);
185
			$scope.hideSpinner();
186
		});
187
	}
188
	
189
	
190
	$scope.calculateDateDiff = function(start, end) {
191
		if (start <= 0 || end <= 0) {
192
			return '-';
193
		}
194
		var seconds = 0;
195
		var minutes = 0;
196
		var hours = 0;
197
		var days = 0;
198

  
199
		if (end > start) {
200
			seconds = Math.round((end - start) / 1000);
201
			
202
			if (seconds > 60) {
203
				minutes = Math.floor(seconds / 60);
204
				seconds = seconds % 60;
205
				if (minutes > 60) {
206
					hours = Math.floor(minutes / 60);
207
					minutes = minutes % 60;
208
					if (hours > 24) {
209
						days = Math.floor(hours / 24);
210
						hours = hours % 24;
211
					}
212
				}
213
			}
214
		}
215
		
216
		var res = '';
217
		if (days > 0) {
218
			if (res) {	res += ', '; } 
219
			res += days + " day(s)"
220
		}
221
		if (hours > 0) {
222
			if (res) {	res += ', '; } 
223
			res += hours + " hour(s)"
224
		}
225
		if (minutes > 0) {
226
			if (res) {	res += ', '; } 
227
			res += minutes + " minute(s)"
228
		}
229
		if (seconds > 0) {
230
			if (res) {	res += ', '; } 
231
			res += seconds + " second(s)"
232
		}
233

  
234
		if (!res) {
235
			res = '0 seconds';
236
		} 
237
		
238
		return res;
239
	} 
240

  
241
	$scope.getProcessNodeDetails = function(procId, nodeId) {
242
		$('#monitorProcWfModal').modal('hide');
243
		$scope.showSpinner();
244
		$http
245
				.get('wf_proc_node.json?id=' + procId + "&node=" + nodeId)
246
				.success(function(data) {
247
					$scope.currentProcNode = data;
248
					$scope.hideSpinner();
249
					$('#monitorProcNodeModal').modal('show');
250
				})
251
				.error(
252
						function(err) {
253
							$scope.showError(err.message);
254
							$scope.hideSpinner();
255
						});
256
	}
257

  
258
	$scope.killProcess = function(procId) {
259
		if (confirm("Are you sure ?")) {
260
			$scope.showSpinner();
261
			$http.get('wf_proc.kill?id=' + procId).success(function(data) {
262
				$scope.currentProc = {};
263
				$scope.hideSpinner();
264
				$('#monitorProcWfModal').modal('hide');
265
				$scope.showNotification('Workflow killed !');
266
			}).error(function(err) {
267
				$scope.showError(err.message);
268
				$scope.hideSpinner();
269
			});
270
		}
271
	}
272

  
273
	$scope.showSpinner();
274
}
275

  
276
function wf_init($scope, $http, $sce) {
277
	
278
	$scope.currentWorkflow = {};
279
	$scope.currentUserParams = {};
280
	$scope.currentMetaWorkflow = {};
281
	$scope.metaworkflows = [];
282
	$scope.validParamValuesCache = {};
283
	$scope.currentHistory = [];
284
	$scope.filterMetaWfHistory = { filterText : '' };
285
		
286
	$scope.gridHistory = {
287
		data : 'currentHistory',
288
		enableCellEditOnFocus : false,
289
		enablePaging : false,
290
		enableHighlighting : true,
291
		sortInfo : { fields : [ 'date' ], directions : [ 'desc' ] },
292
		filterOptions : $scope.filterMetaWfHistory,
293
		columnDefs : [
294
			{ field : 'procId', displayName : 'Process ID', width : '15%', cellTemplate : '<div class="ngCellText"><a href="javascript:void(0)" ng-click="showProcess(row.getProperty(col.field))">{{row.getProperty(col.field)}}</a></div>' },
295
			{ field : 'name', displayName : 'Workflow name', width : '40%' },
296
			{ field : 'family', displayName : 'Workflow Family', width : '15%' },
297
			{ field : 'status', displayName : 'Status', width : '10%', cellTemplate : '<div class="ngCellText"><span class="label label-default" ng-class="{ \'label-success\': row.getProperty(col.field) == \'SUCCESS\', \'label-danger\': row.getProperty(col.field) == \'FAILURE\', \'label-info\': row.getProperty(col.field) == \'EXECUTING\'}">{{row.getProperty(col.field)}}</span></div>' },
298
			{ field : 'date', displayName : 'Last activity', cellTemplate : '<div class="ngCellText">{{ (row.getProperty("date") > 0 && row.getProperty("date") < 9999999999999) ? (row.getProperty("date") | date:"yyyy-MM-dd HH:mm:ss") : "not yet started" }}</div>' }
299
		]
300
	};
301
	
302
	$scope.verifyType = function(val, type) {
303
		if (type == 'string') {
304
			return val.length > 0;
305
		} else if (type == 'text') {
306
			return val.length > 0;
307
		} else if (type == 'boolean') {
308
			return (val == 'true') || (val == 'false');
309
		} else if (type == 'int') {
310
			return val.test(/^\s*-?\d+\s*$/);
311
		} else if (type == 'float') {
312
			return val.test(/^\s*-?\d*(\.\d+)?\s*$/);
313
		} else if (type == 'date') {
314
			return val.test(/^(0[1-9]|[12][0-9]|3[01])[- \/.](0[1-9]|1[012])[- \/.](19|20)\d\d$/);
315
		} else if (type == 'datetime') {
316
			return true;
317
		} else if (type == 'property') {
318
			return true;
319
		} else {
320
			return false;
321
		}
322

  
323
	}
324
	
325
	$scope.getMetaWorkflow = function(id) {
326
		if (id) {
327
			$scope.showSpinner();
328
			$http.get('wf_metaworkflow.json?id=' + id).success(function(data) {
329
				$scope.currentMetaWorkflow = data;
330
				$scope.hideSpinner();
331
			}).error(function(err) {
332
				$scope.showError(err.message);
333
				$scope.hideSpinner();
334
			});
335
		}
336
	}
337
	
338
	$scope.getAtomicWorkflow = function(id) {
339
		$scope.currentWorkflow = null;
340
		$scope.currentNode = null;
341
		
342
		$scope.showSpinner();
343
		$http.get('wf_atomic_workflow.json?id=' + id).success(function(data) {
344
			$scope.currentWorkflow = data;
345
			$scope.hideSpinner();
346
			$('#atomWfModal').modal('show')
347
		}).error(function(err) {
348
			$scope.showError(err.message);
349
			$scope.hideSpinner();
350
		});
351
	}
352
	
353
	$scope.getAtomicWorkflowAndMetaWf = function(metaWfId, wfId) {
354
		$scope.showSpinner();
355
		$http.get('wf_metaworkflow.json?id=' + metaWfId).success(function(data) {
356
			$scope.currentMetaWorkflow = data;
357
			$scope.getAtomicWorkflow(wfId);
358
		}).error(function(err) {
359
			$scope.showError(err.message);
360
			$scope.hideSpinner();
361
		});
362
	}
363

  
364
	$scope.getWorkflows = function(loadFirstElement, params) {
365
		$scope.showSpinner();
366

  
367
		$http.get('list_metaworkflows.json?' + params).success(function(data) {
368
			$scope.metaworkflows = data;
369
			$scope.hideSpinner();
370

  
371
			if (loadFirstElement) {
372
				if ($scope.initialWf && $scope.initialMetaWf) {
373
					angular.forEach($scope.metaworkflows, function(mw, key) {
374
						if (mw.wfId == $scope.initialMetaWf) {
375
							$scope.getAtomicWorkflowAndMetaWf($scope.initialMetaWf, $scope.initialWf);
376
							return;
377
						}
378
					});
379
				} else if ($scope.initialMetaWf) {
380
					angular.forEach($scope.metaworkflows, function(mw, key) {
381
						if (mw.wfId == $scope.initialMetaWf) {
382
							$scope.getMetaWorkflow(mw.wfId);
383
							return;
384
						}
385
					});
386
				} else if ($scope.metaworkflows.length > 0) {
387
					var id = $scope.metaworkflows[0].wfId;
388
					$scope.getMetaWorkflow(id);
389
				}
390
			} else {
391
				angular.forEach($scope.metaworkflows, function(value, key){
392
					if (value.wfId == $scope.currentMetaWorkflow.wfId) {
393
						$scope.currentMetaWorkflow = value;
394
					}
395
				});
396
			}
397
		}).error(function(err) {
398
			$scope.showError(err.message);
399
			$scope.hideSpinner();
400
		});	
401
	}
402
	
403
	$scope.executeWf = function(wfId) {
404
		$http.get('wf.start?id=' + wfId).success(function(data) {
405
			$scope.updateMetaWorkflowHistory();
406
			$('#monitorWfModal').modal('show');
407
		}).error(function(err) {
408
			$scope.showError(err.message);
409
		});
410
	};
411

  
412
	$scope.executeMetaWf = function() {
413
		$http.get('metawf.start?id=' + $scope.currentMetaWorkflow.wfId).success(function(data) {
414
			$scope.updateMetaWorkflowHistory();
415
			$('#monitorWfModal').modal('show');
416
		}).error(function(err) {
417
			$scope.showError(err.message);
418
		});
419
	};
420
	
421
	$scope.prepareMetaWfEdit = function() {
422
		$scope.tempMetaWorkflow = angular.copy($scope.currentMetaWorkflow);
423
	};
424
	
425
	$scope.saveCurrentMetaWf = function() {
426
		$scope.showSpinner();
427
		$http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8";
428
		$http.post('wf_metaworkflow.edit', $.param({
429
			'json' : JSON.stringify($scope.tempMetaWorkflow)
430
		})).success(function(data) {
431
			$scope.hideSpinner();
432

  
433
			angular.forEach($scope.metaworkflows, function(value, key) {
434
				if (value.wfId == $scope.tempMetaWorkflow.wfId || value.id == $scope.tempMetaWorkflow.wfId) {
435
					value.name = $scope.tempMetaWorkflow.name;
436
				}
437
			});
438
			$scope.showNotification('MetaWorkflow updated !');
439
			
440
			$scope.getMetaWorkflow($scope.tempMetaWorkflow.wfId);
441
		}).error(function(err) {
442
			$scope.showError(err.message);
443
			$scope.hideSpinner();
444
		});
445
	};
446
	
447
	$scope.changeWfStartMode = function(wfId, val) {
448
		$scope.showSpinner();
449
		$http.get('wf_atomic_workflow.enable?start=' + val + "&id="	+ wfId).success(function(data) {
450
			$scope.hideSpinner();
451
			$scope.getMetaWorkflow($scope.currentMetaWorkflow.wfId);
452
		}).error(function(err) {
453
			$scope.showError(err.message);
454
			$scope.hideSpinner();
455
		});
456
	}
457
	
458
	$scope.listValidValuesForUserParam = function(func) {
459
		if (!$scope.validParamValuesCache[func]) {
460
			$scope.showSpinner();
461
			try {
462
				$scope.validParamValuesCache[func] = eval(func);
463
			} catch (e) {
464
				alert('Error evaluating function: ' + func);
465
				$scope.validParamValuesCache[func] = [];
466
			}
467
			$scope.hideSpinner();
468
		}
469
		return $scope.validParamValuesCache[func];
470
	}
471
	
472
	
473
	$scope.listWorkflowsUserParams = function(wfId) {
474
		$scope.showSpinner();
475

  
476
		$scope.currentUserParams = {};
477
		
478
		$http.get('workflow_user_params.json?wf=' + wfId)
479
        .success(
480
            function(data) {
481
            	$scope.hideSpinner();
482
            	$scope.currentUserParams = {
483
            		'wfId' : wfId,
484
            		'data' : data  
485
            	};
486
            }
487
        ).error(
488
            function(err) {
489
            	$scope.showError(err.message);
490
            	$scope.hideSpinner();
491
            }
492
        );
493
		
494
	}	
495
	
496
	$scope.saveWorkflowsUserParams = function() {
497
		$scope.showSpinner();
498
		
499
		$http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8";
500
		$http.post('save_user_params.do', $.param({
501
			'wf' : $scope.currentUserParams.wfId,
502
			'params' : JSON.stringify($scope.currentUserParams.data)
503
		})).success(function(b) {
504
			$scope.hideSpinner();
505
			$scope.showNotification('Workflow updated !');
506
			$scope.getMetaWorkflow($scope.currentMetaWorkflow.wfId);
507
		}).error(function(err) {
508
			$scope.hideSpinner();
509
			$scope.showError(err.message);
510

  
511
		});
512
	}
513
	
514
	$scope.updateMetaWorkflowHistory = function() {
515
		$scope.updateHistory($scope.currentMetaWorkflow.innerWfs);
516
	};
517
	
518
	$scope.updateHistory = function(ids) {
519
		$scope.currentHistory = [];
520
		$scope.showSpinner();
521
		$http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8";
522
		$http.post('wf_journal.find', $.param({
523
			'wfs' : JSON.stringify(ids)
524
		})).success(function(data) {
525
			$scope.hideSpinner();
526
			$scope.currentHistory = data;
527
			$('#monitorWfModal').modal('show')
528
		}).error(function(err) {
529
			$scope.hideSpinner();
530
			$scope.showError(err.message);
531
		});
532
	};
533
}
modules/dnet-modular-workflows-ui/tags/dnet-modular-workflows-ui-5.0.2/src/main/java/eu/dnetlib/functionality/modular/ui/workflows/objects/FilterElem.java
1
package eu.dnetlib.functionality.modular.ui.workflows.objects;
2

  
3
public class FilterElem {
4
	private String name;
5
	private String icon;
6
	private String value;
7
	
8
	public FilterElem(String name, String icon, String value) {
9
		super();
10
		this.name = name;
11
		this.icon = icon;
12
		this.value = value;
13
	}
14

  
15
	public String getName() {
16
		return name;
17
	}
18

  
19
	public void setName(String name) {
20
		this.name = name;
21
	}
22

  
23
	public String getIcon() {
24
		return icon;
25
	}
26

  
27
	public void setIcon(String icon) {
28
		this.icon = icon;
29
	}
30

  
31
	public String getValue() {
32
		return value;
33
	}
34

  
35
	public void setValue(String value) {
36
		this.value = value;
37
	}
38
}
modules/dnet-modular-workflows-ui/tags/dnet-modular-workflows-ui-5.0.2/src/main/resources/eu/dnetlib/web/resources/js/dnet_workflows.js
1
var module = angular.module('workflowsUI', ['ngGrid']);
2

  
3
addCommonDirectives(module);
4

  
5
function workflowsCtrl($scope, $http, $sce) {
6
	$scope.currentSection = getSection();
7
	$scope.initialWf = getInitialWf();
8
	$scope.initialMetaWf = getInitialMetaWf();
9
	
10
	commonInitialize($scope, $http, $sce);
11
	
12
	wf_init($scope, $http, $sce);
13

  
14
	$scope.cloneMetaWf = function(id, name) {
15
		$scope.showSpinner();
16
		$http.get('clone_metaworkflow.do?id=' + id +'&name=' + name)
17
        .success(
18
            function(data) {
19
            	$scope.hideSpinner();
20
				$scope.reload(false);
21
				$scope.getMetaWorkflow(data);
22
            }
23
        ).error(
24
            function(err) {
25
            	$scope.showError(err.message);
26
            	$scope.hideSpinner();
27
            }
28
        );
29
	}	
30
	
31
	$scope.reload = function(loadFirstElement) {
32
		if ($scope.currentSection) { $scope.getWorkflows(loadFirstElement, 'section=' + $scope.currentSection) }
33
		else                       { $scope.hideSpinner(); }
34
	}
35
	
36
	$scope.reload(true);
37
}
modules/dnet-modular-workflows-ui/tags/dnet-modular-workflows-ui-5.0.2/src/main/resources/eu/dnetlib/web/resources/js/dnet_ds_workflows.js
1
var module = angular.module('workflowsUI', ['ngGrid']);
2

  
3
addCommonDirectives(module);
4

  
5
function workflowsCtrl($scope, $http, $sce) {
6

  
7
	commonInitialize($scope, $http, $sce);
8
	
9
	wf_init($scope, $http, $sce);
10
	
11
	$scope.getMetaWorkflow($scope.initialMetaWf);
12
}
modules/dnet-modular-workflows-ui/tags/dnet-modular-workflows-ui-5.0.2/src/main/java/eu/dnetlib/functionality/modular/ui/workflows/values/ListFilesValues.java
1
package eu.dnetlib.functionality.modular.ui.workflows.values;
2

  
3
import java.io.File;
4
import java.util.List;
5
import java.util.Map;
6

  
7
import org.springframework.core.io.Resource;
8
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
9
import org.springframework.core.io.support.ResourcePatternResolver;
10

  
11
import com.google.common.collect.Lists;
12

  
13
import eu.dnetlib.msro.workflows.util.ValidNodeValuesFetcher;
14

  
15
public class ListFilesValues extends ValidNodeValuesFetcher {
16

  
17
	private final ResourcePatternResolver pathResolver = new PathMatchingResourcePatternResolver();
18

  
19
	@Override
20
	protected List<DnetParamValue> obtainValues(final Map<String, String> params) throws Exception {
21
		verifyParams(params, "path", "ext");
22

  
23
		final String pathTmp = params.get("path");
24

  
25
		final String path = pathTmp.startsWith("/") ? pathTmp : "/" + pathTmp;
26

  
27
		final List<DnetParamValue> values = Lists.newArrayList();
28
		for (Resource r : pathResolver.getResources("classpath*:" + path + "/*." + params.get("ext"))) {
29
			values.add(new DnetParamValue(path + File.separator + r.getFilename(), r.getFilename()));
30
		}
31

  
32
		return values;
33
	}
34

  
35
}
modules/dnet-modular-workflows-ui/tags/dnet-modular-workflows-ui-5.0.2/src/main/resources/eu/dnetlib/web/resources/js/dnet_param_values_functions.js
1
function validValues(arr) {
2
	var res = [];
3
	for (i=0; i<arr.length; i++) {
4
		res.push({'id': arr[i], 'name': arr[i]});
5
	}
6
	return res;
7
}
8

  
9
function intRange(from, to) {
10
	var res = [];
11
	for (i=from; i<to; i++) {
12
		res.push({'id': i, 'name': i});
13
	}
14
	return res;
15
}
16

  
17
function obtainValues(bean, params) {
18
	var strReturn = [];
19
	jQuery.ajax({
20
		type: "POST",
21
		url: "wf_obtainValidValues.list?bean=" + bean,
22
		async:false,
23
		data: params,
24
		dataType: "json",
25
		success: function(json) {
26
			strReturn = json;
27
		}
28
	});
29
	return strReturn;
30
}
31

  
32
function listFiles(path, ext)      { return obtainValues('listFiles', { 'path': path, 'ext': ext }); }
33
function listProfiles(type, xpath) { return obtainValues('listProfiles', { 'type': type, 'xpath': xpath }); }
modules/dnet-modular-workflows-ui/tags/dnet-modular-workflows-ui-5.0.2/src/main/java/eu/dnetlib/functionality/modular/ui/workflows/util/functions/NodeToWorkflowParam.java
1
package eu.dnetlib.functionality.modular.ui.workflows.util.functions;
2

  
3
import java.util.List;
4
import java.util.Map;
5

  
6
import org.apache.commons.lang.StringUtils;
7
import org.dom4j.Node;
8

  
9
import com.google.common.base.Function;
10
import com.google.common.collect.Lists;
11
import com.google.common.collect.Maps;
12

  
13
import eu.dnetlib.msro.workflows.util.WorkflowParam;
14
import eu.dnetlib.msro.workflows.util.WorkflowParamUI;
15

  
16
public class NodeToWorkflowParam implements Function<Node, WorkflowParam> {
17
	
18
	private Map<String, List<WorkflowParamUI>> mapUis = Maps.newHashMap();
19
		
20
	public NodeToWorkflowParam(final Map<String, List<WorkflowParamUI>> mapUis) {
21
		this.mapUis = mapUis;
22
	}
23

  
24
	@Override
25
	public WorkflowParam apply(final Node n) {
26
		final String key = n.valueOf("@name");
27
		final boolean required = "true".equalsIgnoreCase(n.valueOf("@required"));
28
		final String type = n.valueOf("@type");
29
		final String function = n.valueOf("@function");
30
		final String value = n.getText();
31
		final boolean userParam = "user".equals(n.valueOf("@managedBy"));
32
		final String category = n.valueOf("@category");
33
		final List<WorkflowParamUI> uis = calculateUis(category);
34
		
35
		return new WorkflowParam(key, value, required, userParam, type, function, uis);
36
	}
37

  
38
	private List<WorkflowParamUI> calculateUis(final String category) {
39
		if (!StringUtils.isEmpty(category) && mapUis.containsKey(category)) {
40
			return mapUis.get(category);
41
		} else {
42
			return Lists.newArrayList();
43
		}
44
	}
45

  
46
}
modules/dnet-modular-workflows-ui/tags/dnet-modular-workflows-ui-5.0.2/src/main/resources/eu/dnetlib/functionality/modular/ui/webContext-modular-ui-workflows.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2

  
3
<beans xmlns="http://www.springframework.org/schema/beans"
4
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
5
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
6

  
7
	<bean name="/ui/workflows.do"
8
		class="eu.dnetlib.functionality.modular.ui.workflows.controllers.WfEntryPointController"
9
		p:menu="Infrastructure Management" 
10
		p:title="Infrastructure Management"
11
		p:description="Infrastructure Workflows Management" 
12
		p:group="Infrastructure Management"
13
		p:validMenuEntry="false">
14
		<property name="permissionLevels">
15
			<set>
16
				<value>DS_ADMIN</value>
17
			</set>
18
		</property>
19
	</bean>
20
	
21
	<bean name="/ui/workflow_journal.do"
22
		class="eu.dnetlib.functionality.modular.ui.workflows.controllers.WfHistoryEntryPointController"
23
		p:menu="Workflow history" 
24
		p:title="Workflow history"
25
		p:description="Workflow history" 
26
		p:group="Logs"
27
		p:order="10"
28
		p:groupOrder="100">
29
		<property name="permissionLevels">
30
			<set>
31
				<value>WF_ADMIN</value>
32
				<value>DS_ADMIN</value>
33
			</set>
34
		</property>
35
	</bean>
36
	
37
	<bean name="/ui/workflow_timeline.do"
38
		class="eu.dnetlib.functionality.modular.ui.workflows.controllers.WfHistoryEntryPointController"
39
		p:menu="Workflow timeline" 
40
		p:title="Workflow timeline"
41
		p:description="Workflow timeline" 
42
		p:group="Logs"
43
		p:order="11"
44
		p:groupOrder="100">
45
		<property name="permissionLevels">
46
			<set>
47
				<value>WF_ADMIN</value>
48
				<value>DS_ADMIN</value>
49
			</set>
50
		</property>
51
	</bean>
52
	
53
	<bean name="infrastructureManagementMenu"
54
		class="eu.dnetlib.functionality.modular.ui.workflows.menu.InfrastructureManagementGroup"
55
		p:title="Infrastructure Management" 
56
		p:order="11"/>
57
		
58

  
59
</beans>
modules/dnet-modular-workflows-ui/tags/dnet-modular-workflows-ui-5.0.2/src/main/java/eu/dnetlib/functionality/modular/ui/workflows/controllers/DnetParamValuesController.java
1
package eu.dnetlib.functionality.modular.ui.workflows.controllers;
2

  
3
import java.io.IOException;
4
import java.io.StringReader;
5
import java.util.ArrayList;
6
import java.util.Collections;
7
import java.util.Enumeration;
8
import java.util.List;
9
import java.util.Map;
10

  
11
import javax.annotation.Resource;
12
import javax.servlet.http.HttpServletRequest;
13
import javax.servlet.http.HttpServletResponse;
14

  
15
import org.apache.commons.io.IOUtils;
16
import org.apache.commons.logging.Log;
17
import org.apache.commons.logging.LogFactory;
18
import org.springframework.stereotype.Controller;
19
import org.springframework.web.bind.annotation.RequestMapping;
20
import org.springframework.web.bind.annotation.RequestParam;
21

  
22
import com.google.common.collect.Maps;
23
import com.google.gson.Gson;
24

  
25
import eu.dnetlib.functionality.modular.ui.AbstractAjaxController;
26
import eu.dnetlib.msro.workflows.util.ValidNodeValuesFetcher;
27
import eu.dnetlib.msro.workflows.util.ValidNodeValuesFetcher.DnetParamValue;
28

  
29
@Controller
30
public class DnetParamValuesController extends AbstractAjaxController {
31

  
32
	@Resource
33
	private List<ValidNodeValuesFetcher> validNodesFetchers;
34

  
35
	private static final Log log = LogFactory.getLog(DnetParamValuesController.class);
36

  
37
	@RequestMapping("/ui/**/wf_obtainValidValues.list")
38
	public void obtainValidValues(final HttpServletRequest request,
39
		final HttpServletResponse response,
40
		@RequestParam(value = "bean", required = true) final String bean) throws IOException {
41

  
42
		final ValidNodeValuesFetcher fetcher = findValidNodeValuesFetcher(bean);
43

  
44
		if (fetcher == null) {
45
			log.error("ValidNodeValuesFetcher not found: " + bean);
46
			sendResponse(response, new ArrayList<>());
47
		} else {
48
			final Map<String, String> params = findParams(request);
49
			sendResponse(response, fetcher.evaluate(params));
50
		}
51
	}
52

  
53
	private ValidNodeValuesFetcher findValidNodeValuesFetcher(final String bean) {
54
		for (final ValidNodeValuesFetcher fetcher : validNodesFetchers) {
55
			if (fetcher.getName().equals(bean)) { return fetcher; }
56
		}
57
		return null;
58
	}
59

  
60
	private Map<String, String> findParams(final HttpServletRequest request) {
61
		final Map<String, String> params = Maps.newHashMap();
62

  
63
		final Enumeration<?> e = request.getParameterNames();
64
		while (e.hasMoreElements()) {
65
			final String name = (String) e.nextElement();
66
			params.put(name, request.getParameter(name));
67
		}
68
		return params;
69
	}
70

  
71
	private void sendResponse(final HttpServletResponse response, final List<DnetParamValue> values) throws IOException {
72
		Collections.sort(values);
73

  
74
		response.setContentType("application/json;charset=UTF-8");
75

  
76
		IOUtils.copy(new StringReader(new Gson().toJson(values)), response.getOutputStream());
77
	}
78
}
modules/dnet-modular-workflows-ui/tags/dnet-modular-workflows-ui-5.0.2/src/main/java/eu/dnetlib/functionality/modular/ui/workflows/controllers/WfEntryPointController.java
1
package eu.dnetlib.functionality.modular.ui.workflows.controllers;
2

  
3
import java.io.StringWriter;
4
import java.net.URLEncoder;
5
import java.util.List;
6

  
7
import javax.annotation.Resource;
8
import javax.servlet.http.HttpServletRequest;
9
import javax.servlet.http.HttpServletResponse;
10

  
11
import org.apache.commons.lang.StringUtils;
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff