Package org.molgenis.framework.ui

Examples of org.molgenis.framework.ui.ScreenMessage


    logger.debug(this.getName());

    // check if in dialog
    if (request.getString(FormModel.INPUT_SHOW) == null)
    {
      ScreenMessage msg = null;
      try
      {
        CsvReader csvReader = new CsvReader(new StringReader(request.getString("__csvdata")));
        String entityName = this.getFormScreen().getEntityClass().getSimpleName();

        EntitiesImporter entitiesImporter = this.getFormScreen().getCsvEntityImporter();
        entitiesImporter.setDatabase(db);

        EntityImportReport importReport = null;
        try
        {
          importReport = entitiesImporter.importEntities(csvReader, entityName, DatabaseAction.ADD);
        }
        finally
        {
          csvReader.close();
        }

        msg = new ScreenMessage("CSV UPLOAD SUCCESS: added " + importReport.getNrImported() + " rows", null,
            true);
        logger.debug("CSV UPLOAD SUCCESS: added " + importReport.getNrImported() + " 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);
    }
View Full Code Here


      for (Object id : idList)
      {
        logger.info("mass updating id: " + id);
      }

      ScreenMessage msg = null;

      // cleanup the request, only use ticked (marked with 'use_'
      WritableTuple tuple = new KeyValueTuple();
      for (HtmlInput<?> input : this.getFormScreen().getNewRecordForm().getInputs())
      {
        if (!request.isNull("use_" + input.getName()))
        {
          tuple.set(input.getName(), request.get(input.getName()));
        }
      }

      int row = 0;
      try
      {
        Query<? extends Entity> q = db.query(view.getController().getEntityClass()).in(
            view.create().getIdField(), idList);
        List<? extends Entity> entities = q.find();

        db.beginTx();
        for (Entity e : entities)
        {
          row++;
          // set only not null values
          e.set(tuple, false);
          db.update(e);
        }
        db.commitTx();
        msg = new ScreenMessage("MASS UPDATE SUCCESS: updated " + entities.size() + " rows", null, true);
      }

      catch (Exception e)
      {
        try
        {
          db.rollbackTx();
        }
        catch (DatabaseException e1)
        {
          logger.error("doMassUpdate() Should never happen: " + e1);
          e1.printStackTrace();
        }
        msg = new ScreenMessage("MASS UPDATE FAILED on item '" + row + "': " + e, null, false);
      }

      view.getMessages().add(msg);
    }
    // record the selected ids
View Full Code Here

  {
    logger.debug(this.getName());

    FormModel<? extends Entity> view = getFormScreen();

    ScreenMessage msg = null;
    try
    {
      // get ids
      List<?> idList = request.getList(FormModel.INPUT_SELECTED);
      if (idList == null || idList.size() == 0) throw new Exception("no items selected");
      for (Object id : idList)
      {
        logger.info("mass removing id: " + id);
      }

      // find selected entities
      Query<? extends Entity> q = db.query(view.getController().getEntityClass()).in(view.create().getIdField(),
          idList);
      List<? extends Entity> selection = q.find();

      // delete selected entities
      db.remove(selection);
      msg = new ScreenMessage("REMOVED " + selection.size() + " records", null, true);
    }
    catch (Exception e)
    {
      msg = new ScreenMessage("REMOVE SELECTION FAILED: " + e.getMessage(), null, false);
    }
    view.getMessages().add(msg);

    // **make sure the user sees a record**/
    if (msg.isSuccess())
    {
      view.getPager().prev(db);
      // resetChildren();
    }

View Full Code Here

    logger.debug(this.getName());

    // check if in dialog
    if (request.getString(FormModel.INPUT_SHOW) == null)
    {
      ScreenMessage msg = null;
      try
      {
        CsvReader csvReader = new CsvReader(request.getFile("filefor___csvdata"));
        String entityName = this.getFormScreen().getEntityClass().getSimpleName();

        EntityImportReport importReport = null;
        try
        {
          EntitiesImporter entityImporter = this.getFormScreen().getCsvEntityImporter();
          entityImporter.setDatabase(db);
          importReport = entityImporter.importEntities(csvReader, entityName, DatabaseAction.ADD);
        }
        finally
        {
          csvReader.close();
        }

        msg = new ScreenMessage("CSV UPLOAD SUCCESS: added " + importReport.getNrImported() + " rows", null,
            true);
        logger.debug("CSV UPLOAD SUCCESS: added " + importReport.getNrImported() + " 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);
    }
View Full Code Here

  public ScreenModel.Show handleRequest(Database db, MolgenisRequest request, OutputStream downloadStream)
      throws Exception
  {
    if (request.getString(FormModel.INPUT_SHOW) == null)
    {
      ScreenMessage msg = null;
      try
      {
        db.beginTx();
        xrefEntity.set(request);
        int updatedRows = db.add(xrefEntity);
        db.commitTx();
        msg = new ScreenMessage("ADD SUCCESS: affected " + updatedRows, null, true);
      }
      catch (Exception e)
      {
        msg = new ScreenMessage("ADD FAILED: " + e.getMessage(), null, false);
        e.printStackTrace();
        if (db.inTx()) db.rollbackTx();
      }
      ((FormController<?>) this.getController()).getModel().getMessages().add(msg);
    }
View Full Code Here

TOP

Related Classes of org.molgenis.framework.ui.ScreenMessage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.