18
18
import certh .iti .mklab .easie .MongoUtils ;
19
19
import com .mongodb .client .MongoCollection ;
20
20
import com .mongodb .client .MongoCursor ;
21
+
21
22
import java .net .UnknownHostException ;
22
23
import java .util .ArrayList ;
24
+
23
25
import org .bson .Document ;
24
26
import org .bson .types .ObjectId ;
25
27
26
28
/**
27
- *
28
29
* @author vasgat
29
30
*/
30
31
public class CompanyMatcher {
@@ -38,14 +39,15 @@ public class CompanyMatcher {
38
39
39
40
/**
40
41
* 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
42
43
*
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
49
51
*/
50
52
public CompanyMatcher (String company_name , String country , String website , MongoCollection companies_collection , CompanySearcher searcher , CountryAbreviationsLoader loader ) throws UnknownHostException {
51
53
this .company_name = company_name .trim ();
@@ -99,8 +101,8 @@ public void insertInfo(String fieldName, String fieldValue) {
99
101
companies .updateOne (new Document ("_id" , company_id ),
100
102
new Document ("$set" ,
101
103
new Document ()
102
- .append (fieldName .trim (),
103
- fieldValue .trim ())));
104
+ .append (fieldName .trim (),
105
+ fieldValue .trim ())));
104
106
}
105
107
}
106
108
@@ -169,13 +171,13 @@ private ObjectId findCompanyId(String CompanyName, String CLink, String Country)
169
171
companies .updateOne (new Document ("_id" , tempId ),
170
172
new Document ("$set" ,
171
173
new Document ()
172
- .append ("aliases" ,
173
- aliases )));
174
+ .append ("aliases" ,
175
+ aliases )));
174
176
companies .updateOne (new Document ("_id" , tempId ),
175
177
new Document ("$set" ,
176
178
new Document ()
177
- .append ("website" ,
178
- CLink .toLowerCase ())));
179
+ .append ("website" ,
180
+ CLink .toLowerCase ())));
179
181
}
180
182
} else {
181
183
tempId = null ;
@@ -191,8 +193,8 @@ private ObjectId findCompanyId(String CompanyName, String CLink, String Country)
191
193
companies .updateOne (new Document ("_id" , tempId ),
192
194
new Document ("$set" ,
193
195
new Document ()
194
- .append ("aliases" ,
195
- aliases )));
196
+ .append ("aliases" ,
197
+ aliases )));
196
198
}
197
199
}
198
200
return tempId ;
@@ -202,19 +204,19 @@ private ObjectId findCompanyId(String CompanyName, String CLink, String Country)
202
204
* Searches if the company exists to the database by having available only
203
205
* Company's name
204
206
*
205
- * @returns company's id, if it is exists in db.
206
207
* @throws UnknownHostException
208
+ * @returns company's id, if it is exists in db.
207
209
*/
208
210
private ObjectId findCompanyId (String CompanyName , String Country ) throws UnknownHostException {
209
211
210
212
ObjectId tempId = searcher .search (CompanyName , Country );
211
213
if (tempId != null ) {
212
214
MongoCursor <Document > tempCursor = companies .find (
213
215
new Document ()
214
- .append (
215
- "_id" ,
216
- tempId
217
- )
216
+ .append (
217
+ "_id" ,
218
+ tempId
219
+ )
218
220
).iterator ();
219
221
220
222
ArrayList aliases = (ArrayList ) tempCursor .next ()
@@ -225,8 +227,8 @@ private ObjectId findCompanyId(String CompanyName, String Country) throws Unknow
225
227
companies .updateOne (new Document ("_id" , tempId ),
226
228
new Document ("$set" ,
227
229
new Document ()
228
- .append ("aliases" ,
229
- aliases )));
230
+ .append ("aliases" ,
231
+ aliases )));
230
232
}
231
233
}
232
234
return tempId ;
0 commit comments