@Override
  public void handleEvent(Event event) {
    // TODO Auto-generated method stub
    Vector<String> values = this.setPlatformsUI.getValues();
    Vector<String> samples = this.setPlatformsUI.getSamples();
    File file =
        new File(
            this.dataType.getPath().toString()
                + File.separator
                + this.dataType.getStudy().toString()
                + ".subject_mapping.tmp");
    File stsmf = ((GeneExpressionData) this.dataType).getStsmf();
    if (stsmf == null) {
      this.setPlatformsUI.displayMessage("Error: no subject to sample mapping file");
    }
    try {
      FileWriter fw = new FileWriter(file);
      BufferedWriter out = new BufferedWriter(fw);
      out.write(
          "study_id\tsite_id\tsubject_id\tSAMPLE_ID\tPLATFORM\tTISSUETYPE\tATTR1\tATTR2\tcategory_cd\n");

      try {
        BufferedReader br = new BufferedReader(new FileReader(stsmf));
        String line = br.readLine();
        while ((line = br.readLine()) != null) {
          String[] fields = line.split("\t", -1);
          String sample = fields[3];
          String platform;
          if (samples.contains(sample)) {
            platform = values.get(samples.indexOf(sample));
          } else {
            br.close();
            return;
          }
          out.write(
              fields[0] + "\t" + fields[1] + "\t" + fields[2] + "\t" + sample + "\t" + platform
                  + "\t" + fields[5] + "\t" + fields[6] + "\t" + fields[7] + "\t" + fields[8]
                  + "\n");
        }
        br.close();
      } catch (Exception e) {
        this.setPlatformsUI.displayMessage("Error: " + e.getLocalizedMessage());
        out.close();
        e.printStackTrace();
      }
      out.close();
      try {
        File fileDest;
        if (stsmf != null) {
          String fileName = stsmf.getName();
          stsmf.delete();
          fileDest = new File(this.dataType.getPath() + File.separator + fileName);
        } else {
          fileDest =
              new File(
                  this.dataType.getPath()
                      + File.separator
                      + this.dataType.getStudy().toString()
                      + ".subject_mapping");
        }
        FileUtils.moveFile(file, fileDest);
        ((GeneExpressionData) this.dataType).setSTSMF(fileDest);
      } catch (IOException ioe) {
        this.setPlatformsUI.displayMessage("File error: " + ioe.getLocalizedMessage());
        return;
      }
    } catch (Exception e) {
      this.setPlatformsUI.displayMessage("Error: " + e.getLocalizedMessage());
      e.printStackTrace();
    }
    this.setPlatformsUI.displayMessage("Subject to sample mapping file updated");
    WorkPart.updateSteps();
    WorkPart.updateFiles();
  }
  @Override
  public void handleEvent(Event event) {
    // TODO Auto-generated method stub
    File file =
        new File(
            this.dataType.getPath().toString()
                + File.separator
                + this.dataType.getStudy().toString()
                + ".subject_mapping.tmp");
    File stsmf = ((GeneExpressionData) this.dataType).getStsmf();
    if (stsmf == null) {
      this.setStudyTreeUI.displayMessage("Error: no subject to sample mapping file");
    }
    String category = "";
    TreeNode node = this.setStudyTreeUI.getRoot();
    if (!node.hasChildren()) {
      this.setStudyTreeUI.displayMessage("You have to set a category code");
      return;
    }
    node = node.getChildren().get(0);
    while (node != null) {
      if (category.compareTo("") == 0) {
        category += node.toString().replace(' ', '_');
      } else {
        category += "+" + node.toString().replace(' ', '_');
      }
      if (node.hasChildren()) {
        node = node.getChildren().get(0);
      } else {
        node = null;
      }
    }
    try {
      FileWriter fw = new FileWriter(file);
      BufferedWriter out = new BufferedWriter(fw);
      out.write(
          "study_id\tsite_id\tsubject_id\tSAMPLE_ID\tPLATFORM\tTISSUETYPE\tATTR1\tATTR2\tcategory_cd\n");

      try {
        BufferedReader br = new BufferedReader(new FileReader(stsmf));
        String line = br.readLine();
        while ((line = br.readLine()) != null) {
          String[] fields = line.split("\t", -1);
          out.write(
              fields[0] + "\t" + fields[1] + "\t" + fields[2] + "\t" + fields[3] + "\t" + fields[4]
                  + "\t" + fields[5] + "\t" + fields[6] + "\t" + fields[7] + "\t" + category
                  + "\n");
        }
        br.close();
      } catch (Exception e) {
        this.setStudyTreeUI.displayMessage("File error: " + e.getLocalizedMessage());
        out.close();
        e.printStackTrace();
      }
      out.close();
      try {
        File fileDest;
        if (stsmf != null) {
          String fileName = stsmf.getName();
          stsmf.delete();
          fileDest = new File(this.dataType.getPath() + File.separator + fileName);
        } else {
          fileDest =
              new File(
                  this.dataType.getPath()
                      + File.separator
                      + this.dataType.getStudy().toString()
                      + ".subject_mapping");
        }
        FileUtils.moveFile(file, fileDest);
        ((GeneExpressionData) this.dataType).setSTSMF(fileDest);
      } catch (IOException ioe) {
        this.setStudyTreeUI.displayMessage("File error: " + ioe.getLocalizedMessage());
        return;
      }
    } catch (Exception e) {
      this.setStudyTreeUI.displayMessage("Eerror: " + e.getLocalizedMessage());
      e.printStackTrace();
    }
    this.setStudyTreeUI.displayMessage("Subject to sample mapping file updated");
    WorkPart.updateSteps();
    WorkPart.updateFiles();
  }
  /**
   * Loads the gene expression data: -initiate Kettle environment -Find Kettle files -Set Kettle
   * parameters -Calls the Kettle job -Save the log file
   */
  @Override
  public void handleEvent(Event event) {
    this.topNode = this.loadDataUI.getTopNode();
    this.path = this.dataType.getPath().getAbsolutePath();
    this.sortName =
        this.dataType.getStudy().getPath().getParentFile().getAbsolutePath()
            + File.separator
            + ".sort";
    loadDataUI.openLoadingShell();
    new Thread() {
      public void run() {
        try {
          String[] splited = topNode.split("\\\\", -1);
          if (splited[0].compareTo("") != 0) {
            loadDataUI.setMessage("A study node has to begin by the character '\\'");
            loadDataUI.setIsLoading(false);
            return;
          }
          try {
            Class.forName("org.postgresql.Driver");
            String connectionString =
                "jdbc:postgresql://"
                    + PreferencesHandler.getDbServer()
                    + ":"
                    + PreferencesHandler.getDbPort()
                    + "/"
                    + PreferencesHandler.getDbName();

            Connection con =
                DriverManager.getConnection(
                    connectionString,
                    PreferencesHandler.getMetadataUser(),
                    PreferencesHandler.getMetadataPwd());
            Statement stmt = con.createStatement();
            ResultSet rs =
                stmt.executeQuery("select * from table_access where c_name='" + splited[1] + "'");
            if (!rs.next()) { // have to add a top node
              stmt.executeQuery(
                  "insert into table_access("
                      + "c_table_cd,"
                      + "c_table_name,"
                      + "c_protected_access,"
                      + "c_hlevel,"
                      + "c_fullname,"
                      + "c_name,"
                      + "c_synonym_cd,"
                      + "c_visualattributes,"
                      + "c_totalnum,"
                      + "c_facttablecolumn,"
                      + "c_dimtablename,"
                      + "c_columnname,"
                      + "c_columndatatype,"
                      + "c_operator,"
                      + "c_dimcode,"
                      + "c_tooltip,"
                      + "c_status_cd) values("
                      + "'"
                      + splited[1]
                      + "',"
                      + "'i2b2',"
                      + "'N',"
                      + "0,"
                      + "'\\"
                      + splited[1]
                      + "\\',"
                      + "'"
                      + splited[1]
                      + "',"
                      + "'N',"
                      + "'CA',"
                      + "0,"
                      + "'concept_cd',"
                      + "'concept_dimension',"
                      + "'concept_path',"
                      + "'T',"
                      + "'LIKE',"
                      + "'\\"
                      + splited[1]
                      + "\\',"
                      + "'\\"
                      + splited[1]
                      + "\\',"
                      + "'A')");
              stmt.executeQuery(
                  "insert into i2b2 values(0, '\\"
                      + splited[1]
                      + "\\', '"
                      + splited[1]
                      + "','N','CA',0,null, null, 'CONCEPT_CD','CONCEPT_DIMENSION','CONCEPT_PATH', 'T', 'LIKE','\\"
                      + splited[1]
                      + "\\', null, '\\"
                      + splited[1]
                      + "\\', sysdate, null, null, null, null, null, '@', null, null, null)");
            }
            con.close();
          } catch (SQLException e) {
            e.printStackTrace();
            loadDataUI.displayMessage("SQL error: " + e.getLocalizedMessage());
            loadDataUI.setIsLoading(false);
            return;
          } catch (ClassNotFoundException e) {
            loadDataUI.displayMessage("Java error: Class not found exception");
            // TODO Auto-generated catch block
            e.printStackTrace();
            loadDataUI.setIsLoading(false);
            return;
          }
          // initiate kettle environment
          URL kettleUrl = new URL("platform:/plugin/fr.sanofi.fcl4transmart/lib/pentaho");
          kettleUrl = FileLocator.toFileURL(kettleUrl);
          System.setProperty("KETTLE_PLUGIN_BASE_FOLDERS", kettleUrl.getPath());
          KettleEnvironment.init(false);

          // find the kettle job to initiate the loading
          URL jobUrl =
              new URL(
                  "platform:/plugin/fr.sanofi.fcl4transmart/jobs_kettle/load_gene_expression_data.kjb");
          jobUrl = FileLocator.toFileURL(jobUrl);
          String jobPath = jobUrl.getPath();
          // create a new job from the kettle file
          JobMeta jobMeta = new JobMeta(jobPath, null);
          Job job = new Job(null, jobMeta);

          // find the other files needed for this job and put them in the cache
          jobUrl =
              new URL(
                  "platform:/plugin/fr.sanofi.fcl4transmart/jobs_kettle/validate_gene_expression_params.ktr");
          jobUrl = FileLocator.toFileURL(jobUrl);
          jobUrl =
              new URL(
                  "platform:/plugin/fr.sanofi.fcl4transmart/jobs_kettle/validate_gene_expression_columns.ktr");
          jobUrl = FileLocator.toFileURL(jobUrl);
          jobUrl =
              new URL(
                  "platform:/plugin/fr.sanofi.fcl4transmart/jobs_kettle/check_gene_expression_filenames.ktr");
          jobUrl = FileLocator.toFileURL(jobUrl);
          jobUrl =
              new URL(
                  "platform:/plugin/fr.sanofi.fcl4transmart/jobs_kettle/load_all_gene_expression_files_for_study.kjb");
          jobUrl = FileLocator.toFileURL(jobUrl);
          jobUrl =
              new URL(
                  "platform:/plugin/fr.sanofi.fcl4transmart/jobs_kettle/run_i2b2_process_mrna_data.ktr");
          jobUrl = FileLocator.toFileURL(jobUrl);
          jobUrl =
              new URL(
                  "platform:/plugin/fr.sanofi.fcl4transmart/jobs_kettle/load_subject_sample_map_to_lt.ktr");
          jobUrl = FileLocator.toFileURL(jobUrl);
          jobUrl =
              new URL(
                  "platform:/plugin/fr.sanofi.fcl4transmart/jobs_kettle/get_list_of_gene_expression_filenames.ktr");
          jobUrl = FileLocator.toFileURL(jobUrl);
          jobUrl =
              new URL(
                  "platform:/plugin/fr.sanofi.fcl4transmart/jobs_kettle/load_gene_expression_one_study.kjb");
          jobUrl = FileLocator.toFileURL(jobUrl);
          jobUrl =
              new URL(
                  "platform:/plugin/fr.sanofi.fcl4transmart/jobs_kettle/set_gene_expression_filename.ktr");
          jobUrl = FileLocator.toFileURL(jobUrl);
          jobUrl =
              new URL(
                  "platform:/plugin/fr.sanofi.fcl4transmart/jobs_kettle/validate_gene_expression_columns.ktr");
          jobUrl = FileLocator.toFileURL(jobUrl);
          jobUrl =
              new URL(
                  "platform:/plugin/fr.sanofi.fcl4transmart/jobs_kettle/load_gene_expression_data_to_lz.ktr");
          jobUrl = FileLocator.toFileURL(jobUrl);
          jobUrl =
              new URL("platform:/plugin/fr.sanofi.fcl4transmart/jobs_kettle/pivot_gene_file.ktr");
          jobUrl = FileLocator.toFileURL(jobUrl);
          jobUrl =
              new URL("platform:/plugin/fr.sanofi.fcl4transmart/jobs_kettle/cz_start_audit.ktr");
          jobUrl = FileLocator.toFileURL(jobUrl);
          jobUrl = new URL("platform:/plugin/fr.sanofi.fcl4transmart/jobs_kettle/cz_end_audit.ktr");
          jobUrl = FileLocator.toFileURL(jobUrl);
          jobUrl =
              new URL(
                  "platform:/plugin/fr.sanofi.fcl4transmart/jobs_kettle/write_gene_expression_audit.ktr");
          jobUrl = FileLocator.toFileURL(jobUrl);
          jobUrl =
              new URL(
                  "platform:/plugin/fr.sanofi.fcl4transmart/jobs_kettle/write_study_id_to_audit.ktr");
          jobUrl = FileLocator.toFileURL(jobUrl);

          job.getJobMeta().setParameterValue("DATA_FILE_PREFIX", "raw");
          job.getJobMeta().setParameterValue("DATA_LOCATION", path);
          job.getJobMeta()
              .setParameterValue(
                  "MAP_FILENAME", ((GeneExpressionData) dataType).getStsmf().getName());
          job.getJobMeta().setParameterValue("DATA_TYPE", "R");
          job.getJobMeta().setParameterValue("LOG_BASE", "2");
          job.getJobMeta().setParameterValue("FilePivot_LOCATION", "");
          job.getJobMeta().setParameterValue("LOAD_TYPE", "I");
          job.getJobMeta().setParameterValue("SAMPLE_REMAP_FILENAME", "NOSAMPLEREMAP");
          job.getJobMeta().setParameterValue("SAMPLE_SUFFIX", ".rma-Signal");

          if (loadDataUI.getSecurity()) {
            job.getJobMeta().setParameterValue("SECURITY_REQUIRED", "Y");
          } else {
            job.getJobMeta().setParameterValue("SECURITY_REQUIRED", "N");
          }
          job.getJobMeta().setParameterValue("SOURCE_CD", "STD");

          File sort = new File(sortName);
          if (!sort.exists()) {
            FileUtils.forceMkdir(sort);
          }
          path = sort.getAbsolutePath();
          job.getJobMeta().setParameterValue("SORT_DIR", path);

          job.getJobMeta().setParameterValue("STUDY_ID", dataType.getStudy().toString());
          job.getJobMeta().setParameterValue("TOP_NODE", topNode);

          // job.getJobMeta().setParameterValue("JAVA_HOME", "/usr/local/jdk1.6.0_31");

          job.getJobMeta().setParameterValue("TM_CZ_DB_SERVER", PreferencesHandler.getDbServer());
          job.getJobMeta().setParameterValue("TM_CZ_DB_NAME", PreferencesHandler.getDbName());
          job.getJobMeta().setParameterValue("TM_CZ_DB_PORT", PreferencesHandler.getDbPort());
          job.getJobMeta().setParameterValue("TM_CZ_DB_USER", PreferencesHandler.getTm_czUser());
          job.getJobMeta().setParameterValue("TM_CZ_DB_PWD", PreferencesHandler.getTm_czPwd());
          job.getJobMeta().setParameterValue("TM_LZ_DB_SERVER", PreferencesHandler.getDbServer());
          job.getJobMeta().setParameterValue("TM_LZ_DB_NAME", PreferencesHandler.getDbName());
          job.getJobMeta().setParameterValue("TM_LZ_DB_PORT", PreferencesHandler.getDbPort());
          job.getJobMeta().setParameterValue("TM_LZ_DB_USER", PreferencesHandler.getTm_lzUser());
          job.getJobMeta().setParameterValue("TM_LZ_DB_PWD", PreferencesHandler.getTm_lzPwd());
          job.getJobMeta().setParameterValue("DEAPP_DB_SERVER", PreferencesHandler.getDbServer());
          job.getJobMeta().setParameterValue("DEAPP_DB_NAME", PreferencesHandler.getDbName());
          job.getJobMeta().setParameterValue("DEAPP_DB_PORT", PreferencesHandler.getDbPort());
          job.getJobMeta().setParameterValue("DEAPP_DB_USER", PreferencesHandler.getDeappUser());
          job.getJobMeta().setParameterValue("DEAPP_DB_PWD", PreferencesHandler.getDeappPwd());

          if (loadDataUI.getIndexes()) {
            // drop indexes
            String connectionString =
                "jdbc:oracle:thin:@"
                    + PreferencesHandler.getDbServer()
                    + ":"
                    + PreferencesHandler.getDbPort()
                    + ":"
                    + PreferencesHandler.getDbName();
            Connection con =
                DriverManager.getConnection(
                    connectionString,
                    PreferencesHandler.getTm_czUser(),
                    PreferencesHandler.getTm_czPwd());

            String sql = "{call i2b2_mrna_index_maint(?)}";
            CallableStatement call = con.prepareCall(sql);
            call.setString(1, "DROP");
            call.execute();

            con.close();
            System.out.println("Indexes dropped");
          }

          job.start();
          job.waitUntilFinished();
          System.out.println("Job finished");
          if (loadDataUI.getIndexes()) {
            // add indexes
            String connectionString =
                "jdbc:postgresql://"
                    + PreferencesHandler.getDbServer()
                    + ":"
                    + PreferencesHandler.getDbPort()
                    + "/"
                    + PreferencesHandler.getDbName();
            Connection con =
                DriverManager.getConnection(
                    connectionString,
                    PreferencesHandler.getTm_czUser(),
                    PreferencesHandler.getTm_czPwd());

            String sql = "{call i2b2_mrna_index_maint(?)}";
            CallableStatement call = con.prepareCall(sql);
            call.setString(1, "ADD");
            call.execute();

            con.close();
            System.out.println("Indexes added");
          }

          @SuppressWarnings("unused")
          Result result = job.getResult();
          Display.getDefault()
              .asyncExec(
                  new Runnable() {
                    public void run() {
                      loadDataUI.displayMessage(
                          "Loading process is over.\n Please check monitoring step.");
                    }
                  });

          Log4jBufferAppender appender = CentralLogStore.getAppender();
          String logText = appender.getBuffer(job.getLogChannelId(), false).toString();

          Pattern pattern =
              Pattern.compile(
                  ".*Finished job entry \\[run i2b2_process_mrna_data\\].*", Pattern.DOTALL);
          Matcher matcher = pattern.matcher(logText);
          if (matcher.matches()) {
            String connectionString =
                "jdbc:postgresql://"
                    + PreferencesHandler.getDbServer()
                    + ":"
                    + PreferencesHandler.getDbPort()
                    + "/"
                    + PreferencesHandler.getDbName();
            Connection con =
                DriverManager.getConnection(
                    connectionString,
                    PreferencesHandler.getTm_czUser(),
                    PreferencesHandler.getTm_czPwd());
            Statement stmt = con.createStatement();

            // remove rows for this study before adding new ones
            ResultSet rs =
                stmt.executeQuery(
                    "select max(JOB_ID) from CZ_JOB_AUDIT where STEP_DESC='Starting i2b2_process_mrna_data'");
            int jobId;
            if (rs.next()) {
              jobId = rs.getInt(1);
            } else {
              con.close();
              loadDataUI.setIsLoading(false);
              return;
            }

            logText += "\nOracle job id:\n" + String.valueOf(jobId);
            con.close();
          }

          writeLog(logText);
          CentralLogStore.discardLines(job.getLogChannelId(), false);
        } catch (Exception e1) {
          // this.write(e1.getMessage());
          messageException = e1.getLocalizedMessage();
          Display.getDefault()
              .asyncExec(
                  new Runnable() {
                    public void run() {
                      loadDataUI.displayMessage("Error: " + messageException);
                    }
                  });
          loadDataUI.setIsLoading(false);
          e1.printStackTrace();
        }
        loadDataUI.setIsLoading(false);
      }
    }.start();
    this.loadDataUI.waitForThread();
    WorkPart.updateSteps();
    WorkPart.addFiles(this.dataType);
  }
  @Override
  public void handleEvent(Event event) {
    Vector<File> rawFiles = ((ClinicalData) this.dataType).getRawFiles();
    Vector<String> siteIds = this.setOtherIdsUI.getSiteIds();
    Vector<String> visitNames = this.setOtherIdsUI.getVisitNames();

    // write in a new file
    File file =
        new File(
            this.dataType.getPath().toString()
                + File.separator
                + this.dataType.getStudy().toString()
                + ".columns.tmp");
    try {
      FileWriter fw = new FileWriter(file);
      BufferedWriter out = new BufferedWriter(fw);
      out.write(
          "Filename\tCategory Code\tColumn Number\tData Label\tData Label Source\tControlled Vocab Code\n");

      for (int i = 0; i < rawFiles.size(); i++) {

        // site identifier
        if (siteIds.elementAt(i).compareTo("") != 0) {
          int columnNumber =
              FileHandler.getHeaderNumber(rawFiles.elementAt(i), siteIds.elementAt(i));
          if (columnNumber != -1) {
            out.write(rawFiles.elementAt(i).getName() + "\t\t" + columnNumber + "\tSITE_ID\t\t\n");
          }
        }

        // visit name
        if (visitNames.elementAt(i).compareTo("") != 0) {
          int columnNumber =
              FileHandler.getHeaderNumber(rawFiles.elementAt(i), visitNames.elementAt(i));
          if (columnNumber != -1) {
            out.write(
                rawFiles.elementAt(i).getName() + "\t\t" + columnNumber + "\tVISIT_NAME\t\t\n");
          }
        }
      }
      // add lines from existing CMF
      try {
        BufferedReader br =
            new BufferedReader(new FileReader(((ClinicalData) this.dataType).getCMF()));
        String line = br.readLine();
        while ((line = br.readLine()) != null) {
          String[] s = line.split("\t", -1);
          if (s[3].compareTo("SITE_ID") != 0 && s[3].compareTo("VISIT_NAME") != 0) {
            out.write(line + "\n");
          }
        }
        br.close();
      } catch (Exception e) {
        this.setOtherIdsUI.displayMessage("Error: " + e.getLocalizedMessage());
        e.printStackTrace();
        out.close();
      }
      out.close();
      try {
        String fileName = ((ClinicalData) this.dataType).getCMF().getName();
        ((ClinicalData) this.dataType).getCMF().delete();
        File fileDest = new File(this.dataType.getPath() + File.separator + fileName);
        FileUtils.moveFile(file, fileDest);
        ((ClinicalData) this.dataType).setCMF(fileDest);
      } catch (IOException ioe) {
        this.setOtherIdsUI.displayMessage("File error: " + ioe.getLocalizedMessage());
        return;
      }

    } catch (Exception e) {
      this.setOtherIdsUI.displayMessage("Error: " + e.getLocalizedMessage());
      e.printStackTrace();
    }
    this.setOtherIdsUI.displayMessage("Column mapping file updated");
    WorkPart.updateSteps();
    WorkPart.updateFiles();
    UsedFilesPart.sendFilesChanged(dataType);
  }
示例#5
0
  @Override
  public Composite createUI(Composite parent) {
    this.display = WorkPart.display();
    Shell shell = new Shell(this.display);
    shell.setSize(50, 100);
    GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 1;
    shell.setLayout(gridLayout);
    ProgressBar pb = new ProgressBar(shell, SWT.HORIZONTAL | SWT.INDETERMINATE);
    pb.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    Label searching = new Label(shell, SWT.NONE);
    searching.setText("Searching...");
    shell.open();
    this.isSearching = true;
    new Thread() {
      public void run() {
        testTm_cz = RetrieveData.testTm_czConnection();
        testTm_lz = RetrieveData.testTm_lzConnection();
        testDeapp = RetrieveData.testDeappConnection();
        root = new TreeNode("Dataset explorer", null, false);
        studyTree = new StudyTree(root);
        topNodeController = new TopNodeController(root, dataType, studyTree);
        root = topNodeController.buildTree();
        topNode = dataType.getStudy().getTopNode();
        isSearching = false;
      }
    }.start();
    this.display = WorkPart.display();
    while (this.isSearching) {
      if (!display.readAndDispatch()) {
        display.sleep();
      }
    }
    shell.close();
    Composite composite = new Composite(parent, SWT.NONE);
    GridLayout gd = new GridLayout();
    gd.numColumns = 1;
    gd.horizontalSpacing = 0;
    gd.verticalSpacing = 0;
    composite.setLayout(gd);
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));

    ScrolledComposite scroller = new ScrolledComposite(composite, SWT.H_SCROLL | SWT.V_SCROLL);
    scroller.setLayoutData(new GridData(GridData.FILL_BOTH));
    gd = new GridLayout();
    gd.numColumns = 1;
    gd.horizontalSpacing = 0;
    gd.verticalSpacing = 0;
    scroller.setLayout(gd);
    scroller.setLayoutData(new GridData(GridData.FILL_BOTH));

    Composite scrolledComposite = new Composite(scroller, SWT.NONE);
    scroller.setContent(scrolledComposite);
    GridLayout layout = new GridLayout();
    layout.numColumns = 1;
    layout.verticalSpacing = 10;
    scrolledComposite.setLayout(layout);
    scrolledComposite.setLayoutData(new GridData(GridData.FILL_BOTH));

    this.topNode = this.dataType.getStudy().getTopNode();
    if (topNode != null && topNode.compareTo("") != 0) {
      viewer = new TreeViewer(scrolledComposite, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);
      viewer.setContentProvider(new StudyContentProvider());
      viewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS);

      viewer.setInput(this.studyTree);
      GridData gridData = new GridData(GridData.FILL_BOTH);
      gridData.horizontalAlignment = SWT.FILL;
      gridData.verticalAlignment = SWT.FILL;
      gridData.grabExcessHorizontalSpace = true;
      gridData.grabExcessVerticalSpace = true;
      gridData.heightHint = 300;
      gridData.widthHint = 250;
      this.viewer.getControl().setLayoutData(gridData);
      viewer.setLabelProvider(
          new ColumnLabelProvider() {
            @Override
            public String getText(Object element) {
              return element.toString();
            }

            @Override
            public Color getBackground(Object element) {
              if (((TreeNode) element).isStudyRoot()) {
                return new Color(Display.getCurrent(), 237, 91, 67);
              }
              if (((TreeNode) element).isLabel()) {
                return new Color(Display.getCurrent(), 212, 212, 212);
              }
              return null;
            }
          });

      securityButton = new Button(scrolledComposite, SWT.CHECK);
      securityButton.setText("Security required");
      securityButton.addListener(
          SWT.Selection,
          new Listener() {

            @Override
            public void handleEvent(Event event) {
              security = securityButton.getSelection();
            }
          });

      /*indexesButton=new Button(scrolledComposite, SWT.CHECK);
      indexesButton.setText("Turn off the indexes during loaded (only for large datasets)");
      indexesButton.addListener(SWT.Selection, new Listener(){

      	@Override
      	public void handleEvent(Event event) {
      		indexes=indexesButton.getSelection();
      	}
      })*/ ;
    } else {
      Label label = new Label(scrolledComposite, SWT.NONE);
      label.setText("Please first choose a study node in the description data type");
    }

    Button button = new Button(scrolledComposite, SWT.PUSH);
    button.setText("Load");

    if (topNode != null && topNode.compareTo("") != 0) {
      if (this.testTm_cz && this.testTm_lz && this.testDeapp) {
        button.addListener(SWT.Selection, new LoadGeneExpressionDataListener(this, this.dataType));
        Label dbLabel = new Label(scrolledComposite, SWT.NONE);
        dbLabel.setText("You are connected to database '" + PreferencesHandler.getDb() + "'");
      } else {
        button.setEnabled(false);
        Label warn = new Label(scrolledComposite, SWT.NONE);
        warn.setText("Warning: connection to database is not possible");
      }
    } else {
      button.setEnabled(false);
    }
    scrolledComposite.setSize(scrolledComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    return composite;
  }
  @Override
  public void handleEvent(Event event) {
    this.selectRawFilesUI.openLoadingShell();
    new Thread() {
      public void run() {
        String[] paths = selectRawFilesUI.getPath().split(File.pathSeparator, -1);
        for (int i = 0; i < paths.length; i++) {
          String path = paths[i];
          if (path == null) {
            selectRawFilesUI.setIsLoading(false);
            return;
          }
          File rawFile = new File(path);
          if (rawFile.exists()) {
            if (rawFile.isFile()) {
              if (path.contains("%")) {
                selectRawFilesUI.setMessage("File name can not contain percent ('%') symbol.");
                selectRawFilesUI.setIsLoading(false);
                return;
              }
              String newPath =
                  dataType.getPath().getAbsolutePath() + File.separator + rawFile.getName();
              if (selectRawFilesUI.getFormat().compareTo("Tab delimited raw file") != 0
                  && selectRawFilesUI.getFormat().compareTo("SOFT") != 0) {
                selectRawFilesUI.setMessage("File format does not exist");
                selectRawFilesUI.setIsLoading(false);
                return;
              }
              if (selectRawFilesUI.getFormat().compareTo("SOFT") == 0) {
                File newFile = new File(newPath);
                if (newFile.exists()) {
                  selectRawFilesUI.setMessage("File has already been added");
                  selectRawFilesUI.setIsLoading(false);
                  return;
                } else {
                  if (createTabFileFromSoft(rawFile, newFile)) {
                    ((ClinicalData) dataType).addRawFile(newFile);
                    selectRawFilesUI.setMessage("File has been added");
                  }
                }
              } else if (selectRawFilesUI.getFormat().compareTo("Tab delimited raw file") == 0) {
                if (!checkTabFormat(rawFile)) {
                  selectRawFilesUI.setIsLoading(false);
                  return;
                }

                File copiedRawFile = new File(newPath);
                if (!copiedRawFile.exists()) {
                  try {
                    FileUtils.copyFile(rawFile, copiedRawFile);
                    ((ClinicalData) dataType).addRawFile(copiedRawFile);
                    selectRawFilesUI.setMessage("File has been added");
                  } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                    selectRawFilesUI.setMessage("File error: " + e.getLocalizedMessage());
                    selectRawFilesUI.setIsLoading(false);
                    return;
                  }
                } else {
                  selectRawFilesUI.setMessage("File has already been added");
                  selectRawFilesUI.setIsLoading(false);
                  return;
                }
              }

            } else {
              selectRawFilesUI.setMessage("File is a directory");
              selectRawFilesUI.setIsLoading(false);
              return;
            }
          } else {
            selectRawFilesUI.setMessage("Path does no exist");
            selectRawFilesUI.setIsLoading(false);
            return;
          }
        }
        selectRawFilesUI.setIsLoading(false);
      }
    }.start();
    this.selectRawFilesUI.waitForThread();
    selectRawFilesUI.updateViewer();
    WorkPart.updateSteps();
    UsedFilesPart.sendFilesChanged(dataType);
  }