Jelajahi Sumber

Merge branch 'feature/设计搜索' into 'wrdp'

[数据中心]全局设计搜索之script脚本搜索

See merge request o2oa/o2oa!2532
o2null 5 tahun lalu
induk
melakukan
571b251809
16 mengubah file dengan 1081 tambahan dan 4 penghapusan
  1. 38 1
      o2server/x_base_core_project/src/main/java/com/x/base/core/project/tools/StringTools.java
  2. 132 0
      o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/script/ActionManagerList.java
  3. 19 1
      o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/script/ScriptAction.java
  4. 144 0
      o2server/x_portal_assemble_designer/src/main/java/com/x/portal/assemble/designer/jaxrs/script/ActionManagerList.java
  5. 19 1
      o2server/x_portal_assemble_designer/src/main/java/com/x/portal/assemble/designer/jaxrs/script/ScriptAction.java
  6. 144 0
      o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/script/ActionManagerList.java
  7. 19 1
      o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/script/ScriptAction.java
  8. 4 0
      o2server/x_query_service_processing/pom.xml
  9. 2 0
      o2server/x_query_service_processing/src/main/java/com/x/query/service/processing/jaxrs/ActionApplication.java
  10. 10 0
      o2server/x_query_service_processing/src/main/java/com/x/query/service/processing/jaxrs/DesignJaxrsFilter.java
  11. 311 0
      o2server/x_query_service_processing/src/main/java/com/x/query/service/processing/jaxrs/design/ActionSearch.java
  12. 59 0
      o2server/x_query_service_processing/src/main/java/com/x/query/service/processing/jaxrs/design/BaseAction.java
  13. 45 0
      o2server/x_query_service_processing/src/main/java/com/x/query/service/processing/jaxrs/design/DesignAction.java
  14. 14 0
      o2server/x_query_service_processing/src/main/java/com/x/query/service/processing/jaxrs/design/ExceptionFieldEmpty.java
  15. 12 0
      o2server/x_query_service_processing/src/main/java/com/x/query/service/processing/jaxrs/design/ModuleType.java
  16. 109 0
      o2server/x_query_service_processing/src/main/java/com/x/query/service/processing/jaxrs/design/WrapScript.java

+ 38 - 1
o2server/x_base_core_project/src/main/java/com/x/base/core/project/tools/StringTools.java

@@ -27,6 +27,7 @@ import org.apache.commons.collections4.ListUtils;
 import org.apache.commons.collections4.set.ListOrderedSet;
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang3.ArrayUtils;
+import org.apache.commons.lang3.BooleanUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.reflect.FieldUtils;
 import org.slf4j.helpers.MessageFormatter;
@@ -548,4 +549,40 @@ public class StringTools {
 		}
 		return sb.toString();
 	}
-}
+
+	/**
+	 * 文本搜索
+	 * @param keyword 搜索关键字
+	 * @param content 文本
+	 * @param caseSensitive 大小写敏感
+	 * @param matchWholeWord 是否全字匹配
+	 * @param matchRegExp 正则表达式搜索
+	 * @return
+	 */
+	public static boolean matchKeyword(String keyword, String content, Boolean caseSensitive, Boolean matchWholeWord, Boolean matchRegExp){
+		if(StringUtils.isBlank(keyword) || StringUtils.isBlank(content)){
+			return false;
+		}
+		if(BooleanUtils.isTrue(matchRegExp)){
+			Pattern pattern = Pattern.compile(keyword);
+			Matcher matcher = pattern.matcher(content);
+			return matcher.find();
+		}else if(BooleanUtils.isTrue(matchWholeWord)){
+			if(BooleanUtils.isTrue(caseSensitive)) {
+				Pattern pattern = Pattern.compile("\\b(" + keyword + ")\\b");
+				Matcher matcher = pattern.matcher(content);
+				return matcher.find();
+			}else{
+				Pattern pattern = Pattern.compile("\\b(" + keyword + ")\\b", Pattern.CASE_INSENSITIVE);
+				Matcher matcher = pattern.matcher(content);
+				return matcher.find();
+			}
+		}else{
+			if(BooleanUtils.isTrue(caseSensitive)) {
+				return (content.indexOf(keyword) > -1);
+			}else{
+				return (content.toLowerCase().indexOf(keyword.toLowerCase()) > -1);
+			}
+		}
+	}
+}

+ 132 - 0
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/script/ActionManagerList.java

@@ -0,0 +1,132 @@
+package com.x.cms.assemble.control.jaxrs.script;
+
+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.project.annotation.FieldDescribe;
+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.gson.GsonPropertyObject;
+import com.x.base.core.project.http.ActionResult;
+import com.x.base.core.project.http.EffectivePerson;
+import com.x.base.core.project.tools.ListTools;
+import com.x.base.core.project.tools.StringTools;
+import com.x.cms.core.entity.AppInfo;
+import com.x.cms.core.entity.element.Script;
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.ArrayList;
+import java.util.List;
+
+class ActionManagerList extends BaseAction {
+	ActionResult<List<Wo>> execute(EffectivePerson effectivePerson, JsonElement jsonElement) throws Exception {
+		if(!effectivePerson.isManager()){
+			throw new ExceptionAccessDenied(effectivePerson);
+		}
+		Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
+		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+			ActionResult<List<Wo>> result = new ActionResult<>();
+			List<Wo> wos;
+			if(ListTools.isEmpty(wi.getAppIdList())){
+				wos = emc.fetchAll(Script.class,  Wo.copier);
+			}else{
+				wos = emc.fetchIn(Script.class, Wo.copier, Script.appId_FIELDNAME, wi.getAppIdList());
+			}
+			final List<Wo> resWos = new ArrayList<>();
+			wos.stream().forEach(wo -> {
+				try {
+					AppInfo appInfo = emc.find( wo.getAppId(), AppInfo.class );
+					if(appInfo != null){
+						wo.setAppName(appInfo.getAppName());
+					}
+				} catch (Exception e) {
+				}
+				if(StringUtils.isNotBlank(wi.getKeyword())){
+					if(StringTools.matchKeyword(wi.getKeyword(), wo.getText(), wi.getCaseSensitive(), wi.getMatchWholeWord(), wi.getMatchRegExp())){
+						resWos.add(wo);
+					}
+				}else{
+					resWos.add(wo);
+				}
+			});
+			wos.clear();
+			result.setData(resWos);
+			result.setCount((long)resWos.size());
+			return result;
+		}
+	}
+
+	public static class Wi extends GsonPropertyObject{
+		@FieldDescribe("搜索关键字.")
+		private String keyword;
+		@FieldDescribe("是否区分大小写.")
+		private Boolean caseSensitive;
+		@FieldDescribe("是否全字匹配.")
+		private Boolean matchWholeWord;
+		@FieldDescribe("是否正则表达式匹配.")
+		private Boolean matchRegExp;
+		@FieldDescribe("应用ID列表.")
+		private List<String> appIdList = new ArrayList<>();
+
+		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 List<String> getAppIdList() {
+			return appIdList;
+		}
+
+		public void setAppIdList(List<String> appIdList) {
+			this.appIdList = appIdList;
+		}
+	}
+
+	public static class Wo extends Script {
+
+		private static final long serialVersionUID = -8095369685452823624L;
+
+		static WrapCopier<Script, Wo> copier = WrapCopierFactory.wo(Script.class, Wo.class,
+				JpaObject.singularAttributeField(Script.class, true, false),null);
+
+		@FieldDescribe("应用名称.")
+		private String appName;
+
+		public String getAppName() {
+			return appName;
+		}
+
+		public void setAppName(String appName) {
+			this.appName = appName;
+		}
+	}
+}

+ 19 - 1
o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/script/ScriptAction.java

@@ -258,4 +258,22 @@ public class ScriptAction extends StandardJaxrsAction {
 		}
 		asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
 	}
-}
+
+	@JaxrsMethodDescribe(value = "列示Script对象(管理员权限).", action = ActionManagerList.class)
+	@POST
+	@Path("list/manager")
+	@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
+	@Consumes(MediaType.APPLICATION_JSON)
+	public void managerList(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
+							JsonElement jsonElement) {
+		ActionResult<List<ActionManagerList.Wo>> result = new ActionResult<>();
+		EffectivePerson effectivePerson = this.effectivePerson(request);
+		try {
+			result = new ActionManagerList().execute(effectivePerson, jsonElement);
+		} catch (Exception e) {
+			logger.error(e, effectivePerson, request, null);
+			result.error(e);
+		}
+		asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
+	}
+}

+ 144 - 0
o2server/x_portal_assemble_designer/src/main/java/com/x/portal/assemble/designer/jaxrs/script/ActionManagerList.java

@@ -0,0 +1,144 @@
+package com.x.portal.assemble.designer.jaxrs.script;
+
+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.project.annotation.FieldDescribe;
+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.gson.GsonPropertyObject;
+import com.x.base.core.project.http.ActionResult;
+import com.x.base.core.project.http.EffectivePerson;
+import com.x.base.core.project.tools.ListTools;
+import com.x.base.core.project.tools.StringTools;
+import com.x.portal.core.entity.Portal;
+import com.x.portal.core.entity.Script;
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.ArrayList;
+import java.util.List;
+
+class ActionManagerList extends BaseAction {
+	ActionResult<List<Wo>> execute(EffectivePerson effectivePerson, JsonElement jsonElement) throws Exception {
+		if(!effectivePerson.isManager()){
+			throw new ExceptionAccessDenied(effectivePerson);
+		}
+		Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
+		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+			ActionResult<List<Wo>> result = new ActionResult<>();
+			List<Wo> wos;
+			if(ListTools.isEmpty(wi.getAppIdList())){
+				wos = emc.fetchAll(Script.class,  Wo.copier);
+			}else{
+				wos = emc.fetchIn(Script.class, Wo.copier, Script.portal_FIELDNAME, wi.getAppIdList());
+			}
+			final List<Wo> resWos = new ArrayList<>();
+			wos.stream().forEach(wo -> {
+				try {
+					Portal portal = emc.find(wo.getPortal(), Portal.class);
+					if(portal != null){
+						wo.setAppId(portal.getId());
+						wo.setAppName(portal.getName());
+					}
+				} catch (Exception e) {
+				}
+				if(StringUtils.isNotBlank(wi.getKeyword())){
+					if(StringTools.matchKeyword(wi.getKeyword(), wo.getText(), wi.getCaseSensitive(), wi.getMatchWholeWord(), wi.getMatchRegExp())){
+						resWos.add(wo);
+					}
+				}else{
+					resWos.add(wo);
+				}
+			});
+			wos.clear();
+			result.setData(resWos);
+			result.setCount((long)resWos.size());
+			return result;
+		}
+	}
+
+	public static class Wi extends GsonPropertyObject{
+		@FieldDescribe("搜索关键字.")
+		private String keyword;
+		@FieldDescribe("是否区分大小写.")
+		private Boolean caseSensitive;
+		@FieldDescribe("是否全字匹配.")
+		private Boolean matchWholeWord;
+		@FieldDescribe("是否正则表达式匹配.")
+		private Boolean matchRegExp;
+		@FieldDescribe("应用ID列表.")
+		private List<String> appIdList = new ArrayList<>();
+
+		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 List<String> getAppIdList() {
+			return appIdList;
+		}
+
+		public void setAppIdList(List<String> appIdList) {
+			this.appIdList = appIdList;
+		}
+	}
+
+	public static class Wo extends Script {
+
+		private static final long serialVersionUID = -8095369685452823624L;
+
+		static WrapCopier<Script, Wo> copier = WrapCopierFactory.wo(Script.class, Wo.class,
+				JpaObject.singularAttributeField(Script.class, true, false),null);
+
+		@FieldDescribe("应用Id.")
+		private String appId;
+
+		@FieldDescribe("应用名称.")
+		private String appName;
+
+		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;
+		}
+	}
+}

+ 19 - 1
o2server/x_portal_assemble_designer/src/main/java/com/x/portal/assemble/designer/jaxrs/script/ScriptAction.java

@@ -142,4 +142,22 @@ public class ScriptAction extends StandardJaxrsAction {
 		asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
 	}
 
-}
+	@JaxrsMethodDescribe(value = "列示Script对象(管理员权限).", action = ActionManagerList.class)
+	@POST
+	@Path("list/manager")
+	@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
+	@Consumes(MediaType.APPLICATION_JSON)
+	public void managerList(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
+							JsonElement jsonElement) {
+		ActionResult<List<ActionManagerList.Wo>> result = new ActionResult<>();
+		EffectivePerson effectivePerson = this.effectivePerson(request);
+		try {
+			result = new ActionManagerList().execute(effectivePerson, jsonElement);
+		} catch (Exception e) {
+			logger.error(e, effectivePerson, request, null);
+			result.error(e);
+		}
+		asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
+	}
+
+}

+ 144 - 0
o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/script/ActionManagerList.java

@@ -0,0 +1,144 @@
+package com.x.processplatform.assemble.designer.jaxrs.script;
+
+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.project.annotation.FieldDescribe;
+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.gson.GsonPropertyObject;
+import com.x.base.core.project.http.ActionResult;
+import com.x.base.core.project.http.EffectivePerson;
+import com.x.base.core.project.tools.ListTools;
+import com.x.base.core.project.tools.StringTools;
+import com.x.processplatform.core.entity.element.Application;
+import com.x.processplatform.core.entity.element.Script;
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.ArrayList;
+import java.util.List;
+
+class ActionManagerList extends BaseAction {
+	ActionResult<List<Wo>> execute(EffectivePerson effectivePerson, JsonElement jsonElement) throws Exception {
+		if(!effectivePerson.isManager()){
+			throw new ExceptionAccessDenied(effectivePerson);
+		}
+		Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
+		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
+			ActionResult<List<Wo>> result = new ActionResult<>();
+			List<Wo> wos;
+			if(ListTools.isEmpty(wi.getAppIdList())){
+				wos = emc.fetchAll(Script.class,  Wo.copier);
+			}else{
+				wos = emc.fetchIn(Script.class, Wo.copier, Script.application_FIELDNAME, wi.getAppIdList());
+			}
+			final List<Wo> resWos = new ArrayList<>();
+			wos.stream().forEach(wo -> {
+				try {
+					Application app = emc.find(wo.getApplication(), Application.class);
+					if(app != null){
+						wo.setAppId(app.getId());
+						wo.setAppName(app.getName());
+					}
+				} catch (Exception e) {
+				}
+				if(StringUtils.isNotBlank(wi.getKeyword())){
+					if(StringTools.matchKeyword(wi.getKeyword(), wo.getText(), wi.getCaseSensitive(), wi.getMatchWholeWord(), wi.getMatchRegExp())){
+						resWos.add(wo);
+					}
+				}else{
+					resWos.add(wo);
+				}
+			});
+			wos.clear();
+			result.setData(resWos);
+			result.setCount((long)resWos.size());
+			return result;
+		}
+	}
+
+	public static class Wi extends GsonPropertyObject{
+		@FieldDescribe("搜索关键字.")
+		private String keyword;
+		@FieldDescribe("是否区分大小写.")
+		private Boolean caseSensitive;
+		@FieldDescribe("是否全字匹配.")
+		private Boolean matchWholeWord;
+		@FieldDescribe("是否正则表达式匹配.")
+		private Boolean matchRegExp;
+		@FieldDescribe("应用ID列表.")
+		private List<String> appIdList = new ArrayList<>();
+
+		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 List<String> getAppIdList() {
+			return appIdList;
+		}
+
+		public void setAppIdList(List<String> appIdList) {
+			this.appIdList = appIdList;
+		}
+	}
+
+	public static class Wo extends Script {
+
+		private static final long serialVersionUID = -8095369685452823624L;
+
+		static WrapCopier<Script, Wo> copier = WrapCopierFactory.wo(Script.class, Wo.class,
+				JpaObject.singularAttributeField(Script.class, true, false),null);
+
+		@FieldDescribe("应用Id.")
+		private String appId;
+
+		@FieldDescribe("应用名称.")
+		private String appName;
+
+		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;
+		}
+	}
+}

+ 19 - 1
o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/script/ScriptAction.java

@@ -199,4 +199,22 @@ public class ScriptAction extends StandardJaxrsAction {
 		}
 		asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
 	}
-}
+
+	@JaxrsMethodDescribe(value = "列示Script对象(管理员权限).", action = ActionManagerList.class)
+	@POST
+	@Path("list/manager")
+	@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
+	@Consumes(MediaType.APPLICATION_JSON)
+	public void managerList(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
+							JsonElement jsonElement) {
+		ActionResult<List<ActionManagerList.Wo>> result = new ActionResult<>();
+		EffectivePerson effectivePerson = this.effectivePerson(request);
+		try {
+			result = new ActionManagerList().execute(effectivePerson, jsonElement);
+		} catch (Exception e) {
+			logger.error(e, effectivePerson, request, null);
+			result.error(e);
+		}
+		asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
+	}
+}

+ 4 - 0
o2server/x_query_service_processing/pom.xml

@@ -44,6 +44,10 @@
 			<groupId>o2oa</groupId>
 			<artifactId>x_cms_core_express</artifactId>
 		</dependency>
+		<dependency>
+			<groupId>o2oa</groupId>
+			<artifactId>x_portal_core_entity</artifactId>
+		</dependency>
 	</dependencies>
 	<build>
 		<plugins>

+ 2 - 0
o2server/x_query_service_processing/src/main/java/com/x/query/service/processing/jaxrs/ActionApplication.java

@@ -5,6 +5,7 @@ import java.util.Set;
 import javax.ws.rs.ApplicationPath;
 
 import com.x.base.core.project.jaxrs.AbstractActionApplication;
+import com.x.query.service.processing.jaxrs.design.DesignAction;
 import com.x.query.service.processing.jaxrs.neural.NeuralAction;
 import com.x.query.service.processing.jaxrs.segment.SegmentAction;
 import com.x.query.service.processing.jaxrs.test.TestAction;
@@ -16,6 +17,7 @@ public class ActionApplication extends AbstractActionApplication {
 		classes.add(TestAction.class);
 		classes.add(NeuralAction.class);
 		classes.add(SegmentAction.class);
+		classes.add(DesignAction.class);
 		return classes;
 	}
 

+ 10 - 0
o2server/x_query_service_processing/src/main/java/com/x/query/service/processing/jaxrs/DesignJaxrsFilter.java

@@ -0,0 +1,10 @@
+package com.x.query.service.processing.jaxrs;
+
+import com.x.base.core.project.jaxrs.CipherManagerUserJaxrsFilter;
+
+import javax.servlet.annotation.WebFilter;
+
+@WebFilter(urlPatterns = "/jaxrs/design/*", asyncSupported = true)
+public class DesignJaxrsFilter extends CipherManagerUserJaxrsFilter {
+
+}

+ 311 - 0
o2server/x_query_service_processing/src/main/java/com/x/query/service/processing/jaxrs/design/ActionSearch.java

@@ -0,0 +1,311 @@
+package com.x.query.service.processing.jaxrs.design;
+
+import com.google.gson.JsonElement;
+import com.x.base.core.project.Applications;
+import com.x.base.core.project.annotation.FieldDescribe;
+import com.x.base.core.project.annotation.FieldTypeDescribe;
+import com.x.base.core.project.gson.GsonPropertyObject;
+import com.x.base.core.project.http.ActionResult;
+import com.x.base.core.project.http.EffectivePerson;
+import com.x.base.core.project.logger.Logger;
+import com.x.base.core.project.logger.LoggerFactory;
+import com.x.base.core.project.tools.ListTools;
+import com.x.base.core.project.tools.SortTools;
+import com.x.base.core.project.tools.StringTools;
+import com.x.base.core.project.x_cms_assemble_control;
+import com.x.base.core.project.x_portal_assemble_designer;
+import com.x.base.core.project.x_processplatform_assemble_designer;
+import com.x.query.service.processing.ThisApplication;
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.*;
+import java.util.concurrent.CompletableFuture;
+
+class ActionSearch extends BaseAction {
+
+	private static Logger logger = LoggerFactory.getLogger(ActionSearch.class);
+
+	ActionResult<Wo> execute(EffectivePerson effectivePerson, JsonElement jsonElement)
+			throws Exception {
+		ActionResult<Wo> result = new ActionResult<>();
+		Wi wi = this.convertToWrapIn(jsonElement, Wi.class);
+		Wo wo = new Wo();
+		wo.setType(wi.getType());
+		if(StringUtils.isBlank(wi.getKeyword())){
+			throw new ExceptionFieldEmpty("keyword");
+		}
+		if(StringUtils.isBlank(wi.getType())){
+			throw new ExceptionFieldEmpty("type");
+		}
+		logger.print("{}搜索全局设计:{},关键字:{}", effectivePerson.getDistinguishedName(), wi.getType(), wi.getKeyword());
+		switch (wi.getType()) {
+			case "script":
+				wo.setScriptWrapList(searchScript(wi));
+				break;
+			default:
+				throw new ExceptionFieldEmpty("type");
+		}
+		result.setData(wo);
+		return result;
+	}
+
+	private List<ScriptWo> searchScript(final Wi wi) throws Exception{
+		final Map<String, List<String>> moduleMap = new HashMap<>();
+		if(!ListTools.isEmpty(wi.getModuleList())){
+			for (Module module: wi.getModuleList()){
+				if(module.getModuleType().equalsIgnoreCase(ModuleType.cms.toString())){
+					moduleMap.put(ModuleType.cms.toString(), module.getFlagList());
+				}
+				if(module.getModuleType().equalsIgnoreCase(ModuleType.portal.toString())){
+					moduleMap.put(ModuleType.portal.toString(), module.getFlagList());
+				}
+				if(module.getModuleType().equalsIgnoreCase(ModuleType.processPlatform.toString())){
+					moduleMap.put(ModuleType.processPlatform.toString(), module.getFlagList());
+				}
+			}
+		}else{
+			List<String> list = new ArrayList<>();
+			moduleMap.put(ModuleType.cms.toString(), list);
+			moduleMap.put(ModuleType.portal.toString(), list);
+			moduleMap.put(ModuleType.processPlatform.toString(), list);
+		}
+
+		CompletableFuture<List<ScriptWo>> processPlatformCf = scriptSearchAsync(wi, moduleMap, ModuleType.processPlatform.toString(), x_processplatform_assemble_designer.class);
+		CompletableFuture<List<ScriptWo>> portalCf = scriptSearchAsync(wi, moduleMap, ModuleType.portal.toString(), x_portal_assemble_designer.class);
+		CompletableFuture<List<ScriptWo>> cmsCf = scriptSearchAsync(wi, moduleMap, ModuleType.cms.toString(), x_cms_assemble_control.class);
+
+		List<ScriptWo> scriptWoList = new ArrayList<>();
+		scriptWoList.addAll(processPlatformCf.get());
+		scriptWoList.addAll(portalCf.get());
+		scriptWoList.addAll(cmsCf.get());
+
+		return scriptWoList;
+	}
+
+	private CompletableFuture<List<ScriptWo>> scriptSearchAsync(final Wi wi, final Map<String, List<String>> moduleMap, final String moduleType, final Class<?> applicationClass){
+		CompletableFuture<List<ScriptWo>> cf = CompletableFuture.supplyAsync(() -> {
+			List<ScriptWo> swList = new ArrayList<>();
+			if(moduleMap.containsKey(moduleType)) {
+				try {
+					Map<String, Object> map = new HashMap<>();
+					map.put("appIdList", moduleMap.get(moduleType));
+					map.put("keyword", wi.getKeyword());
+					map.put("caseSensitive", wi.getCaseSensitive());
+					map.put("matchWholeWord", wi.getMatchWholeWord());
+					map.put("matchRegExp", wi.getMatchRegExp());
+					List<WrapScript> scriptList = ThisApplication.context().applications().postQuery(applicationClass,
+							Applications.joinQueryUri("script", "list", "manager"), map).getDataAsList(WrapScript.class);
+					logger.print("设计搜索关联{}的匹配脚本个数:{}", moduleType, scriptList.size());
+					getScriptSearchRes(wi, moduleType, swList, scriptList);
+				} catch (Exception e) {
+					logger.error(e);
+				}
+				if (swList.size() > 2) {
+					try {
+						SortTools.desc(swList, "appId");
+					} catch (Exception e) {
+					}
+				}
+			}
+			return swList;
+		});
+		return cf;
+	}
+
+	private void getScriptSearchRes(final Wi wi, String moduleType, List<ScriptWo> swList, List<WrapScript> scriptList){
+		if (!ListTools.isEmpty(scriptList)){
+			for (WrapScript script:scriptList) {
+				if (StringTools.matchKeyword(wi.getKeyword(), script.getText(), wi.getCaseSensitive(), wi.getMatchWholeWord(), wi.getMatchRegExp())){
+					List<Integer> list = patternLines(script.getId()+"-"+script.getUpdateTime().getTime(),
+							wi.getKeyword(), script.getText(), wi.getCaseSensitive(), wi.getMatchWholeWord(), wi.getMatchRegExp());
+					if (!ListTools.isEmpty(list)){
+						ScriptWo scriptWo = new ScriptWo();
+						scriptWo.setModuleType(moduleType);
+						scriptWo.setAppId(script.getAppId());
+						scriptWo.setAppName(script.getAppName());
+						scriptWo.setScriptId(script.getId());
+						scriptWo.setScriptName(script.getName());
+						scriptWo.setPatternLines(list);
+						swList.add(scriptWo);
+					}
+				}
+			}
+		}
+	}
+
+	public static class Wi extends GsonPropertyObject {
+		private static final long serialVersionUID = 4015406081411685640L;
+
+		@FieldDescribe("搜索关键字.")
+		private String keyword;
+		@FieldDescribe("搜索类型:script|form|process")
+		private String type;
+		@FieldDescribe("是否区分大小写.")
+		private Boolean caseSensitive;
+		@FieldDescribe("是否全字匹配.")
+		private Boolean matchWholeWord;
+		@FieldDescribe("是否正则表达式匹配.")
+		private Boolean matchRegExp;
+		@FieldDescribe("限制查询的模块列表.")
+		@FieldTypeDescribe(fieldType = "class", fieldTypeName = "Module", fieldValue = "{\"moduleType\": \"cms\", \"flagList\": []}")
+		private List<Module> moduleList;
+
+		public String getKeyword() {
+			return keyword;
+		}
+
+		public void setKeyword(String keyword) {
+			this.keyword = keyword;
+		}
+
+		public String getType() {
+			return type;
+		}
+
+		public void setType(String type) {
+			this.type = type;
+		}
+
+		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 List<Module> getModuleList() {
+			return moduleList;
+		}
+
+		public void setModuleList(List<Module> moduleList) {
+			this.moduleList = moduleList;
+		}
+	}
+
+	public static class Module extends GsonPropertyObject {
+		@FieldDescribe("模块的应用id列表.")
+		private List<String> flagList;
+		@FieldDescribe("模块类型:processPlatform|cms|portal|query|service")
+		private String moduleType;
+
+		public List<String> getFlagList() {
+			return flagList == null ? new ArrayList<>() : flagList;
+		}
+
+		public void setFlagList(List<String> flagList) {
+			this.flagList = flagList;
+		}
+
+		public String getModuleType() {
+			return moduleType;
+		}
+
+		public void setModuleType(String moduleType) {
+			this.moduleType = moduleType;
+		}
+	}
+
+	public static class Wo extends GsonPropertyObject {
+		@FieldDescribe("搜索类型:script|form|process")
+		private String type;
+		@FieldDescribe("脚本搜索结果集")
+		private List<ScriptWo> scriptWrapList = new ArrayList<>();
+
+		public String getType() {
+			return type;
+		}
+
+		public void setType(String type) {
+			this.type = type;
+		}
+
+		public List<ScriptWo> getScriptWrapList() {
+			return scriptWrapList;
+		}
+
+		public void setScriptWrapList(List<ScriptWo> scriptWrapList) {
+			this.scriptWrapList = scriptWrapList;
+		}
+	}
+
+	public static class ScriptWo extends GsonPropertyObject {
+		@FieldDescribe("模块类型:processPlatform|cms|portal|query|service")
+		private String moduleType;
+		@FieldDescribe("应用ID")
+		private String appId;
+		@FieldDescribe("应用名称")
+		private String appName;
+		@FieldDescribe("脚本Id")
+		private String scriptId;
+		@FieldDescribe("脚本名称")
+		private String scriptName;
+		@FieldDescribe("匹配行")
+		private List<Integer> patternLines;
+
+		public String getModuleType() {
+			return moduleType;
+		}
+
+		public void setModuleType(String moduleType) {
+			this.moduleType = moduleType;
+		}
+
+		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 getScriptId() {
+			return scriptId;
+		}
+
+		public void setScriptId(String scriptId) {
+			this.scriptId = scriptId;
+		}
+
+		public String getScriptName() {
+			return scriptName;
+		}
+
+		public void setScriptName(String scriptName) {
+			this.scriptName = scriptName;
+		}
+
+		public List<Integer> getPatternLines() {
+			return patternLines;
+		}
+
+		public void setPatternLines(List<Integer> patternLines) {
+			this.patternLines = patternLines;
+		}
+	}
+
+}

+ 59 - 0
o2server/x_query_service_processing/src/main/java/com/x/query/service/processing/jaxrs/design/BaseAction.java

@@ -0,0 +1,59 @@
+package com.x.query.service.processing.jaxrs.design;
+
+import com.x.base.core.project.config.Config;
+import com.x.base.core.project.jaxrs.StandardJaxrsAction;
+import com.x.base.core.project.tools.DefaultCharset;
+import com.x.base.core.project.tools.FileTools;
+import com.x.base.core.project.tools.StringTools;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang3.BooleanUtils;
+import org.apache.commons.lang3.StringUtils;
+
+import java.io.File;
+import java.io.RandomAccessFile;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+abstract class BaseAction extends StandardJaxrsAction {
+
+    protected List<Integer> patternLines(String id, String keyword, String content, Boolean caseSensitive, Boolean matchWholeWord, Boolean matchRegExp){
+        List<Integer> list = new ArrayList<>();
+        File file = readFile(id, content);
+        if (file!=null){
+            try (RandomAccessFile randomFile = new RandomAccessFile(file, "r")) {
+                int curReadLine = 0;
+                String tmp = "";
+                while ((tmp = randomFile.readLine()) != null) {
+                    curReadLine++;
+                    byte[] bytes = tmp.getBytes("ISO8859-1");
+                    String lineStr = new String(bytes);
+                    if(StringUtils.isNotBlank(lineStr) && lineStr.length()>=keyword.length()){
+                        if(StringTools.matchKeyword(keyword, lineStr, caseSensitive, matchWholeWord, matchRegExp)){
+                            list.add(curReadLine);
+                        }
+                    }
+                }
+            }catch (Exception e){
+                e.printStackTrace();
+            }
+        }
+        return list;
+    }
+
+    private synchronized File readFile(String id, String content){
+        try {
+            File searchFile = new File(Config.base(), "local/search");
+            FileTools.forceMkdir(searchFile);
+            File file = new File(searchFile.getAbsolutePath(), id+".txt");
+            if (!file.exists()){
+                FileUtils.writeByteArrayToFile(file, content.getBytes(DefaultCharset.name));
+            }
+            return file;
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+}

+ 45 - 0
o2server/x_query_service_processing/src/main/java/com/x/query/service/processing/jaxrs/design/DesignAction.java

@@ -0,0 +1,45 @@
+package com.x.query.service.processing.jaxrs.design;
+
+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;
+
+@Path("design")
+@JaxrsDescribe("设计")
+public class DesignAction extends StandardJaxrsAction {
+
+	private static Logger logger = LoggerFactory.getLogger(DesignAction.class);
+
+	@JaxrsMethodDescribe(value = "全局设计搜索.", action = ActionSearch.class)
+	@POST
+	@Path("search")
+	@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
+	@Consumes(MediaType.APPLICATION_JSON)
+	public void search(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
+					   JsonElement jsonElement) {
+		ActionResult<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));
+	}
+
+}

+ 14 - 0
o2server/x_query_service_processing/src/main/java/com/x/query/service/processing/jaxrs/design/ExceptionFieldEmpty.java

@@ -0,0 +1,14 @@
+package com.x.query.service.processing.jaxrs.design;
+
+import com.x.base.core.project.exception.PromptException;
+
+public class ExceptionFieldEmpty extends PromptException {
+
+
+	private static final long serialVersionUID = -87643358931771164L;
+
+	public ExceptionFieldEmpty(String field) {
+		super("参数: {} 值无效.", field);
+	}
+
+}

+ 12 - 0
o2server/x_query_service_processing/src/main/java/com/x/query/service/processing/jaxrs/design/ModuleType.java

@@ -0,0 +1,12 @@
+package com.x.query.service.processing.jaxrs.design;
+
+import com.x.base.core.entity.JpaObject;
+
+/**
+ *
+ */
+public enum ModuleType {
+
+	processPlatform, portal, cms;
+	public static final int length = JpaObject.length_64B;
+}

+ 109 - 0
o2server/x_query_service_processing/src/main/java/com/x/query/service/processing/jaxrs/design/WrapScript.java

@@ -0,0 +1,109 @@
+package com.x.query.service.processing.jaxrs.design;
+
+import com.x.base.core.project.gson.GsonPropertyObject;
+
+import java.util.Date;
+
+public class WrapScript extends GsonPropertyObject {
+    private static final long serialVersionUID = 2563902286060447795L;
+
+    private String id;
+    private String name;
+    private String alias;
+    private String text;
+    private String appName;
+    private String appId;
+    private String portalName;
+    private String portal;
+    private String applicationName;
+    private String application;
+    private Date updateTime;
+
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getAlias() {
+        return alias;
+    }
+
+    public void setAlias(String alias) {
+        this.alias = alias;
+    }
+
+    public String getText() {
+        return text;
+    }
+
+    public void setText(String text) {
+        this.text = text;
+    }
+
+    public String getAppName() {
+        return appName;
+    }
+
+    public void setAppName(String appName) {
+        this.appName = appName;
+    }
+
+    public String getAppId() {
+        return appId;
+    }
+
+    public void setAppId(String appId) {
+        this.appId = appId;
+    }
+
+    public String getPortalName() {
+        return portalName;
+    }
+
+    public void setPortalName(String portalName) {
+        this.portalName = portalName;
+    }
+
+    public String getPortal() {
+        return portal;
+    }
+
+    public void setPortal(String portal) {
+        this.portal = portal;
+    }
+
+    public String getApplicationName() {
+        return applicationName;
+    }
+
+    public void setApplicationName(String applicationName) {
+        this.applicationName = applicationName;
+    }
+
+    public String getApplication() {
+        return application;
+    }
+
+    public void setApplication(String application) {
+        this.application = application;
+    }
+
+    public Date getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(Date updateTime) {
+        this.updateTime = updateTime;
+    }
+}