// Path: services/src/main/java/org/exoplatform/task/dto/ProjectDto.java
// @Data
// @NoArgsConstructor
// public class ProjectDto implements Serializable {
//     private static final Log LOG           = ExoLogger.getLogger(ProjectDto.class);
// 
// 
//     private long      id;
// 
//     private String    name;
// 
//     private String    description;
// 
//     private String    color;
// 
//     private Set<StatusDto> status ;
// 
//     private Set<String> manager;
// 
//     private Set<String> participator;
// 
//     private Date dueDate;
// 
//     private Long lastModifiedDate;;
// 
//     private ProjectDto parent;
// 
//     private List<ProjectDto> children;
// 
//     private Set<UserSetting> hiddenOn;
// 
//     private String spaceName;
// 
//     public ProjectDto(String name, String description, HashSet<StatusDto> statuses, Set<String> managers, Set<String> participators) {
//         this.name=name;
//         this.description=description;
//         this.status=statuses;
//         this.manager=managers;
//         this.participator=participators;
//     }
// 
// 
//     public ProjectDto clone(boolean cloneTask) {
//         ProjectDto project = new ProjectDto();
//         project.setId(getId());
//         project.setName(this.getName());
//         project.setDescription(this.getDescription());
//         project.setColor(this.getColor());
//         project.setDueDate(this.getDueDate());
//         if (this.getParent() != null) {
//             project.setParent(getParent().clone(false));
//         }
//         project.status = new HashSet<StatusDto>();
//         project.children = new LinkedList<ProjectDto>();
// 
//         return project;
//     }
// 
//     public boolean canView(Identity user) {
//         Set<String> permissions = new HashSet<String>();
//         Set<String> Participants = getParticipator();
//         Set<String> managers = getManager();
//         if(Participants!=null){
//             permissions.addAll(Participants);
//         }
//         if(managers!=null){
//             permissions.addAll(managers);
//         }
//         return hasPermission(user, permissions);
//     }
// 
//     public boolean canEdit(Identity user) {
//         return hasPermission(user, getManager());
//     }
// 
//     private boolean hasPermission(Identity user, Set<String> permissions) {
//         if (permissions.contains(user.getUserId())) {
//             return true;
//         } else {
//             Set<MembershipEntry> memberships = new HashSet<MembershipEntry>();
//             for (String per : permissions) {
//                 MembershipEntry entry = MembershipEntry.parse(per);
//                 if (entry != null) {
//                     memberships.add(entry);
//                 }
//             }
// 
//             for (MembershipEntry entry :  user.getMemberships()) {
//                 if (memberships.contains(entry)) {
//                     return true;
//                 }
//             }
//         }
// 
//         return false;
//     }
// 
//     @Override
//     public boolean equals(Object obj) {
//         if (this == obj)
//             return true;
//         if (obj == null)
//             return false;
//         if (!(obj instanceof ProjectDto))
//             return false;
//         ProjectDto other = (ProjectDto) obj;
//         if (getId() != other.getId())
//             return false;
//         return true;
//     }
// 
// }


import org.exoplatform.commons.utils.ListAccess;
import org.exoplatform.task.dao.OrderBy;
import org.exoplatform.task.dao.ProjectQuery;
import org.exoplatform.task.dto.ProjectDto;
import org.exoplatform.task.exception.EntityNotFoundException;
import java.util.List;
import java.util.Set;
package org.exoplatform.task.service;




public interface ProjectService {

    /**
     * Return the project with given <code>projectId</code>.
     *
     * @param projectId the project id.
     * @return get the given project.
     * @throws EntityNotFoundException when user is not authorized to get project.
     */
    ProjectDto getProject(Long projectId) throws EntityNotFoundException;

    List<ProjectDto> findCollaboratedProjects(String userName, String keyword, int offset, int limit);

    List<ProjectDto> findNotEmptyProjects(List<String> memberships, String keyword, int offset, int limit);

    int countCollaboratedProjects(String userName, String keyword);

    int countNotEmptyProjects(List<String> memberships, String keyword);

    int countProjects(List<String> memberships, String keyword);

    Set<String> getManager(long projectId);

    Set<String> getParticipator(long projectId);

    /**
     * Create a project with given <code>project</code> model object.
     *
     * @param project the given project.
     * @return create the given project.
     */
    ProjectDto createProject(ProjectDto project);

    /**
     * Create a sub-project with given <code>project</code> model object and parent project ID.
     *
     * @param project  the project metadata to create.
     * @param parentId parent project ID
     * @return Create a sub-project.
     * @throws EntityNotFoundException the project associated with <code>parentId</code> doesn't exist.
     */
    ProjectDto createProject(ProjectDto project, long parentId) throws EntityNotFoundException;

    /**
     * Update the project.
     * <p>
     * It should throws EntityNotFoundException if the project has been removed OR not existed from database.
     *
     * @param project the given project.

     */
// Path: services/src/main/java/org/exoplatform/task/dto/ProjectDto.java
// @Data
// @NoArgsConstructor
// public class ProjectDto implements Serializable {
//     private static final Log LOG           = ExoLogger.getLogger(ProjectDto.class);
// 
// 
//     private long      id;
// 
//     private String    name;
// 
//     private String    description;
// 
//     private String    color;
// 
//     private Set<StatusDto> status ;
// 
//     private Set<String> manager;
// 
//     private Set<String> participator;
// 
//     private Date dueDate;
// 
//     private Long lastModifiedDate;;
// 
//     private ProjectDto parent;
// 
//     private List<ProjectDto> children;
// 
//     private Set<UserSetting> hiddenOn;
// 
//     private String spaceName;
// 
//     public ProjectDto(String name, String description, HashSet<StatusDto> statuses, Set<String> managers, Set<String> participators) {
//         this.name=name;
//         this.description=description;
//         this.status=statuses;
//         this.manager=managers;
//         this.participator=participators;
//     }
// 
// 
//     public ProjectDto clone(boolean cloneTask) {
//         ProjectDto project = new ProjectDto();
//         project.setId(getId());
//         project.setName(this.getName());
//         project.setDescription(this.getDescription());
//         project.setColor(this.getColor());
//         project.setDueDate(this.getDueDate());
//         if (this.getParent() != null) {
//             project.setParent(getParent().clone(false));
//         }
//         project.status = new HashSet<StatusDto>();
//         project.children = new LinkedList<ProjectDto>();
// 
//         return project;
//     }
// 
//     public boolean canView(Identity user) {
//         Set<String> permissions = new HashSet<String>();
//         Set<String> Participants = getParticipator();
//         Set<String> managers = getManager();
//         if(Participants!=null){
//             permissions.addAll(Participants);
//         }
//         if(managers!=null){
//             permissions.addAll(managers);
//         }
//         return hasPermission(user, permissions);
//     }
// 
//     public boolean canEdit(Identity user) {
//         return hasPermission(user, getManager());
//     }
// 
//     private boolean hasPermission(Identity user, Set<String> permissions) {
//         if (permissions.contains(user.getUserId())) {
//             return true;
//         } else {
//             Set<MembershipEntry> memberships = new HashSet<MembershipEntry>();
//             for (String per : permissions) {
//                 MembershipEntry entry = MembershipEntry.parse(per);
//                 if (entry != null) {
//                     memberships.add(entry);
//                 }
//             }
// 
//             for (MembershipEntry entry :  user.getMemberships()) {
//                 if (memberships.contains(entry)) {
//                     return true;
//                 }
//             }
//         }
// 
//         return false;
//     }
// 
//     @Override
//     public boolean equals(Object obj) {
//         if (this == obj)
//             return true;
//         if (obj == null)
//             return false;
//         if (!(obj instanceof ProjectDto))
//             return false;
//         ProjectDto other = (ProjectDto) obj;
//         if (getId() != other.getId())
//             return false;
//         return true;
//     }
// 
// }


// Path: services/src/main/java/org/exoplatform/task/service/ProjectService.java
import org.exoplatform.commons.utils.ListAccess;
import org.exoplatform.task.dao.OrderBy;
import org.exoplatform.task.dao.ProjectQuery;
import org.exoplatform.task.dto.ProjectDto;
import org.exoplatform.task.exception.EntityNotFoundException;
import java.util.List;
import java.util.Set;

package org.exoplatform.task.service;




public interface ProjectService {

    /**
     * Return the project with given <code>projectId</code>.
     *
     * @param projectId the project id.
     * @return get the given project.
     * @throws EntityNotFoundException when user is not authorized to get project.
     */
    ProjectDto getProject(Long projectId) throws EntityNotFoundException;

    List<ProjectDto> findCollaboratedProjects(String userName, String keyword, int offset, int limit);

    List<ProjectDto> findNotEmptyProjects(List<String> memberships, String keyword, int offset, int limit);

    int countCollaboratedProjects(String userName, String keyword);

    int countNotEmptyProjects(List<String> memberships, String keyword);

    int countProjects(List<String> memberships, String keyword);

    Set<String> getManager(long projectId);

    Set<String> getParticipator(long projectId);

    /**
     * Create a project with given <code>project</code> model object.
     *
     * @param project the given project.
     * @return create the given project.
     */
    ProjectDto createProject(ProjectDto project);

    /**
     * Create a sub-project with given <code>project</code> model object and parent project ID.
     *
     * @param project  the project metadata to create.
     * @param parentId parent project ID
     * @return Create a sub-project.
     * @throws EntityNotFoundException the project associated with <code>parentId</code> doesn't exist.
     */
    ProjectDto createProject(ProjectDto project, long parentId) throws EntityNotFoundException;

    /**
     * Update the project.
     * <p>
     * It should throws EntityNotFoundException if the project has been removed OR not existed from database.
     *
     * @param project the given project.

     */
    void updateProjectNoReturn(ProjectDto project);