Project

General

Profile

« Previous | Next » 

Revision 39792

added priority to update wf form

View differences:

modules/dnet-modular-workflows-ui/branches/workflow_templates/src/main/java/eu/dnetlib/functionality/modular/ui/workflows/objects/WorkflowSchedulingInfo.java
1
package eu.dnetlib.functionality.modular.ui.workflows.objects;
2

  
3
import com.google.gson.Gson;
4
import eu.dnetlib.msro.workflows.instances.WorkflowStartModeEnum;
5

  
6
public class WorkflowSchedulingInfo implements Comparable<WorkflowSchedulingInfo> {
7

  
8
	private String wfId;
9
	private WorkflowStartModeEnum mode;
10
	private String email;
11
	private boolean scheduled;
12
	private String cron;
13
	private int interval;
14

  
15
	public WorkflowSchedulingInfo() {
16
	}
17

  
18
	public WorkflowSchedulingInfo(final String wfId,
19
			final WorkflowStartModeEnum mode,
20
			final String email,
21
			final boolean scheduled,
22
			final String cron,
23
			final int interval) {
24
		this.wfId = wfId;
25
		this.mode = mode;
26
		this.email = email;
27
		this.scheduled = scheduled;
28
		this.cron = cron;
29
		this.interval = interval;
30
	}
31

  
32
	public String getWfId() {
33
		return wfId;
34
	}
35

  
36
	public void setWfId(final String wfId) {
37
		this.wfId = wfId;
38
	}
39

  
40
	public WorkflowStartModeEnum getMode() {
41
		return mode;
42
	}
43

  
44
	public void setMode(final WorkflowStartModeEnum mode) {
45
		this.mode = mode;
46
	}
47

  
48
	public String getEmail() {
49
		return email;
50
	}
51

  
52
	public void setEmail(final String email) {
53
		this.email = email;
54
	}
55

  
56
	public boolean isScheduled() {
57
		return scheduled;
58
	}
59

  
60
	public void setScheduled(final boolean scheduled) {
61
		this.scheduled = scheduled;
62
	}
63

  
64
	public String getCron() {
65
		return cron;
66
	}
67

  
68
	public void setCron(final String cron) {
69
		this.cron = cron;
70
	}
71

  
72
	public int getInterval() {
73
		return interval;
74
	}
75

  
76
	public void setInterval(final int interval) {
77
		this.interval = interval;
78
	}
79

  
80
	public String toJson() {
81
		return (new Gson()).toJson(this);
82
	}
83
	
84
	@Override
85
	public int compareTo(final WorkflowSchedulingInfo o) {
86
		return getWfId().compareTo(o.getWfId());
87
	}
88

  
89
}
modules/dnet-modular-workflows-ui/branches/workflow_templates/src/main/resources/eu/dnetlib/web/resources/html/wf/wf-form-scheduling.html
1
<form class="form-horizontal">
2
	<div class="form-group">
3
		<label class="col-sm-3 control-label">Launch mode</label>
4

  
5
		<div class="col-sm-9">
6
			<label class="radio-inline text-primary">
7
				<input type="radio" name="radioLaunchMode" ng-model="wf.mode" value="auto"/>
8
				auto
9
			</label>
10
			<label class="radio-inline text-warning">
11
				<input type="radio" name="radioLaunchMode" ng-model="wf.mode" value="manual"/>
12
				manual
13
			</label>
14
			<label class="radio-inline text-danger">
15
				<input type="radio" name="radioLaunchMode" ng-model="wf.mode" value="disabled"/>
16
				disabled
17
			</label>
18
		</div>
19
	</div>
20
	<div class="form-group">
21
		<label class="col-sm-3 control-label">Email notification</label>
22

  
23
		<div class="col-sm-9">
24
			<input type="text" class="form-control" ng-model="wf.email" placeholder="emails..."/>
25
		</div>
26
	</div>
27
	<div class="form-group">
28
		<label class="col-sm-3 control-label">Enable scheduling</label>
29

  
30
		<div class="col-sm-9">
31
			<input type="checkbox" ng-model="wf.scheduled"/>
32
		</div>
33
	</div>
34
	<div class="form-group">
35
		<label class="col-sm-3 control-label">Cron expression</label>
36

  
37
		<div class="col-sm-4">
38
			<input type="text" class="form-control" ng-model="wf.cron" placeholder="cron expression..." ng-disabled="!wf.scheduled"/>
39
		</div>
40
	</div>
41
	<div class="form-group">
42
		<label class="col-sm-3 control-label">Minimum interval (in minutes)</label>
43

  
44
		<div class="col-sm-4">
45
			<input type="text" class="form-control" ng-model="wf.interval" placeholder="interval..." ng-disabled="!wf.scheduled"/>
46
		</div>
47
	</div>
48
	<div class="form-group">
49
		<div class="col-sm-offset-3 col-sm-9">
50
			<button class="btn btn-primary" ng-click="saveScheduling()">
51
				<span style="margin-right: 8px" class="glyphicon glyphicon-ok"></span>Update
52
			</button>
53
			<button class="btn btn-default" style="margin-left:5px;" ng-click="reset()">
54
				<span style="margin-right:8px" class="glyphicon glyphicon-remove"></span>
55
				Reset
56
			</button>
57
		</div>
58
	</div>
59
</form>
modules/dnet-modular-workflows-ui/branches/workflow_templates/src/main/java/eu/dnetlib/functionality/modular/ui/workflows/controllers/WorkflowsController.java
137 137
		return isLookupClient.getNodeInfo(wfId, nodeName);
138 138
	}
139 139

  
140
	@RequestMapping("/ui/schedule_workflow.do")
140
	@RequestMapping("/ui/update_workflow.do")
141 141
	public
142 142
	@ResponseBody
143
	boolean scheduleWorkflow(@RequestParam(value = "json", required = true) final String json) throws Exception {
143
	boolean updateWorkflow(@RequestParam(value = "json", required = true) final String json) throws Exception {
144 144

  
145
		final WorkflowSchedulingInfo info = (new Gson()).fromJson(json, WorkflowSchedulingInfo.class);
145
		final WorkflowUpdateInfo info = (new Gson()).fromJson(json, WorkflowUpdateInfo.class);
146 146

  
147 147
		log.info("Updating workflow " + info.getWfId());
148 148

  
modules/dnet-modular-workflows-ui/branches/workflow_templates/src/main/java/eu/dnetlib/functionality/modular/ui/workflows/objects/WorkflowUpdateInfo.java
1
package eu.dnetlib.functionality.modular.ui.workflows.objects;
2

  
3
import com.google.gson.Gson;
4
import eu.dnetlib.msro.workflows.instances.WorkflowStartModeEnum;
5

  
6
public class WorkflowUpdateInfo implements Comparable<WorkflowUpdateInfo> {
7

  
8
	private String wfId;
9
	private WorkflowStartModeEnum mode;
10
	private int priority;
11
	private String email;
12
	private boolean scheduled;
13
	private String cron;
14
	private int interval;
15

  
16
	public WorkflowUpdateInfo() {
17
	}
18

  
19
	public WorkflowUpdateInfo(final String wfId,
20
			final WorkflowStartModeEnum mode,
21
			final int priority,
22
			final String email,
23
			final boolean scheduled,
24
			final String cron,
25
			final int interval) {
26
		this.wfId = wfId;
27
		this.mode = mode;
28
		this.priority = priority;
29
		this.email = email;
30
		this.scheduled = scheduled;
31
		this.cron = cron;
32
		this.interval = interval;
33
	}
34

  
35
	public String getWfId() {
36
		return wfId;
37
	}
38

  
39
	public void setWfId(final String wfId) {
40
		this.wfId = wfId;
41
	}
42

  
43
	public WorkflowStartModeEnum getMode() {
44
		return mode;
45
	}
46

  
47
	public void setMode(final WorkflowStartModeEnum mode) {
48
		this.mode = mode;
49
	}
50

  
51
	public int getPriority() {
52
		return priority;
53
	}
54

  
55
	public void setPriority(final int priority) {
56
		this.priority = priority;
57
	}
58

  
59
	public String getEmail() {
60
		return email;
61
	}
62

  
63
	public void setEmail(final String email) {
64
		this.email = email;
65
	}
66

  
67
	public boolean isScheduled() {
68
		return scheduled;
69
	}
70

  
71
	public void setScheduled(final boolean scheduled) {
72
		this.scheduled = scheduled;
73
	}
74

  
75
	public String getCron() {
76
		return cron;
77
	}
78

  
79
	public void setCron(final String cron) {
80
		this.cron = cron;
81
	}
82

  
83
	public int getInterval() {
84
		return interval;
85
	}
86

  
87
	public void setInterval(final int interval) {
88
		this.interval = interval;
89
	}
90

  
91
	public String toJson() {
92
		return (new Gson()).toJson(this);
93
	}
94

  
95
	@Override
96
	public int compareTo(final WorkflowUpdateInfo o) {
97
		return getWfId().compareTo(o.getWfId());
98
	}
99

  
100
}
modules/dnet-modular-workflows-ui/branches/workflow_templates/src/main/java/eu/dnetlib/functionality/modular/ui/workflows/util/ISRegistryClient.java
9 9
import eu.dnetlib.enabling.locators.UniqueServiceLocator;
10 10
import eu.dnetlib.functionality.modular.ui.workflows.objects.NodeInfo;
11 11
import eu.dnetlib.functionality.modular.ui.workflows.objects.NodeWithUserParams;
12
import eu.dnetlib.functionality.modular.ui.workflows.objects.WorkflowSchedulingInfo;
12
import eu.dnetlib.functionality.modular.ui.workflows.objects.WorkflowUpdateInfo;
13 13
import eu.dnetlib.msro.workflows.instances.WorkflowParam;
14 14
import eu.dnetlib.msro.workflows.util.WorkflowsConstants.WorkflowStatus;
15 15
import org.apache.commons.logging.Log;
......
70 70
		return serviceLocator.getService(ISRegistryService.class).updateProfile(wfId, doc.asXML(), doc.valueOf("//RESOURCE_TYPE/@value"));
71 71
	}
72 72

  
73
	public boolean updateSarasvatiWorkflow(final String wfId, final String profile, final WorkflowSchedulingInfo info) throws Exception {
73
	public boolean updateSarasvatiWorkflow(final String wfId, final String profile, final WorkflowUpdateInfo info) throws Exception {
74 74
		final Document doc = new SAXReader().read(new StringReader(profile));
75 75

  
76 76
		((Element) doc.selectSingleNode("//WORKFLOW")).addAttribute("start", info.getMode() != null ? info.getMode().toString() : "");
77 77
		doc.selectSingleNode("//ADMIN_EMAIL").setText(info.getEmail() != null ? info.getEmail() : "");
78
		doc.selectSingleNode("//WORKFLOW_PRIORITY").setText(Integer.toString(info.getPriority()));
78 79

  
79 80
		final Node node = doc.selectSingleNode("//SCHEDULING");
80 81
		((Element) node).addAttribute("enabled", Boolean.toString(info.isScheduled()));
modules/dnet-modular-workflows-ui/branches/workflow_templates/src/main/resources/eu/dnetlib/functionality/modular/workflows/xslt/wf_profile2html.xslt
11 11
        <xsl:variable name="wfName" select="//WORKFLOW_NAME"/>
12 12
        <xsl:variable name="startMode" select="//WORKFLOW/@start"/>
13 13
        <xsl:variable name="status" select="//CONFIGURATION/@status"/>
14
        <xsl:variable name="priority" select="//WORKFLOW_PRIORITY"/>
14 15
        <xsl:variable name="email" select="//ADMIN_EMAIL"/>
15 16
        <xsl:variable name="scheduled" select="//SCHEDULING/@enabled"/>
16 17
        <xsl:variable name="cron" select="//SCHEDULING/CRON"/>
......
29 30
                <div id="collapseWfInfo" class="panel-collapse collapse in">
30 31
                    <div class="panel-body">
31 32
                        <form class="form-horizontal">
33
                            <wf-form-row-link name="Profile ID" value="{$id}" url="isManager.do#/profile/{$id}"/>
32 34
                            <wf-form-row-static name="Workflow name" value="{$wfName}"/>
33 35
                            <wf-form-row-static name="Workflow family" value="{//WORKFLOW_FAMILY}"/>
34
                            <wf-form-row-static name="Workflow priority" value="{//WORKFLOW_PRIORITY}"/>
35
                            <wf-form-row-link name="Profile ID" value="{$id}" url="isManager.do#/profile/{$id}"/>
36
                            <wf-form-row-static name="Workflow family" value="{//WORKFLOW_FAMILY}"/>
36

  
37 37
                            <xsl:choose>
38 38
                                <xsl:when test="//STATUS/LAST_EXECUTION_DATE">
39 39
                                    <wf-form-row-static name="Last execution date" value="{//STATUS/LAST_EXECUTION_DATE}"/>
......
152 152
            <div class="panel panel-default">
153 153
                <div class="panel-heading" id="headingOne">
154 154
                    <h4 class="panel-title">
155
                        <a role="button" data-toggle="collapse" href="javascript:void(0)" data-target="#collapseWfScheduling">
156
                            Scheduling
155
                        <a role="button" data-toggle="collapse" href="javascript:void(0)" data-target="#collapseWfUpdate">
156
                            Notification and scheduling
157 157
                        </a>
158 158
                    </h4>
159 159
                </div>
160
                <div id="collapseWfScheduling" class="panel-collapse collapse out">
160
                <div id="collapseWfUpdate" class="panel-collapse collapse out">
161 161
                    <div class="panel-body">
162
                        <wf-form-scheduling wf-id="{$id}" mode="{$startMode}"
163
                                            email="{$email}"
164
                                            scheduled="{$scheduled}"
165
                                            cron="{$cron}"
166
                                            interval="{$interval}"/>
162
                        <wf-form-update wf-id="{$id}" mode="{$startMode}"
163
                                        priority="{$priority}"
164
                                        email="{$email}"
165
                                        scheduled="{$scheduled}"
166
                                        cron="{$cron}"
167
                                        interval="{$interval}"/>
167 168
                    </div>
168 169
                </div>
169 170
            </div>
modules/dnet-modular-workflows-ui/branches/workflow_templates/src/main/resources/eu/dnetlib/web/resources/html/wf/wf-form-update.html
1
<form class="form-horizontal">
2
	<div class="form-group">
3
		<label class="col-sm-3 control-label">Launch mode</label>
4

  
5
		<div class="col-sm-9">
6
			<label class="radio-inline text-primary">
7
				<input type="radio" name="radioLaunchMode" ng-model="wf.mode" value="auto"/>
8
				auto
9
			</label>
10
			<label class="radio-inline text-warning">
11
				<input type="radio" name="radioLaunchMode" ng-model="wf.mode" value="manual"/>
12
				manual
13
			</label>
14
			<label class="radio-inline text-danger">
15
				<input type="radio" name="radioLaunchMode" ng-model="wf.mode" value="disabled"/>
16
				disabled
17
			</label>
18
		</div>
19
	</div>
20
	<div class="form-group">
21
		<label class="col-sm-3 control-label">Email notification</label>
22

  
23
		<div class="col-sm-9">
24
			<input type="text" class="form-control" ng-model="wf.email" placeholder="emails..."/>
25
		</div>
26
	</div>
27
	<div class="form-group">
28
		<label class="col-sm-3 control-label">Priority (0-100)</label>
29

  
30
		<div class="col-sm-2 col-lg-1">
31
			<input type="text" class="form-control" ng-model="wf.priority" placeholder="priority..."/>
32
		</div>
33
	</div>
34
	<hr/>
35
	<div class="form-group">
36
		<label class="col-sm-3 control-label">Enable scheduling</label>
37

  
38
		<div class="col-sm-9">
39
			<input type="checkbox" ng-model="wf.scheduled"/>
40
		</div>
41
	</div>
42
	<div class="form-group">
43
		<label class="col-sm-3 control-label">Cron expression</label>
44

  
45
		<div class="col-sm-4">
46
			<input type="text" class="form-control" ng-model="wf.cron" placeholder="cron expression..." ng-disabled="!wf.scheduled"/>
47
		</div>
48
	</div>
49
	<div class="form-group">
50
		<label class="col-sm-3 control-label">Minimum interval (in minutes)</label>
51

  
52
		<div class="col-sm-4">
53
			<input type="text" class="form-control" ng-model="wf.interval" placeholder="interval..." ng-disabled="!wf.scheduled"/>
54
		</div>
55
	</div>
56
	<div class="form-group">
57
		<div class="col-sm-offset-3 col-sm-9">
58
			<button class="btn btn-primary" ng-click="saveScheduling()">
59
				<span style="margin-right: 8px" class="glyphicon glyphicon-ok"></span>Update
60
			</button>
61
			<button class="btn btn-default" style="margin-left:5px;" ng-click="reset()">
62
				<span style="margin-right:8px" class="glyphicon glyphicon-remove"></span>
63
				Reset
64
			</button>
65
		</div>
66
	</div>
67
</form>
modules/dnet-modular-workflows-ui/branches/workflow_templates/src/main/resources/eu/dnetlib/web/resources/js/dnet_workflows.js
157 157
	}
158 158
});
159 159

  
160
module.directive('wfFormScheduling', function ($http) {
160
module.directive('wfFormUpdate', function ($http) {
161 161
	return {
162 162
		restrict: 'E',
163
		templateUrl: '../resources/html/wf/wf-form-scheduling.html',
163
		templateUrl: '../resources/html/wf/wf-form-update.html',
164 164
		scope: {
165 165
			'wfId': '@',
166 166
			'mode': '@',
167
			'priority': '@',
167 168
			'email': '@',
168 169
			'scheduled': '@',
169 170
			'cron': '@',
......
175 176
			scope.originalWf = {
176 177
				'wfId': scope.wfId,
177 178
				'mode': scope.mode,
179
				'priority': scope.priority,
178 180
				'email': scope.email,
179 181
				'scheduled': (scope.scheduled == 'true'),
180 182
				'cron': scope.cron,
......
188 190
			scope.saveScheduling = function () {
189 191
				showSpinner();
190 192
				$http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8";
191
				$http.post('schedule_workflow.do', $.param({
193
				$http.post('update_workflow.do', $.param({
192 194
					'json': JSON.stringify(scope.wf)
193 195
				})).success(function (data) {
194 196
					scope.originalWf = angular.copy(scope.wf);

Also available in: Unified diff