/*
 * Copyright (c) 2013 Lucas Holt
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 */

package com.justjournal.ctl.api;

import com.justjournal.db.Tag;
import com.justjournal.db.TagDao;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Collection;

/**
 * @author Lucas Holt
 */
@Controller
@RequestMapping("/api/tags")
final public class TagsController {

    /**
     * Get the tag list for the whole site
     *
     * @return tag list
     */
    @Cacheable("tags")
    @RequestMapping(method = RequestMethod.GET, produces = "application/json")
    public
    @ResponseBody
    Collection<Tag> getTags() {
        return TagDao.list();
    }

    /**
     * Get an individual tag
     *
     * @param id tag id
     * @return tag list
     */
    @Cacheable(value = "tags", key = "id")
    @RequestMapping("/api/tags/{id}")
    @ResponseBody
    public Tag getById(@PathVariable Integer id) {
        return TagDao.viewSingle(id);
    }
}

@@ -1831,16 +1831,24 @@
 n;%0A%0A/**%0A
+ * Tags%0A
  * @auth
@@ -1943,16 +1943,131 @@
 ller %7B%0A%0A
+    private TagDao tagDao = null;%0A%0A    public void setTagDao(TagDao tagDao) %7B%0A        this.tagDao = tagDao;%0A    %7D%0A%0A
     /**%0A
@@ -2322,25 +2322,25 @@
      return 
-T
+t
 agDao.list()
@@ -2503,32 +2503,40 @@
 @RequestMapping(
+value = 
 %22/api/tags/%7Bid%7D%22
@@ -2535,16 +2535,75 @@
 gs/%7Bid%7D%22
+, method = RequestMethod.GET, produces = %22application/json%22
 )%0A    @R
@@ -2650,16 +2650,22 @@
 Variable
+(%22id%22)
  Integer
@@ -2690,25 +2690,18 @@
 urn 
-T
+t
 agDao.
-viewSingle
+get
 (id)

path should be id