Package fr.igred.omero
Class Client
- java.lang.Object
-
- fr.igred.omero.Client
-
public class Client extends Object
Basic class, contains the gateway, the security context, and multiple facilities.Allows the user to connect to OMERO and browse through all the data accessible to the user.
-
-
Constructor Summary
Constructors Constructor Description Client()
Constructor of the Client class.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
connect(String hostname, int port, String sessionId)
Connects to OMERO using a session ID.void
connect(String hostname, int port, String username, char[] password)
Connects the user to OMERO.void
connect(String hostname, int port, String username, char[] password, Long groupID)
Connects the user to OMERO.void
connect(LoginCredentials cred)
Connects the user to OMERO.void
delete(TableWrapper table)
Deletes a table from OMEROvoid
delete(GenericObjectWrapper<?> object)
Deletes an object from OMERO.void
deleteFile(Long id)
Deletes a file from OMEROvoid
disconnect()
Disconnects the userList<IObject>
findByQuery(String query)
Finds objects on OMERO through a database query.AdminFacility
getAdminFacility()
Gets the AdminFacility linked to the gateway to use admin specific function.BrowseFacility
getBrowseFacility()
Gets the BrowseFacility used to access the data from OMERO.ImportConfig
getConfig()
Gets a copy of the importation config for the user.SecurityContext
getCtx()
Contains the permissions of the user in the group.long
getCurrentGroupId()
Gets the current group ID.DatasetWrapper
getDataset(Long id)
Gets the dataset with the specified id from OMERO.List<DatasetWrapper>
getDatasets()
Gets all the datasets available from OMERO.List<DatasetWrapper>
getDatasets(String name)
Gets all datasets with a certain name from OMERO.DataManagerFacility
getDm()
Gets the DataManagerFacility to handle/write data on OMERO.Gateway
getGateway()
GroupWrapper
getGroup(String groupName)
Returns the group which matches the name.long
getId()
Gets the user id.ImageWrapper
getImage(Long id)
Returns an ImageWrapper that contains the image with the specified id from OMERO.List<ImageWrapper>
getImages()
Gets all images available from OMERO.List<ImageWrapper>
getImages(String name)
Gets all images with a certain from OMERO.List<ImageWrapper>
getImagesKey(String key)
Gets all images with a certain keyList<ImageWrapper>
getImagesLike(String motif)
Gets all images with a certain motif in their name from OMERO.List<ImageWrapper>
getImagesPairKeyValue(String key, String value)
Gets all images with a certain key value pair from OMEROList<ImageWrapper>
getImagesTagged(TagAnnotationWrapper tag)
Gets all images tagged with a specified tag from OMERO.List<ImageWrapper>
getImagesTagged(Long tagId)
Gets all images tagged with a specified tag from OMERO.MetadataFacility
getMetadata()
Gets the MetadataFacility used to manipulate annotations from OMERO.ProjectWrapper
getProject(Long id)
Gets the project with the specified id from OMERO.List<ProjectWrapper>
getProjects()
Gets all projects available from OMERO.List<ProjectWrapper>
getProjects(String name)
Gets all projects with a certain name from OMERO.ROIFacility
getRoiFacility()
Gets the ROIFacility used to manipulate ROI from OMERO.String
getSessionId()
Get the ID of the current sessionTablesFacility
getTablesFacility()
Gets the TablesFacility used to manipulate table from OMERO.TagAnnotationWrapper
getTag(Long id)
Gets a specific tag from the OMERO databaseList<TagAnnotationWrapper>
getTags()
Gets the list of TagAnnotationWrapper available to the userList<TagAnnotationWrapper>
getTags(String name)
Gets the list of TagAnnotationWrapper with the specified name available to the userExperimenterWrapper
getUser()
Returns the current user.ExperimenterWrapper
getUser(String username)
Returns the user which matches the username.IObject
save(IObject object)
Saves an object on OMERO.Client
sudoGetUser(String username)
Gets the client associated with the username in the parameters.void
switchGroup(long groupId)
Change the current group used by the current user;
-
-
-
Method Detail
-
getUser
public ExperimenterWrapper getUser()
Returns the current user.- Returns:
- The current user.
-
getCtx
public SecurityContext getCtx()
Contains the permissions of the user in the group.- Returns:
- the
SecurityContext
of the user.
-
getBrowseFacility
public BrowseFacility getBrowseFacility()
Gets the BrowseFacility used to access the data from OMERO.- Returns:
- the
BrowseFacility
linked to the gateway.
-
getDm
public DataManagerFacility getDm() throws ExecutionException
Gets the DataManagerFacility to handle/write data on OMERO. A- Returns:
- the
DataManagerFacility
linked to the gateway. - Throws:
ExecutionException
- If the DataManagerFacility can't be retrieved or instantiated.
-
getMetadata
public MetadataFacility getMetadata() throws ExecutionException
Gets the MetadataFacility used to manipulate annotations from OMERO.- Returns:
- the
MetadataFacility
linked to the gateway. - Throws:
ExecutionException
- If the MetadataFacility can't be retrieved or instantiated.
-
getRoiFacility
public ROIFacility getRoiFacility() throws ExecutionException
Gets the ROIFacility used to manipulate ROI from OMERO.- Returns:
- the
ROIFacility
linked to the gateway. - Throws:
ExecutionException
- If the ROIFacility can't be retrieved or instantiated.
-
getTablesFacility
public TablesFacility getTablesFacility() throws ExecutionException
Gets the TablesFacility used to manipulate table from OMERO.- Returns:
- the
TablesFacility
linked to the gateway. - Throws:
ExecutionException
- If the TablesFacility can't be retrieved or instantiated.
-
getAdminFacility
public AdminFacility getAdminFacility() throws ExecutionException
Gets the AdminFacility linked to the gateway to use admin specific function.- Returns:
- the
AdminFacility
linked to the gateway. - Throws:
ExecutionException
- If the AdminFacility can't be retrieved or instantiated.
-
findByQuery
public List<IObject> findByQuery(String query) throws ServiceException, OMEROServerError
Finds objects on OMERO through a database query.- Parameters:
query
- The database query.- Returns:
- A list of OMERO objects.
- Throws:
ServiceException
- Cannot connect to OMERO.OMEROServerError
- Server error.
-
getConfig
public ImportConfig getConfig()
Gets a copy of the importation config for the user.- Returns:
- config.
-
getId
public long getId()
Gets the user id.- Returns:
- The user ID.
-
getCurrentGroupId
public long getCurrentGroupId()
Gets the current group ID.- Returns:
- The group ID.
-
getSessionId
public String getSessionId() throws DSOutOfServiceException
Get the ID of the current session- Returns:
- See above
- Throws:
DSOutOfServiceException
- If the connection is broken, or not logged in
-
getGateway
public Gateway getGateway()
-
connect
public void connect(String hostname, int port, String sessionId) throws ServiceException, ExecutionException
Connects to OMERO using a session ID.- Parameters:
hostname
- Name of the host.port
- Port used by OMERO.sessionId
- The session ID.- Throws:
ServiceException
- Cannot connect to OMERO.ExecutionException
- A Facility can't be retrieved or instantiated.
-
connect
public void connect(String hostname, int port, String username, char[] password, Long groupID) throws ServiceException, ExecutionException
Connects the user to OMERO.Uses the argument to connect to the gateway.
Connects to the group specified in the argument.
- Parameters:
hostname
- Name of the host.port
- Port used by OMERO.username
- Username of the user.password
- Password of the user.groupID
- Id of the group to connect.- Throws:
ServiceException
- Cannot connect to OMERO.ExecutionException
- A Facility can't be retrieved or instantiated.
-
connect
public void connect(String hostname, int port, String username, char[] password) throws ServiceException, ExecutionException
Connects the user to OMERO.Uses the argument to connect to the gateway.
Connects to the default group of the user.
- Parameters:
hostname
- Name of the host.port
- Port used by OMERO.username
- Username of the user.password
- Password of the user.- Throws:
ServiceException
- Cannot connect to OMERO.ExecutionException
- A Facility can't be retrieved or instantiated.
-
connect
public void connect(LoginCredentials cred) throws ServiceException, ExecutionException
Connects the user to OMERO. Gets the SecurityContext and the BrowseFacility.- Parameters:
cred
- User credential.- Throws:
ServiceException
- Cannot connect to OMERO.ExecutionException
- A Facility can't be retrieved or instantiated.
-
disconnect
public void disconnect()
Disconnects the user
-
getProject
public ProjectWrapper getProject(Long id) throws ServiceException, AccessException, NoSuchElementException
Gets the project with the specified id from OMERO.- Parameters:
id
- Id of the project.- Returns:
- ProjectWrapper containing the project.
- Throws:
ServiceException
- Cannot connect to OMERO.AccessException
- Cannot access data.NoSuchElementException
- No element with such id.
-
getProjects
public List<ProjectWrapper> getProjects() throws ServiceException, AccessException
Gets all projects available from OMERO.- Returns:
- Collection of ProjectWrapper.
- Throws:
ServiceException
- Cannot connect to OMERO.AccessException
- Cannot access data.
-
getProjects
public List<ProjectWrapper> getProjects(String name) throws ServiceException, AccessException
Gets all projects with a certain name from OMERO.- Parameters:
name
- Name searched.- Returns:
- Collection of ProjectWrapper.
- Throws:
ServiceException
- Cannot connect to OMERO.AccessException
- Cannot access data.
-
getDataset
public DatasetWrapper getDataset(Long id) throws ServiceException, AccessException, NoSuchElementException
Gets the dataset with the specified id from OMERO.- Parameters:
id
- Id of the Dataset.- Returns:
- ProjectWrapper containing the project.
- Throws:
ServiceException
- Cannot connect to OMERO.AccessException
- Cannot access data.NoSuchElementException
- No element with such id.
-
getDatasets
public List<DatasetWrapper> getDatasets() throws ServiceException, AccessException, OMEROServerError
Gets all the datasets available from OMERO.- Returns:
- Collection of DatasetWrapper.
- Throws:
ServiceException
- Cannot connect to OMERO.AccessException
- Cannot access data.OMEROServerError
- Server error.
-
getDatasets
public List<DatasetWrapper> getDatasets(String name) throws ServiceException, AccessException
Gets all datasets with a certain name from OMERO.- Parameters:
name
- Name searched.- Returns:
- Collection of DatasetWrapper.
- Throws:
ServiceException
- Cannot connect to OMERO.AccessException
- Cannot access data.
-
getImage
public ImageWrapper getImage(Long id) throws ServiceException, AccessException, NoSuchElementException
Returns an ImageWrapper that contains the image with the specified id from OMERO.- Parameters:
id
- Id of the image.- Returns:
- ImageWrapper containing the image.
- Throws:
ServiceException
- Cannot connect to OMERO.AccessException
- Cannot access data.NoSuchElementException
- No element with such id.
-
getImages
public List<ImageWrapper> getImages() throws ServiceException, AccessException
Gets all images available from OMERO.- Returns:
- ImageWrapper list.
- Throws:
ServiceException
- Cannot connect to OMERO.AccessException
- Cannot access data.
-
getImages
public List<ImageWrapper> getImages(String name) throws ServiceException, AccessException
Gets all images with a certain from OMERO.- Parameters:
name
- Name searched.- Returns:
- ImageWrapper list.
- Throws:
ServiceException
- Cannot connect to OMERO.AccessException
- Cannot access data.
-
getImagesLike
public List<ImageWrapper> getImagesLike(String motif) throws ServiceException, AccessException
Gets all images with a certain motif in their name from OMERO.- Parameters:
motif
- Motif searched in an image name.- Returns:
- ImageWrapper list.
- Throws:
ServiceException
- Cannot connect to OMERO.AccessException
- Cannot access data.
-
getImagesTagged
public List<ImageWrapper> getImagesTagged(TagAnnotationWrapper tag) throws ServiceException, AccessException, OMEROServerError
Gets all images tagged with a specified tag from OMERO.- Parameters:
tag
- TagAnnotationWrapper containing the tag researched.- Returns:
- ImageWrapper list.
- Throws:
ServiceException
- Cannot connect to OMERO.AccessException
- Cannot access data.OMEROServerError
- Server error.
-
getImagesTagged
public List<ImageWrapper> getImagesTagged(Long tagId) throws ServiceException, AccessException, OMEROServerError
Gets all images tagged with a specified tag from OMERO.- Parameters:
tagId
- Id of the tag researched.- Returns:
- ImageWrapper list.
- Throws:
ServiceException
- Cannot connect to OMERO.AccessException
- Cannot access data.OMEROServerError
- Server error.
-
getImagesKey
public List<ImageWrapper> getImagesKey(String key) throws ServiceException, AccessException, ExecutionException
Gets all images with a certain key- Parameters:
key
- Name of the key researched.- Returns:
- ImageWrapper list.
- Throws:
ServiceException
- Cannot connect to OMERO.AccessException
- Cannot access data.ExecutionException
- A Facility can't be retrieved or instantiated.
-
getImagesPairKeyValue
public List<ImageWrapper> getImagesPairKeyValue(String key, String value) throws ServiceException, AccessException, ExecutionException
Gets all images with a certain key value pair from OMERO- Parameters:
key
- Name of the key researched.value
- Value associated with the key.- Returns:
- ImageWrapper list.
- Throws:
ServiceException
- Cannot connect to OMERO.AccessException
- Cannot access data.ExecutionException
- A Facility can't be retrieved or instantiated.
-
sudoGetUser
public Client sudoGetUser(String username) throws ServiceException, AccessException, ExecutionException
Gets the client associated with the username in the parameters. The user calling this function needs to have administrator rights. All action realized with the client returned will be considered as his.- Parameters:
username
- Username of user.- Returns:
- The client corresponding to the new user.
- Throws:
ServiceException
- Cannot connect to OMERO.AccessException
- Cannot access data.ExecutionException
- A Facility can't be retrieved or instantiated.
-
switchGroup
public void switchGroup(long groupId)
Change the current group used by the current user;- Parameters:
groupId
- The group ID.
-
getTags
public List<TagAnnotationWrapper> getTags() throws OMEROServerError, ServiceException
Gets the list of TagAnnotationWrapper available to the user- Returns:
- list of TagAnnotationWrapper.
- Throws:
OMEROServerError
- Server error.ServiceException
- Cannot connect to OMERO.
-
getTags
public List<TagAnnotationWrapper> getTags(String name) throws OMEROServerError, ServiceException
Gets the list of TagAnnotationWrapper with the specified name available to the user- Parameters:
name
- Name of the tag searched.- Returns:
- list of TagAnnotationWrapper.
- Throws:
OMEROServerError
- Server error.ServiceException
- Cannot connect to OMERO.
-
getTag
public TagAnnotationWrapper getTag(Long id) throws OMEROServerError, ServiceException
Gets a specific tag from the OMERO database- Parameters:
id
- Id of the tag.- Returns:
- TagAnnotationWrapper containing the specified tag.
- Throws:
OMEROServerError
- Server error.ServiceException
- Cannot connect to OMERO.
-
save
public IObject save(IObject object) throws ServiceException, AccessException, ExecutionException
Saves an object on OMERO.- Parameters:
object
- The OMERO object.- Returns:
- The saved OMERO object
- Throws:
ServiceException
- Cannot connect to OMERO.AccessException
- Cannot access data.ExecutionException
- A Facility can't be retrieved or instantiated.
-
delete
public void delete(GenericObjectWrapper<?> object) throws ServiceException, AccessException, ExecutionException, OMEROServerError, InterruptedException
Deletes an object from OMERO.- Parameters:
object
- The OMERO object.- Throws:
ServiceException
- Cannot connect to OMERO.AccessException
- Cannot access data.ExecutionException
- A Facility can't be retrieved or instantiated.OMEROServerError
- If the thread was interrupted.InterruptedException
- If block(long) does not return.
-
delete
public void delete(TableWrapper table) throws ServiceException, AccessException, ExecutionException, OMEROServerError, InterruptedException
Deletes a table from OMERO- Parameters:
table
- TableWrapper containing the table to delete.- Throws:
ServiceException
- Cannot connect to OMERO.AccessException
- Cannot access data.ExecutionException
- A Facility can't be retrieved or instantiated.IllegalArgumentException
- Id not defined.OMEROServerError
- If the thread was interrupted.InterruptedException
- If block(long) does not return.
-
deleteFile
public void deleteFile(Long id) throws ServiceException, AccessException, ExecutionException, OMEROServerError, InterruptedException
Deletes a file from OMERO- Parameters:
id
- Id of the file to delete.- Throws:
ServiceException
- Cannot connect to OMERO.AccessException
- Cannot access data.ExecutionException
- A Facility can't be retrieved or instantiated.OMEROServerError
- If the thread was interrupted.InterruptedException
- If block(long) does not return.
-
getUser
public ExperimenterWrapper getUser(String username) throws ExecutionException, ServiceException, AccessException
Returns the user which matches the username.- Parameters:
username
- The name of the user.- Returns:
- The user matching the username, or null if it does not exist.
- Throws:
ServiceException
- Cannot connect to OMERO.AccessException
- Cannot access data.ExecutionException
- A Facility can't be retrieved or instantiated.
-
getGroup
public GroupWrapper getGroup(String groupName) throws ExecutionException, ServiceException, AccessException
Returns the group which matches the name.- Parameters:
groupName
- The name of the group.- Returns:
- The group with the appropriate name, or null if it does not exist.
- Throws:
ServiceException
- Cannot connect to OMERO.AccessException
- Cannot access data.ExecutionException
- A Facility can't be retrieved or instantiated.
-
-