@@ -347,6 +347,34 @@ public List<ProjectRecord> getUserProjects(Long idUser, TableSort sort, TableOrd
347347 public List <ProjectRecord > getSharedProjects (TableSort sort , TableOrder order , Integer limit , Integer offset , Long idUser ) {
348348 LOG .info ("Retreive shared projects." );
349349
350+ SortField <?> orderField = sort == null ? Tables .PROJECT .NAME .asc () : sort .getField ().asc ();
351+ if (TableOrder .desc == order ) {
352+ orderField = sort == null ? Tables .PROJECT .NAME .desc () : sort .getField ().desc ();
353+ }
354+ Condition conditions = Tables .PROJECT .SHARED .eq (Boolean .TRUE );
355+ if (idUser != null ) {
356+ conditions = conditions .or (Tables .PROJECT .ID_USER .eq (idUser ));
357+ }
358+ return create .selectFrom (Tables .PROJECT )
359+ .where (conditions )
360+ .orderBy (orderField ).limit (limit ).offset (offset )
361+ .fetch ();
362+ }
363+
364+ /**
365+ * TODO: add details.
366+ *
367+ * @param sort
368+ * @param order
369+ * @param limit
370+ * @param offset
371+ * @param idUser
372+ * @return
373+ */
374+ @ Override
375+ public List <ProjectRecord > getSharedProjectsByUser (TableSort sort , TableOrder order , Integer limit , Integer offset , Long idUser ) {
376+ LOG .info ("Retreive shared projects." );
377+
350378 SortField <?> orderField = sort == null ? Tables .PROJECT .NAME .asc () : sort .getField ().asc ();
351379 if (TableOrder .desc == order ) {
352380 orderField = sort == null ? Tables .PROJECT .NAME .desc () : sort .getField ().desc ();
@@ -385,6 +413,24 @@ public int countUserProjects(Long idUser) {
385413 public int countSharedProjects (Long idUser ) {
386414 LOG .info ("Count shared projects for user {}." , idUser );
387415
416+ Condition conditions = Tables .PROJECT .SHARED .equal (Boolean .TRUE );
417+ if (idUser != null ) {
418+ conditions = conditions .or (Tables .PROJECT .ID_USER .eq (idUser ));
419+ }
420+ return create .fetchCount (Tables .PROJECT , conditions );
421+ }
422+
423+ /**
424+ *
425+ * TODO: add details.
426+ *
427+ * @param idUser
428+ * @return
429+ */
430+ @ Override
431+ public int countSharedProjectsByUser (Long idUser ) {
432+ LOG .info ("Count shared projects for user {}." , idUser );
433+
388434 Condition conditions = Tables .PROJECT .SHARED .equal (Boolean .TRUE );
389435 if (idUser != null ) {
390436 conditions = conditions .and (Tables .PROJECT .ID_USER .eq (idUser ));
0 commit comments