Skip to content
Snippets Groups Projects
Commit 223d1ce6 authored by Martin Weise's avatar Martin Weise
Browse files

Fixed the mapping for data

parent 6194eebb
Branches
Tags
2 merge requests!81New stable release,!80Multiple features connected with user management and ownership of databases
Showing
with 255 additions and 103 deletions
...@@ -41,6 +41,7 @@ class UserDto(object): ...@@ -41,6 +41,7 @@ class UserDto(object):
'email': 'str', 'email': 'str',
'titles_before': 'str', 'titles_before': 'str',
'titles_after': 'str', 'titles_after': 'str',
'theme_dark': 'bool',
'email_verified': 'bool' 'email_verified': 'bool'
} }
...@@ -58,10 +59,11 @@ class UserDto(object): ...@@ -58,10 +59,11 @@ class UserDto(object):
'email': 'email', 'email': 'email',
'titles_before': 'titles_before', 'titles_before': 'titles_before',
'titles_after': 'titles_after', 'titles_after': 'titles_after',
'theme_dark': 'theme_dark',
'email_verified': 'email_verified' 'email_verified': 'email_verified'
} }
def __init__(self, id=None, authorities=None, username=None, firstname=None, lastname=None, affiliation=None, orcid=None, containers=None, databases=None, identifiers=None, email=None, titles_before=None, titles_after=None, email_verified=None): # noqa: E501 def __init__(self, id=None, authorities=None, username=None, firstname=None, lastname=None, affiliation=None, orcid=None, containers=None, databases=None, identifiers=None, email=None, titles_before=None, titles_after=None, theme_dark=None, email_verified=None): # noqa: E501
"""UserDto - a model defined in Swagger""" # noqa: E501 """UserDto - a model defined in Swagger""" # noqa: E501
self._id = None self._id = None
self._authorities = None self._authorities = None
...@@ -76,6 +78,7 @@ class UserDto(object): ...@@ -76,6 +78,7 @@ class UserDto(object):
self._email = None self._email = None
self._titles_before = None self._titles_before = None
self._titles_after = None self._titles_after = None
self._theme_dark = None
self._email_verified = None self._email_verified = None
self.discriminator = None self.discriminator = None
self.id = id self.id = id
...@@ -101,6 +104,7 @@ class UserDto(object): ...@@ -101,6 +104,7 @@ class UserDto(object):
self.titles_before = titles_before self.titles_before = titles_before
if titles_after is not None: if titles_after is not None:
self.titles_after = titles_after self.titles_after = titles_after
self.theme_dark = theme_dark
if email_verified is not None: if email_verified is not None:
self.email_verified = email_verified self.email_verified = email_verified
...@@ -383,6 +387,29 @@ class UserDto(object): ...@@ -383,6 +387,29 @@ class UserDto(object):
self._titles_after = titles_after self._titles_after = titles_after
@property
def theme_dark(self):
"""Gets the theme_dark of this UserDto. # noqa: E501
:return: The theme_dark of this UserDto. # noqa: E501
:rtype: bool
"""
return self._theme_dark
@theme_dark.setter
def theme_dark(self, theme_dark):
"""Sets the theme_dark of this UserDto.
:param theme_dark: The theme_dark of this UserDto. # noqa: E501
:type: bool
"""
if theme_dark is None:
raise ValueError("Invalid value for `theme_dark`, must not be `None`") # noqa: E501
self._theme_dark = theme_dark
@property @property
def email_verified(self): def email_verified(self):
"""Gets the email_verified of this UserDto. # noqa: E501 """Gets the email_verified of this UserDto. # noqa: E501
......
...@@ -41,6 +41,7 @@ class UserDto(object): ...@@ -41,6 +41,7 @@ class UserDto(object):
'email': 'str', 'email': 'str',
'titles_before': 'str', 'titles_before': 'str',
'titles_after': 'str', 'titles_after': 'str',
'theme_dark': 'bool',
'email_verified': 'bool' 'email_verified': 'bool'
} }
...@@ -58,10 +59,11 @@ class UserDto(object): ...@@ -58,10 +59,11 @@ class UserDto(object):
'email': 'email', 'email': 'email',
'titles_before': 'titles_before', 'titles_before': 'titles_before',
'titles_after': 'titles_after', 'titles_after': 'titles_after',
'theme_dark': 'theme_dark',
'email_verified': 'email_verified' 'email_verified': 'email_verified'
} }
def __init__(self, id=None, authorities=None, username=None, firstname=None, lastname=None, affiliation=None, orcid=None, containers=None, databases=None, identifiers=None, email=None, titles_before=None, titles_after=None, email_verified=None): # noqa: E501 def __init__(self, id=None, authorities=None, username=None, firstname=None, lastname=None, affiliation=None, orcid=None, containers=None, databases=None, identifiers=None, email=None, titles_before=None, titles_after=None, theme_dark=None, email_verified=None): # noqa: E501
"""UserDto - a model defined in Swagger""" # noqa: E501 """UserDto - a model defined in Swagger""" # noqa: E501
self._id = None self._id = None
self._authorities = None self._authorities = None
...@@ -76,6 +78,7 @@ class UserDto(object): ...@@ -76,6 +78,7 @@ class UserDto(object):
self._email = None self._email = None
self._titles_before = None self._titles_before = None
self._titles_after = None self._titles_after = None
self._theme_dark = None
self._email_verified = None self._email_verified = None
self.discriminator = None self.discriminator = None
self.id = id self.id = id
...@@ -101,6 +104,7 @@ class UserDto(object): ...@@ -101,6 +104,7 @@ class UserDto(object):
self.titles_before = titles_before self.titles_before = titles_before
if titles_after is not None: if titles_after is not None:
self.titles_after = titles_after self.titles_after = titles_after
self.theme_dark = theme_dark
if email_verified is not None: if email_verified is not None:
self.email_verified = email_verified self.email_verified = email_verified
...@@ -383,6 +387,29 @@ class UserDto(object): ...@@ -383,6 +387,29 @@ class UserDto(object):
self._titles_after = titles_after self._titles_after = titles_after
@property
def theme_dark(self):
"""Gets the theme_dark of this UserDto. # noqa: E501
:return: The theme_dark of this UserDto. # noqa: E501
:rtype: bool
"""
return self._theme_dark
@theme_dark.setter
def theme_dark(self, theme_dark):
"""Sets the theme_dark of this UserDto.
:param theme_dark: The theme_dark of this UserDto. # noqa: E501
:type: bool
"""
if theme_dark is None:
raise ValueError("Invalid value for `theme_dark`, must not be `None`") # noqa: E501
self._theme_dark = theme_dark
@property @property
def email_verified(self): def email_verified(self):
"""Gets the email_verified of this UserDto. # noqa: E501 """Gets the email_verified of this UserDto. # noqa: E501
......
...@@ -41,6 +41,7 @@ class UserDto(object): ...@@ -41,6 +41,7 @@ class UserDto(object):
'email': 'str', 'email': 'str',
'titles_before': 'str', 'titles_before': 'str',
'titles_after': 'str', 'titles_after': 'str',
'theme_dark': 'bool',
'email_verified': 'bool' 'email_verified': 'bool'
} }
...@@ -58,10 +59,11 @@ class UserDto(object): ...@@ -58,10 +59,11 @@ class UserDto(object):
'email': 'email', 'email': 'email',
'titles_before': 'titles_before', 'titles_before': 'titles_before',
'titles_after': 'titles_after', 'titles_after': 'titles_after',
'theme_dark': 'theme_dark',
'email_verified': 'email_verified' 'email_verified': 'email_verified'
} }
def __init__(self, id=None, authorities=None, username=None, firstname=None, lastname=None, affiliation=None, orcid=None, containers=None, databases=None, identifiers=None, email=None, titles_before=None, titles_after=None, email_verified=None): # noqa: E501 def __init__(self, id=None, authorities=None, username=None, firstname=None, lastname=None, affiliation=None, orcid=None, containers=None, databases=None, identifiers=None, email=None, titles_before=None, titles_after=None, theme_dark=None, email_verified=None): # noqa: E501
"""UserDto - a model defined in Swagger""" # noqa: E501 """UserDto - a model defined in Swagger""" # noqa: E501
self._id = None self._id = None
self._authorities = None self._authorities = None
...@@ -76,6 +78,7 @@ class UserDto(object): ...@@ -76,6 +78,7 @@ class UserDto(object):
self._email = None self._email = None
self._titles_before = None self._titles_before = None
self._titles_after = None self._titles_after = None
self._theme_dark = None
self._email_verified = None self._email_verified = None
self.discriminator = None self.discriminator = None
self.id = id self.id = id
...@@ -101,6 +104,7 @@ class UserDto(object): ...@@ -101,6 +104,7 @@ class UserDto(object):
self.titles_before = titles_before self.titles_before = titles_before
if titles_after is not None: if titles_after is not None:
self.titles_after = titles_after self.titles_after = titles_after
self.theme_dark = theme_dark
if email_verified is not None: if email_verified is not None:
self.email_verified = email_verified self.email_verified = email_verified
...@@ -383,6 +387,29 @@ class UserDto(object): ...@@ -383,6 +387,29 @@ class UserDto(object):
self._titles_after = titles_after self._titles_after = titles_after
@property
def theme_dark(self):
"""Gets the theme_dark of this UserDto. # noqa: E501
:return: The theme_dark of this UserDto. # noqa: E501
:rtype: bool
"""
return self._theme_dark
@theme_dark.setter
def theme_dark(self, theme_dark):
"""Sets the theme_dark of this UserDto.
:param theme_dark: The theme_dark of this UserDto. # noqa: E501
:type: bool
"""
if theme_dark is None:
raise ValueError("Invalid value for `theme_dark`, must not be `None`") # noqa: E501
self._theme_dark = theme_dark
@property @property
def email_verified(self): def email_verified(self):
"""Gets the email_verified of this UserDto. # noqa: E501 """Gets the email_verified of this UserDto. # noqa: E501
......
...@@ -41,6 +41,7 @@ class UserDto(object): ...@@ -41,6 +41,7 @@ class UserDto(object):
'email': 'str', 'email': 'str',
'titles_before': 'str', 'titles_before': 'str',
'titles_after': 'str', 'titles_after': 'str',
'theme_dark': 'bool',
'email_verified': 'bool' 'email_verified': 'bool'
} }
...@@ -58,10 +59,11 @@ class UserDto(object): ...@@ -58,10 +59,11 @@ class UserDto(object):
'email': 'email', 'email': 'email',
'titles_before': 'titles_before', 'titles_before': 'titles_before',
'titles_after': 'titles_after', 'titles_after': 'titles_after',
'theme_dark': 'theme_dark',
'email_verified': 'email_verified' 'email_verified': 'email_verified'
} }
def __init__(self, id=None, authorities=None, username=None, firstname=None, lastname=None, affiliation=None, orcid=None, containers=None, databases=None, identifiers=None, email=None, titles_before=None, titles_after=None, email_verified=None): # noqa: E501 def __init__(self, id=None, authorities=None, username=None, firstname=None, lastname=None, affiliation=None, orcid=None, containers=None, databases=None, identifiers=None, email=None, titles_before=None, titles_after=None, theme_dark=None, email_verified=None): # noqa: E501
"""UserDto - a model defined in Swagger""" # noqa: E501 """UserDto - a model defined in Swagger""" # noqa: E501
self._id = None self._id = None
self._authorities = None self._authorities = None
...@@ -76,6 +78,7 @@ class UserDto(object): ...@@ -76,6 +78,7 @@ class UserDto(object):
self._email = None self._email = None
self._titles_before = None self._titles_before = None
self._titles_after = None self._titles_after = None
self._theme_dark = None
self._email_verified = None self._email_verified = None
self.discriminator = None self.discriminator = None
self.id = id self.id = id
...@@ -101,6 +104,7 @@ class UserDto(object): ...@@ -101,6 +104,7 @@ class UserDto(object):
self.titles_before = titles_before self.titles_before = titles_before
if titles_after is not None: if titles_after is not None:
self.titles_after = titles_after self.titles_after = titles_after
self.theme_dark = theme_dark
if email_verified is not None: if email_verified is not None:
self.email_verified = email_verified self.email_verified = email_verified
...@@ -383,6 +387,29 @@ class UserDto(object): ...@@ -383,6 +387,29 @@ class UserDto(object):
self._titles_after = titles_after self._titles_after = titles_after
@property
def theme_dark(self):
"""Gets the theme_dark of this UserDto. # noqa: E501
:return: The theme_dark of this UserDto. # noqa: E501
:rtype: bool
"""
return self._theme_dark
@theme_dark.setter
def theme_dark(self, theme_dark):
"""Sets the theme_dark of this UserDto.
:param theme_dark: The theme_dark of this UserDto. # noqa: E501
:type: bool
"""
if theme_dark is None:
raise ValueError("Invalid value for `theme_dark`, must not be `None`") # noqa: E501
self._theme_dark = theme_dark
@property @property
def email_verified(self): def email_verified(self):
"""Gets the email_verified of this UserDto. # noqa: E501 """Gets the email_verified of this UserDto. # noqa: E501
......
This diff is collapsed.
...@@ -35,8 +35,9 @@ public class GatewayConfig { ...@@ -35,8 +35,9 @@ public class GatewayConfig {
.uri("lb://fda-identifier-service")) .uri("lb://fda-identifier-service"))
.route("fda-query-service", r -> r.path("/api/container/**/database/**/query/**", .route("fda-query-service", r -> r.path("/api/container/**/database/**/query/**",
"/api/container/**/database/**/table/**/history/**", "/api/container/**/database/**/table/**/history/**",
"/api/container/**/database/**/table/**/data/**", // TODO "/api/container/**/database/**/table/**/data/**",
"/api/container/**/database/**/table/**/query/**", // TODO "/api/container/**/database/**/table/**/query/**",
"/api/container/**/database/**/table/**/export/**",
"/api/container/**/database/**/version/**") "/api/container/**/database/**/version/**")
.and() .and()
.method("POST", "GET", "PUT", "DELETE") .method("POST", "GET", "PUT", "DELETE")
......
...@@ -104,7 +104,7 @@ public interface QueryMapper { ...@@ -104,7 +104,7 @@ public interface QueryMapper {
return connection.prepareStatement(statement.toString()); return connection.prepareStatement(statement.toString());
} catch (SQLException e) { } catch (SQLException e) {
log.error("Failed to prepare statement"); log.error("Failed to prepare statement");
log.debug("failed to prepare statement {} reason {}", statement, e.getMessage()); log.debug("failed to prepare statement {} reason: {}", statement, e.getMessage());
throw new QueryMalformedException("Failed to prepare statement", e); throw new QueryMalformedException("Failed to prepare statement", e);
} }
} }
...@@ -121,7 +121,7 @@ public interface QueryMapper { ...@@ -121,7 +121,7 @@ public interface QueryMapper {
return connection.prepareStatement(statement.toString()); return connection.prepareStatement(statement.toString());
} catch (SQLException e) { } catch (SQLException e) {
log.error("Failed to prepare statement"); log.error("Failed to prepare statement");
log.debug("failed to prepare statement {} reason {}", statement, e.getMessage()); log.debug("failed to prepare statement {} reason: {}", statement, e.getMessage());
throw new QueryMalformedException("Failed to prepare statement", e); throw new QueryMalformedException("Failed to prepare statement", e);
} }
} }
...@@ -177,7 +177,7 @@ public interface QueryMapper { ...@@ -177,7 +177,7 @@ public interface QueryMapper {
return connection.prepareStatement(statement.toString()); return connection.prepareStatement(statement.toString());
} catch (SQLException e) { } catch (SQLException e) {
log.error("Failed to prepare statement"); log.error("Failed to prepare statement");
log.debug("failed to prepare statement {} reason {}", statement, e.getMessage()); log.debug("failed to prepare statement {} reason: {}", statement, e.getMessage());
throw new QueryMalformedException("Failed to prepare statement", e); throw new QueryMalformedException("Failed to prepare statement", e);
} }
} }
...@@ -323,7 +323,7 @@ public interface QueryMapper { ...@@ -323,7 +323,7 @@ public interface QueryMapper {
return connection.prepareStatement(statement.toString()); return connection.prepareStatement(statement.toString());
} catch (SQLException e) { } catch (SQLException e) {
log.error("Failed to prepare statement"); log.error("Failed to prepare statement");
log.debug("failed to prepare statement {} reason {}", statement, e.getMessage()); log.debug("failed to prepare statement {} reason: {}", statement, e.getMessage());
throw new QueryMalformedException("Failed to prepare statement", e); throw new QueryMalformedException("Failed to prepare statement", e);
} }
} }
...@@ -337,7 +337,7 @@ public interface QueryMapper { ...@@ -337,7 +337,7 @@ public interface QueryMapper {
final StringBuilder versionPart = new StringBuilder(" FOR SYSTEM_TIME AS OF TIMESTAMP'") final StringBuilder versionPart = new StringBuilder(" FOR SYSTEM_TIME AS OF TIMESTAMP'")
.append(mariaDbFormatter.format(query.getExecution())) .append(mariaDbFormatter.format(query.getExecution()))
.append("' "); .append("' ");
final Pattern pattern = Pattern.compile("from `?[a-zA-Z0-9_]+`?", Pattern.CASE_INSENSITIVE) /* https://mariadb.com/kb/en/columnstore-naming-conventions/ */; final Pattern pattern = Pattern.compile("from `?[a-zA-Z0-9_-]+`?", Pattern.CASE_INSENSITIVE) /* https://mariadb.com/kb/en/columnstore-naming-conventions/ */;
final Matcher matcher = pattern.matcher(query.getQuery()); final Matcher matcher = pattern.matcher(query.getQuery());
if (!matcher.find()) { if (!matcher.find()) {
log.error("Failed to find 'from' clause in query"); log.error("Failed to find 'from' clause in query");
...@@ -355,7 +355,7 @@ public interface QueryMapper { ...@@ -355,7 +355,7 @@ public interface QueryMapper {
return connection.prepareStatement(statement.toString()); return connection.prepareStatement(statement.toString());
} catch (SQLException e) { } catch (SQLException e) {
log.error("Failed to prepare statement"); log.error("Failed to prepare statement");
log.debug("failed to prepare statement {} reason {}", statement, e.getMessage()); log.debug("failed to prepare statement {} reason: {}", statement, e.getMessage());
throw new QueryMalformedException("Failed to prepare statement", e); throw new QueryMalformedException("Failed to prepare statement", e);
} }
} }
...@@ -407,7 +407,7 @@ public interface QueryMapper { ...@@ -407,7 +407,7 @@ public interface QueryMapper {
return ps; return ps;
} catch (SQLException e) { } catch (SQLException e) {
log.error("Failed to prepare statement"); log.error("Failed to prepare statement");
log.debug("failed to prepare statement {} reason {}", statement, e.getMessage()); log.debug("failed to prepare statement {} reason: {}", statement, e.getMessage());
throw new QueryMalformedException("Failed to prepare statement", e); throw new QueryMalformedException("Failed to prepare statement", e);
} }
} }
...@@ -440,7 +440,7 @@ public interface QueryMapper { ...@@ -440,7 +440,7 @@ public interface QueryMapper {
return connection.prepareStatement(statement.toString()); return connection.prepareStatement(statement.toString());
} catch (SQLException e) { } catch (SQLException e) {
log.error("Failed to prepare statement"); log.error("Failed to prepare statement");
log.debug("failed to prepare statement {} reason {}", statement, e.getMessage()); log.debug("failed to prepare statement {} reason: {}", statement, e.getMessage());
throw new QueryMalformedException("Failed to prepare statement", e); throw new QueryMalformedException("Failed to prepare statement", e);
} }
} }
...@@ -509,7 +509,7 @@ public interface QueryMapper { ...@@ -509,7 +509,7 @@ public interface QueryMapper {
return connection.prepareStatement(statement.toString()); return connection.prepareStatement(statement.toString());
} catch (SQLException e) { } catch (SQLException e) {
log.error("Failed to prepare statement"); log.error("Failed to prepare statement");
log.debug("failed to prepare statement {} reason {}", statement, e.getMessage()); log.debug("failed to prepare statement {} reason: {}", statement, e.getMessage());
throw new QueryMalformedException("Failed to prepare statement", e); throw new QueryMalformedException("Failed to prepare statement", e);
} }
} }
...@@ -560,7 +560,7 @@ public interface QueryMapper { ...@@ -560,7 +560,7 @@ public interface QueryMapper {
return connection.prepareStatement(statement); return connection.prepareStatement(statement);
} catch (SQLException e) { } catch (SQLException e) {
log.error("Failed to prepare statement"); log.error("Failed to prepare statement");
log.debug("failed to prepare statement {} reason {}", statement, e.getMessage()); log.debug("failed to prepare statement {} reason: {}", statement, e.getMessage());
throw new QueryMalformedException("Failed to prepare statement", e); throw new QueryMalformedException("Failed to prepare statement", e);
} }
} }
...@@ -626,7 +626,7 @@ public interface QueryMapper { ...@@ -626,7 +626,7 @@ public interface QueryMapper {
return connection.prepareStatement(statement); return connection.prepareStatement(statement);
} catch (SQLException e) { } catch (SQLException e) {
log.error("Failed to prepare statement"); log.error("Failed to prepare statement");
log.debug("failed to prepare statement {} reason {}", statement, e.getMessage()); log.debug("failed to prepare statement {} reason: {}", statement, e.getMessage());
throw new QueryMalformedException("Failed to prepare statement", e); throw new QueryMalformedException("Failed to prepare statement", e);
} }
} }
...@@ -681,7 +681,7 @@ public interface QueryMapper { ...@@ -681,7 +681,7 @@ public interface QueryMapper {
return connection.prepareStatement(statement.toString()); return connection.prepareStatement(statement.toString());
} catch (SQLException e) { } catch (SQLException e) {
log.error("Failed to prepare statement"); log.error("Failed to prepare statement");
log.debug("failed to prepare statement {} reason {}", statement, e.getMessage()); log.debug("failed to prepare statement {} reason: {}", statement, e.getMessage());
throw new QueryMalformedException("Failed to prepare statement", e); throw new QueryMalformedException("Failed to prepare statement", e);
} }
} }
...@@ -690,7 +690,7 @@ public interface QueryMapper { ...@@ -690,7 +690,7 @@ public interface QueryMapper {
final List<Map<String, Object>> queryResult = new LinkedList<>(); final List<Map<String, Object>> queryResult = new LinkedList<>();
while (result.next()) { while (result.next()) {
/* map the result set to the columns through the stored metadata in the metadata database */ /* map the result set to the columns through the stored metadata in the metadata database */
int[] idx = new int[]{0}; int[] idx = new int[]{1};
final Map<String, Object> map = new HashMap<>(); final Map<String, Object> map = new HashMap<>();
for (int i = 0; i < table.getColumns().size(); i++) { for (int i = 0; i < table.getColumns().size(); i++) {
map.put(table.getColumns().get(i).getInternalName(), dataColumnToObject(result.getObject(idx[0]++), table.getColumns().get(i))); map.put(table.getColumns().get(i).getInternalName(), dataColumnToObject(result.getObject(idx[0]++), table.getColumns().get(i)));
...@@ -717,7 +717,7 @@ public interface QueryMapper { ...@@ -717,7 +717,7 @@ public interface QueryMapper {
return connection.prepareStatement(statement.toString()); return connection.prepareStatement(statement.toString());
} catch (SQLException e) { } catch (SQLException e) {
log.error("Failed to prepare statement"); log.error("Failed to prepare statement");
log.debug("failed to prepare statement {} reason {}", statement, e.getMessage()); log.debug("failed to prepare statement {} reason: {}", statement, e.getMessage());
throw new QueryMalformedException("Failed to prepare statement", e); throw new QueryMalformedException("Failed to prepare statement", e);
} }
} }
...@@ -857,7 +857,7 @@ public interface QueryMapper { ...@@ -857,7 +857,7 @@ public interface QueryMapper {
return connection.prepareStatement(statement.toString()); return connection.prepareStatement(statement.toString());
} catch (SQLException e) { } catch (SQLException e) {
log.error("Failed to prepare statement"); log.error("Failed to prepare statement");
log.debug("failed to prepare statement {} reason {}", statement, e.getMessage()); log.debug("failed to prepare statement {} reason: {}", statement, e.getMessage());
throw new QueryMalformedException("Failed to prepare statement", e); throw new QueryMalformedException("Failed to prepare statement", e);
} }
} }
......
...@@ -58,7 +58,7 @@ public interface StoreMapper { ...@@ -58,7 +58,7 @@ public interface StoreMapper {
return ps; return ps;
} catch (SQLException e) { } catch (SQLException e) {
log.error("Failed to prepare statement"); log.error("Failed to prepare statement");
log.debug("failed to prepare statement {} reason {}", statement, e.getMessage()); log.debug("failed to prepare statement {} reason: {}", statement, e.getMessage());
throw new QueryStoreException("Failed to prepare statement", e); throw new QueryStoreException("Failed to prepare statement", e);
} }
} }
...@@ -69,7 +69,7 @@ public interface StoreMapper { ...@@ -69,7 +69,7 @@ public interface StoreMapper {
return connection.prepareStatement(statement); return connection.prepareStatement(statement);
} catch (SQLException e) { } catch (SQLException e) {
log.error("Failed to prepare statement"); log.error("Failed to prepare statement");
log.debug("failed to prepare statement {} reason {}", statement, e.getMessage()); log.debug("failed to prepare statement {} reason: {}", statement, e.getMessage());
throw new QueryStoreException("Failed to prepare statement", e); throw new QueryStoreException("Failed to prepare statement", e);
} }
} }
...@@ -84,7 +84,7 @@ public interface StoreMapper { ...@@ -84,7 +84,7 @@ public interface StoreMapper {
return ps; return ps;
} catch (SQLException e) { } catch (SQLException e) {
log.error("Failed to prepare statement"); log.error("Failed to prepare statement");
log.debug("failed to prepare statement {} reason {}", statement, e.getMessage()); log.debug("failed to prepare statement {} reason: {}", statement, e.getMessage());
throw new QueryStoreException("Failed to prepare statement", e); throw new QueryStoreException("Failed to prepare statement", e);
} }
} }
...@@ -107,7 +107,7 @@ public interface StoreMapper { ...@@ -107,7 +107,7 @@ public interface StoreMapper {
return ps; return ps;
} catch (SQLException e) { } catch (SQLException e) {
log.error("Failed to prepare statement"); log.error("Failed to prepare statement");
log.debug("failed to prepare statement {} reason {}", statement, e.getMessage()); log.debug("failed to prepare statement {} reason: {}", statement, e.getMessage());
throw new QueryStoreException("Failed to prepare statement", e); throw new QueryStoreException("Failed to prepare statement", e);
} }
} }
......
...@@ -134,6 +134,7 @@ public class QueryServiceImpl extends HibernateConnector implements QueryService ...@@ -134,6 +134,7 @@ public class QueryServiceImpl extends HibernateConnector implements QueryService
throw new TableMalformedException("Could not parse date from format", e); throw new TableMalformedException("Could not parse date from format", e);
} catch (SQLException e) { } catch (SQLException e) {
log.error("Failed to map object"); log.error("Failed to map object");
log.debug("failed to map object, reason: {}", e.getMessage());
throw new TableMalformedException("Failed to map object", e); throw new TableMalformedException("Failed to map object", e);
} finally { } finally {
dataSource.close(); dataSource.close();
......
...@@ -63,7 +63,7 @@ public class StoreServiceImpl extends HibernateConnector implements StoreService ...@@ -63,7 +63,7 @@ public class StoreServiceImpl extends HibernateConnector implements StoreService
return storeMapper.resultSetToQueryList(resultSet); return storeMapper.resultSetToQueryList(resultSet);
} catch (SQLException e) { } catch (SQLException e) {
log.error("Failed to find queries"); log.error("Failed to find queries");
log.debug("failed to find queries in container with id {} and database with id {}, reason {}", containerId, databaseId, e.getMessage()); log.debug("failed to find queries in container with id {} and database with id {}, reason: {}", containerId, databaseId, e.getMessage());
throw new QueryStoreException("Query not found"); throw new QueryStoreException("Query not found");
} finally { } finally {
dataSource.close(); dataSource.close();
......
...@@ -53,21 +53,14 @@ export default { ...@@ -53,21 +53,14 @@ export default {
console.debug('send data', data) console.debug('send data', data)
const page = 0 const page = 0
const urlParams = `page=${page}&size=${this.options.itemsPerPage}` const urlParams = `page=${page}&size=${this.options.itemsPerPage}`
const res = await this.$axios.put(`/api/container/ const res = await this.$axios.put(`/api/container/${this.$route.params.container_id}/database/${this.$route.params.database_id}/query${this.parent.queryId ? `/${this.parent.queryId}` : ''}?${urlParams}`, data, {
${this.$route.params.container_id}/database/${this.$route.params.database_id}/query
${this.parent.queryId ? `/${this.parent.queryId}` : ''}
?${urlParams}`, data, {
headers: this.headers headers: this.headers
}) })
console.debug('query result', res) console.debug('query result', res)
this.$toast.success('Successfully executed query') this.$toast.success('Successfully executed query')
this.mapResults(res.data)
this.loading = false this.loading = false
this.parent.queryId = res.data.id this.parent.queryId = res.data.id
this.result.headers = this.parent.select.map((s) => {
return { text: s.name, value: s.name, sortable: false }
})
this.result.rows = res.data.result
this.total = res.data.resultNumber
} catch (err) { } catch (err) {
console.error('query execute', err) console.error('query execute', err)
this.$toast.error('Could not execute query') this.$toast.error('Could not execute query')
...@@ -95,13 +88,8 @@ ${this.$route.params.container_id}/database/${this.$route.params.database_id}/qu ...@@ -95,13 +88,8 @@ ${this.$route.params.container_id}/database/${this.$route.params.database_id}/qu
?${urlParams}`, {}, { ?${urlParams}`, {}, {
headers: this.headers headers: this.headers
}) })
this.mapResults(res.data)
this.loading = false this.loading = false
if (res.data.result.length) {
this.result.headers = this.buildHeaders(res.data.result[0])
}
console.debug('query result', res.data)
this.result.rows = res.data.result
this.total = res.data.resultNumber
} catch (err) { } catch (err) {
if (err.response.status !== 401 && err.response.status !== 405) { if (err.response.status !== 401 && err.response.status !== 405) {
console.error('query execute', err) console.error('query execute', err)
...@@ -109,6 +97,14 @@ ${this.$route.params.container_id}/database/${this.$route.params.database_id}/qu ...@@ -109,6 +97,14 @@ ${this.$route.params.container_id}/database/${this.$route.params.database_id}/qu
} }
this.loading = false this.loading = false
} }
},
mapResults (data) {
if (data.result.length) {
this.result.headers = this.buildHeaders(data.result[0])
}
console.debug('query result', data)
this.result.rows = data.result
this.total = data.resultNumber
} }
} }
} }
......
...@@ -27,6 +27,9 @@ ...@@ -27,6 +27,9 @@
<v-btn :disabled="!token" class="mb-1" :to="`/container/${$route.params.container_id}/database/${$route.params.database_id}/table/${$route.params.table_id}/import`"> <v-btn :disabled="!token" class="mb-1" :to="`/container/${$route.params.container_id}/database/${$route.params.database_id}/table/${$route.params.table_id}/import`">
<v-icon left>mdi-cloud-upload</v-icon> Import csv <v-icon left>mdi-cloud-upload</v-icon> Import csv
</v-btn> </v-btn>
<v-btn :disabled="error" class="ml-2 mb-1" :loading="downloadLoading" @click.stop="download">
<v-icon left>mdi-download</v-icon> Data .csv
</v-btn>
<v-btn <v-btn
v-if="false" v-if="false"
color="primary" color="primary"
...@@ -96,6 +99,7 @@ export default { ...@@ -96,6 +99,7 @@ export default {
footerProps: { footerProps: {
'items-per-page-options': [10, 20, 30, 40, 50] 'items-per-page-options': [10, 20, 30, 40, 50]
}, },
downloadLoading: false,
dateMenu: false, dateMenu: false,
timeMenu: false, timeMenu: false,
selection: [], selection: [],
...@@ -172,6 +176,27 @@ export default { ...@@ -172,6 +176,27 @@ export default {
this.loadData() this.loadData()
}, },
methods: { methods: {
async download () {
this.downloadLoading = true
try {
const res = await this.$axios.get(`/api/container/${this.$route.params.container_id}/database/${this.$route.params.database_id}/table/${this.$route.params.table_id}/export`, {
headers: { Authorization: `Bearer ${this.token}` },
responseType: 'text'
})
console.debug('export table', res)
const url = window.URL.createObjectURL(new Blob([res.data]))
const link = document.createElement('a')
link.href = url
link.setAttribute('download', 'table.csv')
document.body.appendChild(link)
link.click()
} catch (err) {
console.error('Could not export table', err)
this.$toast.error('Could not export table')
this.error = true
}
this.downloadLoading = false
},
addTuple () { addTuple () {
this.edit = false this.edit = false
const data = {} const data = {}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment