Skip to content

Commit 4458c9b

Browse files
committed
minor fixes
1 parent dd83876 commit 4458c9b

File tree

2 files changed

+25
-44
lines changed

2 files changed

+25
-44
lines changed

src/main/java/certh/iti/mklab/easie/companymatching/CompanyMatcher.java

+25-23
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,14 @@
1818
import certh.iti.mklab.easie.MongoUtils;
1919
import com.mongodb.client.MongoCollection;
2020
import com.mongodb.client.MongoCursor;
21+
2122
import java.net.UnknownHostException;
2223
import java.util.ArrayList;
24+
2325
import org.bson.Document;
2426
import org.bson.types.ObjectId;
2527

2628
/**
27-
*
2829
* @author vasgat
2930
*/
3031
public class CompanyMatcher {
@@ -38,14 +39,15 @@ public class CompanyMatcher {
3839

3940
/**
4041
* Creates a Company object that connects the Company Name and Website with
41-
* an entry from the dataset or creates a new one
42+
* * an entry from the dataset or creates a new one
4243
*
43-
* @param CompanyName the name of the Company
44-
* @param mongo a MongoUtils object
45-
* @param CompanyLink the Website of the company
46-
* @param dbname database's name
47-
* @param collection's name
48-
* @param searcher A CompanySearcher2 object
44+
* @param company_name
45+
* @param country
46+
* @param website
47+
* @param companies_collection
48+
* @param searcher
49+
* @param loader
50+
* @throws UnknownHostException
4951
*/
5052
public CompanyMatcher(String company_name, String country, String website, MongoCollection companies_collection, CompanySearcher searcher, CountryAbreviationsLoader loader) throws UnknownHostException {
5153
this.company_name = company_name.trim();
@@ -99,8 +101,8 @@ public void insertInfo(String fieldName, String fieldValue) {
99101
companies.updateOne(new Document("_id", company_id),
100102
new Document("$set",
101103
new Document()
102-
.append(fieldName.trim(),
103-
fieldValue.trim())));
104+
.append(fieldName.trim(),
105+
fieldValue.trim())));
104106
}
105107
}
106108

@@ -169,13 +171,13 @@ private ObjectId findCompanyId(String CompanyName, String CLink, String Country)
169171
companies.updateOne(new Document("_id", tempId),
170172
new Document("$set",
171173
new Document()
172-
.append("aliases",
173-
aliases)));
174+
.append("aliases",
175+
aliases)));
174176
companies.updateOne(new Document("_id", tempId),
175177
new Document("$set",
176178
new Document()
177-
.append("website",
178-
CLink.toLowerCase())));
179+
.append("website",
180+
CLink.toLowerCase())));
179181
}
180182
} else {
181183
tempId = null;
@@ -191,8 +193,8 @@ private ObjectId findCompanyId(String CompanyName, String CLink, String Country)
191193
companies.updateOne(new Document("_id", tempId),
192194
new Document("$set",
193195
new Document()
194-
.append("aliases",
195-
aliases)));
196+
.append("aliases",
197+
aliases)));
196198
}
197199
}
198200
return tempId;
@@ -202,19 +204,19 @@ private ObjectId findCompanyId(String CompanyName, String CLink, String Country)
202204
* Searches if the company exists to the database by having available only
203205
* Company's name
204206
*
205-
* @returns company's id, if it is exists in db.
206207
* @throws UnknownHostException
208+
* @returns company's id, if it is exists in db.
207209
*/
208210
private ObjectId findCompanyId(String CompanyName, String Country) throws UnknownHostException {
209211

210212
ObjectId tempId = searcher.search(CompanyName, Country);
211213
if (tempId != null) {
212214
MongoCursor<Document> tempCursor = companies.find(
213215
new Document()
214-
.append(
215-
"_id",
216-
tempId
217-
)
216+
.append(
217+
"_id",
218+
tempId
219+
)
218220
).iterator();
219221

220222
ArrayList aliases = (ArrayList) tempCursor.next()
@@ -225,8 +227,8 @@ private ObjectId findCompanyId(String CompanyName, String Country) throws Unknow
225227
companies.updateOne(new Document("_id", tempId),
226228
new Document("$set",
227229
new Document()
228-
.append("aliases",
229-
aliases)));
230+
.append("aliases",
231+
aliases)));
230232
}
231233
}
232234
return tempId;

src/main/java/certh/iti/mklab/easie/extractors/staticpages/StaticHTMLFetcher.java

-21
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,6 @@ public StaticHTMLFetcher(String baseURL, String relativeURL) throws URISyntaxExc
5656
connection = Jsoup.connect(new URI(baseURL + relativeURL).toASCIIString()).followRedirects(true).ignoreHttpErrors(true)
5757
.timeout(60000);
5858
document = connection.get();
59-
if ((baseURL + relativeURL).equals("https://elfar.cat/art/27043/el-amb-plantea-un-centenar-de-medidas-para-mejorar-la-movilidad-hasta-2024")) {
60-
Writer writer = new BufferedWriter(new OutputStreamWriter(
61-
new FileOutputStream("C:\\Users\\vasgat\\Desktop\\site2.json"), StandardCharsets.UTF_8));
62-
63-
org.bson.Document obj = new org.bson.Document();
64-
obj.append("results", document.text());
65-
writer.write(obj.toString());
66-
writer.close();
67-
Gson gson = new Gson();
68-
System.out.println(org.apache.commons.lang3.StringEscapeUtils.unescapeJava(gson.toJson(obj)));
69-
}
7059
responseCode = connection.response().statusCode();
7160
}
7261

@@ -75,16 +64,6 @@ public StaticHTMLFetcher(String fullURL) throws URISyntaxException, IOException,
7564
connection = Jsoup.connect(new URI(fullURL).toASCIIString()).followRedirects(true).ignoreHttpErrors(true)
7665
.timeout(60000);
7766
document = connection.get();
78-
if ((fullURL).equals("https://elfar.cat/art/27043/el-amb-plantea-un-centenar-de-medidas-para-mejorar-la-movilidad-hasta-2024")) {
79-
Writer writer = new BufferedWriter(new OutputStreamWriter(
80-
new FileOutputStream("C:\\Users\\vasgat\\Desktop\\site2.json"), StandardCharsets.UTF_8));
81-
org.bson.Document obj = new org.bson.Document();
82-
obj.append("results", document.text());
83-
writer.write(obj.toJson());
84-
writer.close();
85-
Gson gson = new Gson();
86-
System.out.println(org.apache.commons.lang3.StringEscapeUtils.unescapeJava(gson.toJson(obj)));
87-
}
8867
responseCode = connection.response().statusCode();
8968
}
9069

0 commit comments

Comments
 (0)