1 |
43395
|
eri.katsar
|
import com.lambdaworks.redis.RedisURI;
|
2 |
|
|
import com.lambdaworks.redis.cluster.ClusterClientOptions;
|
3 |
|
|
import com.lambdaworks.redis.cluster.RedisAdvancedClusterConnection;
|
4 |
|
|
import com.lambdaworks.redis.cluster.RedisClusterClient;
|
5 |
|
|
import eu.dnetlib.data.mapreduce.hbase.lodExport.utils.LodConfiguration;
|
6 |
42802
|
eri.katsar
|
import org.json.simple.JSONArray;
|
7 |
|
|
import org.json.simple.JSONObject;
|
8 |
|
|
import org.json.simple.parser.JSONParser;
|
9 |
|
|
import org.json.simple.parser.ParseException;
|
10 |
43143
|
giorgos.al
|
|
11 |
43395
|
eri.katsar
|
import java.io.FileInputStream;
|
12 |
|
|
import java.io.IOException;
|
13 |
|
|
import java.io.InputStream;
|
14 |
|
|
import java.util.Properties;
|
15 |
42802
|
eri.katsar
|
|
16 |
|
|
/**
|
17 |
|
|
* Created by eri_k on 5/28/2016.
|
18 |
|
|
*/
|
19 |
|
|
public class Test {
|
20 |
|
|
|
21 |
|
|
|
22 |
|
|
@org.junit.Test
|
23 |
|
|
public void testJson() throws IOException, ParseException {
|
24 |
|
|
InputStream in = new FileInputStream("C:\\Users\\eri_k\\workspace\\lodinterlinking\\trunk\\src\\main\\resources\\eu\\dnetlib\\data\\mapreduce\\hbase\\lodExport\\mappings.properties");
|
25 |
|
|
|
26 |
|
|
Properties properties = new Properties();
|
27 |
|
|
properties.load(in);
|
28 |
|
|
in.close();
|
29 |
|
|
|
30 |
|
|
JSONParser parser = new JSONParser();
|
31 |
42918
|
eri.katsar
|
JSONObject object = (JSONObject) parser.parse(properties.getProperty("lod_sourceMappings"));
|
32 |
42802
|
eri.katsar
|
System.out.println(object.get("result"));
|
33 |
|
|
|
34 |
42918
|
eri.katsar
|
if (((JSONArray) object.get("result")).toString().contains("http://dbpedia.org/ontology/type"))
|
35 |
42802
|
eri.katsar
|
System.out.println("lal");
|
36 |
42918
|
eri.katsar
|
|
37 |
|
|
|
38 |
42802
|
eri.katsar
|
}
|
39 |
42918
|
eri.katsar
|
|
40 |
|
|
|
41 |
|
|
@org.junit.Test
|
42 |
|
|
public void testSplit() throws Exception {
|
43 |
|
|
String line = "<http://lod.openaire.eu/data/person/doajarticles::dc4862cbad761cd43925c558f89e7d17> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person>";
|
44 |
|
|
InputStream in = new FileInputStream("C:\\Users\\eri_k\\workspace\\lodinterlinking\\trunk\\src\\main\\resources\\eu\\dnetlib\\data\\mapreduce\\hbase\\lodExport\\mappings.properties");
|
45 |
|
|
|
46 |
|
|
Properties properties = new Properties();
|
47 |
|
|
properties.load(in);
|
48 |
|
|
in.close();
|
49 |
|
|
|
50 |
|
|
line = line.replace("<", "").replace(">", "");
|
51 |
|
|
|
52 |
|
|
LodConfiguration lodConfiguration = new LodConfiguration();
|
53 |
|
|
lodConfiguration.load(properties.getProperty("lod_sourceMappings"));
|
54 |
|
|
|
55 |
|
|
String[] Fields = line.toString().split("\t");
|
56 |
|
|
|
57 |
|
|
|
58 |
|
|
int i = 1;
|
59 |
|
|
|
60 |
|
|
String[] tmp = Fields[0].split("/");
|
61 |
|
|
String entity = tmp[4];
|
62 |
|
|
String id = Fields[0];
|
63 |
|
|
|
64 |
|
|
System.out.println(entity);
|
65 |
|
|
System.out.println(id);
|
66 |
|
|
|
67 |
|
|
|
68 |
|
|
StringBuilder value = new StringBuilder();
|
69 |
|
|
|
70 |
|
|
if (lodConfiguration.entityExists(entity)) {
|
71 |
|
|
System.out.println("yeaah");
|
72 |
|
|
System.out.println("field is " + Fields[i].replace("/", "\\/"));
|
73 |
|
|
System.out.println((((org.json.simple.JSONArray) lodConfiguration.getConfig().get(entity))));
|
74 |
|
|
System.out.println((((org.json.simple.JSONArray) lodConfiguration.getConfig().get(entity)).toString().contains(Fields[i].replace("/", "\\/"))));
|
75 |
|
|
|
76 |
42921
|
eri.katsar
|
|
77 |
42918
|
eri.katsar
|
while (i < Fields.length - 1) {
|
78 |
|
|
if (lodConfiguration.isValidField(entity, Fields[i].replace("/", "\\/"))) {
|
79 |
|
|
// value.append(Fields[i] + "\t" + Fields[i+1]);
|
80 |
|
|
value.append(Fields[i] + "\t" + Fields[i + 1]);
|
81 |
|
|
}
|
82 |
|
|
i += 2;
|
83 |
|
|
}
|
84 |
|
|
}
|
85 |
|
|
System.out.println("value is " + value);
|
86 |
|
|
}
|
87 |
43011
|
eri.katsar
|
|
88 |
|
|
|
89 |
|
|
|
90 |
|
|
|
91 |
43093
|
eri.katsar
|
@org.junit.Test
|
92 |
|
|
public void testrecods() {
|
93 |
43102
|
eri.katsar
|
String recordId = " id\thttp://lod.openaire.eu/data/result/doajarticles::1ba2cc76a1da1b039aeafb6da70543b9 http://lod.openaire.eu/vocab/resultSubject \"Social Sciences\" .,";
|
94 |
43093
|
eri.katsar
|
|
95 |
43136
|
eri.katsar
|
recordId = "<http://lod.openaire.eu/data/result/od_______162::3147f9e84fde4d4599a45b10e6b7dffb> <http://purl.org/dc/terms/publisher> \"EDP Sciences\" ";
|
96 |
43093
|
eri.katsar
|
|
97 |
43102
|
eri.katsar
|
|
98 |
43136
|
eri.katsar
|
String regex = "\\s+(?=((\\\\[\\\\\"]|[^\\\\\"])*\"(\\\\[\\\\\"]|[^\\\\\"])*\")*(\\\\[\\\\\"]|[^\\\\\"])*$)";
|
99 |
|
|
//System.out.println(recordId.replaceAll(regex, "\t"));
|
100 |
43102
|
eri.katsar
|
|
101 |
|
|
|
102 |
43136
|
eri.katsar
|
//recordId=recordId.replaceAll(regex, "\t");
|
103 |
|
|
recordId = recordId.replaceAll(" +([?:]) +", "\t");
|
104 |
|
|
// System.out.println(recordId);
|
105 |
43102
|
eri.katsar
|
|
106 |
|
|
|
107 |
43136
|
eri.katsar
|
String[] split = recordId.split("\t");
|
108 |
|
|
for (String s : split) {
|
109 |
43102
|
eri.katsar
|
|
110 |
43136
|
eri.katsar
|
System.out.println("each");
|
111 |
|
|
System.out.println(s);
|
112 |
|
|
}
|
113 |
|
|
}
|
114 |
43102
|
eri.katsar
|
|
115 |
43136
|
eri.katsar
|
@org.junit.Test
|
116 |
|
|
public void testType()
|
117 |
43102
|
eri.katsar
|
|
118 |
43136
|
eri.katsar
|
{
|
119 |
|
|
String id = "<http://dblp.l3s.de/d2r/resource/publications/journals/ijdsn/DanZYY13>";
|
120 |
43102
|
eri.katsar
|
|
121 |
43136
|
eri.katsar
|
String[] s = id.split("/");
|
122 |
43102
|
eri.katsar
|
|
123 |
43136
|
eri.katsar
|
System.out.println(s[5]);
|
124 |
|
|
}
|
125 |
43102
|
eri.katsar
|
|
126 |
|
|
|
127 |
43395
|
eri.katsar
|
@org.junit.Test
|
128 |
|
|
public void writeToRedis() throws Exception {
|
129 |
43011
|
eri.katsar
|
|
130 |
43395
|
eri.katsar
|
RedisURI redisUri = RedisURI.Builder.redis("83.212.110.197").withPort(6379).build();
|
131 |
|
|
RedisClusterClient clusterClient = RedisClusterClient.create(redisUri);
|
132 |
|
|
RedisAdvancedClusterConnection<String, String> connection = clusterClient.connectCluster();
|
133 |
43011
|
eri.katsar
|
|
134 |
43395
|
eri.katsar
|
connection.set("a", "b");
|
135 |
43011
|
eri.katsar
|
}
|
136 |
|
|
|
137 |
42802
|
eri.katsar
|
}
|