Skip to content
This repository has been archived by the owner on Aug 1, 2022. It is now read-only.

Commit

Permalink
Merge pull request #1012 from SAP/fix/few-issues
Browse files Browse the repository at this point in the history
Fixes Synonym existence check, exposing OData with parameters
  • Loading branch information
ThuF authored Jan 13, 2022
2 parents 152abc9 + d5d465e commit 5bba4a0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ public void execute(Connection connection, XSKDataStructureHDBSynonymModel synon
.escapeArtifactName(connection, value.getTarget().getObject(),
value.getTarget().getSchema());
try {
if (!SqlFactory.getNative(connection).exists(connection, value.getSynonymSchema(), key, DatabaseArtifactTypes.SYNONYM)) {
String synonymSchema = null != value.getSynonymSchema() ? value.getSynonymSchema() : connection.getMetaData().getUserName();
if (!SqlFactory.getNative(connection).exists(connection, synonymSchema, key, DatabaseArtifactTypes.SYNONYM)) {
ISqlDialect dialect = SqlFactory.deriveDialect(connection);
if (!(dialect.getClass().equals(HanaSqlDialect.class))) {
String errorMessage = String.format("Synonyms are not supported for %s !", dialect.getDatabaseName(connection));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -65,7 +64,6 @@ public class XSKODataParser implements IXSKODataParser {
private DataSource dataSource = (DataSource) StaticObjects.get(StaticObjects.DATASOURCE);

private static final List<String> METADATA_VIEW_TYPES = List.of(ISqlKeywords.METADATA_CALC_VIEW, ISqlKeywords.METADATA_VIEW);
private static final List<String> METADATA_CALC_ANALYTIC_TYPES = List.of(ISqlKeywords.METADATA_CALC_VIEW);
private static final List<String> METADATA_SYNONYM_TYPES = List.of(ISqlKeywords.METADATA_SYNONYM);
private static final List<String> METADATA_ENTITY_TYPES = List.of(ISqlKeywords.METADATA_TABLE, ISqlKeywords.METADATA_CALC_VIEW,
ISqlKeywords.METADATA_VIEW);
Expand Down Expand Up @@ -312,7 +310,7 @@ private void applyParametersToViewsCondition(XSKODataModel odataModel) throws SQ
if (entity.getParameterEntitySet() != null) {
String catalogObjectName = getCorrectCatalogObjectName(entity);

if (!checkIfEntityIsOfCalcAndAnalyticViewType(catalogObjectName)) {
if (!checkIfEntityIsOfViewType(catalogObjectName)) {
throw new XSKOData2TransformerException(String
.format("Parameters are not allowed for entity %s as it is not a calculation or analytical view.",
entity.getRepositoryObject().getCatalogObjectName()));
Expand Down Expand Up @@ -353,10 +351,6 @@ private boolean checkIfEntityIsOfViewType(String artifactName) throws SQLExcepti
return checkIfEntityIsFromAGivenDBType(artifactName, METADATA_VIEW_TYPES);
}

private boolean checkIfEntityIsOfCalcAndAnalyticViewType(String artifactName) throws SQLException {
return checkIfEntityIsFromAGivenDBType(artifactName, METADATA_CALC_ANALYTIC_TYPES);
}

private boolean checkIfEntityIsFromAGivenDBType(String artifactName, List<String> dbTypes) throws SQLException {
List<XSKDBArtifactModel> artifacts = getDBArtifactsByName(artifactName);
Optional<XSKDBArtifactModel> filteredArtifact = artifacts.stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,19 @@

public class XSKTableMetadataProvider implements ITableMetadataProvider {

private DataSource dataSource = (DataSource) StaticObjects.get(StaticObjects.DATASOURCE);
private final DataSource dataSource = (DataSource) StaticObjects.get(StaticObjects.DATASOURCE);

private static final Logger logger = LoggerFactory.getLogger(XSKTableMetadataProvider.class);

private DBMetadataUtil dbMetadataUtil = new DBMetadataUtil();
private final DBMetadataUtil dbMetadataUtil = new DBMetadataUtil();

private static final List<String> METADATA_ENTITY_TYPES = List.of(ISqlKeywords.METADATA_TABLE, ISqlKeywords.METADATA_CALC_VIEW,
ISqlKeywords.METADATA_VIEW);
private static final String PUBLIC_SCHEMA = "PUBLIC";

public PersistenceTableModel getPersistenceTableModel(ODataEntityDefinition oDataEntityDefinition) throws SQLException {

PersistenceTableModel tableMetadata = dbMetadataUtil.getTableMetadata(oDataEntityDefinition.getName(), Configuration.get("HANA_USERNAME"));
PersistenceTableModel tableMetadata = dbMetadataUtil.getTableMetadata(oDataEntityDefinition.getTable(), Configuration.get("HANA_USERNAME"));

if(METADATA_ENTITY_TYPES.contains(tableMetadata.getTableType())) {
return tableMetadata;
Expand Down

0 comments on commit 5bba4a0

Please sign in to comment.