diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/model/dao/JournalDAOImpl.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/model/dao/JournalDAOImpl.java index 0ea368909eb9cdb4679bf36b77d51ea11dc490e6..a0561e81639ef40ef3d2394980c90c618680c381 100644 --- a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/model/dao/JournalDAOImpl.java +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/model/dao/JournalDAOImpl.java @@ -26,7 +26,7 @@ public class JournalDAOImpl implements JournalDAO { connection.connect(); // build and execute request - String request = "INSERT INTO journals (`id`, `author`, `project`, `text`, `visibility`,`category`, `open` ) VALUES (?,?,?,?,?,?,?);"; + String request = "INSERT INTO journals (`id`, `studentId`, `projectId`, `text`, `visibility`,`category`, `open` ) VALUES (?,?,?,?,?,?,?);"; connection.issueInsertOrDeleteStatement(request, uuid, journal.getStudentIdentifier().getStudentId(), journal.getStudentIdentifier().getProjectId(), journal.getEntryMD(), journal.getVisibility(), journal.getCategory(), true); @@ -105,7 +105,7 @@ public class JournalDAOImpl implements JournalDAO { connection.connect(); // build and execute request - String request = "SELECT * FROM journals WHERE project= ? AND (author = ? OR visibility = \"ALL\" or visibility = \"GROUP\");"; + String request = "SELECT * FROM journals WHERE projectId= ? AND (studentId = ? OR visibility = \"ALL\" or visibility = \"GROUP\");"; VereinfachtesResultSet rs = connection.issueSelectStatement(request, project, student); while (rs.next()) { @@ -128,7 +128,7 @@ public class JournalDAOImpl implements JournalDAO { connection.connect(); // build and execute request - String request = "SELECT * FROM journals WHERE author= ?;"; + String request = "SELECT * FROM journals WHERE studentId= ?;"; VereinfachtesResultSet rs = connection.issueSelectStatement(request, student); while (rs.next()) { @@ -175,7 +175,7 @@ public class JournalDAOImpl implements JournalDAO { connection.connect(); // build and execute request - String request = "SELECT * FROM journals WHERE project = ? AND open = ?;"; + String request = "SELECT * FROM journals WHERE projectId = ? AND open = ?;"; VereinfachtesResultSet rs = connection.issueSelectStatement(request, project.getId(), true); while (rs.next()) { @@ -199,8 +199,8 @@ public class JournalDAOImpl implements JournalDAO { String id = rs.getString("id"); long timestamp = rs.getTimestamp(2).getTime(); - String student = rs.getString("author"); - String project = rs.getString("project"); + String student = rs.getString("studentId"); + String project = rs.getString("projectId"); String text = rs.getString("text"); String visibility = rs.getString("visibility"); String category = rs.getString("category"); diff --git a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/model/dao/ProjectDescriptionDAOImpl.java b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/model/dao/ProjectDescriptionDAOImpl.java index c0b07344e684abc9a2912d02f8be0b2486e12d06..6bd193c998db83cb1cf0a8d18d5c0703e5a24f51 100644 --- a/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/model/dao/ProjectDescriptionDAOImpl.java +++ b/gemeinsamforschen/src/main/java/unipotsdam/gf/modules/journal/model/dao/ProjectDescriptionDAOImpl.java @@ -1,7 +1,5 @@ package unipotsdam.gf.modules.journal.model.dao; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import unipotsdam.gf.core.database.mysql.MysqlConnect; import unipotsdam.gf.core.database.mysql.VereinfachtesResultSet; import unipotsdam.gf.core.management.project.Project; @@ -28,7 +26,7 @@ public class ProjectDescriptionDAOImpl implements ProjectDescriptionDAO { connection.connect(); // build and execute request - String request = "INSERT INTO projectdescription(`id`, `author`, `project`, `text`, `open`) VALUES (?,?,?,?,?);"; + String request = "INSERT INTO projectdescription(`id`, `studentId`, `projectId`, `text`, `open`) VALUES (?,?,?,?,?);"; connection.issueInsertOrDeleteStatement(request, uuid, projectDescription.getStudent().getStudentId(),projectDescription.getStudent().getProjectId(),projectDescription.getDescriptionMD(),true); //close connection @@ -57,7 +55,7 @@ public class ProjectDescriptionDAOImpl implements ProjectDescriptionDAO { connection.connect(); // build and execute request - String request = "SELECT * FROM projectdescription WHERE author = ? AND project = ?;"; + String request = "SELECT * FROM projectdescription WHERE studentId = ? AND projectId = ?;"; VereinfachtesResultSet rs = connection.issueSelectStatement(request, studentIdentifier.getStudentId(),studentIdentifier.getProjectId()); if (rs != null && rs.next()) { @@ -113,7 +111,7 @@ public class ProjectDescriptionDAOImpl implements ProjectDescriptionDAO { connection.connect(); // build and execute request - String request = "DELETE FROM projectdescription WHERE author = ? AND project = ?;"; + String request = "DELETE FROM projectdescription WHERE studentId = ? AND projectId = ?;"; connection.issueInsertOrDeleteStatement(request, studentIdentifier.getStudentId(),studentIdentifier.getProjectId()); // close connection @@ -145,7 +143,7 @@ public class ProjectDescriptionDAOImpl implements ProjectDescriptionDAO { connection.connect(); // build and execute request - String request = "SELECT * FROM projectdescription WHERE project = ? AND open = ?;"; + String request = "SELECT * FROM projectdescription WHERE projectId = ? AND open = ?;"; VereinfachtesResultSet rs = connection.issueSelectStatement(request, project.getId(), true); while (rs.next()) { @@ -161,8 +159,8 @@ public class ProjectDescriptionDAOImpl implements ProjectDescriptionDAO { private ProjectDescription getDescriptionFromResultSet(VereinfachtesResultSet rs) { String id = rs.getString("id"); long timestamp = rs.getTimestamp(2).getTime(); - String author = rs.getString("author"); - String project = rs.getString("project"); + String author = rs.getString("studentId"); + String project = rs.getString("projectId"); String text = rs.getString("text"); boolean open = rs.getBoolean("open"); diff --git a/gemeinsamforschen/src/scripts/dbschema/journal.sql b/gemeinsamforschen/src/scripts/dbschema/journal.sql index 16f050b3c5bba8230a1e136ffa4c86876c9f935d..e8e9ed5f3ab675341ce60e875c9611546c83f3a5 100644 --- a/gemeinsamforschen/src/scripts/dbschema/journal.sql +++ b/gemeinsamforschen/src/scripts/dbschema/journal.sql @@ -4,8 +4,8 @@ CREATE TABLE if not exists `journals` ( `id` varchar(400) NOT NULL, `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - `author` varchar(400) NOT NULL, - `project` varchar(400) NOT NULL, + `studentId` varchar(400) NOT NULL, + `projectId` varchar(400) NOT NULL, `text` text, `visibility` varchar(50), `category` varchar(50), @@ -18,8 +18,8 @@ CREATE TABLE if not exists `projectDescription` ( `id` varchar(400) NOT NULL, `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - `author` varchar(400) NOT NULL, - `project` varchar(400) NOT NULL, + `studentId` varchar(400) NOT NULL, + `projectId` varchar(400) NOT NULL, `text` text, `open` TINYINT(1) ) diff --git a/gemeinsamforschen/src/test/java/unipotsdam/gf/modules/journal/model/dao/JournalDAOImplTest.java b/gemeinsamforschen/src/test/java/unipotsdam/gf/modules/journal/model/dao/JournalDAOImplTest.java index 008ec65f6695807383dfcf4290acc293ef65e41a..d7d201f69c8a72f99538b3ba56cf9a3c32947891 100644 --- a/gemeinsamforschen/src/test/java/unipotsdam/gf/modules/journal/model/dao/JournalDAOImplTest.java +++ b/gemeinsamforschen/src/test/java/unipotsdam/gf/modules/journal/model/dao/JournalDAOImplTest.java @@ -31,8 +31,7 @@ public class JournalDAOImplTest { public void createJournal() { // Create Journal - Journal createJournal = testJournal; - journalDAO.createJournal(createJournal); + journalDAO.createJournal(testJournal); connection.connect(); @@ -108,13 +107,12 @@ public class JournalDAOImplTest { @Test public void deleteJournal() { - Journal deleteJournal = testJournal; //createJournal connection.connect(); // build and execute request - create(deleteJournal); + create(testJournal); //check if Journal was added ArrayList<Journal> resultJournals = getJournals(); @@ -138,14 +136,13 @@ public class JournalDAOImplTest { @Test public void getJournal() { - //create Journal - Journal getJournal = testJournal; + //createJournal connection.connect(); // build and execute request - create(getJournal); + create(testJournal); //get that Journal Journal resultJournal = journalDAO.getJournal(testId); @@ -224,8 +221,7 @@ public class JournalDAOImplTest { connection.connect(); //create Journal - Journal closeJournal = testJournal; - create(closeJournal); + create(testJournal); Journal resultJournal = getJournals().get(0); @@ -277,7 +273,7 @@ public class JournalDAOImplTest { //utility private ArrayList<Journal> getJournals() { - String request = "SELECT * FROM journals WHERE project= ?;"; + String request = "SELECT * FROM journals WHERE projectId= ?;"; VereinfachtesResultSet rs = connection.issueSelectStatement(request, testProject); ArrayList<Journal> resultJournals = new ArrayList<>(); @@ -288,7 +284,7 @@ public class JournalDAOImplTest { } private void create(Journal getJournal) { - String createRequest = "INSERT INTO journals (`id`, `author`, `project`, `text`, `visibility`,`category`, `open` ) VALUES (?,?,?,?,?,?,?);"; + String createRequest = "INSERT INTO journals (`id`, `studentId`, `projectId`, `text`, `visibility`,`category`, `open` ) VALUES (?,?,?,?,?,?,?);"; connection.issueInsertOrDeleteStatement(createRequest, getJournal.getId(), getJournal.getStudentIdentifier().getStudentId(), getJournal.getStudentIdentifier().getProjectId(), getJournal.getEntryMD(), getJournal.getVisibility(), getJournal.getCategory(), getJournal.isOpen()); } @@ -304,8 +300,8 @@ public class JournalDAOImplTest { String id = rs.getString("id"); long timestamp = rs.getTimestamp(2).getTime(); - String student = rs.getString("author"); - String project = rs.getString("project"); + String student = rs.getString("studentId"); + String project = rs.getString("projectId"); String text = rs.getString("text"); String visibility = rs.getString("visibility"); String category = rs.getString("category"); diff --git a/gemeinsamforschen/src/test/java/unipotsdam/gf/modules/journal/model/dao/LinkDAOImplTest.java b/gemeinsamforschen/src/test/java/unipotsdam/gf/modules/journal/model/dao/LinkDAOImplTest.java index 82b1b95d2e5711e2df937329a858027e26e3e982..151b6e7945671bcbb45c8d036a0b55cda4723915 100644 --- a/gemeinsamforschen/src/test/java/unipotsdam/gf/modules/journal/model/dao/LinkDAOImplTest.java +++ b/gemeinsamforschen/src/test/java/unipotsdam/gf/modules/journal/model/dao/LinkDAOImplTest.java @@ -12,14 +12,14 @@ import static org.junit.Assert.assertFalse; public class LinkDAOImplTest { - MysqlConnect connection = new MysqlConnect(); - LinkDAO linkDAO = new LinkDAOImpl(); - - String testId = "-1"; - String testProjectDescription = "testproject"; - String testName = "testname"; - String testLink = "https://www.test.de"; - Link testLinkObj = new Link(testId, testProjectDescription, testName, testLink); + private final MysqlConnect connection = new MysqlConnect(); + private final LinkDAO linkDAO = new LinkDAOImpl(); + + private final String testId = "-1"; + private final String testProjectDescription = "testproject"; + private final String testName = "testname"; + private final String testLink = "https://www.test.de"; + private final Link testLinkObj = new Link(testId, testProjectDescription, testName, testLink); @Test public void addLink() { diff --git a/gemeinsamforschen/src/test/java/unipotsdam/gf/modules/journal/model/dao/ProjectDescriptionImplDAOTest.java b/gemeinsamforschen/src/test/java/unipotsdam/gf/modules/journal/model/dao/ProjectDescriptionImplDAOTest.java index c63a1b8d70c2fd9251cab2852516f55a11966741..bcc98003103ad7c5d13e95336266e32b67657595 100644 --- a/gemeinsamforschen/src/test/java/unipotsdam/gf/modules/journal/model/dao/ProjectDescriptionImplDAOTest.java +++ b/gemeinsamforschen/src/test/java/unipotsdam/gf/modules/journal/model/dao/ProjectDescriptionImplDAOTest.java @@ -9,21 +9,19 @@ import unipotsdam.gf.modules.journal.model.ProjectDescription; import java.util.ArrayList; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.*; public class ProjectDescriptionImplDAOTest { private final ProjectDescriptionDAO descriptionDAO = new ProjectDescriptionDAOImpl(); private final MysqlConnect connection = new MysqlConnect(); - private String testId = "-1"; - private String testStudent = "testStudent"; - private String testDescription = "testDescription"; - private String testProjekt = "testProjekt"; + private final String testId = "-1"; + private final String testStudent = "testStudent"; + private final String testDescription = "testDescription"; + private final String testProjekt = "testProjekt"; - private ProjectDescription testProjectDescription = new ProjectDescription(testId, testStudent, testDescription, testProjekt, null /*Links are added in Service*/); + private final ProjectDescription testProjectDescription = new ProjectDescription(testId, testStudent, testDescription, testProjekt, null /*Links are added in Service*/); @Test public void createDescription() { @@ -82,9 +80,7 @@ public class ProjectDescriptionImplDAOTest { public void getDescriptionSI() { connection.connect(); - ProjectDescription getDescription = testProjectDescription; - - create(getDescription); + create(testProjectDescription); ProjectDescription result = descriptionDAO.getDescription(new StudentIdentifier(testProjekt, testStudent)); @@ -101,9 +97,7 @@ public class ProjectDescriptionImplDAOTest { public void getDescriptionID() { connection.connect(); - ProjectDescription getDescription = testProjectDescription; - - create(getDescription); + create(testProjectDescription); ProjectDescription result = descriptionDAO.getDescription(testId); @@ -120,9 +114,7 @@ public class ProjectDescriptionImplDAOTest { public void deleteDescription() { connection.connect(); - ProjectDescription deleteDescription = testProjectDescription; - - create(deleteDescription); + create(testProjectDescription); ArrayList<ProjectDescription> resultDescriptions = getProjectDescription(); @@ -143,9 +135,7 @@ public class ProjectDescriptionImplDAOTest { public void closeDescription() { connection.connect(); - ProjectDescription closeDescription = testProjectDescription; - - create(closeDescription); + create(testProjectDescription); ArrayList<ProjectDescription> resultDescriptions = getProjectDescription(); @@ -189,7 +179,7 @@ public class ProjectDescriptionImplDAOTest { //Utility private ArrayList<ProjectDescription> getProjectDescription() { - String request = "SELECT * FROM projectdescription WHERE project=?;"; + String request = "SELECT * FROM projectdescription WHERE projectId=?;"; VereinfachtesResultSet rs = connection.issueSelectStatement(request, testProjekt); ArrayList<ProjectDescription> resultDescriptions = new ArrayList<>(); @@ -200,7 +190,7 @@ public class ProjectDescriptionImplDAOTest { } private void create(ProjectDescription projectDescription) { - String request = "INSERT INTO projectdescription(`id`, `author`, `project`, `text`, `open`) VALUES (?,?,?,?,?);"; + String request = "INSERT INTO projectdescription(`id`, `studentId`, `projectId`, `text`, `open`) VALUES (?,?,?,?,?);"; connection.issueInsertOrDeleteStatement(request, projectDescription.getId(), projectDescription.getStudent().getStudentId(), projectDescription.getStudent().getProjectId(), projectDescription.getDescriptionMD(), projectDescription.isOpen()); } @@ -214,8 +204,8 @@ public class ProjectDescriptionImplDAOTest { private ProjectDescription getDescriptionFromResultSet(VereinfachtesResultSet rs) { String id = rs.getString("id"); long timestamp = rs.getTimestamp(2).getTime(); - String author = rs.getString("author"); - String project = rs.getString("project"); + String author = rs.getString("studentId"); + String project = rs.getString("projectId"); String text = rs.getString("text"); boolean open = rs.getBoolean("open");