本文整理汇总了Java中org.kie.server.api.model.ServiceResponse.ResponseType类的典型用法代码示例。如果您正苦于以下问题:Java ResponseType类的具体用法?Java ResponseType怎么用?Java ResponseType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ResponseType类属于org.kie.server.api.model.ServiceResponse包,在下文中一共展示了ResponseType类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: executeCommands
import org.kie.server.api.model.ServiceResponse.ResponseType; //导入依赖的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());
}
}
示例2: executeCommands
import org.kie.server.api.model.ServiceResponse.ResponseType; //导入依赖的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());
}
}
示例3: listContainers
import org.kie.server.api.model.ServiceResponse.ResponseType; //导入依赖的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);
}
示例4: execute
import org.kie.server.api.model.ServiceResponse.ResponseType; //导入依赖的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);
}
示例5: disposeAndCreateContainer
import org.kie.server.api.model.ServiceResponse.ResponseType; //导入依赖的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!");
}
示例6: executeCommands
import org.kie.server.api.model.ServiceResponse.ResponseType; //导入依赖的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());
}
}
示例7: getModels
import org.kie.server.api.model.ServiceResponse.ResponseType; //导入依赖的package包/类
public ServiceResponse<ModelList> getModels(String containerId) {
checkContainer(containerId);
return new ServiceResponse<ModelList>(ResponseType.SUCCESS, "Model List",
containers.get(containerId).modelsList());
}
示例8: getModel
import org.kie.server.api.model.ServiceResponse.ResponseType; //导入依赖的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));
}