diff --git a/modules/engines/engine-hdb/src/main/java/com/sap/xsk/hdb/ds/processors/synonym/HDBSynonymCreateProcessor.java b/modules/engines/engine-hdb/src/main/java/com/sap/xsk/hdb/ds/processors/synonym/HDBSynonymCreateProcessor.java index 145c1b446..3247956df 100644 --- a/modules/engines/engine-hdb/src/main/java/com/sap/xsk/hdb/ds/processors/synonym/HDBSynonymCreateProcessor.java +++ b/modules/engines/engine-hdb/src/main/java/com/sap/xsk/hdb/ds/processors/synonym/HDBSynonymCreateProcessor.java @@ -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)); diff --git a/modules/engines/engine-xsodata/src/main/java/com/sap/xsk/xsodata/ds/service/XSKODataParser.java b/modules/engines/engine-xsodata/src/main/java/com/sap/xsk/xsodata/ds/service/XSKODataParser.java index a60244abc..3df88b238 100644 --- a/modules/engines/engine-xsodata/src/main/java/com/sap/xsk/xsodata/ds/service/XSKODataParser.java +++ b/modules/engines/engine-xsodata/src/main/java/com/sap/xsk/xsodata/ds/service/XSKODataParser.java @@ -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; @@ -65,7 +64,6 @@ public class XSKODataParser implements IXSKODataParser { private DataSource dataSource = (DataSource) StaticObjects.get(StaticObjects.DATASOURCE); private static final List METADATA_VIEW_TYPES = List.of(ISqlKeywords.METADATA_CALC_VIEW, ISqlKeywords.METADATA_VIEW); - private static final List METADATA_CALC_ANALYTIC_TYPES = List.of(ISqlKeywords.METADATA_CALC_VIEW); private static final List METADATA_SYNONYM_TYPES = List.of(ISqlKeywords.METADATA_SYNONYM); private static final List METADATA_ENTITY_TYPES = List.of(ISqlKeywords.METADATA_TABLE, ISqlKeywords.METADATA_CALC_VIEW, ISqlKeywords.METADATA_VIEW); @@ -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())); @@ -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 dbTypes) throws SQLException { List artifacts = getDBArtifactsByName(artifactName); Optional filteredArtifact = artifacts.stream() diff --git a/modules/engines/engine-xsodata/src/main/java/com/sap/xsk/xsodata/ds/service/XSKTableMetadataProvider.java b/modules/engines/engine-xsodata/src/main/java/com/sap/xsk/xsodata/ds/service/XSKTableMetadataProvider.java index 5a281e7f3..e279d8662 100644 --- a/modules/engines/engine-xsodata/src/main/java/com/sap/xsk/xsodata/ds/service/XSKTableMetadataProvider.java +++ b/modules/engines/engine-xsodata/src/main/java/com/sap/xsk/xsodata/ds/service/XSKTableMetadataProvider.java @@ -28,11 +28,11 @@ 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 METADATA_ENTITY_TYPES = List.of(ISqlKeywords.METADATA_TABLE, ISqlKeywords.METADATA_CALC_VIEW, ISqlKeywords.METADATA_VIEW); @@ -40,7 +40,7 @@ public class XSKTableMetadataProvider implements ITableMetadataProvider { 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;