org.telscenter.sail.webapp.service.project.impl
Class ExternalProjectServiceImpl

java.lang.Object
  extended by org.telscenter.sail.webapp.service.project.impl.ExternalProjectServiceImpl
All Implemented Interfaces:
ExternalProjectService, ProjectService

public class ExternalProjectServiceImpl
extends Object
implements ExternalProjectService

DIY Project Service implementation. Speaks to the DIY portal remotely.

Version:
$Id$
Author:
Hiroki Terashima, Scott Cytacki

Field Summary
protected  ProjectDao<Project> projectDao
           
protected  WorkgroupDao<Workgroup> workgroupDao
           
 
Constructor Summary
ExternalProjectServiceImpl()
           
 
Method Summary
 void addBookmarkerToProject(Project project, User bookmarker)
          Adds the given User bookmarker to the Project project
 void addSharedTeacherToProject(AddSharedTeacherParameters addSharedTeacherParameters)
           
 Long addTagToProject(String tag, Long projectId)
          Given a String and a Project adds the tag to the project.
 Long addTagToProject(Tag tag, Long projectId)
          Given a Tag tag and a Long project id adds the given tag to the project.
 Object authorProject(AuthorProjectParameters authorProjectParameters)
          Allows users to author a project
 boolean canAuthorProject(Project project, User user)
          Given a Project project and User user, returns boolean true if the user is allowed to author that particular project, returns false otherwise.
 boolean canCreateRun(Project project, User user)
          Given a Project project and User user, returns boolean true if the user is allowed to create a run from that project (ie, project is TELS, owner, sharedOwner), returns false otherwise.
 boolean canReadProject(Project project, User user)
          Given a Project project and a User user, returns boolean true if the user has read access to that particular project, returns false otherwise.
 Project createProject(ProjectParameters projectParameters)
          Creates a new Project Also, this creates a "Preview run"- that is, a run that is used just for the purpose of previewing this project.
 String getActiveVersion(Project project)
           
 List<Project> getAdminProjectList()
          Returns a List list of all projects in the data store.
 List<Project> getAllProjectsList()
          Get a List of Project
 List<Project> getBookmarkerProjectList(User user)
          Retrieves a List of Project that has been bookmarked by the given User
 Project getById(Serializable projectId)
          Gets a project with the given projectid
 List<ExternalProject> getExternalProjectList()
           
 ProjectMetadata getMetadata(Long projectId)
          Given a Long projectId returns the ProjectMetadata that is associated with that projectId and versionId, if one exists, returns null otherwise.
 ProjectCommunicator getProjectCommunicator()
           
 ProjectCommunicatorDao<ProjectCommunicator> getProjectCommunicatorDao()
           
 List<Project> getProjectCopies(Long projectId)
          Given a project id, returns projects that are copies of the project
 ProjectDao<Project> getProjectDao()
           
 Project getProjectFull(Long projectId)
           
 List<Project> getProjectList()
          Get a List of Project
 List<Project> getProjectList(String query)
          Given a String query, returns a List of Project that satisfies the query.
 List<Project> getProjectList(User user)
          Get a List of Project that the specified user owns
 List<Project> getProjectListByInfo(ProjectInfo info)
          Get a List of Project with matching ProjectInfo
 List<Project> getProjectListByTag(FamilyTag tag)
          Get a List of Project with matching FamilyTag
 List<Project> getProjectListByTag(String tag)
          Get a List of Project with matching ProjectInfoTag
 List<Project> getProjectListByTagName(String tagName)
          Given a String tag name, returns a List list of projects with that tag.
 List<Project> getProjectListByTagNames(Set<String> tagNames)
          Given a Set set of tag names, returns a List list of projects with all of the tag names.
 JSONObject getProjectMetadataFile(Project project)
           
 List<Project> getSharedProjectList(User user)
          Get a List of Project that have been shared with the specified user.
 String getSharedTeacherRole(Project project, User user)
          Returns the permission that the specified user has on the specified project
 WorkgroupDao<Workgroup> getWorkgroupDao()
           
 Long identifyRootProjectId(Project projectId)
          Given a project, gets the project id for the project's root level project
 void importProject(Long externalId, Serializable projectCommunicatorId)
           
 boolean isAuthorizedToCreateTag(User user, String name)
          Given a User user and a String tag name, returns true if that user is authorized to create a tag with that name, returns false otherwise.
 Object launchProject(LaunchProjectParameters launchProjectParameters)
          Launches the project given the launchProjectParameters
 Object launchReport(LaunchReportParameters launchReportParameters)
          Launches the report given the launchReportParameters
 String minifyProject(Project project)
          Given a Project project, attempts to minify a file and returns a String of the final status of the operation.
 Object previewProject(PreviewProjectParameters previewProjectParameters)
          Launches a Preview of the Project
 boolean projectContainsTag(Long projectId, String name)
          Given a Long project id and a String tag name, returns boolean true if the project contains a tag with that name, false otherwise.
 void removeBookmarkerFromProject(Project project, User bookmarker)
          Removes the given User bookmarker from the Project project
 void removeSharedTeacherFromProject(String username, Project project)
          Removes shared user from project.
 void removeTagFromProject(Long tagId, Long projectId)
          Given a Tag and a Project, removes the tag from the project.
 void setProjectCommunicator(ProjectCommunicator projectCommunicator)
           
 void setProjectCommunicatorDao(ProjectCommunicatorDao<ProjectCommunicator> projectCommunicatorDao)
           
 void setProjectDao(ProjectDao<Project> projectDao)
           
 void setRunService(RunService runService)
           
 void setWorkgroupDao(WorkgroupDao<Workgroup> workgroupDao)
           
 void sortProjectsByDateCreated(List<Project> projectList)
          Sorts the given List list of projects by the date they were created.
 String takeSnapshot(Project project, String username, String snapshotName)
           
 void updateProject(Project project, User user)
          Saves the project
 Long updateTag(Long tagId, Long projectId, String name)
          Given a Long tag id, a Long project id and a String name, updates that project tag to that name, returning the resulting Long tag Id.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

projectDao

protected ProjectDao<Project> projectDao

workgroupDao

protected WorkgroupDao<Workgroup> workgroupDao
Constructor Detail

ExternalProjectServiceImpl

public ExternalProjectServiceImpl()
Method Detail

setRunService

public void setRunService(RunService runService)
Parameters:
runService - the runService to set

authorProject

public Object authorProject(AuthorProjectParameters authorProjectParameters)
                     throws Exception
Description copied from interface: ProjectService
Allows users to author a project

Specified by:
authorProject in interface ProjectService
Returns:
Throws:
Exception
See Also:
ProjectService.authorProject(org.telscenter.sail.webapp.domain.project.impl.AuthorProjectParameters)

createProject

public Project createProject(ProjectParameters projectParameters)
                      throws ObjectNotFoundException
Description copied from interface: ProjectService
Creates a new Project Also, this creates a "Preview run"- that is, a run that is used just for the purpose of previewing this project. This is not the ideal solution to Previewing a Project, but the other solution is too much work (making a new JNLP project that takes in curniturl and jnlpurl). The author can also always use the authoring tool to preview the project

Specified by:
createProject in interface ProjectService
Returns:
the Project that was created
Throws:
ObjectNotFoundException - when projectparameters references curnitId and jnlpId that do not exist
See Also:
ProjectService.createProject(org.telscenter.sail.webapp.domain.impl.ProjectParameters)

getById

public Project getById(Serializable projectId)
                throws ObjectNotFoundException
Description copied from interface: ProjectService
Gets a project with the given projectid

Specified by:
getById in interface ProjectService
Parameters:
projectId - the id of the project
Returns:
Project with the specified projectId
Throws:
ObjectNotFoundException - when the specified projectId does not exist
See Also:
ProjectService.getById(java.io.Serializable)

getExternalProjectList

public List<ExternalProject> getExternalProjectList()
Specified by:
getExternalProjectList in interface ExternalProjectService
See Also:
ExternalProjectService.getExternalProjectList()

importProject

@Transactional
public void importProject(Long externalId,
                                        Serializable projectCommunicatorId)
                   throws ObjectNotFoundException
Specified by:
importProject in interface ExternalProjectService
Throws:
ObjectNotFoundException
See Also:
org.telscenter.sail.webapp.service.project.ExternalProjectService#importProject(org.telscenter.sail.webapp.domain.project.ExternalProject)

getProjectList

public List<Project> getProjectList()
Description copied from interface: ProjectService
Get a List of Project

Specified by:
getProjectList in interface ProjectService
Returns:
a List of Project
See Also:
ProjectService.getProjectList()

getProjectListByInfo

public List<Project> getProjectListByInfo(ProjectInfo info)
                                   throws ObjectNotFoundException
Description copied from interface: ProjectService
Get a List of Project with matching ProjectInfo

Specified by:
getProjectListByInfo in interface ProjectService
Returns:
a List of Project
Throws:
ObjectNotFoundException
See Also:
ProjectService.getProjectListByInfo(org.telscenter.sail.webapp.domain.project.ProjectInfo)

getProjectListByTag

public List<Project> getProjectListByTag(FamilyTag tag)
                                  throws ObjectNotFoundException
Description copied from interface: ProjectService
Get a List of Project with matching FamilyTag

Specified by:
getProjectListByTag in interface ProjectService
Returns:
a List of Project
Throws:
ObjectNotFoundException
See Also:
ProjectService.getProjectListByTag(org.telscenter.sail.webapp.domain.project.FamilyTag)

getProjectListByTag

public List<Project> getProjectListByTag(String tag)
                                  throws ObjectNotFoundException
Description copied from interface: ProjectService
Get a List of Project with matching ProjectInfoTag

Specified by:
getProjectListByTag in interface ProjectService
Returns:
a List of Project
Throws:
ObjectNotFoundException
See Also:
ProjectService.getProjectListByTag(java.lang.String)

launchProject

@Transactional(readOnly=false)
public Object launchProject(LaunchProjectParameters launchProjectParameters)
                     throws Exception
Description copied from interface: ProjectService
Launches the project given the launchProjectParameters

Specified by:
launchProject in interface ProjectService
Parameters:
launchProjectParameters - parameters needed to launch the project
Throws:
Exception
See Also:
ProjectService.launchProject(org.telscenter.sail.webapp.domain.project.impl.LaunchProjectParameters)

launchReport

public Object launchReport(LaunchReportParameters launchReportParameters)
Description copied from interface: ProjectService
Launches the report given the launchReportParameters

Specified by:
launchReport in interface ProjectService
Returns:
See Also:
ProjectService.launchReport(org.telscenter.sail.webapp.domain.project.impl.LaunchReportParameters)

previewProject

public Object previewProject(PreviewProjectParameters previewProjectParameters)
                      throws Exception
Description copied from interface: ProjectService
Launches a Preview of the Project

Specified by:
previewProject in interface ProjectService
Throws:
ObjectNotFoundException - when the specified projectId does not exist
IOException - when the url cannot be loaded
Exception
See Also:
ProjectService.previewProject(org.telscenter.sail.webapp.domain.project.impl.PreviewProjectParameters)

updateProject

@Transactional
public void updateProject(Project project,
                                        User user)
Description copied from interface: ProjectService
Saves the project

Specified by:
updateProject in interface ProjectService
Parameters:
project - Project contains updated Project.
See Also:
org.telscenter.sail.webapp.service.project.ProjectService#updateProject(org.telscenter.sail.webapp.domain.project.Project)

getProjectDao

public ProjectDao<Project> getProjectDao()
Returns:
the projectDao

setProjectDao

public void setProjectDao(ProjectDao<Project> projectDao)
Parameters:
projectDao - the projectDao to set

getProjectCommunicatorDao

public ProjectCommunicatorDao<ProjectCommunicator> getProjectCommunicatorDao()
Returns:
the projectCommunicatorDao

setProjectCommunicatorDao

public void setProjectCommunicatorDao(ProjectCommunicatorDao<ProjectCommunicator> projectCommunicatorDao)
Parameters:
projectCommunicatorDao - the projectCommunicatorDao to set

getProjectCommunicator

public ProjectCommunicator getProjectCommunicator()
Specified by:
getProjectCommunicator in interface ExternalProjectService

setProjectCommunicator

public void setProjectCommunicator(ProjectCommunicator projectCommunicator)
Specified by:
setProjectCommunicator in interface ExternalProjectService

addSharedTeacherToProject

public void addSharedTeacherToProject(AddSharedTeacherParameters addSharedTeacherParameters)
                               throws ObjectNotFoundException
Specified by:
addSharedTeacherToProject in interface ProjectService
Throws:
ObjectNotFoundException

getProjectList

public List<Project> getProjectList(User user)
Description copied from interface: ProjectService
Get a List of Project that the specified user owns

Specified by:
getProjectList in interface ProjectService
Returns:
a List of Project

getSharedTeacherRole

public String getSharedTeacherRole(Project project,
                                   User user)
Description copied from interface: ProjectService
Returns the permission that the specified user has on the specified project

Specified by:
getSharedTeacherRole in interface ProjectService
Parameters:
project - The Project that is shared.
user - The User that shares the Project
Returns:
A String containing the permission that the user has on the project. If the user does not have permission on the project, null is returned.

getSharedProjectList

public List<Project> getSharedProjectList(User user)
Description copied from interface: ProjectService
Get a List of Project that have been shared with the specified user.

Specified by:
getSharedProjectList in interface ProjectService
Returns:
a List of Project

getWorkgroupDao

public WorkgroupDao<Workgroup> getWorkgroupDao()
Returns:
the workgroupDao

setWorkgroupDao

public void setWorkgroupDao(WorkgroupDao<Workgroup> workgroupDao)
Parameters:
workgroupDao - the workgroupDao to set

getBookmarkerProjectList

public List<Project> getBookmarkerProjectList(User user)
Description copied from interface: ProjectService
Retrieves a List of Project that has been bookmarked by the given User

Specified by:
getBookmarkerProjectList in interface ProjectService
Returns:
List
See Also:
ProjectService.getBookmarkerProjectList(net.sf.sail.webapp.domain.User)

addBookmarkerToProject

public void addBookmarkerToProject(Project project,
                                   User bookmarker)
                            throws ObjectNotFoundException
Description copied from interface: ProjectService
Adds the given User bookmarker to the Project project

Specified by:
addBookmarkerToProject in interface ProjectService
Throws:
ObjectNotFoundException
See Also:
ProjectService.addBookmarkerToProject(org.telscenter.sail.webapp.domain.project.Project, net.sf.sail.webapp.domain.User)

removeBookmarkerFromProject

public void removeBookmarkerFromProject(Project project,
                                        User bookmarker)
                                 throws ObjectNotFoundException
Description copied from interface: ProjectService
Removes the given User bookmarker from the Project project

Specified by:
removeBookmarkerFromProject in interface ProjectService
Throws:
ObjectNotFoundException
See Also:
ProjectService.removeBookmarkerFromProject(org.telscenter.sail.webapp.domain.project.Project, net.sf.sail.webapp.domain.User)

getAllProjectsList

public List<Project> getAllProjectsList()
Description copied from interface: ProjectService
Get a List of Project

Specified by:
getAllProjectsList in interface ProjectService
Returns:
a List of Project

getProjectList

public List<Project> getProjectList(String query)
Description copied from interface: ProjectService
Given a String query, returns a List of Project that satisfies the query.

Specified by:
getProjectList in interface ProjectService
Returns:
List

minifyProject

public String minifyProject(Project project)
Description copied from interface: ProjectService
Given a Project project, attempts to minify a file and returns a String of the final status of the operation.

Specified by:
minifyProject in interface ProjectService
Returns:

getProjectMetadataFile

public JSONObject getProjectMetadataFile(Project project)

canCreateRun

public boolean canCreateRun(Project project,
                            User user)
Description copied from interface: ProjectService
Given a Project project and User user, returns boolean true if the user is allowed to create a run from that project (ie, project is TELS, owner, sharedOwner), returns false otherwise.

Specified by:
canCreateRun in interface ProjectService
Returns:
boolean

canAuthorProject

public boolean canAuthorProject(Project project,
                                User user)
Description copied from interface: ProjectService
Given a Project project and User user, returns boolean true if the user is allowed to author that particular project, returns false otherwise.

Specified by:
canAuthorProject in interface ProjectService
Returns:
boolean

canReadProject

public boolean canReadProject(Project project,
                              User user)
Description copied from interface: ProjectService
Given a Project project and a User user, returns boolean true if the user has read access to that particular project, returns false otherwise.

Specified by:
canReadProject in interface ProjectService
Returns:

getAdminProjectList

public List<Project> getAdminProjectList()
Description copied from interface: ProjectService
Returns a List list of all projects in the data store.

Specified by:
getAdminProjectList in interface ProjectService
Returns:
List projects

getActiveVersion

public String getActiveVersion(Project project)

takeSnapshot

public String takeSnapshot(Project project,
                           String username,
                           String snapshotName)

getMetadata

public ProjectMetadata getMetadata(Long projectId)
Description copied from interface: ProjectService
Given a Long projectId returns the ProjectMetadata that is associated with that projectId and versionId, if one exists, returns null otherwise.

Specified by:
getMetadata in interface ProjectService
Returns:

sortProjectsByDateCreated

public void sortProjectsByDateCreated(List<Project> projectList)
Description copied from interface: ProjectService
Sorts the given List list of projects by the date they were created.

Specified by:
sortProjectsByDateCreated in interface ProjectService

addTagToProject

public Long addTagToProject(Tag tag,
                            Long projectId)
Description copied from interface: ProjectService
Given a Tag tag and a Long project id adds the given tag to the project.

Specified by:
addTagToProject in interface ProjectService

addTagToProject

public Long addTagToProject(String tag,
                            Long projectId)
Description copied from interface: ProjectService
Given a String and a Project adds the tag to the project.

Specified by:
addTagToProject in interface ProjectService

getProjectListByTagName

public List<Project> getProjectListByTagName(String tagName)
Description copied from interface: ProjectService
Given a String tag name, returns a List list of projects with that tag.

Specified by:
getProjectListByTagName in interface ProjectService
Returns:
List - list of projects

getProjectListByTagNames

public List<Project> getProjectListByTagNames(Set<String> tagNames)
Description copied from interface: ProjectService
Given a Set set of tag names, returns a List list of projects with all of the tag names.

Specified by:
getProjectListByTagNames in interface ProjectService
Returns:
List - list of projects

isAuthorizedToCreateTag

public boolean isAuthorizedToCreateTag(User user,
                                       String name)
Description copied from interface: ProjectService
Given a User user and a String tag name, returns true if that user is authorized to create a tag with that name, returns false otherwise.

Specified by:
isAuthorizedToCreateTag in interface ProjectService
Returns:
boolean

projectContainsTag

public boolean projectContainsTag(Long projectId,
                                  String name)
Description copied from interface: ProjectService
Given a Long project id and a String tag name, returns boolean true if the project contains a tag with that name, false otherwise.

Specified by:
projectContainsTag in interface ProjectService
Returns:
boolean

removeTagFromProject

public void removeTagFromProject(Long tagId,
                                 Long projectId)
Description copied from interface: ProjectService
Given a Tag and a Project, removes the tag from the project.

Specified by:
removeTagFromProject in interface ProjectService

updateTag

public Long updateTag(Long tagId,
                      Long projectId,
                      String name)
Description copied from interface: ProjectService
Given a Long tag id, a Long project id and a String name, updates that project tag to that name, returning the resulting Long tag Id.

Specified by:
updateTag in interface ProjectService
Returns:
Long - tag id

getProjectCopies

public List<Project> getProjectCopies(Long projectId)
Description copied from interface: ProjectService
Given a project id, returns projects that are copies of the project

Specified by:
getProjectCopies in interface ProjectService
Returns:

removeSharedTeacherFromProject

public void removeSharedTeacherFromProject(String username,
                                           Project project)
                                    throws ObjectNotFoundException
Description copied from interface: ProjectService
Removes shared user from project. if user or project does not exist, ignore.

Specified by:
removeSharedTeacherFromProject in interface ProjectService
Throws:
ObjectNotFoundException

getProjectFull

public Project getProjectFull(Long projectId)
                       throws ObjectNotFoundException
Throws:
ObjectNotFoundException

identifyRootProjectId

public Long identifyRootProjectId(Project projectId)
                           throws ObjectNotFoundException
Description copied from interface: ProjectService
Given a project, gets the project id for the project's root level project

Specified by:
identifyRootProjectId in interface ProjectService
Returns:
project
Throws:
ObjectNotFoundException


Copyright © 2012. All Rights Reserved.