1
|
package eu.dnetlib.data.mapreduce.hbase.lodExport.utils;
|
2
|
|
3
|
import org.json.simple.JSONObject;
|
4
|
import org.json.simple.parser.JSONParser;
|
5
|
|
6
|
/**
|
7
|
* Created by eri_k on 5/26/2016.
|
8
|
*/
|
9
|
public class LodConfiguration {
|
10
|
private JSONObject config;
|
11
|
|
12
|
public void load(String json) throws InterruptedException {
|
13
|
JSONParser parser = new JSONParser();
|
14
|
try {
|
15
|
config = (JSONObject) parser.parse(json);
|
16
|
|
17
|
|
18
|
} catch (Exception e) {
|
19
|
System.out.println("error" + e);
|
20
|
throw new InterruptedException(e.toString());
|
21
|
}
|
22
|
}
|
23
|
|
24
|
public String getFields(String entity) {
|
25
|
return config.get(entity).toString();
|
26
|
|
27
|
}
|
28
|
|
29
|
public boolean entityExists(String entity) {
|
30
|
|
31
|
return config.get(entity) != null;
|
32
|
}
|
33
|
|
34
|
public boolean isValidField(String entity, String field) {
|
35
|
if ((config.get(entity)).toString().contains(field)) return true;
|
36
|
|
37
|
return false;
|
38
|
}
|
39
|
|
40
|
public JSONObject getConfig() {
|
41
|
return config;
|
42
|
}
|
43
|
|
44
|
public void setConfig(JSONObject config) {
|
45
|
this.config = config;
|
46
|
}
|
47
|
}
|
48
|
|
49
|
|