コード例 #1
0
 public boolean delete() throws DBException {
   SQLDelete delete = new SQLDelete(TABLE_NAME);
   delete.addCondition("solution_id =", _solutionID);
   try {
     return (_dbManager.delete(delete) > 0);
   } catch (SQLException e) {
     LOGGER.fatal("Exception was thrown!", e);
     throw new DBException("Cannot delete solution info!", e);
   }
 }
コード例 #2
0
  public boolean delete() throws PlatformException, DBException {
    SQLDelete delete = new SQLDelete();
    // deleting data set
    delete.setTable(TABLE_NAME);
    delete.addCondition("attributeset_id =", _attributeSetID);
    int rows;
    try {
      rows = _dbManager.delete(delete);
    } catch (SQLException e) {
      LOGGER.fatal("", e);
      throw new DBException("Cannot delete!", e);
    }

    LOGGER.debug("rows deleted: " + rows);
    return (rows > 0);
  }
コード例 #3
0
 /**
  * Removes given tasks.
  *
  * @see salomon.engine.task.ITaskManager#removeTask(salomon.engine.task.ITask)
  */
 public boolean removeTask(ITask task) throws PlatformException {
   SQLDelete delete = new SQLDelete(TaskInfo.TABLE_NAME);
   IProject currProject = _managerEngine.getProjectManager().getCurrentProject();
   delete.addCondition("project_id =", currProject.getInfo().getId());
   delete.addCondition("task_id = ", task.getInfo().getId());
   boolean retVal = false;
   int deletedRows = 0;
   try {
     deletedRows = _dbManager.delete(delete);
     _dbManager.commit();
     // removing from list
     _tasks.remove(task);
     retVal = (deletedRows > 0);
   } catch (SQLException e) {
     _dbManager.rollback();
     LOGGER.fatal("", e);
     throw new PlatformException(e.getLocalizedMessage());
   }
   return retVal;
 }
コード例 #4
0
  public int save() throws PlatformException, DBException {
    // removing old attribute set with the same name
    SQLDelete delete = new SQLDelete();
    delete.setTable(TABLE_NAME);
    delete.addCondition("attributeset_name = ", _name);
    int rows;
    try {
      rows = _dbManager.delete(delete);
    } catch (SQLException e) {
      LOGGER.fatal("!", e);
      throw new DBException("Cannot delete!", e);
    }
    LOGGER.debug("rows deleted: " + rows);

    // saving header
    SQLUpdate update = new SQLUpdate(TABLE_NAME);
    if (_name != null) {
      update.addValue("attributeset_name", _name);
    }
    if (_info != null) {
      update.addValue("attributeset_info", _info);
    }

    if (_attributeSetID == 0) {
      update.addValue("c_date", new Date(System.currentTimeMillis()));
    }

    update.addValue("solution_id", _solutionID);
    update.addValue("lm_date", new Date(System.currentTimeMillis()));

    try {
      _attributeSetID =
          _dbManager.insertOrUpdate(update, "attributeset_id", _attributeSetID, GEN_NAME);
    } catch (SQLException e) {
      LOGGER.fatal("Exception was thrown!", e);
      throw new DBException("Cannot save!", e);
    }

    try {
      // saving items
      for (IAttributeDescription description : _descriptions) {
        // FIXME: why it can be null???
        if (description != null) {
          SQLInsert insert = new SQLInsert(ITEMS_TABLE_NAME);
          insert.addValue("attributeset_id", _attributeSetID);
          insert.addValue("attribute_name", description.getName());
          insert.addValue("attribute_type", description.getType().getDBString());
          insert.addValue("table_name", description.getColumn().getTable().getName());
          insert.addValue("column_name", description.getColumn().getName());
          insert.addValue("is_output", description.isOutput() ? "Y" : "N");
          // FIXME: workaround!
          if (description instanceof EnumAttributeDescription) {
            insert.addValue(
                "attribute_value", ((EnumAttributeDescription) description).valuesToString());
          }

          LOGGER.debug("insert: " + insert.getQuery());
          _dbManager.insert(insert, "attributeset_item_id");
        }
      }
    } catch (SQLException e) {
      LOGGER.fatal("Exception was thrown!", e);
      throw new DBException("Cannot save!", e);
    }

    return _attributeSetID;
  }