<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#ffffff" text="#000000">
    On 2011/5/5 20:13, Vincent LEGENDRE wrote:
    <blockquote
cite="mid:1937742691.10646.1304597589816.JavaMail.root@confiance.eurodecision.fr"
      type="cite">
      <pre wrap="">Ok, thanks

I had a look to this, and indeed you can query indiviual resource, or get a list of resources in one package.
But If i understand well you idea, it is still necessary to compile manually some package using filters, and put then into separate snapshots by instance.

I think it is really close to what I need, but I need to provide the filter in a query to get filtered assets (results got from REST query looses the Guvnor metadata, it only returns asset's content). 
Something like this would be perfect :
   <a class="moz-txt-link-freetext" href="http://localhost:8080/path/to/guvnor/api/packages/my.sample.package?category=foo&amp;category=bar&amp;status=prod">http://localhost:8080/path/to/guvnor/api/packages/my.sample.package?category=foo&amp;category=bar&amp;status=prod</a>
-&gt; return the list of assert having categories "foo" and "bar" and status set to "prod"<big><big><big></big></big></big>
</pre>
    </blockquote>
    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? <br>
    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 <a class="moz-txt-link-freetext" href="http://localhost:8080/drools-guvnor/rest/packages/mortgage">http://localhost:8080/drools-guvnor/rest/packages/mortgage</a>,
    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.<br>
    <br>
    <blockquote
cite="mid:1937742691.10646.1304597589816.JavaMail.root@confiance.eurodecision.fr"
      type="cite">
      <pre wrap="">I am not familiar with feeds, but the last XML sample of your link seems to allow some filtering ? Or is it just metadata set in the package ? Or it is possible to create feed with filtered assets, and then query them (that would be perfect too).


</pre>
    </blockquote>
    If what you want is to return individual assets, you can send a HTTP
    GET request to URL <a class="jive-link-wiki-small"
      href="http://community.jboss.org/docs/DOC-16217" target="_blank">http://host:portnumber/drools-guvnor/rest/packages/mortgage/assets</a>
    with Accept="application/atom+xml", this returns a list of assets
    under the mortgage package in Atom feed format. An example looks
    like below: <br>
    <p>&lt;feed xmlns="<a class="jive-link-external-small"
        href="http://www.w3.org/2005/Atom" target="_blank">http://www.w3.org/2005/Atom</a>"
      xmlns:xml="<a class="jive-link-external-small"
        href="http://www.w3.org/XML/1998/namespace" target="_blank">http://www.w3.org/XML/1998/namespace</a>"
      xml:base="<a class="jive-link-external-small"
        href="http://localhost:9080/repository/packages/testPackage1/assets"
        target="_blank">http://localhost:9080/</a><a
        class="jive-link-external-small"
        href="http://localhost:9080/repository/packages/testPackage1/assets"
        target="_blank">drools-guvnor/rest</a><a
        class="jive-link-external-small"
        href="http://localhost:9080/repository/packages/testPackage1/assets"
        target="_blank">/packages/mortgage/assets</a>"&gt;<br>
         &lt;title&gt;testPackage1's asset&lt;/title&gt;</p>
    <p>   &lt;entry xml:base="<a class="jive-link-external-small"
        href="http://localhost:9080/repository/packages/testPackage1/assets"
        target="_blank">http://localhost:9080/drools-guvnor/rest/packages/</a><a
        class="jive-link-external-small"
href="http://localhost:9080/repository/packages/packageName/asset/testAsset2"
        target="_blank">mortgage</a><a class="jive-link-external-small"
href="http://localhost:9080/repository/packages/testPackage1/assets"
        target="_blank">/assets</a>"&gt;<br>
           &lt;title&gt;testAsset1&lt;/title&gt;<br>
           &lt;link href="<a class="jive-link-external-small"
href="http://localhost:9080/repository/packages/packageName/asset/testAsset1"
        target="_blank">http://localhost:9080/</a><a
        class="jive-link-external-small"
        href="http://localhost:9080/repository/packages/testPackage1/assets"
        target="_blank">drools-guvnor/rest</a><a
        class="jive-link-external-small"
href="http://localhost:9080/repository/packages/packageName/asset/testAsset1"
        target="_blank">/packages/</a><a
        class="jive-link-external-small"
href="http://localhost:9080/repository/packages/packageName/asset/testAsset2"
        target="_blank">mortgage</a><a class="jive-link-external-small"
href="http://localhost:9080/repository/packages/packageName/asset/testAsset1"
        target="_blank">/assets/testAsset1</a>" /&gt;<br>
         &lt;/entry&gt;</p>
    <p>    &lt;entry xml:base="<a class="jive-link-external-small"
        href="http://localhost:9080/repository/packages/testPackage1/assets"
        target="_blank">http://localhost:9080/</a><a
        class="jive-link-external-small"
        href="http://localhost:9080/repository/packages/testPackage1/assets"
        target="_blank">drools-guvnor/rest</a><a
        class="jive-link-external-small"
        href="http://localhost:9080/repository/packages/testPackage1/assets"
        target="_blank">/packages/</a><a
        class="jive-link-external-small"
href="http://localhost:9080/repository/packages/packageName/asset/testAsset2"
        target="_blank">mortgage</a><a class="jive-link-external-small"
href="http://localhost:9080/repository/packages/testPackage1/assets"
        target="_blank">/assets</a>"&gt;<br>
           &lt;title&gt;testAsset2&lt;/title&gt;<br>
           &lt;link href="<a class="jive-link-external-small"
href="http://localhost:9080/repository/packages/packageName/asset/testAsset2"
        target="_blank">http://localhost:9080/</a><a
        class="jive-link-external-small"
        href="http://localhost:9080/repository/packages/testPackage1/assets"
        target="_blank">drools-guvnor/rest</a><a
        class="jive-link-external-small"
href="http://localhost:9080/repository/packages/packageName/asset/testAsset2"
        target="_blank">/packages/mortgage/assets/testAsset2</a>" /&gt;<br>
         &lt;/entry&gt;<br>
      &lt;/feed&gt;<br>
    </p>
    <p>Then you can further navigate to individual assets using the link
      returned. For example a GET request to <a
        class="jive-link-wiki-small"
        href="http://community.jboss.org/docs/DOC-16217" target="_blank">http://host:portnumber/</a><a
        class="jive-link-external-small"
        href="http://localhost:9080/repository/packages/testPackage1/assets"
        target="_blank">drools-guvnor/rest</a><a
        class="jive-link-external-small"
href="http://localhost:9080/repository/packages/packageName/asset/testAsset2"
        target="_blank">/packages/mortgage/assets</a><a
        class="jive-link-wiki-small"
        href="http://community.jboss.org/docs/DOC-16217" target="_blank">/testAsset1</a>
      with Accept="application/atom+xml" returns an atom entry which is
      the meta data info of that asset. Or URL <a
        class="jive-link-wiki-small"
        href="http://community.jboss.org/docs/DOC-16217" target="_blank">http://host:portnumber/</a><a
        class="jive-link-external-small"
        href="http://localhost:9080/repository/packages/testPackage1/assets"
        target="_blank">drools-guvnor/rest</a><a
        class="jive-link-external-small"
href="http://localhost:9080/repository/packages/packageName/asset/testAsset2"
        target="_blank">/packages/mortgage/assets</a><a
        class="jive-link-wiki-small"
        href="http://community.jboss.org/docs/DOC-16217" target="_blank">/testAsset1/source</a>
      to return source and URL <a class="jive-link-wiki-small"
        href="http://community.jboss.org/docs/DOC-16217" target="_blank">http://host:portnumber/</a><a
        class="jive-link-external-small"
        href="http://localhost:9080/repository/packages/testPackage1/assets"
        target="_blank">drools-guvnor/rest</a><a
        class="jive-link-external-small"
href="http://localhost:9080/repository/packages/packageName/asset/testAsset2"
        target="_blank">/packages/mortgage/assets</a><a
        class="jive-link-wiki-small"
        href="http://community.jboss.org/docs/DOC-16217" target="_blank">/testAsset1/binary</a>
      to return binary content.<br>
    </p>
    <p>JAX-RS does support query using URL like <a
        class="jive-link-wiki-small"
        href="http://community.jboss.org/docs/DOC-16217" target="_blank">http://host:portnumber/drools-guvnor/rest/packages/mortgage/assets</a>?category=foo&amp;category=bar&amp;status=prod
      (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 ;-)</p>
    <p>
      For more information about Guvnor REST interface please check:
      <a class="moz-txt-link-freetext" href="http://blog.athico.com/2011/03/atompub-interface-for-guvnor.html">http://blog.athico.com/2011/03/atompub-interface-for-guvnor.html</a>
      and <a class="moz-txt-link-freetext" href="http://community.jboss.org/wiki/AtomPubinterfaceforGuvnor">http://community.jboss.org/wiki/AtomPubinterfaceforGuvnor</a><br>
      <br>
    </p>
    <p>Cheers,<br>
      Jervis<br>
      <br>
    </p>
    <blockquote
cite="mid:1937742691.10646.1304597589816.JavaMail.root@confiance.eurodecision.fr"
      type="cite">
      <pre wrap="">Otherwise I think I di have to write my own servlet doing that (like Michael suggests), or find another solution.



----- Mail original -----
De: "Jervis Liu" <a class="moz-txt-link-rfc2396E" href="mailto:jliu@redhat.com">&lt;jliu@redhat.com&gt;</a>
À: <a class="moz-txt-link-abbreviated" href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a>
Envoyé: Jeudi 5 Mai 2011 04:48:45
Objet: Re: [rules-users] Guvnor service to compile part of a package ?

On 2011/5/4 22:57, Vincent Legendre wrote:
</pre>
      <blockquote type="cite">
        <pre wrap="">Hi all,

I am looking for a clever way to compile only parts of a Guvnor package
according to some criteria on items (categories, metadata ...), but
outside Guvnor if possible.
The main idea starts by the fact that it is a little bit complex for a
business user to manage packages and compilations, and even more if he
has to manage conditional compilations (using selectors) of a single
package to produce multiple KB compiled according to business criterions.

I want to compile automatically some KB according to categories (more
generally asset's fields) with something external to Guvnor. Thus I need
a way to query Guvnor repository with criterion to get either :
      - the corresponding ressources (DRL)
      - the filtered compiled KB (PKG ressource)
Filtering with DRL (like custom selectors in Guvnor) will be perfect,
using a custom class too.

Is there such service ?
Does the KnowledgeAgent allow filtering (did not see anything in docs) ?
</pre>
      </blockquote>
      <pre wrap="">Not sure about KnowledgeAgent, I ll leave this question to someone more 
familiar with KnowledgeAgent. At the same time, you can probably use 
Guvnor REST service to achieve same goal. Check this example: 
<a class="moz-txt-link-freetext" href="http://community.jboss.org/wiki/PublishDroolsartifactsfromaproductionenvironment">http://community.jboss.org/wiki/PublishDroolsartifactsfromaproductionenvironment</a>. 
This example polls package feed periodically to check if there is a new 
version of package available. If there is a new version created, it will 
download the package compiled binary. Package binary is compiled against 
selectors, so it is filtered as you need.

Cheers,
Jervis





</pre>
      <blockquote type="cite">
        <pre wrap="">Or do I need to add a new service in Guvnor war directly ?

Thanks!
_______________________________________________
rules-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a>
<a class="moz-txt-link-freetext" href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a>
</pre>
      </blockquote>
      <pre wrap="">
_______________________________________________
rules-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a>
<a class="moz-txt-link-freetext" href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a>

_______________________________________________
rules-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a>
<a class="moz-txt-link-freetext" href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>