|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object edu.nrao.sss.catalog.Catalog<Resource,ResourceGroup,ResourceCatalog> edu.nrao.sss.model.resource.ResourceCatalog
public class ResourceCatalog
A catalog of Resource
s.
Each entry in a resource catalog is a Resource
.
This catalog also supports
the notion of ResourceGroup
s, which serve to
associate resources with similar traits with one another.
Version Info:
$Revision: 1709 $ |
$Date: 2008-11-14 11:22:37 -0700 (Fri, 14 Nov 2008) $ |
$Author: dharland $ (last person to modify) |
Field Summary |
---|
Fields inherited from interface edu.nrao.sss.util.Identifiable |
---|
UNIDENTIFIED |
Fields inherited from interface edu.nrao.sss.model.UserAccountable |
---|
NULL_USER_ID |
Constructor Summary | |
---|---|
ResourceCatalog()
Creates a new catalog with a default name. |
|
ResourceCatalog(String nameOfCatalog)
Creates a new catalog with the given name. |
Method Summary | |
---|---|
void |
clearId()
Resets this catalog's ID, and the IDs of all its contents, to a value that represents the unidentified state. |
ResourceCatalog |
clone()
|
ResourceGroup |
createGroup()
|
protected ResourceGroup |
createMainGroup()
|
Resource |
findResourceById(long id)
Returns the Resource with the given id , if any. |
List<Resource> |
findResourceByName(String name)
Returns the Resource (s) with the given name , if any. |
static ResourceCatalog |
fromXml(Reader reader)
Creates a new catalog based on the XML data read from reader . |
static ResourceCatalog |
fromXml(String xmlFile)
Creates a new catalog from the XML data in the given file. |
List<Resource> |
getAllResources()
Returns a list of all resources held by this provider. |
Long |
getCreatedBy()
Returns the ID of the user who created this object. |
Date |
getCreatedOn()
Returns the date on which this object was created. |
protected long |
getIdOfUnidentified()
Returns Identifiable.UNIDENTIFIED . |
Long |
getLastUpdatedBy()
Returns the ID of the user who most recently updated this object. |
Date |
getLastUpdatedOn()
Returns the most recent date on which this object was updated. |
Long |
getOwner()
Returns the ID of the user who owns this catalog. |
void |
setCreatedBy(Long userId)
Sets the ID of the user who created this object. |
void |
setCreatedOn(Date d)
Sets the date on which this object was created. |
void |
setLastUpdatedBy(Long userId)
Sets the ID of the user who most recently updated this object. |
void |
setLastUpdatedOn(Date d)
Sets the date on which this object was most recently updated. |
void |
setOwner(Long userId)
Sets the ID of the user who owns this catalog. |
String |
toXml()
Returns an XML representation of this catalog. |
void |
writeAsXmlTo(Writer writer)
Writes an XML representation of this catalog to writer . |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface edu.nrao.sss.util.Identifiable |
---|
getId |
Constructor Detail |
---|
public ResourceCatalog()
public ResourceCatalog(String nameOfCatalog)
nameOfCatalog
- the name of this catalog. If this value is
null, this catalog will be given a
default name.Method Detail |
---|
protected long getIdOfUnidentified()
Identifiable.UNIDENTIFIED
.
getIdOfUnidentified
in class Catalog<Resource,ResourceGroup,ResourceCatalog>
protected ResourceGroup createMainGroup()
createMainGroup
in class Catalog<Resource,ResourceGroup,ResourceCatalog>
public ResourceGroup createGroup()
createGroup
in class Catalog<Resource,ResourceGroup,ResourceCatalog>
public void clearId()
This method is useful for preparing a catalog for storage in a database. The ID property (as of now, though this may change in the future) is used by our persistence mechanism to identify objects. If you are persisting this catalog for the first time, you may need to call this method before performing a save. This is especially true if you have created this source from XML, as the XML unmarshalling brings along the ID property.
clearId
in class Catalog<Resource,ResourceGroup,ResourceCatalog>
public void setOwner(Long userId)
userId
- the ID of the user who owns this catalog. If this value is
null it will be replaced with
UserAccountable.NULL_USER_ID
.public void setCreatedBy(Long userId)
UserAccountable
If userId
is null, this object will be updated
not with null but with UserAccountable.NULL_USER_ID
instead.
setCreatedBy
in interface UserAccountable
userId
- the ID of the user who most recently updated this object.public void setCreatedOn(Date d)
UserAccountable
If d
is null it will be ignored and this method
will do nothing.
setCreatedOn
in interface UserAccountable
d
- the date on which this object was created.public void setLastUpdatedBy(Long userId)
UserAccountable
If userId
is null, this object will be updated
not with null but with UserAccountable.NULL_USER_ID
instead.
setLastUpdatedBy
in interface UserAccountable
userId
- the ID of the user who most recently updated this object.public void setLastUpdatedOn(Date d)
UserAccountable
If d
is null it will be ignored and this method
will do nothing.
setLastUpdatedOn
in interface UserAccountable
d
- the date on which this object was most recently updated.public Long getOwner()
public Long getCreatedBy()
UserAccountable
If this object does not know the identity of the user who created
it, the returned ID will be UserAccountable.NULL_USER_ID
.
getCreatedBy
in interface UserAccountable
public Date getCreatedOn()
UserAccountable
getCreatedOn
in interface UserAccountable
public Long getLastUpdatedBy()
UserAccountable
If this object does not know the identity of the user who lasted
updated it, the returned ID will be UserAccountable.NULL_USER_ID
.
getLastUpdatedBy
in interface UserAccountable
public Date getLastUpdatedOn()
UserAccountable
getLastUpdatedOn
in interface UserAccountable
public Resource findResourceById(long id) throws RepositoryException
Resource
with the given id
, if any.
If this provider holds no Resource
with an ID of id
,
null is returned.
findResourceById
in interface ResourceProvider
id
- the identifier (primary key) for a Resource
in this
repository.
Resource
with the given id
, or
null, if this provider holds no such Resource
.
RepositoryException
- if anything goes wrong while trying to fetch
resources from this provider.public List<Resource> findResourceByName(String name) throws RepositoryException
Resource
(s) with the given name
, if any.
Ideally, the returned list will contain only one resource. However,
since the name is not usually used as a primary key to a resource, it
is possible that the returned list may contain more than one resource.
If this provider holds no Resource
with a name of name
,
the returned list will be empty.
findResourceByName
in interface ResourceProvider
name
- the name of a Resource
requested from this provider.
Resource
s with the given name
, or
null, if this provider holds no such Resource
.
RepositoryException
- if anything goes wrong while trying to fetch
resources from this provider.public List<Resource> getAllResources() throws RepositoryException
getAllResources
in interface ResourceProvider
RepositoryException
- if anything goes wrong while trying to fetch
resources from this provider.public static ResourceCatalog fromXml(String xmlFile) throws JAXBException, XMLStreamException, FileNotFoundException
xmlFile
- the name of an XML file. This method will attempt to locate
the file by using Class.getResource(String)
.
FileNotFoundException
- if the XML file cannot be found.
JAXBException
- if the schema file used (if any) is malformed, if
the XML file cannot be read, or if the XML file is not
schema-valid.
XMLStreamException
- if there is a problem opening the XML file,
if the XML is not well-formed, or for some other
"unexpected processing conditions".public static ResourceCatalog fromXml(Reader reader) throws JAXBException, XMLStreamException
reader
.
reader
- the source of the XML data.
If this value is null, null is returned.
reader
.
XMLStreamException
- if the XML is not well-formed,
or for some other "unexpected processing conditions".
JAXBException
- if anything else goes wrong during the
transformation.public String toXml() throws JAXBException
toXml
in class Catalog<Resource,ResourceGroup,ResourceCatalog>
JAXBException
- if anything goes wrong during the conversion to XML.public void writeAsXmlTo(Writer writer) throws JAXBException
writer
.
writeAsXmlTo
in class Catalog<Resource,ResourceGroup,ResourceCatalog>
writer
- the device to which XML is written.
JAXBException
- if anything goes wrong during the conversion to XML.public ResourceCatalog clone()
clone
in class Catalog<Resource,ResourceGroup,ResourceCatalog>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |