Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update plugin signatures #178

Merged
merged 1 commit into from
Apr 5, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
xquery version "1.0-ml";

module namespace plugin = "http://marklogic.com/data-hub/plugins/collector";
module namespace plugin = "http://marklogic.com/data-hub/plugins";

declare option xdmp:mapping "false";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
xquery version "1.0-ml";

module namespace plugin = "http://marklogic.com/data-hub/plugins/content";
module namespace plugin = "http://marklogic.com/data-hub/plugins";

declare namespace envelope = "http://marklogic.com/data-hub/envelope";

Expand All @@ -9,20 +9,21 @@ declare option xdmp:mapping "false";
(:~
: Create Content Plugin
:
: @param id - the identifier returned by the collector
: @param content - your final content
: @param headers - a sequence of header nodes
: @param triples - a sequence of triples
: @param $options - a map containing options. Options are sent from Java
: @param $id - the identifier returned by the collector
: @param $options - a map containing options. Options are sent from Java
:
: @return - your transformed content
:)
declare function plugin:create-content(
$id as xs:string,
$content as node()?,
$headers as node()*,
$triples as sem:triple*,
$options as map:map) as node()?
{
fn:doc($id)/envelope:envelope/envelope:content/node()
let $doc := fn:doc($id)
return
if ($doc/envelope:envelope) then
$doc/envelope:envelope/envelope:content/node()
else if ($doc/content) then
$doc/content
else
$doc
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
xquery version "1.0-ml";

module namespace plugin = "http://marklogic.com/data-hub/plugins/headers";
module namespace plugin = "http://marklogic.com/data-hub/plugins";

declare namespace envelope = "http://marklogic.com/data-hub/envelope";

Expand All @@ -11,19 +11,15 @@ declare option xdmp:mapping "false";
(:~
: Create Headers Plugin
:
: @param id - the identifier returned by the collector
: @param content - your final content
: @param headers - a sequence of header nodes
: @param triples - a sequence of triples
: @param $id - the identifier returned by the collector
: @param $content - the output of your content plugin
: @param $options - a map containing options. Options are sent from Java
:
: @return - zero or more header nodes
:)
declare function plugin:create-headers(
$id as xs:string,
$content as node()?,
$headers as node()*,
$triples as sem:triple*,
$options as map:map) as node()*
{
(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
xquery version "1.0-ml";

module namespace plugin = "http://marklogic.com/data-hub/plugins/triples";
module namespace plugin = "http://marklogic.com/data-hub/plugins";

declare namespace envelope = "http://marklogic.com/data-hub/envelope";

Expand All @@ -9,10 +9,9 @@ declare option xdmp:mapping "false";
(:~
: Create Triples Plugin
:
: @param id - the identifier returned by the collector
: @param content - your final content
: @param headers - a sequence of header nodes
: @param triples - a sequence of triples
: @param $id - the identifier returned by the collector
: @param $content - the output of your content plugin
: @param $headers - the output of your headers plugin
: @param $options - a map containing options. Options are sent from Java
:
: @return - zero or more triples
Expand All @@ -21,7 +20,6 @@ declare function plugin:create-triples(
$id as xs:string,
$content as node()?,
$headers as node()*,
$triples as sem:triple*,
$options as map:map) as sem:triple*
{
()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
xquery version "1.0-ml";

module namespace plugin = "http://marklogic.com/data-hub/plugins/content";
module namespace plugin = "http://marklogic.com/data-hub/plugins";

declare namespace envelope = "http://marklogic.com/data-hub/envelope";

Expand All @@ -9,20 +9,16 @@ declare option xdmp:mapping "false";
(:~
: Create Content Plugin
:
: @param id - the identifier returned by the collector
: @param content - your final content
: @param headers - a sequence of header nodes
: @param triples - a sequence of triples
: @param $options - a map containing options. Options are sent from Java
: @param $id - the identifier returned by the collector
: @param $raw-content - the raw content being loaded.
: @param $options - a map containing options. Options are sent from Java
:
: @return - your transformed content
:)
declare function plugin:create-content(
$id as xs:string,
$content as node()?,
$headers as node()*,
$triples as sem:triple*,
$raw-content as node()?,
$options as map:map) as node()?
{
$content
$raw-content
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
xquery version "1.0-ml";

module namespace plugin = "http://marklogic.com/data-hub/plugins/headers";
module namespace plugin = "http://marklogic.com/data-hub/plugins";

declare namespace envelope = "http://marklogic.com/data-hub/envelope";

Expand All @@ -9,19 +9,15 @@ declare option xdmp:mapping "false";
(:~
: Create Headers Plugin
:
: @param id - the identifier returned by the collector
: @param content - your final content
: @param headers - a sequence of header nodes
: @param triples - a sequence of triples
: @param $id - the identifier returned by the collector
: @param $content - the output of your content plugin
: @param $options - a map containing options. Options are sent from Java
:
: @return - zero or more header nodes
:)
declare function plugin:create-headers(
$id as xs:string,
$content as node()?,
$headers as node()*,
$triples as sem:triple*,
$options as map:map) as node()*
{
()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
xquery version "1.0-ml";

module namespace plugin = "http://marklogic.com/data-hub/plugins/triples";
module namespace plugin = "http://marklogic.com/data-hub/plugins";

declare namespace envelope = "http://marklogic.com/data-hub/envelope";

Expand All @@ -9,10 +9,9 @@ declare option xdmp:mapping "false";
(:~
: Create Triples Plugin
:
: @param id - the identifier returned by the collector
: @param content - your final content
: @param headers - a sequence of header nodes
: @param triples - a sequence of triples
: @param $id - the identifier returned by the collector
: @param $content - the output of your content plugin
: @param $headers - the output of your headers plugin
: @param $options - a map containing options. Options are sent from Java
:
: @return - zero or more triples
Expand All @@ -21,7 +20,6 @@ declare function plugin:create-triples(
$id as xs:string,
$content as node()?,
$headers as node()*,
$triples as sem:triple*,
$options as map:map) as sem:triple*
{
()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
xquery version "1.0-ml";

module namespace plugin = "http://marklogic.com/data-hub/plugins/content";
module namespace plugin = "http://marklogic.com/data-hub/plugins";

declare namespace envelope = "http://marklogic.com/data-hub/envelope";

Expand All @@ -9,20 +9,16 @@ declare option xdmp:mapping "false";
(:~
: Create Content Plugin
:
: @param id - the identifier returned by the collector
: @param content - your final content
: @param headers - a sequence of header nodes
: @param triples - a sequence of triples
: @param $options - a map containing options. Options are sent from Java
: @param $id - the identifier returned by the collector
: @param $raw-content - the raw content being loaded.
: @param $options - a map containing options. Options are sent from Java
:
: @return - your transformed content
:)
declare function plugin:create-content(
$id as xs:string,
$content as node()?,
$headers as node()*,
$triples as sem:triple*,
$raw-content as node()?,
$options as map:map) as node()?
{
$content
$raw-content
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
xquery version "1.0-ml";

module namespace plugin = "http://marklogic.com/data-hub/plugins/headers";
module namespace plugin = "http://marklogic.com/data-hub/plugins";

declare namespace envelope = "http://marklogic.com/data-hub/envelope";

Expand All @@ -9,19 +9,15 @@ declare option xdmp:mapping "false";
(:~
: Create Headers Plugin
:
: @param id - the identifier returned by the collector
: @param content - your final content
: @param headers - a sequence of header nodes
: @param triples - a sequence of triples
: @param $id - the identifier returned by the collector
: @param $content - the output of your content plugin
: @param $options - a map containing options. Options are sent from Java
:
: @return - zero or more header nodes
:)
declare function plugin:create-headers(
$id as xs:string,
$content as node()?,
$headers as node()*,
$triples as sem:triple*,
$options as map:map) as node()*
{
()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
xquery version "1.0-ml";

module namespace plugin = "http://marklogic.com/data-hub/plugins/triples";
module namespace plugin = "http://marklogic.com/data-hub/plugins";

declare namespace envelope = "http://marklogic.com/data-hub/envelope";

Expand All @@ -9,10 +9,9 @@ declare option xdmp:mapping "false";
(:~
: Create Triples Plugin
:
: @param id - the identifier returned by the collector
: @param content - your final content
: @param headers - a sequence of header nodes
: @param triples - a sequence of triples
: @param $id - the identifier returned by the collector
: @param $content - the output of your content plugin
: @param $headers - the output of your headers plugin
: @param $options - a map containing options. Options are sent from Java
:
: @return - zero or more triples
Expand All @@ -21,7 +20,6 @@ declare function plugin:create-triples(
$id as xs:string,
$content as node()?,
$headers as node()*,
$triples as sem:triple*,
$options as map:map) as sem:triple*
{
()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
/*
* Create Content Plugin
*
* @param id - the identifier returned by the collector
* @param content - your final content
* @param headers - an array of header objects
* @param triples - an array of triples
* @param options - an object containing options. Options are sent from Java
* @param id - the identifier returned by the collector
* @param options - an object containing options. Options are sent from Java
*
* @return - your content
*/
function createContent(id, content, headers, triples, options) {
var root = cts.doc(id).root;
function createContent(id, options) {
var doc = cts.doc(id);
var root = doc.root;

// for xml we need to use xpath
if (xdmp.nodeKind(root) === 'element') {
if (root && xdmp.nodeKind(root) === 'element') {
return root.xpath('/*:envelope/*:content/node()');
}
// for json we need to return the content
else {
else if (root && root.content) {
return root.content;
}
// for everything else
else {
return doc;
}
}

module.exports = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@
* Create Headers Plugin for Acme Tech data
*
* @param id - the identifier returned by the collector
* @param content - your final content
* @param headers - an array of header objects
* @param triples - an array of triples
* @param content - the output of your content plugin
* @param options - an object containing options. Options are sent from Java
*
* @return - an array of header objects
*/
function createHeaders(id, content, headers, triples, options) {
function createHeaders(id, content, options) {
var latest = xs.date('1900-01-01');
var salary;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,16 @@
* Create Triples Plugin
*
* @param id - the identifier returned by the collector
* @param content - your final content
* @param headers - an array of header objects
* @param triples - an array of triples
* @param content - the output of your content plugin
* @param headers - the output of your heaaders plugin
* @param options - an object containing options. Options are sent from Java
*
* @return - an array of triples
*/
function createTriples(id, content, headers, triples, options) {
function createTriples(id, content, headers, options) {
return [];
}

module.exports = {
createTriples: createTriples
};

Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
*
* @param id - the identifier returned by the collector
* @param envelope - the final envelope
* @param options - a map containing options. Options are sent from Java
* @param options - an object options. Options are sent from Java
*
* @return - zero or more header nodes
* @return - nothing
*/
function write(id, content, options) {
xdmp.documentInsert(id, content, [], ['json-employee']);
function write(id, envelope, options) {
xdmp.documentInsert(id, envelope, [], ['json-employee']);
}

module.exports = {
Expand Down
Loading