Skip to content

Commit 636282e

Browse files
committed
Merge branch 'release/2.0.0-alpha.1' into 2.0-master
2 parents 1da8a43 + bab5c0c commit 636282e

File tree

129 files changed

+4402
-1295
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

129 files changed

+4402
-1295
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ flow.properties
2121
node_modules/
2222
.tmp/
2323
*.sublime-*
24+
.vscode/

CHANGELOG.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,28 @@
11
# Change Log
22

3-
## [v1.0.1](https://github.com/marklogic/marklogic-data-hub/tree/v1.0.1)
3+
## [v2.0.1-alpha.1](https://github.com/marklogic/marklogic-data-hub/tree/v2.0.1-alpha.1)
44

5+
[Full Changelog](https://github.com/marklogic/marklogic-data-hub/compare/v1.0.2...v2.0.1-alpha.1)
6+
7+
**Implemented enhancements:**
8+
9+
- Visual entity type model editor [\#286](https://github.com/marklogic/marklogic-data-hub/issues/286)
10+
11+
## [v1.0.2](https://github.com/marklogic/marklogic-data-hub/tree/v1.0.2) (2016-11-22)
12+
[Full Changelog](https://github.com/marklogic/marklogic-data-hub/compare/v1.0.1...v1.0.2)
13+
14+
**Fixed bugs:**
15+
16+
- mlcp load from QuickStart GUI not loading data [\#331](https://github.com/marklogic/marklogic-data-hub/issues/331)
17+
18+
**Closed issues:**
19+
20+
- Possible typo on wiki page [\#333](https://github.com/marklogic/marklogic-data-hub/issues/333)
21+
- Tutorial instruction - create entity "Employees" instead of "Employee" [\#330](https://github.com/marklogic/marklogic-data-hub/issues/330)
22+
- mlcp job is not getting run + console log button not showing [\#329](https://github.com/marklogic/marklogic-data-hub/issues/329)
23+
- Error Extension hubstats does not exist. [\#328](https://github.com/marklogic/marklogic-data-hub/issues/328)
24+
25+
## [v1.0.1](https://github.com/marklogic/marklogic-data-hub/tree/v1.0.1) (2016-11-08)
526
[Full Changelog](https://github.com/marklogic/marklogic-data-hub/compare/v1.0.0...v1.0.1)
627

728
**Fixed bugs:**

README.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,19 @@
22

33
OS | Status
44
--- | --- | ---
5-
Linux/Mac | [![Build Status](https://travis-ci.org/marklogic/marklogic-data-hub.svg?branch=master)](https://travis-ci.org/marklogic/marklogic-data-hub)
5+
Linux/Mac | [![Build Status](https://travis-ci.org/marklogic/marklogic-data-hub.svg?branch=2.0-develop)](https://travis-ci.org/marklogic/marklogic-data-hub)
66
Windows | [![Windows Build status](https://ci.appveyor.com/api/projects/status/kgj0k5na59uhkvbv?svg=true)](https://ci.appveyor.com/project/paxtonhare/marklogic-data-hub)
77

88
# MarkLogic Data Hub
99

10+
## WARNING!!!! This is the the 2.0 branch of The MarkLogic Data Hub Framework. The 2.0 version is only compatible with MarkLogic 9.0 which is currently in Early Access and not generally available.
11+
1012
Go from nothing to Enterprise Data Hub in a matter of minutes.
1113

1214
This project allows you to deploy a skeleton Data Hub into MarkLogic. With some basic configuration you will be running an Enterprise Data Hub in no time.
1315

16+
17+
1418
# Getting Started
1519

1620
###TL;DR
@@ -36,7 +40,7 @@ Alternatively you can include the jar file as a build dependency in your Java pr
3640
**Gradle**
3741

3842
```groovy
39-
compile('com.marklogic:marklogic-data-hub:1.0.1')
43+
compile('com.marklogic:marklogic-data-hub:2.0.0-alpha.1')
4044
```
4145

4246
**Maven**
@@ -45,15 +49,15 @@ compile('com.marklogic:marklogic-data-hub:1.0.1')
4549
<dependency>
4650
<groupId>com.marklogic</groupId>
4751
<artifactId>marklogic-data-hub</artifactId>
48-
<version>1.0.1</version>
52+
<version>2.0.0-alpha.1</version>
4953
<type>pom</type>
5054
</dependency>
5155
```
5256

5357
**Ivy**
5458

5559
```xml
56-
<dependency org='com.marklogic' name='marklogic-data-hub' rev='1.0.1'>
60+
<dependency org='com.marklogic' name='marklogic-data-hub' rev='2.0.0-alpha.1'>
5761
<artifact name='$AID' ext='pom'></artifact>
5862
</dependency>
5963
```
@@ -64,7 +68,7 @@ If you prefer to use gradle for all of your hub interactions then you can includ
6468

6569
```groovy
6670
plugins {
67-
id 'com.marklogic.ml-data-hub' version '1.0.1'
71+
id 'com.marklogic.ml-data-hub' version '2.0.0-alpha.1'
6872
}
6973
```
7074

examples/spring-batch/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ plugins {
44
id 'idea'
55
id 'application'
66
id 'net.saliman.properties' version '1.4.6'
7-
id 'com.marklogic.ml-data-hub' version '1.0.1'
7+
id 'com.marklogic.ml-data-hub' version '2.0.0-alpha.1'
88
}
99

1010
repositories {
@@ -13,7 +13,7 @@ repositories {
1313
}
1414

1515
dependencies {
16-
compile 'com.marklogic:marklogic-data-hub:1.0.1'
16+
compile 'com.marklogic:marklogic-data-hub:2.0.0-alpha.1'
1717
compile 'com.marklogic:marklogic-spring-batch-core:0.6.0'
1818
compile 'com.marklogic:ml-javaclient-util:2.9.1'
1919
testCompile 'com.marklogic:marklogic-spring-batch-test:0.6.0'

marklogic-data-hub/gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,6 @@ hubProjectDir=examples/hr-hub
3636
mlReplaceTokensInModules=true
3737
mlUseRoxyTokenPrefix=false
3838

39-
version=1.0.1
39+
version=2.0.0-alpha.1
4040

4141

marklogic-data-hub/src/main/java/com/marklogic/hub/DataHub.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,9 @@ public void validateServer() throws ServerValidationException {
174174
alteredString += "0";
175175
}
176176
int major = Integer.parseInt(alteredString.substring(0, 1));
177-
int ver = Integer.parseInt(alteredString.substring(0, 3));
178-
boolean isNightly = versionString.matches("[^-]+-\\d{8}");
179-
if (major < 8 || (!isNightly && ver < 804)) {
177+
// int ver = Integer.parseInt(alteredString.substring(0, 3));
178+
// boolean isNightly = versionString.matches("[^-]+-\\d{8}");
179+
if (major < 9) {
180180
throw new ServerValidationException("Invalid MarkLogic Server Version: " + versionString);
181181
}
182182

marklogic-data-hub/src/main/java/com/marklogic/hub/deploy/commands/LoadUserModulesCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public void execute(CommandContext context) {
8585
DefaultModulesLoader modulesLoader = getStagingModulesLoader(config);
8686
modulesLoader.loadModules(baseDir, new AssetModulesFinder(), stagingClient);
8787

88-
JSONDocumentManager entityDocMgr = stagingClient.newJSONDocumentManager();
88+
JSONDocumentManager entityDocMgr = finalClient.newJSONDocumentManager();
8989

9090
AllButAssetsModulesFinder allButAssetsModulesFinder = new AllButAssetsModulesFinder();
9191

marklogic-data-hub/src/main/java/com/marklogic/hub/scaffold/Scaffolding.java

Lines changed: 73 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,29 +15,39 @@
1515
*/
1616
package com.marklogic.hub.scaffold;
1717

18-
import com.marklogic.client.helper.LoggingObject;
19-
import com.marklogic.client.io.Format;
20-
import com.marklogic.hub.error.ScaffoldingValidationException;
21-
import com.marklogic.hub.flow.FlowType;
22-
import com.marklogic.hub.flow.SimpleFlow;
23-
import com.marklogic.hub.plugin.PluginFormat;
24-
2518
import java.io.*;
19+
import java.nio.charset.StandardCharsets;
2620
import java.nio.file.Files;
2721
import java.nio.file.Path;
2822
import java.nio.file.Paths;
2923

24+
import com.marklogic.client.DatabaseClient;
25+
import com.marklogic.client.extensions.ResourceManager;
26+
import com.marklogic.client.extensions.ResourceServices;
27+
import com.marklogic.client.helper.LoggingObject;
28+
import com.marklogic.client.io.StringHandle;
29+
import com.marklogic.client.util.RequestParameters;
30+
import com.marklogic.hub.error.ScaffoldingValidationException;
31+
import com.marklogic.hub.plugin.PluginFormat;
32+
import com.sun.jersey.api.client.ClientHandlerException;
33+
34+
import com.marklogic.client.io.Format;
35+
import com.marklogic.hub.flow.FlowType;
36+
import com.marklogic.hub.flow.SimpleFlow;
37+
3038
public class Scaffolding extends LoggingObject {
3139

3240
private String projectDir;
3341
private Path pluginsDir;
3442
private Path entitiesDir;
3543
private ScaffoldingValidator validator;
44+
private DatabaseClient databaseClient;
3645

37-
public Scaffolding(String projectDir) {
46+
public Scaffolding(String projectDir, DatabaseClient databaseClient) {
3847
this.projectDir = projectDir;
3948
this.pluginsDir = Paths.get(this.projectDir, "plugins");
4049
this.entitiesDir = this.pluginsDir.resolve("entities");
50+
this.databaseClient = databaseClient;
4151
validator = new ScaffoldingValidator(projectDir);
4252
}
4353

@@ -55,7 +65,14 @@ public void createEntity(String entityName) throws FileNotFoundException {
5565
}
5666

5767
public void createFlow(String entityName, String flowName,
58-
FlowType flowType, PluginFormat pluginFormat, Format dataFormat)
68+
FlowType flowType, PluginFormat pluginFormat,
69+
Format dataFormat) throws IOException {
70+
createFlow(entityName, flowName, flowType, pluginFormat, dataFormat, false);
71+
}
72+
73+
public void createFlow(String entityName, String flowName,
74+
FlowType flowType, PluginFormat pluginFormat,
75+
Format dataFormat, boolean useEsModel)
5976
throws IOException {
6077
Path flowDir = getFlowDir(entityName, flowName, flowType);
6178

@@ -73,8 +90,17 @@ public void createFlow(String entityName, String flowName,
7390

7491
Path contentDir = flowDir.resolve("content");
7592
contentDir.toFile().mkdirs();
76-
writeFile("scaffolding/" + flowType + "/" + pluginFormat + "/content." + pluginFormat,
93+
94+
95+
if (useEsModel) {
96+
ContentPlugin cp = new ContentPlugin(databaseClient);
97+
String content = cp.getContents(entityName, pluginFormat);
98+
writeBuffer(content, contentDir.resolve("content." + pluginFormat));
99+
}
100+
else {
101+
writeFile("scaffolding/" + flowType + "/" + pluginFormat + "/content." + pluginFormat,
77102
contentDir.resolve("content." + pluginFormat));
103+
}
78104

79105
Path headerDir = flowDir.resolve("headers");
80106
headerDir.toFile().mkdirs();
@@ -104,6 +130,14 @@ private void writeFile(String srcFile, Path dstFile) throws IOException {
104130
}
105131
}
106132

133+
private void writeBuffer(String buffer, Path dstFile) throws IOException {
134+
logger.info("writing: " + dstFile.toString());
135+
if (!dstFile.toFile().exists()) {
136+
InputStream inputStream = new ByteArrayInputStream(buffer.getBytes(StandardCharsets.UTF_8));
137+
Files.copy(inputStream, dstFile);
138+
}
139+
}
140+
107141
public void createRestExtension(String entityName, String extensionName,
108142
FlowType flowType, PluginFormat pluginFormat) throws IOException, ScaffoldingValidationException {
109143
logger.info(extensionName);
@@ -224,4 +258,33 @@ public static String getAbsolutePath(String first, String... more) {
224258
}
225259
return absolutePath.toString();
226260
}
261+
262+
public class ContentPlugin extends ResourceManager {
263+
private static final String NAME = "scaffold-content";
264+
265+
private RequestParameters params = new RequestParameters();
266+
267+
public ContentPlugin(DatabaseClient client) {
268+
super();
269+
client.init(NAME, this);
270+
}
271+
272+
public String getContents(String entityName, PluginFormat pluginFormat) throws IOException {
273+
try {
274+
params.add("entity", entityName);
275+
params.add("pluginFormat", pluginFormat.toString());
276+
ResourceServices.ServiceResultIterator resultItr = this.getServices().get(params);
277+
if (resultItr == null || ! resultItr.hasNext()) {
278+
throw new IOException("Unable to get Content Plugin scaffold");
279+
}
280+
ResourceServices.ServiceResult res = resultItr.next();
281+
return res.getContent(new StringHandle()).get();
282+
}
283+
catch(ClientHandlerException e) {
284+
}
285+
return "{}";
286+
}
287+
288+
}
289+
227290
}

marklogic-data-hub/src/main/resources/ml-modules/root/com.marklogic.hub/lib/flow-lib.xqy

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -562,15 +562,15 @@ declare function flow:make-envelope(
562562
map:put($o, "headers", $headers),
563563
map:put($o, "triples", $triples),
564564
map:put($o, "instance",
565-
if ($content instance of map:map) then
565+
if ($content castable as map:map) then
566566
flow:instance-to-canonical-json($content)
567567
else
568568
$content
569569
),
570570
map:put($o, "attachments",
571571
let $content := map:get($map, "content")
572572
return
573-
if ($content instance of map:map) then
573+
if ($content castable as map:map) then
574574
map:get($content, "$attachments")
575575
else
576576
()
@@ -590,9 +590,8 @@ declare function flow:make-envelope(
590590
<instance>
591591
{
592592
let $content := map:get($map, "content")
593-
let $_ := xdmp:log(("content: [", $content, "]"))
594593
return
595-
if ($content instance of map:map) then
594+
if ($content castable as map:map) then
596595
flow:instance-to-canonical-xml($content)
597596
else
598597
$content
@@ -602,7 +601,7 @@ declare function flow:make-envelope(
602601
{
603602
let $content := map:get($map, "content")
604603
return
605-
if ($content instance of map:map) then
604+
if ($content castable as map:map) then
606605
map:get($content, "$attachments")
607606
else
608607
()
@@ -844,10 +843,12 @@ declare function flow:run-plugin(
844843

845844
let $resp :=
846845
typeswitch($resp)
847-
case map:map return
848-
$resp
849846
case object-node() | json:object return
850-
if ($data-format = $XML) then
847+
(: map:map lands here too :)
848+
(: map:map is ES response type :)
849+
if ($resp castable as map:map) then
850+
$resp
851+
else if ($data-format = $XML) then
851852
json:transform-from-json($resp, json:config("custom"))
852853
else
853854
$resp
@@ -938,14 +939,22 @@ declare function flow:run-writer(
938939
xdmp:rethrow()
939940
}
940941
let $duration := xdmp:elapsed-time() - $before
942+
let $is-xml :=
943+
let $e :=
944+
if ($envelope instance of document-node()) then
945+
$envelope/node()
946+
else
947+
$envelope
948+
return
949+
$e instance of element()
941950
let $_ :=
942951
trace:plugin-trace(
943952
$identifier,
944953
$module-uri,
945954
"writer",
946955
$flow-type,
947956
$envelope,
948-
if ($envelope instance of element()) then ()
957+
if ($is-xml) then ()
949958
else null-node {},
950959
$duration
951960
)

marklogic-data-hub/src/main/resources/ml-modules/root/com.marklogic.hub/lib/hub-entities.xqy

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,25 @@ declare variable $ENTITY-MODEL-COLLECTION := "http://marklogic.com/entity-servic
99

1010
declare option xdmp:mapping "false";
1111

12+
declare function hent:get-model($entity-name as xs:string)
13+
{
14+
let $model := fn:collection($ENTITY-MODEL-COLLECTION)[info/title = $entity-name]
15+
where fn:exists($model)
16+
return
17+
let $model-map as map:map? := $model
18+
let $refs := $model//*[fn:local-name(.) = '$ref'][fn:starts-with(., "#/definitions")] ! fn:replace(., "#/definitions/", "")
19+
let $_ :=
20+
let $definitions := $model-map=>map:get("definitions")
21+
for $ref in $refs
22+
let $other-model as map:map? := hent:get-model($ref)
23+
let $other-defs := $other-model=>map:get("definitions")
24+
for $key in map:keys($other-defs)
25+
return
26+
$definitions=>map:put($key, $other-defs=>map:get($key))
27+
return
28+
$model-map
29+
};
30+
1231
declare function hent:dump-indexes()
1332
{
1433
let $uber-model := map:map()

0 commit comments

Comments
 (0)