Search in sources :

Example 1 with ResourceTypeDeclarationWarning

use of org.drools.compiler.compiler.ResourceTypeDeclarationWarning in project drools by kiegroup.

the class KnowledgeBuilderImpl method registerBuildResource.

public void registerBuildResource(final Resource resource, ResourceType type) {
    InternalResource ires = (InternalResource) resource;
    if (ires.getResourceType() == null) {
        ires.setResourceType(type);
    } else if (ires.getResourceType() != type) {
        addBuilderResult(new ResourceTypeDeclarationWarning(resource, ires.getResourceType(), type));
    }
    if (ResourceType.CHANGE_SET == type) {
        try {
            ChangeSet changeSet = parseChangeSet(resource);
            List<Resource> resources = new ArrayList<>();
            resources.add(resource);
            resources.addAll(changeSet.getResourcesAdded());
            resources.addAll(changeSet.getResourcesModified());
            resources.addAll(changeSet.getResourcesRemoved());
            buildResources.push(resources);
        } catch (Exception e) {
            results.add(new DroolsError() {

                public String getMessage() {
                    return "Unable to register changeset resource " + resource;
                }

                public int[] getLines() {
                    return new int[0];
                }
            });
        }
    } else {
        buildResources.push(Collections.singletonList(resource));
    }
}
Also used : InternalResource(org.drools.core.io.internal.InternalResource) DroolsError(org.drools.drl.parser.DroolsError) BaseResource(org.drools.core.io.impl.BaseResource) DescrResource(org.drools.core.io.impl.DescrResource) ClassPathResource(org.drools.core.io.impl.ClassPathResource) Resource(org.kie.api.io.Resource) ReaderResource(org.drools.core.io.impl.ReaderResource) InternalResource(org.drools.core.io.internal.InternalResource) ArrayList(java.util.ArrayList) ResourceTypeDeclarationWarning(org.drools.compiler.compiler.ResourceTypeDeclarationWarning) ChangeSet(org.kie.internal.ChangeSet) DroolsParserException(org.drools.drl.parser.DroolsParserException) InvocationTargetException(java.lang.reflect.InvocationTargetException) UncheckedIOException(java.io.UncheckedIOException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) MissingImplementationException(org.drools.compiler.builder.impl.errors.MissingImplementationException) SAXException(org.xml.sax.SAXException) ExpanderException(org.drools.drl.parser.lang.ExpanderException)

Aggregations

IOException (java.io.IOException)1 UncheckedIOException (java.io.UncheckedIOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ArrayList (java.util.ArrayList)1 ExecutionException (java.util.concurrent.ExecutionException)1 MissingImplementationException (org.drools.compiler.builder.impl.errors.MissingImplementationException)1 ResourceTypeDeclarationWarning (org.drools.compiler.compiler.ResourceTypeDeclarationWarning)1 BaseResource (org.drools.core.io.impl.BaseResource)1 ClassPathResource (org.drools.core.io.impl.ClassPathResource)1 DescrResource (org.drools.core.io.impl.DescrResource)1 ReaderResource (org.drools.core.io.impl.ReaderResource)1 InternalResource (org.drools.core.io.internal.InternalResource)1 DroolsError (org.drools.drl.parser.DroolsError)1 DroolsParserException (org.drools.drl.parser.DroolsParserException)1 ExpanderException (org.drools.drl.parser.lang.ExpanderException)1 Resource (org.kie.api.io.Resource)1 ChangeSet (org.kie.internal.ChangeSet)1 SAXException (org.xml.sax.SAXException)1