@Transactional public class DeleteBean extends AbstractLevel2Service implements IDelete
IDelete
service interface which will use
the SecuritySystem
via
SecuritySystem.runAsAdmin(AdminAction)
to forcibly
delete instances.IDelete
Modifier and Type | Field and Description |
---|---|
protected LocalAdmin |
admin |
static String |
CHANNELID_QUERY |
static String |
IMAGE_QUERY
Loads an
Image graph including: Pixels, Channel, LogicalChannel,
StatsInfo, PlaneInfo, Thumbnails, file maps, OriginalFiles, and Settings |
static org.slf4j.Logger |
log |
static String |
PLATEIMAGES_QUERY |
static String |
SETTINGSID_QUERY |
protected SessionFactory |
sf |
iQuery, iUpdate, metadata, queryFactory, sec
Constructor and Description |
---|
DeleteBean(LocalAdmin admin,
SessionFactory sf) |
Modifier and Type | Method and Description |
---|---|
List<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,
Image i)
Walks the
Image graph collecting unloaded instances of all
entities for later delete. |
void |
deleteChannels(long imageId) |
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(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<IObject> |
previewImageDelete(long id,
boolean force)
This uses
IMAGE_QUERY to load all the subordinate metadata of the
Image which will be deleted. |
getBeanHelper, getExtendedMetadata, getQueryFactory, getSecuritySystem, selfConfigure, setExtendedMetadata, setQueryFactory, setQueryService, setSecuritySystem, setUpdateService
public static final org.slf4j.Logger log
public static final String IMAGE_QUERY
Image
graph including: Pixels, Channel, LogicalChannel,
StatsInfo, PlaneInfo, Thumbnails, file maps, OriginalFiles, and Settingspublic static final String SETTINGSID_QUERY
public static final String CHANNELID_QUERY
public static final String PLATEIMAGES_QUERY
protected final LocalAdmin admin
protected final SessionFactory sf
public DeleteBean(LocalAdmin admin, SessionFactory sf)
public final Class<? extends ServiceInterface> getServiceInterface()
getServiceInterface
in interface SelfConfigurableService
public List<IObject> checkImageDelete(long id, boolean force)
IDelete
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.checkImageDelete
in interface IDelete
id
- of the Image
to be deleted.force
- return value will be includedpublic List<IObject> previewImageDelete(long id, boolean force)
IMAGE_QUERY
to load all the subordinate metadata of the
Image
which will be deleted.previewImageDelete
in interface IDelete
public void deleteImage(long id, boolean force) throws SecurityViolation, ValidationException
IDelete
Image
and all related (subordinate) metadata as
defined below. This method calls IDelete.checkImageDelete(long, boolean)
and throws a ConstraintViolationException
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, theImage
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.
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.deleteImage
in interface IDelete
id
- id of the Image
to be deletedforce
- Image
will be removed even if contained in other
datasets
. If false, a
ConstraintViolationException
will be raised.SecurityViolation
- If the Image
does not belong to the current user.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)public void deleteImages(Set<Long> ids, boolean force) throws SecurityViolation, ValidationException, ApiUsageException
IDelete
Image
instances within a single transaction via
the IDelete.deleteImage(long, boolean)
method.deleteImages
in interface IDelete
ids
- As IDelete.deleteImage(long, boolean)
force
- As IDelete.deleteImage(long, boolean)
SecurityViolation
- As IDelete.deleteImage(long, boolean)
ValidationException
- As IDelete.deleteImage(long, boolean)
ApiUsageException
- As IDelete.deleteImage(long, boolean)
public void deleteImagesByDataset(long datasetId, boolean force) throws SecurityViolation, ValidationException, ApiUsageException
IDelete
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.deleteImagesByDataset
in interface IDelete
datasetId
- As IDelete.deleteImage(long, boolean)
force
- As IDelete.deleteImage(long, boolean)
SecurityViolation
- As IDelete.deleteImage(long, boolean)
ValidationException
- As IDelete.deleteImage(long, boolean)
ApiUsageException
- As IDelete.deleteImage(long, boolean)
public void deleteSettings(long imageId)
IDelete
deleteSettings
in interface IDelete
public void deleteChannels(long imageId)
public void deletePlate(long plateId)
IDelete
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.
WellAnnotationLinks, and PlateAnnotationLinks are
deleted as necessary.deletePlate
in interface IDelete
protected void getImageAndCount(Image[] images, long id, ome.services.delete.UnloadedCollector delete)
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.
Version: 5.3.5-ice35-b73
Copyright © 2017 The University of Dundee & Open Microscopy Environment. All Rights Reserved.