Skip to content
Snippets Groups Projects
Commit f18b9737 authored by Axel's avatar Axel
Browse files

Merge remote-tracking branch 'origin/development_master' into PhaseShifter

parents 0925673a 76d97422
No related branches found
No related tags found
No related merge requests found
......@@ -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");
......
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");
......
......@@ -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)
)
......
......@@ -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");
......
......@@ -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() {
......
......@@ -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");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment