private IFile getBeanFile(Item beanItem) throws SystemException {
   IRunProcessService service = CamelDesignerPlugin.getDefault().getRunProcessService();
   ITalendProcessJavaProject talendProcessJavaProject = service.getTalendProcessJavaProject();
   if (talendProcessJavaProject == null) {
     return null;
   }
   IFolder beanFolder =
       talendProcessJavaProject.getSrcSubFolder(null, JavaUtils.JAVA_BEANS_DIRECTORY);
   IFile file = beanFolder.getFile(beanItem.getProperty().getLabel() + JavaUtils.JAVA_EXTENSION);
   return file;
 }
 protected ILaunchConfiguration createLaunchConfiguration() {
   if (GlobalServiceRegister.getDefault().isServiceRegistered(IRunProcessService.class)) {
     IRunProcessService processService =
         (IRunProcessService)
             GlobalServiceRegister.getDefault().getService(IRunProcessService.class);
     ITalendProcessJavaProject talendProcessJavaProject =
         processService.getTalendProcessJavaProject();
     if (talendProcessJavaProject != null) {
       IProject project = talendProcessJavaProject.getProject();
       return createLaunchConfiguration(project, goals);
     }
   }
   return null;
 }
  /*
   * (non-Javadoc)
   *
   * @see
   * org.talend.designer.codegen.ISQLPatternSynchronizer#getSQLPattern(org.talend.core.model.properties.SQLPatternItem
   * )
   */
  @Override
  public IFile getSQLPatternFile(SQLPatternItem item) throws SystemException {
    IRunProcessService service = CodeGeneratorActivator.getDefault().getRunProcessService();
    ITalendProcessJavaProject talendProcessJavaProject = service.getTalendProcessJavaProject();
    if (talendProcessJavaProject == null) {
      return null;
    }
    String basePath = JavaUtils.JAVA_SQLPATTERNS_DIRECTORY + '/' + item.getEltName();
    // init user defined folder
    talendProcessJavaProject.getResourceSubFolder(
        null, basePath + '/' + JavaUtils.JAVA_USER_DEFINED);

    IFolder systemFolder =
        talendProcessJavaProject.getResourceSubFolder(
            null, basePath + '/' + JavaUtils.JAVA_SYSTEM_DIRECTORY);

    IFile file =
        systemFolder.getFile(item.getProperty().getLabel() + JavaUtils.JAVA_SQLPATTERN_EXTENSION);
    return file;
  }
  /** yzhang Comment method "updateProblems". */
  private void updateProblems(List<IRepositoryViewObject> routineObjectList, String filePath) {

    IRunProcessService runProcessService = CorePlugin.getDefault().getRunProcessService();
    try {
      ITalendProcessJavaProject talendProcessJavaProject =
          runProcessService.getTalendProcessJavaProject();
      if (talendProcessJavaProject == null) {
        return;
      }
      IProject javaProject = talendProcessJavaProject.getProject();
      IFile file = javaProject.getFile(filePath);
      String fileName = file.getName();

      for (IRepositoryViewObject repositoryObject : routineObjectList) {
        Property property = repositoryObject.getProperty();
        ITalendSynchronizer synchronizer =
            CorePlugin.getDefault().getCodeGeneratorService().createRoutineSynchronizer();
        Item item = property.getItem();
        if (GlobalServiceRegister.getDefault()
            .isServiceRegistered(ICamelDesignerCoreService.class)) {
          ICamelDesignerCoreService service =
              (ICamelDesignerCoreService)
                  GlobalServiceRegister.getDefault().getService(ICamelDesignerCoreService.class);
          if (service.isInstanceofCamel(item)) {
            synchronizer =
                CorePlugin.getDefault().getCodeGeneratorService().createCamelBeanSynchronizer();
          }
        }
        IFile currentFile = synchronizer.getFile(item);
        if (currentFile != null && fileName.equals(currentFile.getName()) && currentFile.exists()) {
          Problems.addRoutineFile(currentFile, property);
          break;
        }
      }
    } catch (SystemException e) {
      ExceptionHandler.process(e);
    }
  }
  private IFile getCamelProcessFile(CamelProcessItem item) throws SystemException {
    IRunProcessService service = CamelDesignerPlugin.getDefault().getRunProcessService();
    ITalendProcessJavaProject talendProcessJavaProject = service.getTalendProcessJavaProject();
    if (talendProcessJavaProject == null) {
      return null;
    }
    IFolder srcFolder = talendProcessJavaProject.getSrcFolder();

    String projectFolderName = JavaResourcesHelper.getProjectFolderName(item);

    String folderName =
        JavaResourcesHelper.getJobFolderName(
            item.getProperty().getLabel(), item.getProperty().getVersion());
    IFile file =
        srcFolder.getFile(
            projectFolderName
                + '/'
                + folderName
                + '/'
                + item.getProperty().getLabel()
                + JavaUtils.JAVA_EXTENSION);
    return file;
  }
  private int getColumnCount(
      String filename,
      String rowSep,
      String fieldSep,
      int limitRows,
      int headerRows,
      String escapeChar,
      String textEnclosure,
      EShadowProcessType fileType) {

    File config =
        new File(
            CorePlugin.getDefault()
                    .getPreferenceStore()
                    .getString(ITalendCorePrefConstants.FILE_PATH_TEMP)
                + "/conf.pl"); //$NON-NLS-1$
    if (config.exists()) {
      config.delete();
    }
    String modulepath = LibrariesManagerUtils.getLibrariesPath(ECodeLanguage.PERL);
    FileWriter filewriter;
    String str = "0"; // $NON-NLS-1$
    File resultFile =
        new File(
            CorePlugin.getDefault()
                    .getPreferenceStore()
                    .getString(ITalendCorePrefConstants.FILE_PATH_TEMP)
                + "/result.txt"); //$NON-NLS-1$

    if (resultFile.exists()) {
      resultFile.delete();
    }

    try {
      filewriter = new FileWriter(config, true);
      switch (fileType) {
        case FILE_DELIMITED:
          filewriter.write("$conf{filename} = " + filename + ";"); // $NON-NLS-1$ //$NON-NLS-2$
          filewriter.write("$conf{row_separator} = " + rowSep + ";"); // $NON-NLS-1$ //$NON-NLS-2$
          filewriter.write(
              "$conf{field_separator} = " + fieldSep + ";"); // $NON-NLS-1$ //$NON-NLS-2$
          filewriter.write("$conf{header} = " + headerRows + ";"); // $NON-NLS-1$ //$NON-NLS-2$
          filewriter.write("$conf{limit} = " + limitRows + ";"); // $NON-NLS-1$ //$NON-NLS-2$
          filewriter.write(
              "$conf{result_file} =\'"
                  + resultFile.toString()
                  + "\';"); //$NON-NLS-1$ //$NON-NLS-2$
          filewriter.write("$conf{type} = \'delimited\';"); // $NON-NLS-1$
          break;
        case FILE_CSV:
          filewriter.write("$conf{filename} = " + filename + ";"); // $NON-NLS-1$ //$NON-NLS-2$
          filewriter.write("$conf{row_separator} = " + rowSep + ";"); // $NON-NLS-1$ //$NON-NLS-2$
          filewriter.write(
              "$conf{field_separator} = " + fieldSep + ";"); // $NON-NLS-1$ //$NON-NLS-2$
          filewriter.write("$conf{escape_char} = " + escapeChar + ";"); // $NON-NLS-1$ //$NON-NLS-2$
          filewriter.write(
              "$conf{text_enclosure} = " + textEnclosure + ";"); // $NON-NLS-1$ //$NON-NLS-2$
          filewriter.write("$conf{header} = " + headerRows + ";"); // $NON-NLS-1$ //$NON-NLS-2$
          filewriter.write("$conf{limit} = " + limitRows + ";"); // $NON-NLS-1$ //$NON-NLS-2$
          filewriter.write(
              "$conf{result_file} =\'"
                  + resultFile.toString()
                  + "\';"); //$NON-NLS-1$ //$NON-NLS-2$
          filewriter.write("$conf{type} = \'CSV\';"); // $NON-NLS-1$
          break;
        default:
          break;
      }

      filewriter.close();
      modulepath = modulepath + "/column_counter_delimited.pl"; // $NON-NLS-1$
      StringBuffer out = new StringBuffer();
      StringBuffer err = new StringBuffer();

      IRunProcessService service =
          (IRunProcessService)
              GlobalServiceRegister.getDefault().getService(IRunProcessService.class);
      service.perlExec(
          out,
          err,
          new Path(modulepath),
          null,
          Level.DEBUG,
          "",
          null,
          -1,
          -1,
          new String[] {
            "--conf=" //$NON-NLS-1$ //$NON-NLS-2$
                + config
          });

      FileReader filereader = new FileReader(resultFile);
      BufferedReader reader = new BufferedReader(filereader);
      str = reader.readLine();
    } catch (IOException e) {
      // TODO Auto-generated catch block
      // e.printStackTrace();
      ExceptionHandler.process(e);
    } catch (ProcessorException e) {
      // TODO Auto-generated catch block
      // e.printStackTrace();
      ExceptionHandler.process(e);
    }
    return Integer.parseInt(str);
  }
예제 #7
0
  /** DOC amaumont PerlLanguage constructor comment. */
  public JavaLanguage() {
    super(ECodeLanguage.JAVA);

    IRunProcessService service = PluginUtils.getRunProcessService();
    this.codeChecker = service.getSyntaxChecker(ECodeLanguage.JAVA);
  }