Skip to content
This repository has been archived by the owner on Aug 26, 2020. It is now read-only.

Commit

Permalink
bug:45621 and issue #276, example bugfix and comments in qconsole
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles Greer committed Jun 5, 2017
1 parent e3b3dc2 commit acb47f0
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<description>
Extraction Template Generated from Entity Type Document
graph uri: http://example.org/example-person/Person-0.0.1</description>
<context>//es:instance</context>
<context>//es:instance[es:info/es:version = "0.0.1"]</context>
<vars>
<var>
<name>RDF</name>
Expand Down Expand Up @@ -112,4 +112,4 @@ graph uri: http://example.org/example-person/Person-0.0.1</description>
</templates>
</template>
</templates>
</template>
</template>
23 changes: 16 additions & 7 deletions entity-services-examples/example-person/person-qc.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<export><workspace name="Person"><query name="00. README" focus="true" listorder="1" taborder="1" active="true" database="12450102741220167768" server="309628398882601242" database-name="entity-services-examples-content" server-name="entity-services-examples" mode="xquery">(:
<export><workspace name="Person"><query name="00. README" focus="false" listorder="1" taborder="1" active="true" database="1508525697967155335" server="12298971685414116198" database-name="entity-services-examples-content" server-name="entity-services-examples" mode="xquery">(:
: This Workspace contains reports and examples about an Entity Services scenario.
: It's designed with simplicity in mind, not real business data.
: Once you have run the Examples Loader ('./gradlew runExamplePerson') you can step
Expand All @@ -7,7 +7,9 @@
: and Optic API queries against Person data. These queries are replicated here.
: You can see that Optic API queries are conceptually portable across JavaScript, XQuery
: and Java.
:)</query><query name="01. Model Metadata" focus="false" listorder="2" taborder="2" active="true" database="12450102741220167768" server="309628398882601242" database-name="entity-services-examples-content" server-name="entity-services-examples" mode="sparql"># Return types and properties currently loaded in the database.
:)</query><query name="01. Model Metadata" focus="false" listorder="2" taborder="2" active="true" database="11182891158822652871" server="17367034213768814251" database-name="entity-services-examples-content" server-name="entity-services-examples" mode="sparql"># Return types and properties currently loaded in the database.
# The UNION clause would find both scalar dataypes and references
# for arrays.
prefix es: &lt;http://marklogic.com/entity-services#&gt;
prefix : &lt;http://example.org/example-person/&gt;
select ?title ?propertyName ?scalarType ?arrayType
Expand All @@ -24,29 +26,35 @@ where {
UNION
{ ?property es:items/es:datatype ?arraytype }
}
}</query><query name="02. Instances" focus="false" listorder="3" taborder="3" active="true" database="12450102741220167768" server="309628398882601242" database-name="entity-services-examples-content" server-name="entity-services-examples" mode="sparql"># select all IDS of all the Person instances in the database
}</query><query name="02. Instances" focus="false" listorder="3" taborder="3" active="true" database="11182891158822652871" server="17367034213768814251" database-name="entity-services-examples-content" server-name="entity-services-examples" mode="sparql"># select all IDS of all the Person instances in the database
# This query works because the generated TDE for Person contains
# a triple pattern linking instances to their types.
prefix es: &lt;http://marklogic.com/entity-services#&gt;
prefix : &lt;http://example.org/example-person/&gt;

select ?person ?typeName
where {
?person a ?personType .
?personType es:title ?typeName
} </query><query name="03. Optic XQ Rows" focus="false" listorder="4" taborder="4" active="true" database="12450102741220167768" server="309628398882601242" database-name="entity-services-examples-content" server-name="entity-services-examples" mode="xquery">import module namespace op = "http://marklogic.com/optic" at "/MarkLogic/optic.xqy";
} </query><query name="03. Optic XQ Rows" focus="false" listorder="4" taborder="4" active="true" database="11182891158822652871" server="17367034213768814251" database-name="entity-services-examples-content" server-name="entity-services-examples" mode="xquery">(: This query demonstrates the TDE view generated by ES, and how to query it using Optic :)
import module namespace op = "http://marklogic.com/optic" at "/MarkLogic/optic.xqy";
import module namespace opxs = "http://marklogic.com/optic/expression/xs" at "/MarkLogic/optic/optic-xs.xqy";


let $p := op:from-view("Person", "Person")
=&gt;op:where(op:eq(op:col("id"), opxs:string("122")))
=&gt;op:select( (op:col("firstName"), op:col("lastName")) )

return $p=&gt;op:result()</query><query name="04. Optic SJS Rows" focus="false" listorder="5" taborder="5" active="true" database="12450102741220167768" server="309628398882601242" database-name="entity-services-examples-content" server-name="entity-services-examples" mode="javascript">var op = require("/MarkLogic/optic");
return $p=&gt;op:result()</query><query name="04. Optic SJS Rows" focus="false" listorder="5" taborder="5" active="true" database="11182891158822652871" server="17367034213768814251" database-name="entity-services-examples-content" server-name="entity-services-examples" mode="javascript">// This query demonstrates the TDE view generated by ES, and how to query it using Optic SJS

var op = require("/MarkLogic/optic");
var opxs = op.xs;

op.fromView("Person", "Person")
.where(op.eq(op.col("id"), opxs.string("122")))
.select( [op.col("firstName"), op.col("lastName") ] )
.result();</query><query name="05. Optic XQ Triples" focus="false" listorder="6" taborder="6" active="true" database="12450102741220167768" server="309628398882601242" database-name="entity-services-examples-content" server-name="entity-services-examples" mode="xquery">import module namespace op = "http://marklogic.com/optic" at "/MarkLogic/optic.xqy";
.result();</query><query name="05. Optic XQ Triples" focus="false" listorder="6" taborder="6" active="true" database="11182891158822652871" server="17367034213768814251" database-name="entity-services-examples-content" server-name="entity-services-examples" mode="xquery">(: This Optic query returns type information from triples :)
import module namespace op = "http://marklogic.com/optic" at "/MarkLogic/optic.xqy";
import module namespace opxs = "http://marklogic.com/optic/expression/xs" at "/MarkLogic/optic/optic-xs.xqy";
import module namespace opsem = "http://marklogic.com/optic/expression/sem" at "/MarkLogic/optic/optic-sem.xqy";

Expand All @@ -58,7 +66,8 @@ return
$rdf("type"),
op:col("type") ) ) )
=&gt;op:where( op:eq( op:col("type"), $ps("Person")))
=&gt;op:result()</query><query name="06. Optic SJS Triples" focus="false" listorder="7" taborder="7" active="true" database="12450102741220167768" server="309628398882601242" database-name="entity-services-examples-content" server-name="entity-services-examples" mode="javascript">var op = require("/MarkLogic/optic");
=&gt;op:result()</query><query name="06. Optic SJS Triples" focus="true" listorder="7" taborder="7" active="true" database="16220437251696472715" server="7981641921837170260" database-name="entity-services-examples-modules" server-name="App-Services" mode="javascript">(: This Optic query returns type information from triples :)
var op = require("/MarkLogic/optic");
var sem = require("/MarkLogic/semantics");
var ps = op.prefixer("http://example.org/example-person/Person-0.0.1/");
var rdf = op.prefixer("http://www.w3.org/1999/02/22-rdf-syntax-ns#");
Expand Down
Loading

0 comments on commit acb47f0

Please sign in to comment.