提交 7ad21f6d 编写于 作者: O o2sword

服务管理、数据中心设计搜索

上级 060e2888
......@@ -9,9 +9,13 @@ import com.x.base.core.entity.JpaObject;
* page(门户的页面)
* widget(门户的widget)
* process(流程平台的流程模板)
* view(数据中心视图)
* table(数据中心自建表)
* stat(数据中心统计)
* statement(数据中心查询语句)
*/
public enum DesignerType {
script, form, page, widget, process;
script, form, page, widget, process, view, table, stat, statement;
public static final int length = JpaObject.length_64B;
}
......@@ -18,6 +18,7 @@ import com.x.program.center.jaxrs.collect.CollectAction;
import com.x.program.center.jaxrs.command.CommandAction;
import com.x.program.center.jaxrs.config.ConfigAction;
import com.x.program.center.jaxrs.datastructure.DataStructureAction;
import com.x.program.center.jaxrs.designer.DesignerAction;
import com.x.program.center.jaxrs.dingding.DingdingAction;
import com.x.program.center.jaxrs.distribute.DistributeAction;
import com.x.program.center.jaxrs.input.InputAction;
......@@ -72,6 +73,7 @@ public class ActionApplication extends AbstractActionApplication {
classes.add(OutputAction.class);
classes.add(InputAction.class);
classes.add(MarketAction.class);
classes.add(DesignerAction.class);
return classes;
}
}
package com.x.program.center.jaxrs;
import com.x.base.core.project.jaxrs.CipherManagerJaxrsFilter;
import javax.servlet.annotation.WebFilter;
@WebFilter(urlPatterns = "/jaxrs/designer/*", asyncSupported = true)
public class DesignerJaxrsFilter extends CipherManagerJaxrsFilter {
}
package com.x.program.center.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.ListTools;
import com.x.base.core.project.tools.PropertyTools;
import com.x.program.center.core.entity.Agent;
import com.x.program.center.core.entity.Invoke;
import org.apache.commons.lang3.StringUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
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);
logger.info("{}开始服务管理设计搜索,关键字:{}", effectivePerson.getDistinguishedName(), wi.getKeyword());
if(StringUtils.isBlank(wi.getKeyword())){
throw new ExceptionFieldEmpty("keyword");
}
ActionResult<List<Wo>> result = new ActionResult<>();
List<Wo> resWos = new ArrayList<>();
List<CompletableFuture<List<Wo>>> list = new ArrayList<>();
if (wi.getDesignerTypes().isEmpty() || wi.getDesignerTypes().contains(DesignerType.script.toString())){
if(wi.getAppIdList().isEmpty() || wi.getAppIdList().contains("invoke")) {
list.add(searchInvoke(wi));
}
if(wi.getAppIdList().isEmpty() || wi.getAppIdList().contains("agent")) {
list.add(searchAgent(wi));
}
}
for (CompletableFuture<List<Wo>> cf : list){
if(resWos.size()<50) {
resWos.addAll(cf.get(60, TimeUnit.SECONDS));
}
}
if (resWos.size()>50){
resWos = resWos.subList(0, 50);
}
result.setData(resWos);
result.setCount((long)resWos.size());
return result;
}
private CompletableFuture<List<Wo>> searchAgent(final Wi wi) {
CompletableFuture<List<Wo>> cf = CompletableFuture.supplyAsync(() -> {
List<Wo> resWos = new ArrayList<>();
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
List<WoAgent> woAgents = emc.fetchAll(Agent.class, WoAgent.copier);
for (WoAgent woAgent : woAgents) {
Map<String, String> map = PropertyTools.fieldMatchKeyword(WoAgent.copier.getCopyFields(), woAgent, wi.getKeyword(),
wi.getCaseSensitive(), wi.getMatchWholeWord(), wi.getMatchRegExp());
if (!map.isEmpty()) {
Wo wo = new Wo();
wo.setAppId("agent");
wo.setAppName("代理");
wo.setDesignerId(woAgent.getId());
wo.setDesignerName(woAgent.getName());
wo.setDesignerType(DesignerType.script.toString());
wo.setUpdateTime(woAgent.getUpdateTime());
wo.setPatternList(map);
resWos.add(wo);
}
}
woAgents.clear();
}catch (Exception e){
logger.error(e);
}
return resWos;
});
return cf;
}
private CompletableFuture<List<Wo>> searchInvoke(final Wi wi) {
CompletableFuture<List<Wo>> cf = CompletableFuture.supplyAsync(() -> {
List<Wo> resWos = new ArrayList<>();
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
List<WoInvoke> woInvokes = emc.fetchAll(Invoke.class, WoInvoke.copier);
for (WoInvoke woInvoke : woInvokes) {
Map<String, String> map = PropertyTools.fieldMatchKeyword(WoInvoke.copier.getCopyFields(), woInvoke, wi.getKeyword(),
wi.getCaseSensitive(), wi.getMatchWholeWord(), wi.getMatchRegExp());
if (!map.isEmpty()) {
Wo wo = new Wo();
wo.setAppId("invoke");
wo.setAppName("接口");
wo.setDesignerId(woInvoke.getId());
wo.setDesignerName(woInvoke.getName());
wo.setDesignerType(DesignerType.script.toString());
wo.setUpdateTime(woInvoke.getUpdateTime());
wo.setPatternList(map);
resWos.add(wo);
}
}
woInvokes.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 WoAgent extends Agent {
static WrapCopier<Agent, WoAgent> copier = WrapCopierFactory.wo(Agent.class, WoAgent.class,
JpaObject.singularAttributeField(Agent.class, true, false),null);
}
public static class WoInvoke extends Invoke {
static WrapCopier<Invoke, WoInvoke> copier = WrapCopierFactory.wo(Invoke.class, WoInvoke.class,
JpaObject.singularAttributeField(Invoke.class, true, false),null);
}
}
package com.x.program.center.jaxrs.designer;
import com.x.base.core.project.jaxrs.StandardJaxrsAction;
abstract class BaseAction extends StandardJaxrsAction {
}
package com.x.program.center.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.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
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 search(@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));
}
}
package com.x.program.center.jaxrs.designer;
import com.x.base.core.project.exception.PromptException;
public class ExceptionFieldEmpty extends PromptException {
public ExceptionFieldEmpty(String field) {
super("参数: {} 值无效.", field);
}
}
......@@ -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.assemble.designer.jaxrs.designer.DesignerAction;
import com.x.query.assemble.designer.jaxrs.id.IdAction;
import com.x.query.assemble.designer.jaxrs.input.InputAction;
import com.x.query.assemble.designer.jaxrs.neural.NeuralAction;
......@@ -30,6 +31,7 @@ public class ActionApplication extends AbstractActionApplication {
classes.add(InputAction.class);
classes.add(TableAction.class);
classes.add(StatementAction.class);
classes.add(DesignerAction.class);
return classes;
}
......
package com.x.query.assemble.designer.jaxrs;
import com.x.base.core.project.jaxrs.CipherManagerJaxrsFilter;
import javax.servlet.annotation.WebFilter;
@WebFilter(urlPatterns = "/jaxrs/designer/*", asyncSupported = true)
public class DesignerJaxrsFilter extends CipherManagerJaxrsFilter {
}
package com.x.query.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.ListTools;
import com.x.base.core.project.tools.PropertyTools;
import com.x.query.core.entity.Query;
import com.x.query.core.entity.Stat;
import com.x.query.core.entity.View;
import com.x.query.core.entity.schema.Statement;
import com.x.query.core.entity.schema.Table;
import org.apache.commons.lang3.StringUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
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);
logger.info("{}开始数据中心设计搜索,关键字:{}", effectivePerson.getDistinguishedName(), wi.getKeyword());
if(StringUtils.isBlank(wi.getKeyword())){
throw new ExceptionFieldEmpty("keyword");
}
ActionResult<List<Wo>> result = new ActionResult<>();
List<Wo> resWos = new ArrayList<>();
List<CompletableFuture<List<Wo>>> list = new ArrayList<>();
if (wi.getDesignerTypes().isEmpty() || wi.getDesignerTypes().contains(DesignerType.view.toString())){
list.add(searchView(wi, wi.getAppIdList()));
}
if (wi.getDesignerTypes().isEmpty() || wi.getDesignerTypes().contains(DesignerType.table.toString())){
list.add(searchTable(wi, wi.getAppIdList()));
}
if (wi.getDesignerTypes().isEmpty() || wi.getDesignerTypes().contains(DesignerType.statement.toString())){
list.add(searchStatement(wi, wi.getAppIdList()));
}
if (wi.getDesignerTypes().isEmpty() || wi.getDesignerTypes().contains(DesignerType.stat.toString())){
list.add(searchStat(wi, wi.getAppIdList()));
}
for (CompletableFuture<List<Wo>> cf : list){
if(resWos.size()<50) {
resWos.addAll(cf.get(60, TimeUnit.SECONDS));
}
}
if (resWos.size()>50){
resWos = resWos.subList(0, 50);
}
result.setData(resWos);
result.setCount((long)resWos.size());
return result;
}
private CompletableFuture<List<Wo>> searchView(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<WoView> woViews;
if (ListTools.isEmpty(appIdList)) {
woViews = emc.fetchAll(View.class, WoView.copier);
} else {
woViews = emc.fetchIn(View.class, WoView.copier, View.query_FIELDNAME, appIdList);
}
for (WoView woView : woViews) {
Map<String, String> map = PropertyTools.fieldMatchKeyword(WoView.copier.getCopyFields(), woView, wi.getKeyword(),
wi.getCaseSensitive(), wi.getMatchWholeWord(), wi.getMatchRegExp());
if (!map.isEmpty()) {
Wo wo = new Wo();
Query query = emc.find(woView.getQuery(), Query.class);
if (query != null) {
wo.setAppId(query.getId());
wo.setAppName(query.getName());
}
wo.setDesignerId(woView.getId());
wo.setDesignerName(woView.getName());
wo.setDesignerType(DesignerType.view.toString());
wo.setUpdateTime(woView.getUpdateTime());
wo.setPatternList(map);
resWos.add(wo);
}
}
woViews.clear();
}catch (Exception e){
logger.error(e);
}
return resWos;
});
return cf;
}
private CompletableFuture<List<Wo>> searchTable(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<WoTable> woTables;
if (ListTools.isEmpty(appIdList)) {
woTables = emc.fetchAll(Table.class, WoTable.copier);
} else {
woTables = emc.fetchIn(Table.class, WoTable.copier, Table.query_FIELDNAME, appIdList);
}
for (WoTable woTable : woTables) {
Map<String, String> map = PropertyTools.fieldMatchKeyword(WoTable.copier.getCopyFields(), woTable, wi.getKeyword(),
wi.getCaseSensitive(), wi.getMatchWholeWord(), wi.getMatchRegExp());
if (!map.isEmpty()) {
Wo wo = new Wo();
Query query = emc.find(woTable.getQuery(), Query.class);
if (query != null) {
wo.setAppId(query.getId());
wo.setAppName(query.getName());
}
wo.setDesignerId(woTable.getId());
wo.setDesignerName(woTable.getName());
wo.setDesignerType(DesignerType.table.toString());
wo.setUpdateTime(woTable.getUpdateTime());
wo.setPatternList(map);
resWos.add(wo);
}
}
woTables.clear();
}catch (Exception e){
logger.error(e);
}
return resWos;
});
return cf;
}
private CompletableFuture<List<Wo>> searchStat(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<WoStat> woStats;
if (ListTools.isEmpty(appIdList)) {
woStats = emc.fetchAll(Stat.class, WoStat.copier);
} else {
woStats = emc.fetchIn(Stat.class, WoStat.copier, Stat.query_FIELDNAME, appIdList);
}
for (WoStat woStat : woStats) {
Map<String, String> map = PropertyTools.fieldMatchKeyword(WoStat.copier.getCopyFields(), woStat, wi.getKeyword(),
wi.getCaseSensitive(), wi.getMatchWholeWord(), wi.getMatchRegExp());
if (!map.isEmpty()) {
Wo wo = new Wo();
Query query = emc.find(woStat.getQuery(), Query.class);
if (query != null) {
wo.setAppId(query.getId());
wo.setAppName(query.getName());
}
wo.setDesignerId(woStat.getId());
wo.setDesignerName(woStat.getName());
wo.setDesignerType(DesignerType.stat.toString());
wo.setUpdateTime(woStat.getUpdateTime());
wo.setPatternList(map);
resWos.add(wo);
}
}
woStats.clear();
}catch (Exception e){
logger.error(e);
}
return resWos;
});
return cf;
}
private CompletableFuture<List<Wo>> searchStatement(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<WoStatement> woStatements;
if (ListTools.isEmpty(appIdList)) {
woStatements = emc.fetchAll(Statement.class, WoStatement.copier);
} else {
woStatements = emc.fetchIn(Statement.class, WoStatement.copier, Statement.query_FIELDNAME, appIdList);
}
for (WoStatement woStatement : woStatements) {
Map<String, String> map = PropertyTools.fieldMatchKeyword(WoStatement.copier.getCopyFields(), woStatement, wi.getKeyword(),
wi.getCaseSensitive(), wi.getMatchWholeWord(), wi.getMatchRegExp());
if (!map.isEmpty()) {
Wo wo = new Wo();
Query query = emc.find(woStatement.getQuery(), Query.class);
if (query != null) {
wo.setAppId(query.getId());
wo.setAppName(query.getName());
}
wo.setDesignerId(woStatement.getId());
wo.setDesignerName(woStatement.getName());
wo.setDesignerType(DesignerType.statement.toString());
wo.setUpdateTime(woStatement.getUpdateTime());
wo.setPatternList(map);
resWos.add(wo);
}
}
woStatements.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 WoView extends View {
static WrapCopier<View, WoView> copier = WrapCopierFactory.wo(View.class, WoView.class,
JpaObject.singularAttributeField(View.class, true, false),null);
}
public static class WoStat extends Stat {
static WrapCopier<Stat, WoStat> copier = WrapCopierFactory.wo(Stat.class, WoStat.class,
JpaObject.singularAttributeField(Stat.class, true, false),null);
}
public static class WoTable extends Table {
static WrapCopier<Table, WoTable> copier = WrapCopierFactory.wo(Table.class, WoTable.class,
JpaObject.singularAttributeField(Table.class, true, false),null);
}
public static class WoStatement extends Statement {
static WrapCopier<Statement, WoStatement> copier = WrapCopierFactory.wo(Statement.class, WoStatement.class,
JpaObject.singularAttributeField(Statement.class, true, false),null);
}
}
package com.x.query.assemble.designer.jaxrs.designer;
import com.x.base.core.project.jaxrs.StandardJaxrsAction;
abstract class BaseAction extends StandardJaxrsAction {
}
package com.x.query.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.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
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 search(@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));
}
}
package com.x.query.assemble.designer.jaxrs.designer;
import com.x.base.core.project.exception.PromptException;
public class ExceptionFieldEmpty extends PromptException {
public ExceptionFieldEmpty(String field) {
super("参数: {} 值无效.", field);
}
}
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.*;
import com.x.base.core.project.annotation.FieldDescribe;
import com.x.base.core.project.annotation.FieldTypeDescribe;
import com.x.base.core.project.gson.GsonPropertyObject;
......@@ -13,9 +13,6 @@ 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.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.beanutils.BeanUtils;
import org.apache.commons.lang3.StringUtils;
......@@ -52,17 +49,27 @@ class ActionSearch extends BaseAction {
if(module.getModuleType().equalsIgnoreCase(ModuleType.processPlatform.toString())){
moduleMap.put(ModuleType.processPlatform.toString(), module.getFlagList());
}
if(module.getModuleType().equalsIgnoreCase(ModuleType.query.toString())){
moduleMap.put(ModuleType.query.toString(), module.getFlagList());
}
if(module.getModuleType().equalsIgnoreCase(ModuleType.service.toString())){
moduleMap.put(ModuleType.service.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);
moduleMap.put(ModuleType.query.toString(), list);
moduleMap.put(ModuleType.service.toString(), list);
}
Executor executor = Executors.newFixedThreadPool(5);
CompletableFuture<List<WrapDesigner>> processPlatformCf = searchAsync(wi, moduleMap, ModuleType.processPlatform.toString(), x_processplatform_assemble_designer.class, executor);
CompletableFuture<List<WrapDesigner>> portalCf = searchAsync(wi, moduleMap, ModuleType.portal.toString(), x_portal_assemble_designer.class, executor);
CompletableFuture<List<WrapDesigner>> cmsCf = searchAsync(wi, moduleMap, ModuleType.cms.toString(), x_cms_assemble_control.class, executor);
CompletableFuture<List<WrapDesigner>> queryCf = searchAsync(wi, moduleMap, ModuleType.query.toString(), x_query_assemble_designer.class, executor);
CompletableFuture<List<WrapDesigner>> serviceCf = searchAsync(wi, moduleMap, ModuleType.service.toString(), x_program_center.class, executor);
Wo wo = new Wo();
try {
wo.setProcessPlatformList(processPlatformCf.get(200, TimeUnit.SECONDS));
......@@ -79,6 +86,16 @@ class ActionSearch extends BaseAction {
} catch (Exception e) {
logger.warn("搜索内容管理平台设计异常:{}",e.getMessage());
}
try {
wo.setQueryList(queryCf.get(200, TimeUnit.SECONDS));
} catch (Exception e) {
logger.warn("搜索数据中心平台设计异常:{}",e.getMessage());
}
try {
wo.setServiceList(serviceCf.get(200, TimeUnit.SECONDS));
} catch (Exception e) {
logger.warn("搜索服务管理平台设计异常:{}",e.getMessage());
}
return wo;
}
......@@ -223,6 +240,10 @@ class ActionSearch extends BaseAction {
private List<WrapDesigner> portalList;
private List<WrapDesigner> queryList;
private List<WrapDesigner> serviceList;
public List<WrapDesigner> getProcessPlatformList() {
return processPlatformList;
}
......@@ -246,6 +267,22 @@ class ActionSearch extends BaseAction {
public void setPortalList(List<WrapDesigner> portalList) {
this.portalList = portalList;
}
public List<WrapDesigner> getQueryList() {
return queryList;
}
public void setQueryList(List<WrapDesigner> queryList) {
this.queryList = queryList;
}
public List<WrapDesigner> getServiceList() {
return serviceList;
}
public void setServiceList(List<WrapDesigner> serviceList) {
this.serviceList = serviceList;
}
}
}
......@@ -17,14 +17,17 @@ 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.concurrent.locks.ReentrantLock;
@Path("design")
@JaxrsDescribe("设计")
@JaxrsDescribe("全平台设计")
public class DesignAction extends StandardJaxrsAction {
private static Logger logger = LoggerFactory.getLogger(DesignAction.class);
@JaxrsMethodDescribe(value = "全局设计搜索.", action = ActionSearch.class)
private static ReentrantLock lock = new ReentrantLock();
@JaxrsMethodDescribe(value = "全平台设计搜索.", action = ActionSearch.class)
@POST
@Path("search")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
......@@ -33,11 +36,14 @@ public class DesignAction extends StandardJaxrsAction {
JsonElement jsonElement) {
ActionResult<ActionSearch.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
lock.lock();
try {
result = new ActionSearch().execute(effectivePerson, jsonElement);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
} finally {
lock.unlock();
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册