Пример #1
0
  private void handleShowProteinDomain(Tuple request) throws Exception {
    if (StringUtils.isNotEmpty(request.getString("domain_id")))
      this.getModel().getMutationSearchCriteriaVO().setProteinDomainId(request.getInt("domain_id"));
    if (StringUtils.isNotEmpty(request.getString("snpbool")))
      if (request.getString("snpbool").equals("hide"))
        this.getModel().getMutationSearchCriteriaVO().setReportedAsSNP(false);

    SearchService searchService = ServiceLocator.instance().getSearchService();

    this.getModel()
        .setProteinDomainDTO(searchService.findProteinDomain(request.getInt("domain_id"), false));
    this.getModel()
        .setMutationSummaryDTOList(
            searchService.findMutationsByDomainId(request.getInt("domain_id")));
    ((HttpServletRequestTuple) request)
        .getRequest()
        .setAttribute("mutationSummaryVOList", this.getModel().getMutationSummaryDTOList());
    this.getModel().setRawOutput(this.include(request, this.getModel().getMutationPager()));

    this.getModel().setHeader((this.getModel().getProteinDomainDTO() == null) ? "Unknown id." : "");

    this.getModel().getMbrowse().setProteinDomainDTO(this.getModel().getProteinDomainDTO());

    if (this.getModel().getMbrowse().getExonDTOList() == null)
      this.getModel().getMbrowse().setExonDTOList(searchService.findAllExons());

    this.setView(new FreemarkerView("proteindomain.ftl", getModel()));
  }
Пример #2
0
  /**
   * Needed for hyperlink form switches...
   *
   * @param request
   * @throws DatabaseException
   */
  private void doXrefselect(Tuple request) throws DatabaseException {
    // also set the parent menu
    if (getParent() != null && getParent() instanceof MenuController) {
      // set the filter to select the xref-ed entity
      pager.resetFilters();
      getModel().setUserRules(new ArrayList<QueryRule>());
      QueryRule rule =
          new QueryRule(
              request.getString("attribute"),
              QueryRule.Operator.valueOf(request.getString("operator")),
              request.getString("value"));
      pager.addFilter(rule);

      // tell "my" menu to select me
      Tuple parentRequest = new SimpleTuple();
      String aChildName = getModel().getName();
      ScreenController<?> aParent = getParent();
      while (aParent != null) {
        if (aParent instanceof MenuModel) {
          parentRequest.set("select", aChildName);
          MenuController c = (MenuController) aParent;
          c.doSelect(parentRequest);
        }
        aChildName = aParent.getName();
        aParent = aParent.getParent();
      }
    }
  }
Пример #3
0
  private void handleFindMutationsByTerm(Tuple request) {
    //		if (StringUtils.isNotEmpty(request.getString("term")) && request.getString("term").length()
    // < 3)
    //		throw new SearchException("Search term is too general. Please use a more specific one.");

    if (StringUtils.isNotEmpty(request.getString("result")))
      this.getModel().setResult(request.getString("result"));
    else this.getModel().setResult("mutations"); // Default: Show mutations

    this.getModel().setMutationSummaryVOHash(new HashMap<String, String>());
    this.getModel().setPatientSummaryVOHash(new HashMap<String, String>());

    SearchService searchService = ServiceLocator.instance().getSearchService();

    if (this.getModel().getResult().equals("patients")) {
      HashMap<String, List<PatientSummaryDTO>> result =
          searchService.findPatientsByTerm(request.getString("term"));

      int numPatients = 0;

      for (String key : result.keySet()) {
        if (CollectionUtils.isNotEmpty(result.get(key))) {
          ((HttpServletRequestTuple) request)
              .getRequest()
              .setAttribute("patientSummaryVOs", result.get(key));
          this.getModel()
              .getPatientSummaryVOHash()
              .put(" " + key + " ", this.include(request, this.getModel().getPatientPager()));
          numPatients += result.get(key).size();
        }
      }

      this.getModel().setHeader(numPatients + " patients found.");
    } else if (this.getModel().getResult().equals("mutations")) {
      HashMap<String, List<MutationSummaryDTO>> result =
          searchService.findMutationsByTerm(request.getString("term"));

      int numMutations = 0;

      for (String key : result.keySet()) {
        if (CollectionUtils.isNotEmpty(result.get(key))) {
          ((HttpServletRequestTuple) request)
              .getRequest()
              .setAttribute("mutationSummaryDTOList", result.get(key));
          this.getModel()
              .getMutationSummaryVOHash()
              .put(" " + key + " ", this.include(request, this.getModel().getMutationPager()));
          numMutations += result.get(key).size();
        }
      }

      this.getModel().setHeader(numMutations + " mutations found.");
    }

    this.setView(new FreemarkerView("freetext.ftl", this.getModel()));
  }
Пример #4
0
 private void handleShowNextMutation(Tuple request) {
   SearchService searchService = ServiceLocator.instance().getSearchService();
   MutationSummaryDTO mutationSummaryDTO =
       searchService.findNextMutation(request.getString("mid"));
   request.set("mid", mutationSummaryDTO.getIdentifier());
   this.handleShowMutation(request);
 }
  @Override
  public ScreenModel.Show handleRequest(Database db, Tuple request, OutputStream downloadStream)
      throws Exception {
    logger.debug(this.getName());

    // check if in dialog
    if (request.getString(FormModel.INPUT_SHOW) == null) {
      ScreenMessage msg = null;
      try {
        CsvToDatabase<? extends Entity> csvReader = this.getFormScreen().getCsvReader();

        int updatedRows =
            csvReader.importCsv(
                db,
                new CsvFileReader(request.getFile("filefor___csvdata")),
                request,
                DatabaseAction.ADD);
        // for (E entity : entities)
        // logger.debug("parsed: " + entity);
        // view.getDatabase().add(entities);
        msg = new ScreenMessage("CSV UPLOAD SUCCESS: added " + updatedRows + " rows", null, true);
        logger.debug("CSV UPLOAD SUCCESS: added " + updatedRows + " rows");
        getFormScreen().getPager().resetFilters();
        getFormScreen().getPager().last(db);
      } catch (Exception e) {
        e.printStackTrace();
        msg = new ScreenMessage("CSV UPLOAD FAILED: " + e.getMessage(), null, false);
        logger.error("CSV UPLOAD FAILED: " + e.getMessage());
      }
      getFormScreen().getMessages().add(msg);
    }

    // show result in the main screen
    return ScreenModel.Show.SHOW_MAIN;
  }
Пример #6
0
  private void handleShowPatient(Tuple request) {
    if (StringUtils.isNotEmpty(request.getString("pid"))) {
      String patientIdentifier = request.getString("pid");

      SearchService searchService = ServiceLocator.instance().getSearchService();

      PatientSummaryDTO patientSummaryVO =
          searchService.findPatientByPatientIdentifier(patientIdentifier);

      this.getModel().setPatientSummaryVO(patientSummaryVO);

      this.getModel().setHeader("Details for patient " + patientIdentifier);

      this.setView(new FreemarkerView(this.getModel().getPatientViewer(), getModel()));
    }
  }
Пример #7
0
  private void handleShowPhenotypeDetails(Tuple request) throws Exception {
    if (StringUtils.isNotEmpty(request.getString("pid"))) {
      String patientIdentifier = request.getString("pid");

      PhenoService phenoService = ServiceLocator.instance().getPhenoService();
      SearchService searchService = ServiceLocator.instance().getSearchService();

      PatientSummaryDTO patientSummaryVO =
          searchService.findPatientByPatientIdentifier(patientIdentifier);

      this.getModel()
          .setIndividualDTO(phenoService.findPhenotypeDetails(patientSummaryVO.getPatientId()));

      this.getModel().setHeader("Phenotypic details for Patient " + patientIdentifier);

      this.setView(new FreemarkerView("phenotypedetails.ftl", getModel()));
    }
  }
Пример #8
0
  /**
   * Get all MAP file entries
   *
   * @return
   * @throws Exception
   */
  public List<MapEntry> getAllEntries() throws Exception {
    reader.reset();
    final ArrayList<MapEntry> result = new ArrayList<MapEntry>();
    int line_number = 0;
    for (Tuple tuple : reader) {
      line_number++;
      for (int objIndex = 0; objIndex < 4; objIndex++) {
        if (tuple.getObject(objIndex) == null)
          throw new Exception(Helper.errorMsg(line_number, objIndex));
      }
      MapEntry me =
          new MapEntry(
              tuple.getString(0), tuple.getString(1), tuple.getDouble(2), tuple.getLong(3));
      result.add(me);
    }

    return result;
  }
Пример #9
0
  private void handleFindPatients(Tuple request) {
    if (StringUtils.isNotEmpty(request.getString("mid"))) {
      String mutationIdentifier = request.getString("mid");

      SearchService searchService = ServiceLocator.instance().getSearchService();

      List<PatientSummaryDTO> patientSummaryVOList =
          searchService.findPatientsByMutationIdentifier(mutationIdentifier);

      ((HttpServletRequestTuple) request)
          .getRequest()
          .setAttribute("patientSummaryVOs", patientSummaryVOList);
      this.getModel().setRawOutput(this.include(request, this.getModel().getPatientPager()));
      this.getModel().setHeader(patientSummaryVOList.size() + " results for " + mutationIdentifier);

      this.setView(new FreemarkerView("included.ftl", this.getModel()));
    }
  }
Пример #10
0
  private void handleShowMutation(Tuple request) {
    if (StringUtils.isNotEmpty(request.getString("mid"))) {
      String mutationIdentifier = request.getString("mid");

      //			if (StringUtils.isNotEmpty(request.getString("snpbool")))
      //				if (request.getString("snpbool").equals("hide"))
      //					this.getModel().getMutationSearchCriteriaVO().setReportedAsSNP(false);

      SearchService searchService = ServiceLocator.instance().getSearchService();

      MutationSummaryDTO mutationSummaryDTO =
          searchService.findMutationByIdentifier(mutationIdentifier);

      this.getModel().setMutationSummaryVO(mutationSummaryDTO);

      this.getModel().setPositionMutations(searchService.findPositionMutations(mutationSummaryDTO));
      this.getModel().setCodonMutations(searchService.findCodonMutations(mutationSummaryDTO));

      this.getModel().setHeader("Details for mutation " + mutationIdentifier);

      this.setView(new FreemarkerView("mutation.ftl", getModel()));
    }
  }
Пример #11
0
  private Show addFilters(DatabasePager<E> pager, Database db, Tuple request)
      throws DatabaseException, MolgenisModelException {
    List<QueryRule> userRules = new ArrayList<QueryRule>();
    for (int i = 0; i < MAX_FILTERS; ++i) {
      // suffix: __filter_value, __filter_value1, __filter_value2 etc.
      String suffix = i > 0 ? i + "" : "";

      String filterAttr = request.getString("__filter_attribute" + suffix);
      if (filterAttr == null) break;

      String operatorStr = request.getString("__filter_operator" + suffix);
      Operator operator = QueryRule.Operator.valueOf(operatorStr);
      String filterValue = request.getString("__filter_value" + suffix);

      QueryRule filterRule;
      if (filterAttr.equals(FILTER_ATTRIBUTE_ALL)) {
        filterRule = createFilterRule(db, operator, filterValue);
      } else {
        String fieldName = toFieldName(filterAttr);
        filterRule = createFilterRule(db, fieldName, operator, filterValue);
      }
      userRules.add(filterRule);
    }

    FormModel<E> model = getModel();
    model.getUserRules().addAll(userRules);

    // reset pager
    List<QueryRule> rules = new ArrayList<QueryRule>();
    rules.addAll(model.getUserRules());
    rules.addAll(model.getSystemRules());
    pager.resetFilters(rules);
    pager.first(db);

    return Show.SHOW_MAIN;
  }
 // @Implements
 public void set(org.molgenis.util.Tuple tuple, boolean strict) throws Exception {
   // optimization :-(
   if (tuple instanceof org.molgenis.util.ResultSetTuple) {
     // set Id
     this.setId(tuple.getInt("id"));
     // set __Type
     this.set__Type(tuple.getString("__Type"));
     // set Name
     this.setName(tuple.getString("name"));
   } else if (tuple != null) {
     // set Id
     if (strict || tuple.getInt("id") != null) this.setId(tuple.getInt("id"));
     if (tuple.getInt("MolgenisRole_id") != null) this.setId(tuple.getInt("MolgenisRole_id"));
     // set __Type
     if (strict || tuple.getString("__Type") != null) this.set__Type(tuple.getString("__Type"));
     if (tuple.getString("MolgenisRole___Type") != null)
       this.set__Type(tuple.getString("MolgenisRole___Type"));
     // set Name
     if (strict || tuple.getString("name") != null) this.setName(tuple.getString("name"));
     if (tuple.getString("MolgenisRole_name") != null)
       this.setName(tuple.getString("MolgenisRole_name"));
   }
   // org.apache.log4j.Logger.getLogger("test").debug("set "+this);
 }
Пример #13
0
  /**
   * Function to build a datastructure filled with rows from a {@link TupleTable}, to be serialised
   * by Gson and displayed from there by a jqGrid.
   *
   * @param rowCount The number of rows to select.
   * @param totalPages The total number of pages of data (ie. dependent on size of dataset and nr.
   *     of rows per page)
   * @param page The selected page.
   * @param table The Tupletable from which to read the data.
   * @return
   */
  public static JQGridResult buildJQGridResults(
      final int rowCount, final int totalPages, final int page, final TupleTable table)
      throws TableException {
    final JQGridResult result = new JQGridResult(page, totalPages, rowCount);
    for (final Tuple row : table.getRows()) {
      System.out.println("check: " + row);
      final LinkedHashMap<String, String> rowMap = new LinkedHashMap<String, String>();

      final List<String> fieldNames = row.getFieldNames();
      for (final String fieldName : fieldNames) {
        final String rowValue = !row.isNull(fieldName) ? row.getString(fieldName) : "null";
        rowMap.put(fieldName, rowValue); // TODO encode to HTML
      }
      result.rows.add(rowMap);
    }
    return result;
  }
Пример #14
0
  @Override
  public void handleRequest(Database db, Tuple request) {
    try {
      String action = request.getString("__action");

      if (action.equals("load")) {
        String filename = request.getString("zip");
        String legacy = request.getString("source");
        if (legacy.equals("prefill")) {
          PrefillAnimalDB myPrefill = new PrefillAnimalDB(db, this.getLogin());
          myPrefill.prefillFromZip(filename);
          this.setSuccess("Pre-filling AnimalDB successful");
        } else if (legacy.equals("ulidb")) {
          ConvertUliDbToPheno myLoadUliDb = new ConvertUliDbToPheno(db, this.getLogin());
          myLoadUliDb.convertFromFile(filename);
          this.setSuccess("Legacy import from Uli Eisel DB successful");
        } else if (legacy.equals("oldadb")) {
          LoadAnimalDB myLoadAnimalDB = new LoadAnimalDB(db, this.getLogin());
          myLoadAnimalDB.convertFromZip(filename);
          this.setSuccess("Legacy import from old AnimalDB successful");
        } else if (legacy.equals("rhutdb")) {
          ConvertRhutDbToPheno myLoadRhutDb = new ConvertRhutDbToPheno(db, this.getLogin());
          myLoadRhutDb.convertFromZip(filename);
          this.setSuccess("Legacy import from Roelof Hut DB successful");
        }
      }

      // if( action.equals("loadUliBackgrounds") )
      // {
      // String filename = request.getString("ulibackgroundtable");
      // ConvertUliDbToPheno myLoadUliDb = new ConvertUliDbToPheno(db,
      // this.getLogin());
      // myLoadUliDb.populateBackground(filename);
      // }
      //
      // if( action.equals("loadUliGenes") )
      // {
      // String filename = request.getString("uligenetable");
      // ConvertUliDbToPheno myLoadUliDb = new ConvertUliDbToPheno(db,
      // this.getLogin());
      // myLoadUliDb.populateGene(filename);
      // }
      //
      // if( action.equals("loadUliLines") )
      // {
      // String filename = request.getString("ulilinetable");
      // ConvertUliDbToPheno myLoadUliDb = new ConvertUliDbToPheno(db,
      // this.getLogin());
      // myLoadUliDb.populateLine(filename);
      // }
      //
      // if( action.equals("loadUliAnimals") )
      // {
      // String filename = request.getString("ulianimaltable");
      // //String filename =
      // "C:/Documents and
      // Settings/Administrator/workspace/molgenis_apps/data/AnimalDB/legacy/20110429_UliEisel/Tierdetails.csv";
      // ConvertUliDbToPheno myLoadUliDb = new ConvertUliDbToPheno(db,
      // this.getLogin());
      // //myLoadUliDb.populateLine("C:/Documents and
      // Settings/Administrator/workspace/molgenis_apps/data/AnimalDB/legacy/20110429_UliEisel/Linie.csv");
      // //myLoadUliDb.populateGene("C:/Documents and
      // Settings/Administrator/workspace/molgenis_apps/data/AnimalDB/legacy/20110429_UliEisel/Gen.csv");
      // //myLoadUliDb.populateBackground("C:/Documents and
      // Settings/Administrator/workspace/molgenis_apps/data/AnimalDB/legacy/20110429_UliEisel/GenetischerHintergrund.csv");
      // myLoadUliDb.populateAnimal(filename);
      // myLoadUliDb.populateProtocolApplication();
      // myLoadUliDb.populateValue(filename);
      // myLoadUliDb.parseParentRelations(filename);
      // myLoadUliDb.writeToDb();
      //
      // CommonService cs = CommonService.getInstance();
      // cs.setDatabase(db);
      // cs.makeObservationTargetNameMap(this.getLogin().getUserName(),
      // true);
      // }
      //
      // if( action.equals("loadAnimals") )
      // {
      // String filename = request.getString("animaltable");
      // LoadAnimalDB myLoadAnimalDB = new LoadAnimalDB(db,
      // this.getLogin());
      // myLoadAnimalDB.populateAnimal(filename);
      // }
      //
      // if( action.equals("loadLocations") )
      // {
      // String filename = request.getString("locationtable");
      // LoadAnimalDB myLoadAnimalDB = new LoadAnimalDB(db,
      // this.getLogin());
      // myLoadAnimalDB.populateLocation(filename);
      // }
      //
      // if( action.equals("loadLitters") )
      // {
      // String filename = request.getString("littertable");
      // LoadAnimalDB myLoadAnimalDB = new LoadAnimalDB(db,
      // this.getLogin());
      // myLoadAnimalDB.populateLitter(filename);
      // }
      //
      // if( action.equals("loadExperiments") )
      // {
      // String filename = request.getString("experimenttable");
      // LoadAnimalDB myLoadAnimalDB = new LoadAnimalDB(db,
      // this.getLogin());
      // myLoadAnimalDB.populateExperiment(filename);
      // }
      //
      // if( action.equals("loadDECApplications") )
      // {
      // String filename = request.getString("decapplicationtable");
      // LoadAnimalDB myLoadAnimalDB = new LoadAnimalDB(db,
      // this.getLogin());
      // myLoadAnimalDB.populateDECApplication(filename);
      // }
      //
      // if( action.equals("loadAnimalsInExperiments") )
      // {
      // String filename = request.getString("experimentanimaltable");
      // LoadAnimalDB myLoadAnimalDB = new LoadAnimalDB(db,
      // this.getLogin());
      // myLoadAnimalDB.populateAnimalsInExperiments(filename);
      // }
      //
      // if( action.equals("loadPresets") )
      // {
      // String filename = request.getString("presettable");
      // LoadAnimalDB myLoadAnimalDB = new LoadAnimalDB(db,
      // this.getLogin());
      // myLoadAnimalDB.populatePreset(filename);
      // }
      //
      // if( action.equals("loadPresetAnimals") )
      // {
      // String filename = request.getString("presetanimaltable");
      // LoadAnimalDB myLoadAnimalDB = new LoadAnimalDB(db,
      // this.getLogin());
      // myLoadAnimalDB.populatePresetAnimals(filename);
      // }
      //
      // if( action.equals("loadEvents") )
      // {
      // String filename = request.getString("eventtable");
      // LoadAnimalDB myLoadAnimalDB = new LoadAnimalDB(db,
      // this.getLogin());
      // myLoadAnimalDB.populateEvents(filename);
      // }

    } catch (Exception e) {
      e.printStackTrace();
      this.setError("Something went wrong while loading your legacy database: " + e.getMessage());
    }
  }
Пример #15
0
  /**
   * Handle a particular {@link MolgenisRequest}, and render into an {@link OutputStream}.
   * Particulars handled:
   *
   * <ul>
   *   <li>Wrap the desired data source in the appropriate instantiation of {@link TupleTable}.
   *   <li>Determine which {@link Operation} the request is asking to handle.
   *   <li>Apply proper sorting and filter rules.
   *   <li>Select the appropriate view towards which to export/render.
   *   <li>Select and render the data.
   * </ul>
   *
   * @param db The database to connect to
   * @param request The {@link MolgenisRequest} tuple that encodes the request to handle
   * @param out The {@link OutputStream} to render to.
   */
  public void handleRequest(Database db, Tuple request, OutputStream out)
      throws HandleRequestDelegationException {
    try {
      final TupleTable tupleTable = tupleTableBuilder.create(db, request);
      final Operation operation =
          StringUtils.isNotEmpty(request.getString(OPERATION))
              ? Operation.valueOf(request.getString(OPERATION))
              : Operation.RENDER_DATA;

      switch (operation) {
        case LOAD_CONFIG:
          loadTupleTableConfig(db, (MolgenisRequest) request, tupleTable);
          break;
        case LOAD_TREE:
          // risky: we give it all columns which would fail if there
          // are many
          final String treeNodes = JQueryUtil.getDynaTreeNodes(tupleTable.getAllColumns());
          ((MolgenisRequest) request).getResponse().getOutputStream().print(treeNodes);
          break;
        case RENDER_DATA:
          final List<QueryRule> rules = new ArrayList<QueryRule>();

          // parse the request into post data
          final JQGridPostData postData = new JQGridPostData(request);

          // convert any filters to query rules
          final List<QueryRule> filterRules = createQueryRulesFromJQGridRequest(postData.filters);

          if (CollectionUtils.isNotEmpty(filterRules)) {
            if (tupleTable instanceof FilterableTupleTable) {
              rules.addAll(filterRules);
              ((FilterableTupleTable) tupleTable).setFilters(rules);
            }
          }

          final int rowCount = tupleTable.getCount();
          final int totalPages = (int) Math.ceil(rowCount / postData.rows);

          // update page
          postData.page = Math.min(postData.page, totalPages);
          final int offset = Math.max((postData.page - 1) * postData.rows, 0);

          final String exportSelection = request.getString("exportSelection");
          if (!StringUtils.equalsIgnoreCase(exportSelection, "ALL")) {
            // data.rows == limit
            tupleTable.setLimit(postData.rows);
            // data.rows * data.page
            tupleTable.setOffset(offset);
          }

          if (StringUtils.isNotEmpty(postData.sidx) && tupleTable instanceof FilterableTupleTable) {
            final Operator sortOperator =
                StringUtils.equals(postData.sord, "asc")
                    ? QueryRule.Operator.SORTASC
                    : QueryRule.Operator.SORTDESC;
            rules.add(new QueryRule(sortOperator, postData.sidx));
          }

          if (tupleTable instanceof FilterableTupleTable) {
            ((FilterableTupleTable) tupleTable).setFilters(rules);
          }

          renderData(((MolgenisRequest) request), postData, totalPages, tupleTable);
      }
    } catch (final Exception e) {
      throw new HandleRequestDelegationException(e);
    }
  }
Пример #16
0
  @Override
  public Show handleRequest(Database db, Tuple request, OutputStream out) {
    logger.debug("handleRequest(" + request + ")");

    // clear the old messages
    FormModel<E> model = getModel();
    model.setMessages(new Vector<ScreenMessage>()); // clear messsages

    try {
      String action = request.getString(FormModel.INPUT_ACTION);
      if (request.getString(FormModel.INPUT_COMMAND) != null) {
        action = request.getString(FormModel.INPUT_COMMAND);
      }

      // get the selected ids into the screen list (if any)
      model.setSelectedIds(request.getList(FormModel.INPUT_SELECTED));

      // if none selected, make empty list
      if (model.getSelectedIds() == null) model.setSelectedIds(new ArrayList<Object>());

      // get the current command if any
      ScreenCommand command = model.getCommand(action);

      if (action == null || action.isEmpty()) {
        logger.debug("action or command does not exist");
        return Show.SHOW_MAIN;
      }
      // delegate to a command
      else if (command != null && command instanceof SimpleCommand) {
        logger.debug("delegating to PluginCommand");
        model.setCurrentCommand(command);
        return command.handleRequest(db, request, out);
      } else if (action.equals("filter_add")) {
        this.addFilters(pager, db, request);
      } else if (action.equals("filter_remove")) {
        // remove filter
        int index = request.getInt("filter_id");
        model.getUserRules().remove(index);

        // update pager
        List<QueryRule> rules = new ArrayList<QueryRule>();
        rules.addAll(model.getUserRules());
        rules.addAll(model.getSystemRules());
        pager.resetFilters(rules);
      } else if (action.equals("filter_set")) {
        // remove all existing filters and than add this as a new one.
        model.setUserRules(new ArrayList<QueryRule>());
        this.addFilters(pager, db, request);
      } else if (action.equals("update")) {
        this.doUpdate(db, request);
      } else if (action.equals("remove")) {
        this.doRemove(db, request);
      } else if (action.equals("add")) {
        this.doAdd(db, request);
      } else if (action.equals("prev")) {
        pager.prev(db);
      } else if (action.equals("next")) {
        pager.next(db);
      } else if (action.equals("first")) {
        pager.first(db);
      } else if (action.equals("last")) {
        pager.last(db);
      } else if (action.equals("sort")) {
        String attribute = getSearchField(request.getString("__sortattribute"));

        if (pager.getOrderByField().equals(attribute)) {
          if (pager.getOrderByOperator().equals(Operator.SORTASC)) {
            pager.setOrderByOperator(Operator.SORTDESC);
          } else {
            pager.setOrderByOperator(Operator.SORTASC);
          }
        } else {
          pager.setOrderByField(attribute);
          pager.setOrderByOperator(Operator.SORTASC);
        }
      } else if (action.equals("xref_select")) // this is used to link from
      // one
      // form to another based on an xref
      {
        this.doXrefselect(request);
      } else if (action.equals("hideColumn")) {
        List<String> UserHiddencols = model.getUserHiddenColumns();
        String attribute = request.getString("attribute");

        if (!UserHiddencols.contains(attribute)) UserHiddencols.add(attribute);
        model.setUserHiddenColumns(UserHiddencols);

      } else if (action.equals("showColumn")) {
        List<String> UserHiddencols = model.getUserHiddenColumns();
        String attribute = request.getString("attribute");

        if (UserHiddencols.contains(attribute)) UserHiddencols.remove(attribute);
        model.setUserHiddenColumns(UserHiddencols);
      } else {
        logger.debug("action '" + action + "' unknown");
      }

      logger.debug("handleRequest finished.");
    } catch (Exception e) {
      e.printStackTrace();
      logger.error(e);
    }
    return Show.SHOW_MAIN;
  }
  /**
   * Imports UploadBatch from tab/comma delimited File
   *
   * @param db database to import into
   * @param reader csv reader to load data from
   * @param defaults to set default values for each row
   * @param dbAction indicating wether to add,update,remove etc
   * @param missingValues indicating what value in the csv is treated as 'null' (e.g. "" or "NA")
   * @return number of elements imported
   */
  public int importCsv(
      final Database db,
      CsvReader reader,
      final Tuple defaults,
      final DatabaseAction dbAction,
      final String missingValues)
      throws DatabaseException, IOException, Exception {
    // cache for entities of which xrefs couldn't be resolved (e.g. if there
    // is a self-refence)
    // these entities can be updated with their xrefs in a second round when
    // all entities are in the database
    // final List<UploadBatch> uploadBatchsMissingRefs = new
    // ArrayList<UploadBatch>();

    final MutationService mutationService = new MutationService();
    mutationService.setDatabase(db);
    final UploadService uploadService = new UploadService();
    uploadService.setDatabase(db);

    final Submission submission = new Submission();
    DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
    submission.setDate(dateFormat.format(new Date()));
    submission.setReleasedate(dateFormat.format(new Date()));
    submission.setIdentifier("S" + new Date());
    if (db instanceof JDBCDatabase) {
      List<Integer> submitters = new ArrayList<Integer>();
      submitters.add(db.getLogin().getUserId());
      submission.setSubmitters_Id(submitters);
    } else if (db instanceof JpaDatabase) {
      List<MolgenisUser> submitters = new ArrayList<MolgenisUser>();
      submitters.add(db.findById(MolgenisUser.class, db.getLogin().getUserId()));
      // submission.setSubmitters(submitters);
    }
    db.add(submission);

    // cache for objects to be imported from file (in batch)
    // TODO: Danny: Use or loose
    /* final List<PatientSummaryVO> patientList = */ new ArrayList<PatientSummaryVO>(BATCH_SIZE);
    // wrapper to count
    final IntegerWrapper total = new IntegerWrapper(0);
    reader.setMissingValues(missingValues);

    Integer mutationIdentifier = uploadService.getMaxMutationIdentifier();
    Integer patientIdentifier = uploadService.getMaxPatientIdentifier();

    for (Tuple tuple : reader) {

      // parse object, setting defaults and values from file
      // if (lineNo > 5) return;
      PatientSummaryVO patientSummaryVO = new PatientSummaryVO();

      patientSummaryVO.setSubmissionDate(submission.getDate());

      patientSummaryVO.setPatientNumber(tuple.getString("Local patient number"));
      patientSummaryVO.setPatientGender(
          ObjectUtils.toString(StringUtils.lowerCase(tuple.getString("Gender")), "unknown"));
      patientSummaryVO.setPatientEthnicity(tuple.getString("Ethnicity"));
      patientSummaryVO.setPatientAge(ObjectUtils.toString(tuple.getString("Age"), "unknown"));
      patientSummaryVO.setPatientDeceased(
          ObjectUtils.toString(StringUtils.lowerCase(tuple.getString("Deceased")), "unknown"));
      patientSummaryVO.setPatientConsent(
          ObjectUtils.toString(StringUtils.lowerCase(tuple.getString("Signed consent")), "no"));

      patientSummaryVO.setVariantSummaryVOList(new ArrayList<MutationSummaryVO>());

      if (StringUtils.isNotEmpty(tuple.getString("cDNA change_1"))) {
        MutationUploadVO mutationUploadVO = new MutationUploadVO();
        mutationUploadVO.setGeneSymbol("COL7A1");
        mutationUploadVO.setMutation(new Mutation());
        mutationUploadVO.getMutation().setCdna_Notation("c." + tuple.getString("cDNA change_1"));
        mutationService.assignValuesFromNotation(mutationUploadVO);
        if (StringUtils.isNotEmpty(tuple.getString("Protein change_1")))
          mutationUploadVO.getMutation().setAa_Notation("p." + tuple.getString("Protein change_1"));
        if (StringUtils.isNotEmpty(tuple.getString("Consequence_1")))
          mutationUploadVO
              .getMutation()
              .setConsequence(ObjectUtils.toString(tuple.getString("Consequence_1"), ""));
        mutationUploadVO
            .getMutation()
            .setInheritance(
                ObjectUtils.toString(StringUtils.lowerCase(tuple.getString("Inheritance_1")), ""));

        mutationIdentifier = mutationIdentifier + 1;
        mutationUploadVO.getMutation().setIdentifier("M" + mutationIdentifier);
        mutationUploadVO.getMutation().setName("M" + mutationIdentifier);

        // Insert mutation if it does not exist already

        MutationSearchCriteriaVO criteria = new MutationSearchCriteriaVO();
        criteria.setVariation(mutationUploadVO.getMutation().getCdna_Notation());
        List<MutationSummaryVO> results = mutationService.findMutations(criteria);

        if (results.size() != 1) {
          uploadService.insert(mutationUploadVO);
          System.out.println(">>>Inserted mutation: " + mutationUploadVO.getMutation().toString());
        }
        MutationSummaryVO mutationSummaryVO = new MutationSummaryVO();
        mutationSummaryVO.setCdnaNotation(mutationUploadVO.getMutation().getCdna_Notation());

        patientSummaryVO.getVariantSummaryVOList().add(mutationSummaryVO);
      }

      // Second mutation can be 'NA' or 'unknown':
      // Leave xref == null and add remark in mutation2remark
      if (StringUtils.isNotEmpty(tuple.getString("cDNA change_2"))) {
        if (tuple.getString("cDNA change_2").equalsIgnoreCase("na"))
          patientSummaryVO.setVariantComment(tuple.getString("cDNA change_2").toUpperCase());
        else if (tuple.getString("cDNA change_2").equalsIgnoreCase("unknown"))
          patientSummaryVO.setVariantComment(tuple.getString("cDNA change_2").toUpperCase());
        else {
          MutationUploadVO mutationUploadVO = new MutationUploadVO();
          mutationUploadVO.setGeneSymbol("COL7A1");
          mutationUploadVO.setMutation(new Mutation());
          mutationUploadVO.getMutation().setCdna_Notation("c." + tuple.getString("cDNA change_2"));
          mutationService.assignValuesFromNotation(mutationUploadVO);
          if (StringUtils.isNotEmpty(tuple.getString("Protein change_2")))
            mutationUploadVO
                .getMutation()
                .setAa_Notation("p." + tuple.getString("Protein change_2"));
          if (StringUtils.isNotEmpty(tuple.getString("Consequence_2")))
            mutationUploadVO
                .getMutation()
                .setConsequence(ObjectUtils.toString(tuple.getString("Consequence_2"), ""));
          mutationUploadVO
              .getMutation()
              .setInheritance(
                  ObjectUtils.toString(
                      StringUtils.lowerCase(tuple.getString("Inheritance_2")), ""));

          mutationIdentifier = mutationIdentifier + 1;
          mutationUploadVO.getMutation().setIdentifier("M" + mutationIdentifier);
          mutationUploadVO.getMutation().setName("M" + mutationIdentifier);

          // Insert mutation if it does not exist already

          MutationSearchCriteriaVO criteria = new MutationSearchCriteriaVO();
          criteria.setVariation(mutationUploadVO.getMutation().getCdna_Notation());
          List<MutationSummaryVO> results = mutationService.findMutations(criteria);

          if (results.size() != 1) {
            uploadService.insert(mutationUploadVO);
            System.out.println(
                ">>>Inserted mutation: " + mutationUploadVO.getMutation().toString());
          }
          MutationSummaryVO mutationSummaryVO = new MutationSummaryVO();
          mutationSummaryVO.setCdnaNotation(mutationUploadVO.getMutation().getCdna_Notation());

          patientSummaryVO.getVariantSummaryVOList().add(mutationSummaryVO);
        }
      }

      patientSummaryVO.setPhenotypeMajor(
          StringUtils.upperCase(tuple.getString("Phenotype major type")));
      patientSummaryVO.setPhenotypeSub(StringUtils.lowerCase(tuple.getString("Phenotype Subtype")));

      // PhenotypeDetailsVO phenotypeDetailsVO = new PhenotypeDetailsVO();

      // patientSummaryVO.getPhenotypeDetails().setLocation(ObjectUtils.toString(StringUtils.lowerCase(tuple.getString("Location")),
      // "unknown"));
      // patientSummaryVO.getPhenotypeDetails().setBlistering(ObjectUtils.toString(StringUtils.lowerCase(tuple.getString("Blistering")),
      // "unknown"));
      // patientSummaryVO.getPhenotypeDetails().setHands(ObjectUtils.toString(StringUtils.lowerCase(tuple.getString("Hands")),
      // "unknown"));
      // patientSummaryVO.getPhenotypeDetails().setFeet(ObjectUtils.toString(StringUtils.lowerCase(tuple.getString("Feet")),
      // "unknown"));
      // patientSummaryVO.getPhenotypeDetails().setArms(ObjectUtils.toString(StringUtils.lowerCase(tuple.getString("Arms")),
      // "unknown"));
      // patientSummaryVO.getPhenotypeDetails().setLegs(ObjectUtils.toString(StringUtils.lowerCase(tuple.getString("Legs")),
      // "unknown"));
      // patientSummaryVO.getPhenotypeDetails().setProximal_Body_Flexures(ObjectUtils.toString(StringUtils.lowerCase(tuple.getString("Proximal body flexures")),
      // "unknown"));
      // patientSummaryVO.getPhenotypeDetails().setTrunk(ObjectUtils.toString(StringUtils.lowerCase(tuple.getString("Trunk")),
      // "unknown"));
      // patientSummaryVO.getPhenotypeDetails().setMucous_Membranes(ObjectUtils.toString(StringUtils.lowerCase(tuple.getString("Mucosa")),
      // "unknown"));
      // patientSummaryVO.getPhenotypeDetails().setSkin_Atrophy(ObjectUtils.toString(StringUtils.lowerCase(tuple.getString("Skin atrophy")),
      // "unknown"));
      // patientSummaryVO.getPhenotypeDetails().setMilia(ObjectUtils.toString(StringUtils.lowerCase(tuple.getString("Milia")),
      // "unknown"));
      // patientSummaryVO.getPhenotypeDetails().setNail_Dystrophy(ObjectUtils.toString(StringUtils.lowerCase(tuple.getString("Nail dystrophy")),
      // "unknown"));
      // patientSummaryVO.getPhenotypeDetails().setAlbopapuloid_Papules(ObjectUtils.toString(StringUtils.lowerCase(tuple.getString("Albopapuloid papules")),
      // "unknown"));
      // patientSummaryVO.getPhenotypeDetails().setPruritic_Papules(ObjectUtils.toString(StringUtils.lowerCase(tuple.getString("Pruritic papules")),
      // "unknown"));
      // patientSummaryVO.getPhenotypeDetails().setAlopecia(ObjectUtils.toString(StringUtils.lowerCase(tuple.getString("Alopecia")),
      // "unknown"));
      // patientSummaryVO.getPhenotypeDetails().setSquamous_Cell_Carcinomas(ObjectUtils.toString(StringUtils.lowerCase(tuple.getString("Squamous cell carcinoma(s)")),
      // "unknown"));
      // patientSummaryVO.getPhenotypeDetails().setRevertant_Skin_Patch(ObjectUtils.toString(StringUtils.lowerCase(tuple.getString("Revertant skin patch(es)")),
      // "unknown"));
      // patientSummaryVO.getPhenotypeDetails().setMechanism(ObjectUtils.toString(StringUtils.lowerCase(tuple.getString("Mechanism")),
      // "unknown"));
      // patientSummaryVO.getPhenotypeDetails().setFlexion_Contractures(ObjectUtils.toString(StringUtils.lowerCase(tuple.getString("Flexion contractures")),
      // "unknown"));
      // patientSummaryVO.getPhenotypeDetails().setPseudosyndactyly_Hands(ObjectUtils.toString(StringUtils.lowerCase(tuple.getString("Pseudosyndactyly (hands)")),
      // "unknown"));
      // patientSummaryVO.getPhenotypeDetails().setMicrostomia(ObjectUtils.toString(StringUtils.lowerCase(tuple.getString("Microstomia")),
      // "unknown"));
      // patientSummaryVO.getPhenotypeDetails().setAnkyloglossia(ObjectUtils.toString(StringUtils.lowerCase(tuple.getString("Ankyloglossia")),
      // "unknown"));
      // patientSummaryVO.getPhenotypeDetails().setDysphagia(ObjectUtils.toString(StringUtils.lowerCase(tuple.getString("Swallowing difficulties/ dysphagia/ oesophagus strictures")),
      // "unknown"));
      // patientSummaryVO.getPhenotypeDetails().setGrowth_Retardation(ObjectUtils.toString(StringUtils.lowerCase(tuple.getString("Growth retardation")),
      // "unknown"));
      // patientSummaryVO.getPhenotypeDetails().setAnemia(ObjectUtils.toString(StringUtils.lowerCase(tuple.getString("Anaemia")),
      // "unknown"));
      // patientSummaryVO.getPhenotypeDetails().setRenal_Failure(ObjectUtils.toString(StringUtils.lowerCase(tuple.getString("Renal failure")),
      // "unknown"));
      // patientSummaryVO.getPhenotypeDetails().setDilated_Cardiomyopathy(ObjectUtils.toString(StringUtils.lowerCase(tuple.getString("Dilated cardiomyopathy")),
      // "unknown"));
      //
      // patientSummaryVO.getPhenotypeDetails().setColoboma(ObjectUtils.toString(StringUtils.lowerCase(tuple.getString("Coloboma")),
      // "unknown"));
      // patientSummaryVO.getPhenotypeDetails().setCongenital_Heart_Defect(ObjectUtils.toString(StringUtils.lowerCase(tuple.getString("Congenital heart defect")),
      // "unknown"));
      // patientSummaryVO.getPhenotypeDetails().setClp(ObjectUtils.toString(StringUtils.lowerCase(tuple.getString("C(L)P")),
      // "unknown"));
      // patientSummaryVO.getPhenotypeDetails().setChoanal_Anomaly(ObjectUtils.toString(StringUtils.lowerCase(tuple.getString("Choanal anomaly")),
      // "unknown"));
      // patientSummaryVO.getPhenotypeDetails().setMental_Retardation(ObjectUtils.toString(StringUtils.lowerCase(tuple.getString("Mental retardation")),
      // "unknown"));
      // patientSummaryVO.getPhenotypeDetails().setGrowth_Retardation(ObjectUtils.toString(StringUtils.lowerCase(tuple.getString("Growth retardation")),
      // "unknown"));
      // patientSummaryVO.getPhenotypeDetails().setGenital_Hypoplasia(ObjectUtils.toString(StringUtils.lowerCase(tuple.getString("Genital hypoplasia")),
      // "unknown"));
      // patientSummaryVO.getPhenotypeDetails().setExternal_Ear_Anomaly(ObjectUtils.toString(StringUtils.lowerCase(tuple.getString("External ear anomaly")),
      // "unknown"));
      // patientSummaryVO.getPhenotypeDetails().setSemicircular_Canal_Anomaly(ObjectUtils.toString(StringUtils.lowerCase(tuple.getString("Semicircular canal anomaly")),
      // "unknown"));
      // patientSummaryVO.getPhenotypeDetails().setHearing_Loss(ObjectUtils.toString(StringUtils.lowerCase(tuple.getString("Hearing loss")),
      // "unknown"));
      // patientSummaryVO.getPhenotypeDetails().setTe_Anomaly(ObjectUtils.toString(StringUtils.lowerCase(tuple.getString("TE anomaly")),
      // "unknown"));
      // patientSummaryVO.getPhenotypeDetails().setCn_Dysfunction(ObjectUtils.toString(StringUtils.lowerCase(tuple.getString("CN dysfunction")),
      // "unknown"));

      // for (String field :
      // patientSummaryVO.getPhenotypeDetails().getFields(true))
      // {
      // if ("".equals(patientSummaryVO.getPhenotypeDetails().get(field)))
      // patientSummaryVO.getPhenotypeDetails().set(field, "unknown");
      // }
      // patientSummaryVO.getPhenotypeDetails().set(tuple.getString(""));

      if (tuple.getString("PubMed ID") != null && tuple.getString("Reference") != null) {
        List<PublicationVO> publicationVOs = new ArrayList<PublicationVO>();
        String[] pubmeds = tuple.getString("PubMed ID").split(";");
        String[] titles = tuple.getString("Reference").split(";");
        for (int i = 0; i < pubmeds.length; i++) {
          PublicationVO publicationVO = new PublicationVO();
          publicationVO.setPubmedId(pubmeds[i]);
          publicationVO.setName(titles[i]);
          publicationVO.setTitle(titles[i]);
          publicationVOs.add(publicationVO);
        }
        patientSummaryVO.setPublicationVOList(publicationVOs);
        patientSummaryVO.setPatientConsent("publication");
      }

      patientIdentifier = patientIdentifier + 1;
      patientSummaryVO.setPatientIdentifier("P" + patientIdentifier);
      patientSummaryVO.setPatientName("P" + patientIdentifier);

      patientSummaryVO.setObservedValueVOList(new ArrayList<ObservedValueVO>());

      ObservedValueVO observedValueVO;

      observedValueVO = new ObservedValueVO();
      observedValueVO.setFeatureName("LH7:2 Amount of type VII collagen");
      observedValueVO.setTargetName(patientSummaryVO.getPatientIdentifier());
      observedValueVO.setValue(ObjectUtils.toString(tuple.getString("IF LH7:2"), "unknown"));
      patientSummaryVO.getObservedValueVOList().add(observedValueVO);

      observedValueVO = new ObservedValueVO();
      observedValueVO.setFeatureName("IF Retention of type VII Collagen in basal cells");
      observedValueVO.setTargetName(patientSummaryVO.getPatientIdentifier());
      observedValueVO.setValue(
          ObjectUtils.toString(tuple.getString("IF Retention COLVII"), "unknown"));
      patientSummaryVO.getObservedValueVOList().add(observedValueVO);

      observedValueVO = new ObservedValueVO();
      observedValueVO.setFeatureName("Anchoring fibrils Number");
      observedValueVO.setTargetName(patientSummaryVO.getPatientIdentifier());
      observedValueVO.setValue(ObjectUtils.toString(tuple.getString("EM AF_no"), "unknown"));
      patientSummaryVO.getObservedValueVOList().add(observedValueVO);

      observedValueVO = new ObservedValueVO();
      observedValueVO.setFeatureName("Anchoring fibrils Ultrastructure");
      observedValueVO.setTargetName(patientSummaryVO.getPatientIdentifier());
      observedValueVO.setValue(ObjectUtils.toString(tuple.getString("EM AF_structure"), "unknown"));
      patientSummaryVO.getObservedValueVOList().add(observedValueVO);

      observedValueVO = new ObservedValueVO();
      observedValueVO.setFeatureName("EM Retention of type VII Collagen in basal cells");
      observedValueVO.setTargetName(patientSummaryVO.getPatientIdentifier());
      observedValueVO.setValue(
          ObjectUtils.toString(tuple.getString("EM_Retention COLVII"), "unknown"));
      patientSummaryVO.getObservedValueVOList().add(observedValueVO);

      for (int i = 34; ; i++) {
        System.out.println(">>>i==" + i);
        String colName = tuple.getColName(i);
        System.out.println(">>>colName==" + colName);

        if (colName == null) break;

        observedValueVO = new ObservedValueVO();
        observedValueVO.setFeatureName(colName);
        observedValueVO.setTargetName(patientSummaryVO.getPatientIdentifier());
        observedValueVO.setValue(ObjectUtils.toString(tuple.getString(colName), "unknown"));
        patientSummaryVO.getObservedValueVOList().add(observedValueVO);
      }

      uploadService.insert(patientSummaryVO);

      total.set(total.get() + 1);
      // patientList.add(patientSummaryVO);
      //
      // //add to db when batch size is reached
      // if(patientList.size() == BATCH_SIZE)
      // {
      // //resolve foreign keys and copy those entities that could not be
      // resolved to the missingRefs list
      // uploadBatchsMissingRefs.addAll(resolveForeignKeys(db,
      // uploadBatchList));
      //
      // //update objects in the database using xref_label defined
      // secondary key(s) 'id' defined in xref_label
      // db.update(uploadBatchList,dbAction, "id");
      //
      // //clear for next batch
      // uploadBatchList.clear();
      //
      // //keep count
      // total.set(total.get() + BATCH_SIZE);
      // }
    }

    // add remaining elements to the database
    // if(!uploadBatchList.isEmpty())
    // {
    // //resolve foreign keys, again keeping track of those entities that
    // could not be solved
    // uploadBatchsMissingRefs.addAll(resolveForeignKeys(db,
    // uploadBatchList));
    // //update objects in the database using xref_label defined secondary
    // key(s) 'id' defined in xref_label
    // db.update(uploadBatchList,dbAction, "id");
    // }
    //
    // //second import round, try to resolve FK's for entities again as they
    // might have referred to entities in the imported list
    // List<UploadBatch> uploadBatchsStillMissingRefs =
    // resolveForeignKeys(db, uploadBatchsMissingRefs);
    //
    // //if there are still missing references, throw error and rollback
    // if(uploadBatchsStillMissingRefs.size() > 0){
    // throw new
    // Exception("Import of 'UploadBatch' objects failed: attempting to resolve in-list references,
    // but there are still UploadBatchs referring to UploadBatchs that are neither in the database
    // nor in the list of to-be imported UploadBatchs. (the first one being:
    // "+uploadBatchsStillMissingRefs.get(0)+")");
    // }
    // //else update the entities in the database with the found references
    // and return total
    // else
    // {
    // db.update(uploadBatchsMissingRefs,DatabaseAction.UPDATE, "id");
    //
    // //output count
    // total.set(total.get() + uploadBatchList.size());
    // logger.info("imported "+total.get()+" uploadBatch from CSV");
    //
    // return total.get();
    // }

    return total.get();
  }
Пример #18
0
  private void handleFindMutations(Tuple request) {
    this.getModel().setMutationSearchCriteriaVO(new MutationSearchCriteriaDTO());
    if (StringUtils.isNotEmpty(request.getString("variation")))
      this.getModel().getMutationSearchCriteriaVO().setVariation(request.getString("variation"));
    if (StringUtils.isNotEmpty(request.getString("consequence")))
      this.getModel()
          .getMutationSearchCriteriaVO()
          .setConsequence(request.getString("consequence"));
    if (StringUtils.isNotEmpty(request.getString("mutation_id")))
      this.getModel().getMutationSearchCriteriaVO().setMutationId(request.getInt("mutation_id"));
    if (StringUtils.isNotEmpty(request.getString("mid")))
      this.getModel().getMutationSearchCriteriaVO().setMid(request.getString("mid"));
    if (StringUtils.isNotEmpty(request.getString("nuclno")))
      this.getModel().getMutationSearchCriteriaVO().setCdnaPosition(request.getInt("nuclno"));
    if (StringUtils.isNotEmpty(request.getString("aano")))
      this.getModel().getMutationSearchCriteriaVO().setCodonChangeNumber(request.getInt("aano"));
    if (StringUtils.isNotEmpty(request.getString("exon_id")))
      this.getModel().getMutationSearchCriteriaVO().setExonId(request.getInt("exon_id"));
    if (StringUtils.isNotEmpty(request.getString("exon")))
      this.getModel().getMutationSearchCriteriaVO().setExonName(request.getString("exon"));
    if (StringUtils.isNotEmpty(request.getString("type")))
      this.getModel().getMutationSearchCriteriaVO().setType(request.getString("type"));
    if (StringUtils.isNotEmpty(request.getString("domain_id")))
      this.getModel().getMutationSearchCriteriaVO().setProteinDomainId(request.getInt("domain_id"));
    if (StringUtils.isNotEmpty(request.getString("phenotype")))
      this.getModel()
          .getMutationSearchCriteriaVO()
          .setPhenotypeName(request.getString("phenotype"));
    if (StringUtils.isNotEmpty(request.getString("inheritance")))
      this.getModel()
          .getMutationSearchCriteriaVO()
          .setInheritance(request.getString("inheritance"));
    if (StringUtils.isNotEmpty(request.getString("snpbool")))
      if (request.getString("snpbool").equals("hide"))
        this.getModel().getMutationSearchCriteriaVO().setReportedAsSNP(false);

    SearchService searchService = ServiceLocator.instance().getSearchService();

    this.getModel()
        .setMutationSummaryDTOList(
            searchService.findMutations(this.getModel().getMutationSearchCriteriaVO()));
    ((HttpServletRequestTuple) request)
        .getRequest()
        .setAttribute("mutationSummaryDTOList", this.getModel().getMutationSummaryDTOList());
    this.getModel().setRawOutput(this.include(request, this.getModel().getMutationPager()));

    this.getModel().setHeader(this.getModel().getMutationSummaryDTOList().size() + " results.");

    this.setView(new FreemarkerView("included.ftl", this.getModel()));
  }
Пример #19
0
  @Override
  public Show handleRequest(Database db, Tuple request, OutputStream out) {
    ServiceLocator.instance()
        .getContext()
        .getAutowireCapableBeanFactory()
        .initializeBean(db, "org.molgenis.framework.db.Database");

    try {
      if (StringUtils.isEmpty(request.getAction())) this.getModel().setAction("init");
      else this.getModel().setAction(request.getAction());

      if ("1".equals(request.getString("expertSearch")))
        this.getModel().getQueryParametersVO().setExpertSearch(true);
      else this.getModel().getQueryParametersVO().setExpertSearch(false);

      if (this.getModel().getAction().equals("findMutationsByTerm")) {
        this.handleFindMutationsByTerm(request);
      } else if (this.getModel().getAction().equals("findMutations")) {
        this.handleFindMutations(request);
      } else if (this.getModel().getAction().equals("findPatients")) {
        this.handleFindPatients(request);
      } else if (this.getModel().getAction().equals("listAllMutations")) {
        this.listAllMutations(request);
      } else if (this.getModel().getAction().equals("listAllPatients")) {
        this.listAllPatients(request);
      } else if (this.getModel().getAction().equals("showProteinDomain")) {
        this.handleShowProteinDomain(request);
      } else if (this.getModel().getAction().equals("showExon")) {
        this.handleShowExon(request);
      } else if (this.getModel().getAction().equals("showFirstExon")) {
        this.handleShowFirstExon(request);
      } else if (this.getModel().getAction().equals("showPrevExon")) {
        this.handleShowPrevExon(request);
      } else if (this.getModel().getAction().equals("showNextExon")) {
        this.handleShowNextExon(request);
      } else if (this.getModel().getAction().equals("showLastExon")) {
        this.handleShowLastExon(request);
      } else if (this.getModel().getAction().equals("showMutation")) {
        this.handleShowMutation(request);
      } else if (this.getModel().getAction().equals("showFirstMutation")) {
        this.handleShowFirstMutation(request);
      } else if (this.getModel().getAction().equals("showPrevMutation")) {
        this.handleShowPrevMutation(request);
      } else if (this.getModel().getAction().equals("showNextMutation")) {
        this.handleShowNextMutation(request);
      } else if (this.getModel().getAction().equals("showLastMutation")) {
        this.handleShowLastMutation(request);
      } else if (this.getModel().getAction().equals("showPatient")) {
        this.handleShowPatient(request);
      } else if (this.getModel().getAction().equals("showPhenotypeDetails")) {
        this.handleShowPhenotypeDetails(request);
      } else if (this.getModel().getAction().startsWith("mutationsFirstPage")) {
        this.getModel().getPager().first();
      } else if (this.getModel().getAction().startsWith("mutationsPrevPage")) {
        this.getModel().getPager().prev();
      } else if (this.getModel().getAction().startsWith("mutationsNextPage")) {
        this.getModel().getPager().next();
      } else if (this.getModel().getAction().startsWith("mutationsLastPage")) {
        this.getModel().getPager().last();
      } else {
        this.setView(new FreemarkerView("init.ftl", this.getModel()));
      }

      this.populateDisplayOptionsForm();

      //			for (ScreenController<?> child : this.getChildren())
      //			{
      //				child.handleRequest(db, request, out);
      //			}
    } catch (Exception e) {
      String message =
          "Oops, an error occurred. We apologize and will work on fixing it as soon as possible. <a href=\"molgenis.do?__target=SearchPlugin&__action=init&expertSearch=0\">Return to home page</a>";
      this.getModel().getMessages().add(new ScreenMessage(message, false));
      for (StackTraceElement el : e.getStackTrace()) logger.error(el.toString());
      //				this.getMessages().add(new ScreenMessage(el.toString(), false));
    }

    return Show.SHOW_MAIN;
  }