1
|
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
|
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
|
|
11
|
import java.io.FileInputStream;
|
12
|
import java.io.IOException;
|
13
|
import java.io.InputStream;
|
14
|
import java.util.Properties;
|
15
|
|
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
|
JSONObject object = (JSONObject) parser.parse(properties.getProperty("lod_sourceMappings"));
|
32
|
System.out.println(object.get("result"));
|
33
|
|
34
|
if (((JSONArray) object.get("result")).toString().contains("http://dbpedia.org/ontology/type"))
|
35
|
System.out.println("lal");
|
36
|
|
37
|
|
38
|
}
|
39
|
|
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
|
|
77
|
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
|
|
88
|
|
89
|
|
90
|
|
91
|
@org.junit.Test
|
92
|
public void testrecods() {
|
93
|
String recordId = " id\thttp://lod.openaire.eu/data/result/doajarticles::1ba2cc76a1da1b039aeafb6da70543b9 http://lod.openaire.eu/vocab/resultSubject \"Social Sciences\" .,";
|
94
|
|
95
|
recordId = "<http://lod.openaire.eu/data/result/od_______162::3147f9e84fde4d4599a45b10e6b7dffb> <http://purl.org/dc/terms/publisher> \"EDP Sciences\" ";
|
96
|
|
97
|
|
98
|
String regex = "\\s+(?=((\\\\[\\\\\"]|[^\\\\\"])*\"(\\\\[\\\\\"]|[^\\\\\"])*\")*(\\\\[\\\\\"]|[^\\\\\"])*$)";
|
99
|
//System.out.println(recordId.replaceAll(regex, "\t"));
|
100
|
|
101
|
|
102
|
//recordId=recordId.replaceAll(regex, "\t");
|
103
|
recordId = recordId.replaceAll(" +([?:]) +", "\t");
|
104
|
// System.out.println(recordId);
|
105
|
|
106
|
|
107
|
String[] split = recordId.split("\t");
|
108
|
for (String s : split) {
|
109
|
|
110
|
System.out.println("each");
|
111
|
System.out.println(s);
|
112
|
}
|
113
|
}
|
114
|
|
115
|
@org.junit.Test
|
116
|
public void testType()
|
117
|
|
118
|
{
|
119
|
String id = "<http://dblp.l3s.de/d2r/resource/publications/journals/ijdsn/DanZYY13>";
|
120
|
|
121
|
String[] s = id.split("/");
|
122
|
|
123
|
System.out.println(s[5]);
|
124
|
}
|
125
|
|
126
|
|
127
|
@org.junit.Test
|
128
|
public void writeToRedis() throws Exception {
|
129
|
|
130
|
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
|
|
134
|
connection.set("a", "b");
|
135
|
}
|
136
|
|
137
|
}
|