/** * @param user * @return * @throws java.text.ParseException @Desc This function populates the "classifiedDayVector" * variable of the com.post.parser.model.User class. It gives the total number of posts in the * specified day range which has been described in getDayCategory(int DayOfWeek) in this * class. */ public User setCategorizedDayOfMonthToUser(User user) throws ParseException { int[] userDayOfMonthVector = user.getClassifiedDayOfMonthVector(); for (Posts posts : user.getUserPost()) { String date = posts.getDate(); int DayOfMonth = getDayOfMonth(date) - 1; userDayOfMonthVector[DayOfMonth] = userDayOfMonthVector[DayOfMonth] + 1; } user.setClassifiedDayOfMonthVector(userDayOfMonthVector); return user; }
public void onClick(View v) { // TODO Auto-generated method stub switch (v.getId()) { case R.id.cancel: finish(); break; case R.id.okay: // Displaying the count of letters c = message.getText().length(); String letter_count = Integer.toString(c); count.setText(letter_count); Posts post = new Posts(); Log.d(TAG, message.getText().toString()); // get the username from login page post.username = Timeline.name; post.message = message.getText().toString(); // post.icon = Timeline.icon; post.time = now(); Log.d(TAG, post.username + " " + post.message + " " + post.time); GsonBuilder gsonb = new GsonBuilder(); Gson gson = gsonb.create(); msg = gson.toJson(post); Log.d(TAG, msg); Intent res_intent = new Intent(); res_intent.putExtra("message", msg); List<NameValuePair> list = new ArrayList<NameValuePair>(); HttpPost httppost = new HttpPost(newPostURL); HttpResponse response; try { list.add(new BasicNameValuePair("username", post.username)); list.add(new BasicNameValuePair("message", post.message)); list.add(new BasicNameValuePair("time", post.time)); httppost.setEntity(new UrlEncodedFormEntity(list)); Log.d(TAG, list.toString()); response = client.execute(httppost); String res = tl.responsetoString(response.getEntity().getContent()); Log.d(TAG, res); } catch (Exception e) { e.printStackTrace(); } setResult(RESULT_OK, res_intent); finish(); break; } }
/** * @param user * @return * @throws java.text.ParseException @Desc This function populates the "classifiedDayVector" * variable of the com.post.parser.model.User class. It gives the total number of posts in the * specified day range which has been described in getDayCategory(int DayOfWeek) in this * class. */ public User setCategorizedMonthToUser(User user) throws ParseException { int[] userMonthVector = user.getClassifiedMonthVector(); for (Posts posts : user.getUserPost()) { String date = posts.getDate(); int MonthOfYear = getMonthOfYear(date); // System.out.println("Day Of Week " + DayOfWeek); userMonthVector[MonthOfYear] = userMonthVector[MonthOfYear] + 1; } user.setClassifiedMonthVector(userMonthVector); return user; }
/** * @param user * @return * @throws java.text.ParseException @Desc This function populates the "classifiedDayVector" * variable of the com.post.parser.model.User class. It gives the total number of posts in the * specified day range which has been described in getDayCategory(int DayOfWeek) in this * class. */ public User setCategorizedDayToUser(User user) throws ParseException { int[] userDayVector = user.getClassifiedDayVector(); for (Posts posts : user.getUserPost()) { String date = posts.getDate(); int DayOfWeek = getDayOfWeek(date) - 1; // System.out.println("Day Of Week " + DayOfWeek); userDayVector[DayOfWeek] = userDayVector[DayOfWeek] + 1; } user.setClassifiedDayVector(userDayVector); return user; }
/** * @param userList * @return * @throws java.text.ParseException @Desc This function populates the "classifiedDayVector" * variable of the com.post.parser.model.User class. It gives the total number of posts in the * specified day range which has been described in getDayCategory(int DayOfWeek) in this * class. */ public List<User> setCategorizedDayOfMonthToUser(List<User> userList) throws ParseException { for (User user : userList) { int[] userDayOfMonthVector = user.getClassifiedDayOfMonthVector(); for (Posts posts : user.getUserPost()) { String date = posts.getDate(); int DayOfMonth = getDayOfMonth(date) - 1; System.out.println("Day Of Week " + DayOfMonth); userDayOfMonthVector[DayOfMonth] = userDayOfMonthVector[DayOfMonth] + 1; } user.setClassifiedDayOfMonthVector(userDayOfMonthVector); } return userList; }
/** * @param user * @return user @Desc This function populates the "classifiedTimeVector" variable of the * com.post.parser.model.User class. It gives the total number of posts in the specified time * range which has been described in getTimeCategory(int hours) in this class. */ public User setCategorizedHourOfDayToUser(User user) { int[] userTimeVector = user.getClassifiedHourOfDayVector(); for (Posts posts : user.getUserPost()) { Timestamp ts = Timestamp.valueOf( new SimpleDateFormat("yyyy-MM-dd ").format(new Date()).concat(posts.getTime())); int timeCategory = ts.getHours(); userTimeVector[timeCategory] = userTimeVector[timeCategory] + 1; } user.setClassifiedHourOfDayVector(userTimeVector); return user; }
/** * @param user * @return user * @throws java.text.ParseException @Desc This function populates the "classifiedTimeVector" * variable of the com.post.parser.model.User class. It gives the total number of posts in the * specified time range which has been described in getTimeCategory(int hours) in this class. */ public User setCategorizedTypeOfWeekToUser(User user) throws ParseException { int[] userTimeVector = user.getClassifiedTypeOfWeekVector(); for (Posts posts : user.getUserPost()) { String date = posts.getDate(); int dayOfWeek = getDayOfWeek(date); int typeOfWeek = getTypeOfWeek(dayOfWeek); userTimeVector[typeOfWeek] = userTimeVector[typeOfWeek] + 1; } user.setClassifiedTypeOfWeekVector(userTimeVector); return user; }
/** * @param userList * @return * @throws java.text.ParseException @Desc This function populates the * "classifiedSixMonthDataVector" variable of the com.post.parser.model.User class. It gives * the total number of posts of only six months */ public List<User> setCategorizedSixMonthDataToUser(List<User> userList) throws ParseException { for (User user : userList) { int[] userMonthVector = user.getClassifiedSixMonthDataVector(); for (Posts posts : user.getUserPost()) { String date = posts.getDate(); int MonthOfYear = getMonthOfYear(date); if (MonthOfYear <= 5) { userMonthVector[MonthOfYear] = userMonthVector[MonthOfYear] + 1; } } user.setClassifiedMonthVector(userMonthVector); } return userList; }
/** * @param user @Desc This function populates the "classifiedTimeVector" variable of the * com.post.parser.model.User class. It gives the total number of posts in the specified time * range which has been described in getTimeCategory(int hours) in this class. * @return List<User> */ public User setCategorizedTimeToUser(User user) { ClusterCommons cc = new ClusterCommons(); int[] userTimeVector = user.getClassifiedTimeVector(); for (Posts posts : user.getUserPost()) { Timestamp ts = Timestamp.valueOf( new SimpleDateFormat("yyyy-MM-dd ").format(new Date()).concat(posts.getTime())); int timeCategory = cc.getTimeCategory(ts.getHours()); if (timeCategory < 6) { userTimeVector[timeCategory] = userTimeVector[timeCategory] + 1; } } user.setClassifiedTimeVector(userTimeVector); return user; }
public static void index() { Posts frontPost = Posts.find("order by postedAt desc").first(); List<Posts> olderPosts = Posts.find("order by postedAt desc").from(1).fetch(10); render(frontPost, olderPosts); }