on 03-08-2006 2:43 PM
hello all,
i need to implement and combined <b>order using 1 header & 2 childs field of my sync bo in my web page.</b>
I <b>tried to use, as javadoc explain, the classes: Condition, Query, SortOrder</b> but they not have effect in my dataset display.
could we help me?
my java code is:
<i>Condition cond = queryFactory.createCondition(fd, filterOperator, filter);
FieldDescriptor OrderNumberField = rd.getFieldDescriptor(OrderNumber);
SortOrder byOrderNumber = queryFactory.createSortOrder(OrderNumberField, true);
RowDescriptor childrow = sbd.getRowDescriptor("010");
FieldDescriptor posFieldDescriptor = null;
FieldDescriptor rowFieldDescriptor = null;
iteratorSyncBos = dataFacade.getSyncBos(sbd).iterator();
SyncBo S = (SyncBo) iteratorSyncBos.next();
RowCollection rc = S.getRows(childrow);
MeIterator ri = rc.iterator();
Row r = (Row) ri.next();
posFieldDescriptor = r.getRowDescriptor ().getFieldDescriptor("EBELP");
rowFieldDescriptor = r.getRowDescriptor().getFieldDescriptor("EXTROW");
SortOrder singleSortOrder = queryFactory.createSortOrder(fd, sortOrder);
SortOrder byPosition = queryFactory.createSortOrder(posFieldDescriptor,true);
SortOrder byRow = queryFactory.createSortOrder(rowFieldDescriptor,true);
SortOrder[] multipleSortOrder = new SortOrder[];
SortOrder compositeSortOrder = queryFactory.createSortOrder(multipleSortOrder);
Query syncBoQuery =
queryFactory.createQuery(sbd,cond,compositeSortOrder, start, count);</i>
- using MIClient 2.5 SP13 -
Hi Elina,
use this code template to code..
For Header
*************************************************
//Here return is MeIterator
SyncBoDescriptor sbd = descriptorFacade.getSyncBoDescriptor(<SyncBoName>);
MeIterator iteratorSyncBos = null;
Condition cond1 = null;
Condition cond2 = null;
Condition[] condArray = {};
Condition condNet = null;
SmartSyncQueryFactory queryFactory =
SmartSyncRuntime.getInstance().getQueryFactory();
RowDescriptor rd = sbd.getTopRowDescriptor();
FieldDescriptor fd1 = rd.getFieldDescriptor("<Field1 from Header>");
//Customer Code
FieldDescriptor fd2 = rd.getFieldDescriptor("<Field2 from Header>");
cond1 =
queryFactory.createCondition(
fd1,
<RelationalOperatorType.EQUALS>,
<Value of this field>);
cond2 =
queryFactory.createCondition(
fd2,
<RelationalOperatorType.EQUALS>,
<Value of this field>);
condArray = { cond1,cond2 };
condNet =
queryFactory.createCondition(
condArray,
<LogicalOperatorType.OR>);
SortOrder sort1 = queryFactory.createSortOrder(fd1, true);
SortOrder sort2 = queryFactory.createSortOrder(fd2, true);
SortOrder[] sortArray = { sort1, sort2 };
SortOrder sortNet = queryFactory.createSortOrder(sortArray);
Query syncBoQuery =
queryFactory.createQuery(
sbd,
condNet,
sortNet,
start,
count);
iteratorSyncBos = dataFacade.getSyncBos(syncBoQuery).iterator();
loop through this ..
**************************************************
For Item
****************************************************
// Here Return parameter is Row[]
SyncBoDescriptor sbd = descriptorFacade.getSyncBoDescriptor(<SyncBoName>);
MeIterator iteratorSyncBos = null;
Condition cond1 = null;
Condition cond2 = null;
Condition[] condArray = {};
Condition condNet = null;
SmartSyncQueryFactory queryFactory =
SmartSyncRuntime.getInstance().getQueryFactory();
RowDescriptor rd = sbd.getRowDescriptor(<itemName>); // particular item name.. Here we can use "TOP" for Header
FieldDescriptor fd1 = rd.getFieldDescriptor("<Field1 from Header>");
//Customer Code
FieldDescriptor fd2 = rd.getFieldDescriptor("<Field2 from Header>");
cond1 =
queryFactory.createCondition(
fd1,
<RelationalOperatorType.EQUALS>,
<Value of this field>);
cond2 =
queryFactory.createCondition(
fd2,
<RelationalOperatorType.EQUALS>,
<Value of this field>);
condArray = { cond1,cond2 };
condNet =
queryFactory.createCondition(
condArray,
<LogicalOperatorType.OR>);
SortOrder sort1 = queryFactory.createSortOrder(fd1, true);
SortOrder sort2 = queryFactory.createSortOrder(fd2, true);
SortOrder[] sortArray = { sort1, sort2 };
SortOrder sortNet = queryFactory.createSortOrder(sortArray);
Query syncBoQuery =
queryFactory.createQuery(
rd,
condNet,
sortNet,
start,
count);
RowList rc = dataFacade.getRows(syncBoQuery);
Row[] arrayRows = null;
MeIterator ri = rc.iterator();
int i = 0;
while (ri.hasNext()) {
ri.next();
i++;
}
ri = rc.iterator();
arrayRows = new Row<i>;
//start filling the array now
i = 0;
while (ri.hasNext()) {
arrayRows<i> = (Row) ri.next();
i++;
}
return arrayRows;
*********************************************************
Here in this method ..
just look here
//Here sbd for header itself.
queryFactory.createQuery(<b>sbd</b>,condNet,sortNet,start,count);
//Here rd for items
queryFactory.createQuery
(<b>rd</b>,condNet,sortNet,start,count);
here
//For top Row -- means header
RowDescriptor topRow = sbd.getTopRowDescriptor();
//for item rows..
RowDescriptor rd = sbd.getRowDescriptor(<itemName>);
for Header , in place of <itemName> , u can use "TOP"..
can put "TOP" in place of "010" ,"020"...
Regards
Kishor Gopinathan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Elina ,
u can use this code to iterate..
For Header
*****************
MeIterator syncBos = <iterate method>
while (syncBos.hasNext()) {
SyncBo sb = (SyncBo) syncBos.next();
Vector rowData = new Vector();
for (int col = 0; col < getColumns(); col++) {
String headerFieldValue =
// this is the standard method in Smart Sync
dbAccess.getFieldValue(
sb,
"<Header field Name>");
}
}
For Item
***************************
Row[] arrayHeaders = <get item values as >
String[] arrayItemFields =
dbAccess.getItemFieldNames(syncBoName, itemName);
int itemCount = arrayHeaders.length;
int itemFieldCount = arrayItemFields.length;
String itemFieldName;
String itemFieldValue;
for (int row = 0; row < itemCount; row++) {
//itemVector.clear();
itemVector.removeAllElements();
for (int col = 0; col < itemFieldCount; col++) {
itemFieldName = arrayItemFields[col];
itemFieldValue =
dbAccess.getFieldValue(
arrayHeaders[row],
itemFieldName);
}
}
Regards
Kishor Gopinathan
Hi Elina,
this will help u ... go through this code samples...
<b>//Method for getting the field names in the ITEM .This is a standard method in the //SmartSyncDBAccess.This have two input parameters . ]
// syncBoName - Name of sync Bo
// itemName Item name of the syncBo. Eg 010 , 020 If you want to find out the // field names of the header of the sync bo , then u can use TOP in place of the item //name </b>
public String[] getFieldNames(String syncBoName, String itemName) {
SyncBoDescriptor sbd = descriptorFacade.getSyncBoDescriptor(syncBoName);
RowDescriptor rd = sbd.getRowDescriptor(itemName);
FieldDescriptorIterator fdi = rd.getAllFieldDescriptors();
String[] arrayItemFieldNames = null;
if (fdi != null) {
// count the SyncBoDescriptors to size the array //accordingly
int i = 0;
while (fdi.hasNext()) {
fdi.next();
i++;
}
fdi = rd.getAllFieldDescriptors();
arrayItemFieldNames = new String<i>;
i = 0;
while (fdi.hasNext()) {
arrayItemFieldNames<i> = fdi.next().getFieldName();
i++;
}
return arrayItemFieldNames;
} else {
System.out.println(
"SmartSyncDBAccess.getItemFieldNames - Array of Item Field Names is empty");
return null;
}
}
<b>/// This method is for getting the values of Header instances..This is the modified version //of one standard method in SmartSyncDBAccess.The modification is to avoid the null
// pointer exception in the standard method. The standard method is without handling
//some null pointer exceptions .use this way .
//Here import params are SyncBo instance and HeaderFieldName</b>
public String getHeaderFieldValue(SyncBo sb, String headerFieldName) {
SyncBoDescriptor sbd = sb.getSyncBoDescriptor();
RowDescriptor trd = sbd.getTopRowDescriptor();
FieldDescriptor fd = trd.getFieldDescriptor(headerFieldName);
BasisFieldType bft = fd.getFieldType();
Row header = sb.getTopRow();
try {
if (bft == BasisFieldType.N) {
NumericField nf = header.getNumericField(fd);
try {
return nf.getValueWithLeadingZeros();
} catch (RuntimeException e) {
return "";
}
} else {
Field f = header.getField(fd);
if (f == null) {
return "";
} else if (f.getValue() == null) {
return "";
} else {
if (bft == BasisFieldType.D) {
String aDa = f.getValue().toString();
if (!aDa.equals("")) {
Date fDa = Date.valueOf(aDa);
return formater.format(fDa);
}
}
return f.getValue().toString();
}
}
} catch (SmartSyncException ssex) {
System.out.println(ssex.getMessage());
return null;
}
}
<b>/// This method is for getting the values of Item instances..This is the modified version //of one standard method in SmartSyncDBAccess.The modification is to avoid the null
// pointer exception in the standard method. The standard method is without handling
//some null pointer exceptions .use this way .
//Here import params are Row instance and FieldName </b>
public String getItemFieldValue(Row item, String itemFieldName) {
RowDescriptor rd = item.getRowDescriptor();
FieldDescriptor fd = rd.getFieldDescriptor(itemFieldName);
BasisFieldType bft = fd.getFieldType();
try {
if (bft == BasisFieldType.N) {
NumericField nf = item.getNumericField(fd);
try {
return nf.getValueWithLeadingZeros();
} catch (RuntimeException e) {
return "";
}
} else {
Field f = item.getField(fd);
if (f == null) {
return "";
} else if (f.getValue() == null)
return "";
else if (f.getValue() != null) {
if (bft == BasisFieldType.D) {
String aDa = f.getValue().toString();
if (!aDa.equals("")) {
Date fDa = Date.valueOf(aDa);
return formater.format(fDa);
}
}
return f.getValue().toString();
} else
return "";
}
} catch (SmartSyncException ssex) {
System.out.println(ssex.getMessage());
return null;
}
}
<b>//How to use these methods .
// How to loop through Header instances and getting the values of each instaces , which // are already queried ,using the code I have given in my second last forum..</b>
String[]getFieldNames =
getItemFieldNames(<syncBoName>, TOP);
<b>MeIterator headerValues = <Here query the header values as I mentioned in that sample code ></b>
int fieldCount = arrayHeaderFields.length;
while (headerValues.hasNext()) {
SyncBo sb = (SyncBo) headerValues.next();
for (int col = 0; col < fieldCount; col++) {
String headerFieldValue =
getHeaderFieldValue (sb,arrayHeaderFields[col]);
}
}
<b>// Get values from item instaces which are already queried ..u can use the code in my last // reply itself.</b>
String[] arrayItemFields =
getFieldNames(<syncBoName>, <itemName>);
<b>Row[] itemValues = <Here query the item instances as I mentioned in that last sample code>;</b>
int itemCount = itemValues.length;
int itemFieldCount = arrayItemFields.length;
String itemFieldName;
String itemFieldValue;
//loop through item instances
for (int row = 0; row < itemCount; row++) {
// loop through each instace of item
for (int col = 0; col < itemFieldCount; col++) {
// getting values
itemFieldName = arrayItemFields[col];
itemFieldValue = getItemFieldValue(itemValues[row],itemFieldName);
}
}
Regards
Kishor Gopinathan
tx kishor,
i'm able to read / set values in the structure of syncbo.
i'm not able to filter 1header + 2 child with MultipleCondition class for local Persistence.
i have resolved my problem using a vector:
i ask the Bo filtered by header from local persistence -> then i valorize a vector.
in this vector i'm able to filter the string values using algorithm .
User | Count |
---|---|
89 | |
10 | |
9 | |
9 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.