Exemple #1
0
  public JsonType(JEVisType jtype) {
    try {
      name = jtype.getName();
      primitiveType = jtype.getPrimitiveType();
      GUIDisplayType = jtype.getGUIDisplayType();
      description = jtype.getDescription();
      GUIPosition = jtype.getGUIPosition();

    } catch (JEVisException ex) {
      Logger.getLogger(JsonType.class.getName()).log(Level.SEVERE, null, ex);
    }
  }
  public boolean delete(JEVisClass jclass) throws JEVisException {
    String sql = "delete from " + TABLE + " where " + COLUMN_NAME + "=?";
    PreparedStatement ps = null;
    ResultSet rs = null;
    _ds.addQuery("ClassTable.delete");

    try {
      for (JEVisType type : jclass.getTypes()) {
        if (jclass.getInheritance() != null) {
          if (jclass.getInheritance().getType(type.getName()) == null) {
            _ds.getTypeTable().detele(type);
          }
        } else {
          _ds.getTypeTable().detele(type);
        }
      }

      for (JEVisClassRelationship rel : jclass.getRelationships()) {
        _ds.getClassRelationshipTable().delete(rel);
      }

      ps = _connection.prepareStatement(sql);
      ps.setString(1, jclass.getName());

      System.out.println("delete.class: " + ps.toString());
      int count = ps.executeUpdate();

      if (count == 1) {
        SimpleClassCache.getInstance().remove(jclass.getName());

        return true;
      } else {
        return false;
      }

    } catch (Exception ex) {
      throw new JEVisException("Error while deleting Class: " + ex, 2342763);
    } finally {
      if (ps != null) {
        try {
          ps.close();
        } catch (SQLException ex) {
          logger.warn("cound not close Prepared statement: {}", ex);
        }
      }
    }
  }