com.irisel.sv.faces.mgdbeans
Class BaseMB

java.lang.Object
  extended by com.irisel.sv.faces.mgdbeans.BaseMB
Direct Known Subclasses:
AdMB, TableMB, TimeReportMB, UserMB

public abstract class BaseMB
extends java.lang.Object


Constructor Summary
BaseMB()
          If clbrowser is null, initializes it as new CLGuiomBrowser.
BaseMB(CLBrowser clbrowser, java.lang.String classname)
          Sets the clbrowser and does the initializations: Initializes logger, instance, and if there is a FacesContext, request and session.
 
Method Summary
 void delete(boolean soft)
          Deletes this instance from the database
 java.lang.Object get(java.lang.String key)
          Returns the value for an attribute of this object's instance
 long getId()
           
 Instance getInstance()
           
 java.lang.String getName()
           
 void load(JSONObject obj)
          Loads from the given JSON to this object for the class given by getClassname(), each property is read and copied from the json obj.
 void load(long oid)
          Loads the instance from database into this object, uses the classname associated to the object which is implemented by the abstract getClassname().
 void load(java.lang.String name)
          Loads from the database to this object, the record given by "name" for the class given by getClassname()
 void logout()
           
static void main(java.lang.String[] args)
           
 void save()
          Saves this object to database.
 void set(java.lang.String key, java.lang.Object value)
          Sets the value for the given attribute
 void setInstance(Instance inst)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BaseMB

public BaseMB()
       throws java.lang.Exception
If clbrowser is null, initializes it as new CLGuiomBrowser. Initializes logger, instance, and if there is a FacesContext, request and session. Does not initialize instance, userInstance and employeeInstance

Throws:
java.lang.Exception

BaseMB

public BaseMB(CLBrowser clbrowser,
              java.lang.String classname)
       throws java.lang.Exception
Sets the clbrowser and does the initializations: Initializes logger, instance, and if there is a FacesContext, request and session. Does not initialize userInstance and employeeInstance

Throws:
java.lang.Exception
Method Detail

getInstance

public Instance getInstance()

setInstance

public void setInstance(Instance inst)

logout

public void logout()

load

public void load(long oid)
          throws java.rmi.RemoteException,
                 java.sql.SQLException,
                 DataException
Loads the instance from database into this object, uses the classname associated to the object which is implemented by the abstract getClassname().

Parameters:
oid - is the primary key of the instance
Throws:
java.rmi.RemoteException
java.sql.SQLException
DataException

load

public void load(java.lang.String name)
          throws java.rmi.RemoteException,
                 java.sql.SQLException,
                 DataException
Loads from the database to this object, the record given by "name" for the class given by getClassname()

Parameters:
name -
Throws:
java.rmi.RemoteException
java.sql.SQLException
DataException

load

public void load(JSONObject obj)
          throws java.lang.Exception
Loads from the given JSON to this object for the class given by getClassname(), each property is read and copied from the json obj.

Parameters:
obj - is the JSON representation of the object
Throws:
java.rmi.RemoteException
java.sql.SQLException
DataException
java.lang.Exception

getId

public long getId()
Returns:
the id of this object's instance.

getName

public java.lang.String getName()
Returns:
the "name" value of this object's instance.

save

public void save()
          throws QuerySaveException,
                 java.rmi.RemoteException,
                 java.sql.SQLException,
                 DataException
Saves this object to database. Calls clbrowser.setAutomaticFields first. If getId() is 0, calls clbrowser.create(), otherwise clbrowser.update()

Throws:
QuerySaveException
java.rmi.RemoteException
java.sql.SQLException
DataException

get

public java.lang.Object get(java.lang.String key)
Returns the value for an attribute of this object's instance

Parameters:
key - the name of the attribute
Returns:

set

public void set(java.lang.String key,
                java.lang.Object value)
Sets the value for the given attribute

Parameters:
key - name of the attribute
value -

main

public static void main(java.lang.String[] args)
Parameters:
args -

delete

public void delete(boolean soft)
            throws java.rmi.RemoteException,
                   java.sql.SQLException,
                   DataException
Deletes this instance from the database

Parameters:
soft - will flag the record as deleted, without actually deleting it
Throws:
java.rmi.RemoteException
java.sql.SQLException
DataException