package org.pdxfinder.services;

import org.pdxfinder.dao.Marker;
import org.pdxfinder.repositories.MarkerRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

/**
 * Created by csaba on 16/05/2017.
 */
@Service
public class MarkerService {

    private MarkerRepository markerRepository;

    @Autowired
    public MarkerService(MarkerRepository markerRepository) {
        this.markerRepository = markerRepository;
    }

    public List<String> getAllMarkers() {

        //TODO: Temporary hack to fix search page

        //Collection<Marker> markers = markerRepository.findAllMarkers();
        List<String> result = new ArrayList<>();
        /*
        for (Marker marker : markers) {
            result.add(marker.getName());
        }
        */
        return result;
    }

    public List<String> getAllMarkerNamesBySampleId(String sampleId){
        Collection<Marker> markers = this.markerRepository.findAllBySampleId(sampleId);
        List<String> result = new ArrayList<>();

        for(Marker marker:markers){
            result.add(marker.getName());
        }

        return result;
    }



}

@@ -669,18 +669,16 @@
         
-//
 Collecti
@@ -729,24 +729,24 @@
 lMarkers();%0A
+
         List
@@ -786,19 +786,9 @@
 ();%0A
-        /*
 %0A
+
     
@@ -879,18 +879,8 @@
   %7D%0A
-        */
 %0A   

Enable looking up markers