/*
  * use to synchronize column list for output connections.
  */
 private void syncOutputNodeColumnsList(List<ColumnNameChanged> columnNameChanged) {
   if (outputdataContainer == null) {
     return;
   }
   for (IConnection conn : node.getOutgoingConnections()) {
     INode targetNode = conn.getTarget();
     EConnectionType connStyle = conn.getLineStyle();
     if (EConnectionType.FLOW_MAIN.equals(connStyle)
         || EConnectionType.FLOW_MERGE.equals(connStyle)
         || EConnectionType.FLOW_REF.equals(connStyle)) {
       ColumnListController.updateColumnList(targetNode, columnNameChanged);
       // fix for TDI-23202
       // reset value in order to call "firePropertyChange(RETURNS_CHANGED, null, null)"
       IElementParameter defaultMap =
           targetNode.getElementParameter(EParameterName.DEFAULT_MAP.getName());
       if (defaultMap != null) {
         if ("tFlowToIterate".equals(targetNode.getComponent().getName())) {
           // update target properties incase any old columns are removed
           IElementParameter elementParameter = targetNode.getElementParameter("MAP");
           if (elementParameter != null) {
             Object value = elementParameter.getValue();
             if (value instanceof List) {
               for (Object obj : (List) value) {
                 if (obj instanceof Map) {
                   Object object = ((Map) obj).get("VALUE");
                   if (newOutputMetadata != null
                       && !newOutputMetadata.getListColumns().isEmpty()) {
                     boolean found = false;
                     for (IMetadataColumn column : newOutputMetadata.getListColumns()) {
                       if (column.getLabel().equals(object)) {
                         found = true;
                       }
                     }
                     if (!found) {
                       ((Map) obj)
                           .put("VALUE", newOutputMetadata.getListColumns().get(0).getLabel());
                     }
                   } else {
                     ((Map) obj).put("VALUE", "");
                   }
                 }
               }
             }
           }
         }
         targetNode.setPropertyValue(EParameterName.DEFAULT_MAP.getName(), defaultMap.getValue());
       }
     }
   }
 }
예제 #2
0
  public String generate(Object argument) {
    final StringBuffer stringBuffer = new StringBuffer();

    CodeGeneratorArgument codeGenArgument = (CodeGeneratorArgument) argument;
    Vector v = (Vector) codeGenArgument.getArgument();
    IProcess process = (IProcess) v.get(0);
    String version = (String) v.get(1);
    String exportAsOSGI = (String) v.get(2);

    List<? extends INode> processNodes = (List<? extends INode>) process.getGeneratingNodes();
    boolean stats = codeGenArgument.isStatistics();
    boolean trace = codeGenArgument.isTrace();
    boolean isRunInMultiThread = codeGenArgument.getIsRunInMultiThread();
    List<IContextParameter> params = new ArrayList<IContextParameter>();
    params = process.getContextManager().getDefaultContext().getContextParameterList();

    IBrandingService service =
        (IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class);
    if (service instanceof AbstractBrandingService) {

      stringBuffer.append(TEXT_1);
      stringBuffer.append(((AbstractBrandingService) service).getJobLicenseHeader(version));
    }
    String jobFolderName =
        JavaResourcesHelper.getJobFolderName(process.getName(), process.getVersion());
    String packageName =
        codeGenArgument.getCurrentProjectName().toLowerCase() + "." + jobFolderName;

    stringBuffer.append(TEXT_2);
    stringBuffer.append(packageName);
    stringBuffer.append(TEXT_3);
    for (String routine : CodeGeneratorRoutine.getRequiredRoutineName(process)) {
      if (!routine.equals(ITalendSynchronizer.TEMPLATE)) {
        stringBuffer.append(TEXT_4);
        stringBuffer.append(routine);
        stringBuffer.append(TEXT_5);
      }
    }
    stringBuffer.append(TEXT_6);
    stringBuffer.append(TEXT_7);
    stringBuffer.append(ElementParameterParser.getValue(process, "__HEADER_IMPORT__"));
    stringBuffer.append(TEXT_8);
    stringBuffer.append(ElementParameterParser.getValue(process, "__FOOTER_IMPORT__"));
    stringBuffer.append(TEXT_9);

    List<INode> nodesWithImport = process.getNodesWithImport();
    if (nodesWithImport != null) {
      for (INode node : nodesWithImport) {

        stringBuffer.append(TEXT_10);
        stringBuffer.append(node.getUniqueName());
        stringBuffer.append(TEXT_11);
        stringBuffer.append(ElementParameterParser.getValue(node, "__IMPORT__"));
        stringBuffer.append(TEXT_12);
      }
    }

    stringBuffer.append(TEXT_13);
    stringBuffer.append(process.getName());
    stringBuffer.append(TEXT_14);
    stringBuffer.append(ElementParameterParser.getValue(process, "__PURPOSE__"));
    stringBuffer.append(TEXT_15);
    stringBuffer.append(ElementParameterParser.getValue(process, "__DESCRIPTION__"));
    stringBuffer.append(TEXT_16);
    stringBuffer.append(ElementParameterParser.getValue(process, "__AUTHOR__"));
    stringBuffer.append(TEXT_17);
    stringBuffer.append(version);
    stringBuffer.append(TEXT_18);
    stringBuffer.append(ElementParameterParser.getValue(process, "__STATUS__"));
    stringBuffer.append(TEXT_19);

    String talendJobInterfaces = "TalendJob";

    boolean talendMdmJob =
        !process.getNodesOfType("tMDMTriggerInput").isEmpty()
            || !process.getNodesOfType("tMDMTriggerOutput").isEmpty();
    boolean talendEsbJob =
        !process.getNodesOfType("tESBProviderRequest").isEmpty()
            || !process.getNodesOfType("tESBConsumer").isEmpty();
    boolean talendEsbJobFactory = !process.getNodesOfType("tESBProviderRequest").isEmpty();

    if (talendMdmJob) {
      talendJobInterfaces += ", TalendMDMJob"; // Talend MDM job
    }
    if (talendEsbJob) {
      talendJobInterfaces += ", TalendESBJob"; // Talend ESB job
    }
    if (talendEsbJobFactory) {
      talendJobInterfaces += ", TalendESBJobFactory"; // Talend ESB provider job
    }

    stringBuffer.append(TEXT_20);
    stringBuffer.append(process.getName());
    stringBuffer.append(TEXT_21);
    stringBuffer.append(talendJobInterfaces);
    stringBuffer.append(TEXT_22);
    if (talendEsbJobFactory) {
      stringBuffer.append(TEXT_23);
      stringBuffer.append(process.getName());
      stringBuffer.append(TEXT_24);
      stringBuffer.append(process.getName());
      stringBuffer.append(TEXT_25);
    }
    stringBuffer.append(TEXT_26);

    if (isRunInMultiThread) {

      stringBuffer.append(TEXT_27);
    }

    stringBuffer.append(TEXT_28);
    // it will be use in job setting.
    stringBuffer.append(TEXT_29);
    // uft-8 is for temp file, for example: tSortRow, tMap. Because they need keep reversibility.
    stringBuffer.append(TEXT_30);
    for (IContextParameter ctxParam : params) {
      String cParaName = ctxParam.getName();

      stringBuffer.append(TEXT_31);
      stringBuffer.append(cParaName);
      stringBuffer.append(TEXT_32);
      if (ctxParam.getType().equals("id_Date")) {
        stringBuffer.append(TEXT_33);
        stringBuffer.append(cParaName);
        stringBuffer.append(TEXT_34);
        stringBuffer.append(cParaName);
        stringBuffer.append(TEXT_35);
        stringBuffer.append(ctxParam.getValue());
        stringBuffer.append(TEXT_36);
        stringBuffer.append(cParaName);
        stringBuffer.append(TEXT_37);
        stringBuffer.append(cParaName);
        stringBuffer.append(TEXT_38);
        stringBuffer.append(cParaName);
        stringBuffer.append(TEXT_39);
        stringBuffer.append(cParaName);
        stringBuffer.append(TEXT_40);
        stringBuffer.append(cParaName);
        stringBuffer.append(TEXT_41);
        stringBuffer.append(cParaName);
        stringBuffer.append(TEXT_42);
        stringBuffer.append(cParaName);
        stringBuffer.append(TEXT_43);
        stringBuffer.append(cParaName);
        stringBuffer.append(TEXT_44);
        stringBuffer.append(cParaName);
        stringBuffer.append(TEXT_45);
        stringBuffer.append(cParaName);
        stringBuffer.append(TEXT_46);
        stringBuffer.append(cParaName);
        stringBuffer.append(TEXT_47);
        stringBuffer.append(cParaName);
        stringBuffer.append(TEXT_48);
      } else {
        stringBuffer.append(TEXT_49);
        stringBuffer.append(cParaName);
        stringBuffer.append(TEXT_50);
        stringBuffer.append(cParaName);
        stringBuffer.append(TEXT_51);
      }
      stringBuffer.append(TEXT_52);
    }
    stringBuffer.append(TEXT_53);

    for (IContextParameter ctxParam : params) {
      if (ctxParam.getType().equals("id_List Of Value")
          || ctxParam.getType().equals("id_File")
          || ctxParam.getType().equals("id_Directory")) {

        stringBuffer.append(TEXT_54);
        stringBuffer.append(ctxParam.getName());
        stringBuffer.append(TEXT_55);
        stringBuffer.append(
            Character.toUpperCase(ctxParam.getName().charAt(0)) + ctxParam.getName().substring(1));
        stringBuffer.append(TEXT_56);
        stringBuffer.append(ctxParam.getName());
        stringBuffer.append(TEXT_57);

      } else {

        stringBuffer.append(TEXT_58);
        stringBuffer.append(JavaTypesManager.getTypeToGenerate(ctxParam.getType(), true));
        stringBuffer.append(TEXT_59);
        stringBuffer.append(ctxParam.getName());
        stringBuffer.append(TEXT_60);
        stringBuffer.append(JavaTypesManager.getTypeToGenerate(ctxParam.getType(), true));
        stringBuffer.append(TEXT_61);
        stringBuffer.append(
            Character.toUpperCase(ctxParam.getName().charAt(0)) + ctxParam.getName().substring(1));
        stringBuffer.append(TEXT_62);
        stringBuffer.append(ctxParam.getName());
        stringBuffer.append(TEXT_63);
      }
    }

    stringBuffer.append(TEXT_64);
    stringBuffer.append(process.getVersion());
    stringBuffer.append(TEXT_65);
    stringBuffer.append(codeGenArgument.getJobName());
    stringBuffer.append(TEXT_66);
    stringBuffer.append(codeGenArgument.getCurrentProjectName());
    stringBuffer.append(TEXT_67);

    if (!isRunInMultiThread) {

      stringBuffer.append(TEXT_68);

    } else {

      stringBuffer.append(TEXT_69);
    }
    stringBuffer.append(TEXT_70);

    if (stats) {

      stringBuffer.append(TEXT_71);
    }

    if (trace) {

      stringBuffer.append(TEXT_72);
    }

    stringBuffer.append(TEXT_73);
    stringBuffer.append(exportAsOSGI);
    stringBuffer.append(TEXT_74);

    for (INode logCatcher : process.getNodesOfType("tLogCatcher")) {

      stringBuffer.append(TEXT_75);
      stringBuffer.append(logCatcher.getUniqueName());
      stringBuffer.append(TEXT_76);
    }

    for (INode statCatcher : process.getNodesOfType("tStatCatcher")) {

      stringBuffer.append(TEXT_77);
      stringBuffer.append(statCatcher.getUniqueName());
      stringBuffer.append(TEXT_78);
      stringBuffer.append(process.getId());
      stringBuffer.append(TEXT_79);
      stringBuffer.append(process.getVersion());
      stringBuffer.append(TEXT_80);
    }

    for (INode metterCatcher : process.getNodesOfType("tFlowMeterCatcher")) {

      stringBuffer.append(TEXT_81);
      stringBuffer.append(metterCatcher.getUniqueName());
      stringBuffer.append(TEXT_82);
      stringBuffer.append(process.getId());
      stringBuffer.append(TEXT_83);
      stringBuffer.append(process.getVersion());
      stringBuffer.append(TEXT_84);
    }

    for (INode assertCatcher : process.getNodesOfType("tAssertCatcher")) {

      stringBuffer.append(TEXT_85);
      stringBuffer.append(assertCatcher.getUniqueName());
      stringBuffer.append(TEXT_86);
    }

    stringBuffer.append(TEXT_87);
    stringBuffer.append(process.getName());
    stringBuffer.append(TEXT_88);
    stringBuffer.append(process.getName());
    stringBuffer.append(TEXT_89);

    if (process.getNodesOfType("tLogCatcher").size() > 0) {
      List<INode> logCatchers = (List<INode>) process.getNodesOfType("tLogCatcher");
      for (INode logCatcher : logCatchers) {
        if (ElementParameterParser.getValue(logCatcher, "__CATCH_JAVA_EXCEPTION__")
            .equals("true")) {
          // 1) add the message to the stack

          stringBuffer.append(TEXT_90);
          stringBuffer.append(logCatcher.getUniqueName());
          stringBuffer.append(TEXT_91);
        }
      }

      INode virtualNCatchNode = null;
      boolean hasRealCatchNode = false;
      for (INode logCatcher : logCatchers) {
        if (ElementParameterParser.getValue(logCatcher, "__CATCH_JAVA_EXCEPTION__")
            .equals("true")) {
          if (logCatcher.isVirtualGenerateNode()) {
            virtualNCatchNode = logCatcher;
          } else {
            hasRealCatchNode = true;
          }
        }
      }
      if (hasRealCatchNode && virtualNCatchNode != null) {

        stringBuffer.append(TEXT_92);
      }
      for (INode logCatcher : logCatchers) {
        if (ElementParameterParser.getValue(logCatcher, "__CATCH_JAVA_EXCEPTION__")
            .equals("true")) {
          if (logCatcher != virtualNCatchNode) {
            // 2) launch logCatcher subProcess

            stringBuffer.append(TEXT_93);
            stringBuffer.append(logCatcher.getDesignSubjobStartNode().getUniqueName());
            stringBuffer.append(TEXT_94);
          }
        }
      }
      if (hasRealCatchNode && virtualNCatchNode != null) {

        stringBuffer.append(TEXT_95);
      }
      if (virtualNCatchNode != null) {

        stringBuffer.append(TEXT_96);
        stringBuffer.append(virtualNCatchNode.getDesignSubjobStartNode().getUniqueName());
        stringBuffer.append(TEXT_97);
      }
      if (hasRealCatchNode && virtualNCatchNode != null) {

        stringBuffer.append(TEXT_98);
      }
    }

    stringBuffer.append(TEXT_99);

    boolean needCatchTalendException = false;
    if (process.getNodesOfType("tLogCatcher").size() > 0) {
      for (INode node : process.getNodesOfType("tLogCatcher")) {
        if (ElementParameterParser.getValue(node, "__CATCH_JAVA_EXCEPTION__").equals("true")) {
          needCatchTalendException = true;
          break;
        }
      }
    }

    if ((!needCatchTalendException) && (process.getNodesOfType("tAssertCatcher").size() > 0)) {
      for (INode node : process.getNodesOfType("tAssertCatcher")) {
        if (ElementParameterParser.getValue(node, "__CATCH_JAVA_EXCEPTION__").equals("true")) {
          needCatchTalendException = true;
          break;
        }
      }
    }
    if (needCatchTalendException) {
      if (process.getNodesOfType("tLogCatcher").size() > 0) {

        stringBuffer.append(TEXT_100);
      }
    }

    stringBuffer.append(TEXT_101);

    if (isRunInMultiThread) {

      stringBuffer.append(TEXT_102);

    } else {
      stringBuffer.append(TEXT_103);
    }

    stringBuffer.append(TEXT_104);
    // Methods for RUN IF Error links

    for (INode node : processNodes) {
      if (node.isActivate()) {

        stringBuffer.append(TEXT_105);
        stringBuffer.append(node.getUniqueName());
        stringBuffer.append(TEXT_106);
        stringBuffer.append(node.getUniqueName());
        stringBuffer.append(TEXT_107);

        boolean ifBeforRunError = NodeUtil.checkComponentErrorConnectionAfterNode(node);
        if (!ifBeforRunError) {
          if (process.getNodesOfType("tAssertCatcher").size() > 0) {
            List<INode> assertCatchers = (List<INode>) process.getNodesOfType("tAssertCatcher");
            for (INode assertCatcher : assertCatchers) {
              if (ElementParameterParser.getValue(assertCatcher, "__CATCH_JAVA_EXCEPTION__")
                  .equals("true")) {
                // 1) add the message to the stack

                stringBuffer.append(TEXT_108);
                stringBuffer.append(assertCatcher.getUniqueName());
                stringBuffer.append(TEXT_109);
                stringBuffer.append(assertCatcher.getDesignSubjobStartNode().getUniqueName());
                stringBuffer.append(TEXT_110);
              }
            }
          }
        }
        if (!node.getComponent().getName().equals("tDie")) {
          String statCatcher = ElementParameterParser.getValue(node, "__TSTATCATCHER_STATS__");
          if (statCatcher.compareTo("true") == 0) {
            for (INode statCatcherNode : node.getProcess().getNodesOfType("tStatCatcher")) {

              stringBuffer.append(TEXT_111);
              stringBuffer.append(statCatcherNode.getUniqueName());
              stringBuffer.append(TEXT_112);
              stringBuffer.append(node.getUniqueName());
              stringBuffer.append(TEXT_113);
              stringBuffer.append(node.getUniqueName());
              stringBuffer.append(TEXT_114);
              stringBuffer.append(node.getUniqueName());
              stringBuffer.append(TEXT_115);
              stringBuffer.append(statCatcherNode.getDesignSubjobStartNode().getUniqueName());
              stringBuffer.append(TEXT_116);
            }
          }
        }
        boolean isExistOnCompErrorLink = false;
        List<? extends IConnection> conns = node.getOutgoingConnections();
        for (IConnection conn : conns) {
          if (conn.getLineStyle().equals(EConnectionType.ON_COMPONENT_ERROR)) {
            isExistOnCompErrorLink = true;

            stringBuffer.append(TEXT_117);
            if (stats) {
              stringBuffer.append(TEXT_118);
              stringBuffer.append(conn.getUniqueName());
              stringBuffer.append(TEXT_119);
            }
            stringBuffer.append(TEXT_120);

            if (isRunInMultiThread) {

              stringBuffer.append(TEXT_121);
              stringBuffer.append(conn.getTarget().getUniqueName());
              stringBuffer.append(TEXT_122);

            } else {

              stringBuffer.append(TEXT_123);
              stringBuffer.append(conn.getTarget().getUniqueName());
              stringBuffer.append(TEXT_124);
            }

            stringBuffer.append(TEXT_125);
          }
        }
        boolean isSubjobHasOnSubJobError = false;
        if (!isExistOnCompErrorLink) {
          INode subJobStartNode = node.getDesignSubjobStartNode();
          if (subJobStartNode != null) {
            List<? extends IConnection> tempConns = subJobStartNode.getOutgoingConnections();
            for (IConnection conn : tempConns) {
              if (conn.getLineStyle().equals(EConnectionType.ON_SUBJOB_ERROR)) {
                isSubjobHasOnSubJobError = true;
                break;
              }
            }
          }
        }

        if (!isSubjobHasOnSubJobError
            && !isExistOnCompErrorLink) { // when there is no subjoberror and no onComponentError
          if (isRunInMultiThread) {

            stringBuffer.append(TEXT_126);

          } else {

            stringBuffer.append(TEXT_127);
          }
        }
        // when use parallelize will add virtual components(tAsyncIn and tAsyncOut) but in graphical
        // these is visable=false
        if ("true".equals(ElementParameterParser.getValue(node, "__PARALLELIZE__"))) {
          for (INode gNode : node.getProcess().getGeneratingNodes()) {
            if (gNode.getUniqueName().equals(node.getUniqueName())) {
              if (gNode.getIncomingConnections(EConnectionType.FLOW_MAIN).size() != 0) {
                INode gSourceNode =
                    gNode.getIncomingConnections(EConnectionType.FLOW_MAIN).get(0).getSource();
                node = gSourceNode;
              }
            }
          }
        }
        // end

        stringBuffer.append(TEXT_128);
        stringBuffer.append(node.getDesignSubjobStartNode().getUniqueName());
        stringBuffer.append(TEXT_129);
      }
    }
    for (INode node : processNodes) {
      if (node.isDesignSubjobStartNode()) {

        stringBuffer.append(TEXT_130);
        stringBuffer.append(node.getUniqueName());
        stringBuffer.append(TEXT_131);

        List<? extends IConnection> conns = node.getOutgoingConnections();
        int count = 0;
        for (IConnection conn : conns) {
          if (conn.getLineStyle().equals(EConnectionType.ON_SUBJOB_ERROR)) {
            count++;
          }
        }

        String label = "ERROR";

        if (count == 0) { // FATAL
          label = "FATAL";
        } else { // ERROR------>RunSubJobError
          label = "ERROR";
        }

        stringBuffer.append(TEXT_132);
        stringBuffer.append(label);
        stringBuffer.append(TEXT_133);

        for (IConnection conn : conns) {
          if (conn.getLineStyle().equals(EConnectionType.ON_SUBJOB_ERROR)) {

            stringBuffer.append(TEXT_134);
            if (stats) {
              stringBuffer.append(TEXT_135);
              stringBuffer.append(conn.getUniqueName());
              stringBuffer.append(TEXT_136);
            }

            if (isRunInMultiThread) {

              stringBuffer.append(TEXT_137);
              stringBuffer.append(conn.getTarget().getUniqueName());
              stringBuffer.append(TEXT_138);

            } else {

              stringBuffer.append(TEXT_139);
              stringBuffer.append(conn.getTarget().getUniqueName());
              stringBuffer.append(TEXT_140);
            }

            stringBuffer.append(TEXT_141);
          }
        }

        stringBuffer.append(TEXT_142);
      }
    }

    stringBuffer.append(TEXT_143);
    return stringBuffer.toString();
  }
  private void propagateDatas(boolean isExecute) {
    String baseConnectorForCurrentNode =
        node.getConnectorFromName(currentConnector).getBaseSchema();

    // Propagate :
    if (outputdataContainer != null
        && (!outputdataContainer.getInputs().isEmpty()
            || !outputdataContainer.getOuputs().isEmpty())) {
      for (IODataComponent currentIO : outputdataContainer.getInputs()) {
        INode sourceNode = currentIO.getSource();
        if (currentIO.hasChanged()
            && (sourceNode
                .getConnectorFromName(currentIO.getConnection().getConnectorName())
                .getBaseSchema()
                .equals(baseConnectorForCurrentNode))) {
          sourceNode.metadataOutputChanged(currentIO, currentIO.getName());
          if (isExecute) {
            currentIO.setTable(oldInputMetadata);
            currentIO.setColumnNameChanged(null);
          } else {
            currentIO.setTable(newInputMetadata);
            currentIO.setColumnNameChanged(null);
          }
        }
      }
      for (IODataComponent currentIO : outputdataContainer.getOuputs()) {
        INodeConnector nodeConnector = null;
        String baseConnector = null;

        Node sourceNode = (Node) currentIO.getSource();
        nodeConnector =
            sourceNode.getConnectorFromName(currentIO.getConnection().getConnectorName());
        baseConnector = nodeConnector.getBaseSchema();

        INode targetNode = currentIO.getTarget();

        boolean sourceIsBuiltIn =
            ((Node) currentIO.getSource())
                .getConnectorFromType(currentIO.getConnection().getLineStyle())
                .isMultiSchema();

        boolean targetIsBuiltIn =
            ((Node) targetNode)
                .getConnectorFromType(currentIO.getConnection().getLineStyle())
                .isMultiSchema();
        boolean isJoblet = ((Node) targetNode).isJoblet();
        if (!isJoblet
            && baseConnector.equals(baseConnectorForCurrentNode)
            && (targetIsBuiltIn
                || (targetNode.getMetadataFromConnector(baseConnector) != null
                    && !targetNode
                        .getMetadataFromConnector(baseConnector)
                        .sameMetadataAs(newOutputMetadata)))) {

          targetNode.metadataInputChanged(currentIO, currentIO.getUniqueName());
          if (isExecute) {
            if (targetNode instanceof Node) {
              if (((Node) targetNode).getComponent().isSchemaAutoPropagated()
                  && getPropagate()
                  && targetNode.getMetadataList().size() > 0) {
                IMetadataTable tmpClone;
                if (sourceIsBuiltIn) {
                  IMetadataTable tab =
                      node.getMetadataTable(
                          currentIO.getConnection().getMetadataTable().getTableName());
                  if (tab == null && node.getJobletNode() != null) {
                    tab =
                        node.getJobletNode()
                            .getMetadataTable(
                                currentIO.getConnection().getMetadataTable().getTableName());
                  }
                  tmpClone = tab.clone(true);
                } else {
                  IMetadataTable tab =
                      node.getMetadataFromConnector(currentIO.getConnection().getConnectorName());
                  if (tab == null && node.getJobletNode() != null) {
                    tab =
                        node.getJobletNode()
                            .getMetadataFromConnector(currentIO.getConnection().getConnectorName());
                  }
                  tmpClone = tab.clone(true);
                }
                IMetadataTable toCopy = newOutputMetadata.clone();

                // wzhang modify to add feature 7611

                String dbmsId = null;
                IMetadataTable copy;
                if (((Node) targetNode).getMetadataFromConnector(baseConnector) != null) {
                  dbmsId = targetNode.getMetadataFromConnector(baseConnector).getDbms();
                  MetadataToolHelper.copyTable(dbmsId, toCopy, tmpClone);
                  toCopy = tmpClone;

                  // only if the target node have exactly the same connector
                  copy = ((Node) targetNode).getMetadataFromConnector(baseConnector).clone(true);
                } else {
                  final String mainConnector =
                      "FLOW"; // can only be FLOW right now for this case. //$NON-NLS-1$

                  dbmsId = targetNode.getMetadataFromConnector(mainConnector).getDbms();
                  MetadataToolHelper.copyTable(dbmsId, toCopy, tmpClone);
                  toCopy = tmpClone;
                  // if don't have the same connector, take the main connector of the component.

                  copy = ((Node) targetNode).getMetadataFromConnector(mainConnector).clone(true);
                }
                // MetadataTool.copyTable(toCopy, copy);
                // wzhang modify to add feature 7611
                MetadataToolHelper.copyTable(dbmsId, toCopy, copy);
                ChangeMetadataCommand cmd =
                    new ChangeMetadataCommand(targetNode, null, null, copy, inputSchemaParam);
                if (outputdataContainer.getOuputs().size() > 0) {
                  List<ColumnNameChanged> columnNameChanged =
                      outputdataContainer.getOuputs().get(0).getColumnNameChanged();
                  for (IODataComponent dataComp : cmd.outputdataContainer.getOuputs()) {
                    dataComp.setColumnNameChanged(columnNameChanged);
                  }
                }
                cmd.execute(true);
                propagatedChange.add(cmd);
              }
            }
            currentIO.setTable(oldOutputMetadata);
            currentIO.setColumnNameChanged(null);
          } else {
            if (targetNode instanceof Node) {
              if (!targetIsBuiltIn && getPropagate()) {
                if (((Node) targetNode).getComponent().isSchemaAutoPropagated()) {
                  if (outputdataContainer.getOuputs().size() > 0) {
                    List<ColumnNameChanged> columnNameChanged =
                        outputdataContainer.getOuputs().get(0).getColumnNameChanged();
                    for (ChangeMetadataCommand cmd : propagatedChange) {
                      for (IODataComponent dataComp : cmd.outputdataContainer.getOuputs()) {
                        dataComp.setColumnNameChanged(columnNameChanged);
                      }
                    }
                  }
                }
              }
            }

            currentIO.setTable(newOutputMetadata);
            currentIO.setColumnNameChanged(null);
          }
        }
      }
    } else if (dataComponent != null) {
      for (IConnection outgoingConnection : node.getOutgoingConnections()) {
        if (outgoingConnection.getConnectorName().equals(currentConnector)) {
          outgoingConnection
              .getTarget()
              .metadataInputChanged(dataComponent, outgoingConnection.getName());
        }
      }
    } else {
      if (!node.getOutgoingConnections().isEmpty()) {
        IMetadataTable relativeOldOutputMetadata = null;
        IMetadataTable relativeNewOutputMetadata = null;
        if (isExecute) {
          relativeOldOutputMetadata = oldOutputMetadata;
          relativeNewOutputMetadata = newOutputMetadata;
        } else {
          relativeOldOutputMetadata = newOutputMetadata;
          relativeNewOutputMetadata = oldOutputMetadata;
        }
        for (IConnection outgoingConnection : node.getOutgoingConnections()) {
          final Node target = (Node) outgoingConnection.getTarget();
          if (target != null && target.getExternalNode() != null) {
            List<IMetadataColumn> oldListColumns = relativeOldOutputMetadata.getListColumns();
            List<IMetadataColumn> newListColumns = relativeNewOutputMetadata.getListColumns();
            List<ColumnNameChanged> columnNameChanges = new ArrayList<ColumnNameChanged>();
            int size = oldListColumns.size();
            int newSize = newListColumns.size();
            if (newSize < size) {
              size = newSize;
            }
            IODataComponent output =
                new IODataComponent(outgoingConnection, relativeNewOutputMetadata);
            if (newListColumns != null) {
              List<ColumnNameChanged> newColumnsList = output.getNewMetadataColumns();
              // new added columns list
              Set<String> newAddedColumns = new HashSet<String>();
              // newest columns after user changed
              Set<String> newestColumns = new HashSet<String>();

              // init
              if (newColumnsList != null) {
                for (ColumnNameChanged columnChanged : newColumnsList) {
                  newAddedColumns.add(columnChanged.getNewName());
                }
              }
              for (IMetadataColumn metadataColumn : newListColumns) {
                newestColumns.add(metadataColumn.getLabel());
              }

              // check
              for (int i = 0; i < size; i++) {
                IMetadataColumn oldMetadataColumn = oldListColumns.get(i);
                String columnName = oldMetadataColumn.getLabel();
                // if this column(before changing) is not exists in the new columns(after changing),
                // there are two possible truth: 1. this column has been renamed; 2. this column has
                // been removed
                if (!newestColumns.contains(columnName)) {
                  IMetadataColumn newMetadataColumn = newListColumns.get(i);
                  String newColumnNameAtThisIndex = newMetadataColumn.getLabel();
                  // if the column at the same position in new table is a new column(two possible
                  // truth: 1. an old column's name has been changed; 2. user add a new column);
                  // For now, Seems it is very hard to judge whether it is a renamed column or a new
                  // column, so we suppose the more possible truth is that it is a renamed column
                  if (newAddedColumns.contains(newColumnNameAtThisIndex)) {
                    columnNameChanges.add(
                        new ColumnNameChanged(columnName, newColumnNameAtThisIndex));
                  }
                }
              }
            }

            if (GlobalServiceRegister.getDefault().isServiceRegistered(IXmlMapService.class)) {
              final IXmlMapService service =
                  (IXmlMapService)
                      GlobalServiceRegister.getDefault().getService(IXmlMapService.class);
              if (service.isXmlMapComponent(target.getExternalNode())) {
                output.setColumnNameChanged(columnNameChanges);
                target.metadataInputChanged(output, outgoingConnection.getName());
              }
            }
            if (GlobalServiceRegister.getDefault().isServiceRegistered(ISparkMapService.class)) {
              final ISparkMapService service =
                  (ISparkMapService)
                      GlobalServiceRegister.getDefault().getService(ISparkMapService.class);
              if (service.isSparkMapComponent(target.getExternalNode())) {
                output.setColumnNameChanged(columnNameChanges);
                target.metadataInputChanged(output, outgoingConnection.getName());
              }
            }

            if (GlobalServiceRegister.getDefault().isServiceRegistered(IDbMapService.class)) {
              final IDbMapService service =
                  (IDbMapService)
                      GlobalServiceRegister.getDefault().getService(IDbMapService.class);
              if (service.isDbMapComponent(target.getExternalNode())) {
                // TDI-25307:should setColumNameChanged here for ELtDbMap in case the propagate
                // schema
                // does not affect it.
                output.setColumnNameChanged(columnNameChanges);
                target.metadataInputChanged(output, outgoingConnection.getName());
              }
            }
          }
        }
      }
    }

    if (inputdataContainer != null) {
      for (IODataComponent currentIO : inputdataContainer.getOuputs()) {
        if (currentIO.hasChanged()
            && (currentIO
                .getSource()
                .getConnectorFromName(currentIO.getConnection().getConnectorName())
                .getBaseSchema()
                .equals(currentConnector))) {
          INode targetNode = currentIO.getTarget();
          targetNode.metadataInputChanged(currentIO, currentIO.getUniqueName());
          if (isExecute) {
            currentIO.setTable(oldInputMetadata);
            currentIO.setColumnNameChanged(null);
          } else {
            currentIO.setTable(newInputMetadata);
            currentIO.setColumnNameChanged(null);
          }
        }
      }
    }
    // End propagate
  }