Skip to content

Commit b05ff42

Browse files
author
youseries
committed
为流程模版添加业务分类属性,在用户实现了AdditionalInfoProvider接口,同时配置到Spring上下文后这个属性就可以在设计器中配置
1 parent df3676a commit b05ff42

File tree

12 files changed

+92
-10
lines changed

12 files changed

+92
-10
lines changed

uflo-console-js/src/designer/UFLODesigner.js

+24-6
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ export default class UfloDesigner extends FlowDesigner{
3030
if(this.categoryId){
3131
xml+=` category-id="${this.categoryId}"`;
3232
}
33+
if(this.category){
34+
xml+=` category="${this.category}"`;
35+
}
3336
if(this.url){
3437
xml+=` start-process-url="${this.url}"`;
3538
}
@@ -55,6 +58,7 @@ export default class UfloDesigner extends FlowDesigner{
5558
this.url=json.startProcessUrl;
5659
this.eventHandlerBean=json.eventHandlerBean;
5760
this.categoryId=json.categoryId;
61+
this.category=json.category;
5862
this.effectDate=json.effectDate;
5963
this.description=json.description;
6064
for(let nodeJson of json.nodes){
@@ -157,15 +161,29 @@ export default class UfloDesigner extends FlowDesigner{
157161
});
158162
});
159163

160-
const categoryGroup=$(`<div class="form-group"><label>分类ID:</label></div>`);
161-
g.append(categoryGroup);
162-
const categoryText=$(`<input type="text" class="form-control uflo-text-editor" style="width: 315px">`);
163-
categoryGroup.append(categoryText);
164-
categoryText.val(target.categoryId);
165-
categoryText.change(function(){
164+
const categoryIdGroup=$(`<div class="form-group"><label>分类ID:</label></div>`);
165+
g.append(categoryIdGroup);
166+
const categoryIdText=$(`<input type="text" class="form-control uflo-text-editor" style="width: 315px">`);
167+
categoryIdGroup.append(categoryIdText);
168+
categoryIdText.val(target.categoryId);
169+
categoryIdText.change(function(){
166170
target.categoryId=$(this).val();
167171
});
168172

173+
if(window._categories.length>0){
174+
const categoryGroup=$(`<div class="form-group"><label>业务分类:</label></div>`);
175+
g.append(categoryGroup);
176+
const categorySelect=$(`<select class="form-control uflo-text-editor" style="width: 300px"></select>`);
177+
for(let category of window._categories){
178+
categorySelect.append(`<option value="${category}">${category}</option>`);
179+
}
180+
categoryGroup.append(categorySelect);
181+
categorySelect.val(target.category);
182+
categorySelect.change(function(){
183+
target.category=$(this).val();
184+
});
185+
}
186+
169187
const effectDateGroup=$(`<div class="form-group"><label>生效日期:</label></div>`);
170188
g.append(effectDateGroup);
171189
const effectDateText=$(`<input type="datetime" placeholder="日期格式为yyyy-MM-dd HH:mm:ss" title="日期格式为yyyy-MM-dd HH:mm:ss" class="form-control uflo-text-editor" style="width: 300px">`);

uflo-console/src/main/java/com/bstek/uflo/console/handler/impl/designer/DesignerServletHandler.java

+29
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import java.io.PrintWriter;
66
import java.io.UnsupportedEncodingException;
77
import java.net.URLDecoder;
8+
import java.util.Collection;
89
import java.util.List;
910

1011
import javax.servlet.ServletException;
@@ -15,12 +16,15 @@
1516
import org.apache.commons.lang.StringUtils;
1617
import org.apache.velocity.Template;
1718
import org.apache.velocity.VelocityContext;
19+
import org.springframework.beans.BeansException;
20+
import org.springframework.context.ApplicationContext;
1821

1922
import com.bstek.uflo.console.handler.impl.RenderPageServletHandler;
2023
import com.bstek.uflo.console.provider.ProcessFile;
2124
import com.bstek.uflo.console.provider.ProcessProvider;
2225
import com.bstek.uflo.console.provider.ProcessProviderUtils;
2326
import com.bstek.uflo.deploy.parse.impl.ProcessParser;
27+
import com.bstek.uflo.env.AdditionalInfoProvider;
2428
import com.bstek.uflo.model.ProcessDefinition;
2529
import com.bstek.uflo.service.ProcessService;
2630

@@ -30,6 +34,7 @@
3034
*/
3135
public class DesignerServletHandler extends RenderPageServletHandler {
3236
private ProcessService processService;
37+
private AdditionalInfoProvider additionalInfoProvider;
3338
@Override
3439
public void execute(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
3540
String method=retriveMethod(req);
@@ -38,6 +43,21 @@ public void execute(HttpServletRequest req, HttpServletResponse resp) throws Ser
3843
}else{
3944
VelocityContext context = new VelocityContext();
4045
context.put("contextPath", req.getContextPath());
46+
if(additionalInfoProvider!=null) {
47+
List<String> categories=additionalInfoProvider.categories();
48+
if(categories!=null && categories.size()>0) {
49+
StringBuilder sb=new StringBuilder();
50+
for(String category:categories) {
51+
if(sb.length()>0) {
52+
sb.append(",");
53+
}
54+
sb.append("\""+category+"\"");
55+
}
56+
context.put("categories", sb.toString());
57+
}
58+
}else {
59+
context.put("categories", "");
60+
}
4161
resp.setContentType("text/html");
4262
resp.setCharacterEncoding("utf-8");
4363
Template template=ve.getTemplate("uflo-html/designer.html","utf-8");
@@ -118,6 +138,15 @@ private String decode(String str){
118138
}
119139
return str;
120140
}
141+
142+
@Override
143+
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
144+
super.setApplicationContext(applicationContext);
145+
Collection<AdditionalInfoProvider> coll=applicationContext.getBeansOfType(AdditionalInfoProvider.class).values();
146+
if(coll.size()>0) {
147+
additionalInfoProvider=coll.iterator().next();
148+
}
149+
}
121150

122151
@Override
123152
public String url() {

uflo-console/src/main/resources/uflo-asserts/js/calendar.bundle.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

uflo-console/src/main/resources/uflo-asserts/js/central.bundle.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

uflo-console/src/main/resources/uflo-asserts/js/designer.bundle.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

uflo-console/src/main/resources/uflo-asserts/js/todo.bundle.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

uflo-console/src/main/resources/uflo-html/designer.html

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<script type="text/javascript">
1313
window._server="${contextPath}/uflo";
1414
window._contextPath="${contextPath}";
15+
window._categories=[${categories}];
1516
</script>
1617
<script type="text/javascript" src="${contextPath}/uflo/res/uflo-asserts/js/designer.bundle.js"></script>
1718
</body>

uflo-core/src/main/java/com/bstek/uflo/deploy/parse/impl/ProcessParser.java

+1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ public Object parse(Element element,long processId,boolean parseChildren) {
7171
process.setStartProcessUrl(unescape(element.attributeValue("start-process-url")));
7272
process.setKey(unescape(element.attributeValue("key")));
7373
process.setCategoryId(unescape(element.attributeValue("category-id")));
74+
process.setCategory(unescape(element.attributeValue("category")));
7475
String effectDateStr=unescape(element.attributeValue("effect-date"));
7576
if(StringUtils.isNotEmpty(effectDateStr)){
7677
SimpleDateFormat sd=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package com.bstek.uflo.env;
2+
3+
import java.util.List;
4+
5+
/**
6+
* @author Jacky.gao
7+
* @since 2018年7月31日
8+
*/
9+
public interface AdditionalInfoProvider {
10+
List<String> categories();
11+
}

uflo-core/src/main/java/com/bstek/uflo/model/ProcessDefinition.java

+11
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ public class ProcessDefinition implements java.io.Serializable{
6363
@Column(name="CATEGORY_ID_",length=60)
6464
private String categoryId;
6565

66+
@Column(name="CATEGORY_",length=60)
67+
private String category;
68+
6669
@Column(name="DESCRIPTION_")
6770
private String description;
6871

@@ -162,6 +165,14 @@ public void setCategoryId(String categoryId) {
162165
this.categoryId = categoryId;
163166
}
164167

168+
public String getCategory() {
169+
return category;
170+
}
171+
172+
public void setCategory(String category) {
173+
this.category = category;
174+
}
175+
165176
public String getDescription() {
166177
return description;
167178
}

uflo-core/src/main/java/com/bstek/uflo/query/ProcessQuery.java

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
public interface ProcessQuery extends Query<List<ProcessDefinition>>{
2828
ProcessQuery id(long id);
2929
ProcessQuery categoryId(String id);
30+
ProcessQuery category(String category);
3031
ProcessQuery createDateLessThen(Date date);
3132
ProcessQuery createDateLessThenOrEquals(Date date);
3233
ProcessQuery createDateGreaterThen(Date date);

uflo-core/src/main/java/com/bstek/uflo/query/impl/ProcessQueryImpl.java

+10
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public class ProcessQueryImpl implements ProcessQuery,QueryJob{
4242
private String name;
4343
private String key;
4444
private String categoryId;
45+
private String category;
4546
private String subject;
4647
private int version;
4748
private int firstResult;
@@ -109,6 +110,9 @@ private void buildCriteria(Criteria criteria,boolean queryCount){
109110
criteria.add(Restrictions.eq("categoryId", categoryId));
110111
}
111112
}
113+
if(StringUtils.isNotBlank(category)) {
114+
criteria.add(Restrictions.eq("category", category));
115+
}
112116
if(version>0){
113117
criteria.add(Restrictions.eq("version", Integer.valueOf(version)));
114118
}
@@ -159,6 +163,12 @@ public ProcessQuery categoryId(String categoryId) {
159163
return this;
160164
}
161165

166+
@Override
167+
public ProcessQuery category(String category) {
168+
this.category=category;
169+
return this;
170+
}
171+
162172
public ProcessQuery nameLike(String name) {
163173
this.name=name;
164174
return this;

0 commit comments

Comments
 (0)