Android Open Source - field-data-app Survey Image






From Project

Back to project page field-data-app.

License

The source code is released under:

MIT License

If you think the Android project field-data-app 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 nz.cri.gns.springs.db;
//from  w  ww . j av  a 2 s. c o  m

import java.sql.SQLException;
import java.util.List;

import android.util.Log;

import com.j256.ormlite.dao.RuntimeExceptionDao;
import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.stmt.PreparedQuery;
import com.j256.ormlite.stmt.QueryBuilder;
import com.j256.ormlite.table.DatabaseTable;

/**
 * A SurveyImage is a photo or sketch associated with a survey of a geothermal feature.
 * Images are stored on the tablet's file system, the database only stores the file name.
 * @author duncanw
 */
@DatabaseTable
public class SurveyImage extends PersistentObject {

  private static final long serialVersionUID = 5806825941895415396L;

  @DatabaseField(foreign = true)
  private Survey survey;
  
  @DatabaseField private String imageType;
  @DatabaseField private String fileName;


  public Survey getSurvey() {
    return survey;
  }

  public void setSurvey(Survey survey) {
    this.survey = survey;
  }

  public String getImageType() {
    return imageType;
  }
  
  public void setImageType(String imageType) {
    this.imageType = imageType;
  }

  public String getFileName() {
    return fileName;
  }

  public void setFileName(String fileName) {
    this.fileName = fileName;
  }
  
  public static List<SurveyImage> getBySurvey(Survey survey, SpringsDbHelper dbHelper) {

    List<SurveyImage> surveyImageList;
    RuntimeExceptionDao<SurveyImage, Long> dao = dbHelper.getSurveyImageDao();
    QueryBuilder<SurveyImage, Long> queryBuilder = dao.queryBuilder();
    try {
      queryBuilder.where().eq("survey_id", survey.getId());
      PreparedQuery<SurveyImage> preparedQuery = queryBuilder.prepare();
      surveyImageList = dao.query(preparedQuery);

    } catch (SQLException e) {
      throw new RuntimeException(e);
    }
    return surveyImageList;

  }
  
  public static int getImageCount(Survey survey, SpringsDbHelper dbHelper) {
    RuntimeExceptionDao<SurveyImage, Long> dao = dbHelper.getSurveyImageDao();
    try {
      return (int)dao.queryRawValue("select count(*) from SurveyImage where survey_id=?", String.valueOf(survey.getId()));
    } catch (Exception e) {
      Log.e(SurveyImage.class.getSimpleName(), "Error retrieving SurveyImage count", e);
      return 0;
    }    
  }

}




Java Source Code List

nz.cri.gns.springs.GpsLocation.java
nz.cri.gns.springs.SpringsApplication.java
nz.cri.gns.springs.activity.BioSampleActivity.java
nz.cri.gns.springs.activity.EditBiologicalSamplesActivity.java
nz.cri.gns.springs.activity.MainMenuActivity.java
nz.cri.gns.springs.activity.ManageBioSamplesActivity.java
nz.cri.gns.springs.activity.SettingsActivity.java
nz.cri.gns.springs.db.BiologicalSampleTest.java
nz.cri.gns.springs.db.BiologicalSample.java
nz.cri.gns.springs.db.ChecklistItem.java
nz.cri.gns.springs.db.Configuration.java
nz.cri.gns.springs.db.FeatureTest.java
nz.cri.gns.springs.db.Feature.java
nz.cri.gns.springs.db.PersistentObject.java
nz.cri.gns.springs.db.SpringsDbHelper.java
nz.cri.gns.springs.db.SurveyImage.java
nz.cri.gns.springs.db.SurveyTest.java
nz.cri.gns.springs.db.Survey.java
nz.cri.gns.springs.fragments.AppearanceFragment.java
nz.cri.gns.springs.fragments.BioSampleActivityFragment.java
nz.cri.gns.springs.fragments.BioSampleFragment.java
nz.cri.gns.springs.fragments.ChooseImageFragment.java
nz.cri.gns.springs.fragments.ExportSamplesFragment.java
nz.cri.gns.springs.fragments.FeatureIdFragment.java
nz.cri.gns.springs.fragments.ImageColourPickerFragment.java
nz.cri.gns.springs.fragments.ImageFragment.java
nz.cri.gns.springs.fragments.SpringsDialogFragment.java
nz.cri.gns.springs.fragments.SpringsFragment.java
nz.cri.gns.springs.util.CustomExceptionHandler.java
nz.cri.gns.springs.util.DataStatistics.java
nz.cri.gns.springs.util.DateTimePickerDialog.java
nz.cri.gns.springs.util.UiUtil.java
nz.cri.gns.springs.util.Util.java