Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

small fix to comment parser

  • Loading branch information...
commit 1077668ded14d6a1ada25426305ce430fdd6a16a 1 parent b176cf1
Jared Williams authored
11 BillBuzzDataStore/src/comment/model/persist/DisqusThread.java
View
@@ -33,14 +33,15 @@ public DisqusThread () {
comments = new ArrayList<DisqusComment>();
}
- public DisqusThread (List<Post> posts) {
- url = posts.iterator().next().getLink();
+ public DisqusThread (Article article) {
+
+ url = article.getUrl();
bill = ObjectHelper.billFromUrl(url);
comments = new ArrayList<DisqusComment>();
- for(Post p: posts) {
- /*Date d = ObjectHelper.dateFromString(p.getCreatedAt());
+ for(Comment c: article.getComments().getComment()) {
+ Date d = ObjectHelper.dateFromString(c.getDate());
if(first == null || d.before(first)) {
first = d;
@@ -49,7 +50,7 @@ public DisqusThread (List<Post> posts) {
if(last == null || d.after(last)) {
last = d;
}
- comments.add(new DisqusComment(c));*/
+ comments.add(new DisqusComment(c));
}
setSize();
29 BillBuzzDataStore/src/comment/parser/CommentParser.java
View
@@ -17,6 +17,7 @@
import javax.xml.bind.Unmarshaller;
import comment.model.persist.DisqusThread;
+import comment.model.xml.Articles;
import comments.generated.Disqus;
import comments.generated.Post;
@@ -24,7 +25,7 @@
public static void main(String[] args) throws IOException {
- new CommentParser().doParsing(new File("xml/comments22.xml"));
+ new CommentParser().doParsing(new File("xml/old/comments21.xml"));
}
@@ -32,7 +33,7 @@ public static void main(String[] args) throws IOException {
public void doParsing(File f) {
- Disqus disqus = null;
+ Articles disqus = null;
try {
disqus = parseStream(new FileReader(f));
@@ -40,12 +41,10 @@ public void doParsing(File f) {
catch (Exception e) {
e.printStackTrace();
}
+
+// HashMap<Integer,List<Post>> map = new HashMap<Integer,List<Post>>();
- List<Post> posts = disqus.getPosts().getPost();
-
- HashMap<Integer,List<Post>> map = new HashMap<Integer,List<Post>>();
-
- for(Post post:posts) {
+ /*for(Post post:posts) {
String url = post.getLink();
if(url != null && !url.equals("")) {
@@ -58,20 +57,18 @@ public void doParsing(File f) {
else {
thread = new ArrayList<Post>();
}
-
- System.out.println(post.get)
-
+
thread.add(post);
map.put(threadNo, thread);
}
- }
+ }*/
/*for(Integer key:map.keySet()) {
System.out.println(key + ": " + map.get(key).size());
}*/
- /*comment.model.xml.Articles articles = null;
+ comment.model.xml.Articles articles = null;
try {
articles = parseStream(new FileReader(f));
@@ -97,16 +94,16 @@ public void doParsing(File f) {
}
}
- }*/
+ }
}
- public Disqus parseStream(Reader reader) throws Exception {
+ public Articles parseStream(Reader reader) throws Exception {
- String packageName="comments.generated";
+ String packageName="comment.model.xml";
JAXBContext jc = JAXBContext.newInstance(packageName);
Unmarshaller u = jc.createUnmarshaller();
- return (Disqus)u.unmarshal(reader);
+ return (Articles)u.unmarshal(reader);
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.