Skip to content

Commit d70e261

Browse files
committed
adding writer plugin to scaffolding
updating to 8.0-5 adding hr-hub example turning off debug logging by default
1 parent dd02623 commit d70e261

File tree

26 files changed

+2279
-22
lines changed

26 files changed

+2279
-22
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
dept_num,dept_name
2+
1,Sales
3+
2,Marketing
4+
3,Engineering
5+
4,R&D
6+
5,Training

examples/hr-hub/input/EmployeeTables/EmployeeTable.csv

Lines changed: 1001 additions & 0 deletions
Large diffs are not rendered by default.

examples/hr-hub/input/EmployeeTables/SalaryTable.csv

Lines changed: 1001 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Collect IDs plugin
3+
*
4+
* @param options - a map containing options. Options are sent from Java
5+
*
6+
* @return - an array of ids or uris
7+
*/
8+
function collect(options) {
9+
var y = [];
10+
for (var x of fn.collection()) {
11+
var empid = x.root.content.emp_id;
12+
if (empid) {
13+
y.push(empid);
14+
}
15+
}
16+
return fn.distinctValues(xdmp.arrayValues(y));
17+
}
18+
19+
module.exports = {
20+
collect: collect
21+
};
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Create Content Plugin
3+
*
4+
* @param id - the identifier returned by the collector
5+
* @param content - your final content
6+
* @param headers - an array of header objects
7+
* @param triples - an array of triples
8+
* @param options - an object containing options. Options are sent from Java
9+
*
10+
* @return - your content
11+
*/
12+
function createContent(id, content, headers, triples, options) {
13+
// start with an empty object
14+
content = {};
15+
16+
// find the documents matching the given employee id
17+
for (var doc of cts.search(cts.jsonPropertyValueQuery('emp_id', id))) {
18+
19+
// merge the keys and values from the found document into content
20+
for (var key in doc.root.content) {
21+
if (doc.root.content.hasOwnProperty(key)) {
22+
content[key] = doc.root.content[key];
23+
}
24+
}
25+
}
26+
27+
// return the merged content
28+
return content;
29+
}
30+
31+
module.exports = {
32+
createContent: createContent
33+
};
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<?xml version="1.0" ?><flow xmlns="http://marklogic.com/data-hub"><name>create-employees</name><entity>Employee</entity><type>conformance</type><complexity>simple</complexity><data-format>application/json</data-format><plugins></plugins></flow>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
* Create Headers Plugin
3+
*
4+
* @param id - the identifier returned by the collector
5+
* @param content - your final content
6+
* @param headers - an array of header objects
7+
* @param triples - an array of triples
8+
* @param options - an object containing options. Options are sent from Java
9+
*
10+
* @return - an array of header objects
11+
*/
12+
function createHeaders(id, content, headers, triples, options) {
13+
return [];
14+
}
15+
16+
module.exports = {
17+
createHeaders: createHeaders
18+
};
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
* Create Triples Plugin
3+
*
4+
* @param id - the identifier returned by the collector
5+
* @param content - your final content
6+
* @param headers - an array of header objects
7+
* @param triples - an array of triples
8+
* @param options - an object containing options. Options are sent from Java
9+
*
10+
* @return - an array of triples
11+
*/
12+
function createTriples(id, content, headers, triples, options) {
13+
return [];
14+
}
15+
16+
module.exports = {
17+
createTriples: createTriples
18+
};
19+
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*~
2+
* Writer Plugin
3+
*
4+
* @param id - the identifier returned by the collector
5+
* @param envelope - the final envelope
6+
* @param options - a map containing options. Options are sent from Java
7+
*
8+
* @return - zero or more header nodes
9+
*/
10+
function write(id, content, options) {
11+
xdmp.documentInsert('/employees/' + id + '.json', content);
12+
}
13+
14+
module.exports = {
15+
write: write
16+
};
17+
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
* Create Content Plugin
3+
*
4+
* @param id - the identifier returned by the collector
5+
* @param content - your final content
6+
* @param headers - an array of header objects
7+
* @param triples - an array of triples
8+
* @param options - an object containing options. Options are sent from Java
9+
*
10+
* @return - your content
11+
*/
12+
function createContent(id, content, headers, triples, options) {
13+
return content;
14+
}
15+
16+
module.exports = {
17+
createContent: createContent
18+
};

0 commit comments

Comments
 (0)