Back to project page field-data-app.
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.
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; } } }