|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object edu.nrao.sss.catalog.Catalog<SourceCatalogEntry,SourceGroup,SourceCatalog> edu.nrao.sss.model.source.SourceCatalog
public class SourceCatalog
A catalog of Source
s.
Each entry in a catalog is either a Source
or
SourceLookupTable
. This catalog also supports
the notion of SourceGroup
s, which serve to
associate sources with similar traits with one another.
Version Info:
$Revision: 2313 $ |
$Date: 2009-05-20 15:00:52 -0600 (Wed, 20 May 2009) $ |
$Author: btruitt $ |
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 | |
---|---|
SourceCatalog()
Creates a new catalog with a default name. |
|
SourceCatalog(String nameOfCatalog)
Creates a new catalog with the given name. |
Method Summary | |
---|---|
SourceCatalogEntry |
addItem(SourceCatalogEntry newItem)
Adds a new entry to this catalog. |
void |
clearId()
Resets this catalog's ID, and the IDs of all its contents, to a value that represents the unidentified state. |
SourceCatalog |
clone()
|
SourceGroup |
createGroup()
|
protected SourceGroup |
createMainGroup()
|
Source |
findSourceById(long id)
Returns the Source with the given id , if any. |
List<Source> |
findSourceByName(String name)
Returns the Source (s) with the given name , if any. |
SourceLookupTable |
findSourceTableById(long id)
Returns the SourceLookupTable with the given id , if any. |
List<SourceLookupTable> |
findSourceTableByName(String name)
Returns the SourceLookupTable (s) with the given name ,
if any. |
static SourceCatalog |
fromXml(Reader reader)
Creates a new catalog based on the XML data read from reader . |
static SourceCatalog |
fromXml(String xmlFile)
Creates a new catalog from the XML data in the given file. |
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. |
List<Source> |
getSources()
Returns a list of all sources held by this provider. |
List<Source> |
getSources(Filter<Source> filter)
Returns a list of sources held this provider that can pass through filter . |
List<SourceLookupTable> |
getSourceTables()
Returns a list of all source lookup tables held by this provider. |
List<SourceGroup> |
makeDeclinationGroups()
Returns a list of source groups based on the declinations of the sources in this catalog. |
List<SourceGroup> |
makeRightAscensionGroups()
Returns a list of source groups based on the right ascensions of the sources in this catalog. |
SourceCatalogEntry |
removeItem(int index)
|
SourceCatalogEntry |
removeItem(SourceCatalogEntry entry)
|
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 |
updateRaAndDecGroups()
Updates this catalog with a new collection of right ascension and declination groups. |
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 SourceCatalog()
public SourceCatalog(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<SourceCatalogEntry,SourceGroup,SourceCatalog>
protected SourceGroup createMainGroup()
createMainGroup
in class Catalog<SourceCatalogEntry,SourceGroup,SourceCatalog>
public SourceGroup createGroup()
createGroup
in class Catalog<SourceCatalogEntry,SourceGroup,SourceCatalog>
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<SourceCatalogEntry,SourceGroup,SourceCatalog>
public SourceCatalogEntry addItem(SourceCatalogEntry newItem)
addItem
in class Catalog<SourceCatalogEntry,SourceGroup,SourceCatalog>
newItem
- a new entry for this catalog.
newEntry
is nullnewEntry
is already contained in this catalogpublic SourceCatalogEntry removeItem(SourceCatalogEntry entry)
removeItem
in class Catalog<SourceCatalogEntry,SourceGroup,SourceCatalog>
public SourceCatalogEntry removeItem(int index)
removeItem
in class Catalog<SourceCatalogEntry,SourceGroup,SourceCatalog>
public List<SourceGroup> makeRightAscensionGroups()
Only those groups that have sources in the appropriate RA range are held by the returned list. Each group holds one hour-angle of sources. This method does not automatically add the returned groups to this catalog.
makeDeclinationGroups()
,
updateRaAndDecGroups()
public List<SourceGroup> makeDeclinationGroups()
Only those groups that have sources in the appropriate declination range are held by the returned list. Each group holds a declination range of ten degrees. This method does not automatically add the returned groups to this catalog.
makeRightAscensionGroups()
,
updateRaAndDecGroups()
public void updateRaAndDecGroups()
This method is thorough, but not efficient. It works by creating brand new RA and Dec groups, removing the current RA and Dec groups (if any), and then adding the new groups. If you want to make RA and Dec groups for the first time, if you are adding several sources at once, or if you suspect that the sources' positions may have changed, calling this method is probably the right thing to do. If you are adding just one new source, though, and if you know its RA and Dec, it could be more efficient to add it directly to the RA group and Dec group to which it belongs on your own.
makeDeclinationGroups()
,
makeRightAscensionGroups()
public List<Source> getSources(Filter<Source> filter) throws RepositoryException
SourceProvider
filter
. If filter
is null, it will be treated
as a wide-open filter, allowing all sources to pass.
getSources
in interface SourceProvider
filter
- the filter through which a source must pass in order
to be included in the returned set.
filter
.
RepositoryException
- if anything goes wrong while trying to fetch
sources from this provider.public List<Source> getSources() throws RepositoryException
SourceProvider
getSources
in interface SourceProvider
RepositoryException
- if anything goes wrong while trying to fetch
sources from this provider.public List<SourceLookupTable> getSourceTables() throws RepositoryException
SourceProvider
getSourceTables
in interface SourceProvider
RepositoryException
- if anything goes wrong while trying to fetch
tables from this provider.public Source findSourceById(long id) throws RepositoryException
SourceProvider
Source
with the given id
, if any.
If this provider holds no Source
with an ID of id
,
null is returned.
findSourceById
in interface SourceProvider
id
- the identifier (primary key) for a Source
in this
repository.
Source
with the given id
, or
null, if this provider holds no such Source
.
RepositoryException
- if anything goes wrong while trying to fetch
sources from this provider.public List<Source> findSourceByName(String name) throws RepositoryException
SourceProvider
Source
(s) with the given name
, if any.
Ideally, the returned list will contain only one source. However,
since the name is not usually used as a primary key to a source, it
is possible that the returned list may contain more than one source.
If this provider holds no Source
with a name of name
,
the returned list will be empty.
findSourceByName
in interface SourceProvider
name
- the name of a Source
requested from this provider.
Source
s with the given name
, or
null, if this provider holds no such Source
.
RepositoryException
- if anything goes wrong while trying to fetch
sources from this provider.public SourceLookupTable findSourceTableById(long id) throws RepositoryException
SourceProvider
SourceLookupTable
with the given id
, if any.
If this provider holds no SourceLookupTable
with an ID of
id
, null is returned.
findSourceTableById
in interface SourceProvider
id
- the identifier (primary key) for a SourceLookupTable
in
this repository.
SourceLookupTable
with the given id
, or
null, if this provider holds no such
SourceLookupTable
.
RepositoryException
- if anything goes wrong while trying to fetch
source tables from this provider.public List<SourceLookupTable> findSourceTableByName(String name) throws RepositoryException
SourceProvider
SourceLookupTable
(s) with the given name
,
if any.
Ideally, the returned list will contain only one table. However,
since the name is not usually used as a primary key to a table, it
is possible that the returned list may contain more than one table.
If this provider holds no SourceLookupTable
with a name of
name
, the returned list will be empty.
findSourceTableByName
in interface SourceProvider
name
- the name of a SourceLookupTable
requested from
this provider.
SourceLookupTable
s with the given name
,
or null, if this provider holds no such table.
RepositoryException
- if anything goes wrong while trying to fetch
tables from this provider.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 static SourceCatalog 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 SourceCatalog 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<SourceCatalogEntry,SourceGroup,SourceCatalog>
JAXBException
- if anything goes wrong during the conversion to XML.public void writeAsXmlTo(Writer writer) throws JAXBException
writer
.
writeAsXmlTo
in class Catalog<SourceCatalogEntry,SourceGroup,SourceCatalog>
writer
- the device to which XML is written.
JAXBException
- if anything goes wrong during the conversion to XML.public SourceCatalog clone()
clone
in class Catalog<SourceCatalogEntry,SourceGroup,SourceCatalog>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |