3030import com .marklogic .client .io .Format ;
3131
3232public 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}
0 commit comments