How to convert IFields to Fields

By iamlaksh1

 

I am trying connect to external database (simple standalone DBF) to one of layer dynamically using ADF. I wrote a method to connect to database and return the fields. I can able to join with database but retrieving fields seems bit tough!. The RelQueryTable class has method  getFields() which returns  IFields objects . How to convert to IFields to Fields object in com.esri.arcgisws which has getFieldArray() to obtain fields list.

 

Can anyone ping me or give me any clues? 

 

private Fields JoinTable(IServerContext pSC, IFeatureClass pFeatclass){

try{                

ShapefileWorkspaceFactory filefactory = (ShapefileWorkspaceFactory)pSC.createObject(ShapefileWorkspaceFactory.getClsid());

Workspace ws = (Workspace) filefactory.openFromFile(“C:/test/”, 0);

IRelationshipClass pRelationshipClass ;              

ITable table = ws.openTable(“1Z.dbf”);

factory = (MemoryRelationshipClassFactory)pSC.createObject(MemoryRelationshipClassFactory.getClsid());

MemoryRelationshipClass rclass = (MemoryRelationshipClass)factory.open(“test”, pFeatclass, “ZONENO”, new ObjectClass(table),”ZONENO”, “forward”, “backward”, esriRelCardinality.esriRelCardinalityOneToOne);                     

RelQueryTableFactory relQueryTableFact = (RelQueryTableFactory)pSC.createObject(RelQueryTableFactory.getClsid());

RelQueryTable relQueryTab = (RelQueryTable) relQueryTableFact.open (rclass, true, null, null, “”, true, true);

System.out.println(“After Joining total Field count::::::”+ relQueryTab.getFields().getFieldCount())                        

return  relQueryTab.getFields();        

 }

catch(Exception ex){

System.out.println(“ERROR in JOINTable Method”+ ex.toString());

return null;

}

 

Leave a Reply