Project

General

Profile

« Previous | Next » 

Revision 49250

View differences:

modules/dnet-isti/trunk/src/main/java/eu/dnetlib/data/mdstore/plugins/EnrichProjectsPlugin.java
36 36

  
37 37
		final MongoCollection<DBObject> collPubs = store.getCollection();
38 38

  
39
		final Map<String, List<Project>> pubs = resolveProjects(collPubs);
40

  
41
		// update the publications
42
		pubs.entrySet().forEach(e -> patchRecord(collPubs, e.getKey(), e.getValue()));
43

  
44
		touch(store);
45
	}
46

  
47
	private Map<String, List<Project>> resolveProjects(final MongoCollection<DBObject> collPubs) {
48
		final Map<String, List<Project>> pubs = new HashMap<>();
39 49
		final Map<String, Project> mapProjects = new HashMap<>();
40
		final Map<String, List<Project>> pubs = new HashMap<>();
41

  
42 50
		for (final DBObject obj : collPubs.find()) {
43 51
			final List<Project> projects = projectsFromPublication(obj, mapProjects);
44 52
			pubs.put(obj.get("id").toString(), projects);
45 53
		}
46

  
47
		// update the publications
48
		pubs.entrySet().forEach(e -> {
49
			final String id = e.getKey();
50
			final List<Project> projects = e.getValue();
51
			patchRecord(collPubs, id, projects);
52
		});
53

  
54
		touch(store);
54
		return pubs;
55 55
	}
56 56

  
57 57
	private List<Project> projectsFromPublication(final DBObject obj, final Map<String, Project> mapProjects) {
......
60 60
			final Document doc = (new SAXReader()).read(new StringReader(obj.get("body").toString()));
61 61
			for (final Object o : doc.selectNodes("//*[local-name()='project']")) {
62 62
				final Element p = (Element) o;
63
				final String code = p.valueOf("//*[local-name() = 'code']").trim();
64
				final String infoId = p.valueOf("//*[local-name() = 'infoId']").trim();
63
				final String code = p.valueOf("./*[local-name() = 'code']").trim();
64
				final String infoId = p.valueOf("./*[local-name() = 'infoId']").trim();
65 65

  
66 66
				if (StringUtils.isEmpty(code) && StringUtils.isNotEmpty(infoId)) {
67 67
					final String[] arr = infoId.split("/");

Also available in: Unified diff