Project

General

Profile

« Previous | Next » 

Revision 29380

Added by Eri Katsari over 10 years ago

View differences:

modules/dnet-openaire-stats/trunk/src/main/java/eu/dnetlib/data/mapreduce/hbase/statsExport/utils/Serializer.java
200 200

  
201 201
	}
202 202

  
203
	public static boolean isNumeric(String str) {
204
		return str.matches("-?\\d+(\\.\\d+)?"); // match a number with optional
205
												// '-' and decimal.
206
	}
207

  
208
	private boolean isValidTopic(String t) {
209
		if (t != null && !t.isEmpty() && !t.equals(ENCLOSED + ENCLOSED + DELIM) && !t.equals(ENCLOSED + NULL_STRING + ENCLOSED + DELIM))
210

  
211
		{
212
			return true;
213
		}
214
		return false;
215
	}
216
	
217
	
218

  
203 219
	private HashMap<String, List<String>> getResultTopics(OafEntity valueEntity) {
204 220
		HashMap<String, List<String>> rels = new HashMap<String, List<String>>();
205 221
		List<String> buffs = new ArrayList<String>();
......
209 225
		List<StructuredProperty> Topics = metadata.getSubjectList();
210 226
		for (StructuredProperty topic : Topics) {
211 227
			// TODOs
212
			if (topic.getValue() != null && !topic.getValue().isEmpty() && !topic.getValue().equals("")) {
213
				String t = getStringField(topic.getValue());
214
				if (t != null && !t.isEmpty() && !t.equals(ENCLOSED + NULL_STRING + ENCLOSED + DELIM)) {
215
					buffs.add(t);
228
			if (topic.getValue() != null && !topic.getValue().isEmpty() && !topic.getValue().equals("") && !topic.getValue().equals(" ")) {
229

  
230
				if (!isNumeric(topic.getValue())) {
231
					String t = getStringField(topic.getValue());
232
					if (isValidTopic(t)) {
233
						buffs.add(t);
234
					}
235

  
216 236
				}
217

  
218 237
			}
219 238
		}
220 239
		rels.put("resultTopic", buffs);
......
327 346

  
328 347
		// result_topics/
329 348
		String full_id = getStringField(data.getId());
330
		
349

  
331 350
		buff += full_id;
332 351

  
333 352
		// result_languages
......
386 405
		// number??
387 406

  
388 407
		buff += getStringField("1");
389
		//TODO this is a rotten record.//
390
				if (full_id.contentEquals("datacite____::5903fa1fba477116aba4a922cc9eb56f")) {
391
					log.error("ROTTEN RECORD " + buff);
392
					return null;
393
				}
408
		// TODO this is a rotten record.//
409
		if (full_id.contentEquals("datacite____::5903fa1fba477116aba4a922cc9eb56f")) {
410
			log.error("ROTTEN RECORD " + buff);
411
			return null;
412
		}
394 413
		// TODO check if valid or empty protobuff
395 414
		// TODO do it in all protos?
396 415
		if (isValid(buff, full_id)) {

Also available in: Unified diff