Android Open Source - campus Main






From Project

Back to project page campus.

License

The source code is released under:

GNU General Public License

If you think the Android project campus 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

package lecho.app.campus.dao;
/*ww  w. ja va2  s .c  om*/
import java.io.IOException;

import de.greenrobot.daogenerator.DaoGenerator;
import de.greenrobot.daogenerator.Entity;
import de.greenrobot.daogenerator.Property;
import de.greenrobot.daogenerator.Schema;

/**
 * Generates model and DAO's for campus project.
 * 
 * @author Lecho
 * 
 */
public class Main {
  // *** IMPORTANT - INCREMENT IF NEEDED ***
  private static final int SCHEMA_VERSION = 12;

  // *** Entities and properties ***

  // PLACE
  // One place can have many categories, many faculties and many units
  private static final String PLACE = "Place";
  private static final String PLACE_NAME = "name";// not null
  // TODO add boolean flag to control place symbol visibility on details view
  private static final String PLACE_SYMBOL = "symbol";// not null
  private static final String PLACE_DESCRIPTION = "description";// null
  private static final String PLACE_LATITUDE = "latitude";// not null
  private static final String PLACE_LONGITUDE = "longitude";// not null
  private static final String PLACE_HAS_IMAGE = "hasImage";// not null

  // FACULTY
  // One faculty can have many units.
  private static final String FACULTY = "Faculty";
  private static final String FACULTY_NAME = "name";// not null
  private static final String FACULTY_SHORT_NAME = "shortName";// not null
  private static final String FACULTY_FILTERABLE_NAME = "filterableName";// not null;

  // UNIT
  // Unit may belong to one faculty or exists without faculty. For example
  // ICS, DMCS.
  private static final String UNIT = "Unit";
  private static final String UNIT_NAME = "name";// not null
  private static final String UNIT_SHORT_NAME = "shortName";// null
  private static final String UNIT_FACULTY_ID = "facultyId";// null

  // CATEGORY
  // Many-to-Many with place. For example "administration", "sport", etc.
  private static final String CATEGORY = "Category";
  private static final String CATEGORY_NAME = "name";// not null

  // PLACE_FACULTY
  private static final String PLACE_FACULTY = "PlaceFaculty";
  private static final String PLACE_FACULTY_PLACE_ID = "placeId";// null
  private static final String PLACE_FACULTY_FACULTY_ID = "facultyId";// null

  // PLACE_CATEGORY
  private static final String PLACE_CATEGORY = "PlaceCategory";
  private static final String PLACE_CATEGORY_PLACE_ID = "placeId";// null
  private static final String PLACE_CATEGORY_CATEGORY_ID = "categoryId";// null

  // PLACE_UNIT
  private static final String PLACE_UNIT = "PlaceUnit";
  private static final String PLACE_UNIT_PLACE_ID = "placeId";// null
  private static final String PLACE_UNIT_UNIT_ID = "unitId";// null

  public static void main(String[] args) throws IOException, Exception {
    Schema schema = new Schema(SCHEMA_VERSION, "lecho.app.campus.dao");

    // PLACE_FACULTY
    Entity placeFaculty = schema.addEntity(PLACE_FACULTY);
    placeFaculty.addIdProperty().autoincrement();
    Property placeFacultyFacultyId = placeFaculty.addLongProperty(PLACE_FACULTY_FACULTY_ID).getProperty();
    Property placeFacultyPlaceId = placeFaculty.addLongProperty(PLACE_FACULTY_PLACE_ID).getProperty();

    // PLACE_CATEGORY
    Entity placeCategory = schema.addEntity(PLACE_CATEGORY);
    placeCategory.addIdProperty().autoincrement();
    Property placeCategoryCategoryId = placeCategory.addLongProperty(PLACE_CATEGORY_CATEGORY_ID).getProperty();
    Property placeCategoryPlaceId = placeCategory.addLongProperty(PLACE_CATEGORY_PLACE_ID).getProperty();

    // PLACE_UNIT
    Entity placeUnit = schema.addEntity(PLACE_UNIT);
    placeUnit.addIdProperty().autoincrement();
    Property placeUnitUnitId = placeUnit.addLongProperty(PLACE_UNIT_UNIT_ID).getProperty();
    Property placeUnitPlaceId = placeUnit.addLongProperty(PLACE_UNIT_PLACE_ID).getProperty();

    // FACULTY
    Entity faculty = schema.addEntity(FACULTY);
    faculty.addIdProperty();
    faculty.addStringProperty(FACULTY_NAME).notNull();
    faculty.addStringProperty(FACULTY_SHORT_NAME).notNull();
    faculty.addStringProperty(FACULTY_FILTERABLE_NAME).notNull();
    faculty.addToMany(placeFaculty, placeFacultyFacultyId);

    // UNIT
    Entity unit = schema.addEntity(UNIT);
    unit.addIdProperty();
    unit.addStringProperty(UNIT_NAME).notNull();
    unit.addStringProperty(UNIT_SHORT_NAME);
    unit.addToMany(placeUnit, placeUnitUnitId);
    Property unitFacultyId = unit.addLongProperty(UNIT_FACULTY_ID).getProperty();
    unit.addToOne(faculty, unitFacultyId);

    // CATEGORY
    Entity category = schema.addEntity(CATEGORY);
    category.addIdProperty();
    category.addStringProperty(CATEGORY_NAME).notNull();
    category.addToMany(placeCategory, placeCategoryCategoryId);

    // PLACE
    Entity place = schema.addEntity(PLACE);
    place.addIdProperty();
    place.addStringProperty(PLACE_NAME).notNull();
    place.addStringProperty(PLACE_SYMBOL).notNull();
    place.addStringProperty(PLACE_DESCRIPTION);
    place.addDoubleProperty(PLACE_LATITUDE).notNull();
    place.addDoubleProperty(PLACE_LONGITUDE).notNull();
    place.addBooleanProperty(PLACE_HAS_IMAGE).notNull();
    place.addToMany(placeFaculty, placeFacultyPlaceId);
    place.addToMany(placeUnit, placeUnitPlaceId);
    place.addToMany(placeCategory, placeCategoryPlaceId);

    new DaoGenerator().generateAll(schema, "./src-gen");

  }
}




Java Source Code List

lecho.app.campus.activity.AboutAppActivity.java
lecho.app.campus.activity.CampusMapActivity.java
lecho.app.campus.activity.GalleryActivity.java
lecho.app.campus.activity.LegalInfoActivity.java
lecho.app.campus.activity.PlaceDetailsActivity.java
lecho.app.campus.adapter.GalleryPagesFragmentAdapter.java
lecho.app.campus.adapter.MarkerInfoWindowAdapter.java
lecho.app.campus.adapter.NavigationDrawerAdapter.java
lecho.app.campus.adapter.PlaceDetailsFragmentAdapter.java
lecho.app.campus.adapter.SearchResultViewAdapter.java
lecho.app.campus.adapter.SearchSuggestionAdapter.java
lecho.app.campus.dao.CategoryDao.java
lecho.app.campus.dao.CategoryDao.java
lecho.app.campus.dao.Category.java
lecho.app.campus.dao.Category.java
lecho.app.campus.dao.DaoMaster.java
lecho.app.campus.dao.DaoMaster.java
lecho.app.campus.dao.DaoSession.java
lecho.app.campus.dao.DaoSession.java
lecho.app.campus.dao.FacultyDao.java
lecho.app.campus.dao.FacultyDao.java
lecho.app.campus.dao.Faculty.java
lecho.app.campus.dao.Faculty.java
lecho.app.campus.dao.Main.java
lecho.app.campus.dao.PlaceCategoryDao.java
lecho.app.campus.dao.PlaceCategoryDao.java
lecho.app.campus.dao.PlaceCategory.java
lecho.app.campus.dao.PlaceCategory.java
lecho.app.campus.dao.PlaceDao.java
lecho.app.campus.dao.PlaceDao.java
lecho.app.campus.dao.PlaceFacultyDao.java
lecho.app.campus.dao.PlaceFacultyDao.java
lecho.app.campus.dao.PlaceFaculty.java
lecho.app.campus.dao.PlaceFaculty.java
lecho.app.campus.dao.PlaceUnitDao.java
lecho.app.campus.dao.PlaceUnitDao.java
lecho.app.campus.dao.PlaceUnit.java
lecho.app.campus.dao.PlaceUnit.java
lecho.app.campus.dao.Place.java
lecho.app.campus.dao.Place.java
lecho.app.campus.dao.UnitDao.java
lecho.app.campus.dao.UnitDao.java
lecho.app.campus.dao.Unit.java
lecho.app.campus.dao.Unit.java
lecho.app.campus.fragment.GalleryPageFragment.java
lecho.app.campus.fragment.PlaceDetailsFragment.java
lecho.app.campus.fragment.dialog.NoInternetConnectionDialogFragment.java
lecho.app.campus.fragment.dialog.PlayServicesErrorDialogFragment.java
lecho.app.campus.loader.PlaceDetailsLoader.java
lecho.app.campus.loader.PlacesLoader.java
lecho.app.campus.provider.SearchSuggestionProvider.java
lecho.app.campus.service.PopulateDBIntentService.java
lecho.app.campus.utils.ABSMenuItemConverter.java
lecho.app.campus.utils.BitmapAsyncTask.java
lecho.app.campus.utils.Config.java
lecho.app.campus.utils.DataParser.java
lecho.app.campus.utils.DatabaseHelper.java
lecho.app.campus.utils.ImagesDirAsyncTask.java
lecho.app.campus.utils.NavigationDrawerItem.java
lecho.app.campus.utils.PlaceDetails.java
lecho.app.campus.utils.PlacesList.java
lecho.app.campus.utils.UnitsGroup.java
lecho.app.campus.utils.Utils.java
lecho.app.campus.view.CheckableDrawerItem.java
lecho.app.campus.view.UnitsGroupLayout.java
lecho.app.campus.view.ZoomImageView.java
lecho.app.campus.view.ZoomViewPager.java