PageRenderTime 13ms CodeModel.GetById 8ms app.highlight 2ms RepoModel.GetById 2ms app.codeStats 0ms

/src/main/java/com/google/ie/business/service/TagService.java

http://thoughtsite.googlecode.com/
Java | 140 lines | 22 code | 19 blank | 99 comment | 0 complexity | f41c3f27ef3504823f3f19d4d692baac MD5 | raw file
  1/* Copyright 2010 Google Inc.
  2 * 
  3 * Licensed under the Apache License, Version 2.0 (the "License");
  4 * you may not use this file except in compliance with the License.
  5 * You may obtain a copy of the License at
  6 * 
  7 *      http://www.apache.org/licenses/LICENSE-2.0
  8 * 
  9 * Unless required by applicable law or agreed to in writing, software
 10 * distributed under the License is distributed on an "AS IS" BASIS.
 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12 * See the License for the specific language governing permissions and
 13 * limitations under the License
 14 */
 15
 16package com.google.ie.business.service;
 17
 18import com.google.ie.business.domain.Idea;
 19import com.google.ie.business.domain.Tag;
 20import com.google.ie.business.domain.User;
 21import com.google.ie.dto.RetrievalInfo;
 22
 23import java.util.ArrayList;
 24import java.util.Collection;
 25import java.util.List;
 26
 27/**
 28 * A service specification for the Tag entity
 29 * 
 30 * @author Sachneet
 31 */
 32public interface TagService {
 33
 34    boolean retagIdea(ArrayList<Tag> newTag, Idea idea, User user);
 35
 36    /**
 37     * Saves the tags provided as a comma separate string.
 38     * It Parses the tag string and checks for de-dupe and finally save them
 39     * into data store.
 40     * 
 41     * @param tags The String object representing the comma separated tag
 42     *        strings.
 43     * @return list of saved tag objects.
 44     */
 45    List<Tag> saveTags(String tags);
 46
 47    /**
 48     * Retrieves a list of Tags by keys.
 49     * 
 50     * @param keys the collection of keys of Tag objects.
 51     * @return Returns the list of Tag objects corresponding to keys.
 52     */
 53    List<Tag> getTagsByKeys(Collection<String> keys);
 54
 55    /**
 56     * Retrieves the tags staring with a specific string.
 57     * 
 58     * @param startString the start string to be matched with the title of
 59     *        the tags
 60     * @param retrievalInfo the {@link RetrievalInfo} object containing the
 61     *        request parameters
 62     * 
 63     * @return list of fetched tags
 64     */
 65    List<Tag> getTagsWithSpecificStartString(String startString, RetrievalInfo retrievalInfo);
 66
 67    /**
 68     * Get the data for auto suggestion of tags.
 69     * 
 70     * @param startString the start string for which the suggestions are to
 71     *        be fetched.
 72     * @param retrievalInfo the {@link RetrievalInfo} object containing the
 73     *        request parameters
 74     * @return the list of fetched tags
 75     */
 76    List<Tag> getTagsForAutoSuggestion(String startString, RetrievalInfo retrievalInfo);
 77
 78    /**
 79     * Get the data for Tag Cloud.The tags returned are sorted alphabetically.
 80     * 
 81     * @param retrievalInfo the {@link RetrievalInfo} object containing the
 82     *        request parameters
 83     * @return the list of tags for tag cloud
 84     */
 85    List<Tag> getTagsForTagCloud(RetrievalInfo retrievalInfo);
 86
 87    /**
 88     * Get the tag with title equal to the tagName param.
 89     * 
 90     * @param tagName the title of the tag to be fetched
 91     * @return the {@link Tag} object
 92     */
 93    Tag getTagByName(String tagName);
 94
 95    /**
 96     * Get the tags associated with ideas owned by a user.
 97     * 
 98     * @param user the user whose tags are to be fetched
 99     * @return list of tags associated with ideas of the user
100     */
101    List<Tag> getMyTagCloud(User user);
102
103    /**
104     * Iterates through the list of objects and increment the weight if each Tag
105     * {@link Tag} object.
106     * 
107     * @param tags comma separated tags string.
108     * @return list of tags for which, weight successfully incremented.
109     */
110
111    List<Tag> incrementWeights(String tags);
112
113    /**
114     * Save a tag
115     * 
116     * @param tag the {@link Tag} object to be saved
117     * @return the saved {@link Tag} object
118     */
119    Tag saveTag(Tag tag);
120
121    /**
122     * Iterates through the list of objects and decrement the weight of each Tag
123     * {@link Tag} object.
124     * 
125     * @param tags comma separated tags string.
126     * @return list of tags for which, weight successfully decremented.
127     */
128
129    List<Tag> decrementWeights(String tags);
130
131    /**
132     * Remove tags with zero weight from the list
133     * 
134     * @param tagList the list of {@link Tag} objects from which to remove
135     *        objects with zero weight
136     * @return the filtered list
137     */
138    List<Tag> removeTagWithZeroWeight(List<Tag> tagList);
139}
140