com.ragic.s3.service.workflow
Class ScriptBDBSmartWorker

java.lang.Object
  extended by com.ragic.s3.service.workflow.ScriptBDBSmartWorker
Direct Known Subclasses:
ExecuteScriptWorker

public class ScriptBDBSmartWorker
extends java.lang.Object

ScriptBDBSmartWorker is an essential class when manipulating database. It provides several functions to register new values and access current values of existing fields. Also, the function to create a new record is also included in this class.

Try to imagine the whole database as a graph. The main task of BDBSmartWorker is to work on this great graph for you. Each value you creates is a new node on this graph. Therefore each node has a distinct node ID to be identified. All nodes associated with a certain field are connected and are regarded as a group, just like how graphs work. Thus field ID is also important when finding and manipulating a node.

Make sure to keep above words in mind. They are pretty useful when working with these functions.


Constructor Summary
ScriptBDBSmartWorker(java.lang.String apname)
           
 
Method Summary
 int addFieldSelectionValue(int rootDomainId, int rootNodeId, int fieldDomainId, java.lang.String value)
          Extend a new choice of the given selection-typed field when field ID and node ID of root field are provided.
 int addFieldSelectionValue(int rootDomainId, java.lang.String keyValue, int fieldDomainId, java.lang.String value)
          Extend a new choice of the given selection-typed field when field ID and value of root field are provided.
 int[] addRecord(int[] domainIds, java.lang.String[] values, boolean[] ifMerge)
          Register a new record by providing serial field IDs, corresponding values and an array of boolean values indicating if these new nodes should be merged with old values or not.
 int getFieldNodeId(int rootDomainId, int rootNodeId, int fieldDomainId)
          Returns node ID of the given field when node ID of root field is provided.
 int getFieldNodeId(int rootDomainId, java.lang.String keyValue, int fieldDomainId)
          Returns node ID of the given field when value of root field is provided.
 java.util.List<java.lang.Integer> getFieldNodeIds(int rootDomainId, int rootNodeId, int fieldDomainId)
          Returns a list of string-typed value of the given selection-typed field when node ID of root field is provided.
 java.util.List<java.lang.Integer> getFieldNodeIds(int rootDomainId, java.lang.String keyValue, int fieldDomainId)
          Returns a list of string-typed node ID of the given selection-typed field when the value of root field is provided.
 java.lang.String getFieldValue(int rootDomainId, int rootNodeId, int fieldDomainId)
          Returns string-typed value of the given field when node ID of root field is provided.
 java.lang.String getFieldValue(int rootDomainId, java.lang.String keyValue, int fieldDomainId)
          Returns string-typed value of the given field when value of root field is provided.
 java.util.List<java.lang.String> getFieldValues(int rootDomainId, int rootNodeId, int fieldDomainId)
          Returns a list of string-typed value of the given selection-typed field when node ID of root field is provided.
 java.util.List<java.lang.String> getFieldValues(int rootDomainId, java.lang.String keyValue, int fieldDomainId)
          Returns a list of string-typed value of the given selection-typed field when value of root field is provided.
 java.lang.String getFieldValuesString(int rootDomainId, java.lang.String keyValue, int fieldDomainId)
          Returns a joined string of values of the given selection-typed field when value of root field is provided.
 int setFieldSelectionValue(int rootDomainId, int rootNodeId, int fieldDomainId, java.lang.String value)
          Register the first choice to the given selection-typed field when field ID and node ID of root field are provided.
 int setFieldSelectionValue(int rootDomainId, java.lang.String keyValue, int fieldDomainId, java.lang.String value)
          Register the first choice to the given selection-typed field when field ID and value of root field are provided.
 int[] setFieldSelectionValues(int rootDomainId, int rootNodeId, int fieldDomainId, java.util.List<java.lang.String> values)
          Register a list of all choices to the given selection-typed field when field ID and node ID of root field are provided.
 int[] setFieldSelectionValues(int rootDomainId, int rootNodeId, int fieldDomainId, java.lang.String[] values)
          Register an array of all choices to the given selection-typed field when field ID and node ID of root field are provided.
 int[] setFieldSelectionValues(int rootDomainId, java.lang.String keyValue, int fieldDomainId, java.util.List<java.lang.String> values)
          Register a list of all choices to the given selection-typed field when ID and value of root field are provided.
 int[] setFieldSelectionValues(int rootDomainId, java.lang.String keyValue, int fieldDomainId, java.lang.String[] values)
          Register an array of all choices to the given selection-typed field when ID and value of root field are provided.
 void setFieldValue(int rootDomainId, int rootNodeId, int fieldDomainId, java.lang.String value)
          Register a new value to the given field when field ID and node ID of root field are provided.
 void setFieldValue(int rootDomainId, java.lang.String keyValue, int fieldDomainId, java.lang.String value)
          Register a new value to the given field when field ID and value of root field are provided.
 void setValue(int domainId, java.lang.String keyValue, java.lang.String newValue)
          Register a new value to the given field when current value of this field is provided.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ScriptBDBSmartWorker

public ScriptBDBSmartWorker(java.lang.String apname)
Method Detail

getFieldValue

public java.lang.String getFieldValue(int rootDomainId,
                                      java.lang.String keyValue,
                                      int fieldDomainId)
Returns string-typed value of the given field when value of root field is provided.

Parameters:
rootDomainId - root field ID of this form or this subtable.
keyValue - value of root field ID (first parameter).
fieldDomainId - field ID of the one of interest.
Returns:
string-typed value of the given field.

getFieldValue

public java.lang.String getFieldValue(int rootDomainId,
                                      int rootNodeId,
                                      int fieldDomainId)
Returns string-typed value of the given field when node ID of root field is provided.

Parameters:
rootDomainId - root field ID of this form or this subtable.
rootNodeId - node ID of root field (first parameter).
fieldDomainId - field ID of the one of interest.
Returns:
string-typed value of the given field.

getFieldValues

public java.util.List<java.lang.String> getFieldValues(int rootDomainId,
                                                       int rootNodeId,
                                                       int fieldDomainId)
Returns a list of string-typed value of the given selection-typed field when node ID of root field is provided.

Parameters:
rootDomainId - root field ID of this form or this subtable.
rootNodeId - node ID of root field (first parameter).
fieldDomainId - field ID of the one of interest.
Returns:
a list of string-typed values of the given field.

getFieldValues

public java.util.List<java.lang.String> getFieldValues(int rootDomainId,
                                                       java.lang.String keyValue,
                                                       int fieldDomainId)
Returns a list of string-typed value of the given selection-typed field when value of root field is provided.

Parameters:
rootDomainId - root field ID of this form or this subtable.
keyValue - value of root field ID (first parameter).
fieldDomainId - field ID of the one of interest.
Returns:
list of string-typed value of the given field.

getFieldValuesString

public java.lang.String getFieldValuesString(int rootDomainId,
                                             java.lang.String keyValue,
                                             int fieldDomainId)
Returns a joined string of values of the given selection-typed field when value of root field is provided. Every two values are separated by a semicolon ";".

Parameters:
rootDomainId - root field ID of this form or this subtable.
keyValue - value of root field ID (first parameter).
fieldDomainId - field ID of the one of interest.
Returns:
a joined string of values of the given selection-typed field.

getFieldNodeId

public int getFieldNodeId(int rootDomainId,
                          int rootNodeId,
                          int fieldDomainId)
Returns node ID of the given field when node ID of root field is provided.

Parameters:
rootDomainId - root field ID of this form or this subtable.
rootNodeId - node ID of this root field (first parameter).
fieldDomainId - field ID of the one of interest.
Returns:
node ID of the given field.

getFieldNodeId

public int getFieldNodeId(int rootDomainId,
                          java.lang.String keyValue,
                          int fieldDomainId)
Returns node ID of the given field when value of root field is provided.

Parameters:
rootDomainId - root field ID of this form or this subtable.
keyValue - value of root field ID (first parameter).
fieldDomainId - field ID of the one of interest.
Returns:
node ID of the given field.

getFieldNodeIds

public java.util.List<java.lang.Integer> getFieldNodeIds(int rootDomainId,
                                                         int rootNodeId,
                                                         int fieldDomainId)
Returns a list of string-typed value of the given selection-typed field when node ID of root field is provided.

Parameters:
rootDomainId - root field ID of this form or this subtable.
rootNodeId - node ID of this root field (first parameter).
fieldDomainId - field ID of the one of interest.
Returns:
list of node IDs of the given selection-typed field.

getFieldNodeIds

public java.util.List<java.lang.Integer> getFieldNodeIds(int rootDomainId,
                                                         java.lang.String keyValue,
                                                         int fieldDomainId)
Returns a list of string-typed node ID of the given selection-typed field when the value of root field is provided.

Parameters:
rootDomainId - root field ID of this form or this subtable.
keyValue - value of this root field (first parameter).
fieldDomainId - field ID of the one of interest.
Returns:
list of node IDs of the given selection-typed field.

setValue

public void setValue(int domainId,
                     java.lang.String keyValue,
                     java.lang.String newValue)
Register a new value to the given field when current value of this field is provided.

Parameters:
domainId - field ID whose value is to be updated.
keyValue - current value of this field.
newValue - new value of this field.

setFieldValue

public void setFieldValue(int rootDomainId,
                          java.lang.String keyValue,
                          int fieldDomainId,
                          java.lang.String value)
Register a new value to the given field when field ID and value of root field are provided.

Parameters:
rootDomainId - root field ID of this form or this subtable.
keyValue - value of this root field (first parameter).
fieldDomainId - field ID whose value is to be set.
value - new value of this field.

setFieldValue

public void setFieldValue(int rootDomainId,
                          int rootNodeId,
                          int fieldDomainId,
                          java.lang.String value)
Register a new value to the given field when field ID and node ID of root field are provided.

Parameters:
rootDomainId - root field ID of this form or this subtable.
rootNodeId - node ID of this root field (first parameter).
fieldDomainId - field ID whose value is to be set.
value - new value of this field.

setFieldSelectionValue

public int setFieldSelectionValue(int rootDomainId,
                                  int rootNodeId,
                                  int fieldDomainId,
                                  java.lang.String value)
Register the first choice to the given selection-typed field when field ID and node ID of root field are provided.

Parameters:
rootDomainId - root field ID of this form or this subtable.
rootNodeId - node ID of this root field (first parameter).
fieldDomainId - field ID whose value is to be set.
value - first choice of this selection-typed field.
Returns:
node ID of this new choice node.

setFieldSelectionValue

public int setFieldSelectionValue(int rootDomainId,
                                  java.lang.String keyValue,
                                  int fieldDomainId,
                                  java.lang.String value)
Register the first choice to the given selection-typed field when field ID and value of root field are provided.

Parameters:
rootDomainId - root field ID of this form or this subtable.
keyValue - value of this root field (first parameter).
fieldDomainId - field ID whose value is to be set.
value - first choice of this selection-typed field.
Returns:
node ID of this new choice node.

setFieldSelectionValues

public int[] setFieldSelectionValues(int rootDomainId,
                                     int rootNodeId,
                                     int fieldDomainId,
                                     java.util.List<java.lang.String> values)
Register a list of all choices to the given selection-typed field when field ID and node ID of root field are provided.

Parameters:
rootDomainId - root field ID of this form or this subtable.
rootNodeId - node ID of this root field (first parameter).
fieldDomainId - field ID whose value is to be set.
values - a list of all choices to be set in this selection-typed field.
Returns:
an array of node ID of these new choice nodes.

setFieldSelectionValues

public int[] setFieldSelectionValues(int rootDomainId,
                                     java.lang.String keyValue,
                                     int fieldDomainId,
                                     java.util.List<java.lang.String> values)
Register a list of all choices to the given selection-typed field when ID and value of root field are provided.

Parameters:
rootDomainId - root field ID of this form or this subtable.
keyValue - value of this root field (first parameter).
fieldDomainId - field ID whose values are to be set.
values - a list of all choices of this selection-typed field.
Returns:
an array of node ID of these new choice nodes.

setFieldSelectionValues

public int[] setFieldSelectionValues(int rootDomainId,
                                     java.lang.String keyValue,
                                     int fieldDomainId,
                                     java.lang.String[] values)
Register an array of all choices to the given selection-typed field when ID and value of root field are provided.

Parameters:
rootDomainId - root field ID of this form or this subtable.
keyValue - value of this root field (first parameter).
fieldDomainId - field ID whose values are to be set.
values - an array of all choices of this selection-typed field.
Returns:
an array of node ID of these new choice nodes.

setFieldSelectionValues

public int[] setFieldSelectionValues(int rootDomainId,
                                     int rootNodeId,
                                     int fieldDomainId,
                                     java.lang.String[] values)
Register an array of all choices to the given selection-typed field when field ID and node ID of root field are provided.

Parameters:
rootDomainId - root field ID of this form or this subtable.
rootNodeId - node ID of this root field (first parameter).
fieldDomainId - field ID whose values are to be set.
values - an array of all choices of this selection-typed field.
Returns:
an array of node ID of these new choice nodes.

addFieldSelectionValue

public int addFieldSelectionValue(int rootDomainId,
                                  int rootNodeId,
                                  int fieldDomainId,
                                  java.lang.String value)
Extend a new choice of the given selection-typed field when field ID and node ID of root field are provided.

Parameters:
rootDomainId - root field ID of this form or this subtable.
rootNodeId - node ID of this root field (first parameter).
fieldDomainId - field ID whose value are to be extended.
value - the value of the new choice.
Returns:
node ID of the new choice node.

addFieldSelectionValue

public int addFieldSelectionValue(int rootDomainId,
                                  java.lang.String keyValue,
                                  int fieldDomainId,
                                  java.lang.String value)
Extend a new choice of the given selection-typed field when field ID and value of root field are provided.

Parameters:
rootDomainId - root field ID of this form or this subtable.
keyValue - value of this root field (first parameter).
fieldDomainId - field ID whose value are to be extended.
value - the value of the new choice.
Returns:
node ID of the new choice node.

addRecord

public int[] addRecord(int[] domainIds,
                       java.lang.String[] values,
                       boolean[] ifMerge)
Register a new record by providing serial field IDs, corresponding values and an array of boolean values indicating if these new nodes should be merged with old values or not.

Parameters:
domainIds - serial field IDs to hold values of this new record.
values - corresponding values to be set on these field IDs (first parameter).
ifMerge - controller which decides each new node should be created as a new one or merged with old value.
if true, new node will be merged with an old one if the node possess the same value already exists. if false, new node wil be still created.
Returns:
node IDs of these new values.


Copyright © 2009,2010,2011,2012 Ragic Corp. All Rights Reserved.