private void checkContextGroupSource() {
   IContextManager contextManager = getContextManager();
   if (helper == null) {
     return;
   }
   if (contextManager != null) {
     helper.initHelper(contextManager);
     Map<String, Item> items = new HashMap<String, Item>();
     boolean needRefresh = false;
     for (IContextParameter param : contextManager.getDefaultContext().getContextParameterList()) {
       if (!param.isBuiltIn()) {
         String source = param.getSource();
         Item sourceItem = items.get(source);
         if (sourceItem == null) {
           sourceItem = ContextUtils.getRepositoryContextItemById(source);
         }
         if (sourceItem == null) { // source not found
           needRefresh = true;
           param.setSource(IContextParameter.BUILT_IN);
           propagateType(contextManager, param);
         } else {
           items.put(source, sourceItem);
         }
       }
     }
     if (needRefresh) {
       setModifiedFlag(contextManager);
       modelManager.refresh();
     }
   }
 }
 /**
  * This method is used to remove the <code>JobContextParameter</code> in <code>JobContext</code>,
  * using the combination of <code>sourceId</code> and <code>name</code> can identify the unique
  * <code>JobContextParameter</code>.
  *
  * @param sourceId
  * @param name
  */
 private void removeParameterFromContext(String sourceId, String name) {
   List<IContext> list = contextManager.getListContext();
   if (list != null && list.size() > 0) {
     for (int i = 0; i < list.size(); i++) {
       IContext context = list.get(i);
       List<IContextParameter> contextParameters = context.getContextParameterList();
       List<IContextParameter> movedList = new ArrayList<IContextParameter>();
       if (contextParameters != null && contextParameters.size() > 0) {
         for (int j = 0; j < contextParameters.size(); j++) {
           IContextParameter contextPara = contextParameters.get(j);
           String tempSourceId = contextPara.getSource();
           String tempParaName = contextPara.getName();
           if (tempSourceId.equals(sourceId) && tempParaName.equals(name)) {
             movedList.add(contextPara);
             contextParameters.remove(j);
             if (mapParams.get(context.getName()) != null) {
               mapParams.get(context.getName()).addAll(movedList);
               mapParams.put(context.getName(), mapParams.get(context.getName()));
             } else {
               mapParams.put(context.getName(), movedList);
             }
             break;
           }
         }
       }
     }
   }
 }
 public IContextParameter getRealParameter(
     IContextManager manager, String property, Object element) {
   IContextParameter para = null;
   IContext context = null;
   if (manager != null) {
     context = manager.getContext(property);
     if (context == null) {
       return null;
     }
     if (element instanceof ContextTableTabParentModel) {
       if (IContextParameter.BUILT_IN.equals(
           ((ContextTableTabParentModel) element).getSourceId())) {
         IContextParameter builtContextParameter =
             ((ContextTableTabParentModel) element).getContextParameter();
         if (builtContextParameter != null) {
           para = context.getContextParameter(builtContextParameter.getName());
         }
       }
     } else if (element instanceof ContextTableTabChildModel) {
       ContextTableTabChildModel child = (ContextTableTabChildModel) element;
       String sourceId = child.getContextParameter().getSource();
       para =
           context.getContextParameter(
               sourceId, ((ContextTableTabChildModel) element).getContextParameter().getName());
     }
   }
   return para;
 }
 /*
  * check same ContextParameter or not.
  */
 private boolean checkIsSameContextParameter() {
   List<ContextItem> allContextItem = ContextUtils.getAllContextItem();
   for (IContext context : process.getContextManager().getListContext()) {
     for (IContextParameter param : context.getContextParameterList()) {
       if (allContextItem != null) {
         ContextItem contextItem =
             ContextUtils.getContextItemById(allContextItem, param.getSource());
         ContextType contextType =
             ContextUtils.getContextTypeByName(contextItem, context.getName(), true);
         ContextParameterType contextParameterType =
             ContextUtils.getContextParameterTypeByName(contextType, param.getName());
         if (!ContextUtils.samePropertiesForContextParameter(param, contextParameterType)) {
           return false;
         }
         // if don't open the job to run it(not use the "Detect and update all jobs"), will show
         // UpdateDetectionDialog to update the context ,after updated the item, the
         // contextComboViewer still
         // set the old one , so need refresh.
         IContext runJobViewContext = getSelectedContext();
         if (runJobViewContext != null) {
           for (IContextParameter tempContext : runJobViewContext.getContextParameterList()) {
             if (tempContext.getName().equals(contextParameterType.getName())
                 && !ContextUtils.samePropertiesForContextParameter(
                     tempContext, contextParameterType)) {
               return false;
             }
           }
         }
       }
     }
   }
   return true;
 }
 private static TreeItem retrieveTreeItem(final TreeItem[] items, IContextParameter param) {
   if (items == null || param == null) {
     return null;
   }
   for (TreeItem item : items) {
     final Object data = item.getData();
     if (data != null) {
       if (data instanceof ContextVariableTabParentModel) {
         ContextVariableTabParentModel parent = (ContextVariableTabParentModel) data;
         if (parent.getContextParameter() != null
             && param.getName().equals(parent.getContextParameter().getName())) {
           return item;
         }
       } else if (data instanceof ContextVariableTabChildModel) {
         ContextVariableTabChildModel son = (ContextVariableTabChildModel) data;
         if (son.getContextParameter() != null
             && param.getName().equals(son.getContextParameter().getName())) {
           return item;
         }
       }
     }
     // search child item
     TreeItem childItem = retrieveTreeItem(item.getItems(), param);
     if (childItem != null) {
       return childItem;
     }
   }
   return null;
 }
    /*
     * (non-Javadoc)
     *
     * @see org.eclipse.gef.commands.Command#execute()
     */
    @Override
    public void execute() {
      boolean modified = false;
      if (modelManager.getContextManager() != null) {
        originalName = param.getName();
        for (IContext context : modelManager.getContextManager().getListContext()) {
          for (IContextParameter contextParameter : context.getContextParameterList()) {
            String tempSourceId = contextParameter.getSource();
            if (originalName.equals(contextParameter.getName()) && tempSourceId.equals(sourceId)) {
              contextParameter.setName(newName);

              if (contextParameter.getPrompt().equals(originalName + "?")) {
                contextParameter.setPrompt(newName + "?");
              }
              modified = true;
            }
          }
        }
        param.setName(newName);
        if (param.getPrompt().equals(originalName + "?")) {
          param.setPrompt(newName + "?");
        }
      }
      if (modified) {
        updateRelation(originalName, newName);
      }
    }
 /**
  * Set the first item of value list for the default value if this parameter does not need to
  * prompt.
  *
  * @param contextParameterList
  */
 private static void updateDefaultValueForListTypeParameter(
     List<IContextParameter> contextParameterList) {
   for (IContextParameter contextParameter : contextParameterList) {
     String[] list = contextParameter.getValueList();
     if (list == null) {
       continue;
     }
     if (list.length == 0) {
       contextParameter.setInternalValue(""); // $NON-NLS-1$
     } else {
       contextParameter.setInternalValue(list[0]);
     }
   }
 }
 private void propagateType(IContextManager contextManager, IContextParameter param) {
   for (IContext context : contextManager.getListContext()) {
     IContextParameter paramToModify = context.getContextParameter(param.getName());
     paramToModify.setType(param.getType());
     paramToModify.setComment(param.getComment());
     paramToModify.setSource(param.getSource());
   }
 }
 /*
  * (non-Javadoc)
  *
  * @see org.eclipse.gef.commands.Command#undo()
  */
 @Override
 public void undo() {
   boolean modified = false;
   if (modelManager.getContextManager() != null) {
     for (IContext context : modelManager.getContextManager().getListContext()) {
       for (IContextParameter contextParameter : context.getContextParameterList()) {
         if (param.getName().equals(contextParameter.getName())) {
           contextParameter.setType(oldValue);
           modified = true;
         }
       }
     }
   }
   if (modified) {
     updateRelation();
   }
 }
 private IContextParameter findContextPara(
     List<IContext> contexts, String columnGroupName, String contextParaName) {
   for (IContext envContext : contexts) {
     if (envContext.getName().equals(columnGroupName)) {
       List<IContextParameter> list = envContext.getContextParameterList();
       if (list != null && list.size() > 0) {
         for (IContextParameter contextPara : list) {
           String tempContextParaName = contextPara.getName();
           if (tempContextParaName.equals(contextParaName)) {
             return contextPara;
           }
         }
       }
     }
   }
   return null;
 }
 private void initExistedParametersMap() {
   if (!isValid(manager)) {
     return;
   }
   itemNameToParametersMap.clear();
   for (IContextParameter param : manager.getDefaultContext().getContextParameterList()) {
     if (!param.isBuiltIn()) {
       final String source = param.getSource();
       Set<String> paramSet = itemNameToParametersMap.get(source);
       if (paramSet == null) {
         paramSet = new HashSet<String>();
         itemNameToParametersMap.put(source, paramSet);
       }
       paramSet.add(param.getName());
     }
   }
 }
 private void removeParentModelInGroupBySource(ContextTableTabParentModel parentModel) {
   Set<String> paraNames = new HashSet<String>();
   String sourceId = parentModel.getSourceId();
   if (IContextParameter.BUILT_IN.equals(sourceId)) {
     String paraName = parentModel.getContextParameter().getName();
     paraNames.add(paraName);
   } else {
     List<ContextTabChildModel> children = parentModel.getChildren();
     if (children != null && children.size() > 0) {
       for (ContextTabChildModel child : children) {
         IContextParameter contextPara = child.getContextParameter();
         String paraName = contextPara.getName();
         paraNames.add(paraName);
       }
     }
   }
   modelManager.onContextRemoveParameter(getContextManager(), paraNames, sourceId);
 }
    /*
     * (non-Javadoc)
     *
     * @see org.eclipse.gef.commands.Command#undo()
     */
    @Override
    public void undo() {
      boolean modified = false;
      if (property.equals(ContextTableConstants.COLUMN_CHECK_PROPERTY)) {
        param.setPromptNeeded((Boolean) oldValue);
        modified = true;
      } else if (property.equals(ContextTableConstants.COLUMN_PROMPT_PROPERTY)) {
        param.setPrompt((String) oldValue);
        modified = true;
      } else if (property.equals(ContextTableConstants.COLUMN_CONTEXT_VALUE)) {
        param.setValue((String) oldValue);
        modified = true;
      }

      if (modified) {
        updateRelation();
      }
    }
  /**
   * ggu Comment method "checkAndSetDefaultValue".
   *
   * <p>if value is null or empty. will return the undef value (bug 4420).
   */
  public static void checkAndSetDefaultValue(final IContextParameter param) {
    if (param == null) {
      return;
    }
    final String value = param.getValue();
    final String type = param.getType();

    if (param.isBuiltIn() && (value == null || "".equals(value.trim()))) { // $NON-NLS-1$
      final ECodeLanguage codeLanguage = LanguageManager.getCurrentLanguage();
      switch (codeLanguage) {
        case JAVA:
          //
          break;
        case PERL:
        default:
          param.setValue("undef"); // $NON-NLS-1$
      }
    }
    return;
  }
 /*
  * (non-Javadoc)
  *
  * @see org.eclipse.gef.commands.Command#undo()
  */
 @Override
 public void undo() {
   boolean modified = false;
   if (modelManager.getContextManager() != null) {
     for (IContext context : modelManager.getContextManager().getListContext()) {
       for (IContextParameter contextParameter : context.getContextParameterList()) {
         if (newName.equals(contextParameter.getName())) {
           contextParameter.setName(originalName);
           if (contextParameter.getPrompt().equals(newName + "?")) {
             contextParameter.setPrompt(originalName + "?");
           }
           modified = true;
         }
       }
     }
   }
   if (modified) {
     // it is undo, so the order changed
     updateRelation(newName, originalName);
   }
 }
 /** @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int) */
 @Override
 public String getColumnText(final Object element, final int columnIndex) {
   String text;
   IContextParameter parameter = (IContextParameter) element;
   switch (columnIndex) {
     case 0:
       text = parameter.getName();
       break;
     case 1:
       if (ContextParameterUtils.isPasswordType(parameter)) {
         // see bug 0005661: In Run, Context password fields appear
         // in plaintext
         text = "****"; // $NON-NLS-1$
       } else {
         text = parameter.getValue();
       }
       break;
     default:
       text = super.getText(element);
   }
   return text;
 }
  public static boolean promptConfirmLauch(Shell shell, IContext context, IProcess process) {
    boolean continueLaunch = true;

    int nbValues = 0;
    if (context == null) {
      throw new IllegalArgumentException("Context is null"); // $NON-NLS-1$
    }
    // Prompt for context values ?
    for (IContextParameter parameter : context.getContextParameterList()) {
      if (parameter.isPromptNeeded()) {
        nbValues++;
      }
    }
    if (nbValues > 0) {
      IContext contextCopy = context.clone();
      PromptDialog promptDialog = new PromptDialog(shell, contextCopy);
      if (promptDialog.open() == PromptDialog.OK) {
        for (IContextParameter param : context.getContextParameterList()) {
          boolean found = false;
          IContextParameter paramCopy = null;
          for (int i = 0; i < contextCopy.getContextParameterList().size() & !found; i++) {
            paramCopy = contextCopy.getContextParameterList().get(i);
            if (param.getName().equals(paramCopy.getName())) {
              // param.setValueList(paramCopy.getValueList());
              param.setInternalValue(paramCopy.getValue());
              found = true;
            }
          }
        }
        contextComboViewer.refresh();
        contextTableViewer.refresh();
        processNeedGenCode(process);
      } else {
        continueLaunch = false;
      }
    } else {
      if (context.isConfirmationNeeded()) {
        continueLaunch =
            MessageDialog.openQuestion(
                shell,
                Messages.getString("ProcessComposite.confirmTitle"), // $NON-NLS-1$
                Messages.getString(
                    "ProcessComposite.confirmText", context.getName())); // $NON-NLS-1$
      }

      updateDefaultValueForListTypeParameter(context.getContextParameterList());
    }
    return continueLaunch;
  }
 private void updateRelation() {
   // set updated flag.
   if (param != null) {
     IContextManager manager = modelManager.getContextManager();
     if (manager != null && manager instanceof JobContextManager) {
       JobContextManager jobContextManager = (JobContextManager) manager;
       // not added new
       if (!modelManager.isRepositoryContext()
           || modelManager.isRepositoryContext()
               && jobContextManager.isOriginalParameter(param.getName())) {
         jobContextManager.setModified(true);
         manager.fireContextsChangedEvent();
       }
     }
   }
 }
 private void updateRelation(String _oldName, String _newName) {
   // set updated flag.
   if (param != null) {
     IContextManager manager = modelManager.getContextManager();
     if (manager != null && manager instanceof JobContextManager) {
       JobContextManager jobContextManager = (JobContextManager) manager;
       // not added new
       if (!modelManager.isRepositoryContext()
           || modelManager.isRepositoryContext()
               && jobContextManager.isOriginalParameter(param.getName())) {
         jobContextManager.setModified(true);
         manager.fireContextsChangedEvent();
       }
     }
   }
   // update nodes in the job
   if (modelManager instanceof ContextComposite) {
     ((ContextComposite) modelManager).switchSettingsView(_oldName, _newName);
   }
 }
 private void removeChildModelInGroupBySource(ContextTableTabChildModel child) {
   IContextParameter contextPara = child.getContextParameter();
   String sourceId = contextPara.getSource();
   String contextName = contextPara.getName();
   modelManager.onContextRemoveParameter(getContextManager(), contextName, sourceId);
 }
  public static List<ContextTableTabParentModel> constructContextDatas(
      List<IContextParameter> contextDatas) {
    List<ContextTableTabParentModel> output = new ArrayList<ContextTableTabParentModel>();
    if (!contextDatas.isEmpty()) {
      int i = 0;
      for (IContextParameter para : contextDatas) {
        String sourceId = para.getSource();
        if (IContextParameter.BUILT_IN.equals(sourceId)) {
          sourceId = para.getSource();
          ContextTableTabParentModel firstLevelNode = new ContextTableTabParentModel();
          String sourceLabel = sourceId;
          ContextItem contextItem = ContextUtils.getContextItemById2(sourceId);
          if (contextItem != null) {
            sourceLabel = contextItem.getProperty().getLabel();
            final ProjectManager pm = ProjectManager.getInstance();
            if (!pm.isInCurrentMainProject(contextItem)) {
              final Project project = pm.getProject(contextItem);
              if (project != null) {
                firstLevelNode.setProjectLabel(project.getLabel());
              }
            }
          }
          firstLevelNode.setOrder(i);
          firstLevelNode.setSourceName(sourceLabel);
          firstLevelNode.setSourceId(sourceId);
          firstLevelNode.setContextParameter(para);
          output.add(firstLevelNode);
        } else {
          ContextTableTabParentModel firstLevelNode = null;
          if (sourceId != null) {
            firstLevelNode = lookupContextParentForNonBuiltinNode(sourceId, output);
            if (firstLevelNode == null) {
              firstLevelNode = new ContextTableTabParentModel();
              output.add(firstLevelNode);
              String sourceLabel = sourceId;
              // the item maybe a joblet item now
              Item contextItem = ContextUtils.getRepositoryContextItemById(sourceId);
              if (contextItem != null) {
                sourceLabel = contextItem.getProperty().getLabel();
                final ProjectManager pm = ProjectManager.getInstance();
                if (!pm.isInCurrentMainProject(contextItem)) {
                  final Project project = pm.getProject(contextItem);
                  if (project != null) {
                    firstLevelNode.setProjectLabel(project.getLabel());
                  }
                }
              }
              firstLevelNode.setSourceName(sourceLabel);
              firstLevelNode.setOrder(i);
              firstLevelNode.setSourceId(sourceId);
            }

            ContextTableTabChildModel child = new ContextTableTabChildModel();
            child.setSourceId(sourceId);
            child.setContextParameter(para);
            child.setParent(firstLevelNode);
            firstLevelNode.addChild(child);
          }
        }
        i++;
      }
    }
    return output;
  }
Пример #22
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 Object getPropertyValue(IContextModelManager manager, Object element, int columnIndex) {

    if (isEmptyTreeNode(element)) {
      return "";
    }
    String contextParaName = ContextNatTableUtils.getCurrentContextModelName(element);
    String currentColumnName = getColumnProperty(columnIndex);
    if (currentColumnName.equals(ContextTableConstants.COLUMN_NAME_PROPERTY)) {
      if (element instanceof ContextTableTabParentModel) {
        String sourceId = ((ContextTableTabParentModel) element).getSourceId();
        if (!sourceId.equals(IContextParameter.BUILT_IN)) {
          Item item = ContextUtils.getRepositoryContextItemById(sourceId);
          if (item != null) {
            if (item instanceof JobletProcessItem) {
              return contextParaName + JOBLET_CONTEXT;
            } else if (item instanceof ProcessItem) {
              return contextParaName + JOB_CONTEXT;
            } else {
              return contextParaName + REPOSITORYT_CONTEXT;
            }
          }
        } else {
          return contextParaName;
        }
      } else {
        return contextParaName;
      }
    } else {
      IContextParameter currentParam =
          getRealParameter(manager.getContextManager(), currentColumnName, element);
      if (currentParam != null) {
        if (columnIndex == 1) {
          String contextParaType = currentParam.getType();
          JavaType javaType = ContextParameterJavaTypeManager.getJavaTypeFromId(contextParaType);
          if (javaType != null) {
            return javaType.getLabel();
          } else {
            return contextParaType;
          }
        } else if (currentColumnName.equals(ContextTableConstants.COLUMN_COMMENT_PROPERTY)) {
          return currentParam.getComment();
        } else {
          if (this.groupModel.isPartOfAGroup(columnIndex)) {
            String columnGroupName = this.groupModel.getColumnGroupByIndex(columnIndex).getName();
            if (manager.getContextManager() != null) {
              List<IContext> contexts = manager.getContextManager().getListContext();
              IContextParameter currentPara =
                  findContextPara(contexts, columnGroupName, contextParaName);
              if (currentPara == null) {
                return "";
              }
              if (currentColumnName.equals(ContextTableConstants.COLUMN_CHECK_PROPERTY)) {
                return currentPara.isPromptNeeded();
              } else if (currentColumnName.equals(ContextTableConstants.COLUMN_PROMPT_PROPERTY)) {
                return currentPara.getPrompt();
              } else if (currentColumnName.equals(ContextTableConstants.COLUMN_CONTEXT_VALUE)) {
                // because it's raw value, so need display * for password type.
                if (PasswordEncryptUtil.isPasswordType(currentPara.getType())) {
                  return PasswordEncryptUtil.getPasswordDisplay(currentPara.getValue());
                }
                return currentPara.getDisplayValue();
              }
            }
          }
        }
      }
    }
    return "";
  }
  private void setPropertyValue(
      IContextModelManager manager,
      Object dataElement,
      String contextParaName,
      int columnIndex,
      Object newValue) {
    String currentColumnName = getColumnProperty(columnIndex);
    if (this.groupModel.isPartOfAGroup(columnIndex)) {
      String columnGroupName = this.groupModel.getColumnGroupByIndex(columnIndex).getName();
      IContextManager contextManger = manager.getContextManager();
      if (contextManger != null) {
        // change the property of context such as prompt,promptyNeeded,value etc.
        List<Object> list = new ArrayList<Object>();
        list.add(dataElement);

        IContextParameter para = null;
        para = getRealParameter(contextManger, columnGroupName, dataElement);
        if (para == null) {
          return;
        }
        Command cmd =
            new SetContextGroupParameterCommand(manager, para, currentColumnName, newValue);
        runCommand(cmd, manager);
        if (currentColumnName.equals(ContextTableConstants.COLUMN_CHECK_PROPERTY)) {
          manager.refresh();
        }
      }
    } else {
      if (currentColumnName.equals(ContextTableConstants.COLUMN_TYPE_PROPERTY)) {
        ContextTableTabParentModel parent = (ContextTableTabParentModel) dataElement;
        IContextParameter contextPara = parent.getContextParameter();
        if (contextPara.getType() == ((String) newValue)) {
          return;
        }
        String newType = getRealType((String) newValue);
        contextPara.setType(newType);

        Command cmd = new SetContextTypeCommand(manager, contextPara, newType);
        runCommand(cmd, manager);
      } else if (currentColumnName.equals(ContextTableConstants.COLUMN_NAME_PROPERTY)) {
        ContextTableTabParentModel parent = (ContextTableTabParentModel) dataElement;
        IContextParameter contextPara = parent.getContextParameter();
        String sourceId = contextPara.getSource();
        String newParaName = (String) newValue;

        if (manager.getContextManager() instanceof JobContextManager) {
          // in case joblet rename will propagate to the job,just record it
          JobContextManager contextManager = (JobContextManager) manager.getContextManager();
          contextManager.addNewName(newParaName, contextPara.getName());
          contextManager.setModified(true);
        }
        Command cmd = new SetContextNameCommand(manager, contextPara, newParaName, sourceId);
        runCommand(cmd, manager);
      } else if (currentColumnName.equals(ContextTableConstants.COLUMN_COMMENT_PROPERTY)) {
        ContextTableTabParentModel parent = (ContextTableTabParentModel) dataElement;
        IContextParameter contextPara = parent.getContextParameter();
        if (contextPara.getComment() == ((String) newValue)) {
          return;
        }
        Command cmd = new setContextCommentCommand(manager, contextPara, (String) newValue);
        runCommand(cmd, manager);
      }
    }
  }
 /*
  * (non-Javadoc)
  *
  * @see org.eclipse.gef.commands.Command#execute()
  */
 @Override
 public void execute() {
   boolean modified = false;
   if (property.equals(ContextTableConstants.COLUMN_CHECK_PROPERTY)) {
     if (param.isPromptNeeded() == (Boolean) newValue) {
       return;
     }
     oldValue = param.isPromptNeeded();
     param.setPromptNeeded((Boolean) newValue);
     modified = true;
   } else if (property.equals(ContextTableConstants.COLUMN_PROMPT_PROPERTY)) {
     if (param.getPrompt() != null && param.getPrompt().equals(newValue)) {
       return;
     }
     oldValue = param.getPrompt();
     param.setPrompt((String) newValue);
     modified = true;
   } else if (property.equals(ContextTableConstants.COLUMN_CONTEXT_VALUE)) {
     if (param.getValue() != null && param.getValue().equals(newValue)) {
       return;
     }
     oldValue = param.getValue();
     // if (newValue != null) {
     param.setValue(newValue == null ? "" : (String) newValue);
     modified = true;
     // }
   }
   if (modified) {
     updateRelation();
   }
 }