示例#1
0
 public int execute() throws Exception {
   if (QueryInfo.get__dbInfo() == null) {
     throw new Exception("No choosed database");
   }
   String tableName = tree.getChild(2).getText();
   tableInfo = DictCenterManager.findTableWithName(QueryInfo.get__dbInfo(), tableName);
   int ret = 0;
   if (!chooseAll) {
     table = DataTableManager.loadTable(tableInfo);
     int len = table.getRecords().size();
     for (cur = 0; cur < len; cur++) {
       visitor.visitTree((sqlParser.ExprContext) tree.getChild(3).getChild(1));
       if (((ValueTree) tree.getChild(3).getChild(1)).getValue().getValue().equals(true)) {
         ret++;
       } else {
         resTable.getRecords().add(table.getRecords().get(cur));
       }
     }
     table.setRecords(resTable.getRecords());
   } else {
     ret = table.getRecords().size();
     table.getRecords().clear();
   }
   DataTableManager.storeTable(table);
   return ret;
 }
示例#2
0
 public DeleteConsole() {
   tree = null;
   table = new DataTable();
   tableInfo = new DictTableInfo();
   chooseAll = true;
   cur = 0;
   resTable = new DataTable();
   List<DataRecord> __tmp = new ArrayList<DataRecord>();
   resTable.setRecords(__tmp);
   visitor = new TreeVisitor(this);
 }
示例#3
0
 public ValueBase getColValue(String Column) throws Exception {
   if (Column.indexOf(".") == -1) {
     int i;
     for (i = 0; i < table.getColumns().size(); i++) {
       if (table.getColumns().get(i).getColumnName().equals(Column)) {
         ValueBase ret = table.getRecords().get(cur).getValues().get(i);
         if (ret.getValue() instanceof String) {
           ret.setType(TypeDataEnum.STRING);
         } else if (ret.getValue() instanceof Double) {
           ret.setType(TypeDataEnum.DOUBLE);
         } else if (ret.getValue() instanceof Integer) {
           ret.setType(TypeDataEnum.INT);
         }
         return ret;
       }
     }
   } else {
     String[] __tmp = Column.split("\\.");
     if (!__tmp[0].equals(tableInfo.getTableName())) {
       throw new Exception("Forbidden to access table " + __tmp[0]);
     }
     int i;
     for (i = 0; i < table.getColumns().size(); i++) {
       if (table.getColumns().get(i).getColumnName().equals(__tmp[1])) {
         ValueBase ret = table.getRecords().get(cur).getValues().get(i);
         if (ret.getValue() instanceof String) {
           ret.setType(TypeDataEnum.STRING);
         } else if (ret.getValue() instanceof Double) {
           ret.setType(TypeDataEnum.DOUBLE);
         } else if (ret.getValue() instanceof Integer) {
           ret.setType(TypeDataEnum.INT);
         }
         return ret;
       }
     }
   }
   throw new Exception("Fail to find column: " + Column);
 }