public class Product extends AbstractComposite<Product> implements Copyable<Product>
In general a Product contains zero or more datasets, history, optional
metadata as well as some required metadata fields.
Its intent is that it can fully describe itself; this includes the way how
this product was achieved (its history
).
As it is the result of a process, it should be able to save to and restore
from an Archive device, which is described in the herschel.ia.io package.
Many times a Product may contain a single dataset and for this purpose
the first dataset entry can be accessed by the getDefault()
method.
Note that the datasets may be a composite
of datasets
by themselves.
creation:creation: $ x=Product(description="This is my product example",instrument="MyFavourite",modelName="Flight") $ xaccess:["RawImage"]
=anImage $ x["QualityImage"]
=aQualityImage $ x["Spectrum"]
=aSpectrum $ x.creator
="Me, myself and I" $ x.meta
["Version"]= StringParameter(value="2.1.1a",description="patch taken from download.herschel.int")$ print x $ print x.comparison:default
# returns the first added dataset: "RawImage" $ raw=x.["RawImage"]
$ print x.creator
$ print x.description
$ p1=Product
(description
="Description") $ p2=Product
(description
="Description 2") $ print p1.equals(p2) #shows '0': false $ print p1.equals(p1) #shows '1': true #A complete report: $ print herschel.ia.toolbox.util.ProductDiff.diff(p1,p2) #shows a report
Mandatory Meta-Data:
All Products must have the following Meta-Data fields:
Metadata table Keyword Value Type Comment creator java.lang.String Creator of this Product creationDate herschel.share.fltdyn.time.FineTime Time of creation of this Product (TAI) description java.lang.String Full name of the product if applicable or UNKNOWN
instrument java.lang.String Instrument name: SPIRE|PACS|HIFI|SC startDate herschel.share.fltdyn.time.FineTime Start time of applicability (TAI) endDate herschel.share.fltdyn.time.FineTime End time of applicability (TAI) modelName java.lang.String Model name if applicable or UNKNOWN
type java.lang.String Sub-type within this Product family if applicable or UNKNOWN
Developers sub-classing Product:
This generic product is not final; that is, under certain conditions described in the developer's documentation one is allowed to extend this class within Java.
ArrayDataset
,
TableDataset
,
CompositeDataset
,
MetaData
,
History
Modifier and Type | Class and Description |
---|---|
static class |
Product.DatasetProductLinkedHashMap
HashMap extension for checking 'History' dataset.
'History' dataset is not allowed to be added as a any other dataset. |
Modifier and Type | Field and Description |
---|---|
static List<String> |
ATTRIBUTES
List of mandatory metadata entries in all products.
|
static String |
CREATION_DATE
Standard key for creationDate
|
static String |
CREATOR
Standard key for creator
|
static String |
DESCRIPTION
Standard key for description
|
static String |
END_DATE
Standard key for endDate
|
static String |
FORMATV
Standard key for format version
|
static String |
FORMATV_DESCRIPTION
Standard description for format version
|
static String |
FORMATV_INIT_VALUE
Standard value for format version
|
static String |
HISTORY
Standard key for History dataset
|
static String |
INSTRUMENT
Standard key for instrument
|
static String |
MODEL_NAME
Standard key for modelName
|
static String |
START_DATE
Standard key for startDate
|
static String |
TYPE
Standard key for type
|
static String |
UNKNOWN
Unknown string value.
|
Constructor and Description |
---|
Product()
Constructs an empty product
|
Product(Product copy)
Constructs this as a deep copy of specified argument.
|
Product(String description)
Constructs a product with a description
|
Modifier and Type | Method and Description |
---|---|
void |
accept(DatasetVisitor visitor)
Adds functionality through visitor pattern.
|
void |
addProductListener(ProductListener listener)
Adds a listener to the product.
|
protected String |
contentsToString()
Provides a formatted string with information common to all annotatables.
|
Product |
copy()
Returns a deep copy of this Product.
|
boolean |
equals(Object obj) |
FineTime |
getCreationDate()
Returns the creation date of this product.
|
String |
getCreator()
Returns the creator of this product.
|
Dataset |
getDefault()
Convenience method that returns the first dataset belonging to this product.
|
String |
getDescription()
gets the description of this Annotatable object.
|
double |
getDuration()
Return the duration in hours of a this Product.
|
String |
getDurationText()
Return the duration of this Product as a human
friendly readable string
|
FineTime |
getEndDate()
Returns the end date of this product.
|
String |
getFormatVersion()
Returns the format version of this product
|
History |
getHistory()
Accesses the History of this product.
|
String |
getInstrument()
Returns the instrument name of this product.
|
String |
getModelName()
Returns the model name of this product.
|
ProductOwner |
getOwner()
Returns the product's owner; may be
null . |
Map<String,Dataset> |
getSets()
Provide access to the Map<String, Dataset>.
|
FineTime |
getStartDate()
Returns the creation date of this product.
|
String |
getType()
Returns the type of this product.
|
int |
hashCode() |
void |
removeProductListener(ProductListener listener)
Removes a listener to the product.
|
void |
setCreationDate(FineTime creationDate)
Changes the creation date of this product.
|
void |
setCreator(String creator)
Changes the creator of this product.
|
void |
setDescription(String newDescription)
Changes the description of this product;
a
null description is converted to the string UNKNOWN |
void |
setEndDate(FineTime endDate)
Changes the end date of this product.
|
void |
setFormatVersion(String formatv)
Changes the format version of this product
|
void |
setHistory(History history)
Replaces the history of this product.
|
void |
setInstrument(String instrument)
Changes the instrument name of this product.
|
void |
setMeta(MetaData newMeta)
Changes the meta data.
|
void |
setModelName(String modelName)
Changes the model name of this product.
|
void |
setOwner(ProductOwner owner)
Sets the product's owner; may be
null . |
void |
setStartDate(FineTime startDate)
Changes the start date of this product.
|
void |
setType(String type)
Changes the type of this product.
|
__getitem__, __setitem__, containsKey, get, getDataWrappers, getMeta, isEmpty, keySet, remove, set, size, targetChanged
getEventSupport, toString
public static final String FORMATV
public static final String FORMATV_DESCRIPTION
public static final String FORMATV_INIT_VALUE
public static final String CREATOR
public static final String CREATION_DATE
public static final String DESCRIPTION
public static final String INSTRUMENT
public static final String START_DATE
public static final String END_DATE
public static final String MODEL_NAME
public static final String TYPE
public static final String HISTORY
public static final List<String> ATTRIBUTES
public static final String UNKNOWN
public Product()
public Product(String description)
description
- the descriptionpublic Product(Product copy)
copy
- original product.public Product copy()
The copy has the same Product class instance containing a deep copy of meta-data datasets and history.
If sub-classes override this method, they always have to call this method first.
@Override public T copy() { T copy=(T)super.copy(); : return copy; }
public void setMeta(MetaData newMeta)
setMeta
in interface Attributable
setMeta
in class AbstractComposite<Product>
newMeta
- the new meta datapublic final History getHistory()
public final void setHistory(History history)
history
- the history to replacepublic final Dataset getDefault()
Dataset
.NoSuchElementException
- if the product does not contain any dataset.public final String getDescription()
Annotatable
getDescription
in interface Annotatable
getDescription
in class AbstractAnnotatable<Product>
public final void setDescription(String newDescription)
null
description is converted to the string UNKNOWN
setDescription
in interface Annotatable
setDescription
in class AbstractAnnotatable<Product>
newDescription
- the new descriptionpublic final String getType()
public final void setType(String type)
type
- the typepublic final String getCreator()
public final void setCreator(String creator)
creator
- the creation datepublic final FineTime getCreationDate()
public final void setCreationDate(FineTime creationDate)
creationDate
- the creation datepublic final String getInstrument()
public final void setInstrument(String instrument)
instrument
- the instrument namepublic final String getModelName()
public final void setModelName(String modelName)
modelName
- the model namepublic final FineTime getStartDate()
public final void setStartDate(FineTime startDate)
startDate
- the start datepublic final FineTime getEndDate()
public final void setEndDate(FineTime endDate)
endDate
- the end datepublic ProductOwner getOwner()
null
.public void setOwner(ProductOwner owner)
null
.owner
- the ownerpublic final String getFormatVersion()
public final void setFormatVersion(String formatv)
formatv
- the format versionprotected String contentsToString()
AbstractAnnotatable
contentsToString
in class AbstractComposite<Product>
public void addProductListener(ProductListener listener)
Warning:
The listener handler must be a class attribute in order to create an object hard reference.
See DatasetBaseListener
.
listener
- the listenerpublic void removeProductListener(ProductListener listener)
listener
- the listenerpublic void accept(DatasetVisitor visitor)
visitor
- the added functionalitypublic Map<String,Dataset> getSets()
AbstractComposite
getSets
in class AbstractComposite<Product>
public double getDuration()
public String getDurationText()