I devloped a custom rule editor able to create drl file and save them in file system under a given directory. (e.g. c:\savedRules\rule.drl).
The problem is that once the rule is saved I need to run it with drools engine.
In my class I try to load rule in this way:
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource("c:\savedRules\rule.drl"), ResourceType.DRL);
but its doesn't work. the exception is "rule.drl cannot be opened because it does not exist" but it actually exists....
What am I doing wrong? Is there another way to load rules directly from file system?
Try using,
FileInputStream fis = new FileInputStream(drlFile);
kbuilder.add(ResourceFactory.newInputStreamResource(fis), ResourceType.DRL);
Thanks.
kbuilder.add(ResourceFactory.newClassPathResource("LoopConditionRules.drl"),ResourceType.DRL);
Just add this line and copy your drl file in resource folder of the project, when you will run it will automatically find the file from the project there is no need to give specific path for your file.
Try this way, may be you can get your required result.
Try the below code, this will work.
kbuilder.add(ResourceFactory.newFileResource(drlFileName), ResourceType.DRL);
Related
I moved file to another folder if file exist with that name it 's raise error "file already exist". How can i overwrite it to the exist one using move action?
Here is example of same whatever you want to achive but different way.
Might be you will get some idea from that.
https://github.com/keensoft/alfresco-version-by-name
I can't find it in the documentation : Silverstripe-behat-extension
I have a feature file that has some testing scripts. Now I want to fill some test content in a temp database.
So I create a yml file that puts the content in the database.
But how do I load the yml file in my features file?
In your feature use:
Background:
Given a file "/absolute/path/my-data-fixture.yml"
I'm using grunt-init to build a template for a site structure I repeat regularly.
The template.js file uses the init.copyAndProcess function to customize most of files but a few of them get corrupted by the file processing (some fonts and image files) and I want to include those files in the 'noProcess' option. If these files all existed in the same directory, I could use the noProcess option as mentioned in the documentation [ See: http://gruntjs.com/project-scaffolding#copying-files ] and pass in a string like and it works:
var files = init.filesToCopy(props);
init.copyAndProcess(files, props, {noProcess: 'app/fonts/**'} );
Unfortunately the files that I need to have no processing performed on are not all in the same directory and I'd like to be able to pass in an array of them, something like the following block of code, but this does not work.
var files = init.filesToCopy(props);
init.copyAndProcess(files, props, {noProcess: ['app/fonts/**', 'app/images/*.png', 'app/images/*.jpg']} );
Any thoughts on how I can have multiple targets for the 'noProcess' option?
As soon as I posted the question, I realized that my proposed code did work. I simply had an invalid path when I'd renamed my 'app' directory to 'dev'.
If I use the write method, where will these files be written? Example:
write(results, file="myFile.csv", ncolumns=1)
I don't specify a full path so I assume it's writing to some default directory. I checked program files, but it's not there. Suggestions on where to look?
If you type from within your R session:
getwd()
You should be able to retrieve your current working directory, that's the place where the files should be saved to.
You can also choose to set your workspace to a location of your desire:
setwd('C:/Users/.../Documents/R/Scripts')
Files you save will automatically be written to this new location.
I try to guard a file, which I save from a form, in a path I specify. I use file_directory_path that returns the path to default, what do i do to change the path or to modify it to personalize it?
Code that this done but it does not function
$filepath='/sites/ficheros_profesores';
// str_replace(file_directory_path(),'',$filepath);
$file = file_save_upload('test',null,file_directory_path());
file_set_status($file, FILE_STATUS_PERMANENT);
Thanks
If I properly understood, you are trying to save the uploaded file in a folder which is inside the default 'files' directory, isn't it?
Instead str_replace, you could concatenate the strings with '.'. Simply:
$file = file_save_upload('test',null,file_directory_path().'/sites/ficheros_profesores');
You should then ensure that the '/sites/ficheros_profesores/' exists and that the 'www-data' user (asuming linux) has the proper permissions.
Hope it helps.