1
|
package eu.dnetlib.repo.manager.server.utils;
|
2
|
|
3
|
import com.google.gwt.user.client.rpc.IsSerializable;
|
4
|
import eu.dnetlib.repo.manager.shared.Timezone;
|
5
|
import org.apache.log4j.Logger;
|
6
|
import org.springframework.beans.factory.annotation.Configurable;
|
7
|
|
8
|
import java.io.BufferedReader;
|
9
|
import java.io.InputStreamReader;
|
10
|
import java.util.ArrayList;
|
11
|
import java.util.List;
|
12
|
|
13
|
@Configurable
|
14
|
public class LocalVocabularies implements IsSerializable {
|
15
|
|
16
|
private static Logger logger = Logger.getLogger(LocalVocabularies.class);
|
17
|
|
18
|
public static String loggedInField = "LOGGED_IN_FIELD";
|
19
|
|
20
|
public static List<String> typologies;
|
21
|
public static List<String> countries;
|
22
|
public static List<Timezone> timezones;
|
23
|
|
24
|
public static final String MODE_LOCAL = "local";
|
25
|
public static final String MODE_DNET = "dnet";
|
26
|
public static final String MODE_LDAP = "ldap";
|
27
|
|
28
|
public static final String ENV_LAREFERENCIA = "lareferencia";
|
29
|
public static final String ENV_MINCYT = "mincyt";
|
30
|
public static final String ENV_OPENAIRE_PRODUCTION = "openaire-production";
|
31
|
public static final String ENV_OPENAIRE_BETA = "openaire-beta";
|
32
|
public static final String ENV_DEVELOPMENT = "development";
|
33
|
|
34
|
static {
|
35
|
|
36
|
typologies = new ArrayList<String>();
|
37
|
countries = new ArrayList<String>();
|
38
|
timezones = new ArrayList<Timezone>();
|
39
|
|
40
|
try {
|
41
|
logger.debug("loading typologies, countries, timezones and other constants");
|
42
|
|
43
|
BufferedReader br = new BufferedReader(new InputStreamReader(LocalVocabularies.class.getResourceAsStream("/eu/dnetlib/repo/manager/server/utils/typologies.txt")));
|
44
|
String line;
|
45
|
while((line = br.readLine()) != null) {
|
46
|
typologies.add(line.trim());
|
47
|
}
|
48
|
br.close();
|
49
|
|
50
|
br = new BufferedReader(new InputStreamReader(LocalVocabularies.class.getResourceAsStream("/eu/dnetlib/repo/manager/server/utils/countries.txt")));
|
51
|
while((line = br.readLine()) != null) {
|
52
|
countries.add(line.trim());
|
53
|
}
|
54
|
br.close();
|
55
|
|
56
|
br = new BufferedReader(new InputStreamReader(LocalVocabularies.class.getResourceAsStream("/eu/dnetlib/repo/manager/server/utils/timezones.txt")));
|
57
|
while((line = br.readLine()) != null) {
|
58
|
String parts[] = line.split("\t");
|
59
|
if(parts.length < 2 || parts.length > 2)
|
60
|
continue;
|
61
|
String name = parts[1].trim();
|
62
|
double offset = Double.parseDouble(parts[0].trim());
|
63
|
Timezone timezone = new Timezone(name, offset);
|
64
|
timezones.add(timezone);
|
65
|
}
|
66
|
br.close();
|
67
|
|
68
|
} catch (Exception e) {
|
69
|
logger.error("Error loading typologies, countries, timezones and other constants", e);
|
70
|
}
|
71
|
}
|
72
|
|
73
|
}
|
74
|
|