package repositories;

import database.MongoDBConnector;
import objects.Solution;
import org.bson.Document;

import javax.inject.Inject;

/**
 * Created by gpietrus on 20.02.2016.
 */
public class SolutionsRepository implements Repository {
    private MongoDBConnector mongoDBConnector;

    @Inject
    public SolutionsRepository(MongoDBConnector mongoDBConnector) {
        this.mongoDBConnector = mongoDBConnector;
    }

//    public void get(UUID uuid) {
//
//    }

//    public List<Solution> getAll() {
//        return mongoDBConnector.getCollection("solutions")
//                .stream()
//                .map(Solution::new)
//                .collect(Collectors.toList());
//    }

    public void add(Solution solution) {
        mongoDBConnector.addDocument("solutions", new Document(solution.toMap()));
    }

    public void clean() {
        mongoDBConnector.removeCollection("solutions");
    }
}

//todo: generify!