public static OfflineModelInfo buildOfflineModelInfo()

in odps-console-xflow/src/main/java/com/aliyun/openservices/odps/console/xflow/CreateOfflineModelCommand.java [150:202]


  public static OfflineModelInfo buildOfflineModelInfo(
          String cmd, Pattern PATTERN, ExecutionContext ctx) throws ODPSConsoleException {
    Matcher m = PATTERN.matcher(cmd);
    boolean match = m.matches();

    if (!match) {
      return null;
    }

    String input = m.group(1);
    String[] inputs = ODPSConsoleUtils.translateCommandline(input);
    CommandLine commandLine = getCommandLine(inputs);

    OfflineModelInfo modelInfo = new OfflineModelInfo();
    if (commandLine.hasOption("modelPath")) {
      modelInfo.modelPath = commandLine.getOptionValue("modelPath");
    } else {
      throw new ODPSConsoleException(ODPSConsoleConstants.BAD_COMMAND
              + "invalid parameter for offlinemodel, please HELP OFFLINEMODEL.");
    }

    if (commandLine.hasOption("arn")) {
      modelInfo.rolearn = commandLine.getOptionValue("arn");
    }
    if (commandLine.hasOption("type") &&
        !commandLine.hasOption("processor")) {
      modelInfo.type = commandLine.getOptionValue("type");
      if (commandLine.hasOption("version")) {
        modelInfo.version = commandLine.getOptionValue("version");
      }

      if (commandLine.hasOption("configuration")) {
        modelInfo.configuration = commandLine.getOptionValue("configuration");
      }
    } else if (commandLine.hasOption("processor") &&
               !commandLine.hasOption("type")) {
      modelInfo.processor = commandLine.getOptionValue("processor");
    } else {
      throw new ODPSConsoleException(ODPSConsoleConstants.BAD_COMMAND
              + "invalid parameter for offlinemodel, please HELP OFFLINEMODEL.");
    }

    if (commandLine.getArgList().size() != 1) {
      throw new ODPSConsoleException(ODPSConsoleConstants.BAD_COMMAND + "Model name is ambiguous.");
    }

    String modelName = commandLine.getArgs()[0];
    if (!modelName.matches("[\\w]+")) {
      throw new ODPSConsoleException(ODPSConsoleConstants.BAD_COMMAND + "Invalid model name.");
    }
    modelInfo.modelName = modelName;
    return modelInfo;
  }