org.drupal.project.computing
Class DSite

java.lang.Object
  extended by org.drupal.project.computing.DSite
Direct Known Subclasses:
DDrushSite, DServicesSite, DSqlSite

public abstract class DSite
extends java.lang.Object

This is the super class to any Drupal site. A Drupal Hybrid Computing application will use this class and sub-classes to connect to Drupal sites. The suggested way to pass data between applications and Drupal site is through the DRecord objects (maps to a record in the {computing_record} table. You would have your Drupal module write input data to a record, and then your application read it and write results back to the output field in the record, and your Drupal module can read data back to the database.

It doesn't handle deleting of old records, which is handled by Drupal. Here we don't require DSite to offer nodeLoad(), nodeSave(), or userLoad(), etc, because of security concerns. If your application needs to read nodes, the Drupal part of your application will write the node info into the "input" field of computing_record, and then your Java application can read it. However, we don't prevent subclasses to provide a nodeLoad() method. If you use DDrushSite in particular, you can call any Drupal API with drush. Also, you can use DDatabase to access Drupal database directly, but it's not recommended.

A Drupal site doesn't need to know the DApplication, or DConfig.

Some sub-class implementations:


Field Summary
protected  java.util.logging.Logger logger
           
 
Constructor Summary
DSite()
           
 
Method Summary
 boolean checkConnection()
          Check whether connection to Drupal site is established.
abstract  java.lang.String getDrupalVersion()
           
 DRecord getNextRecord(java.lang.String appName)
          The first active record for the application.
abstract  long getTimestamp()
           
abstract  DRecord loadRecord(long id)
          Load one record according to its ID.
abstract  java.util.List<DRecord> queryActiveRecords(java.lang.String appName)
          Active records are those without a "status" code.
abstract  long saveRecord(DRecord record)
          Save the new record in the database using the data in the parameter.
abstract  void updateRecord(DRecord record)
          Save the updated record in the database.
abstract  void updateRecordField(DRecord record, java.lang.String fieldName)
          Update only the specified field of the record.
abstract  java.lang.Object variableGet(java.lang.String name, java.lang.Object defaultValue)
          Execute Drupal API "variable_get()"
abstract  void variableSet(java.lang.String name, java.lang.Object value)
          Execute Drupal API "variable_set()"
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected java.util.logging.Logger logger
Constructor Detail

DSite

public DSite()
Method Detail

getNextRecord

public DRecord getNextRecord(java.lang.String appName)
                      throws DConnectionException
The first active record for the application. Use this for the "first" running mode. Sub-classes can use whatever logic to implement this method.

Parameters:
appName -
Returns:
One active record for processing or null if no record is found.
Throws:
DConnectionException

queryActiveRecords

public abstract java.util.List<DRecord> queryActiveRecords(java.lang.String appName)
                                                    throws DConnectionException
Active records are those without a "status" code. All handled records has a status code. Usually, you would process the active records that has "REDY" control code. Other records might have other control code, and would be processed differently.

Parameters:
appName -
Returns:
All active records that are not handled.
Throws:
DConnectionException

updateRecord

public abstract void updateRecord(DRecord record)
                           throws DConnectionException
Save the updated record in the database.

Parameters:
record -
Throws:
DConnectionException

updateRecordField

public abstract void updateRecordField(DRecord record,
                                       java.lang.String fieldName)
                                throws DConnectionException
Update only the specified field of the record.

Parameters:
record -
fieldName -
Throws:
DConnectionException

saveRecord

public abstract long saveRecord(DRecord record)
                         throws DConnectionException
Save the new record in the database using the data in the parameter.

Parameters:
record - The newly created record. record.isSave() has too be true.
Returns:
The database record ID of the newly created record.
Throws:
DConnectionException

loadRecord

public abstract DRecord loadRecord(long id)
                            throws DConnectionException
Load one record according to its ID.

Parameters:
id -
Returns:
Throws:
DConnectionException

checkConnection

public boolean checkConnection()
Check whether connection to Drupal site is established.

Returns:
true if the connection is valid. will not throw exceptions.

getDrupalVersion

public abstract java.lang.String getDrupalVersion()
                                           throws DConnectionException
Returns:
The version of Drupal for this site.
Throws:
DConnectionException

variableGet

public abstract java.lang.Object variableGet(java.lang.String name,
                                             java.lang.Object defaultValue)
                                      throws DConnectionException
Execute Drupal API "variable_get()"

Parameters:
name -
defaultValue -
Returns:
Throws:
DConnectionException

variableSet

public abstract void variableSet(java.lang.String name,
                                 java.lang.Object value)
                          throws DConnectionException
Execute Drupal API "variable_set()"

Parameters:
name -
value -
Throws:
DConnectionException

getTimestamp

public abstract long getTimestamp()
                           throws DConnectionException
Returns:
Drupal site's current timestamp. Equivalent to PHP time().
Throws:
DConnectionException