package org.col.resources;

import java.util.List;

import javax.validation.constraints.NotNull;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;

import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.col.api.model.EditorialDecision;
import org.col.dao.DecisionDao;
import org.col.db.mapper.DecisionMapper;
import org.col.es.name.index.NameUsageIndexService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@Path("/decision")
@Produces(MediaType.APPLICATION_JSON)
@SuppressWarnings("static-method")
public class DecisionResource extends CatalogueEntityResource<EditorialDecision> {
  
  @SuppressWarnings("unused")
  private static final Logger LOG = LoggerFactory.getLogger(DecisionResource.class);
  
  public DecisionResource(SqlSessionFactory factory, NameUsageIndexService indexService) {
    super(EditorialDecision.class, new DecisionDao(factory, indexService), factory);
  }
  
  @GET
  public List<EditorialDecision> list(@Context SqlSession session,
                                      @NotNull @QueryParam("datasetKey") Integer datasetKey,
                                      @QueryParam("subjectDatasetKey") Integer subjectDatasetKey,
                                      @QueryParam("id") String id) {
    return session.getMapper(DecisionMapper.class).listBySubjectDataset(datasetKey, subjectDatasetKey, id);
  }
  
  @GET
  @Path("/broken")
  public List<EditorialDecision> broken(@Context SqlSession session,
                                        @NotNull @QueryParam("datasetKey") Integer datasetKey,
                                        @QueryParam("subjectDatasetKey") Integer subjectDatasetKey) {
    DecisionMapper mapper = session.getMapper(DecisionMapper.class);
    return mapper.subjectBroken(datasetKey, subjectDatasetKey);
  }
  
}

@@ -405,24 +405,59 @@
 alDecision;%0A
+import org.col.api.vocab.Datasets;%0A
 import org.c
@@ -1214,33 +1214,24 @@
             
-@NotNull 
 @QueryParam(
@@ -1268,106 +1268,8 @@
 ey,%0A
-                                      @QueryParam(%22subjectDatasetKey%22) Integer subjectDatasetKey,%0A
     
@@ -1405,36 +1405,37 @@
 Dataset(
-d
+D
 ataset
-Key, subjectD
+s.DRAFT_COL, d
 atasetKe
@@ -1588,17 +1588,8 @@
     
-@NotNull 
 @Que
@@ -1632,108 +1632,8 @@
 tKey
-,%0A                                        @QueryParam(%22subjectDatasetKey%22) Integer subjectDatasetKey
 ) %7B%0A
@@ -1737,28 +1737,29 @@
 ken(
-d
+D
 ataset
-Key, subjectD
+s.DRAFT_COL, d
 atas

Revert to only exposing draft decisions in the API for now