Project

General

Profile

« Previous | Next » 

Revision 50412

Migrated from dnet40 and adapted to current version of the OpenAIRE Search API.

View differences:

OpenAireDocumentPage.java
2 2

  
3 3
import java.util.List;
4 4

  
5
import com.google.common.collect.Lists;
5 6
import org.dom4j.Attribute;
6 7
import org.dom4j.Document;
7 8
import org.dom4j.Node;
8 9

  
9
import com.google.common.collect.Lists;
10

  
11 10
public class OpenAireDocumentPage {
12 11

  
13 12
	private Document doc;
......
23 22
		return objIds;
24 23
	}
25 24

  
26
	public boolean allWithECFundng() {
27
		return allWithContextId("funding", "ec");
25
	public boolean allWithECFunding() {
26
		return allWithContextId("funding", "EC");
28 27
	}
29 28

  
30
	public boolean allWithUKFundng() {
31
		return allWithContextId("funding", "uk");
29
	public boolean allWithWTFunding() {
30
		return allWithContextId("funding", "WT");
32 31
	}
33 32

  
34 33
	public boolean allWithContextId(final String contextType, final String contextID) {
35 34
		@SuppressWarnings("unchecked")
36
		List<Attribute> fundingList = doc.selectNodes("//context[./@type='" + contextType + "']/@id");
37
		for (Attribute fundingId : fundingList) {
38
			if (!fundingId.getValue().equals(contextID)) return false;
35
		List<Node> entities = doc.selectNodes("//*[local-name()='entity']");
36
		for(Node e : entities){
37
			List<Attribute> fundingList = e.selectNodes("//context[./@type='" + contextType + "']/@id");
38
			boolean found = false;
39
			for (Attribute fundingId : fundingList) {
40
				if(fundingId.getValue().equals(contextID)) {
41
					found = true;
42
					break;
43
				}
44
			}
45
			if(!found) return false;
39 46
		}
40 47
		return true;
41 48
	}

Also available in: Unified diff