Main Page | Packages | Class Hierarchy | Class List | Directories | File List | Class Members | Related Pages

RunSeriesCollection Class Reference

Inheritance diagram for RunSeriesCollection:

Inheritance graph
[legend]
Collaboration diagram for RunSeriesCollection:

Collaboration graph
[legend]
List of all members.

Detailed Description

Collection of RunSeries which are associated with a single Model.
Author:
Jon Butterworth
Version:
Date
2007-01-12 18:57:03 +0000 (Fri, 12 Jan 2007)
Revision
1339

Definition at line 18 of file RunSeriesCollection.java.


Public Member Functions

 RunSeriesCollection ()
 RunSeriesCollection (int id) throws JetWebException
boolean retrieve () throws JetWebException
boolean store () throws JetWebException
RunSeries getRunSeries (DataPlot plot) throws JetWebException
Vector< RunSeriesgetRunSeriesList ()
Vector< RunSeriesgetRunSeriesList (MCProcessType proc)
int getId ()
void setId (int id)
boolean contains (DataPlot plot)
boolean add (RunSeries runSeries) throws JetWebException
Date getDate ()

Private Attributes

Vector< RunSeriesrunSeriesList
int id = -1

Constructor & Destructor Documentation

RunSeriesCollection  ) 
 

Instantiate an empty RunSeriesCollection

Definition at line 26 of file RunSeriesCollection.java.

References RunSeriesCollection.runSeriesList.

00026                                 {
00027     runSeriesList = new Vector<RunSeries>();
00028     }

RunSeriesCollection int  id  )  throws JetWebException
 

Instantiate a RunSeriesCollection with and id number = id, and fill it from the database, if a runseries already exists in the database with this id.

Definition at line 36 of file RunSeriesCollection.java.

References RunSeriesCollection.retrieve(), and RunSeriesCollection.runSeriesList.

00036                                                               {
00037     runSeriesList = new Vector<RunSeries>();
00038     this.id = id;
00039     retrieve();
00040     }


Member Function Documentation

boolean add RunSeries  runSeries  )  throws JetWebException
 

Adds a runseries id to the collection if the model doesn't already contain a runseries associated with the same processType that matches the Cut Collection

Parameters:
runseries specifies runseries
Returns:
true if update is performed, false if it is unnecessary
Exceptions:
JetWebException 

Definition at line 147 of file RunSeriesCollection.java.

References CutCollection.equals(), RunSeries.getCutCollection(), CutCollection.getId(), MCProcessType.getId(), RunSeries.getMCProcessType(), and RunSeriesCollection.runSeriesList.

Referenced by Model.addAllRunSeries(), RunSeriesCollection.getRunSeriesList(), Model.Model(), and Model.setFrom().

00147                                                                    {
00148 
00149     System.out.println("CCC Called RunSeriesCollection.add");
00150 
00151     boolean found = false;
00152 
00153     int ptid = runSeries.getMCProcessType().getId();
00154 
00155     System.out.println("ptid = "+ptid);
00156 
00157     CutCollection cuts = runSeries.getCutCollection();
00158 
00159     Enumeration<RunSeries> list = runSeriesList.elements();
00160     while (list.hasMoreElements() && !found){
00161         RunSeries rs = list.nextElement();
00162         System.out.println("existing proc id = " +rs.getMCProcessType().getId());
00163 
00164         //Do check on cuts both being empty here!!
00165 
00166         if (rs.getMCProcessType().getId()==ptid && 
00167         (cuts.equals(rs.getCutCollection())||cuts.getId()==rs.getCutCollection().getId())){
00168         found=true;
00169         }
00170     }
00171 
00172     if (!found){
00173         runSeriesList.add(runSeries);
00174         //need to update runseriescollection in db
00175         //this seems a sensible place to do it
00176         if(id>0){
00177         DBManager.updateDB(this, runSeries);
00178         }
00179     } else {
00180         System.out.println("RunSeries not added: already one matching this MCProcessType");
00181     }
00182     return !found;
00183     }

boolean contains DataPlot  plot  ) 
 

Does the collection contain a RunSeries which contains a prediction for this plot?

Definition at line 126 of file RunSeriesCollection.java.

References DataPlot.isPredictedBy(), and RunSeriesCollection.runSeriesList.

Referenced by Model.predicts().

00126                                           {
00127     
00128     Enumeration<RunSeries> list = runSeriesList.elements();
00129     while (list.hasMoreElements()){
00130         RunSeries rs = (RunSeries)list.nextElement();
00131         if (plot.isPredictedBy(rs)){
00132         return true;
00133         }
00134     }
00135     return false;
00136     }

Date getDate  ) 
 

get the last date at which any data was added to any RunSeries in this collection.

Definition at line 189 of file RunSeriesCollection.java.

References RunSeries.getDate(), and RunSeriesCollection.runSeriesList.

Referenced by Model.getDate().

00189                          {
00190 
00191     Date d = new Date(0);
00192 
00193         Enumeration<RunSeries> list = runSeriesList.elements();
00194     while (list.hasMoreElements()){
00195         RunSeries rs = list.nextElement();
00196         if (rs.getDate().after(d)) { d=rs.getDate(); } 
00197     }
00198     return d;
00199     }

int getId  ) 
 

Return the unique identification number of the collection.

Implements Storeable.

Definition at line 112 of file RunSeriesCollection.java.

Referenced by Model.addAllRunSeries(), Model.getId(), Model.Model(), and Model.store().

00112                       {
00113     return id;
00114     }

RunSeries getRunSeries DataPlot  plot  )  throws JetWebException
 

Return the RunSeries from this collection which contains the prediction for the input DataPlot

Definition at line 70 of file RunSeriesCollection.java.

References RunSeriesCollection.runSeriesList.

Referenced by FittedPlot.getMCProcessType().

00070                                                                         {
00071     Enumeration<RunSeries> en = runSeriesList.elements();
00072     while (en.hasMoreElements()){
00073         RunSeries rs = en.nextElement();
00074         if (plot.isPredictedBy(rs)) {return rs;}
00075     }
00076     JetWebException j = 
00077         new JetWebException("RunSeriesCollection: No prediction for this plot",
00078                         "ID:"+plot.getId());
00079     throw j;
00080     }

Vector<RunSeries> getRunSeriesList MCProcessType  proc  ) 
 

Return Vector of all RunSeries in this collection which are compatible with MCProcessType proc.

Definition at line 93 of file RunSeriesCollection.java.

References RunSeriesCollection.add(), RunSeries.getMCProcessType(), MCProcessType.matches(), and RunSeriesCollection.runSeriesList.

00093                                                                  {
00094     Vector<RunSeries> list = new Vector<RunSeries>();
00095     Enumeration<RunSeries> en = runSeriesList.elements();
00096     while (en.hasMoreElements()){
00097         RunSeries rs = en.nextElement();
00098         try{
00099         if (rs.getMCProcessType().matches(proc)) {
00100             add(rs);
00101         }
00102         }catch (Throwable err){
00103         System.out.println(err.getMessage());
00104         }
00105     }
00106     return list;
00107     }

Vector<RunSeries> getRunSeriesList  ) 
 

Return Vector of all RunSeries in this collection

Definition at line 85 of file RunSeriesCollection.java.

Referenced by Model.getRunSeries(), and Model.zero().

00085                                                {
00086     return runSeriesList;
00087     }

boolean retrieve  )  throws JetWebException
 

Populate the object in memory from the database. Return true if the information retrieved is up to date.

Implements Storeable.

Definition at line 43 of file RunSeriesCollection.java.

Referenced by RunSeriesCollection.RunSeriesCollection().

00043                                                      {
00044 
00045     if (id < 0) {
00046         throw new JetWebException("Tried to retrieve RunSeriesCollection with no id","error");
00047     }
00048     try {
00049         DBManager.selectFromDB(this);
00050     } catch (Exception e) {
00051         throw new JetWebException(e,"Error retrieving RunSeriesCollection");
00052     }
00053     return true;
00054     }

void setId int  id  ) 
 

Set the unique identification number of the collection.

Definition at line 118 of file RunSeriesCollection.java.

00118                              {
00119     this.id=id;
00120     }

boolean store  )  throws JetWebException
 

Write the object in memory to the database. If the ID does not exist in the DB the object is inserted as a new entry. If the ID exists, that entry is updated.

Returns:
true if the object was inserted, false otherwise.

Implements Storeable.

Definition at line 56 of file RunSeriesCollection.java.

Referenced by Model.store().

00056                                                   {
00057 
00058     if (id>=0) {
00059         return DBManager.updateDB(this);
00060     } else {
00061         return DBManager.addToDB(this);
00062     }
00063     }


Member Data Documentation

int id = -1 [private]
 

Definition at line 21 of file RunSeriesCollection.java.

Vector<RunSeries> runSeriesList [private]
 

Definition at line 20 of file RunSeriesCollection.java.

Referenced by RunSeriesCollection.add(), RunSeriesCollection.contains(), RunSeriesCollection.getDate(), RunSeriesCollection.getRunSeries(), RunSeriesCollection.getRunSeriesList(), and RunSeriesCollection.RunSeriesCollection().


The documentation for this class was generated from the following file:

Generated Wed Jan 17 09:14:27 GMT 2007