���ҵ��idɾ����ݼ�¼
@param requestParamMap �ύ����
@param tableName �����
@return
@throws Exception
174165
public Integer delInfoByBizIdService(String bizId,String tableName,String bizCol){
		
		Integer filterViewRet=filterView(tableName,new HashMap(),bizId,bizCol,TYPE_DEL_BIZID);
		if(filterViewRet!=null && filterViewRet>0){
			return filterViewRet;
		}
		
		Integer retStatus=getInnerDao().delObjByBizId(tableName,bizId,bizCol);
		return retStatus;
	}
592575
public Integer updateInfoServiceInner(String id,Map requestParamMap,String tableName,String cusCondition,String cusSetStr,String modelName) throws Exception{
		String tempKeyId=calcuIdKey();
		//add 20170829 ninghao
		Integer filterViewRet=filterView(tableName,requestParamMap,id,tempKeyId,TYPE_UPDATE_ID);
		if(filterViewRet!=null && filterViewRet>0){
			return filterViewRet;
		}
		String tempDbType=calcuDbType();
		//add 20170627 ninghao
		filterParam(tableName,requestParamMap);
		
		//String id=(String) requestParamMap.get(defaultId);
		String condition=tempKeyId+"=?";
		if(modelName==null || "".equals(modelName)){
			modelName=tableName;
		}
		Map modelEntryMap=getModelEntryMap(requestParamMap,tableName,modelName,dbName);
		
		List placeList=new ArrayList();
		//add 201807 ning
		//Map requestParamMap=changeCase4Param(requestParamMap0);
		
		String setStr=createUpdateInStr(requestParamMap,modelEntryMap,placeList);
		String nCondition=cusCondition;
		String nSetStr=setStr;
		
		//add 201806 ninghao
		if(condition!=null && !"".equals(condition)){
			nCondition=Cutil.jn(" and ", condition,cusCondition);
		}
		if(cusSetStr!=null && !"".equals(cusSetStr)){
			nSetStr=Cutil.jn(",", setStr,cusSetStr);
		}		
		
		
		placeList.add(id);
		Integer retStatus=getInnerDao().updateObjByCondition(tableName, nCondition, nSetStr,placeList.toArray());
		return retStatus;
	}
463444
public int deleteByTableName(String tableName) throws SQLException {
		DeleteBuilder<MetadataReference, Void> db = deleteBuilder();
		db.where().eq(MetadataReference.COLUMN_TABLE_NAME, tableName);
		PreparedDelete<MetadataReference> deleteQuery = db.prepare();
		int deleted = delete(deleteQuery);
		return deleted;
	}
631415
public int deleteByTableName(String tableName) throws SQLException {
		DeleteBuilder<DataColumns, TableColumnKey> db = deleteBuilder();
		db.where().eq(DataColumns.COLUMN_TABLE_NAME, tableName);
		PreparedDelete<DataColumns> deleteQuery = db.prepare();
		int deleted = delete(deleteQuery);
		return deleted;
	}
677002
public void execute() throws Exception {
        ActionRequest request = requestBuilder.request();

        //todo: maby change to instanceof multi?
        if(requestBuilder instanceof JoinRequestBuilder){
            executeJoinRequestAndSendResponse();
        }
		else if (request instanceof SearchRequest) {
			client.search((SearchRequest) request, new RestStatusToXContentListener<SearchResponse>(channel));
		} else if (requestBuilder instanceof SqlElasticDeleteByQueryRequestBuilder) {
            throw new UnsupportedOperationException("currently not support delete on elastic 2.0.0");
        }
        else if(request instanceof GetIndexRequest) {
            this.requestBuilder.getBuilder().execute( new GetIndexRequestRestListener(channel, (GetIndexRequest) request));
        }


		else {
			throw new Exception(String.format("Unsupported ActionRequest provided: %s", request.getClass().getName()));
		}
	}
68664
@Override
    public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body) throws TemplateException, IOException {
        if (params.size() > 1)
        {
            String message = "This directive doesn't allow multiple parameters.";
            errors.add(message);
            throw new TemplateModelException(message);
        }
        if (params.size() == 1 && !((Map.Entry)params.entrySet().toArray()[0]).getKey().equals("sql")) {
            String message = "This directive only takes 'sql', which you specify the type of engine, ie mysql, postgres, etc.";
            errors.add(message);
            throw new TemplateModelException(message);
        }
        Object sqlParam = params.get("sql");
        String engine = "mysql";
        if (sqlParam == null) { } else
        if (sqlParam instanceof TemplateScalarModel)
        {
            TemplateScalarModel engineParam = (TemplateScalarModel) sqlParam;
            engine = engineParam.getAsString();
        } else {
            String message = "This directive only accepts string values for 'sql'.";
            errors.add(message);
            throw new TemplateModelException(message);
        }
        if (loopVars.length != 0) throw new TemplateModelException("This directive doesn't allow loop variables.");
        limitExists[0] = true;
        int limit = freemarkerSQLDataReportConnector.getPageLimit();
        int offset = freemarkerSQLDataReportConnector.getPage() * limit;
        if (engine.equalsIgnoreCase("mysql") || engine.equalsIgnoreCase("postgres"))
        {
            env.getOut().write(" LIMIT " + limit + " OFFSET " + offset + " ");
        } else
        {
            String message = "Unknown SQL Engine " + engine + ".";
            errors.add(message);
            throw new TemplateModelException(message);
        }
    }
166327
public static String getParameter(final Request request, final String parameterName)
	{
		String parameterValue = request.getRequestParameters().getParameterValue(parameterName)
			.toString();
		if ((parameterValue == null) || parameterValue.isEmpty())
		{
			parameterValue = request.getPostParameters().getParameterValue(parameterName)
				.toString();
		}
		if ((parameterValue == null) || parameterValue.isEmpty())
		{
			parameterValue = request.getQueryParameters().getParameterValue(parameterName)
				.toString();
		}
		if ((parameterValue == null) || parameterValue.isEmpty())
		{
			parameterValue = request.getRequestParameters().getParameterValue(parameterName)
				.toString();
		}
		return parameterValue;
	}
985626
@Override
	public void bindParams(final PreparedStatement preparedStatement) throws SQLException {
		Parameter[] bindParameters = getBindParameters();

		Set<String> matchParams = new HashSet<>();
		int parameterIndex = 1;
		for (Parameter bindParameter : bindParameters) {
			Parameter parameter = getSqlFilterManager().doParameter(bindParameter);
			parameterIndex = parameter.setParameter(preparedStatement, parameterIndex, parameterMapperManager);
			matchParams.add(parameter.getParameterName());
		}
		// SQL上のバインドパラメータ群（bindNames）に対応する値がすべて設定されているかどうかをチェックする
		if (!matchParams.containsAll(bindNames)) {
			Set<String> missMatchParams = new LinkedHashSet<>(bindNames);
			missMatchParams.removeAll(matchParams);
			throw new ParameterNotFoundRuntimeException("Parameter " + missMatchParams.toString() + " is not bound.");
		}
	}
428988
public List<Entity> findAll(String tableName) throws SQLException {
		return findAll(Entity.create(tableName));
	}
204142
public CompletableFuture<Void> createTable(String tableName) {
        log.debug("create table called for table: {}", tableName);

        return Futures.toVoid(withRetries(() -> segmentHelper.createTableSegment(tableName, authToken.get(), RequestTag.NON_EXISTENT_ID),
                () -> String.format("create table: %s", tableName)))
                .whenCompleteAsync((r, e) -> {
                    if (e != null) {
                        log.warn("create table {} threw exception", tableName, e);
                    } else {
                        log.debug("table {} created successfully", tableName);
                    }
                }, executor);
    }
1092521
@InternalApi
  public ReadRowsRequest toProto(RequestContext requestContext) {
    String tableName =
        NameUtil.formatTableName(
            requestContext.getProjectId(), requestContext.getInstanceId(), tableId);

    return builder
        .setTableName(tableName)
        .setAppProfileId(requestContext.getAppProfileId())
        .build();
  }
849467
private Map<String, Object> parseRequestParameters(String requestParameters) {

        Map<String, Object> parameterMap;
        if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(requestParameters)) {
            parameterMap = new HashMap<String, Object>();
            String[] params = requestParameters.split("&");
            for (int i = 0; i < params.length; i++) {
                int position = params[i].indexOf("=");
                if (position >= 0) {
                    String key = params[i].substring(0, position);
                    String value = params[i].substring(position + 1);
                    if (value.contains(",")) {
                        parameterMap.put(key, value.split(","));
                    } else {
                        parameterMap.put(key, value);
                    }
                }
            }
        } else {
            parameterMap = Collections.<String, Object> emptyMap();
        }
        return parameterMap;
    }
1147143
@Override
  public final void process(final Map<String, Object> pAddParam,
    final IRequestData pRequestData) throws Exception {
    String taxDestIdStr = pRequestData.getParameter("taxDestId");
    Long taxDestId = Long.parseLong(taxDestIdStr);
    String itemIdStr = pRequestData.getParameter("itemId");
    Long itemId = Long.parseLong(itemIdStr);
    String nmEnt = pRequestData.getParameter("nmEnt");
    String destTaxItemLnNm;
    String itemNm;
    if (SalesInvoiceServiceLine.class.getSimpleName().equals(nmEnt)) {
      destTaxItemLnNm = DestTaxServSelLn.class.getSimpleName().toUpperCase();
      itemNm = ServiceToSale.class.getSimpleName().toUpperCase();
    } else if (PurchaseInvoiceServiceLine.class.getSimpleName().equals(nmEnt)) {
      destTaxItemLnNm = DestTaxServPurchLn.class.getSimpleName().toUpperCase();
      itemNm = ServicePurchased.class.getSimpleName().toUpperCase();
    } else if (PurchaseInvoiceLine.class.getSimpleName().equals(nmEnt)
      || SalesInvoiceLine.class.getSimpleName().equals(nmEnt)
        || SalesReturnLine.class.getSimpleName().equals(nmEnt)
          || PurchaseReturnLine.class.getSimpleName().equals(nmEnt)) {
      destTaxItemLnNm = DestTaxGoodsLn.class.getSimpleName().toUpperCase();
      itemNm = InvItem.class.getSimpleName().toUpperCase();
    } else {
      throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER,
        "Wrong line type " + nmEnt);
    }
    String query = lazyGetQueryRevealTaxCat();
    query = query.replace(":ITEMNM", itemNm);
    query = query.replace(":DESTTAXITEMLNNM", destTaxItemLnNm);
    query = query.replace(":ITEMID", itemId.toString());
    query = query.replace(":TAXDESTID", taxDestId.toString());
    InvItemTaxCategory taxCategory = new InvItemTaxCategory();
    IRecordSet<RS> recordSet = null;
    AccSettings as = (AccSettings) pAddParam.get("accSet");
    RoundingMode rounding = as.getSalTaxRoundMode();
    try {
      this.srvDatabase.setIsAutocommit(false);
      this.srvDatabase.setTransactionIsolation(ISrvDatabase
        .TRANSACTION_READ_UNCOMMITTED);
      this.srvDatabase.beginTransaction();
      recordSet = getSrvDatabase().retrieveRecords(query);
      if (recordSet.moveToFirst()) {
        Long dtlId = recordSet.getLong("DTLID");
        Integer tdrm = null;
        Long tcId = recordSet.getLong("DTCID");
        String tcd = null;
        String tcn = null;
        Double tcRate = null;
        if (dtlId == null) {
          tcn = recordSet.getString("OTCNAME");
          tcd = recordSet.getString("OTCDESCR");
          tcId = recordSet.getLong("OTCID");
          tcRate = recordSet.getDouble("OTCRATE");
        } else if (tcId != null) {
          tdrm = recordSet.getInteger("DTRM");
          tcd = recordSet.getString("DTCDESCR");
          tcn = recordSet.getString("DTCNAME");
          tcRate = recordSet.getDouble("DTCRATE");
        }
        taxCategory.setItsId(tcId);
        taxCategory.setItsName(tcn);
        taxCategory.setTaxesDescription(tcd);
        if (tdrm != null) {
          rounding = RoundingMode.class.getEnumConstants()[tdrm];
        }
        if (tcRate != null) {
          taxCategory.setAggrOnlyPercent(BigDecimal.valueOf(tcRate));
        }
        if (recordSet.moveToNext()) {
          throw new ExceptionWithCode(ExceptionWithCode.SOMETHING_WRONG,
    "There are multiply tax category results for item id/tax dest.id/entity: "
      + itemId + "/" + taxDestId + "/" + nmEnt);
        }
      }
      this.srvDatabase.commitTransaction();
    } catch (Exception ex) {
      this.srvDatabase.rollBackTransaction();
      throw ex;
    } finally {
      if (recordSet != null) {
        recordSet.close();
      }
      this.srvDatabase.releaseResources();
    }
    pRequestData.setAttribute("taxRounding", rounding);
    pRequestData.setAttribute("taxCategory", taxCategory);
  }
391333
@Override
    public java.util.concurrent.Future<UpdateTableResult> updateTableAsync(String tableName, ProvisionedThroughput provisionedThroughput) {

        return updateTableAsync(new UpdateTableRequest().withTableName(tableName).withProvisionedThroughput(provisionedThroughput));
    }
140580
public Integer createInfoServiceInner(Map requestParamMap0,String tableName,String cusCol,String cusValue,String modelName) throws Exception{
		//add 201902 ning
		Map requestParamMap=new CaseInsensitiveKeyMap();
		if(requestParamMap0!=null){
			requestParamMap.putAll(requestParamMap0);
		}
		//add 20170829 ninghao
		Integer filterViewRet=filterView(tableName,requestParamMap,"","",TYPE_INSERT);
		if(filterViewRet!=null && filterViewRet>0){
			return filterViewRet;
		}
		String tempDbType=calcuDbType();
		//add 20170627 ninghao
		filterParam(tableName,requestParamMap);
		
		//add 201807 ning
		//Map requestParamMap=changeCase4Param(requestParamMap0);
		
		
		boolean autoFlag=false;
		if(modelName==null || "".equals(modelName)){
			modelName=tableName;
		}
		String tempKeyId=calcuIdKey();
		Map modelEntryMap=getModelEntryMap(requestParamMap,tableName,modelName,dbName);
		MicroDbModelEntry idEntry=(MicroDbModelEntry) modelEntryMap.get(tempKeyId);
		
		String id=(String) requestParamMap.get(tempKeyId);
		
		if(id==null || "".equals(id)){
			requestParamMap.put(tempKeyId, null);
			
			if(idEntry!=null && idEntry.colType.equals(String.class)){
				id=UUID.randomUUID().toString();
				requestParamMap.put(tempKeyId, id);	
			}else if(idEntry==null){//add 201805 ning support nonid
				autoFlag=false;
			}else{
				autoFlag=true;
			}
		
		}

		String cols=createInsertBeforeStr4ModelEntry(requestParamMap,modelEntryMap);

		List placeList=new ArrayList();
		String values=createInsertValueStr4ModelEntry(requestParamMap,modelEntryMap,placeList);
		String ncols=Cutil.jn(",", cols,cusCol);
		String nvalues=Cutil.jn(",", values,cusValue);
		Integer retStatus=0;
		if(autoFlag==false){
			retStatus=getInnerDao().insertObj(tableName, ncols, nvalues,placeList.toArray());
		}else{
			KeyHolder keyHolder=new GeneratedKeyHolder(); 
			retStatus=getInnerDao().insertObj(tableName, ncols, nvalues,placeList.toArray(),keyHolder,tempKeyId);
			if(keyHolder!=null){
/*				List keyList=keyHolder.getKeyList();
				if(keyList!=null && keyList.size()>0){
					Map keyMap=(Map) keyList.get(0);
					Object retId=keyMap.get(defaultId);
					if(retId!=null){
						requestParamMap.put(defaultId, retId.toString());
					}
				}*/
				requestParamMap0.put(tempKeyId, keyHolder.getKey().toString());
			}
		}
		//add 201807
		//requestParamMap0.put(calcuDbOutCaseId(), requestParamMap.get(tempKeyId));

		return retStatus;
	}
487539
public Object invoke(Object conn, Object requestData) throws AdapterException {
        try {
            DatabaseAccess dbAccess = (DatabaseAccess)conn;
            if (requestData == null)
                throw new AdapterException("Missing SQL Query");
            String query = (String) requestData;
            QueryType queryType = getQueryType();

            Object queryParams = getQueryParameters();
            if (queryParams instanceof List<?>) {
                if (queryType == QueryType.Select)
                    return dbAccess.runSelect(query, ((List<?>) queryParams).toArray());
                else if (queryType == QueryType.Update) {
                    Integer ret = new Integer(dbAccess.runUpdate(query, ((List<?>)queryParams).toArray()));
                    dbAccess.commit();
                    return ret;
                }
                else
                    throw new AdapterException("Unsupported query type: " + queryType);
            }
            else {
                if (queryType == QueryType.Select)
                    return dbAccess.runSelect(query, queryParams);
                else if (queryType == QueryType.Update) {
                    Integer ret = new Integer(dbAccess.runUpdate(query, queryParams));
                    dbAccess.commit();
                    return ret;
                }
                else
                    throw new AdapterException("Unsupported query type: " + queryType);
            }
        }
        catch (SQLException ex) {
            AdapterException adapEx = new AdapterException(-1, ex.getMessage(), ex);
            if (isRetryable(ex))
              adapEx.setRetryable(true);
            throw adapEx;
        }
        catch (Exception ex) {
            throw new AdapterException(-1, ex.getMessage() , ex);
        }
    }
322769
@When("^I query the database with '(.+?)'$")
    public void selectData(String query) throws Exception {
        Statement myStatement = null;
        //postgres table
        List<String> sqlTable = new ArrayList<String>();
        List<String> sqlTableAux = new ArrayList<String>();
        Connection myConnection = this.commonspec.getConnection();
        java.sql.ResultSet rs = null;
        try {
            myStatement = myConnection.createStatement();
            rs = myStatement.executeQuery(query);
            //column names
            ResultSetMetaData resultSetMetaData = rs.getMetaData();
            int count = resultSetMetaData.getColumnCount();
            for (int i = 1; i <= count; i++) {
                sqlTable.add(resultSetMetaData.getColumnName(i).toString());
            }
            //takes column names and column count
            while (rs.next()) {
                for (int i = 1; i <= count; i++) {
                    //aux list without column names
                    sqlTableAux.add(rs.getObject(i).toString());
                }
            }
            sqlTable.addAll(sqlTableAux);

            //sends raws to environment variable
            for (int i = 0; i < sqlTable.size(); i++) {
                ThreadProperty.set("queryresponse" + i, sqlTable.get(i));
            }
            ThreadProperty.remove("queryresponse" + sqlTable.size());
            rs.close();
            myStatement.close();
        } catch (Exception e) {
            e.printStackTrace();
            Assertions.assertThat(rs).as("There are no response from SELECT").isNotNull();
        }
    }