本文整理了Java中org.kie.api.builder.Message.getText()
方法的一些代码示例,展示了Message.getText()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message.getText()
方法的具体详情如下:
包路径:org.kie.api.builder.Message
类名称:Message
方法名:getText
[英]Return the text of this Message
[中]返回此消息的文本
代码示例来源:origin: kiegroup/jbpm
protected InternalKieModule createKieJar(KieServices ks, ReleaseId releaseId, Map<String, String> resources, ReleaseId... dependencies) {
KieFileSystem kfs = createKieFileSystemWithKProject(ks);
kfs.writePomXML(getPom(releaseId, dependencies));
for (Map.Entry<String, String> entry : resources.entrySet()) {
kfs.write(entry.getKey(), ResourceFactory
.newByteArrayResource(entry.getValue().getBytes()));
}
KieBuilder kieBuilder = ks.newKieBuilder(kfs);
if (!kieBuilder.buildAll().getResults().getMessages().isEmpty()) {
for (Message message : kieBuilder.buildAll().getResults()
.getMessages()) {
logger.error("Error Message: ({}) {}", message.getPath(), message.getText());
}
throw new RuntimeException(
"There are errors builing the package, please check your knowledge assets!");
}
return (InternalKieModule) kieBuilder.getKieModule();
}
代码示例来源:origin: kiegroup/jbpm
protected InternalKieModule createKieJar(KieServices ks, ReleaseId releaseId, List<String> resources ) {
KieFileSystem kfs = createKieFileSystemWithKProject(ks);
kfs.writePomXML( getPom(releaseId) );
for (String resource : resources) {
kfs.write("src/main/resources/rules/" + resource, ResourceFactory.newClassPathResource(resource));
}
KieBuilder kieBuilder = ks.newKieBuilder(kfs);
if (!kieBuilder.buildAll().getResults().getMessages().isEmpty()) {
for (Message message : kieBuilder.buildAll().getResults().getMessages()) {
logger.error("Error Message: ({}) {}", message.getPath(), message.getText());
}
throw new RuntimeException(
"There are errors builing the package, please check your knowledge assets!");
}
return ( InternalKieModule ) kieBuilder.getKieModule();
}
代码示例来源:origin: kiegroup/jbpm
protected InternalKieModule createKieJar(KieServices ks, ReleaseId releaseId, List<String> resources ) {
KieFileSystem kfs = createKieFileSystemWithKProject(ks);
kfs.writePomXML( getPom(releaseId) );
for (String resource : resources) {
kfs.write("src/main/resources/KBase-test/" + resource, ResourceFactory.newClassPathResource(resource));
}
KieBuilder kieBuilder = ks.newKieBuilder(kfs);
if (!kieBuilder.buildAll().getResults().getMessages().isEmpty()) {
for (Message message : kieBuilder.buildAll().getResults().getMessages()) {
logger.error("Error Message: ({}) {}", message.getPath(), message.getText());
}
throw new RuntimeException(
"There are errors builing the package, please check your knowledge assets!");
}
return ( InternalKieModule ) kieBuilder.getKieModule();
}
代码示例来源:origin: stackoverflow.com
if(logger.isDebugEnable()) {
for(Message mess:list) {
logger.debug("mess:" + mess.getText());
}
}
代码示例来源:origin: stackoverflow.com
for(Message mess:list) {
logger.debug("mess:" + mess.getText());
}
代码示例来源:origin: org.drools/drools-compiler
public static byte[] buildKJar(KieServices ks, KieFileSystem kfs, ReleaseId releaseId) {
KieBuilder kb = ks.newKieBuilder(kfs).buildAll();
if (kb.getResults().hasMessages(Message.Level.ERROR)) {
for (Message result : kb.getResults().getMessages()) {
System.out.println(result.getText());
}
return null;
}
InternalKieModule kieModule = (InternalKieModule) ks.getRepository()
.getKieModule(releaseId);
byte[] jar = kieModule.getBytes();
return jar;
}
代码示例来源:origin: stackoverflow.com
ObjectInputStream in = new ObjectInputStream(socket.getInputStream());
Message messageObject = (Message) in.readObject();
String messageText = messageObject.getText();
代码示例来源:origin: org.kie.workbench.services/kie-wb-common-services-backend
private static String convertMessageText(final Message message) {
final StringBuilder sb = new StringBuilder();
if (message instanceof InternalMessage) {
final InternalMessage impl = (InternalMessage) message;
final String kieBaseName = impl.getKieBaseName();
if (!(kieBaseName == null || kieBaseName.isEmpty())) {
sb.append("[KBase: ").append(kieBaseName).append("]: ");
}
}
sb.append(message.getText());
return sb.toString();
}
代码示例来源:origin: stackoverflow.com
public static void main(String[] args) {
Message message = new XmlMessage();
System.out.println(message.getText());
}
代码示例来源:origin: org.drools/drools-compiler
@Test
public void testDSLExpansion_MessageImplNPE() throws Exception {
final KieServices ks = KieServices.Factory.get();
final ReleaseId releaseId = ks.newReleaseId( "org.kie", "dsl-test", "1.0" );
final KieModuleModel kproj = ks.newKieModuleModel();
final KieFileSystem kfs = ks.newKieFileSystem();
kfs.writeKModuleXML( kproj.toXML() )
.writePomXML( generatePomXml( releaseId ) )
.write( "src/main/resources/KBase1/test-dsl.dsl", createDSL() )
.write( "src/main/resources/KBase1/test-rule.dslr", createDRL() );
final KieBuilder kieBuilder = ks.newKieBuilder( kfs );
final List<Message> messages = kieBuilder.buildAll().getResults().getMessages();
if ( !messages.isEmpty() ) {
for ( final Message m : messages ) {
System.out.println( m.getText() );
}
}
assertTrue( messages.isEmpty() );
}
代码示例来源:origin: org.drools/drools-compiler
@Test
public void testDSLExpansion_NoExpansion() throws Exception {
final KieServices ks = KieServices.Factory.get();
final ReleaseId releaseId = ks.newReleaseId( "org.kie", "dsl-test", "1.0" );
final KieModuleModel kproj = ks.newKieModuleModel();
final KieFileSystem kfs = ks.newKieFileSystem();
kfs.writeKModuleXML( kproj.toXML() )
.writePomXML( generatePomXml( releaseId ) )
.write( "src/main/resources/KBase1/test-dsl.dsl", createDSL() )
.write( "src/main/resources/KBase1/test-rule.drl", createDRL() );
final KieBuilder kieBuilder = ks.newKieBuilder( kfs );
final List<Message> messages = kieBuilder.buildAll().getResults().getMessages();
if ( !messages.isEmpty() ) {
for ( final Message m : messages ) {
System.out.println( m.getText() );
}
}
assertFalse( messages.isEmpty() );
}
代码示例来源:origin: org.drools/drools-workbench-models-guided-scorecard
public static void dumpMessages( final List<Message> messages ) {
if ( !messages.isEmpty() ) {
for ( Message m : messages ) {
System.out.println( m.getText() );
}
}
}
代码示例来源:origin: secbr/drools
public static void main(String[] args) {
KieServices kieServices = KieServices.Factory.get();
KieContainer container = kieServices.getKieClasspathContainer();
Results results = container.verify();
List<Message> messages = results.getMessages();
System.out.println("messages size:" + messages.size());
for (Message msg : messages) {
System.out.println("level:" + msg.getLevel() + ";text=" + msg.getText());
}
Collection<String> kieBaseNames = container.getKieBaseNames();
for(String kieBaseName : kieBaseNames){
System.out.println("kieBaseName----" + kieBaseName);
Collection<String> kieSessionNamesInKieBase = container.getKieSessionNamesInKieBase(kieBaseName);
for(String kieSession : kieSessionNamesInKieBase){
System.out.println("kieSession-----" + kieSession);
}
}
}
}
代码示例来源:origin: secbr/drools
protected static KieSession getKieSessionByDrl(String drlContent) {
KieHelper kieHelper = new KieHelper();
kieHelper.addContent(drlContent, ResourceType.DRL);
Results verify = kieHelper.verify();
boolean hasMessages = verify.hasMessages(Message.Level.WARNING, Message.Level.ERROR);
if (hasMessages) {
List<Message> messages = verify.getMessages(Message.Level.WARNING, Message.Level.ERROR);
for (Message message : messages) {
System.out.println("ERROR : " + message.getText());
}
throw new RuntimeException("verify has errors!");
}
return kieHelper.build().newKieSession();
}
代码示例来源:origin: stackoverflow.com
KieHelper kieHelper = new KieHelper();
for (String ruleId : drls.keySet()) {
kieHelper.addContent(drls.get(ruleId), ResourceType.DRL);
}
Results results = kieHelper.verify();
for (Message message : results.getMessages()) {
log.error(">> Message ({}): {}", message.getLevel(), message.getText());
}
if (results.hasMessages(Message.Level.ERROR)) {
throw new IllegalStateException("There are errors in the KB.");
}
KieSession ksession = kieHelper.build().newKieSession();
代码示例来源:origin: deepu105/drools-demo
private static String prettyBuildMessage(Message msg) {
return "Message: {"
+ "id="+ msg.getId()
+ ", level=" + msg.getLevel()
+ ", path=" + msg.getPath()
+ ", line=" + msg.getLine()
+ ", column=" + msg.getColumn()
+ ", text=\"" + msg.getText() + "\""
+ "}";
}
代码示例来源:origin: gratiartis/qzr
private static String prettyBuildMessage(Message msg) {
return "Message: {"
+ "id="+ msg.getId()
+ ", level=" + msg.getLevel()
+ ", path=" + msg.getPath()
+ ", line=" + msg.getLine()
+ ", column=" + msg.getColumn()
+ ", text=\"" + msg.getText() + "\""
+ "}";
}
代码示例来源:origin: deepu105/drools-demo
private static String prettyBuildMessage(Message msg) {
return "Message: {"
+ "id="+ msg.getId()
+ ", level=" + msg.getLevel()
+ ", path=" + msg.getPath()
+ ", line=" + msg.getLine()
+ ", column=" + msg.getColumn()
+ ", text=\"" + msg.getText() + "\""
+ "}";
}
代码示例来源:origin: org.kie.server/kie-server-services-common
private Message updateKieContainerToVersion(KieContainerInstanceImpl kci, ReleaseId releaseId) {
String containerId = kci.getContainerId();
Message response = null;
kci.clearExtraClasses();
kci.disposeMarshallers();
Results results = kci.getKieContainer().updateToVersion(releaseId);
if (results.hasMessages(Level.ERROR)) {
response = new Message(Severity.WARN, "Error updating releaseId for container " + containerId + " to version " + releaseId);
for (org.kie.api.builder.Message builderMsg : results.getMessages()) {
response.addMessage(builderMsg.getText());
}
logger.error("Error updating releaseId for container " + containerId + " to version " + releaseId + "\nMessages: " + results.getMessages());
} else {
kci.updateReleaseId();
response = new Message(Severity.INFO, "Kie container updated successfully to version " + releaseId);
}
return response;
}
代码示例来源:origin: org.kie/kie-spring
protected InternalKieModule createKieJar(KieServices ks, ReleaseId releaseId, List<String> resources, Map<String, String> extraResources ) {
KieFileSystem kfs = createKieFileSystemWithKProject(ks);
kfs.writePomXML( getPom(releaseId) );
for (String resource : resources) {
kfs.write("src/main/resources/KBase-test/" + resource, ResourceFactory.newClassPathResource(resource));
}
if (extraResources != null) {
for (Map.Entry<String, String> entry : extraResources.entrySet()) {
kfs.write(entry.getKey(), ResourceFactory.newByteArrayResource(entry.getValue().getBytes()));
}
}
KieBuilder kieBuilder = ks.newKieBuilder(kfs);
if (!kieBuilder.buildAll().getResults().getMessages().isEmpty()) {
for (Message message : kieBuilder.buildAll().getResults().getMessages()) {
logger.error("Error Message: ({}) {}", message.getPath(), message.getText());
}
throw new RuntimeException(
"There are errors builing the package, please check your knowledge assets!");
}
return ( InternalKieModule ) kieBuilder.getKieModule();
}
内容来源于网络,如有侵权,请联系作者删除!