Revision 49898
Added by Panagiotis Kanakakis over 6 years ago
Converter.java | ||
---|---|---|
2 | 2 |
|
3 | 3 |
import eu.dnetlib.domain.data.Repository; |
4 | 4 |
import eu.dnetlib.domain.data.RepositoryInterface; |
5 |
import eu.dnetlib.repo.manager.service.controllers.RepositoryApi; |
|
5 | 6 |
import eu.dnetlib.repo.manager.shared.*; |
6 | 7 |
import org.apache.log4j.Logger; |
7 | 8 |
import org.json.JSONArray; |
8 | 9 |
import org.json.JSONException; |
9 | 10 |
import org.json.JSONObject; |
11 |
import org.springframework.beans.factory.annotation.Autowired; |
|
10 | 12 |
|
11 | 13 |
import java.io.*; |
12 | 14 |
import java.text.ParseException; |
... | ... | |
16 | 18 |
public class Converter { |
17 | 19 |
|
18 | 20 |
private static final Logger LOGGER = Logger.getLogger(Converter.class); |
19 |
|
|
21 |
|
|
20 | 22 |
public static Repository jsonToRepositoryObject(JSONObject repositoryObject) throws JSONException { |
21 | 23 |
|
22 | 24 |
Repository repository = new Repository(); |
... | ... | |
31 | 33 |
repository.setCertificates(datasource.get("certificates").toString()); |
32 | 34 |
repository.setCitationGuidelineUrl(datasource.get("citationguidelineurl").toString()); |
33 | 35 |
repository.setCollectedFrom( datasource.get("collectedfrom").toString()); |
36 |
|
|
34 | 37 |
repository.setContactEmail(datasource.get("contactemail").toString()); |
38 |
if(repository.getContactEmail().equals("null")) |
|
39 |
repository.setContactEmail(""); |
|
40 |
|
|
35 | 41 |
repository.setDatabaseAccessRestriction(datasource.get("databaseaccessrestriction").toString()); |
36 | 42 |
repository.setDatabaseAccessType(datasource.get("databaseaccesstype").toString()); |
37 | 43 |
repository.setDataUploadRestriction(datasource.get("datauploadrestriction").toString()); |
38 | 44 |
repository.setDataUploadType(datasource.get("datauploadtype").toString()); |
39 | 45 |
repository.setDateOfCollection(convertStringToDate( datasource.get("dateofcollection").toString())); |
40 | 46 |
repository.setDateOfValidation(convertStringToDate( datasource.get("dateofvalidation").toString())); |
47 |
|
|
41 | 48 |
repository.setDescription(datasource.get("description").toString()); |
49 |
if(repository.getDescription().equals("null")) |
|
50 |
repository.setDescription(""); |
|
51 |
|
|
42 | 52 |
repository.setEissn(datasource.get("eissn").toString()); |
53 |
|
|
43 | 54 |
repository.setEnglishName( datasource.get("englishname").toString()); |
55 |
if(repository.getEnglishName().equals("null")) |
|
56 |
repository.setEnglishName(""); |
|
57 |
|
|
58 |
|
|
44 | 59 |
repository.setId(datasource.get("id").toString()); |
45 | 60 |
repository.setIssn(datasource.get("issn").toString()); |
46 | 61 |
repository.setOdLanguages(datasource.get("languages").toString()); |
47 | 62 |
repository.setLatitude( toDouble(datasource.get("latitude").toString())); |
48 | 63 |
repository.setLissn(datasource.get("lissn").toString()); |
64 |
|
|
49 | 65 |
repository.setLogoUrl(datasource.get("logourl").toString()); |
66 |
if(repository.getLogoUrl().equals("null")) |
|
67 |
repository.setLogoUrl(""); |
|
68 |
|
|
50 | 69 |
repository.setLongitude(toDouble(datasource.get("longitude").toString())); |
51 | 70 |
//datasource.get("managed"); |
52 | 71 |
repository.setMissionStatementUrl(datasource.get("missionstatementurl").toString()); |
53 | 72 |
repository.setNamespacePrefix(datasource.get("namespaceprefix").toString()); |
54 | 73 |
repository.setOdContentTypes(datasource.get("od_contenttypes").toString()); |
55 | 74 |
repository.setOfficialName(datasource.get("officialname").toString()); |
75 |
if(repository.getOfficialName().equals("null")) |
|
76 |
repository.setOfficialName(""); |
|
77 |
|
|
56 | 78 |
repository.setPidSystems(datasource.get("pidsystems").toString()); |
57 | 79 |
//datasource.get("platform"); |
58 | 80 |
repository.setProvenanceActionClass( datasource.get("provenanceaction").toString()); |
... | ... | |
64 | 86 |
//datasource.get("subjects"); |
65 | 87 |
Double timezone = toDouble(datasource.get("timezone").toString()); |
66 | 88 |
repository.setTimezone(timezone!=null?timezone:0.0); |
67 |
repository.setTypology(datasource.get("typology").toString());
|
|
89 |
repository.setTypology(datasource.get("platform").toString());
|
|
68 | 90 |
repository.setVersioning(Boolean.valueOf(datasource.get("versioning").toString())); |
69 | 91 |
repository.setWebsiteUrl(datasource.get("websiteurl").toString()); |
92 |
repository.setDatasourceClass(datasource.get("typology").toString()); |
|
93 |
|
|
94 |
//TODO change organization to list |
|
95 |
repository.setOrganization( ((JSONArray)datasource.get("organizations")).getJSONObject(0).get("legalname").toString()); |
|
96 |
String countryCode = ((JSONArray)datasource.get("organizations")).getJSONObject(0).get("country").toString(); |
|
97 |
repository.setCountryCode(countryCode); |
|
98 |
|
|
70 | 99 |
return repository; |
71 | 100 |
} |
72 | 101 |
|
102 |
|
|
103 |
|
|
73 | 104 |
public static Date convertStringToDate(String date){ |
74 | 105 |
|
75 | 106 |
if(Objects.equals(date, "null")) |
Also available in: Unified diff
1. Create new update methods for repository api
2. Rename piwik file.
3. Create bean repomanager.datasource
4. Update converter methods ( typology, datasourceClass )