提交 652ff58a 编写于 作者: O o2sword

流程、内容管理、门户设计搜索1

上级 f21654e2
package com.x.base.core.entity.enums;
import com.x.base.core.entity.JpaObject;
/**
* 平台设计搜索业务类型枚举类
* script(脚本:流程平台脚本、内容管理脚本、门户脚本、服务管理的代理、服务管理的接口)
* form(流程平台的表单、内容管理的表单、门户的页面)
* process(流程平台的流程模板)
*/
public enum DesignerType {
script, form, process;
public static final int length = JpaObject.length_64B;
}
package com.x.base.core.project.jaxrs;
import com.x.base.core.project.annotation.FieldDescribe;
import com.x.base.core.project.gson.GsonPropertyObject;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class WiDesigner extends GsonPropertyObject {
@FieldDescribe("搜索关键字.")
private String keyword;
@FieldDescribe("是否区分大小写.")
private Boolean caseSensitive;
@FieldDescribe("是否全字匹配.")
private Boolean matchWholeWord;
@FieldDescribe("是否正则表达式匹配.")
private Boolean matchRegExp;
@FieldDescribe("模块的应用ID信息.")
private Map<String, List<String>> moduleApps = new HashMap<>();
public String getKeyword() {
return keyword;
}
public void setKeyword(String keyword) {
this.keyword = keyword;
}
public Boolean getCaseSensitive() {
return caseSensitive;
}
public void setCaseSensitive(Boolean caseSensitive) {
this.caseSensitive = caseSensitive;
}
public Boolean getMatchWholeWord() {
return matchWholeWord;
}
public void setMatchWholeWord(Boolean matchWholeWord) {
this.matchWholeWord = matchWholeWord;
}
public Boolean getMatchRegExp() {
return matchRegExp;
}
public void setMatchRegExp(Boolean matchRegExp) {
this.matchRegExp = matchRegExp;
}
public Map<String, List<String>> getModuleApps() {
return moduleApps;
}
public void setModuleApps(Map<String, List<String>> moduleApps) {
this.moduleApps = moduleApps;
}
}
package com.x.base.core.project.jaxrs;
import com.x.base.core.project.annotation.FieldDescribe;
import com.x.base.core.project.gson.GsonPropertyObject;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class WrapDesigner extends GsonPropertyObject {
@FieldDescribe("应用Id.")
private String appId;
@FieldDescribe("应用名称.")
private String appName;
@FieldDescribe("设计Id.")
private String designerId;
@FieldDescribe("设计名称.")
private String designerName;
@FieldDescribe("设计类型.")
private String designerType;
@FieldDescribe("匹配信息.")
private List<DesignerPattern> patternList = new ArrayList<>();
public String getAppId() {
return appId;
}
public void setAppId(String appId) {
this.appId = appId;
}
public String getAppName() {
return appName;
}
public void setAppName(String appName) {
this.appName = appName;
}
public String getDesignerId() {
return designerId;
}
public void setDesignerId(String designerId) {
this.designerId = designerId;
}
public String getDesignerName() {
return designerName;
}
public void setDesignerName(String designerName) {
this.designerName = designerName;
}
public String getDesignerType() {
return designerType;
}
public void setDesignerType(String designerType) {
this.designerType = designerType;
}
public List<DesignerPattern> getPatternList() {
return patternList;
}
public void setPatternList(List<DesignerPattern> patternList) {
this.patternList = patternList;
}
public void setPatternList(Map<String, String> map) {
if(map!=null && !map.isEmpty()){
List<DesignerPattern> patternList = new ArrayList<>();
for (String key : map.keySet()){
DesignerPattern pattern = new DesignerPattern();
pattern.setProperty(key);
pattern.setPropertyValue(map.get(key));
patternList.add(pattern);
}
this.patternList = patternList;
}
this.patternList = patternList;
}
public DesignerPattern getPatternInstant(){
DesignerPattern pattern = new DesignerPattern();
return pattern;
}
public void clearPatternValue(){
for (DesignerPattern pattern : this.patternList){
pattern.propertyValue = null;
}
}
class DesignerPattern extends GsonPropertyObject {
@FieldDescribe("元素类型(activity | process).")
private String elementType;
@FieldDescribe("元素ID.")
private String elementId;
@FieldDescribe("元素名称.")
private String elementName;
@FieldDescribe("设计属性.")
private String property;
@FieldDescribe("设计属性.")
private String propertyValue;
@FieldDescribe("匹配行")
private List<Integer> lines;
public String getElementType() {
return elementType;
}
public void setElementType(String elementType) {
this.elementType = elementType;
}
public String getElementId() {
return elementId;
}
public void setElementId(String elementId) {
this.elementId = elementId;
}
public String getElementName() {
return elementName;
}
public void setElementName(String elementName) {
this.elementName = elementName;
}
public String getProperty() {
return property;
}
public void setProperty(String property) {
this.property = property;
}
public List<Integer> getLines() {
return lines;
}
public void setLines(List<Integer> lines) {
this.lines = lines;
}
public String getPropertyValue() {
return propertyValue;
}
public void setPropertyValue(String propertyValue) {
this.propertyValue = propertyValue;
}
}
}
......@@ -2,11 +2,10 @@ package com.x.base.core.project.tools;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.*;
import com.x.base.core.project.jaxrs.WiDesigner;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.reflect.FieldUtils;
public class FieldTools {
......@@ -18,4 +17,19 @@ public class FieldTools {
}
return new ArrayList<Field>(set);
}
public static <T> Map<String, String> fieldMatchKeyword(final Class<T> origClass, T t, String keyword, Boolean caseSensitive, Boolean matchWholeWord, Boolean matchRegExp) throws Exception{
Map<String, String> map = new HashMap<>();
if(origClass!=null && StringUtils.isNotBlank(keyword)) {
for (Field field : FieldUtils.getAllFields(origClass)) {
if (field.getType() == String.class) {
String content = (String) field.get(t);
if (StringTools.matchKeyword(keyword, content, caseSensitive, matchWholeWord, matchRegExp)) {
map.put(field.getName(), content);
}
}
}
}
return map;
}
}
......@@ -2,6 +2,7 @@ package com.x.processplatform.assemble.designer.element.factory;
import java.util.Comparator;
import java.util.List;
import java.util.concurrent.locks.Condition;
import java.util.stream.Collectors;
import javax.persistence.EntityManager;
......@@ -10,6 +11,7 @@ import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import com.x.base.core.project.tools.ListTools;
import com.x.processplatform.assemble.designer.AbstractFactory;
import com.x.processplatform.assemble.designer.Business;
import com.x.processplatform.core.entity.element.Form;
......@@ -31,6 +33,19 @@ public class FormFactory extends AbstractFactory {
return em.createQuery(cq).getResultList();
}
public List<String> listWithApplications(List<String> applications) throws Exception {
EntityManager em = this.entityManagerContainer().get(Form.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<String> cq = cb.createQuery(String.class);
Root<Form> root = cq.from(Form.class);
Predicate p = cb.conjunction();
if(ListTools.isNotEmpty(applications)) {
p = cb.isMember(root.get(Form_.application), cb.literal(applications));
}
cq.select(root.get(Form_.id)).where(p);
return em.createQuery(cq).getResultList();
}
public List<Form> listWithApplicationObject(String application) throws Exception {
EntityManager em = this.entityManagerContainer().get(Form.class);
CriteriaBuilder cb = em.getCriteriaBuilder();
......@@ -47,4 +62,4 @@ public class FormFactory extends AbstractFactory {
return list;
}
}
\ No newline at end of file
}
......@@ -8,6 +8,7 @@ import com.x.base.core.project.jaxrs.AbstractActionApplication;
import com.x.processplatform.assemble.designer.jaxrs.application.ApplicationAction;
import com.x.processplatform.assemble.designer.jaxrs.applicationcategory.ApplicationCategoryAction;
import com.x.processplatform.assemble.designer.jaxrs.applicationdict.ApplicationDictAction;
import com.x.processplatform.assemble.designer.jaxrs.designer.DesignerAction;
import com.x.processplatform.assemble.designer.jaxrs.elementtool.ElementToolAction;
import com.x.processplatform.assemble.designer.jaxrs.file.FileAction;
import com.x.processplatform.assemble.designer.jaxrs.form.FormAction;
......@@ -45,7 +46,8 @@ public class ActionApplication extends AbstractActionApplication {
classes.add(MappingAction.class);
classes.add(ElementToolAction.class);
classes.add(WorkCompletedAction.class);
classes.add(DesignerAction.class);
return classes;
}
}
\ No newline at end of file
}
package com.x.processplatform.assemble.designer.jaxrs;
import com.x.base.core.project.jaxrs.ManagerUserJaxrsFilter;
import javax.servlet.annotation.WebFilter;
@WebFilter(urlPatterns = "/jaxrs/designer/*", asyncSupported = true)
public class DesignerJaxrsFilter extends ManagerUserJaxrsFilter {
}
package com.x.processplatform.assemble.designer.jaxrs.designer;
import com.google.gson.JsonElement;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.JpaObject;
import com.x.base.core.entity.enums.DesignerType;
import com.x.base.core.project.bean.WrapCopier;
import com.x.base.core.project.bean.WrapCopierFactory;
import com.x.base.core.project.exception.ExceptionAccessDenied;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WiDesigner;
import com.x.base.core.project.jaxrs.WrapDesigner;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.base.core.project.tools.FieldTools;
import com.x.base.core.project.tools.ListTools;
import com.x.processplatform.assemble.designer.Business;
import com.x.processplatform.core.entity.element.Application;
import com.x.processplatform.core.entity.element.Form;
import com.x.processplatform.core.entity.element.Script;
import com.x.processplatform.core.entity.element.wrap.WrapProcess;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
class ActionSearch extends BaseAction {
private static Logger logger = LoggerFactory.getLogger(ActionSearch.class);
ActionResult<List<Wo>> execute(EffectivePerson effectivePerson, JsonElement jsonElement) throws Exception {
if(!effectivePerson.isManager()){
throw new ExceptionAccessDenied(effectivePerson);
}
Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
ActionResult<List<Wo>> result = new ActionResult<>();
final List<Wo> resWos = new ArrayList<>();
result.setData(resWos);
result.setCount((long)resWos.size());
return result;
}
private CompletableFuture<List<Wo>> searchScript(final Wi wi, final List<String> appIdList) {
CompletableFuture<List<Wo>> cf = CompletableFuture.supplyAsync(() -> {
List<Wo> resWos = new ArrayList<>();
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
List<WoScript> woScripts;
if (ListTools.isEmpty(appIdList)) {
woScripts = emc.fetchAll(Script.class, WoScript.copier);
} else {
woScripts = emc.fetchIn(Script.class, WoScript.copier, Script.application_FIELDNAME, appIdList);
}
for (WoScript woScript : woScripts) {
Map<String, String> map = FieldTools.fieldMatchKeyword(WoScript.class, woScript, wi.getKeyword(),
wi.getCaseSensitive(), wi.getMatchWholeWord(), wi.getMatchRegExp());
if (!map.isEmpty()) {
Wo wo = new Wo();
Application app = emc.find(woScript.getApplication(), Application.class);
if (app != null) {
wo.setAppId(app.getId());
wo.setAppName(app.getName());
}
wo.setDesignerId(woScript.getId());
wo.setDesignerName(woScript.getName());
wo.setDesignerType(DesignerType.script.toString());
wo.setPatternList(map);
resWos.add(wo);
}
}
woScripts.clear();
}catch (Exception e){
logger.error(e);
}
return resWos;
});
return cf;
}
private CompletableFuture<List<Wo>> searchForm(final Wi wi, final List<String> appIdList) {
CompletableFuture<List<Wo>> cf = CompletableFuture.supplyAsync(() -> {
List<Wo> resWos = new ArrayList<>();
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
List<String> formIds = business.form().listWithApplications(appIdList);
for (List<String> partFormIds : ListTools.batch(formIds, 100)) {
List<WoForm> woForms = emc.fetchIn(Form.class, WoForm.copier, Form.id_FIELDNAME, partFormIds);
for (WoForm woForm : woForms) {
Map<String, String> map = FieldTools.fieldMatchKeyword(WoForm.class, woForm, wi.getKeyword(),
wi.getCaseSensitive(), wi.getMatchWholeWord(), wi.getMatchRegExp());
if (!map.isEmpty()) {
Wo wo = new Wo();
Application app = emc.find(woForm.getApplication(), Application.class);
if (app != null) {
wo.setAppId(app.getId());
wo.setAppName(app.getName());
}
wo.setDesignerId(woForm.getId());
wo.setDesignerName(woForm.getName());
wo.setDesignerType(DesignerType.script.toString());
wo.setPatternList(map);
resWos.add(wo);
}
}
woForms.clear();
}
}catch (Exception e){
logger.error(e);
}
return resWos;
});
return cf;
}
public static class Wi extends WiDesigner {
}
public static class Wo extends WrapDesigner{
}
public static class WoScript extends Script {
static WrapCopier<Script, WoScript> copier = WrapCopierFactory.wo(Script.class, WoScript.class,
JpaObject.singularAttributeField(Script.class, true, false),null);
}
public static class WoForm extends Form {
static WrapCopier<Form, WoForm> copier = WrapCopierFactory.wo(Form.class, WoForm.class,
JpaObject.singularAttributeField(Form.class, true, false),null);
}
public static class WoProcess extends WrapProcess {
private static final long serialVersionUID = -8507786999314667403L;
}
}
package com.x.processplatform.assemble.designer.jaxrs.designer;
import com.x.base.core.project.jaxrs.StandardJaxrsAction;
abstract class BaseAction extends StandardJaxrsAction {
}
package com.x.processplatform.assemble.designer.jaxrs.designer;
import com.google.gson.JsonElement;
import com.x.base.core.project.annotation.JaxrsDescribe;
import com.x.base.core.project.annotation.JaxrsMethodDescribe;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.http.HttpMediaType;
import com.x.base.core.project.jaxrs.ResponseFactory;
import com.x.base.core.project.jaxrs.StandardJaxrsAction;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.*;
import javax.ws.rs.container.AsyncResponse;
import javax.ws.rs.container.Suspended;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import java.util.List;
@Path("designer")
@JaxrsDescribe("设计")
public class DesignerAction extends StandardJaxrsAction {
private static Logger logger = LoggerFactory.getLogger(DesignerAction.class);
@JaxrsMethodDescribe(value = "根据关键字搜索设计对象.", action = ActionSearch.class)
@POST
@Path("search")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void managerList(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
JsonElement jsonElement) {
ActionResult<List<ActionSearch.Wo>> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionSearch().execute(effectivePerson, jsonElement);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
}
......@@ -146,7 +146,7 @@ class ActionSearch extends BaseAction {
private Boolean matchWholeWord;
@FieldDescribe("是否正则表达式匹配.")
private Boolean matchRegExp;
@FieldDescribe("限制查询的模块列表.")
@FieldDescribe("限制查询的模块列表(模块:processPlatform|portal|cms|service).")
@FieldTypeDescribe(fieldType = "class", fieldTypeName = "Module", fieldValue = "{\"moduleType\": \"cms\", \"flagList\": []}")
private List<Module> moduleList;
......
......@@ -3,10 +3,13 @@ package com.x.query.service.processing.jaxrs.design;
import com.x.base.core.entity.JpaObject;
/**
*
* processPlatform(流程管理平台)
* portal(门户管理平台)
* cms(内容管理平台)
* service(服务管理平台)
*/
public enum ModuleType {
processPlatform, portal, cms;
processPlatform, portal, cms, service;
public static final int length = JpaObject.length_64B;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册