-
-
Notifications
You must be signed in to change notification settings - Fork 489
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Database harvester #8247
base: main
Are you sure you want to change the base?
Database harvester #8247
Conversation
7b65eec
to
249edde
Compare
249edde
to
6b7fb4d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you !
harvesterSettingsManager.add("id:" + siteId, "server", params.getServer()); | ||
harvesterSettingsManager.add("id:" + siteId, "port", params.getPort()); | ||
harvesterSettingsManager.add("id:" + siteId, "username", params.getUsername()); | ||
harvesterSettingsManager.add("id:" + siteId, "password", params.getPassword()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello, are we sure this is encrypted in datatase ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The passwords in the seetings and settings table are encrypted using Jasypt
//--- retrieve harvested uuids for given harvesting node | ||
localCateg = new CategoryMapper(context); | ||
localGroups = new GroupMapper(context); | ||
localUuids = new UUIDMapper(context.getBean(IMetadataUtils.class), params.getUuid()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to use the one defined line 92 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 0d74819
|
||
private void deleteLocalMetadataNotInDatabase(List<Integer> idsForHarvestingResult) throws Exception { | ||
Set<Integer> idsResultHs = Sets.newHashSet(idsForHarvestingResult); | ||
List<Integer> existingMetadata = context.getBean(MetadataRepository.class).findIdsBy(MetadataSpecs.hasHarvesterUuid(params.getUuid())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could a class member be made from MetadataRepository bean ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 0d74819
sqlQuery = String.format("SELECT %s FROM %s", columnName, metadataTable); | ||
} | ||
|
||
getJdbcTemplate().query(sqlQuery, param, rs -> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can please say how is DatabaseMetadataRetriever related to ArcSDEJdbcConnection ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DatabaseMetadataRetriever
is quite similar indeed to ArcSDEJdbcConnection
.
Probably at some point we should remove the ArcSDE harvester as the API connection mode is only useful for ArcSDE 9 and below, which is probably not used much nowadays.
The direct connection mode of the ArcSDE harvester is analogous to the database harvester, the only advantage is that in the ArcSDE harvester the user does not have to provide table and field configuration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 for deprecating ArcSDE
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, but this will not be part of this pull request. That's for another pull request.
|
||
import static org.junit.Assert.*; | ||
|
||
public class DatabaseMetadataRetrieverFactoryTest { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 for testing !
|
||
- **Schedule**: Scheduling options to execute the harvester. If disabled, the harvester should be executed manually from the harvesters page. If enabled a schedule expression using cron syntax should be configured ([See examples](https://www.quartz-scheduler.org/documentation/quartz-2.1.7/tutorials/crontrigger)). | ||
|
||
- **Configure connection to Database** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was having a look at all the code and I could not workout how the connection to the db is closed. Since a Factory is used to create a new instance of the DatabaseMetadataRetriever is created each time and its database connection is encapsulated. Could clarify how the disconnection is done ? (Are we expected to have special database auto disconnect setup ? or is it missing ?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can be wrong, as not an expert about this, but getJdbcTemplate().query
seems handling that
, it uses this code
That closes the statement and releases underlying connection.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it not ResultSet connection closing? (it allows to fetch a bunch of rows at a time, as there might be too many for one fetch). Usually you open a connection to a DB. Then you send a lot of requests. Then you close it. I don't know of a case where a single query (especially select queries) are expected to close the db connection. We need a third opinion or some test that will validate it ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As indicated, afaik the Spring JdbcTemplate
manages this internally. It's not like using JDBC directly.
…e IMetadataUtils class member instead of context.getBean
eab298f
to
0d74819
Compare
- *Batch edits*: (Optional) Allows to update harvested records, using XPATH syntax. It can be used to add, replace or delete element. | ||
- *Translate metadata content*: (Optional) Allows to translate metadata elements. It requires a translation service provider configured in the System settings. | ||
|
||
- **Privileges** - Assign privileges to harvested metadata. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe you could add a brief description of the structure of the DB to be harvested, in order to avoid having to read the code ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation had already some entries for this:
Please check if requires some improvements or examples.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes this part is good. I was referring to the part which lists the column types supported which are not mentionned and I came accross them in DatabaseMetadataRetriever.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the documentation: 32c6dce
A harvester to retrieve metadata from a database table using JDBC, currently supporting Postgres and Oracle connections.
Configuration is described in https://github.com/GeoCat/core-geonetwork/blob/7b65eecc5b77c35620c505655d7e75d6c2046f85/docs/manual/docs/user-guide/harvesting/harvesting-database.md
Checklist
main
branch, backports managed with labelREADME.md
filespom.xml
dependency management. Update build documentation with intended library use and library tutorials or documentationFunded by: Rijkswaterstaat