Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,19 @@ List<ProjectRecord> getSharedProjects(
Integer offset,
Long idUser);

List<ProjectRecord> getSharedProjectsByUser(
TableSort sort,
TableOrder order,
Integer limit,
Integer offset,
Long idUser);

int countUserProjects(Long idUser);

int countSharedProjects(Long idUser);

int countSharedProjectsByUser(Long idUser);

ProjectRecord cloneProject(Long idProject);

boolean deleteProject(Long idProject);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,34 @@ public List<ProjectRecord> getUserProjects(Long idUser, TableSort sort, TableOrd
public List<ProjectRecord> getSharedProjects(TableSort sort, TableOrder order, Integer limit, Integer offset, Long idUser) {
LOG.info("Retreive shared projects.");

SortField<?> orderField = sort == null ? Tables.PROJECT.NAME.asc() : sort.getField().asc();
if (TableOrder.desc == order) {
orderField = sort == null ? Tables.PROJECT.NAME.desc() : sort.getField().desc();
}
Condition conditions = Tables.PROJECT.SHARED.eq(Boolean.TRUE);
if (idUser != null) {
conditions = conditions.or(Tables.PROJECT.ID_USER.eq(idUser));
}
return create.selectFrom(Tables.PROJECT)
.where(conditions)
.orderBy(orderField).limit(limit).offset(offset)
.fetch();
}

/**
* TODO: add details.
*
* @param sort
* @param order
* @param limit
* @param offset
* @param idUser
* @return
*/
@Override
public List<ProjectRecord> getSharedProjectsByUser(TableSort sort, TableOrder order, Integer limit, Integer offset, Long idUser) {
LOG.info("Retreive shared projects.");

SortField<?> orderField = sort == null ? Tables.PROJECT.NAME.asc() : sort.getField().asc();
if (TableOrder.desc == order) {
orderField = sort == null ? Tables.PROJECT.NAME.desc() : sort.getField().desc();
Expand Down Expand Up @@ -385,6 +413,24 @@ public int countUserProjects(Long idUser) {
public int countSharedProjects(Long idUser) {
LOG.info("Count shared projects for user {}.", idUser);

Condition conditions = Tables.PROJECT.SHARED.equal(Boolean.TRUE);
if (idUser != null) {
conditions = conditions.or(Tables.PROJECT.ID_USER.eq(idUser));
}
return create.fetchCount(Tables.PROJECT, conditions);
}

/**
*
* TODO: add details.
*
* @param idUser
* @return
*/
@Override
public int countSharedProjectsByUser(Long idUser) {
LOG.info("Count shared projects for user {}.", idUser);

Condition conditions = Tables.PROJECT.SHARED.equal(Boolean.TRUE);
if (idUser != null) {
conditions = conditions.and(Tables.PROJECT.ID_USER.eq(idUser));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public List<ProjectRecord> getSharedProjects(TableSort sort, TableOrder order, I

@Override
public List<ProjectRecord> getSharedProjectsByUser(TableSort sort, TableOrder order, Integer limit, Integer offset, Long idUser) {
return projectDao.getSharedProjects(sort, order, limit, offset, idUser);
return projectDao.getSharedProjectsByUser(sort, order, limit, offset, idUser);
}

@Override
Expand All @@ -103,7 +103,7 @@ public int countSharedProjects() {

@Override
public int countSharedProjectsByUser(Long idUser) {
return projectDao.countSharedProjects(idUser);
return projectDao.countSharedProjectsByUser(idUser);
}

@Override
Expand Down