ome.services.delete
Class DeleteBean

java.lang.Object
  extended by ome.logic.AbstractLevel2Service
      extended by ome.services.delete.DeleteBean
All Implemented Interfaces:
IDelete, ServiceInterface, SelfConfigurableService

@Transactional
public class DeleteBean
extends AbstractLevel2Service
implements IDelete

Strict implementation of the IDelete service interface which will use the SecuritySystem via SecuritySystem.runAsAdmin(AdminAction) to forcibly delete instances.

Since:
3.0-Beta3
Author:
Josh Moore, josh at glencoesoftware.com
See Also:
IDelete

Field Summary
protected  LocalAdmin admin
           
static String IMAGE_QUERY
          Loads an Image graph including: Pixels, Channel, LogicalChannel, StatsInfo, PlaneInfo, Thumbnails, file maps, OriginalFiles, and Settings
static org.apache.commons.logging.Log log
           
static String PLATEIMAGES_QUERY
           
static String SETTINGS_QUERY
           
protected  SessionFactory sf
           
 
Fields inherited from class ome.logic.AbstractLevel2Service
iQuery, iUpdate, metadata, queryFactory, sec
 
Constructor Summary
DeleteBean(LocalAdmin admin, SessionFactory sf)
           
 
Method Summary
 List<ome.model.IObject> checkImageDelete(long id, boolean force)
          Returns all entities which would prevent the given Image id from being deleted.
protected  void collect(ome.services.delete.UnloadedCollector delete, ome.model.core.Image i)
          Walks the Image graph collecting unloaded instances of all entities for later delete.
 void deleteImage(long id, boolean force)
          Deletes an Image and all related (subordinate) metadata as defined below.
 void deleteImages(Set<Long> ids, boolean force)
          Deletes several Image instances within a single transaction via the IDelete.deleteImage(long, boolean) method.
 void deleteImagesByDataset(long datasetId, boolean force)
          Deletes the user-visible Image instances of the given Dataset within a single transaction via the IDelete.deleteImage(long, boolean).
 void deletePlate(long plateId)
          Deletes all the images contained in a plate as if deleted by: deleteImage(id, true) so that all Dataset and Annotation links are broken, with WellSamples removed first.
 void deleteSettings(long imageId)
          Deletes all rendering settings for the given Pixel id.
protected  void getImageAndCount(ome.model.core.Image[] images, long id, ome.services.delete.UnloadedCollector delete)
          Uses the locally defined query to load an Image and calls collect(UnloadedCollector, Image) in order to define a list of what will be deleted.
 Class<? extends ServiceInterface> getServiceInterface()
           
 List<ome.model.IObject> previewImageDelete(long id, boolean force)
          This uses IMAGE_QUERY to load all the subordinate metadata of the Image which will be deleted.
 
Methods inherited from class ome.logic.AbstractLevel2Service
getBeanHelper, getExtendedMetadata, getQueryFactory, getSecuritySystem, selfConfigure, setExtendedMetadata, setQueryFactory, setQueryService, setSecuritySystem, setUpdateService
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

public static final org.apache.commons.logging.Log log

IMAGE_QUERY

public static final String IMAGE_QUERY
Loads an Image graph including: Pixels, Channel, LogicalChannel, StatsInfo, PlaneInfo, Thumbnails, file maps, OriginalFiles, and Settings

See Also:
Constant Field Values

SETTINGS_QUERY

public static final String SETTINGS_QUERY
See Also:
Constant Field Values

PLATEIMAGES_QUERY

public static final String PLATEIMAGES_QUERY
See Also:
Constant Field Values

admin

protected final LocalAdmin admin

sf

protected final SessionFactory sf
Constructor Detail

DeleteBean

public DeleteBean(LocalAdmin admin,
                  SessionFactory sf)
Method Detail

getServiceInterface

public final Class<? extends ServiceInterface> getServiceInterface()
Specified by:
getServiceInterface in interface SelfConfigurableService

checkImageDelete

public List<ome.model.IObject> checkImageDelete(long id,
                                                boolean force)
Description copied from interface: IDelete
Returns all entities which would prevent the given Image id from being deleted. The force boolean determines whether or not the user's collections should be removed in order to facilitate the delete. Currently this only includes datasets. The force boolean determines if Dataset instances from the same user will be considered as constraints. Regardless of force, datasets from other users are considered constraints.

Specified by:
checkImageDelete in interface IDelete
Parameters:
id - of the Image to be deleted.
force - return value will be included
Returns:
unloaded entity list

previewImageDelete

public List<ome.model.IObject> previewImageDelete(long id,
                                                  boolean force)
This uses IMAGE_QUERY to load all the subordinate metadata of the Image which will be deleted.

Specified by:
previewImageDelete in interface IDelete
Returns:
unloaded entity list

deleteImage

public void deleteImage(long id,
                        boolean force)
                 throws ome.conditions.SecurityViolation,
                        ome.conditions.ValidationException
Description copied from interface: IDelete
Deletes an Image and all related (subordinate) metadata as defined below. This method calls IDelete.checkImageDelete(long, boolean) and throws a ConstraintViolation exception with the results of that call are not empty; then it forcibly deletes all objects returned by IDelete.previewImageDelete(long, boolean)

The deleted metadata includes all of the following types which belong to the current user:

If any of these types do not belong to the current user, the Image data graph will be considered corrupted and a ValidationException will be thrown.

For the types:

a forced deletion will take place even if the user information does not match the current user.

If the Image is not owned by the current user, then SecurityViolation is thrown, unless the user is root or the group leader.

An image will not be deleted if it is contained in a Dataset owned by another user. If the Image is contained in other datasets belonging to the same user, then the force parameter decides what will happen. A force value of true implies that the Image will be removed as well as the related links. The Pixels.getRelatedTo() field will be set to null for all Pixels pointing to a Pixels instance which is about to be deleted.

Specified by:
deleteImage in interface IDelete
Parameters:
id - id of the Image to be deleted
force - Image will be removed even if contained in other datasets. If false, a ConstraintViolation will be raised.
Throws:
ome.conditions.SecurityViolation - If the Image does not belong to the current user.
ome.conditions.ValidationException - throws an exception if there is any unexpected object which prevents this object from being deleted, i.e. not in IDelete.checkImageDelete(long, boolean) (check first)

deleteImages

public void deleteImages(Set<Long> ids,
                         boolean force)
                  throws ome.conditions.SecurityViolation,
                         ome.conditions.ValidationException,
                         ome.conditions.ApiUsageException
Description copied from interface: IDelete
Deletes several Image instances within a single transaction via the IDelete.deleteImage(long, boolean) method.

Specified by:
deleteImages in interface IDelete
force - As IDelete.deleteImage(long, boolean)
Throws:
ome.conditions.SecurityViolation - As IDelete.deleteImage(long, boolean)
ome.conditions.ValidationException - As IDelete.deleteImage(long, boolean)
ome.conditions.ApiUsageException - As IDelete.deleteImage(long, boolean)

deleteImagesByDataset

public void deleteImagesByDataset(long datasetId,
                                  boolean force)
                           throws ome.conditions.SecurityViolation,
                                  ome.conditions.ValidationException,
                                  ome.conditions.ApiUsageException
Description copied from interface: IDelete
Deletes the user-visible Image instances of the given Dataset within a single transaction via the IDelete.deleteImage(long, boolean). In addition, before Image deletion is attempted, the links to the given Dataset are first removed, otherwise this method would always require a "force" argument of true.

Specified by:
deleteImagesByDataset in interface IDelete
force - As IDelete.deleteImage(long, boolean)
Throws:
ome.conditions.ValidationException - As IDelete.deleteImage(long, boolean)
ome.conditions.ApiUsageException - As IDelete.deleteImage(long, boolean)
ome.conditions.SecurityViolation

deleteSettings

public void deleteSettings(long imageId)
Description copied from interface: IDelete
Deletes all rendering settings for the given Pixel id. This removes all the same objects that deleteImage() would delete below the given Pixels

Specified by:
deleteSettings in interface IDelete

deletePlate

public void deletePlate(long plateId)
Description copied from interface: IDelete
Deletes all the images contained in a plate as if deleted by: deleteImage(id, true) so that all Dataset and Annotation links are broken, with WellSamples removed first. Then all Wells in the Plate and the Plate itself are removed. WellSampleAnnotationLinks, WellAnnotationLinks, and PlateAnnotationLinks are deleted as necessary.

Specified by:
deletePlate in interface IDelete

getImageAndCount

protected void getImageAndCount(ome.model.core.Image[] images,
                                long id,
                                ome.services.delete.UnloadedCollector delete)
Uses the locally defined query to load an Image and calls collect(UnloadedCollector, Image) in order to define a list of what will be deleted. This method fulfills the previewImageDelete(long, boolean) contract and as such is used by deleteImage(long, boolean) in order to fulfill its contract.


collect

protected void collect(ome.services.delete.UnloadedCollector delete,
                       ome.model.core.Image i)
Walks the Image graph collecting unloaded instances of all entities for later delete.



OmeroJava Api

Version: Beta-4.2.0-r7571-b29

Copyright © 2009 The University of Dundee. All Rights Reserved.