Skip to content

Commit 8f5f462

Browse files
committed
fixed #547
1 parent 30418af commit 8f5f462

File tree

5 files changed

+62
-4
lines changed

5 files changed

+62
-4
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ services:
1111
- docker
1212

1313
before_install:
14+
- "/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -ac -screen 0 1280x1024x16"
1415
- ./.travis/download.sh
1516

1617
script:

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
@@ -188,7 +188,7 @@ else if (isEntityDir(dir, startPath.toAbsolutePath())) {
188188
InputStream inputStream = r.getInputStream();
189189
StringHandle handle = new StringHandle(IOUtils.toString(inputStream));
190190
inputStream.close();
191-
entityDocMgr.write(URLEncoder.encode("/entities/" + r.getFilename(), "UTF-8"), meta, handle);
191+
entityDocMgr.write("/entities/" + r.getFilename(), meta, handle);
192192
modulesManager.saveLastLoadedTimestamp(r.getFile(), new Date());
193193
}
194194
}

ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/task/CreateFlowTask.groovy

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,14 @@ import com.marklogic.hub.flow.CodeFormat
66
import com.marklogic.hub.flow.DataFormat
77
import com.marklogic.hub.flow.FlowType
88
import com.marklogic.hub.scaffold.Scaffolding
9+
import org.gradle.api.tasks.Input
910

1011
abstract class CreateFlowTask extends HubTask {
1112

13+
@Input
14+
public Boolean useES
15+
16+
1217
void createFlow(FlowType flowType) {
1318
def entityName = project.hasProperty("entityName") ? project.property("entityName") : null
1419
if (entityName == null) {
@@ -38,9 +43,14 @@ abstract class CreateFlowTask extends HubTask {
3843
return
3944
}
4045

46+
if (useES == null) {
47+
useES = project.hasProperty("useES") ?
48+
Boolean.parseBoolean(project.property("useES")) : false
49+
}
50+
4151
def projectDir = getHubConfig().projectDir
4252
Scaffolding scaffolding = new Scaffolding(projectDir, getFinalClient())
4353
println "Creating an " + pluginFormat + " " + flowType + " flow named " + flowName + " for entity " + entityName
44-
scaffolding.createFlow(entityName, flowName, flowType, pluginFormat, dataFormat)
54+
scaffolding.createFlow(entityName, flowName, flowType, pluginFormat, dataFormat, useES)
4555
}
4656
}

ml-data-hub-plugin/src/test/groovy/com/marklogic/gradle/task/InstalledTests.groovy

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ import com.marklogic.client.io.DocumentMetadataHandle
55
import com.marklogic.hub.Debugging
66
import com.marklogic.hub.HubConfig
77
import com.marklogic.hub.Tracing
8-
import com.marklogic.hub.error.LegacyFlowsException
9-
import org.apache.commons.io.FileUtils
108
import org.gradle.testkit.runner.UnexpectedBuildFailure
119
import org.gradle.testkit.runner.UnexpectedBuildSuccess
10+
1211
import java.nio.file.Paths
12+
1313
import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual
1414
import static org.gradle.testkit.runner.TaskOutcome.FAILED
1515
import static org.gradle.testkit.runner.TaskOutcome.SUCCESS
@@ -158,4 +158,32 @@ class InstalledTests extends BaseTest {
158158
result.output.contains('legacy-test => legacy-input-flow')
159159
result.task(":mlLoadModules").outcome == FAILED
160160
}
161+
162+
def "createHarmonizeFlow with useES flag"() {
163+
given:
164+
propertiesFile << """
165+
ext {
166+
entityName=Employee
167+
flowName=my-new-harmonize-flow
168+
useES=true
169+
}
170+
"""
171+
172+
when:
173+
runTask('hubUpdate')
174+
runTask('hubCreateEntity')
175+
copyResourceToFile("employee.entity.json", Paths.get(testProjectDir.root.toString(), "plugins", "entities", "Employee", "Employee.entity.json").toFile())
176+
runTask('mlLoadModules')
177+
def result = runTask('hubCreateHarmonizeFlow')
178+
179+
then:
180+
notThrown(UnexpectedBuildFailure)
181+
result.task(":hubCreateHarmonizeFlow").outcome == SUCCESS
182+
183+
File entityDir = Paths.get(testProjectDir.root.toString(), "plugins", "entities", "Employee", "harmonize", "my-new-harmonize-flow").toFile()
184+
entityDir.isDirectory() == true
185+
File contentPlugin = Paths.get(testProjectDir.root.toString(), "plugins", "entities", "Employee", "harmonize", "my-new-harmonize-flow", "content.sjs").toFile()
186+
contentPlugin.text.contains("extractInstanceEmployee")
187+
}
188+
161189
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"info" : {
3+
"title" : "Employee",
4+
"version" : "0.0.1"
5+
},
6+
"definitions" : {
7+
"Employee" : {
8+
"required" : [ ],
9+
"rangeIndex" : [ ],
10+
"wordLexicon" : [ ],
11+
"properties" : {
12+
"name" : {
13+
"datatype" : "string",
14+
"collation" : "http://marklogic.com/collation/codepoint"
15+
}
16+
}
17+
}
18+
}
19+
}

0 commit comments

Comments
 (0)