dnet-applications/apps/dnet-is-application/src/main/java/eu/dnetlib/is/vocabulary/VocabularyAjaxController.java

51 lines
1.8 KiB
Java

package eu.dnetlib.is.vocabulary;
import java.util.List;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import eu.dnetlib.is.util.InformationServiceException;
import eu.dnetlib.is.vocabulary.model.Vocabulary;
import eu.dnetlib.is.vocabulary.model.VocabularyTerm;
@RestController
@RequestMapping("/ajax/vocs")
public class VocabularyAjaxController extends AbstractVocabularyController {
@GetMapping("/{vocabulary}")
public Vocabulary getVoc(@PathVariable final String vocabulary) throws InformationServiceException {
return vocabularyService.getVoc(vocabulary);
}
@DeleteMapping("/{vocabulary}")
public List<Vocabulary> deleteVocs(@PathVariable final String vocabulary) {
vocabularyService.deleteVocs(vocabulary);
return vocabularyService.listVocs();
}
@PostMapping("/")
public List<Vocabulary> saveVoc(@RequestBody final Vocabulary voc) {
vocabularyService.saveVoc(voc);
return vocabularyService.listVocs();
}
@PostMapping("/{vocabulary}/terms")
public Iterable<VocabularyTerm> saveTerm(@PathVariable final String vocabulary, @RequestBody final VocabularyTerm term) {
vocabularyService.saveTerms(vocabulary, term);
return vocabularyService.listTerms(vocabulary);
}
@DeleteMapping("/{vocabulary}/terms/{term}")
public Iterable<VocabularyTerm> deleteTerms(@PathVariable final String vocabulary, @PathVariable final String term) {
vocabularyService.deleteTerms(vocabulary, term);
return vocabularyService.listTerms(vocabulary);
}
}