public void transform(NodeType node) {

      if (ComponentUtilities.getNodeProperty(node, name) == null) {
        ComponentUtilities.addNodeProperty(node, name, field);
      }

      String host = "", port = "";
      boolean hostDone = false, portDone = false;

      for (Object o : node.getElementParameter()) {
        ElementParameterType para = (ElementParameterType) o;
        if ("HOST".equals(para.getName())) {
          host = para.getValue();
          hostDone = true;
        }
        if ("PORT".equals(para.getName())) {
          port = para.getValue();
          portDone = true;
        }
        if (hostDone && portDone) break;
      }

      for (Object o : node.getElementParameter()) {
        ElementParameterType para = (ElementParameterType) o;
        if ("DB_VERSION".equals(para.getName())) { // $NON-NLS-1$
          if (para.getValue().startsWith("hadoop-0.20.2-dev-core.jar")) {
            ComponentUtilities.setNodeValue(
                node, name, "\"maprfs://\"+" + host + "+\":\" + " + port + " + \"/\"");
          } else {
            ComponentUtilities.setNodeValue(node, name, "\"hdfs://\"+" + host + "+\":\" + " + port);
          }
          break;
        }
      }
    }
  /*
   * (non-Javadoc)
   *
   * @see
   * org.talend.core.model.migration.TXMLMapChangeAllInOneValueMigrationTask
   * (org .talend.core.model.properties.Item)
   */
  @Override
  public ExecutionResult execute(Item item) {

    IProxyRepositoryFactory factory =
        CorePlugin.getDefault().getRepositoryService().getProxyRepositoryFactory();
    ProcessType processType = getProcessType(item);
    boolean modified = false;

    if (processType != null) {
      for (Object obj : processType.getNode()) {
        NodeType nodeType = (NodeType) obj;
        if (nodeType.getComponentName().startsWith("tXMLMap")) {
          XmlMapData xmlMapdata = (XmlMapData) nodeType.getNodeData();
          EList<OutputXmlTree> outputTables = xmlMapdata.getOutputTrees();
          EList<InputXmlTree> inputTables = xmlMapdata.getInputTrees();
          boolean hasDocumentInTheMainInputTable = false;
          for (InputXmlTree inputTable : inputTables) {
            if (!(inputTable.isLookup())) {
              for (TreeNode inputEntry : inputTable.getNodes()) {
                if ("id_Document".equals(inputEntry.getType())) {
                  hasDocumentInTheMainInputTable = true;
                }
              }
            }
          }
          if (hasDocumentInTheMainInputTable) {
            for (OutputXmlTree outputTable : outputTables) {
              for (TreeNode outputEntry : outputTable.getNodes()) {
                if ("id_Document".equals(outputEntry.getType())) {
                  if (!outputTable.isAllInOne()) {
                    outputTable.setAllInOne(true);
                    modified = true;
                    break;
                  }
                }
              }
            }
          }
        }
      }
    }
    try {
      if (modified) {
        factory.save(item, true);
        return ExecutionResult.SUCCESS_WITH_ALERT;
      } else {
        return ExecutionResult.SUCCESS_NO_ALERT;
      }
    } catch (Exception e) {
      ExceptionHandler.process(e);
      return ExecutionResult.FAILURE;
    }
  }
 /**
  * DOC qiang.zhang Comment method "getUNIQUENAME".
  *
  * @param node
  * @return
  */
 public static String getUNIQUENAME(NodeType node) {
   List<ElementParameterType> parameters = node.getElementParameter();
   for (ElementParameterType elementParam : parameters) {
     if (elementParam.getName().equals("UNIQUE_NAME")) { // $NON-NLS-1$
       return elementParam.getValue();
     }
   }
   return ""; //$NON-NLS-1$
 }
 protected static boolean checkIsDeactivated(NodeType nodeType) {
   @SuppressWarnings("unchecked")
   List<ElementParameterType> params = nodeType.getElementParameter();
   for (ElementParameterType param : params) {
     if (param.getName().equals("Activate")) {
       return "false".equals(param.getValue());
     }
   }
   return false;
 }
示例#5
0
  @Override
  public List<ModuleNeeded> getModulesNeededForJobs() throws PersistenceException {
    List<ModuleNeeded> importNeedsList = new ArrayList<ModuleNeeded>();
    IProxyRepositoryFactory repositoryFactory =
        CoreRuntimePlugin.getInstance().getRepositoryService().getProxyRepositoryFactory();
    ERepositoryObjectType jobType = ERepositoryObjectType.PROCESS;
    if (jobType != null) {
      List<IRepositoryViewObject> jobs = repositoryFactory.getAll(jobType, true);
      for (IRepositoryViewObject cur : jobs) {
        if (!cur.isDeleted()) {
          ProcessItem item = (ProcessItem) cur.getProperty().getItem();
          if (item == null || item.getProcess() == null) {
            continue;
          }
          List<NodeType> nodes = item.getProcess().getNode();
          for (NodeType node : nodes) {
            List<ElementParameterType> elementParameter = node.getElementParameter();
            for (ElementParameterType elementParam : elementParameter) {
              if (elementParam.getField() != null
                  && elementParam.getField().equals(EParameterFieldType.MODULE_LIST.getName())) {
                String uniquename = coreSerivce.getParameterUNIQUENAME(node);
                ModuleNeeded toAdd =
                    new ModuleNeeded(
                        Messages.getString("AbstractEMFRepositoryFactory.job")
                            + item.getProperty().getLabel(), // $NON-NLS-1$
                        elementParam.getValue(),
                        Messages.getString("AbstractEMFRepositoryFactory.requiredComponent")
                            + uniquename
                            + ".",
                        true); //$NON-NLS-1$ //$NON-NLS-2$
                importNeedsList.add(toAdd);
              }
            }
          }
        }
      }
    }

    return importNeedsList;
  }