• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ServiceResponse类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.kie.server.api.model.ServiceResponse的典型用法代码示例。如果您正苦于以下问题:Java ServiceResponse类的具体用法?Java ServiceResponse怎么用?Java ServiceResponse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ServiceResponse类属于org.kie.server.api.model包,在下文中一共展示了ServiceResponse类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getModels

import org.kie.server.api.model.ServiceResponse; //导入依赖的package包/类
@GET
@Path(KieMLConstants.URI_GET_MODELS)
public Response getModels(@PathParam(CONTAINER_ID) String containerId) {
	Response response;
	try {
		ServiceResponse<ModelList> result = kieMLServicesBase.getModels(containerId);
		if (result.getType() == ServiceResponse.ResponseType.SUCCESS) {
			response = Response.ok(result).build();
		} else {
			response = Response.status(Status.NOT_FOUND).build();
		}
	} catch (Exception e) {
		logger.warn("Unexpected error retrieving Model List. Message: '{}'", e.getMessage(), e);
		response = Response.serverError().type("text/plain").entity("Error retrieving model list: " + e.getMessage()).build();
	}
	return response;
}
 
开发者ID:jesuino,项目名称:kie-ml,代码行数:18,代码来源:KieMLResource.java


示例2: getModel

import org.kie.server.api.model.ServiceResponse; //导入依赖的package包/类
@GET
@Path(KieMLConstants.URI_GET_MODEL)
public Response getModel(@PathParam(CONTAINER_ID) String containerId, @PathParam(KieMLConstants.PARAM_MODEL_ID) String modelId) {
	Response response;
	try {
		ServiceResponse<Model> result = kieMLServicesBase.getModel(containerId, modelId);
		if (result.getType() == ServiceResponse.ResponseType.SUCCESS) {
			response=  Response.ok(result).build();
		} else {
			response = Response.status(Status.NOT_FOUND).build();
		}
	} catch (Exception e) {
		logger.warn("Unexpected error Model. Message: '{}'", e.getMessage(), e);
		response = Response.serverError().type("text/plain").entity("Unexpected error Model: " + e.getMessage()).build();
	}
	return response;
}
 
开发者ID:jesuino,项目名称:kie-ml,代码行数:18,代码来源:KieMLResource.java


示例3: processRules

import org.kie.server.api.model.ServiceResponse; //导入依赖的package包/类
public Measure processRules(@Body Measure measure) {
	
	KieServicesConfiguration config = KieServicesFactory.newRestConfiguration(
			kieHost, kieUser,
			kiePassword);
	
	Set<Class<?>> jaxBClasses = new HashSet<Class<?>>();
	jaxBClasses.add(Measure.class);
	
	config.addJaxbClasses(jaxBClasses);
	config.setMarshallingFormat(MarshallingFormat.JAXB);
	RuleServicesClient client = KieServicesFactory.newKieServicesClient(config)
			.getServicesClient(RuleServicesClient.class);

       List<Command<?>> cmds = new ArrayList<Command<?>>();
	KieCommands commands = KieServices.Factory.get().getCommands();
	cmds.add(commands.newInsert(measure));
	
    GetObjectsCommand getObjectsCommand = new GetObjectsCommand();
    getObjectsCommand.setOutIdentifier("objects");

	
	cmds.add(commands.newFireAllRules());
	cmds.add(getObjectsCommand);
	BatchExecutionCommand myCommands = CommandFactory.newBatchExecution(cmds,
			"DecisionTableKS");
	ServiceResponse<ExecutionResults> response = client.executeCommandsWithResults("iot-ocp-businessrules-service", myCommands);
			
	List responseList = (List) response.getResult().getValue("objects");
	
	Measure responseMeasure = (Measure) responseList.get(0);
	
	return responseMeasure;

}
 
开发者ID:sabre1041,项目名称:iot-ocp,代码行数:36,代码来源:BusinessRulesBean.java


示例4: executeCommands

import org.kie.server.api.model.ServiceResponse; //导入依赖的package包/类
@Test
public void executeCommands() {
	System.out.println("== Sending commands to the server ==");
	RuleServicesClient rulesClient = kieServicesClient
			.getServicesClient(RuleServicesClient.class);
	KieCommands commandsFactory = KieServices.Factory.get().getCommands();
	Command<?> insert = commandsFactory.newInsert("Some String OBJ");
	Command<?> fireAllRules = commandsFactory.newFireAllRules();
	Command<?> batchCommand = commandsFactory.newBatchExecution(Arrays
			.asList(insert, fireAllRules));
	ServiceResponse<ExecutionResults> executeResponse = rulesClient
			.executeCommandsWithResults(RULES_CONTAINER, batchCommand);
	if (executeResponse.getType() == ResponseType.SUCCESS) {
		System.out.println("Commands executed with success! Response: ");
		System.out.println(executeResponse.getResult());
	} else {
		System.out.println("Error executing rules. Message: ");
		System.out.println(executeResponse.getMsg());
	}
}
 
开发者ID:jesuino,项目名称:bpms6-examples,代码行数:21,代码来源:DecisionServerJMSTest.java


示例5: executeCommands

import org.kie.server.api.model.ServiceResponse; //导入依赖的package包/类
@Test
public void executeCommands() {
	System.out.println("== Sending commands to the server ==");
	RuleServicesClient rulesClient = kieServicesClient
			.getServicesClient(RuleServicesClient.class);
	KieCommands commandsFactory = KieServices.Factory.get().getCommands();
	Command<?> insert = commandsFactory.newInsert("Some String OBJ");
	Command<?> fireAllRules = commandsFactory.newFireAllRules();
	Command<?> batchCommand = commandsFactory.newBatchExecution(Arrays
			.asList(insert, fireAllRules));
	ServiceResponse<ExecutionResults> executeResponse = rulesClient.executeCommandsWithResults(RULES_CONTAINER, batchCommand);
	if (executeResponse.getType() == ResponseType.SUCCESS) {
		System.out.println("Commands executed with success! Response: ");
		System.out.println(executeResponse.getResult());
	} else {
		System.out.println("Error executing rules. Message: ");
		System.out.println(executeResponse.getMsg());
	}
}
 
开发者ID:jesuino,项目名称:bpms6-examples,代码行数:20,代码来源:DecisionServerTest.java


示例6: listContainers

import org.kie.server.api.model.ServiceResponse; //导入依赖的package包/类
@GET
@Path(KieMLConstants.URI_KIEML_CONTAINERS)
public Response listContainers(){
	Response response;		
	try {
		ServiceResponse<KieContainerResourceList> result = kieMLServicesBase.listContainers();
		response =  Response.ok(result).build();
	} catch (Exception e) {
		logger.warn("Unexpected error retrieving container List. Message: '{}'", e.getMessage(), e);
		response = Response.serverError().type("text/plain").entity("Unexpected error retrieving container list: " + e.getMessage()).build();
	}
	return response;
   }
 
开发者ID:jesuino,项目名称:kie-ml,代码行数:14,代码来源:KieMLResource.java


示例7: predict

import org.kie.server.api.model.ServiceResponse; //导入依赖的package包/类
@POST
@Path(KieMLConstants.URI_PREDICTION)
@Consumes({  MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response predict(@javax.ws.rs.core.Context HttpHeaders headers, @PathParam(CONTAINER_ID) String containerId,
		@PathParam(KieMLConstants.PARAM_MODEL_ID) String modelId, String inputPayload) {
	String contentType = getContentType(headers).split(";")[0];
	try {
		Input input = marshallerHelper.unmarshal(containerId, inputPayload, contentType, Input.class);
		ServiceResponse<Result> result = kieMLServicesBase.predict(containerId, modelId, input);
		return Response.ok(result).build();
	} catch (Exception e) {
		logger.warn("Unexpected error running prediction. Message: '{}'", e.getMessage(), e);
		return Response.serverError().type("text/plain").entity("Unexpected error running prediction: " + e.getMessage()).build();
	}
}
 
开发者ID:jesuino,项目名称:kie-ml,代码行数:16,代码来源:KieMLResource.java


示例8: listContainers

import org.kie.server.api.model.ServiceResponse; //导入依赖的package包/类
public ServiceResponse<KieContainerResourceList> listContainers() {
	List<KieContainerResource> containersList = containers.keySet().stream()
					.map(context::getContainer)
					.map(KieContainerInstance::getResource)
					.collect(Collectors.toList());
	KieContainerResourceList list = new KieContainerResourceList(containersList);
	return new ServiceResponse<KieContainerResourceList>(ResponseType.SUCCESS, "Containers using KieML extension", list);
}
 
开发者ID:jesuino,项目名称:kie-ml,代码行数:9,代码来源:KieMLServicesBase.java


示例9: predict

import org.kie.server.api.model.ServiceResponse; //导入依赖的package包/类
@Override
public ServiceResponse<Result> predict(String containerId, String modelId, Input input) {
	String uri = String.join("/", 
			baseUrl,
			KieMLConstants.URI_BASE.replaceFirst("\\{" + KieMLConstants.PARAM_CONTAINER_ID + "\\}", containerId),
			KieMLConstants.URI_PREDICTION.replaceAll("\\{" + KieMLConstants.PARAM_MODEL_ID + "\\}", modelId)
	);
	String body = marshaller.marshall(input);
	return makeHttpPostRequestAndCreateServiceResponse(uri, body, Result.class, new HashMap<>());
}
 
开发者ID:jesuino,项目名称:kie-ml,代码行数:11,代码来源:KieServerMLClientImpl.java


示例10: getModelList

import org.kie.server.api.model.ServiceResponse; //导入依赖的package包/类
@Override
public ServiceResponse<ModelList> getModelList(String containerId) {
	String uri = String.join("/", 
			baseUrl,
			KieMLConstants.URI_BASE.replaceFirst("\\{" + KieMLConstants.PARAM_CONTAINER_ID + "\\}", containerId),
			KieMLConstants.URI_GET_MODELS
	);
	return makeHttpGetRequestAndCreateServiceResponse(uri, ModelList.class);
}
 
开发者ID:jesuino,项目名称:kie-ml,代码行数:10,代码来源:KieServerMLClientImpl.java


示例11: getModel

import org.kie.server.api.model.ServiceResponse; //导入依赖的package包/类
@Override
public ServiceResponse<Model> getModel(String containerId, String modelId) {
	String uri = String.join("/", 
			baseUrl,
			KieMLConstants.URI_BASE.replaceFirst("\\{" + KieMLConstants.PARAM_CONTAINER_ID + "\\}", containerId),
			KieMLConstants.URI_GET_MODEL.replaceAll("\\{" + KieMLConstants.PARAM_MODEL_ID + "\\}", modelId)
	);
	return makeHttpGetRequestAndCreateServiceResponse(uri, Model.class);
}
 
开发者ID:jesuino,项目名称:kie-ml,代码行数:10,代码来源:KieServerMLClientImpl.java


示例12: extractResult

import org.kie.server.api.model.ServiceResponse; //导入依赖的package包/类
public Greeting extractResult(ServiceResponse<ExecutionResults> response) {
    ExecutionResults res = response.getResult();
    Greeting greeting = null;
    if (res != null) {
        QueryResults queryResults = (QueryResults) res.getValue("greetings");
        for (QueryResultsRow queryResult : queryResults) {
            greeting = (Greeting) queryResult.get("greeting");
            break;
        }
    }

    return greeting;
}
 
开发者ID:fabric8-quickstarts,项目名称:spring-boot-camel-drools,代码行数:14,代码来源:DecisionServerHelper.java


示例13: execute

import org.kie.server.api.model.ServiceResponse; //导入依赖的package包/类
public Object execute(Command command, String containerId) {
	BatchExecutionHelperProviderImpl batchExecutionHelperProviderImpl = new BatchExecutionHelperProviderImpl();
	XStream xstream = batchExecutionHelperProviderImpl
			.newXStreamMarshaller();
	String payload = xstream.toXML(command);
	LOG.debug("payload=" + payload);
	ServiceResponse<String> serviceResponse = kieServicesClient
			.executeCommands(containerId, payload);
	if (serviceResponse.getType().equals(ResponseType.FAILURE)) {
		throw new RuntimeException(serviceResponse.getMsg());
	}
	String response = serviceResponse.getResult();
	LOG.debug("response=" + response);
	return xstream.fromXML(response);
}
 
开发者ID:anurag-saran,项目名称:drools-usage-patterns,代码行数:16,代码来源:RemoteCommandExecutor.java


示例14: listCapabilities

import org.kie.server.api.model.ServiceResponse; //导入依赖的package包/类
@Test
public void listCapabilities() {
	ServiceResponse<KieServerInfo> r = kieServicesClient.getServerInfo();
	r.getType();
	KieServerInfo serverInfo = kieServicesClient.getServerInfo()
			.getResult();
	System.out.println("== Server capabilities: ==");
	for (String capability : serverInfo.getCapabilities()) {
		System.out.print(" " + capability);
	}
	System.out.println();
}
 
开发者ID:jesuino,项目名称:bpms6-examples,代码行数:13,代码来源:DecisionServerTest.java


示例15: disposeAndCreateContainer

import org.kie.server.api.model.ServiceResponse; //导入依赖的package包/类
@Test
public void disposeAndCreateContainer() {
	System.out.println("== Disposing and creating containers ==");
	List<KieContainerResource> kieContainers = kieServicesClient
			.listContainers().getResult().getContainers();
	if (kieContainers.size() == 0) {
		System.out.println("No containers available...");
		return;
	}
	KieContainerResource container = kieContainers.get(0);
	String containerId = container.getContainerId();
	ServiceResponse<Void> responseDispose = kieServicesClient
			.disposeContainer(containerId);
	if (responseDispose.getType() == ResponseType.FAILURE) {
		System.out
				.println("Error disposing " + containerId + ". Message: ");
		System.out.println(responseDispose.getMsg());
		return;
	}
	System.out.println("Success Disposing container " + containerId);
	System.out.println("Trying to recreate the container...");
	ServiceResponse<KieContainerResource> createResponse = kieServicesClient
			.createContainer(containerId, container);
	if (createResponse.getType() == ResponseType.FAILURE) {
		System.out.println("Error creating " + containerId + ". Message: ");
		System.out.println(responseDispose.getMsg());
		return;
	}
	System.out.println("Container recreated with success!");
}
 
开发者ID:jesuino,项目名称:bpms6-examples,代码行数:31,代码来源:DecisionServerTest.java


示例16: executeCommands

import org.kie.server.api.model.ServiceResponse; //导入依赖的package包/类
@Test
public void executeCommands() {
	System.out.println("== Sending commands to the server ==");
	RuleServicesClient rulesClient = kieServicesClient
			.getServicesClient(RuleServicesClient.class);
	KieCommands commandsFactory = KieServices.Factory.get().getCommands();
	Command<?> insert = commandsFactory.newInsert("Some String OBJ");
	Command<?> fireAllRules = commandsFactory.newFireAllRules();
	Command<?> batchCommand = commandsFactory.newBatchExecution(Arrays
			.asList(insert, fireAllRules));
	ServiceResponse<String> executeResponse = rulesClient.executeCommands(RULES_CONTAINER, batchCommand);
	if (executeResponse.getType() == ResponseType.SUCCESS) {
		System.out.println("Commands executed with success! Response: ");
		System.out.println(executeResponse.getResult());
	} else {
		System.out.println("Error executing rules. Message: ");
		System.out.println(executeResponse.getMsg());
	}
}
 
开发者ID:jesuino,项目名称:bpms6-examples,代码行数:20,代码来源:DecisionServerTest.java


示例17: getModels

import org.kie.server.api.model.ServiceResponse; //导入依赖的package包/类
public ServiceResponse<ModelList> getModels(String containerId) {
	checkContainer(containerId);
	return new ServiceResponse<ModelList>(ResponseType.SUCCESS, "Model List",
			containers.get(containerId).modelsList());
}
 
开发者ID:jesuino,项目名称:kie-ml,代码行数:6,代码来源:KieMLServicesBase.java


示例18: getModel

import org.kie.server.api.model.ServiceResponse; //导入依赖的package包/类
public ServiceResponse<Model> getModel(String containerId, String modelId) {
	checkContainer(containerId);
	return containers.get(containerId).modelsList().getModels().stream().filter(m -> m.getId().equals(modelId))
			.map(m -> new ServiceResponse<Model>(ResponseType.SUCCESS, "Found model", m)).findFirst()
			.orElse(new ServiceResponse<Model>(ResponseType.FAILURE, "Model Not found: " + modelId));
}
 
开发者ID:jesuino,项目名称:kie-ml,代码行数:7,代码来源:KieMLServicesBase.java


示例19: predict

import org.kie.server.api.model.ServiceResponse; //导入依赖的package包/类
public ServiceResponse<Result> predict(String containerId, String modelId, Input input); 
开发者ID:jesuino,项目名称:kie-ml,代码行数:2,代码来源:KieServerMLClient.java


示例20: getModelList

import org.kie.server.api.model.ServiceResponse; //导入依赖的package包/类
public ServiceResponse<ModelList> getModelList(String containerId); 
开发者ID:jesuino,项目名称:kie-ml,代码行数:2,代码来源:KieServerMLClient.java



注:本文中的org.kie.server.api.model.ServiceResponse类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ObservableFloatArray类代码示例发布时间:2022-05-23
下一篇:
Java StateManager类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap