Android Open Source - ormada App Data Source






From Project

Back to project page ormada.

License

The source code is released under:

Copyright (c) 2012 Jesse Rosalia Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Sof...

If you think the Android project ormada listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.// w w  w  . j  av a2  s .co  m
 */
package org.ormada.hsql.example;

import java.util.List;

import org.ormada.ORMDataSource;
import org.ormada.hsql.dialect.HSQLDialect;
import org.ormada.hsql.example.model.Cat;
import org.ormada.hsql.example.model.Kitten;

/**
 *
 * @author jesse.rosalia
 */
public class AppDataSource {

    private static final String DATABASE_NAME   = "felines.db";
    private static final int   DATABASE_VERSION = 1;

    private Class<?> [] entities = {
        Cat.class,
        Kitten.class
    };
    private final ORMDataSource orm;

    public AppDataSource() {
        this.orm = new ORMDataSource(new HSQLDialect(DATABASE_NAME, DATABASE_VERSION), entities);
    }

    public void open() {
      try {
        this.orm.open();
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }

    public void clear() {
      this.orm.deleteAll(Cat.class,    null);
      this.orm.deleteAll(Kitten.class, null);
    }

    public void close() {
      try {
          this.orm.close();
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
    }

    public List<Cat> getAllCats() {
        return (List<Cat>) this.orm.getAll(Cat.class, null);
    }

    public Cat getCat(long id) {
      return this.orm.get(Cat.class, id);
  }

    public void saveCat(Cat newCat) {
        this.orm.save(newCat);
    }

    public void updateCat(Cat cat) {
        this.orm.update(cat);
    }
    
    public void deleteCat(Cat cat) {
      this.orm.delete(cat);
    }

  public void refreshCat(Cat bella) {
    this.orm.refresh(bella);
  }
}




Java Source Code List

org.andrormeda.dialect.SQLiteCursor.java
org.andrormeda.dialect.SQLiteDialect.java
org.andrormeda.dialect.SQLiteValueSet.java
org.andrormeda.example.AppDataSource.java
org.andrormeda.example.ExampleActivity.java
org.andrormeda.example.model.Cat.java
org.andrormeda.example.model.Kitten.java
org.ormada.ORMDataSource.java
org.ormada.annotations.OneToMany.java
org.ormada.annotations.Owner.java
org.ormada.annotations.Reference.java
org.ormada.annotations.Text.java
org.ormada.annotations.Transient.java
org.ormada.dialect.AStandardSQLDialect.java
org.ormada.dialect.DefaultValueSet.java
org.ormada.dialect.Dialect.java
org.ormada.dialect.ForwardOnlyResultSetCursor.java
org.ormada.dialect.FullResultSetCursor.java
org.ormada.dialect.QueryCursor.java
org.ormada.dialect.ValueSet.java
org.ormada.entity.EntityBuilder.java
org.ormada.entity.EntityCache.java
org.ormada.entity.EntityMetaData.java
org.ormada.entity.Entity.java
org.ormada.exception.MixedCollectionException.java
org.ormada.exception.UnableToOpenException.java
org.ormada.exception.UnsavedReferenceException.java
org.ormada.hsql.dialect.HSQLDialect.java
org.ormada.hsql.example.AppDataSource.java
org.ormada.hsql.example.ExampleMain.java
org.ormada.hsql.example.model.Cat.java
org.ormada.hsql.example.model.Kitten.java
org.ormada.model.ORMeta.java
org.ormada.reflect.DefaultReflector.java
org.ormada.reflect.Reflector.java
org.ormada.util.Profiler.java