1 | package eu.clarin.sru.fcs.aggregator.data; |
---|
2 | |
---|
3 | import eu.clarin.sru.fcs.aggregator.sparam.CorpusTreeNode; |
---|
4 | import eu.clarin.sru.fcs.aggregator.data.CenterRegistry; |
---|
5 | import java.io.IOException; |
---|
6 | import java.io.InputStream; |
---|
7 | import java.net.URL; |
---|
8 | import java.util.*; |
---|
9 | import java.util.logging.Level; |
---|
10 | import java.util.logging.Logger; |
---|
11 | import javax.xml.parsers.DocumentBuilder; |
---|
12 | import javax.xml.parsers.DocumentBuilderFactory; |
---|
13 | import org.w3c.dom.Document; |
---|
14 | import org.w3c.dom.NodeList; |
---|
15 | |
---|
16 | /** |
---|
17 | * Institution node. Can have Endpoint children. |
---|
18 | * |
---|
19 | * @author Yana Panchenko |
---|
20 | */ |
---|
21 | public class InstitutionForTesting extends Institution { |
---|
22 | |
---|
23 | private List<Endpoint> endpoints = new ArrayList<Endpoint>(); |
---|
24 | private boolean hasChildrenLoaded = false; |
---|
25 | |
---|
26 | private static final String[] testEndpoints = new String[]{"http://lux17.mpi.nl/cqltest"}; |
---|
27 | |
---|
28 | private static final Logger logger = Logger.getLogger(Institution.class.getName()); |
---|
29 | |
---|
30 | public InstitutionForTesting(String name, String link) { |
---|
31 | super(name,link); |
---|
32 | } |
---|
33 | |
---|
34 | |
---|
35 | |
---|
36 | @Override |
---|
37 | public boolean hasChildrenLoaded() { |
---|
38 | return hasChildrenLoaded; |
---|
39 | } |
---|
40 | |
---|
41 | @Override |
---|
42 | public void loadChildren() { |
---|
43 | |
---|
44 | if (hasChildrenLoaded) { |
---|
45 | return; |
---|
46 | } |
---|
47 | hasChildrenLoaded = true; |
---|
48 | |
---|
49 | for (int j = 0; j < testEndpoints.length; j++) { |
---|
50 | String epUrl = testEndpoints[j]; |
---|
51 | Endpoint endpoint = new Endpoint(epUrl, this); |
---|
52 | endpoints.add(endpoint); |
---|
53 | } |
---|
54 | |
---|
55 | } |
---|
56 | |
---|
57 | @Override |
---|
58 | public List<? extends CorpusTreeNode> getChildren() { |
---|
59 | loadChildren(); |
---|
60 | return this.endpoints; |
---|
61 | } |
---|
62 | |
---|
63 | @Override |
---|
64 | public CorpusTreeNode getChild(int index) { |
---|
65 | loadChildren(); |
---|
66 | if (index >= endpoints.size()) { |
---|
67 | return null; |
---|
68 | } |
---|
69 | return endpoints.get(index); |
---|
70 | } |
---|
71 | |
---|
72 | |
---|
73 | } |
---|