-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #372 from VEuPathDB/371-dependency-table
Add dataset_dependencies table queries for app db
- Loading branch information
Showing
7 changed files
with
69 additions
and
0 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
17 changes: 17 additions & 0 deletions
17
lib/app-db/src/main/kotlin/vdi/component/db/app/sql/delete/delete-dataset-dependencies.kt
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,17 @@ | ||
package vdi.component.db.app.sql.delete | ||
|
||
import org.veupathdb.vdi.lib.common.field.DatasetID | ||
import vdi.component.db.app.sql.preparedUpdate | ||
import java.sql.Connection | ||
|
||
private fun sql(schema: String) = | ||
// language=oracle | ||
""" | ||
DELETE FROM | ||
${schema}.dataset_dependency | ||
WHERE | ||
dataset_id = ? | ||
""" | ||
|
||
internal fun Connection.deleteDatasetDependencies(schema: String, datasetID: DatasetID) = | ||
preparedUpdate(sql(schema)) { setString(1, datasetID.toString()) } |
35 changes: 35 additions & 0 deletions
35
lib/app-db/src/main/kotlin/vdi/component/db/app/sql/insert/insert-dataset-dependencies.kt
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,35 @@ | ||
package vdi.component.db.app.sql.insert | ||
|
||
import org.veupathdb.vdi.lib.common.field.DatasetID | ||
import org.veupathdb.vdi.lib.common.model.VDIDatasetDependency | ||
import vdi.component.db.app.sql.preparedBatchUpdate | ||
import vdi.component.db.app.sql.setDatasetID | ||
import java.sql.Connection | ||
|
||
|
||
private fun sql(schema: String) = | ||
// language=oracle | ||
""" | ||
INSERT INTO | ||
${schema}.dataset_dependency ( | ||
dataset_id | ||
, identifier | ||
, display_name | ||
, version | ||
) | ||
VALUES | ||
(?, ?, ?, ?) | ||
""" | ||
|
||
internal fun Connection.insertDatasetDependencies( | ||
schema: String, | ||
datasetID: DatasetID, | ||
dependencies: Collection<VDIDatasetDependency>, | ||
) { | ||
preparedBatchUpdate(sql(schema), dependencies) { | ||
setDatasetID(1, datasetID) | ||
setString(2, it.identifier) | ||
setString(3, it.displayName) | ||
setString(4, it.version) | ||
} | ||
} |
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
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