@@ -56,8 +56,6 @@ public class FlowApiController extends BaseController {
5656
5757 private static final String MLCP_OPTIONS_FILENAME = "mlcpOptions.txt" ;
5858
59- private static final String NEW_LINE = "\n " ;
60-
6159 @ Autowired
6260 private EnvironmentConfiguration environmentConfiguration ;
6361
@@ -216,9 +214,7 @@ public void cancel(BasicFuture<?> resultFuture) {
216214 @ Override
217215 public void run (BasicFuture <?> resultFuture ) {
218216 try {
219- SourceOptions sourceOptions = createSourceOptionsInstance (flowOptionsModel );
220- Mlcp mlcp = createMlcpInstance (flowOptionsModel ,sourceOptions );
221- mlcp .loadContent ();
217+ flowManagerService .loadData (flowOptionsModel );
222218
223219 resultFuture .completed (null );
224220 }
@@ -235,31 +231,6 @@ public void run(BasicFuture<?> resultFuture) {
235231 return taskManagerService .addTask (task );
236232 }
237233
238- protected Mlcp createMlcpInstance (FlowOptionsModel flowOptionsModel , SourceOptions sourceOptions ) throws NumberFormatException , IOException {
239- Mlcp mlcp = new Mlcp (
240- environmentConfiguration .getMLHost ()
241- ,Integer .parseInt (environmentConfiguration .getMLStagingRestPort ())
242- ,environmentConfiguration .getMLUsername ()
243- ,environmentConfiguration .getMLPassword ()
244- );
245- mlcp .addSourceDirectory (flowOptionsModel .getInputPath (), sourceOptions );
246- return mlcp ;
247- }
248-
249- protected SourceOptions createSourceOptionsInstance (FlowOptionsModel flowOptionsModel ) throws NumberFormatException , IOException {
250- Flow flow = flowManagerService .getFlow (flowOptionsModel .getEntityName (), flowOptionsModel .getFlowName ());
251-
252- SourceOptions sourceOptions = new SourceOptions (
253- flowOptionsModel .getEntityName (), flowOptionsModel .getFlowName (),
254- FlowType .INPUT .toString (),
255- flow .getDataFormat ());
256-
257- sourceOptions .setInputFileType (flowOptionsModel .getInputFileType ());
258- sourceOptions .setOtherOptions (flowOptionsModel .getOtherOptions ());
259-
260- return sourceOptions ;
261- }
262-
263234 @ RequestMapping (value = "/input-path" , method = RequestMethod .GET , produces = { MediaType .TEXT_PLAIN_VALUE })
264235 @ ResponseBody
265236 public String getPreviousInputPath (HttpServletRequest request ) {
@@ -292,7 +263,7 @@ public void runFlowsInParallel(HttpServletRequest request) {
292263
293264 @ RequestMapping (value = "/options/download" , method = RequestMethod .POST , consumes = { MediaType .APPLICATION_JSON_UTF8_VALUE }, produces = { MediaType .TEXT_PLAIN_VALUE })
294265 public ResponseEntity <InputStreamResource > downloadMlcpConfig (@ RequestBody FlowOptionsModel flowOptionsModel ) throws IOException , NumberFormatException , JSONException {
295- String mlcpConfigContent = buildMlcpConfigContent (flowOptionsModel );
266+ String mlcpConfigContent = flowManagerService . buildMlcpConfigContent (flowOptionsModel );
296267 byte [] contentBytes = mlcpConfigContent .getBytes (StandardCharsets .UTF_8 );
297268 InputStream inputStream = new ByteArrayInputStream (contentBytes );
298269 HttpHeaders headers = new HttpHeaders ();
@@ -306,13 +277,6 @@ public ResponseEntity<InputStreamResource> downloadMlcpConfig(@RequestBody FlowO
306277 .body (new InputStreamResource (inputStream ));
307278 }
308279
309- private String buildMlcpConfigContent (FlowOptionsModel flowOptionsModel ) throws NumberFormatException , IOException , JSONException {
310- SourceOptions sourceOptions = createSourceOptionsInstance (flowOptionsModel );
311- Mlcp mlcp = createMlcpInstance (flowOptionsModel ,sourceOptions );
312- List <String > mlcpOptions = mlcp .getMlcpOptions (new MlcpSource (flowOptionsModel .getInputPath (), sourceOptions ));
313- return StringUtils .collectionToDelimitedString (mlcpOptions , NEW_LINE );
314- }
315-
316280 private void addRemoveCachingInHeaders (HttpHeaders headers ) {
317281 headers .add ("Cache-Control" , "no-cache, no-store, must-revalidate" );
318282 headers .add ("Pragma" , "no-cache" );
0 commit comments