private XFlowInstance CreateXflowInstance()

in odps-console-xflow/src/main/java/com/aliyun/openservices/odps/console/xflow/PAICommand.java [210:285]


  private XFlowInstance CreateXflowInstance(Odps odps, CommandLine cl,
      StringBuilder urlBuilder) throws OdpsException, ODPSConsoleException{
    String algoName = cl.getOptionValue("name");
    String projectName = cl.getOptionValue("project");
    Properties properties = cl.getOptionProperties("D");

    String runningProject = odps.getDefaultProject();
    replaceProperty(properties, runningProject);

    XFlowInstance xFlowInstance = new XFlowInstance();
    xFlowInstance.setXflowName(algoName);

    if (projectName == null) {
      xFlowInstance.setProject("algo_public");
    } else {
      xFlowInstance.setProject(projectName);
    }



    String guid = UUID.randomUUID().toString();
    if (printUrlList.contains(algoName.toUpperCase())) {
      final String token = properties.getProperty("token");
      final String host = properties.getProperty("host");
      String defaultToken = new SimpleDateFormat("yyyyMMddHHmmss").format(
          new Date());
      defaultToken += "xflowinstance";
      defaultToken += guid.replaceAll("-", "");
      final String defaultHost = printUrlHosts.get(
          printUrlList.indexOf(algoName.toUpperCase()));
      urlBuilder.append("http://");
      if (token == null) {
        urlBuilder.append(defaultToken);
      } else {
        urlBuilder.append(token);
      }
      if (host == null) {
        urlBuilder.append("." + defaultHost);
      } else {
        urlBuilder.append("." + host);
      }

      if (token == null) {
        xFlowInstance.setParameter("token", defaultToken);
      }

      if (host == null) {
        xFlowInstance.setParameter("host", defaultHost);
      }
    }

    for (Entry<Object, Object> property : properties.entrySet()) {
      String value = property.getValue().toString();
      if (value.toLowerCase().startsWith(TEMP_RESOURCE_PREFIX)) {
        try {
          value = new URL(URLDecoder.decode(value, "utf-8")).getPath();
        } catch (IOException e) {
          throw new ODPSConsoleException("Invalid temp fileName:" + e.getMessage(), e);
        }
        value = odps.resources().createTempResource(runningProject, value).getName();
      }
      xFlowInstance.setParameter(property.getKey().toString(), value);
    }

    xFlowInstance.setGuid(guid);

    Integer priority = getContext().getPaiPriority();
    xFlowInstance.setPriority(priority);

    HashMap<String, String> userConfig = getUserConfig(cl);
    for (Entry<String, String> property : userConfig.entrySet()) {
      xFlowInstance.setProperty(property.getKey(), property.getValue());
    }

    return xFlowInstance;
  }