@Override public AjaxRecommenderCommand<R> instantiateCommand() { final AjaxRecommenderCommand<R> command = new AjaxRecommenderCommand<R>(); /* * initialize lists * FIXME: is it really neccessary to initialize ALL those lists? Which are really needed? */ command.setRelevantGroups(new ArrayList<String>()); command.setRelevantTagSets(new HashMap<String, Map<String, List<String>>>()); command.setRecommendedTags(new TreeSet<RecommendedTag>()); command.setCopytags(new ArrayList<Tag>()); /* * initialize post & resource */ command.setPost(new Post<R>()); command.getPost().setResource(this.initResource()); GroupingCommandUtils.initGroupingCommand(command); return command; }
@Override public View workOn(AjaxRecommenderCommand<R> command) { final RequestWrapperContext context = command.getContext(); /* * only users which are logged in might post bookmarks -> send them to * login page */ if (!context.isUserLoggedIn()) { command.setResponseString(""); return Views.AJAX_XML; } final User loginUser = context.getLoginUser(); // ------------------------------------------------------------------------ // THIS IS AN ISSUE WE STILL HAVE TO DISCUSS: // During the ECML/PKDD recommender challenge, many recommender systems // couldn't deal with the high load, so we filter out those users, which // are flagged as spammer either by an admin, or by the framework for sure // TODO: we could probably also filter out those users, which are // flagged as 'spammer unsure' // ------------------------------------------------------------------------ final User dbUser = adminLogic.getUserDetails(loginUser.getName()); /* * set the user of the post to the loginUser (the recommender might need * the user name) */ command.getPost().setUser(loginUser); /* * initialize groups */ GroupingCommandUtils.initGroups(command, command.getPost().getGroups()); // set postID for recommender command.getPost().setContentId(command.getPostID()); if ((dbUser.isSpammer()) && ((dbUser.getPrediction() == null && dbUser.getAlgorithm() == null) || (dbUser.getPrediction().equals(1) || dbUser.getAlgorithm().equals(USERSPAMALGORITHM)))) { // the user is a spammer log.debug("Filtering out recommendation request from spammer"); if (this.getSpamTagRecommender() != null) { SortedSet<RecommendedTag> result = this.getSpamTagRecommender().getRecommendedTags(command.getPost()); this.processRecommendedTags(command, result); } else { command.setResponseString(""); } } else { // the user doesn't seem to be a spammer /* * get the recommended tags for the post from the command */ if (this.getTagRecommender() != null) { SortedSet<RecommendedTag> result = this.getTagRecommender().getRecommendedTags(command.getPost(), command.getPostID()); this.processRecommendedTags(command, result); } else { command.setResponseString(""); } } return Views.AJAX_XML; }