package eu.dnetlib.is.context;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import eu.dnetlib.data.is.context.model.Category;
import eu.dnetlib.data.is.context.model.Context;
import eu.dnetlib.data.is.context.model.CtxChildInfo;
import eu.dnetlib.is.errors.InformationServiceException;

@RestController
@RequestMapping("/ajax/contexts")
public class ContextAjaxController extends AbstractContextController {

	@GetMapping("/{ctxId}")
	public Context getContext(@PathVariable final String ctxId) throws InformationServiceException {
		return contextService.getContext(ctxId);
	}

	@GetMapping("/{parent}/categories")
	public Iterable<Category> listCategories(@PathVariable final String parent) {
		return contextService.listCategories(parent);
	}

	@GetMapping("/{level}/{parent}/concepts")
	public Iterable<? extends CtxChildInfo> listCategories(@PathVariable final int level, @PathVariable final String parent)
		throws InformationServiceException {
		return contextService.listConcepts(level, parent);
	}

}
