Skip to content

Commit

Permalink
fix(plugin): fix get version
Browse files Browse the repository at this point in the history
  • Loading branch information
qianmoQ committed Dec 9, 2024
1 parent 5720c42 commit 2692fb0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import lombok.extern.slf4j.Slf4j;

import java.util.ArrayList;
import java.util.Map;
import java.util.Optional;

/**
Expand Down Expand Up @@ -161,7 +162,12 @@ private void updateSourceVersion(SourceEntity source, Response response)
return ((ArrayList<?>) version).get(0).toString();
}
else if (version instanceof JsonNode) {
return ((JsonNode) version).get("version").asText();
String columnName = response.getHeaders().get(0);
return ((JsonNode) version).get(columnName).asText();
}
else if (version instanceof Map) {
String columnName = response.getHeaders().get(0);
return ((Map<?, ?>) version).get(columnName).toString();
}
return version.toString();
})
Expand Down
9 changes: 6 additions & 3 deletions core/datacap-ui/src/views/pages/admin/source/SourceInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -358,9 +358,7 @@ export default defineComponent({
this.testInfo.connected = true
this.testInfo.successful = true
this.testInfo.message = null
this.formState.version = response.data?.columns[0]?.version
? response.data?.columns[0]?.version
: response.data?.columns[0]?.result
this.formState.version = this.extractVersion(response.data)
}
else {
this.testInfo.message = response.message
Expand Down Expand Up @@ -427,6 +425,11 @@ export default defineComponent({
.filter(group => group && typeof group === 'string')
this.configureTabs = [...new Set(validGroups)]
},
extractVersion(json: string)
{
const columnName = json['headers'][0]
return json['columns'][0][columnName]
}
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public String url(Configure configure)
buffer.append(configure.getDatabase().get());
}
if (configure.getSsl().isPresent()) {
if (!configure.getDatabase().isPresent()) {
if (configure.getDatabase().isEmpty()) {
buffer.append(String.format("?ssl=%s", configure.getSsl().get()));
}
else {
Expand All @@ -61,7 +61,7 @@ public String url(Configure configure)
.stream()
.map(value -> String.format("%s=%s", value.getKey(), value.getValue()))
.collect(Collectors.toList());
if (!configure.getDatabase().isPresent()) {
if (configure.getDatabase().isEmpty()) {
buffer.append("?");
}
else {
Expand Down

0 comments on commit 2692fb0

Please sign in to comment.