Package com.sibvisions.rad.persist

Examples of com.sibvisions.rad.persist.AbstractMemStorage


  public IStorage getContacts() throws Exception
  {
    //TODO replace example storage with your storage, e.g. DBStorage
   
    //use Session for caching
    AbstractMemStorage amsContacts = (AbstractMemStorage)getParent().get("contacts");
   
    if (amsContacts == null)
    {
      amsContacts = new AbstractMemStorage()
      {
        private int iId = 0;
       
        @Override
        public RowDefinition getRowDefinition() throws ModelException
        {
          RowDefinition rowdef = new RowDefinition();
          rowdef.addColumnDefinition(new ColumnDefinition("ID", new BigDecimalDataType()));
          rowdef.addColumnDefinition(new ColumnDefinition("FIRST_NAME"));
          rowdef.addColumnDefinition(new ColumnDefinition("LAST_NAME"));
          rowdef.addColumnDefinition(new ColumnDefinition("DOB", new TimestampDataType()));
         
          rowdef.setColumnView(null, new ColumnView("ID", "FIRST_NAME", "LAST_NAME", "DOB"));
         
          rowdef.setPrimaryKeyColumnNames(new String[] {"ID"});
         
          return rowdef;
        }
       
        @Override
        public void update(DataBookEvent pEvent) throws ModelException
        {
        }
       
        @Override
        public void loadData(MemDataBook pBook, ICondition pFilter) throws ModelException
        {
        }
       
        @Override
        public void insert(DataBookEvent pEvent) throws ModelException
        {
          pEvent.getChangedDataBook().setValue("ID", BigDecimal.valueOf(iId++));
        }
       
        @Override
        public void delete(DataBookEvent pEvent) throws ModelException
        {
        }
      };

      amsContacts.open();

      //use Session for caching
      getParent().put("contacts", amsContacts);
    }
   
View Full Code Here

TOP

Related Classes of com.sibvisions.rad.persist.AbstractMemStorage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.