@Test public void testGetBaseParam() { String parameter = "{\"type\":\"MYSQL_TO_HDFS\",\"reader\":{\"column\":[\"`id`\",\"`name`\",\"`email`\",\"`desc`\",\"`phone`\",\"`password`\",\"`role`\",\"`proxy_users`\",\"`create_time`\",\"`modify_time`\"],\"datasource\":\"test11111\",\"table\":[\"user\"]},\"writer\":{\"path\":\"/test/temp/here\",\"fileName\":\"filetest\",\"writeMode\":\"APPEND\",\"fileType\":\"ORC\",\"column\":[{\"name\":\"`id`\",\"type\":\"VARCHAR\"},{\"name\":\"`name`\",\"type\":\"VARCHAR\"},{\"name\":\"`email`\",\"type\":\"VARCHAR\"},{\"name\":\"`desc`\",\"type\":\"VARCHAR\"},{\"name\":\"`phone`\",\"type\":\"VARCHAR\"},{\"name\":\"`password`\",\"type\":\"VARCHAR\"},{\"name\":\"`role`\",\"type\":\"VARCHAR\"},{\"name\":\"`proxy_users`\",\"type\":\"VARCHAR\"},{\"name\":\"`create_time`\",\"type\":\"VARCHAR\"},{\"name\":\"`modify_time`\",\"type\":\"VARCHAR\"}]},\"setting\":{\"speed\":{\"channel\":1,\"byte\":104857600},\"errorLimit\":{\"record\":3,\"percentage\":0.05}}}"; String type = "IMPEXP"; ImpExpParam impExpParam = (ImpExpParam) BaseParamFactory.getBaseParam(type, parameter); assertTrue(impExpParam.checkValid()); }
public static BaseParam getBaseParam(String type, String parameter) { try { switch (type) { case MR: return JsonUtil.parseObject(parameter, MrParam.class); case SHELL: return JsonUtil.parseObject(parameter, ShellParam.class); case HQL: return JsonUtil.parseObject(parameter, HqlParam.class); case VIRTUAL: return VirtualParam.getInstance(); case SPARK_STREAMING: return JsonUtil.parseObject(parameter, SparkParam.class); case SPARK: return JsonUtil.parseObject(parameter, SparkParam.class); case IMPEXP: return JsonUtil.parseObject(parameter,ImpExpBuilder.class).buildImpExp(); case STORM: return JsonUtil.parseObject(parameter, StormBuilder.class).buildStormParam(); default: return null; } } catch (Exception e) { logger.error("Get BaseParam object error", e); return null; } }
BaseParamFactory { public static BaseParam getBaseParam(String type, String parameter) { try { switch (type) { case MR: return JsonUtil.parseObject(parameter, MrParam.class); case SHELL: return JsonUtil.parseObject(parameter, ShellParam.class); case HQL: return JsonUtil.parseObject(parameter, HqlParam.class); case VIRTUAL: return VirtualParam.getInstance(); case SPARK_STREAMING: return JsonUtil.parseObject(parameter, SparkParam.class); case SPARK: return JsonUtil.parseObject(parameter, SparkParam.class); case IMPEXP: return JsonUtil.parseObject(parameter,ImpExpBuilder.class).buildImpExp(); case STORM: return JsonUtil.parseObject(parameter, StormBuilder.class).buildStormParam(); default: return null; } } catch (Exception e) { logger.error("Get BaseParam object error", e); return null; } } }
BaseParamFactory { public static BaseParam getBaseParam(String type, String parameter) { try { switch (type) { case MR: return JsonUtil.parseObject(parameter, MrParam.class); case SHELL: return JsonUtil.parseObject(parameter, ShellParam.class); case HQL: return JsonUtil.parseObject(parameter, HqlParam.class); case VIRTUAL: return VirtualParam.getInstance(); case SPARK_STREAMING: return JsonUtil.parseObject(parameter, SparkParam.class); case SPARK: return JsonUtil.parseObject(parameter, SparkParam.class); case IMPEXP: return JsonUtil.parseObject(parameter,ImpExpBuilder.class).buildImpExp(); case STORM: return JsonUtil.parseObject(parameter, StormBuilder.class).buildStormParam(); default: return null; } } catch (Exception e) { logger.error("Get BaseParam object error", e); return null; } }  }
BaseParamFactory { public static BaseParam getBaseParam(String type, String parameter) { try { switch (type) { case MR: return JsonUtil.parseObject(parameter, MrParam.class); case SHELL: return JsonUtil.parseObject(parameter, ShellParam.class); case HQL: return JsonUtil.parseObject(parameter, HqlParam.class); case VIRTUAL: return VirtualParam.getInstance(); case SPARK_STREAMING: return JsonUtil.parseObject(parameter, SparkParam.class); case SPARK: return JsonUtil.parseObject(parameter, SparkParam.class); case IMPEXP: return JsonUtil.parseObject(parameter,ImpExpBuilder.class).buildImpExp(); case STORM: return JsonUtil.parseObject(parameter, StormBuilder.class).buildStormParam(); default: return null; } } catch (Exception e) { logger.error("Get BaseParam object error", e); return null; } }  static BaseParam getBaseParam(String type, String parameter); }
BaseParamFactory { public static BaseParam getBaseParam(String type, String parameter) { try { switch (type) { case MR: return JsonUtil.parseObject(parameter, MrParam.class); case SHELL: return JsonUtil.parseObject(parameter, ShellParam.class); case HQL: return JsonUtil.parseObject(parameter, HqlParam.class); case VIRTUAL: return VirtualParam.getInstance(); case SPARK_STREAMING: return JsonUtil.parseObject(parameter, SparkParam.class); case SPARK: return JsonUtil.parseObject(parameter, SparkParam.class); case IMPEXP: return JsonUtil.parseObject(parameter,ImpExpBuilder.class).buildImpExp(); case STORM: return JsonUtil.parseObject(parameter, StormBuilder.class).buildStormParam(); default: return null; } } catch (Exception e) { logger.error("Get BaseParam object error", e); return null; } }  static BaseParam getBaseParam(String type, String parameter);  }