All Downloads are FREE. Search and download functionalities are using the official Maven repository.

fr.profi.mzdb.io.reader.table.SampleReader Maven / Gradle / Ivy

There is a newer version: 0.0.27
Show newest version
package fr.profi.mzdb.io.reader.table;

import java.util.List;

import com.almworks.sqlite4java.SQLiteConnection;
import com.almworks.sqlite4java.SQLiteException;

import fr.profi.mzdb.db.model.Sample;
import fr.profi.mzdb.db.table.SampleTable;
import fr.profi.mzdb.util.sqlite.ISQLiteRecordExtraction;
import fr.profi.mzdb.util.sqlite.SQLiteRecord;

// TODO: Auto-generated Javadoc

/**
 * The Class SampleReader.
 * 
 * @author David Bouyssie
 */
public class SampleReader extends AbstractTableModelReader {

	public SampleReader(SQLiteConnection connection) {
		super(connection);
	}

	protected ISQLiteRecordExtraction buildRecordExtractor() {
		return new ISQLiteRecordExtraction() {

			public Sample extract(SQLiteRecord r) throws SQLiteException {

				int id = r.columnInt(SampleTable.ID);
				String name = r.columnString(SampleTable.NAME);
				String paramTreeAsStr = r.columnString(SampleTable.PARAM_TREE);

				return new Sample(id, name, ParamTreeParser.parseParamTree(paramTreeAsStr));
			}
		};
	}

	public Sample getSample(int id) throws SQLiteException {
		return getRecord(Sample.TABLE_NAME, id);
	}
	
	public List getSampleList() throws SQLiteException {
		return getRecordList(Sample.TABLE_NAME);
	}
	
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy