Skip to content

Commit 9945aaa

Browse files
committed
fixing some bugs in tests
1 parent 546026a commit 9945aaa

File tree

3 files changed

+32
-14
lines changed

3 files changed

+32
-14
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ public void runInputFlow(Flow flow, HubConfig config) {
237237
flow.getEntityName(), flow.getName(),
238238
FlowType.INPUT.toString(),
239239
flow.getDataFormat());
240+
sourceOptions.setInputFileType("documents");
240241
mlcp.addSourceDirectory(config.modulesPath, sourceOptions);
241242
mlcp.loadContent();
242243
}

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

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
import com.marklogic.client.io.Format;
3131

3232
public class Mlcp {
33-
33+
3434
public static final String DOCUMENT_TYPE_KEY = "-document_type";
3535
public static final String INPUT_FILE_PATH_KEY = "-input_file_path";
3636
public static final String INPUT_FILE_TYPE_KEY = "-input_file_type";
@@ -40,7 +40,7 @@ public class Mlcp {
4040
public static final String PORT_KEY = "-port";
4141
public static final String USERNAME_KEY = "-username";
4242
public static final String PASSWORD_KEY = "-password";
43-
43+
4444
private static final Logger LOGGER = LoggerFactory.getLogger(Mlcp.class);
4545
private static final String DEFAULT_HADOOP_HOME_DIR = "./hadoop/";
4646

@@ -109,24 +109,36 @@ public List<String> getMlcpArguments() throws IOException, JSONException {
109109
String canonicalPath = file.getCanonicalPath();
110110

111111
List<String> arguments = new ArrayList<>();
112-
112+
113113
arguments.add(INPUT_FILE_PATH_KEY);
114114
arguments.add(canonicalPath);
115-
115+
116116
arguments.add(OUTPUT_URI_REPLACE_KEY);
117117
arguments.add("\""+canonicalPath+",''\"");
118-
118+
119119
arguments.add(INPUT_FILE_TYPE_KEY);
120120
arguments.add(sourceOptions.getInputFileType());
121121

122-
addOtherArguments(arguments, sourceOptions.getOtherOptions());
123-
122+
123+
String other = sourceOptions.getOtherOptions();
124+
if (other != null) {
125+
addOtherArguments(arguments, other);
126+
}
127+
124128
//add document type only if it does not exist in the list
125129
if(!arguments.contains(DOCUMENT_TYPE_KEY)) {
126130
arguments.add(DOCUMENT_TYPE_KEY);
127131
arguments.add(sourceOptions.getDataFormat());
128132
}
129-
133+
134+
arguments.add("-transform_module");
135+
arguments.add("/com.marklogic.hub/mlcp-flow-transform.xqy");
136+
arguments.add("-transform_namespace");
137+
arguments.add("http://marklogic.com/data-hub/mlcp-flow-transform");
138+
arguments.add("-transform_param");
139+
arguments.add("\"" + sourceOptions.getTransformParams() + "\"");
140+
141+
130142
return arguments;
131143
}
132144

@@ -142,9 +154,9 @@ private void addOtherArguments(List<String> arguments,
142154
arguments.add(key);
143155
arguments.add(jsonObject.getString(key));
144156
}
145-
157+
146158
}
147-
159+
148160
}
149161
}
150162

@@ -191,14 +203,20 @@ public String getInputFileType() {
191203
public void setInputFileType(String inputFileType) {
192204
this.inputFileType = inputFileType;
193205
}
194-
206+
195207
public String getOtherOptions() {
196208
return otherOptions;
197209
}
198210

199211
public void setOtherOptions(String otherOptions) {
200212
this.otherOptions = otherOptions;
201213
}
214+
215+
protected String getTransformParams() {
216+
return String.format(
217+
"<params><entity-name>%s</entity-name><flow-name>%s</flow-name><flow-type>%s</flow-type></params>",
218+
entityName, flowName, flowType);
219+
}
202220
}
203221

204222
public List<String> getMlcpOptions(MlcpSource source) throws IOException, JSONException {
@@ -218,7 +236,7 @@ public List<String> getMlcpOptions(MlcpSource source) throws IOException, JSONEx
218236

219237
List<String> sourceArguments = source.getMlcpArguments();
220238
mlcpOptions.addAll(sourceArguments);
221-
239+
222240
return mlcpOptions;
223241
}
224242
}

quick-start/src/main/java/com/marklogic/hub/config/EnvironmentConfiguration.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ public class EnvironmentConfiguration {
4545
private static final String ML_AUTH = "mlAuth";
4646
private static final String USER_PLUGIN_DIR = "userPluginDir";
4747
private static final String ASSET_INSTALL_TIME_FILE = "assetInstallTimeFile";
48-
private static final String MLCP_OPTIONS_DIR = "mlcp-options";
4948

5049
@Autowired
5150
private Environment environment;
@@ -255,7 +254,7 @@ public void saveOrUpdateFlowMlcpOptionsToFile(String entityName, String flowName
255254
}
256255

257256
private String getMlcpOptionsFilePath(String entityName, String flowName) {
258-
return "." + File.separator + MLCP_OPTIONS_DIR + File.separator + entityName + "-" + flowName + ".txt";
257+
return "." + File.separator + entityName + "-" + flowName + ".txt";
259258
}
260259

261260
public String getFlowMlcpOptionsFromFile(String entityName, String flowName) throws IOException {

0 commit comments

Comments
 (0)