package ca.corefacility.bioinformatics.irida.repositories;

import org.springframework.data.repository.PagingAndSortingRepository;

import ca.corefacility.bioinformatics.irida.exceptions.EntityNotFoundException;
import ca.corefacility.bioinformatics.irida.model.Project;
import ca.corefacility.bioinformatics.irida.model.Sample;

/**
 * A repository for storing Sample objects
 * 
 * @author Thomas Matthews <thomas.matthews@phac-aspc.gc.ca>
 */
public interface SampleRepository extends PagingAndSortingRepository<Sample, Long> {

	/**
	 * Get a {@link Sample} with the given string sample identifier from a
	 * specific project.
	 * 
	 * @param project
	 *            The {@link Project} that the {@link Sample} belongs to.
	 * @param externalSampleId
	 *            The string sample identifier for a sample
	 * @return The {@link Sample} for this identifier
	 * @throws EntityNotFoundException
	 *             if a sample with this identifier doesn't exist
	 */
	public Sample getSampleByExternalSampleId(Project p, String externalSampleId) throws EntityNotFoundException;
}

@@ -53,16 +53,70 @@
 ories;%0A%0A
+import org.springframework.data.jpa.repository.Query;%0A
 import o
@@ -178,16 +178,16 @@
 sitory;%0A
-
 %0Aimport 
@@ -489,16 +489,79 @@
 .gc.ca%3E%0A
+ * @author Franklin Bristow %3Cfranklin.bristow@phac-aspc.gc.ca%3E%0A
  */%0Apubl
@@ -1075,13 +1075,121 @@
 ist%0A
-
 %09 */%0A
+%09@Query(%22select j.sample from ProjectSampleJoin j where j.project = ?1 and j.sample.externalSampleId = ?2%22)%0A
 %09pub

Add query for getting sample by external identifier.