de.hs_rm.cs.lecturenotes.server.core.persistence
Class LectureSelectHandler

java.lang.Object
  extended by de.hs_rm.cs.lecturenotes.server.core.persistence.SQLConnection
      extended by de.hs_rm.cs.lecturenotes.server.core.persistence.LectureSelectHandler

public final class LectureSelectHandler
extends SQLConnection

Originates from SQLSelectHandler. Handles the "Editor" business database logic for Lecture and Paragraph. Processes also the Exercise paragraph children for PDF generation.

Version:
$LastChangedRevision: 274 $
Author:
Enrico Homann

Field Summary
 
Fields inherited from class de.hs_rm.cs.lecturenotes.server.core.persistence.SQLConnection
CHECK_DATABASE_TIMEOUT_SECONDS, DRIVER, JDBC_HOST_ENDPOINT, JDBC_URI, PASSWORD, USER
 
Constructor Summary
LectureSelectHandler(java.sql.Connection con)
          Constructor.
 
Method Summary
 long createParagraph(long position, long parent, long lectureId, java.lang.String title, java.lang.String content)
          Creates a Paragraph using the given parameters.
 boolean deleteParagraph(long paraId)
          Will soft remove a Paragraph.
 void fillExercisesForChildren(Paragraph paragraph)
          Fills parent paragraph and its children recursively with known Exercise objects from the database.
 ExerciseDAO getExerciseDAO()
          Will return the ExerciseDAO instance.
 LectureDAO getLectureDAO()
          Will return the LectureDAO instance.
 long getMaxParaId()
          Will return the current maximum paraId.
 long movePosition(long paraPosition, long parentId, long lectureId)
          Moves a Paragraph position.
 Lecture selectCompleteLectureByLectureId(long lectureId)
          Will return a Lecture and its Paragraph entities with complete contents from the database.
 Paragraph selectCompleteParagraph(long paraId)
          Will return a Paragraph for long paraId and its children, including their contents.
 Paragraph selectLatestVersionOfParagraph(long paraId)
          Will return the latest version of a Paragraph with contents but without children.
 Lecture selectLectureContentByLectureId(long lectureId)
          Will return a Lecture outline with Paragraph head data but without their contents.
 java.util.List<Paragraph> selectLectureParagraphFirstLevelChildrenByLectureId(long lectureId, boolean withContent)
          Will return a List of Paragraph entities from the database, including first level children.
 boolean updateParagraph(Paragraph para)
          Updates Paragraph para.
 
Methods inherited from class de.hs_rm.cs.lecturenotes.server.core.persistence.SQLConnection
connect, disconnect, executeCreateSQL, executeUpdateSQL, getConnection, isConnected, setConnection
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LectureSelectHandler

public LectureSelectHandler(java.sql.Connection con)
Constructor.

Parameters:
con - Connection
Method Detail

getLectureDAO

public LectureDAO getLectureDAO()
Will return the LectureDAO instance.

Returns:
LectureDAO

getExerciseDAO

public ExerciseDAO getExerciseDAO()
Will return the ExerciseDAO instance.

Returns:
ExerciseDAO

selectLectureParagraphFirstLevelChildrenByLectureId

public java.util.List<Paragraph> selectLectureParagraphFirstLevelChildrenByLectureId(long lectureId,
                                                                                     boolean withContent)
Will return a List of Paragraph entities from the database, including first level children.

Parameters:
lectureId - long
withContent - boolean
Returns:
List of Paragraph

selectCompleteLectureByLectureId

public Lecture selectCompleteLectureByLectureId(long lectureId)
Will return a Lecture and its Paragraph entities with complete contents from the database. Shall not be used for transport transfer due to performance issues. Used for server side PDF generation.

Parameters:
lectureId - long
Returns:
Lecture

fillExercisesForChildren

public void fillExercisesForChildren(Paragraph paragraph)
Fills parent paragraph and its children recursively with known Exercise objects from the database.

Parameters:
paragraph - Exercise

selectLectureContentByLectureId

public Lecture selectLectureContentByLectureId(long lectureId)
Will return a Lecture outline with Paragraph head data but without their contents.

Parameters:
lectureId - long
Returns:
Lecture

selectLatestVersionOfParagraph

public Paragraph selectLatestVersionOfParagraph(long paraId)
Will return the latest version of a Paragraph with contents but without children.

Parameters:
paraId - long
Returns:
Paragraph

selectCompleteParagraph

public Paragraph selectCompleteParagraph(long paraId)
Will return a Paragraph for long paraId and its children, including their contents.

Parameters:
paraId - long
Returns:
Paragraph

getMaxParaId

public long getMaxParaId()
Will return the current maximum paraId.

Returns:
long

updateParagraph

public boolean updateParagraph(Paragraph para)
Updates Paragraph para.

Parameters:
para - Paragraph
Returns:
boolean

createParagraph

public long createParagraph(long position,
                            long parent,
                            long lectureId,
                            java.lang.String title,
                            java.lang.String content)
Creates a Paragraph using the given parameters.

Parameters:
position - long
parent - long
lectureId - long
title - String
content - String
Returns:
long

movePosition

public long movePosition(long paraPosition,
                         long parentId,
                         long lectureId)
Moves a Paragraph position.

Parameters:
paraPosition - long
parentId - long
lectureId - long
Returns:
long

deleteParagraph

public boolean deleteParagraph(long paraId)
Will soft remove a Paragraph.

Parameters:
paraId - long
Returns:
boolean