Skip to content

Commit

Permalink
Remove unused update method
Browse files Browse the repository at this point in the history
  • Loading branch information
anarute committed Jun 21, 2022
1 parent 92e0b7a commit fa1d090
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 70 deletions.
49 changes: 0 additions & 49 deletions model/dao/TaskDAO/PostgreSQLTaskDAO.php
Original file line number Diff line number Diff line change
Expand Up @@ -835,55 +835,6 @@ private function checkOverlappingTasks($tasks) {
return true;
}

/** Task updater for PostgreSQL.
*
* This function updates the data of a Task by its {@link TaskVO}.
* WARNING: it doesn't check if task overlaps with other tasks, because that
* would be very expensive to do for every task. TaskDAO::batchCreate should
* be used for that purpose.
* TODO: consider making private or even removing.
*
* @param TaskVO $taskVO the {@link TaskVO} with the data we want to update on database.
* @return int the number of rows that have been affected (it should be 1).
* @throws {@link SQLQueryErrorException}, {@link SQLUniqueViolationException}
*/
public function update(TaskVO $taskVO) {
$affectedRows = 0;

if($taskVO->getId() != "") {
$currTaskVO = $this->getById($taskVO->getId());
}

// If the query returned a row then update
if(sizeof($currTaskVO) > 0) {

$sql = "UPDATE task SET _date=" . DBPostgres::formatDate($taskVO->getDate()) .
", init=" . DBPostgres::checkNull($taskVO->getInit()) .
", _end=" . DBPostgres::checkNull($taskVO->getEnd()) .
", story=" . DBPostgres::checkStringNull($taskVO->getStory()) .
", telework=" . DBPostgres::boolToString($taskVO->getTelework()) .
", onsite=" . DBPostgres::boolToString($taskVO->getOnsite()) .
", text=" . DBPostgres::checkStringNull($taskVO->getText()) .
", ttype=" . DBPostgres::checkStringNull($taskVO->getTtype()) .
", phase=" . DBPostgres::checkStringNull($taskVO->getPhase()) .
", usrid=" . DBPostgres::checkNull($taskVO->getUserId()) .
", projectid=" . DBPostgres::checkNull($taskVO->getProjectId()) .
" WHERE id=".$taskVO->getId();

$res = pg_query($this->connect, $sql);

if ($res == NULL)
if (strpos(pg_last_error(), "unique_task_usr_time"))
throw new SQLUniqueViolationException(pg_last_error());
else throw new SQLQueryErrorException(pg_last_error());

$affectedRows = pg_affected_rows($res);

}

return $affectedRows;
}

/** Task creator for PostgreSQL.
*
* This function creates a new row for a Task by its {@link TaskVO}.
Expand Down
21 changes: 0 additions & 21 deletions model/dao/TaskDAO/TaskDAO.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,6 @@ abstract class TaskDAO extends BaseDAO{
*/
protected $groupFields = array("USER" => "usrid", "PROJECT" => "projectid", "CUSTOMER" => "customerid", "TTYPE" => "ttype", "STORY" => "story");

/** Task DAO constructor.
*
* This is the base constructor of Task DAOs, and it just calls its parent's constructor.
*
* @throws {@link ConnectionErrorException}
* @see BaseDAO::__construct()
*/
protected function __construct() {
parent::__construct();
}

/** Task retriever by id.
*
* This function retrieves the row from Task table with the id <var>$taskId</var> and creates a {@link TaskVO} with its data.
Expand Down Expand Up @@ -250,16 +239,6 @@ public abstract function partialUpdate(DirtyTaskVO $taskVO);
*/
public abstract function batchPartialUpdate($tasks);

/** Task updater.
*
* This function updates the data of a Task by its {@link TaskVO}.
*
* @param TaskVO $taskVO the {@link TaskVO} with the data we want to update on database.
* @return int the number of rows that have been affected (it should be 1).
* @throws {@link OperationErrorException}, {@link SQLUniqueViolationException}
*/
public abstract function update(TaskVO $taskVO);

/** Task creator.
*
* This function creates a new row for a Task by its {@link TaskVO}.
Expand Down

0 comments on commit fa1d090

Please sign in to comment.