210 likes | 335 Views
MBS908:Building Data-Driven AvantGo Applications. David Kloba Senior Manager, Software Engineer Development klobad@sybase.com August 7 th , 2003. Overview. Architecture XML Conduit AvantGo Database POD Example - Simple Example - Full Miscellaneous Q & A. Architecture Overview.
E N D
MBS908:Building Data-Driven AvantGo Applications David KlobaSenior Manager, Software Engineer Developmentklobad@sybase.comAugust 7th, 2003
Overview • Architecture • XML Conduit • AvantGo Database POD • Example - Simple • Example - Full • Miscellaneous • Q & A
XML Conduit Overview • What is it? • Another conduit that runs inside the AvantGo M-Business Server Application Edition • Configured much the same way a regular channel is, has a data url and a schema url • Makes http requests for the urls, expects XML and XMLSchema documents instead of html documents • Currently the conduit is effectively read-only, it makes requests for data, but does not push data • Currently most developers are handling changes through normal html form submissions • It expects the responses to be the full data set, and will only send changes or deletes to the device • Expects a single field to be the PrimaryKey, doesn’t support compound keys
XML Conduit Overview Continued…
XML Conduit Overview Continued…
XML Conduit Overview Continued… • How do I tell the conduit what columns are in my table? <?xml version="1.0" encoding="UTF-8" standalone="no"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:dt="urn:schemas-microsoft-com:datatypes" xmlns:msch="urn:schemas-microsoft-com:mapping-schema"> <xsd:element name="DataRecord" msch:relation="DataRecord" type="DataType"/> <xsd:complexType name="DataType"> <xsd:attribute name="int32Field" type="xsd:int"/> <xsd:attribute name="uint32Field" type="xsd:unsignedInt"/> <xsd:attribute name="int16Field" type="xsd:short"/> <xsd:attribute name="uint16Field" type="xsd:unsignedShort"/> <xsd:attribute name="stringField" type="xsd:string"/> <xsd:attribute name="dateField" type="xsd:dateTime"/> <xsd:attribute name="stringNField" > <xsd:simpleType> <xsd:restriction base="xsd:string"> <xsd:maxLength value="32"/> </xsd:restriction> </xsd:simpleType> </xsd:attribute> <xsd:attribute name="booleanField" type="xsd:boolean"/> <xsd:attribute name="timeField" type="xsd:dateTime"/> <xsd:attribute name="int32Field2" type="xsd:int"/> <xsd:key name="PrimaryKey"> <xsd:selector xpath="."/> <xsd:field xpath="@int32Field"/> </xsd:key> </xsd:complexType> </xsd:schema>
XML Conduit Overview Continued… • How do I tell the conduit what data is in my table? <?xml version="1.0" encoding="iso-8859-1" ?> <root> <DataRecord int32Field="1025" uint32Field="1027" int16Field="1028" uint16Field="1026" stringField="string1" dateField="Mon, 26 Dec 1994 00:01:00 GMT" stringNField="FixedString1" booleanField="TRUE" timeField="Mon, 26 Dec 1994 00:01:00 GMT" int32Field2="1025" /> <DataRecord int32Field="1026" uint32Field="1028" int16Field="1029" uint16Field="1027" stringField="string2" dateField="Mon, 26 Dec 1994 00:02:00 GMT" stringNField="FixedString2" booleanField="FALSE" timeField="Mon, 26 Dec 1994 00:02:00 GMT" int32Field2="1026" /> </root>
AvantGo Database POD Overview • What is it? • A POD is simply a plugin to the AvantGo client • A simple ADO like api accessible from JavaScript to manipulate the databases • Standard methods to add / change / delete / filter / sort the data within a database on the device • Supports float, int, string, boolean, and date types • Straight forward cursor based api, you have a current row, all actions apply to that row • Simple search and sort functions. Lightweight implementations • we’ve been using it in production applications for over a year
AvantGo Database POD Overview Continued… • How do I get one and work with it? function DoSomethingInteresting() { var dbMgr = CreateObject("avantgo.db"); var dbSet; dbSet = dbMgr.open("test", "w"); dbSet.addNew(); dbSet.int32Field = 123; dbSet.stringField = "new string record"; dbSet.commit(); dbSet.close() }
AvantGo Database POD Overview API Review – AGDBDatabaseManager interface AGDBDatabaseManager : AGDBObject readonly attribute AGDBColumnTypes types; AGDBNewMetadata createMetadata(); boolean create( String dbname, AGDBMetadata metadata, String flags); void remove( String dbname); boolean exists( String dbname); AGDBSet open( String dbname, String flags);
AvantGo Database POD Overview API Review - AGDBSet interface AGDBSet : AGDBObject readonly attribute unsigned long nrows; readonly attribute unsigned long index; readonly attribute AGDBMetadata metadata; boolean moveTo(unsigned long index); boolean moveBy(long numRecords); boolean moveFirst(); boolean moveLast(); boolean moveNext(); boolean movePrev(); /*These are all valid JavaScript examples of search criteria: search = myDBSet.createSearch("startDate >= " + myDate); search = myDBSet.createSearch("startDate >= " + myDate.getTime()); search = myDBSet.createSearch("address like #park lane#"); search = myDBSet.createSearch("name == 'David'"); search = myDBSet.createSearch("city == Chicago"); search = myDBSet.createSearch("zipcode >= 90302"); search = myDBSet.createSearch("hasPaid == true"); search = myDBSet.createSearch("city $= Chicago");*/ AGDBSearch createSearch(in String criteria); boolean find(AGDBSearch search); boolean atbof(); boolean ateof(); boolean rowDeleted(); boolean rowUpdated();
AvantGo Database POD Overview API Review – AGDBSet continued… interface AGDBSet : AGDBObject …. void addNew(); void deleteRow(); // Marks record deleted void removeRow(); // Completely deletes row from db void undo(); void commit(); void close(); boolean getBooleanField( String name); PODSDate getDateField( String name); long getInt32Field( String name); unsigned long getUInt32Field( String name); short getInt16Field( String name); unsigned short getUInt16Field( String name); String getStringField( String name); PODSDouble getDoubleField( String name); void setBooleanField( String name, boolean value); void setDateField( String name, PODSDate value); void setInt32Field( String name, long value); void setUInt32Field( String name, unsigned long value); void setInt16Field( String name, short value); void setUInt16Field( String name, unsigned short value); void setStringField( String name, String value); void setDoubleField( String name, PODSDouble value);
AvantGo Database POD Overview API Review void setFilter(AGDBSearch); void filterDeletedRecords(boolean filter); void setSort( String columnName, boolean sortAscending); boolean isFieldNull( String name); void setFieldNull( String name); interface AGDBMetadata : AGDBObject readonly attribute unsigned long ncolumns; String getColumnName( unsigned long index); short getColumnType( unsigned long index); long getColumnSize( unsigned long index); long getColumnIndex( String name); long getNullable( unsigned long index); interface AGDBNewMetadata : AGDBMetadata void appendColumn( String name, short type, unsigned long stringn_size); void setNullable( unsigned long index, long isNullable); interface AGDBColumnTypes : AGDBObject readonly attribute short BOOLEAN; readonly attribute short DATE; readonly attribute short INT16; readonly attribute short UINT16; readonly attribute short INT32; readonly attribute short UINT32; readonly attribute short STRING; readonly attribute short STRINGN; readonly attribute short DOUBLE;
Simple Example • Alright already, let’s see this thing!
Full Example • That was pretty boring, how about something with a little more pizzaz.
Q & A QUESTIONS Main Developer Site: http://developer.avantgo.com Developer Guide: http://www.avantgo.com/doc/developer/apps/js_pods_guide/index.html
iAnywhere Solutions at TechWave2003 Activities for iAnywhere Solutions • Ask the iAnywhere Experts on the Technology Boardwalk • Drop in during exhibit hall hours and have all your questions answered by our technical experts! • Appointments outside of exhibit hall hours are also available to speak one-on-one with our Senior Engineers. Ask questions or get your yearly technical review – ask us for details • m-Business Pavilion • Visit the m-Business Pavilion in the exhibit hall to see how companies like Intermec have built m-Business solutions using iAnywhere Solutions technology • Wi-Fi Hotspots – brought to you by Intel & iAnywhere Solutions • You can enjoy wireless internet access via a Wi-Fi hotspot provided by Intel and iAnywhere Solutions. Using either a laptop or PDA that is Wi-Fi 802.11b wirelessly-enabled, visitors can access personal email, the internet ,and "TechWave To Go", a My AvantGo channel providing up-to-date information about TechWave classes, events and more.
iAnywhere Solutions at TechWave2003 Activities for iAnywhere Solutions • Developer Community A one-stop source for technical information! • Access to newsgroups,new betas and code samples • Monthly technical newsletters • Technical whitepapers,tips and online product documentation • Current webcast,class,conference and seminar listings • Excellent resources for commonly asked questions • All available express bug fixes and patches • Network with thousands of industry experts http://www.ianywhere.com/developer/