public class ContactStorage extends AbstractMemStorage { //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Initialization //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /** * Creates a new instance of ContactStorage. */ public ContactStorage() { } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Abstract methods implementation //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @Override public RowDefinition getRowDefinition() throws ModelException { RowDefinition rdef = new RowDefinition(); rdef.addColumnDefinition(new ColumnDefinition("ID", new BigDecimalDataType())); rdef.addColumnDefinition(new ColumnDefinition("FIRST")); rdef.addColumnDefinition(new ColumnDefinition("LAST")); rdef.setPrimaryKeyColumnNames(new String[] {"ID"}); rdef.setColumnView(null, new ColumnView(rdef)); return rdef; } @Override public void loadData(MemDataBook pBook, ICondition pCondition) throws ModelException { pBook.close(); pBook.open(); ClientResource cres = new ClientResource("https://cloud.sibvisions.com/demoerp/services/rest/DemoERP/Customers/data/customer/"); cres.setChallengeResponse(ChallengeScheme.HTTP_BASIC, "manager", "manager"); try { List> list = JSONUtil.getObject(cres.get(), List.class); for (Map m : list) { pBook.insert(false); pBook.setValues(new String[] {"ID", "FIRST", "LAST"}, new Object[] {new BigDecimal((BigInteger)m.get("ID")), m.get("FIRSTNAME"), m.get("SURNAME")} ); } pBook.saveAllRows(); } catch (IOException ioe) { throw new ModelException(ioe); } } @Override public void insert(DataBookEvent pEvent) throws ModelException { } @Override public void update(DataBookEvent pEvent) throws ModelException { } @Override public void delete(DataBookEvent pEvent) throws ModelException { } }