On 2011/5/6 2:33, Vincent LEGENDRE wrote:
I am not sure if I understand you correctly. You want to return a
compiled package binary based on certain criteria or you want to
return individual assets based on certain criteria?
The main objective is the first one : get compiled package including
filtred assert on certain criteria
But if I can do the second (get all assets having certain criteria), I
can compile it myself.
If its the former, you can do this through Guvnor REST API (to be
precise, it is the new JAX-RS based REST api). In this case, you dont
provide filters through the URL. When you hit the REST URL for example
http://localhost:8080/drools-guvnor/rest/packages/mortgage, the REST
service will first check if this package's binary is up-to-date. If
not, it will build the package first, then return compiled binary. It
is the Guvnor selector in charge of which assets get into the build.
At the moment, we dont have a REST API to control which selector is
taking effect during the build, but if this is what you need, I am
sure we can figure this out.
It is exactly that : be able to choose the filter used to compile the
package.
If what you want is to return individual assets, you can send a HTTP
GET request to URL
http://host:portnumber/drools-guvnor/rest/packages/mortgage/assets
<
http://community.jboss.org/docs/DOC-16217>with
Accept="application/atom+xml", this returns a list of assets under the
mortgage package in Atom feed format.
/.../
For example a GET request to
http://host:portnumber/
<
http://community.jboss.org/docs/DOC-16217>drools-guvnor/rest
<
http://localhost:9080/repository/packages/testPackage1/assets>/package...
<
http://localhost:9080/repository/packages/packageName/asset/testAsset2>...
<
http://community.jboss.org/docs/DOC-16217>with
Accept="application/atom+xml" returns an atom entry which is the meta
data info of that asset.
The links you provide and these sample seems really great to access
some internal values of repository, and even do updates to
programmatically ... but ... I can't get it work ... may be I hit my
limits on web-base things here ... So lots of questions :
- I don't understand when you say "with
Accept="application/atom+xml" : what is "with" ? URL parameters like
http://host:portnumber/drools-guvnor/rest/packages/mortgage/assets
<
http://community.jboss.org/docs/DOC-16217>?Accept="application/at...
? Guess not according to what you say after. So what is "with", how do
you provide these args to the URL ?
This is an example code of how you set up HTTP
headers on your client side:
URL url = new
URL("http://localhost:8080/drools-guvnor/rest/packages/mortgage");
HttpURLConnection connection =
(HttpURLConnection)url.openConnection();
connection.setRequestMethod("GET");
connection.setRequestProperty("Accept",
MediaType.APPLICATION_ATOM_XML);
connection.connect();
assertEquals (200, connection.getResponseCode());
assertEquals(MediaType.APPLICATION_ATOM_XML,
connection.getContentType());
- when I try the URL given "as this" (
http://host:portnumber/drools-guvnor/rest/packages/mortgage/assets
<
http://community.jboss.org/docs/DOC-16217> ) tomcat replies that
there is no service. I get something to work with this URL
http://localhost:8080/drools-5.2.0.M1-guvnor/org.drools.guvnor.Guvnor/api...
, ie adding "org.drools.guvnor.Guvnor", with "api" instead of
"rest",
and without "assets" (which tells me that the "assets" is not a valid
path). Does this mean that I am not running the correct version ? Need
to deploy something else ? Need to configure something ?
In your case the URL should be
http://localhost:8080/drools-5.2.0.M1-guvnor/rest/packages/mortgages/assets
<about:blank>
The new JAX-Rs based REST interface is available from 5.2.0.M1. The URL
starts with
http://localhost:8080/drools-5.2.0.M1-guvnor/org.drools.guvnor.Guvnor/api/
<about:blank> etc is the old non-Jax-RS based implementation and will be
deprecated later.
<about:blank>
- with my URL form, I can get the content of a package (raw text,
one resource by line) like this :
drools.package=2008-09-30T03:36:29,1
MortgageModel.model.drl=2008-10-22T22:01:14,6
Underage.brl=2008-10-01T04:54:34,2
...
- or one rule
(
http://localhost:8080/drools-5.2.0.M1-guvnor/org.drools.guvnor.Guvnor/api...)
:
<rule>
<name>RegexDslRule</name>
<modelVersion>1.0</modelVersion>
<attributes/>
<metadataList/>
<lhs>
<dslSentence>
<sentence>When the ages is less than {57:1?[0-9]?[0-9]}</sentence>
</dslSentence>
</lhs>
<rhs/>
</rule>
I noticed a metadataList there, but empty ... and I explicitely set
some metadata in that rule in guvnor before query it. What should go
there ? Annotations ?
JAX-RS does support query using URL like
http://host:portnumber/drools-guvnor/rest/packages/mortgage/assets
<
http://community.jboss.org/docs/DOC-16217>?category=foo&category=b...
(and several other query mechanisms). But we have not implemented
query in Guvnor yet. Of course you will be very welcome if you want to
help ;-)
Yep why not ... if you don't find my previous questions too stupid :)
For now we will try to make the business user arrange their rules
directly in different packages and then query the package "as usual"
for each rule app we have
But it is quite sure that this won't fit their needs in a real living
application where rules numbers will grow .... as for rule apps
Thanks a lot for you time anyway
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users