Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DROOLS-1663 Kie DMN doesn't support IMPORT decisions between DMN files #300

Merged
merged 6 commits into from
Mar 27, 2018
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,24 @@

package org.kie.api.internal.assembler;

import java.util.Collection;

import org.kie.api.internal.utils.KieService;
import org.kie.api.io.Resource;
import org.kie.api.io.ResourceConfiguration;
import org.kie.api.io.ResourceType;
import org.kie.api.io.ResourceWithConfiguration;

public interface KieAssemblerService extends KieService {
ResourceType getResourceType();

default void addResources(Object kbuilder, Collection<ResourceWithConfiguration> resources, ResourceType type) throws Exception {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume there is no suitable interface/class that could be used here instead of Object?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@winklerm correct, and this is for consistency with the other method in class KieAssemblerService

for (ResourceWithConfiguration rd : resources) {
rd.getBeforeAdd().accept(kbuilder);
addResource(kbuilder, rd.getResource(), type, rd.getResourceConfigutation());
rd.getAfterAdd().accept(kbuilder);
}
}

void addResource(Object kbuilder, Resource resource, ResourceType type, ResourceConfiguration configuration) throws Exception;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package org.kie.api.io;

import java.util.function.Consumer;

import org.kie.api.internal.assembler.KieAssemblerService;

/**
* Represent a tuple of a {@link Resource} with associated {@link ResourceConfiguration}, along with necessary kbuilder callbacks, to be used in in {@link KieAssemblerService}.
*/
public interface ResourceWithConfiguration {

Resource getResource();

ResourceConfiguration getResourceConfigutation();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix the typo in getResourceConfigutation.


/**
* callback executed on `kbuilder` as a paramenter in {@link KieAssemblerService}, which will be executed before performing {@link KieAssemblerService#addResource(Object, Resource, ResourceType, ResourceConfiguration)} for the given resource {@link #getResource()}.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix the typo in paramenter.

*/
Consumer<Object> getBeforeAdd();

/**
* callback executed on `kbuilder` as a paramenter in {@link KieAssemblerService}, which will be executed after performing {@link KieAssemblerService#addResource(Object, Resource, ResourceType, ResourceConfiguration)} for the given resource {@link #getResource()}.
*/
Consumer<Object> getAfterAdd();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package org.kie.internal.io;

import java.util.function.Consumer;

import org.kie.api.internal.assembler.KieAssemblerService;
import org.kie.api.io.Resource;
import org.kie.api.io.ResourceConfiguration;
import org.kie.api.io.ResourceType;
import org.kie.api.io.ResourceWithConfiguration;

public class ResourceWithConfigurationImpl implements ResourceWithConfiguration {

private final Resource resource;
private final ResourceConfiguration resourceConfiguration;
private final Consumer<Object> beforeAdd;
private final Consumer<Object> afterAdd;

/**
*
* @param resource
* @param resourceConfiguration
* @param beforeAdd callback executed on `kbuilder` as a paramenter, which will be executed before performing {@link KieAssemblerService#addResource(Object, Resource, ResourceType, ResourceConfiguration)} for the given resource {@link #resource}
* @param afterAdd callback executed on `kbuilder` as a paramenter, which will be executed after performing {@link KieAssemblerService#addResource(Object, Resource, ResourceType, ResourceConfiguration)} for the given resource {@link #resource}
*/
public ResourceWithConfigurationImpl(Resource resource, ResourceConfiguration resourceConfiguration, Consumer<Object> beforeAdd, Consumer<Object> afterAdd) {
this.resource = resource;
this.resourceConfiguration = resourceConfiguration;
this.beforeAdd = beforeAdd;
this.afterAdd = afterAdd;
}

@Override
public Resource getResource() {
return resource;
}

@Override
public ResourceConfiguration getResourceConfigutation() {
return resourceConfiguration;
}

@Override
public Consumer<Object> getBeforeAdd() {
return beforeAdd;
}

@Override
public Consumer<Object> getAfterAdd() {
return afterAdd;
}

}