<?xml version="1.0" encoding="ISO-8859-1"?>
<cookbook xmlns:al="http://www.logilab.org/namespaces/Narval/1.2">

<al:group-alias name="kb-backend" actual="PyLogDB"/>

<al:recipe name="xmlrdf-export">
  <al:description lang="en">
    Export the knowledge base as XML-RDF
  </al:description>
  <al:step id="s1" type="action" target="kb-backend.export-stmts"/>
  <al:step id="s2" type="action" target="AlRDF.stmts2xmlrdf"/>
  <al:transition id="t1">
    <al:in idref="s1"/>
    <al:out idref="s2"/>
  </al:transition>
</al:recipe>


<al:recipe name="xmlrdf-import">
  <al:description lang="en">
    Import XML-RDF into the knowledge base
  </al:description>
  <al:step id="s1" type="action" target="RedLand.import-string"/>
<!--
  <al:step id="s1" type="action" target="AlRDF.xmlrdf2stmts"/>
  <al:step id="s2" type="action" target="kb-backend.add-stmts"/>
  <al:transition id="t1">
    <al:in idref="s1"/>
    <al:out idref="s2"/>
  </al:transition>
 -->
</al:recipe>


<!-- FIXME: we should use xmlrdf-import, no ? -->
<al:recipe name="foaf-import">
  <al:description lang="en">
    Import FOAF XML-RDF into the knowledge base
  </al:description>
  <al:step id="s1" type="action" target="RedLand.import-url"/>
  <al:step id="s2" type="action" target="Chat.data2msg">
    <al:input id='response' to_context="step" list="yes">
      <al:match>IData(elmt)</al:match>
    </al:input>
  </al:step>
  <al:transition id="t1">
    <al:in idref="s1"/>
    <al:out idref="s2"/>
  </al:transition>
</al:recipe>


<al:recipe name="show-foaf">
  <al:description lang="en">
    show the user's foaf file
  </al:description>
  <al:step id="s1" type="action" target="Basic.read-file">
    <al:input id="to-read">
      <al:match>IURL(elmt)</al:match>
      <al:match>elmt.getattr((TYPE_NS, 'name')) == 'uri:memory:foaf'</al:match>
    </al:input>
  </al:step>
  <al:step id="s2" type="action" target="Chat.data2msg"/>
  <al:transition id="t1">
    <al:in idref="s1"/>
    <al:out idref="s2"/>
  </al:transition>
</al:recipe>


<al:recipe name="add-rule-from-text">
  <al:description lang="en">
    Add rule from text
  </al:description>
  <al:step id="s1" type="action" target="AlRDF.text2rule"/>
  <al:step id="s2" type="action" target="kb-backend.add-rule"/>
  <al:transition id="t1">
    <al:in idref="s1"/>
    <al:out idref="s2"/>
  </al:transition>
</al:recipe>


<al:recipe name="search-stmts">
  <al:step id="s1" type="action" target="kb-backend.search-stmts"/>
  <al:step id="s2" type="action" target="Chat.data2msg">
    <al:input id='response' to_context="step" list="yes">
      <al:match>IData(elmt)</al:match>
    </al:input>
  </al:step>
  <al:transition id="t1">
    <al:in idref="s1"/>
    <al:out idref="s2"/>
  </al:transition>
</al:recipe>


<al:recipe name="rdql-search-stmts">
  <al:step id="s1" type="action" target="RedLand.rdql-query"/>
  <al:step id="s2" type="action" target="Chat.data2msg">
    <al:input id='response' to_context="step" list="yes">
      <al:match>IData(elmt)</al:match>
    </al:input>
  </al:step>
  <al:transition id="t1">
    <al:in idref="s1"/>
    <al:out idref="s2"/>
  </al:transition>
</al:recipe>


<al:recipe name="register-user">
  <al:description lang="en">
    Register found users
  </al:description>
  <al:step id="s1" type="action" target="AlRDF.stmts-for-user-info"/>
  <al:step id="s2" type="action" target="kb-backend.add-stmts"/>
  <al:transition id="t1">
    <al:in idref="s1"/>
    <al:out idref="s2"/>
  </al:transition>
</al:recipe>


<al:recipe name="respond-to-presence">
  <al:description lang="en">
    Handle presence element to discover narval agent / human being
  </al:description>
  <al:step id="s1" type="action" target="AlRDF.is-a-known-user-stmt"/>
  <al:step id="s2" type="action" target="kb-backend.search-stmts"/>
  <al:step id="s3" type="action" target="AlRDF.ask-if-user-is-a-narval"/>
  <al:transition id="t1">
    <al:in idref="s1"/>
    <al:out idref="s2"/>
  </al:transition>
  <al:transition id="t2">
    <al:in idref="s2" onError="yes"/>
    <al:out idref="s3"/>
  </al:transition>
</al:recipe>

 
</cookbook>
