package org.pdxfinder.repositories;

import org.pdxfinder.dao.Specimen;
import org.springframework.data.neo4j.annotation.Query;
import org.springframework.data.neo4j.repository.Neo4jRepository;
import org.springframework.data.repository.query.Param;

import java.util.List;

/**
 * Created by jmason on 08/06/2017.
 */
public interface SpecimenRepository extends Neo4jRepository<Specimen, Long> {

    Specimen findByExternalId(@Param("externalId") String externalId);

    @Query("MATCH (mod:ModelCreation) where mod.sourcePdxId = {modelId} with mod" +
            "  optional match (mod)-[io:INSTANCE_OF]-(pdxPass:PdxPassage)-[passfrm:PASSAGED_FROM]-(spec:Specimen)-[char:CHARACTERIZED_BY]-(molchar:MolecularCharacterization)-[assoc:ASSOCIATED_WITH]-(mAss:MarkerAssociation)-[aw:MARKER]-(m:Marker) " +
            "  return spec")
    List<Specimen> findVariationDataBySourcePdxId(@Param("modelId") String modelId);



}

@@ -912,12 +912,584 @@
 elId);%0A%0A
+    @Query(%22MATCH (s:Sample)--(mod:ModelCreation)--(pass:PdxPassage)--(spec:Specimen) %22 +%0A            %22WHERE s.dataSource = %7BdataSource%7D %22 +%0A            %22AND mod.sourcePdxId = %7BmodelId%7D %22 +%0A            %22AND pass.passage = %7Bpassage%7D %22 +%0A            %22AND spec.externalId = %7BspecimenId%7D %22 +%0A            %22RETURN spec%22)%0A    Specimen findByModelIdAndDataSourceAndSpecimenIdAndPassage(%0A            @Param(%22modelId%22) String modelId,%0A            @Param(%22dataSource%22) String dataSource,%0A            @Param(%22specimenId%22) String specimenId,%0A            @Param(%22passage%22) int passage);
 %0A%0A%7D%0A

Add model specific find method