Wednesday, January 19, 2011

SharedAM Unfold Again

Shared Application Modules are mostly used to cache static data.
If a SharedAM has a ViewObject instance in it, we really cannt apply Dynamic ViewCriteria nor setWhereClause().This causes Multi User threading issues from SharedAM and unexpected errors prop up.

Query from SharedAM VO based on Dynamic VOAttrName and Value.

* @author AMulya Mishra
* This method iterates the SharedAM Vo rowset and matches the VOAttrname and Value.
* Then returns a collection of the matched rows.
* Note, since these Vos are from SharedAM, hence they are already executed in the
* PrepareSesion of the SharedAMImpl.
* So, in this method, there is no DB queries fired for these VOs.
* @param vo
* @param sharedAMName
* @param keyVals
* @return
public static List<Row> getRowsFromSharedAMVOs(ViewObject vo, String amName,
String[][] keyVals) {
//Initialiaze the Row List
List<Row> returnedRows = new ArrayList<Row>();
//Get the Original RnageSize of the VO so that we can reset back
int rsize = vo.getRangeSize();
//to ensure we get a complete esimated row count
//gets all the VO rows.
Row[] rowsArray = vo.getAllRowsInRange();
//Loop through the row set
for(Row row : rowsArray){
//Initialize the rowmatch boolean variable
boolean matchedRowFound = true;
if (keyVals != null && keyVals.length > 0) {
//Iterates through the key value pairs.
for (String[] keyValArray : keyVals) {
//get the voAttrName
String voAttrName = keyValArray[0];
//get the voAttrValue
String voAttrVal = keyValArray[1];

//If value matches then make the variable true
if(voAttrVal != null && voAttrVal.equals((String)row.getAttribute(voAttrName))){
matchedRowFound = matchedRowFound && true;
matchedRowFound = false;
//If a row match found, then add the row to the list
if(matchedRowFound == true){
//Reset the VO
//Reset the RangeSize of the VO
//return the Found Rows
return returnedRows;


No comments: