/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. package com.google.ie.business.service;
  16. import com.google.ie.business.domain.Idea;
  17. import com.google.ie.business.domain.Tag;
  18. import com.google.ie.business.domain.User;
  19. import com.google.ie.dto.RetrievalInfo;
  20. import java.util.ArrayList;
  21. import java.util.Collection;
  22. import java.util.List;
  23. /**
  24. * A service specification for the Tag entity
  25. *
  26. * @author Sachneet
  27. */
  28. public interface TagService {
  29. boolean retagIdea(ArrayList<Tag> newTag, Idea idea, User user);
  30. /**
  31. * Saves the tags provided as a comma separate string.
  32. * It Parses the tag string and checks for de-dupe and finally save them
  33. * into data store.
  34. *
  35. * @param tags The String object representing the comma separated tag
  36. * strings.
  37. * @return list of saved tag objects.
  38. */
  39. List<Tag> saveTags(String tags);
  40. /**
  41. * Retrieves a list of Tags by keys.
  42. *
  43. * @param keys the collection of keys of Tag objects.
  44. * @return Returns the list of Tag objects corresponding to keys.
  45. */
  46. List<Tag> getTagsByKeys(Collection<String> keys);
  47. /**
  48. * Retrieves the tags staring with a specific string.
  49. *
  50. * @param startString the start string to be matched with the title of
  51. * the tags
  52. * @param retrievalInfo the {@link RetrievalInfo} object containing the
  53. * request parameters
  54. *
  55. * @return list of fetched tags
  56. */
  57. List<Tag> getTagsWithSpecificStartString(String startString, RetrievalInfo retrievalInfo);
  58. /**
  59. * Get the data for auto suggestion of tags.
  60. *
  61. * @param startString the start string for which the suggestions are to
  62. * be fetched.
  63. * @param retrievalInfo the {@link RetrievalInfo} object containing the
  64. * request parameters
  65. * @return the list of fetched tags
  66. */
  67. List<Tag> getTagsForAutoSuggestion(String startString, RetrievalInfo retrievalInfo);
  68. /**
  69. * Get the data for Tag Cloud.The tags returned are sorted alphabetically.
  70. *
  71. * @param retrievalInfo the {@link RetrievalInfo} object containing the
  72. * request parameters
  73. * @return the list of tags for tag cloud
  74. */
  75. List<Tag> getTagsForTagCloud(RetrievalInfo retrievalInfo);
  76. /**
  77. * Get the tag with title equal to the tagName param.
  78. *
  79. * @param tagName the title of the tag to be fetched
  80. * @return the {@link Tag} object
  81. */
  82. Tag getTagByName(String tagName);
  83. /**
  84. * Get the tags associated with ideas owned by a user.
  85. *
  86. * @param user the user whose tags are to be fetched
  87. * @return list of tags associated with ideas of the user
  88. */
  89. List<Tag> getMyTagCloud(User user);
  90. /**
  91. * Iterates through the list of objects and increment the weight if each Tag
  92. * {@link Tag} object.
  93. *
  94. * @param tags comma separated tags string.
  95. * @return list of tags for which, weight successfully incremented.
  96. */
  97. List<Tag> incrementWeights(String tags);
  98. /**
  99. * Save a tag
  100. *
  101. * @param tag the {@link Tag} object to be saved
  102. * @return the saved {@link Tag} object
  103. */
  104. Tag saveTag(Tag tag);
  105. /**
  106. * Iterates through the list of objects and decrement the weight of each Tag
  107. * {@link Tag} object.
  108. *
  109. * @param tags comma separated tags string.
  110. * @return list of tags for which, weight successfully decremented.
  111. */
  112. List<Tag> decrementWeights(String tags);
  113. /**
  114. * Remove tags with zero weight from the list
  115. *
  116. * @param tagList the list of {@link Tag} objects from which to remove
  117. * objects with zero weight
  118. * @return the filtered list
  119. */
  120. List<Tag> removeTagWithZeroWeight(List<Tag> tagList);
  121. }