private void addFilterStringtoGlobalWhere(List<Filter> filters, String currentPath) { currentPath=convertToUpperCaseIfRequired(currentPath); if (filters != null && !filters.isEmpty()) { for (int i = 0; i < filters.size(); i++) { globalWherePlaceHolder.add(filters.get(i).getExpression() .replaceAll("ROOT_ENTITY_SELECT_ALIAS", rootEntitySelectAlias) .replaceAll("ROOT_ENTITY_SELECT", rootEntitySelect).replaceAll("PATH_FROM_ROOT", currentPath)); } } }
public static String replaceDotIfRequired(String name) { if(name == null) return null; else return name.replaceAll("\\.", getSeparator()); }
public static String getSeparator() { initialize(); if(plainSqlMapping) return "_"; return "."; }
static String getPersistenceName(String fqEntityName, String elementName) { String persistenceName = null; if(isHdbcdsMode == null) isHdbcdsMode = CSNUtil.isHdbcdsMapping(); if(isHdbcdsMode) persistenceName = CSNUtil.getPersistenceName(fqEntityName, elementName); if (persistenceName == null) if (elementName != null) persistenceName = elementName; else persistenceName = replaceDotIfRequired(fqEntityName); return quoteIfRequired(persistenceName); }
int[] rowsAffected; String insertSqlStart = "INSERT INTO " + quoteIfRequired(nameSpace + getSeparator() + createEntityInfoList.get(0).getEntityName()); Map<String, Object> fcstd = generateFlatColumnStructure(createEntityInfoList.get(0).getColumns()); LinkedHashSet<String> columnNames = (LinkedHashSet<String>) CSNUtil.getProperties(nameSpace,
/** * Sets the specific columns to be returned. * @param selections Variable length array of column names * @return A builder object with which you can construct the rest of the CDS query */ public SelectColumnBuilder selectColumns(final String... selections){ String currentSelect = StringUtils.join(selections, COMMA); currentSelect = quoteIfRequired(currentSelect.replace(COMMA, quoteIfRequired(SPACE+COMMA+SPACE))); this.selectColumn = this.selectColumn == null ? currentSelect : this.selectColumn.concat(SPACE+COMMA+SPACE + currentSelect); return new SelectColumnBuilder(this); }
keyValues.add(e.getValue()); condition.append(quoteIfRequired(key) + " = ?"); rs = pstmt.executeQuery(); EntityData ed = convertResultSetToEntityData(rs, entityName); if(isPlainSqlMapping()) { ed = getEntityDataAfterCaseChange(ed, properties, entityName);
private void appendOrderByStringLimit(ReadEntityInfo eInfo) { StringBuffer localOrderBy = new StringBuffer(); for (String propName : eInfo.getOrderBySeq()) { OrderBy orderBy = eInfo.getOrderby().get(propName); if (orderBy != null) { localOrderBy.append(", "); String orderByAlias = (eInfo.getParententityName() != null&&!eInfo.getParententityName().isEmpty()) ? eInfo.getParententityName().replaceAll("ZZ", ".") + "." +eInfo.getEntityName()+ "."+propName : propName; if(isPlainSqlMapping() && (eInfo.getParententityName() != null&&!eInfo.getParententityName().isEmpty())) { orderByAlias = eInfo.getParententityName().replaceAll("ZZ", ".") + "." +eInfo.getEntityName() + "." + propName; } if(orderByAlias.startsWith(".")) { orderByAlias=orderByAlias.substring(1); } localOrderBy.append(orderByAlias); if (orderBy.isDescending()) { localOrderBy.append(" DESC"); } else { localOrderBy.append(" ASC"); } } } globalOrderByLimit.append(localOrderBy.toString()); }
persistenceName = elementName; else persistenceName = replaceDotIfRequired(fqEntityName);
private void appendCount(StringBuilder queryString) { queryString.append(SPACE).append("COUNT").append(LEFTBRACE+quoteIfRequired(count)+RIGHTBRACE); if(selectColumn != null){ queryString.append(COMMA).append(SPACE).append(selectColumn); } }
public List<Column> getColumnsFromListOfStrings(List<String> columns) { return columns.stream().map(s -> !s.contains(" AS ") ? new Column(s).setDbaliasName(convertToUpperCaseIfRequired(ALIASHLP + s)) : new Column((s.split(" AS ")[0]).replaceAll("ROOT_ENTITY_SELECT_ALIAS\\.", "").replaceAll("ROOT_ENTITY_SELECT\\.","").replaceAll("PATH_FROM_ROOT\\.", "")) .setDbaliasName(convertToUpperCaseIfRequired((s.split(" AS ")[1])).replaceAll("ROOT_ENTITY_SELECT_ALIAS\\.", "").replaceAll("ROOT_ENTITY_SELECT\\.","").replaceAll("PATH_FROM_ROOT\\.", "")) .setAliasName((s.split(" AS ")[1]).replaceAll("ROOT_ENTITY_SELECT_ALIAS\\.", "").replaceAll("ROOT_ENTITY_SELECT\\.","").replaceAll("PATH_FROM_ROOT\\.", ""))) .collect(Collectors.toList()); }
/** * Sets the column based on which the condition is created. * @param columnName Name of the column * @return A builder with which you can set the operator and operand of the condition */ public OperatorBuilder columnName(String columnName){ condition.append(quoteIfRequired(columnName)); return new OperatorBuilder(condition); }
public static boolean isPlainSqlMapping() { initialize(); return plainSqlMapping; }
private void prepareGroupByHavingClause() { ReadEntityInfo enInfo = qHelper.getEntityInfo(); if (!enInfo.getGroupBy().isEmpty()) { groupByHavingClause.append("GROUP BY ") .append(convertToUpperCaseIfRequired(enInfo.getGroupBy().stream().collect(Collectors.joining(", ")))); if (!enInfo.getHaving().isEmpty()) { groupByHavingClause.append(" HAVING "); groupByHavingClause.append(enInfo.getHaving().stream().collect(Collectors.joining(" AND "))); } } }
/** * Sets the column name based on which the result is ordered. * @param orderBy Name of the column for ordering the result * @param isDescending Indicates whether the result is in the descending order * @return A builder object with which you can construct the rest of the CDS query */ public OrderByBuilder orderBy(String orderBy, boolean isDescending){ if(orderBy != null && orderBy.length() > 0){ String orderByWithQoutes = quoteIfRequired(orderBy); String orderByStr = isDescending ? orderByWithQoutes.concat(SPACE).concat("DESC") : orderByWithQoutes.concat(SPACE).concat("ASC"); this.orderBy = this.orderBy == null ? orderByStr : this.orderBy.concat(COMMA + orderByStr); } return new OrderByBuilder(this); }
public static String quoteIfRequired(String sqlPart) { initialize(); if(plainSqlMapping) return sqlPart; return '"' + sqlPart + '"'; }
private void formWhereClauseforLimitOffset() { String pathtolastNavEnt = formPathtoLastNavEnInfo(); List<Column> lastNavEInfoKeyCols = getLastEntityNavigatedKeyColumns(); for (Column keyCol : lastNavEInfoKeyCols) { StringBuffer limitsql = new StringBuffer(""); limitsql.append(convertToUpperCaseIfRequired(pathtolastNavEnt + keyCol.getName())); limitsql.append(" IN ( "); limitsql.append(formInnerQueriesforLimitOffset(keyCol)); limitsql.append(" )"); globalWherePlaceHolder.add(limitsql.toString()); } }
/** * Sets the column based on which the condition is created. You can also apply a function to the specified column, such as * UCASE or LCASE. * @param columnName Name of the column * @param function An enum specifying the function to be applied to the column * @return A builder with which you can set the operator and operand of the condition */ public OperatorBuilder columnName(String columnName, Functions function){ String quotedColumnName = quoteIfRequired(columnName); condition.append(function.toString().concat(LEFTBRACE).concat(quotedColumnName).concat(RIGHTBRACE)); return new OperatorBuilder(condition); }
public static String convertToUpperCaseIfRequired(String sqlPart) { initialize(); if(plainSqlMapping) return sqlPart.toUpperCase(); return sqlPart; }