本文整理了Java中org.kie.api.builder.Message.getPath()
方法的一些代码示例,展示了Message.getPath()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message.getPath()
方法的具体详情如下:
包路径:org.kie.api.builder.Message
类名称:Message
方法名:getPath
[英]Returns the path of the resource that caused the creation 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: wyh-spring-ecosystem-student/spring-boot-student
/**
* 加载KieContainer容器
*/
public static KieContainer loadKieContainer() throws RuntimeException {
//通过kmodule.xml 找到规则文件,这个文件默认放在resources/META-INF文件夹
log.info("准备创建 KieContainer");
if (kieContainer == null) {
log.info("首次创建:KieContainer");
// 设置drools的日期格式
System.setProperty("drools.dateformat", "yyyy-MM-dd HH:mm:ss");
//线程安全
synchronized (DroolsUtil.class) {
if (kieContainer == null) {
// 创建Container
kieContainer = kieServices.getKieClasspathContainer();
// 检查规则文件是否有错
Results results = kieContainer.verify();
if (results.hasMessages(Message.Level.ERROR)) {
StringBuffer sb = new StringBuffer();
for (Message mes : results.getMessages()) {
sb.append("解析错误的规则:").append(mes.getPath()).append(" 错误位置:").append(mes.getLine()).append(";");
}
throw new RuntimeException(sb.toString());
}
}
}
}
log.info("KieContainer创建完毕");
return kieContainer;
}
代码示例来源:origin: org.kie.guvnor/guvnor-commons-builder
public IncrementalBuildResults deleteResource( final Path resource ) {
//Check a full build has been performed
if ( !isBuilt() ) {
throw new IllegalStateException( "A full build needs to be performed before any incremental operations." );
}
//Delete resource
final String destinationPath = resource.toUri().toString().substring( projectPrefix.length() + 1 );
kieFileSystem.delete( destinationPath );
//Incremental build
final IncrementalResults incrementalResults = ( (InternalKieBuilder) kieBuilder ).createFileSet( destinationPath ).build();
//Messages from incremental build
final IncrementalBuildResults results = convertMessages( incrementalResults );
//Tidy-up removed message handles
for ( Message message : incrementalResults.getRemovedMessages() ) {
handles.remove( RESOURCE_PATH + "/" + message.getPath() );
}
return results;
}
代码示例来源:origin: org.kie.guvnor/guvnor-commons-builder
public IncrementalBuildResults addResource( final Path resource ) {
//Check a full build has been performed
if ( !isBuilt() ) {
throw new IllegalStateException( "A full build needs to be performed before any incremental operations." );
}
//Add new resource
final String destinationPath = resource.toUri().toString().substring( projectPrefix.length() + 1 );
final InputStream is = ioService.newInputStream( resource );
final BufferedInputStream bis = new BufferedInputStream( is );
kieFileSystem.write( destinationPath,
KieServices.Factory.get().getResources().newInputStreamResource( bis ) );
handles.put( destinationPath,
paths.convert( resource ) );
//Incremental build
final IncrementalResults incrementalResults = ( (InternalKieBuilder) kieBuilder ).createFileSet( destinationPath ).build();
//Messages from incremental build
final IncrementalBuildResults results = convertMessages( incrementalResults );
//Tidy-up removed message handles
for ( Message message : incrementalResults.getRemovedMessages() ) {
handles.remove( RESOURCE_PATH + "/" + message.getPath() );
}
return results;
}
代码示例来源: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.guvnor/guvnor-commons-builder
private BuildMessage convertMessage( final Message message ) {
final BuildMessage m = new BuildMessage();
switch ( message.getLevel() ) {
case ERROR:
m.setLevel( BuildMessage.Level.ERROR );
break;
case WARNING:
m.setLevel( BuildMessage.Level.WARNING );
break;
case INFO:
m.setLevel( BuildMessage.Level.INFO );
break;
}
m.setId( message.getId() );
m.setArtifactID( artifactId );
m.setLine( message.getLine() );
if ( message.getPath() != null && !message.getPath().isEmpty() ) {
m.setPath( handles.get( RESOURCE_PATH + "/" + message.getPath() ) );
}
m.setColumn( message.getColumn() );
m.setText( message.getText() );
return m;
}
代码示例来源:origin: org.jbpm/jbpm-test
protected InternalKieModule createKieJar(KieServices ks, ReleaseId releaseId, List<String> resources, Map<String, String> extraResources, ReleaseId... dependencies) {
KieFileSystem kfs = createKieFileSystemWithKProject(ks);
kfs.writePomXML(getPom(releaseId, dependencies));
DeploymentDescriptor customDescriptor = createDeploymentDescriptor();
if (extraResources == null) {
extraResources = new HashMap<String, String>();
}
if (customDescriptor != null) {
extraResources.put("src/main/resources/" + DeploymentDescriptor.META_INF_LOCATION, customDescriptor.toXml());
}
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();
}
代码示例来源:origin: org.kie/kie-dmn-core
@Test
public void testAPIUsage() {
// DROOLS-3335 Broken DMN resource should inhibit KJAR and report KieBuilder message
final KieServices ks = KieServices.Factory.get();
final KieContainer kieContainer = DMNRuntimeUtil.getKieContainerIgnoringErrors(ks.newReleaseId("org.kie", "dmn-test-" + UUID.randomUUID(), "1.0"),
ks.getResources().newClassPathResource("incomplete_expression.dmn", this.getClass()),
ks.getResources().newClassPathResource("duff.drl", this.getClass()));
Results verify = kieContainer.verify();
List<Message> kie_messages = verify.getMessages();
kie_messages.forEach(m -> LOG.info("{}", m));
assertThat(kie_messages.size(), is(3));
assertThat(kie_messages.stream().filter(m -> m.getPath().equals("duff.drl")).count(), is(2L));
List<DMNMessage> dmnMessages = kie_messages.stream()
.filter(DMNMessage.class::isInstance)
.map(DMNMessage.class::cast)
.collect(Collectors.toList());
assertThat(dmnMessages.size(), is(1));
DMNMessage dmnMessage = dmnMessages.get(0);
assertThat(dmnMessage.getSourceId(), is("_c990c3b2-e322-4ef9-931d-79bcdac99686"));
assertThat(dmnMessage.getMessageType(), is(DMNMessageType.ERR_COMPILING_FEEL));
assertThat(dmnMessage.getPath(), is("incomplete_expression.dmn"));
}
代码示例来源:origin: org.kie.workbench.services/kie-wb-common-services-backend
private void buildIncrementally(final IncrementalBuildResults results,
final String... destinationPath) {
try {
final IncrementalResults incrementalResults = ((InternalKieBuilder) kieBuilder).createFileSet(destinationPath).build();
results.addAllAddedMessages(convertMessages(incrementalResults.getAddedMessages(),
handles));
results.addAllRemovedMessages(convertMessages(incrementalResults.getRemovedMessages(),
handles));
//Tidy-up removed message handles
for (Message message : incrementalResults.getRemovedMessages()) {
handles.remove(Handles.RESOURCE_PATH + "/" + getBaseFileName(message.getPath()));
}
} catch (LinkageError e) {
final String msg = MessageFormat.format(ERROR_CLASS_NOT_FOUND,
e.getLocalizedMessage());
logger.warn(msg);
results.addAddedMessage(makeWarningMessage(msg));
} catch (Throwable e) {
final String msg = e.getLocalizedMessage();
logger.error(msg,
e);
results.addAddedMessage(makeErrorMessage(msg));
}
}
代码示例来源: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();
}
代码示例来源:origin: kiegroup/droolsjbpm-integration
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();
}
代码示例来源:origin: org.jbpm/jbpm-services-ejb-impl
protected static 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()));
}
}
kfs.write("src/main/resources/forms/DefaultProcess.ftl", ResourceFactory.newClassPathResource("repo/globals/forms/DefaultProcess.ftl"));
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: org.kie.workbench.services/kie-wb-common-services-backend
static BuildMessage convertMessage(final Message message,
Handles handles) {
final BuildMessage m = new BuildMessage();
switch (message.getLevel()) {
case ERROR:
m.setLevel(Level.ERROR);
break;
case WARNING:
m.setLevel(Level.WARNING);
break;
case INFO:
m.setLevel(Level.INFO);
break;
}
m.setId(message.getId());
m.setLine(message.getLine());
m.setPath(convertPath(message.getPath(),
handles));
m.setColumn(message.getColumn());
m.setText(convertMessageText(message));
return m;
}
内容来源于网络,如有侵权,请联系作者删除!