forked from apache/linkis
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Code Optimization * Code Optimization * Code Optimization * Code Optimization * fix miss code * New interface: Retrieve data source list based on type name * New interface: Retrieve data source list based on type name * bug fix --------- Co-authored-by: “v_kkhuang” <“420895376@qq.com”>
- Loading branch information
Showing
6 changed files
with
293 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
...ain/scala/org/apache/linkis/datasource/client/request/GetDataSourceByTypeNameAction.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.linkis.datasource.client.request | ||
|
||
import org.apache.linkis.datasource.client.config.DatasourceClientConfig.DATA_SOURCE_SERVICE_MODULE | ||
import org.apache.linkis.datasource.client.errorcode.DatasourceClientErrorCodeSummary._ | ||
import org.apache.linkis.datasource.client.exception.DataSourceClientBuilderException | ||
import org.apache.linkis.datasource.client.request.QueryDataSourceAction.Builder | ||
import org.apache.linkis.httpclient.request.GetAction | ||
|
||
class GetDataSourceByTypeNameAction extends GetAction with DataSourceAction { | ||
private var user: String = _ | ||
|
||
override def setUser(user: String): Unit = this.user = user | ||
|
||
override def getUser: String = this.user | ||
|
||
override def suffixURLs: Array[String] = | ||
Array(DATA_SOURCE_SERVICE_MODULE.getValue, "info-by-type") | ||
|
||
} | ||
|
||
object GetDataSourceByTypeNameAction { | ||
def builder(): Builder = new Builder | ||
|
||
class Builder private[GetDataSourceByTypeNameAction] () { | ||
private var user: String = _ | ||
private var typeName: String = _ | ||
private var currentPage: Integer = _ | ||
private var pageSize: Integer = _ | ||
|
||
def setUser(user: String): Builder = { | ||
this.user = user | ||
this | ||
} | ||
|
||
def setTypeName(typeName: String): Builder = { | ||
this.typeName = typeName | ||
this | ||
} | ||
|
||
def setCurrentPage(currentPage: Integer): Builder = { | ||
this.currentPage = currentPage | ||
this | ||
} | ||
|
||
def setPageSize(pageSize: Integer): Builder = { | ||
this.pageSize = pageSize | ||
this | ||
} | ||
|
||
def build(): GetDataSourceByTypeNameAction = { | ||
if (user == null) throw new DataSourceClientBuilderException(USER_NEEDED.getErrorDesc) | ||
val action = new GetDataSourceByTypeNameAction | ||
if (typeName != null) { | ||
action.setParameter("typeName", typeName) | ||
} | ||
if (currentPage != null) { | ||
action.setParameter("currentPage", currentPage) | ||
} | ||
if (pageSize != null) { | ||
action.setParameter("pageSize", pageSize) | ||
} | ||
action.user = user | ||
action | ||
} | ||
|
||
} | ||
|
||
} |
65 changes: 65 additions & 0 deletions
65
...cala/org/apache/linkis/datasource/client/request/GetDataSourceKeyDefineByTypeAction.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.linkis.datasource.client.request | ||
|
||
import org.apache.linkis.datasource.client.config.DatasourceClientConfig.DATA_SOURCE_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 GetDataSourceKeyDefineByTypeAction extends GetAction with DataSourceAction { | ||
private var user: String = _ | ||
private var typeName: String = _ | ||
|
||
override def setUser(user: String): Unit = this.user = user | ||
|
||
override def getUser: String = this.user | ||
|
||
override def suffixURLs: Array[String] = | ||
Array(DATA_SOURCE_SERVICE_MODULE.getValue, "key-define", typeName) | ||
|
||
} | ||
|
||
object GetDataSourceKeyDefineByTypeAction { | ||
def builder(): Builder = new Builder | ||
|
||
class Builder private[GetDataSourceKeyDefineByTypeAction] () { | ||
private var user: String = _ | ||
private var typeName: String = _ | ||
|
||
def setUser(user: String): Builder = { | ||
this.user = user | ||
this | ||
} | ||
|
||
def setTypeName(typeName: String): Builder = { | ||
this.typeName = typeName | ||
this | ||
} | ||
|
||
def build(): GetDataSourceKeyDefineByTypeAction = { | ||
if (user == null) throw new DataSourceClientBuilderException(USER_NEEDED.getErrorDesc) | ||
val action = new GetDataSourceKeyDefineByTypeAction | ||
action.user = user | ||
action.typeName = typeName | ||
action | ||
} | ||
|
||
} | ||
|
||
} |
44 changes: 44 additions & 0 deletions
44
...in/scala/org/apache/linkis/datasource/client/response/GetDataSourceByTypeNameResult.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.linkis.datasource.client.response | ||
|
||
import org.apache.linkis.datasourcemanager.common.domain.DataSource | ||
import org.apache.linkis.httpclient.dws.DWSHttpClient | ||
import org.apache.linkis.httpclient.dws.annotation.DWSHttpMessageResult | ||
import org.apache.linkis.httpclient.dws.response.DWSResult | ||
|
||
import java.util | ||
|
||
import scala.beans.BeanProperty | ||
|
||
@DWSHttpMessageResult("/api/rest_j/v\\d+/data-source-manager/info-by-type") | ||
class GetDataSourceByTypeNameResult extends DWSResult { | ||
@BeanProperty var queryList: util.List[java.util.Map[String, Any]] = _ | ||
@BeanProperty var totalPage: Int = _ | ||
|
||
def getAllDataSource: util.List[DataSource] = { | ||
import scala.collection.JavaConverters._ | ||
queryList.asScala | ||
.map(x => { | ||
val str = DWSHttpClient.jacksonJson.writeValueAsString(x) | ||
DWSHttpClient.jacksonJson.readValue(str, classOf[DataSource]) | ||
}) | ||
.asJava | ||
} | ||
|
||
} |
47 changes: 47 additions & 0 deletions
47
...ala/org/apache/linkis/datasource/client/response/GetDataSourceKeyDefineByTypeResult.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.linkis.datasource.client.response | ||
|
||
import org.apache.linkis.datasourcemanager.common.domain.{ | ||
DataSourceParamKeyDefinition, | ||
DatasourceVersion | ||
} | ||
import org.apache.linkis.httpclient.dws.DWSHttpClient | ||
import org.apache.linkis.httpclient.dws.annotation.DWSHttpMessageResult | ||
import org.apache.linkis.httpclient.dws.response.DWSResult | ||
|
||
import java.util | ||
|
||
import scala.beans.BeanProperty | ||
|
||
@DWSHttpMessageResult("/api/rest_j/v\\d+/data-source-manager/key-define/(\\S+)") | ||
class GetDataSourceKeyDefineByTypeResult extends DWSResult { | ||
|
||
@BeanProperty var keyDefine: util.List[java.util.Map[String, Any]] = _ | ||
|
||
def getDatasourceVersion: util.List[DataSourceParamKeyDefinition] = { | ||
import scala.collection.JavaConverters._ | ||
keyDefine.asScala | ||
.map(x => { | ||
val str = DWSHttpClient.jacksonJson.writeValueAsString(x) | ||
DWSHttpClient.jacksonJson.readValue(str, classOf[DataSourceParamKeyDefinition]) | ||
}) | ||
.asJava | ||
} | ||
|
||
} |