Package de.elo.ix.jscript
Class FindObjects
java.lang.Object
de.elo.ix.jscript.FindObjects
- Direct Known Subclasses:
FindSordsByIds
,FindSordsByObjKeys
This class is used to build a database query on the archive in order to process the results of a
registered function.
E.g. when findFirstSords searches for Sord IDs returned from a registered function specified with
FindByRegisteredFunction
, this class builds the SQL statement statement
that reads the Sord objects from the archive database.
The registered function returns an instance of FindObjects or an instance of one of the derived
classes. Furthermor it can return an alternative JavaScript implementation of this class. This
might be nessesary, if more columns than either IDs, GUIDs or ObjKey values have to be queried.
Example: IDs or GUIDs from an external database.
function RF_findSordsByIds(ec, args) {
var db = new Packages.de.elo.ix.jscript.DBConnection( "jdbc/ExternalDatabase" );
var ids = db.query("select objid from ...");
return new Packages.de.elo.ix.jscript.FindSordsByIds(ids);
}
function RF_findSordsByGuids(ec, args) {
var db = new Packages.de.elo.ix.jscript.DBConnection( "jdbc/ExternalDatabase" );
var guids = db.query("select objguid from ...");
return new Packages.de.elo.ix.jscript.FindSordsByGuids(guids);
}
Example: ObjKey-Values from an external database.
function RF_findSordsByOkeys(ec, args) {
var db = new Packages.de.elo.ix.jscript.DBConnection( "jdbc/ExternalDatabase" );
var okeys = db.query("select okeydata from ...");
return new Packages.de.elo.ix.jscript.FindSordsByObjKeys("INVOICENR", okeys);
}
function RF_findSordsByOkeys(ec, args) {
var db = new Packages.de.elo.ix.jscript.DBConnection( "jdbc/ExternalDatabase" );
var okeys = db.query("select okeyname, okeydata from ...");
return new Packages.de.elo.ix.jscript.FindSordsByObjKeys(okeys);
}
Example: Registered function that returns a JavaScript implementation of the FindObjects class.
function FindObjects(ids) {
this.ids = ids;
this.pos = -1;
this.findObjects = new Packages.de.elo.ix.jscript.FindObjects();
this.getAlias = function() {
return "o";
}
this.getFrom = function() {
return "objekte o";
}
this.getWhere = function() {
return "o.objid=?";
}
this.next = function() {
return (++this.pos < this.ids.length);
}
this.bindParams = function(pstmt, startCol) {
pstmt.setInt(startCol, this.ids[this.pos]);
}
this.close = function() {
}
this.getCurrentPosAsString = function() {
return this.ids[this.pos];
}
}
function RF_findSords(ec, args) {
// use some dummy values
return new FindObjects([123,456,789]);
}
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
SQL table name used to select Sords by index fields.static final String
SQL table name used to select Sords by IDs and GUIDs.static final String
Where clause to select Sords by index field.static final String
Where clause to select Sords by index field.static final String
Where clause to select Sords by GUID.static final String
Where clause to select Sords by numeric ID. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
bindParams
(PreparedStatement pstmt, int startCol) Submit parameters for the JDBC Statement.void
close()
Release ressources.getAlias()
Get alias table name for the Sords (objekte) table.Get information about the current position.getFrom()
Get the table name or a comma separated list of table names to select from.getWhere()
Where clause.boolean
next()
Move to next object.
-
Field Details
-
FROM_SORDS
SQL table name used to select Sords by IDs and GUIDs.- See Also:
-
FROM_OBJ_KEYS
SQL table name used to select Sords by index fields. Must be used in conjunction with FROM_SORDS.- See Also:
-
WHERE_SORD_ID
Where clause to select Sords by numeric ID.- See Also:
-
WHERE_SORD_GUID
Where clause to select Sords by GUID.- See Also:
-
WHERE_OBJ_KEY_DATA
Where clause to select Sords by index field. This constant uses the equals operator.- See Also:
-
WHERE_OBJ_KEY_DATA_LIKE
Where clause to select Sords by index field. This constant uses the "like" operator.- See Also:
-
-
Constructor Details
-
FindObjects
public FindObjects()
-
-
Method Details
-
getAlias
Get alias table name for the Sords (objekte) table. Optional. This alias must be used in the where clause for every column name of the Sords table. This function is only called for the first object.- Returns:
- alias name
-
getFrom
Get the table name or a comma separated list of table names to select from. E. g. to select from Sords and document versions return "objekte,dochistory". This function is only called for the first object.
If an alias for the Sords table should be used, the alias must follow the table name. E.g. getAlias()="o", getFormat()="objekte o, dochistory d", getWhere()="o.objid=d.objectid and ..."- Returns:
- table name(s)
-
getWhere
Where clause. This function is only called for the first object. Use PreparedStatement placeholders for the Sord ID and other parameters (if there are any).
If an alias for the Sords table should be used, the alias must prefix the column names. E.g. getAlias()="o", getFormat()="objekte o, dochistory d", getWhere()="o.objid=d.objectid and ..."- Returns:
- where clause
-
next
Move to next object.- Returns:
- false, if no more objects available
- Throws:
SQLException
-
bindParams
Submit parameters for the JDBC Statement. The calling function creates a PreparedStatement based on the return values of getAlias, getFrom and getWhere. With a call to this function, all parameters conatined in the Prepared statement should be bound.- Parameters:
pstmt
-startCol
-- Throws:
SQLException
-
close
Release ressources.- Throws:
SQLException
-
getCurrentPosAsString
Get information about the current position. E. g. return the parameters set into the PreparedStatement in the bindParams function.- Returns:
- Information string
-