Remember that we are using a special feature of hibernate to read/write db rows as plain xml, is not neccesary to create pojo classes. See http://docs.jboss.org/hibernate/stable/core/reference/en/html_single/#xml.
This hibernate feature requires a differente hibernate mapping, this xml mapping is not the same mapping that you are using in a common java application when you use hibernate as ORM between classes and db tables.
HibernateContentAdapter and HibernateSyncRepository are based on this feature and is not easy to reuse in pojo scenario. All ours scenarios are based in tools that directly works with db tables and not mesh4x embedded in a business application.
We need to implements a new HibernbatePojoContentAdapter and HibernatePojoSyncRepository (similar to the existing one), this new split adapter components use a POJO SessionFactory (your bussines session factory), the core methods read/write pojo objects. For create items we need to express the business objects as xml. RDF is added only if you really need it. The idea is create a SplitAdapter instance with a HibernbatePojoContentAdapter and HibernatePojoSyncRepository instances (sharing the same session factory).
Mesh4x is a open source that give help in humanitarian task, is a good adapter to collaborate with mesh4x.
The previous scenario should be possible to support in mesh4x. Currently j2me version of mesh4x supports sinchronize a record in the mobile phone with the cloud or with other mobile phone via sms.
The cloud supports add a new item via http too.
Related with multi table sync, check my last changes, I am working in "Issue 113: Add to adapters the possibility to sync a mesh group (group of datasets)".
Currently you can sync a lot of tables (see ) in the same sync session.
Some others ISyncAdapter creation examples :)
Example of creation of sync adapter for MSAccess table:
MsAccessSyncAdapterFactory factory = new MsAccessSyncAdapterFactory(
"c:\\test", // directory for hibernate mapping files
"http://sync.staging.instedd.org:8080/mesh4x/feeds"); // base url for RDF, put null if you decide dont use RDF
String mdbFileName = "c:\\test\myMDB.mdb";
String tableName= "myTableName";
ISyncAdapter singleTable = factory.createSyncAdapterFromFile(tableName, mdbFileName, tableName, new LoggedInIdentityProvider());
Example of creation of sync adapter for MSAccess tables:
MsAccessSyncAdapterFactory factory = new MsAccessSyncAdapterFactory(
"c:\\test", // directory for hibernate mapping files
"http://sync.staging.instedd.org:8080/mesh4x/feeds"); // base url for RDF, put null if you decide dont use RDF
String[] tables = new String[]{"tableName1", "tableName2"};
ISyncAdapter adapterOpaque = new any sync adapter...
String mdbFileName = "c:\\test\myMDB.mdb";
ISyncAdapter multiTable = factory.createSyncAdapterForMultiTables(mdbFileName, tables, new LoggedInIdentityProvider(), adapterOpaque);
Example of creation of sync adapter for MsExcel sheet:
MsExcelRDFSyncAdapterFactory rdfExcelFactory = new MsExcelRDFSyncAdapterFactory("http:\\mesh4x\example") ; // base url for RDF
ISyncAdapter adapterMsExcelXLSrdf = rdfExcelFactory.createSyncAdapter("c:\\test\\myExcel.xls", "sheetName", "idColumnName", new LoggedInIdentityProvider());
ISyncAdapter adapterMsExcelXLSXrdf = rdfExcelFactory.createSyncAdapter("c:\\test\\myExcel.xlsx", "sheetName", "idColumnName", new LoggedInIdentityProvider());
MsExcelRDFSyncAdapterFactory plainXmlExcelFactory = new MsExcelSyncAdapterFactory();
ISyncAdapter adapterMsExcelXLS = plainXmlExcelFactory .createSyncAdapter("c:\\test\\myExcel.xls", "sheetName", "idColumnName", new LoggedInIdentityProvider());
ISyncAdapter adapterMsExcelXLSX = plainXmlExcelFactory .createSyncAdapter("c:\\test\\myExcel.xlsx", "sheetName", "idColumnName", new LoggedInIdentityProvider());
ISyncAdapter adapterOpaque = new any sync adapter...
Map<String, String> sheets = new HashMap<String, String>();
sheets.put("sheet1", "Code");
sheets.put("sheet2", "Code");
sheets.put("sheet3", "Code");
ISyncAdapter adapterMsExcelMultiSheets = createSyncAdapterForMultiSheets("c:\\test\\myExcel.xlsx", new LoggedInIdentityProvider(), sheets, opaqueAdapter);
Example of creation of Folder adapter:
ISyncAdapter adapterFolder = FolderSyncAdapterFactory.createFolderAdapter("c:\\test\myFolderToSync", new LoggedInIdentityProvider()), IdGenerator.INSTANCE);
Example of creation of KMLAdapter:
ISyncAdapter adapterKML = KMLDOMLoaderFactory.createKMLAdapter("c:\\test\myKml.kml", new LoggedInIdentityProvider());
ISyncAdapter adapterKMZ = KMLDOMLoaderFactory.createKMLAdapter("c:\\test\myKml.kmz", new LoggedInIdentityProvider());
Example of dummy adapter:
ISyncAdapter adapterDUMMY = new InMemorySyncAdapter("an adapter name", new LoggedInIdentityProvider());
Example of GoogleSpreadsheets adapter:
GoogleSpreadSheetSyncAdapterFactory gssPlainXMLFactory= new GoogleSpreadSheetSyncAdapterFactory();
ISyncAdapter adapterGss = gssPlainXMLFactory.createSyncAdapter("userName", "passWord", "spreadsheetName", "sheetName", "idColumName", null, new LoggedInIdentityProvider(), "sheetName");
GoogleSpreadSheetRDFSyncAdapterFactory gssRDFFactory = new GoogleSpreadSheetRDFSyncAdapterFactory(("http:\\mesh4x\example") ; // base url for RDF
ISyncAdapter adapterGssRDF = gssRDFFactory.createSyncAdapter("username", "password", "spreadsheetName", "sheetName", "idColumnName", "lastUpdateColumnName", new LoggedInIdentityProvider, "spreadsheetName");
Currently, we can classify adapters in 3 groups:
1. Adapters based on tables with structured data:
DB adapters (mysql, msaccess), Excel adapter, GoogleSS adapter.
RDF is required here, adapters need to interpret the information (xml content).
take values from xml elements and put each value in typed fields (column in a db table, cell in excel).
3. Opaque Adapters:
Adapters that store items and not interpret the xml content.
Cloud Adapter (Sync server), S3Adapter (amazon s3 adapter), Feed adapter (rss, atom)
Compatibility between adapter types: