source: other-projects/maori-lang-detection/src/org/greenstone/atea/morphia/WebpageInfo.java@ 33653

Last change on this file since 33653 was 33653, checked in by ak19, 4 years ago
  1. As suggested by Dr Bainbridge, made the code changes to use Morphia as ODM for MongoDB (Object Document Mapper, ODM for MongoDB is equivalent to what ORM is to RDBMS). 2. Adding jar files to get this to work. 3. Further changes to store site folder names of form ##### as primary key of Websites collection. However, may in a future commit decide to store a reference to a WebsiteInfo object (representing a JSON document in a Websites MongoDB collection) inside a WebpageInfo object. 4. The MongoDB collections are now called Websites and Webpages, not websites and webpages. 5. geolocation of site now stored as field in Websites mongodb collection. And containsMRI now stored as field in Webpages collection of mongoDB. 6. Tried out some mongodb query commands based on what Dr Bainbridge did yesterday.
File size: 1.9 KB
Line 
1package org.greenstone.atea.morphia;
2
3import dev.morphia.annotations.*;
4import java.util.ArrayList;
5import java.util.List;
6
7/**
8 * Morphia provides the Object Document Mapper for MongoDB
9 * https://www.baeldung.com/mongodb-morphia
10 *
11 */
12@Entity("Webpages")
13public class WebpageInfo {
14
15 /** db table ids */
16 @Id
17 public final long webpageID;
18 // TODO: should this be a "Reference" to the WebsiteInfo object instead?
19 // See section 5.2 of https://www.baeldung.com/mongodb-morphia
20 public final String websiteID; //int websiteID;
21
22 public final int totalSentences;
23
24 public final String text;
25 public final String URL;
26 public final boolean isMRI;
27
28 public final String charEncoding;
29 public final String modifiedTime;
30 public final String fetchTime;
31
32 @Embedded
33 public final List<SentenceInfo> singleSentences;
34 @Embedded
35 public final List<SentenceInfo> overlappingSentences;
36
37 private int mriSentenceCount;
38 private boolean containsMRI;
39
40 public WebpageInfo (long webpageID, String siteID/*int websiteID,*/,
41 String pageText, String pageURL, boolean isMRI, int totalSentences,
42 String charEncoding, String modifiedTime, String fetchTime,
43 List<SentenceInfo> singleSentences,
44 List<SentenceInfo> overlappingSentences)
45 {
46
47 this.webpageID = webpageID;
48 //this.websiteID = websiteID;
49 this.websiteID = siteID;
50
51 this.totalSentences = totalSentences;
52
53 this.text = pageText;
54 this.URL = pageURL;
55 this.isMRI = isMRI;
56
57 this.charEncoding = charEncoding;
58 this.modifiedTime = modifiedTime;
59 this.fetchTime = fetchTime;
60
61 this.singleSentences = singleSentences;
62 this.overlappingSentences = overlappingSentences;
63
64 }
65
66 public void setMRISentenceCount(int count) {
67 this.mriSentenceCount = count;
68 }
69 public void setContainsMRI(boolean containsMRI) {
70 this.containsMRI = containsMRI;
71 }
72
73 public int getMRISentenceCount() { return this.mriSentenceCount; }
74}
Note: See TracBrowser for help on using the repository browser.