Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
DLCM-Backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
DLCM
Community
DLCM-Backend
Commits
bf28a879
Commit
bf28a879
authored
5 years ago
by
Jules Paget
Browse files
Options
Downloads
Patches
Plain Diff
CLeaning code of test and service
parent
0aa79c85
No related branches found
Branches containing commit
No related tags found
1 merge request
!275
Draft: JPA Siard tool
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
DLCM-Tools/src/main/java/ch/dlcm/siard/SiardService.java
+2
-69
2 additions, 69 deletions
DLCM-Tools/src/main/java/ch/dlcm/siard/SiardService.java
DLCM-Tools/src/test/java/ch/dlcm/test/tools/SiardTest.java
+2
-1
2 additions, 1 deletion
DLCM-Tools/src/test/java/ch/dlcm/test/tools/SiardTest.java
with
4 additions
and
70 deletions
DLCM-Tools/src/main/java/ch/dlcm/siard/SiardService.java
+
2
−
69
View file @
bf28a879
...
@@ -154,88 +154,21 @@ public class SiardService extends Tools implements CommandLineRunner {
...
@@ -154,88 +154,21 @@ public class SiardService extends Tools implements CommandLineRunner {
throw
new
RuntimeException
(
"Error when trying to get Primary data from DB."
,
e
);
throw
new
RuntimeException
(
"Error when trying to get Primary data from DB."
,
e
);
}
}
/* Close archive and connection */
/* Close archive and connection */
// TODO Proper try catch block with exception
try
{
try
{
archiveSiard
.
close
();
archiveSiard
.
close
();
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
// TODO Proper try catch block with exception
try
{
try
{
connect
.
rollback
();
connect
.
rollback
();
connect
.
close
();
connect
.
close
();
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
return
fileSiard
;
return
fileSiard
;
}
}
// private File exportDatabase() {
// Connection connect = null;
// /* Get good JDBC driver and open connection */
// String connectError = SiardConnection.getSiardConnection().loadDriver(siardConfig.getJdbcUrl());
//
// try {
// connect = DriverManager.getConnection(siardConfig.getJdbcUrl(), siardConfig.getUserDb(),
// siardConfig.getPasswordDb());
// connect.setAutoCommit(false);
// log.info("Connected to " + connect.getMetaData().getURL().toString());
// } catch (SQLException e) {
// throw new RuntimeException("Error when trying to connect to Database.", e);
// }
//
// /* Siard archive where database will be exported => Zip ? */
// Archive archiveSiard = ArchiveImpl.newInstance();
// /* Siard file where database will be exported */
// File fileSiard = siardConfig.getFileSiard();
//
// // Overwrite automatically
// if (fileSiard != null) {
// if (fileSiard.exists()) {
// fileSiard.delete();
// }
// }
//
// try {
// archiveSiard.create(fileSiard);
// } catch (IOException e) {
// throw new RuntimeException("Error when trying to create new SIARD file.", e);
// }
//
// /* Get Metadata from DB */
// MetaDataFromDb metadataDb;
// try {
// metadataDb = MetaDataFromDb.newInstance(connect.getMetaData(), archiveSiard.getMetaData());
// metadataDb.download(false, false, null);
// } catch (SQLException | IOException e) {
// throw new RuntimeException("Error when trying to get Metadata from DB.", e);
// }
//
// /* Get Primary data from DB */
// PrimaryDataFromDb primaryDataDb = PrimaryDataFromDb.newInstance(connect, archiveSiard);
// try {
// primaryDataDb.download(null);
// } catch (SQLException | IOException e) {
// throw new RuntimeException("Error when trying to get Primary data from DB.", e);
// }
//
// /* Close archive and connection */
// try {
// archiveSiard.close();
// } catch (IOException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// try {
// connect.rollback();
// connect.close();
// } catch (SQLException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
//
// return fileSiard;
// }
}
}
This diff is collapsed.
Click to expand it.
DLCM-Tools/src/test/java/ch/dlcm/test/tools/SiardTest.java
+
2
−
1
View file @
bf28a879
...
@@ -62,7 +62,8 @@ public class SiardTest {
...
@@ -62,7 +62,8 @@ public class SiardTest {
ZipTool
expectedZipTool
=
new
ZipTool
(
expectedSiardFile
.
toURI
());
ZipTool
expectedZipTool
=
new
ZipTool
(
expectedSiardFile
.
toURI
());
assertTrue
(
resultZipTool
.
checkZip
());
assertTrue
(
resultZipTool
.
checkZip
());
assertEquals
(
expectedZipTool
.
getEntryNumber
(),
resultZipTool
.
getEntryNumber
());
assertEquals
(
expectedZipTool
.
getEntryNumber
(),
resultZipTool
.
getEntryNumber
());
// assertEquals("database wrongly exported", expectedZipTool, resultZipTool); // TODO find a new way of comparing zip archives
// assertEquals("database wrongly exported", expectedZipTool, resultZipTool);
// TODO find a way oto compare zip archives content
}
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment