Search in sources :

Example 6 with TagData

use of com.pratilipi.data.client.TagData in project pratilipi by Pratilipi.

the class TagsApi method getTags.

@Get
public Response getTags(Request request) {
    List<TagData> tagDataList = TagDataUtil.getTags(request.getLanguage(), request.getType());
    List<Response.ResponseObject> responseObjList = new ArrayList<>();
    List<TagData> storyTagList = new ArrayList<>();
    List<TagData> articleTagList = new ArrayList<>();
    List<TagData> poemTagList = new ArrayList<>();
    for (TagData tagData : tagDataList) {
        if (tagData.getPratilipiType().equals(PratilipiType.STORY))
            storyTagList.add(tagData);
        else if (tagData.getPratilipiType().equals(PratilipiType.ARTICLE))
            articleTagList.add(tagData);
        else if (tagData.getPratilipiType().equals(PratilipiType.POEM))
            poemTagList.add(tagData);
    }
    if (storyTagList.size() > 0)
        responseObjList.add(new Response.ResponseObject(PratilipiType.STORY, null, storyTagList));
    if (articleTagList.size() > 0)
        responseObjList.add(new Response.ResponseObject(PratilipiType.ARTICLE, null, articleTagList));
    if (poemTagList.size() > 0)
        responseObjList.add(new Response.ResponseObject(PratilipiType.POEM, null, poemTagList));
    return new Response(responseObjList);
}
Also used : GenericResponse(com.pratilipi.api.shared.GenericResponse) ArrayList(java.util.ArrayList) TagData(com.pratilipi.data.client.TagData) Get(com.pratilipi.api.annotation.Get)

Aggregations

TagData (com.pratilipi.data.client.TagData)6 ArrayList (java.util.ArrayList)3 Gson (com.google.gson.Gson)2 GenericResponse (com.pratilipi.api.shared.GenericResponse)2 InsufficientAccessException (com.pratilipi.common.exception.InsufficientAccessException)2 DataAccessor (com.pratilipi.data.DataAccessor)2 Tag (com.pratilipi.data.type.Tag)2 JsonObject (com.google.gson.JsonObject)1 Get (com.pratilipi.api.annotation.Get)1 Post (com.pratilipi.api.annotation.Post)1 BlogPostApi (com.pratilipi.api.impl.blogpost.BlogPostApi)1 EventApi (com.pratilipi.api.impl.event.EventApi)1 PratilipiContentIndexApi (com.pratilipi.api.impl.pratilipi.PratilipiContentIndexApi)1 PratilipiV2Api (com.pratilipi.api.impl.pratilipi.PratilipiV2Api)1 UserV1Api (com.pratilipi.api.impl.user.UserV1Api)1 InvalidArgumentException (com.pratilipi.common.exception.InvalidArgumentException)1 UnexpectedServerException (com.pratilipi.common.exception.UnexpectedServerException)1 Language (com.pratilipi.common.type.Language)1 PratilipiType (com.pratilipi.common.type.PratilipiType)1 Website (com.pratilipi.common.type.Website)1