@@ -839,16 +839,28 @@ private function checkOverlappingTasks($tasks) {
839
839
*
840
840
* This function creates a new row for a Task by its {@link TaskVO}.
841
841
* The internal id of <var>$taskVO</var> will be set after its creation.
842
- * WARNING: it doesn't check if task overlaps with other tasks, because that
843
- * would be very expensive to do for every task. TaskDAO::batchCreate should
844
- * be used for that purpose.
845
- * TODO: consider making private.
846
842
*
847
843
* @param TaskVO $taskVO the {@link TaskVO} with the data we want to insert on database.
848
844
* @return int the number of rows that have been affected (it should be 1).
849
845
* @throws {@link SQLQueryErrorException}, {@link SQLUniqueViolationException}
850
846
*/
851
847
public function create (TaskVO $ taskVO ) {
848
+ $ tasks = array ($ taskVO );
849
+ return $ this ->batchCreate ($ tasks );
850
+ }
851
+
852
+ /** Task creator for PostgreSQL.
853
+ *
854
+ * This function creates a new row for a Task by its {@link TaskVO}.
855
+ * The internal id of <var>$taskVO</var> will be set after its creation.
856
+ * WARNING: it doesn't check if task overlaps with other tasks.
857
+ * TaskDAO::create and TaskDAO::batchCreate should be used for that purpose.
858
+ *
859
+ * @param TaskVO $taskVO the {@link TaskVO} with the data we want to insert on database.
860
+ * @return int the number of rows that have been affected (it should be 1).
861
+ * @throws {@link SQLQueryErrorException}, {@link SQLUniqueViolationException}
862
+ */
863
+ private function createInternal (TaskVO $ taskVO ) {
852
864
$ affectedRows = 0 ;
853
865
854
866
$ sql = "INSERT INTO task ( " .
@@ -894,6 +906,15 @@ public function create(TaskVO $taskVO) {
894
906
895
907
}
896
908
909
+ /** Task batch creator.
910
+ *
911
+ * Equivalent to {@see create} for arrays of tasks.
912
+ *
913
+ * @param array $tasks array of {@link TaskVO} objects to be created.
914
+ * @return int the number of rows that have been affected (it should be
915
+ * equal to the size of $tasks).
916
+ * @throws {@link SQLQueryErrorException}
917
+ */
897
918
public function batchCreate ($ tasks ) {
898
919
if (!$ this ->checkOverlappingWithDBTasks ($ tasks )) {
899
920
return 0 ;
@@ -902,7 +923,7 @@ public function batchCreate($tasks) {
902
923
$ affectedRows = 0 ;
903
924
904
925
foreach ($ tasks as $ task ) {
905
- $ affectedRows += $ this ->create ($ task );
926
+ $ affectedRows += $ this ->createInternal ($ task );
906
927
}
907
928
908
929
return $ affectedRows ;
0 commit comments