public class FileSet extends BasicItem
Modifier and Type | Class and Description |
---|---|
private static class |
FileSet.QueryRuntimeFilterImpl |
Modifier and Type | Field and Description |
---|---|
private FileStoreEnabled |
item
The item this file set belongs to.
|
private static QueryRuntimeFilter |
RUNTIME_FILTER
This filter gives everybody read permission to file sets.
|
static Item |
TYPE
The type of item represented by this class.
|
Constructor and Description |
---|
FileSet(FileSetData data)
Regular constructor if the item is not known beforehand.
|
FileSet(FileSetData data,
FileStoreEnabled item)
Special constructor to avoid
getItem() to hit the database
when the item is known beforehand. |
Modifier and Type | Method and Description |
---|---|
FileSetMember |
addMember(File file,
DataFileType type)
Add a file as a member to the file set.
|
static FileSet |
getById(DbControl dc,
int id)
Get a
FileSet item when you know the id. |
(package private) FileSetData |
getData()
Get the
BasicData object that holds all data for this item. |
private ExtensionsInvoker<ValidationAction> |
getInvoker(DbControl dc) |
FileStoreEnabled |
getItem()
Get the item this file set belongs to.
|
Item |
getItemType()
Get the
Item type of the item this file set belongs to. |
FileSetMember |
getMember(DataFileType type)
Get the member of the given type assuming that there
is only a single member of that type.
|
ItemQuery<FileSetMember> |
getMembers()
Get the members of this file set.
|
ItemQuery<FileSetMember> |
getMembers(DataFileType type)
Get a query that returns all members in a file set with a specific
DataFileType . |
ItemQuery<FileSetMember> |
getMembers(String genericType)
Get a query that returns all members in a file set with a specific
generic
ItemSubtype . |
ItemQuery<DataFileType> |
getMemberTypes()
Get a query that return the
DataFileType for all members
of this file set. |
ItemQuery<PlatformFileType> |
getMissingDataFileTypes()
Get a query that is returning all file types that
have been marked as required by the associated platform but has no member
in this file set.
|
(package private) static FileSet |
getNew(DbControl dc,
FileStoreEnabled item)
Create a new file set for the specified item.
|
int |
getNumMembers(DataFileType type)
Get the number of members in the file set of the specified type.
|
(package private) PluginPermission |
getPluginPermissions() |
(package private) static ItemQuery<FileSet> |
getQuery()
Get a
ItemQuery object configured to retrieve FileSet
items. |
Item |
getType()
Get the type of item represented by the object.
|
Set<ItemProxy> |
getUsingItems()
Get the item this file set belongs to.
|
boolean |
hasAllRequiredFiles()
Checks if this file set contains a file for
each
DataFileType that is required according to
what has been specified by the Platform and
PlatformVariant . |
boolean |
hasMember(DataFileType type)
Check if the file set contains at least one file of the specified type.
|
(package private) void |
initPermissions(int granted,
int denied)
READ permission is granted to all users.
|
boolean |
isUsed()
Always return TRUE.
|
void |
removeAllMembers()
Remove all members in a file set.
|
int |
removeAllOfType(DataFileType type)
Remove all member files of the given type.
|
private FileSetMember |
removeAllOfTypeExcept(DataFileType type,
File file)
Remove all member files of the given type.
|
boolean |
removeMember(File file,
DataFileType type)
Remove a file as a member from the file set.
|
void |
removeMember(FileSetMember member)
Remove the given member from this file set.
|
(package private) void |
setItem(FileStoreEnabled item)
Set the item this file set belongs to.
|
FileSetMember |
setMember(File file,
DataFileType type)
Set a file of a given type as a member of this file set.
|
List<Throwable> |
validate(DbControl dc)
Validate the files in this file set.
|
addUsingItems, addUsingItems, checkPermission, equals, getBasicData, getDbControl, getId, getPermissions, getSessionControl, getVersion, hashCode, hasPermission, isDetached, isInDatabase, onAfterCommit, onAfterInsert, onBeforeCommit, onRollback, setDbControl, setProjectDefaults, toString, validate
public static final Item TYPE
Item.FILESET
,
getType()
private static final QueryRuntimeFilter RUNTIME_FILTER
private FileStoreEnabled item
FileSet(FileSetData data)
FileSet(FileSetData data, FileStoreEnabled item)
getItem()
to hit the database
when the item is known beforehand.static FileSet getNew(DbControl dc, FileStoreEnabled item) throws BaseException
BaseException
public static FileSet getById(DbControl dc, int id) throws ItemNotFoundException, PermissionDeniedException, BaseException
FileSet
item when you know the id.dc
- The DbControl
which will be used for
permission checking and database access.id
- The id of the item to loadFileSet
itemItemNotFoundException
- If an item with the specified
id is not foundPermissionDeniedException
- If the logged in user doesn't
have read permission to the itemBaseException
- If there is another errorstatic ItemQuery<FileSet> getQuery()
ItemQuery
object configured to retrieve FileSet
items. This query may return items which the logged in user doesn't have
read permission to. At the moment there is no way to solve this problem.ItemQuery
objectFileSetData getData()
BasicItem
BasicData
object that holds all data for this item.public Item getType()
Identifiable
Item
enumeration.public boolean isUsed() throws BaseException
isUsed
in class BasicItem
BaseException
- If not able to tell if item is used or not.BasicItem.getUsingItems()
public Set<ItemProxy> getUsingItems() throws BaseException
getUsingItems
in class BasicItem
BaseException
- If there is an error loading the itemsBasicItem.addUsingItems(Set, Item, org.hibernate.Query)
void initPermissions(int granted, int denied) throws BaseException
initPermissions
in class BasicItem
granted
- Permissions that have been granted by the subclassdenied
- Permissions that have been denied by the subclassBaseException
- If the permissions couldn't be initialisedPluginPermission getPluginPermissions()
getPluginPermissions
in class BasicItem
public FileStoreEnabled getItem() throws PermissionDeniedException, BaseException
FileStoreEnabled
itemPermissionDeniedException
- If the logged in user doesn't have
read permission to the itemBaseException
- If there is another errorvoid setItem(FileStoreEnabled item)
public ItemQuery<FileSetMember> getMembers()
FileSetMember
itemspublic ItemQuery<FileSetMember> getMembers(String genericType)
ItemSubtype
. Note! The query checks the generic type from the
DataFileType.getGenericType()
, not the File.getItemSubtype()
.genericType
- The system ID of a generic type as defined
by ItemSubtype.getSystemId()
FileSetMember
itemspublic ItemQuery<FileSetMember> getMembers(DataFileType type)
DataFileType
.type
- The type of the fileFileSetMember
itemspublic FileSetMember setMember(File file, DataFileType type)
DbControl.commit()
is called. Calling this method is equivalent to first call
removeAllOfType(DataFileType)
and then addMember(File, DataFileType)
except that if the given file
already is a member that member entry is kept.file
- The file to set as a member (or null to remove it)type
- The type of the fileInvalidUseOfNullException
- If file or type is nullPermissionDeniedException
- If the logged in user doesn't
have write permission for this file set or use permission for the
filepublic FileSetMember addMember(File file, DataFileType type)
file
- The file to addtype
- The type of the fileInvalidUseOfNullException
- If file or type is nullPermissionDeniedException
- If the logged in user doesn't
have write permission for this file set or use permission for the
filepublic boolean hasMember(DataFileType type)
type
- A DataFileType
objectpublic int getNumMembers(DataFileType type)
type
- A DataFileType
objectpublic FileSetMember getMember(DataFileType type)
type
- A DataFileType
objectpublic void removeMember(FileSetMember member)
member
- The member to removepublic boolean removeMember(File file, DataFileType type)
file
- The file to removetype
- The type of the fileInvalidUseOfNullException
- If file or type is nullPermissionDeniedException
- If the logged in user doesn't
have write permission for this file setpublic int removeAllOfType(DataFileType type)
type
- A DataFileType
objectInvalidUseOfNullException
- If type is nullPermissionDeniedException
- If the logged in user
doesn't have write permission for this file setprivate FileSetMember removeAllOfTypeExcept(DataFileType type, File file)
type
- A DataFileType
objectInvalidUseOfNullException
- If type is nullPermissionDeniedException
- If the logged in user
doesn't have write permission for this file setpublic void removeAllMembers()
PermissionDeniedException
- If the logged in user
doesn't have write permission for this file setpublic ItemQuery<DataFileType> getMemberTypes()
DataFileType
for all members
of this file set.public boolean hasAllRequiredFiles()
DataFileType
that is required according to
what has been specified by the Platform
and
PlatformVariant
.PlatformFileType.isRequired()
public ItemQuery<PlatformFileType> getMissingDataFileTypes()
public List<Throwable> validate(DbControl dc)
Throwable
:s and is also
reported by setting the FileSetMember.isValid()
and
FileSetMember.getErrorMessage()
properties for each file.
Note! PermissionDeniedException
:s are not considered validation errors.
They are ignored and doesn't change the validation status.
InvalidRelationException
is a less severe type of exception
and can be used by a validator when the actual file it is validating
is valid but a dependent file is not. For example, a valid CEL file has
been attached to a raw bioassay, but it doesn't match the CDF file attached
to the array design. If a validator throws this exception the member status
will be set to invalid, but metadata is not reset.
dc
- The DbControl to use in the validation processprivate ExtensionsInvoker<ValidationAction> getInvoker(DbControl dc)