Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ object DatasourceClientConfig {
var METADATA_SERVICE_MODULE: CommonVars[String] =
CommonVars.apply("linkis.server.mdq.module.name", "metadataQuery")

var METADATA_OLD_SERVICE_MODULE: CommonVars[String] =
CommonVars.apply("linkis.server.mdq.module.name", "metadatamanager")

var DATA_SOURCE_SERVICE_MODULE: CommonVars[String] =
CommonVars.apply("linkis.server.dsm.module.name", "data-source-manager")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ object DataSourceTestConnectAction {
}

def build(): DataSourceTestConnectAction = {
if (dataSourceId == null) {
if (dataSourceId <= 0) {
throw new DataSourceClientBuilderException(DATASOURCEID_NEEDED.getErrorDesc)
}
if (version == null) throw new DataSourceClientBuilderException(VERSION_NEEDED.getErrorDesc)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ object DeleteDataSourceAction {

def builder(): DeleteDataSourceAction = {
if (user == null) throw new DataSourceClientBuilderException(USER_NEEDED.getErrorDesc)
if (dataSourceId == null) {
if (dataSourceId <= 0) {
throw new DataSourceClientBuilderException(DATASOURCEID_NEEDED.getErrorDesc)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ object ExpireDataSourceAction {
}

def build(): ExpireDataSourceAction = {
if (dataSourceId == null) {
if (dataSourceId <= 0) {
throw new DataSourceClientBuilderException(DATASOURCEID_NEEDED.getErrorDesc)
}
if (user == null) throw new DataSourceClientBuilderException(USER_NEEDED.getErrorDesc)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ object GetConnectParamsByDataSourceIdAction {
}

def build(): GetConnectParamsByDataSourceIdAction = {
if (dataSourceId == null) {
if (dataSourceId <= 0) {
throw new DataSourceClientBuilderException(DATASOURCEID_NEEDED.getErrorDesc)
}
if (user == null) throw new DataSourceClientBuilderException(USER_NEEDED.getErrorDesc)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ object GetDataSourceVersionsAction {
}

def build(): GetDataSourceVersionsAction = {
if (dataSourceId == null) {
if (dataSourceId <= 0) {
throw new DataSourceClientBuilderException(DATASOURCEID_NEEDED.getErrorDesc)
}
if (user == null) throw new DataSourceClientBuilderException(USER_NEEDED.getErrorDesc)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ object GetInfoByDataSourceIdAction {
}

def build(): GetInfoByDataSourceIdAction = {
if (dataSourceId == null) {
if (dataSourceId <= 0) {
throw new DataSourceClientBuilderException(DATASOURCEID_NEEDED.getErrorDesc)
}
if (system == null) throw new DataSourceClientBuilderException(SYSTEM_NEEDED.getErrorDesc)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,36 @@

package org.apache.linkis.datasource.client.request

import org.apache.linkis.datasource.client.config.DatasourceClientConfig.METADATA_SERVICE_MODULE
import org.apache.linkis.datasource.client.config.DatasourceClientConfig.{
METADATA_OLD_SERVICE_MODULE,
METADATA_SERVICE_MODULE
}
import org.apache.linkis.datasource.client.errorcode.DatasourceClientErrorCodeSummary._
import org.apache.linkis.datasource.client.exception.DataSourceClientBuilderException
import org.apache.linkis.httpclient.request.GetAction

class MetadataGetColumnsAction extends GetAction with DataSourceAction {
import org.apache.commons.lang3.StringUtils

class MetadataGetColumnsAction extends GetAction with DataSourceAction {
private var dataSourceId: Long = _
private var dataSourceName: String = _

private var database: String = _
private var table: String = _

override def suffixURLs: Array[String] = Array(METADATA_SERVICE_MODULE.getValue, "getColumns")
override def suffixURLs: Array[String] = if (StringUtils.isNotBlank(dataSourceName)) {
Array(METADATA_SERVICE_MODULE.getValue, "getColumns")
} else {
Array(
METADATA_OLD_SERVICE_MODULE.getValue,
"columns",
dataSourceId.toString,
"db",
database,
"table",
table
)
}

private var user: String = _

Expand All @@ -42,6 +59,7 @@ object MetadataGetColumnsAction {
def builder(): Builder = new Builder

class Builder private[MetadataGetColumnsAction] () {
private var dataSourceId: Long = _
private var dataSourceName: String = _
private var database: String = _
private var table: String = _
Expand All @@ -53,6 +71,20 @@ object MetadataGetColumnsAction {
this
}

/**
* get value form dataSourceId is deprecated, suggest to use dataSourceName
*
* @param dataSourceId
* datasourceId
* @return
* builder
*/
@deprecated
def setDataSourceId(dataSourceId: Long): Builder = {
this.dataSourceId = dataSourceId
this
}

def setDataSourceName(dataSourceName: String): Builder = {
this.dataSourceName = dataSourceName
this
Expand All @@ -74,7 +106,7 @@ object MetadataGetColumnsAction {
}

def build(): MetadataGetColumnsAction = {
if (dataSourceName == null) {
if (dataSourceName == null && dataSourceId <= 0) {
throw new DataSourceClientBuilderException(DATASOURCENAME_NEEDED.getErrorDesc)
}
if (database == null) throw new DataSourceClientBuilderException(DATABASE_NEEDED.getErrorDesc)
Expand All @@ -83,6 +115,7 @@ object MetadataGetColumnsAction {
if (user == null) throw new DataSourceClientBuilderException(USER_NEEDED.getErrorDesc)

val metadataGetColumnsAction = new MetadataGetColumnsAction
metadataGetColumnsAction.dataSourceId = this.dataSourceId
metadataGetColumnsAction.dataSourceName = this.dataSourceName
metadataGetColumnsAction.database = this.database
metadataGetColumnsAction.table = this.table
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,26 @@

package org.apache.linkis.datasource.client.request

import org.apache.linkis.datasource.client.config.DatasourceClientConfig.METADATA_SERVICE_MODULE
import org.apache.linkis.datasource.client.config.DatasourceClientConfig.{
METADATA_OLD_SERVICE_MODULE,
METADATA_SERVICE_MODULE
}
import org.apache.linkis.datasource.client.errorcode.DatasourceClientErrorCodeSummary._
import org.apache.linkis.datasource.client.exception.DataSourceClientBuilderException
import org.apache.linkis.httpclient.request.GetAction

import org.apache.commons.lang3.StringUtils

class MetadataGetDatabasesAction extends GetAction with DataSourceAction {

private var dataSourceId: Long = _
private var dataSourceName: String = _

override def suffixURLs: Array[String] = Array(METADATA_SERVICE_MODULE.getValue, "getDatabases")
override def suffixURLs: Array[String] = if (StringUtils.isNotBlank(dataSourceName)) {
Array(METADATA_SERVICE_MODULE.getValue, "getDatabases")
} else {
Array(METADATA_OLD_SERVICE_MODULE.getValue, "dbs", dataSourceId.toString)
}

private var user: String = _

Expand All @@ -39,6 +49,7 @@ object MetadataGetDatabasesAction {
def builder(): Builder = new Builder

class Builder private[MetadataGetDatabasesAction] () {
private var dataSourceId: Long = _
private var dataSourceName: String = _
private var system: String = _
private var user: String = _
Expand All @@ -48,6 +59,20 @@ object MetadataGetDatabasesAction {
this
}

/**
* get value form dataSourceId is deprecated, suggest to use dataSourceName
*
* @param dataSourceId
* datasourceId
* @return
* builder
*/
@deprecated
def setDataSourceId(dataSourceId: Long): Builder = {
this.dataSourceId = dataSourceId
this
}

def setDataSourceName(dataSourceName: String): Builder = {
this.dataSourceName = dataSourceName
this
Expand All @@ -59,13 +84,14 @@ object MetadataGetDatabasesAction {
}

def build(): MetadataGetDatabasesAction = {
if (dataSourceName == null) {
if (dataSourceName == null && dataSourceId <= 0) {
throw new DataSourceClientBuilderException(DATASOURCENAME_NEEDED.getErrorDesc)
}
if (system == null) throw new DataSourceClientBuilderException(SYSTEM_NEEDED.getErrorDesc)
if (user == null) throw new DataSourceClientBuilderException(USER_NEEDED.getErrorDesc)

val metadataGetDatabasesAction = new MetadataGetDatabasesAction
metadataGetDatabasesAction.dataSourceId = this.dataSourceId
metadataGetDatabasesAction.dataSourceName = this.dataSourceName
metadataGetDatabasesAction.setParameter("system", system)
metadataGetDatabasesAction.setUser(user)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,36 @@

package org.apache.linkis.datasource.client.request

import org.apache.linkis.datasource.client.config.DatasourceClientConfig.METADATA_SERVICE_MODULE
import org.apache.linkis.datasource.client.config.DatasourceClientConfig.{
METADATA_OLD_SERVICE_MODULE,
METADATA_SERVICE_MODULE
}
import org.apache.linkis.datasource.client.errorcode.DatasourceClientErrorCodeSummary._
import org.apache.linkis.datasource.client.exception.DataSourceClientBuilderException
import org.apache.linkis.httpclient.request.GetAction

import org.apache.commons.lang3.StringUtils

class MetadataGetPartitionsAction extends GetAction with DataSourceAction {
private var dataSourceId: Long = _
private var dataSourceName: String = _
private var database: String = _
private var table: String = _
private var traverse: Boolean = false

override def suffixURLs: Array[String] =
override def suffixURLs: Array[String] = if (StringUtils.isNotBlank(dataSourceName)) {
Array(METADATA_SERVICE_MODULE.getValue, "getPartitions")
} else {
Array(
METADATA_OLD_SERVICE_MODULE.getValue,
"partitions",
dataSourceId.toString,
"db",
database,
"table",
table
)
}

private var user: String = _

Expand All @@ -42,6 +59,7 @@ object MetadataGetPartitionsAction {
def builder(): Builder = new Builder

class Builder private[MetadataGetPartitionsAction] () {
private var dataSourceId: Long = _
private var dataSourceName: String = _
private var database: String = _
private var table: String = _
Expand All @@ -54,6 +72,20 @@ object MetadataGetPartitionsAction {
this
}

/**
* get value form dataSourceId is deprecated, suggest to use dataSourceName
*
* @param dataSourceId
* datasourceId
* @return
* builder
*/
@deprecated
def setDataSourceId(dataSourceId: Long): Builder = {
this.dataSourceId = dataSourceId
this
}

def setDataSourceName(dataSourceName: String): Builder = {
this.dataSourceName = dataSourceName
this
Expand All @@ -80,14 +112,16 @@ object MetadataGetPartitionsAction {
}

def build(): MetadataGetPartitionsAction = {
if (dataSourceName == null) {
if (dataSourceName == null && dataSourceId <= 0) {
throw new DataSourceClientBuilderException(DATASOURCENAME_NEEDED.getErrorDesc)
}
if (database == null) throw new DataSourceClientBuilderException(DATABASE_NEEDED.getErrorDesc)
if (table == null) throw new DataSourceClientBuilderException(TABLE_NEEDED.getErrorDesc)
if (system == null) throw new DataSourceClientBuilderException(SYSTEM_NEEDED.getErrorDesc)

val metadataGetPartitionsAction = new MetadataGetPartitionsAction

metadataGetPartitionsAction.dataSourceId = this.dataSourceId
metadataGetPartitionsAction.dataSourceName = this.dataSourceName
metadataGetPartitionsAction.database = this.database
metadataGetPartitionsAction.table = this.table
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,37 @@

package org.apache.linkis.datasource.client.request

import org.apache.linkis.datasource.client.config.DatasourceClientConfig.METADATA_SERVICE_MODULE
import org.apache.linkis.datasource.client.config.DatasourceClientConfig.{
METADATA_OLD_SERVICE_MODULE,
METADATA_SERVICE_MODULE
}
import org.apache.linkis.datasource.client.errorcode.DatasourceClientErrorCodeSummary._
import org.apache.linkis.datasource.client.exception.DataSourceClientBuilderException
import org.apache.linkis.httpclient.request.GetAction

import org.apache.commons.lang3.StringUtils

class MetadataGetTablePropsAction extends GetAction with DataSourceAction {

private var dataSourceId: Long = _
private var dataSourceName: String = _

private var database: String = _
private var table: String = _

override def suffixURLs: Array[String] =
override def suffixURLs: Array[String] = if (StringUtils.isNotBlank(dataSourceName)) {
Array(METADATA_SERVICE_MODULE.getValue, "getTableProps")
} else {
Array(
METADATA_OLD_SERVICE_MODULE.getValue,
"props",
dataSourceId.toString,
"db",
database,
"table",
table
)
}

private var user: String = _

Expand All @@ -42,6 +60,7 @@ object MetadataGetTablePropsAction {
def builder(): Builder = new Builder

class Builder private[MetadataGetTablePropsAction] () {
private var dataSourceId: Long = _
private var dataSourceName: String = _
private var database: String = _
private var table: String = _
Expand All @@ -53,6 +72,19 @@ object MetadataGetTablePropsAction {
this
}

/**
* get value form dataSourceId is deprecated, suggest to use dataSourceName
* @param dataSourceId
* datasourceId
* @return
* builder
*/
@deprecated
def setDataSourceId(dataSourceId: Long): Builder = {
this.dataSourceId = dataSourceId
this
}

def setDataSourceName(dataSourceName: String): Builder = {
this.dataSourceName = dataSourceName
this
Expand All @@ -74,7 +106,7 @@ object MetadataGetTablePropsAction {
}

def build(): MetadataGetTablePropsAction = {
if (dataSourceName == null) {
if (dataSourceName == null && dataSourceId <= 0) {
throw new DataSourceClientBuilderException(DATASOURCENAME_NEEDED.getErrorDesc)
}
if (database == null) throw new DataSourceClientBuilderException(DATABASE_NEEDED.getErrorDesc)
Expand All @@ -83,6 +115,7 @@ object MetadataGetTablePropsAction {
if (user == null) throw new DataSourceClientBuilderException(USER_NEEDED.getErrorDesc)

val metadataGetTablePropsAction = new MetadataGetTablePropsAction
metadataGetTablePropsAction.dataSourceId = this.dataSourceId
metadataGetTablePropsAction.dataSourceName = this.dataSourceName
metadataGetTablePropsAction.database = this.database
metadataGetTablePropsAction.table = this.table
Expand Down
Loading