/**
  * Extracts the module name from the specified project. If empty then the provided default name is
  * used.
  *
  * @param defaultName the default module name to use
  * @param project the maven 2 project
  * @return the module name to use
  */
 private String extractModuleName(final String defaultName, final Project project) {
   if (StringUtils.isBlank(project.getProjectName())) {
     return defaultName;
   } else {
     return project.getProjectName();
   }
 }
  private void jMenuItemLoadProjectActionPerformed(
      java.awt.event.ActionEvent evt) // GEN-FIRST:event_jMenuItemLoadProjectActionPerformed
      { // GEN-HEADEREND:event_jMenuItemLoadProjectActionPerformed
    JFileChooser jfc = new JFileChooser();
    if (lastPath != null) {
      jfc.setCurrentDirectory(lastPath);
    }
    int fileDialogReturnVal = jfc.showOpenDialog(this);

    if (fileDialogReturnVal == JFileChooser.APPROVE_OPTION) {
      try {
        File inputFile = jfc.getSelectedFile();
        FileInputStream fis = new FileInputStream(inputFile);
        ObjectInputStream ois = new ObjectInputStream(fis);

        this.theProject = (Project) ois.readObject();
        this.currentResults = (LSAResults) ois.readObject();

        lastPath = new File(jfc.getSelectedFile().getPath());
      } catch (IOException e) {
        if (this.theProject == null) {
          log.log(Log.ERROR, "Failed to load project");
        }
        if (this.currentResults == null) {
          log.log(Log.WARNING, "Failed to load results");
        }

        log.log(Log.WARNING, e.getMessage());
      } catch (ClassNotFoundException e) {
        log.log(Log.ERROR, "Class not found error, version mismatch");
      }
    }
    if (this.theProject != null) {
      jMenuItemViewDocuments.setEnabled(true);
      jMenuItemSaveProject.setEnabled(true);
      this.setTitle(theProject.getProjectName());
      log.log(Log.INFO, "Project Loaded");
    }
    if (this.currentResults != null) {
      log.log(Log.INFO, "Results loaded");
    }
  } // GEN-LAST:event_jMenuItemLoadProjectActionPerformed
예제 #3
0
  private MultiLoadParameter createMultiLoadParameter(
      String projectName, Project project, Sample sample, List<FileReadAttributeBean> frab)
      throws Exception {

    MultiLoadParameter loadParameter = new MultiLoadParameter();
    boolean isSampleRegistration = false;
    boolean isProjectRegistration = false;

    if (this.eventName.equals(Constants.EVENT_PROJECT_REGISTRATION)
        && project.getProjectName() != null
        && !project.getProjectName().isEmpty()) {
      isProjectRegistration = true;

      List<Project> projectList = new ArrayList<Project>();
      projectList.add(feedProjectData(project));
      loadParameter.addProjects(projectList);

      /*
       *   loads all event meta attributes from the parent
       *   by hkim 6/11/13
       */
      List<EventMetaAttribute> emas =
          this.readPersister.getEventMetaAttributes(
              projectName, null); // , Constants.EVENT_PROJECT_REGISTRATION);
      if (emas != null && emas.size() > 0) {
        List<EventMetaAttribute> newEmas = new ArrayList<EventMetaAttribute>(emas.size());

        for (EventMetaAttribute ema : emas) {
          EventMetaAttribute newEma = new EventMetaAttribute();
          newEma.setProjectName(project.getProjectName());
          newEma.setEventName(ema.getEventName());
          newEma.setEventTypeLookupId(ema.getEventTypeLookupId());
          newEma.setAttributeName(ema.getAttributeName());
          newEma.setNameLookupId(ema.getNameLookupId());
          newEma.setActive(ema.isActive());
          newEma.setRequired(ema.isRequired());
          newEma.setDesc(ema.getDesc());
          newEma.setDataType(ema.getDataType());
          newEma.setLabel(ema.getLabel());
          newEma.setOntology(ema.getOntology());
          newEma.setOptions(ema.getOptions());
          newEma.setSampleRequired(ema.isSampleRequired());
          newEmas.add(newEma);
        }
        loadParameter.addEventMetaAttributes(newEmas);
      } else {
        throw new Exception(
            String.format(
                "Event Metadata has not been set up for the parent project and the '%s' event type.",
                Constants.EVENT_PROJECT_REGISTRATION));
      }

      List<SampleMetaAttribute> smas = this.readPersister.getSampleMetaAttributes(projectId);
      if (smas != null && smas.size() > 0) {
        List<SampleMetaAttribute> newSmas = new ArrayList<SampleMetaAttribute>(smas.size());
        for (SampleMetaAttribute sma : smas) {
          SampleMetaAttribute newSma = new SampleMetaAttribute();
          newSma.setProjectName(project.getProjectName());
          newSma.setAttributeName(sma.getAttributeName());
          newSma.setNameLookupId(sma.getNameLookupId());
          newSma.setDataType(sma.getDataType());
          newSma.setDesc(sma.getDesc());
          newSma.setLabel(sma.getLabel());
          newSma.setOntology(sma.getOntology());
          newSma.setOptions(sma.getOptions());
          newSma.setRequired(sma.isRequired());
          newSma.setActive(sma.isActive());
          newSmas.add(newSma);
        }
        loadParameter.addSampleMetaAttributes(newSmas);
      }

      List<ProjectMetaAttribute> pmas = this.readPersister.getProjectMetaAttributes(projectName);
      if (pmas != null && pmas.size() > 0) {
        List<ProjectMetaAttribute> newPmas = new ArrayList<ProjectMetaAttribute>(pmas.size());
        for (ProjectMetaAttribute pma : pmas) {
          ProjectMetaAttribute newPma = new ProjectMetaAttribute();
          newPma.setProjectName(project.getProjectName());
          newPma.setAttributeName(pma.getAttributeName());
          newPma.setDataType(pma.getDataType());
          newPma.setDesc(pma.getDesc());
          newPma.setLabel(pma.getLabel());
          newPma.setNameLookupId(pma.getNameLookupId());
          newPma.setOntology(pma.getOntology());
          newPma.setOptions(pma.getOptions());
          newPma.setRequired(pma.isRequired());
          newPma.setActive(pma.isActive());
          newPmas.add(newPma);
        }
        loadParameter.addProjectMetaAttributes(newPmas);
      }
    } else if (this.eventName.equals(Constants.EVENT_SAMPLE_REGISTRATION)
        && sample.getSampleName() != null
        && !sample.getSampleName().isEmpty()) {
      isSampleRegistration = true;

      List<Sample> sampleList = new ArrayList<Sample>();
      sampleList.add(feedSampleData(sample));
      loadParameter.addSamples(sampleList);
    }

    List<FileReadAttributeBean> loadingList = null;
    if (frab != null && frab.size() > 0) {
      loadingList =
          processFileReadBeans(
              isProjectRegistration ? project.getProjectName() : projectName,
              isSampleRegistration ? sample.getSampleName() : this.sampleName,
              frab);
    }
    if (loadingList != null && loadingList.size() > 0) {
      if (isProjectRegistration) {
        loadParameter.addProjectRegistrations(Constants.EVENT_PROJECT_REGISTRATION, loadingList);
      } else if (isSampleRegistration) {
        loadParameter.addSampleRegistrations(Constants.EVENT_SAMPLE_REGISTRATION, loadingList);
      } else {
        loadParameter.addEvents(this.eventName, loadingList);
      }
    }
    return loadParameter;
  }