rest api - new asset file extension in guvnor
by Tihomir Surdilovic
Hi guys, I have a question about creating new assets in Guvnor via rest
api, specifically on how to set the file extension of the new asset.
My code is simple:
URL createURL = new URL(packageAssetsURL); // example url:
http://localhost:8080/drools-guvnor/rest/packages/defaultPackage/assets/M...
HttpURLConnection createConnection = (HttpURLConnection)
createURL.openConnection();
applyAuth(profile, createConnection);
createConnection.setRequestMethod("POST");
createConnection.setRequestProperty("Content-Type",
"application/octet-stream");
createConnection.setRequestProperty("Accept", "application/atom+xml");
createConnection.setRequestProperty("Slug", assetName); // assetName is
for example MyImage
createConnection.setDoOutput(true);
// apache batik streams the png image data
PNGTranscoder t = new PNGTranscoder();
TranscoderInput input = new TranscoderInput(new StringReader(svg));
TranscoderOutput output = new
TranscoderOutput(createConnection.getOutputStream());
t.transcode(input, output);
The MyImage asset gets created fine in Guvnor under defaultPackage, but
the file extension is .txt and not .png
If I specify the file extension in the "Slug" request property the file
created is for example MyImage.png.txt.
Is there any request property or anything else I need to set on the
connection to tell guvnor the actual file extension of the new asset??
Any input is much welcome.
Thanks.
13 years, 6 months
Locating objects by query/BC
by Wolfgang Laun
// This rule prints all objects in WM.
rule findObject
when
$o: Object()
then
System.out.println( "Object: " + $o );
end
Happily I get
Object: 42
Object: a String object
Object: org.drools.reteoo.InitialFactImpl@4dde85f0
Now the query way:
query object( Object o )
o := Object()
end
rule findObjectByQuery
when
object( $a ; )
then
System.out.println( "Object by query: " + $a );
end
Surprisingly, I get just one:
Object by query: org.drools.reteoo.InitialFactImpl@4dde85f0
A marvellous effect can be observed when the condition in rule
findObjectByQuery is modified to
when
Object()
object( $a ; )
then
I'd have guessed that the above result would appear repeatedly, once for
each Object in WM,
but that's not so. For N-1 facts the rule fires N*(N+1)/2 times, showing the
"initial object"
N times, the first inserted object N-1 times, the second one N-2 times and,
finally, the last one
once.
Object by query: 42
Object by query: org.drools.reteoo.InitialFactImpl@4dde85f0
Object by query: a String object
Object by query: 100
Object by query: 42
Object by query: org.drools.reteoo.InitialFactImpl@4dde85f0
Object by query: a String object
Object by query: org.drools.reteoo.InitialFactImpl@4dde85f0
Object by query: a String object
Object by query: org.drools.reteoo.InitialFactImpl@4dde85f0
-W
13 years, 6 months
drools-server exposing SOAP
by Rafael Liu
Hello Guys,
I'll be doing a Drools presentation and thought about a generic way to
create Decision Services automatically from a given package (that I would
probably host at Guvnor). After some research to avoid reinventing the
wheel, I stumbled on drools-server.
It seems it already have a way to almost-automatically publish a RESTful
endpoint, only changing XML. At the docs it says a SOAP endpoint will also
be made available, just the thing I was trying to do. So, I thought of
writing to the dev list asking how this is coming up? Maybe there's a not
snapshot I could try?
Ow, and GREAT work you all! Really amazing stuff
--
Rafael Liu
+55 61 9608-7722
http://rafaelliu.net
13 years, 6 months
Perhaps an undocumented feature of Backward Chaining?
by Wolfgang Laun
This is related to the example in 2.1.2.8., Backward Chaining.
Using the same rules and queries given there, the sequence of fact insertions
insert( new Here( "table" ) );
insert( new Edible( "peach" ) );
insert( new Location( "peach", "table" ) );
results in nothing being seen and nothing being edible, whereas
insert( new Edible( "peach" ) );
insert( new Location( "peach", "table" ) );
insert( new Here( "table" ) );
results in the obvious and expected result.
There is no difference w.r.t. using '?' in front of query names.
-W
13 years, 6 months
Houston, TX Drools Architect
by James Burns
We have a key project, and we are looking for Drools experts in Houston, or
perhaps Austin, Texas.
If you know of someone or group that would make sense for us to contract
with or hire, please have them send over some background information.
Thanks
Jim Burns
13 years, 6 months
Drools 5.2.0.Final released
by Geoffrey De Smet
The Drools community is happy to announce the release of *Drools
5.2.0.Final*.
This includes:
* Drools Expert (rule engine)
* Drools Fusion (CEP: complex event processing)
* Drools Planner (planning optimization)
* Guvnor (BRMS web application)
* Drools IDE (Eclipse plugin)
Read the release announcement:
http://blog.athico.com/2011/06/drools-52-released.html
--
With kind regards,
The Drools team
13 years, 6 months
Another MVEL puzzle
by Wolfgang Laun
rule x
when
# ... bind 2 int and 2 long, making sure that
# $int1 == 1 and $int3 == 65536...
eval( $int1 == $long2 == $int3 == $long4 )
then
// print all 4 values
end
Using dialect "java" this results in a syntax error, which is to be
expected.
Dialect "mvel" evaluates this to true for a surprising range of integer
values.
Here is a selection:
1 1 65536 1234567890
1 1 65536 424242
1 1 65536 65536
1 1 65536 4294967296
1 1 65536 65568
1 1 65536 65552
Is there any logic behind this?
-W
13 years, 6 months
New version numbering: 5.2.0.Final, 5.3.0.Beta1, 5.3.0.Beta2, 5.3.0.CR1, 5.3.0.Final, ...
by Geoffrey De Smet
Hi guys,
To avoid OSGi trouble (both for the eclipse plugin and the
osgi-bundles), we're now following the JBoss project version conventions:
http://community.jboss.org/wiki/JBossProjectVersioning
So the version will now follow any of these scheme's:
major.minor.micro.Alpha*[*/*n]*/*/
/*major.minor.micro.Beta*/[n]
/*major.minor.micro.CR*/[n]
/*major.minor.micro.Final
So this means we will now use: 5.2.0.Final, 5.3.0.Beta1, 5.3.0.Beta2,
5.3.0.CR1, 5.3.0.Final, ...
And we will *not* use: 5.2.0, 5.3.0.M1, ...
--
With kind regards,
Geoffrey De Smet
13 years, 6 months
Changing a fact's hashCode causes rules not to fire
by Wolfgang Laun
To avoid misunderstandings: yes, equals() is written according to hashCode,
i.e., according to the usual Java conventions.
If
- an object of class Two contains a member of class One, and
- one object Two and one object One are facts, and
- a rule modifies One, changing its hashCode
then
another rule containing the patterns
$one: One()
$two: Two( $x: one == $one )
does NOT fire (any more).
If you use the constraint
one == $one || != $one
the rule will fire, and you can observe that hashCode results for $one and
$x are the same and that $one.equals( $x ) returns true.
Reproduced using 5.1.1 and 5.2.x
-W
13 years, 6 months