Project

General

Profile

« Previous | Next » 

Revision 51525

1. Add roles for aai
2. Changes on converter file for new interface object
3. Move emailUtils to avoid bug on bean definitions
4. Add openaire provider authorities mapper class
5. Bug fixes on controllers

View differences:

Converter.java
3 3
import com.fasterxml.jackson.databind.ObjectMapper;
4 4
import eu.dnetlib.domain.data.Repository;
5 5
import eu.dnetlib.domain.data.RepositoryInterface;
6
import eu.dnetlib.repo.manager.service.controllers.PiWikApi;
7 6
import eu.dnetlib.repo.manager.shared.AggregationDetails;
8 7
import eu.dnetlib.repo.manager.shared.Timezone;
9 8
import org.apache.commons.codec.digest.DigestUtils;
......
11 10
import org.json.JSONArray;
12 11
import org.json.JSONException;
13 12
import org.json.JSONObject;
14
import org.springframework.beans.factory.annotation.Autowired;
15
import org.springframework.web.bind.annotation.PathVariable;
16 13

  
17 14
import java.io.BufferedReader;
18 15
import java.io.IOException;
......
34 31

  
35 32
        if( datasource.equals(null))
36 33
            return null;
37
        
38
        repository.setActivationId(datasource.get("activationId").toString());
39
        repository.setAggregator(datasource.get("aggregator").toString());
40
//        repository.setCertificates(datasource.get("certificates").toString());
41
//        repository.setCitationGuidelineUrl(datasource.get("citationguidelineurl").toString());
42
        repository.setCollectedFrom( datasource.get("collectedfrom").toString());
43 34

  
44
        repository.setContactEmail(datasource.get("contactemail").toString());
45
        if(repository.getContactEmail().equals("null"))
46
            repository.setContactEmail("");
35
        repository.setId(datasource.get("id").toString());
36
        repository.setOfficialName(datasource.get("officialname").toString());
47 37

  
48
//        repository.setDatabaseAccessRestriction(datasource.get("databaseaccessrestriction").toString());
49
//        repository.setDatabaseAccessType(datasource.get("databaseaccesstype").toString());
50
//        repository.setDataUploadRestriction(datasource.get("datauploadrestriction").toString());
51
//        repository.setDataUploadType(datasource.get("datauploadtype").toString());
52
        repository.setDateOfCollection(convertStringToDate( datasource.get("dateofcollection").toString()));
53
        repository.setDateOfValidation(convertStringToDate( datasource.get("dateofvalidation").toString()));
54

  
55
        repository.setDescription(datasource.get("description").toString());
56
        if(repository.getDescription().equals("null"))
57
            repository.setDescription("");
58

  
59
        repository.setEissn(datasource.get("eissn").toString());
60

  
61 38
        repository.setEnglishName( datasource.get("englishname").toString());
62 39
        if(repository.getEnglishName().equals("null"))
63 40
            repository.setEnglishName("");
64 41

  
65

  
66
        repository.setId(datasource.get("id").toString());
67
        repository.setIssn(datasource.get("issn").toString());
68
        repository.setOdLanguages(datasource.get("languages").toString());
69
        repository.setLatitude( toDouble(datasource.get("latitude").toString()));
70
        repository.setLissn(datasource.get("lissn").toString());
71

  
42
        repository.setWebsiteUrl(datasource.get("websiteurl").toString());
72 43
        repository.setLogoUrl(datasource.get("logourl").toString());
73 44
        if(repository.getLogoUrl().equals("null"))
74 45
            repository.setLogoUrl("");
75 46

  
47
        repository.setContactEmail(datasource.get("contactemail").toString());
48
        repository.setLatitude( toDouble(datasource.get("latitude").toString()));
76 49
        repository.setLongitude(toDouble(datasource.get("longitude").toString()));
77
        //datasource.get("managed");
78
//        repository.setMissionStatementUrl(datasource.get("missionstatementurl").toString());
50
        Double timezone = toDouble(datasource.get("timezone").toString());
51
        repository.setTimezone(timezone!=null?timezone:0.0);
79 52
        repository.setNamespacePrefix(datasource.get("namespaceprefix").toString());
80
//        repository.setOdContentTypes(datasource.get("od_contenttypes").toString());
81
        repository.setOfficialName(datasource.get("officialname").toString());
82
        if(repository.getOfficialName().equals("null"))
83
            repository.setOfficialName("");
53
        repository.setOdLanguages(datasource.get("languages").toString());
54
        repository.setDateOfValidation(convertStringToDate( datasource.get("dateofvalidation").toString()));
84 55

  
85
//        repository.setPidSystems(datasource.get("pidsystems").toString());
86
        //datasource.get("platform");
87
//        repository.setProvenanceActionClass( datasource.get("provenanceaction").toString());
88
//        repository.setQualityManagementKind(datasource.get("qualitymanagementkind").toString());
56
        /*  typology -> platform
57
         *  datasource class -> typology */
58
        repository.setTypology(datasource.get("platform").toString());
59
        if(repository.getTypology().equals("null"))
60
            repository.setTypology("");
61
        repository.setDatasourceClass(datasource.get("typology").toString());
62

  
63
        repository.setDateOfCollection(convertStringToDate( datasource.get("dateofcollection").toString()));
64
        repository.setActivationId(datasource.get("activationId").toString());
65

  
66
        repository.setDescription(datasource.get("description").toString());
67
        if(repository.getDescription().equals("null"))
68
            repository.setDescription("");
69

  
70
        repository.setIssn(datasource.get("issn").toString());
71
        repository.setLissn(datasource.get("lissn").toString());
72
        repository.setEissn(datasource.get("eissn").toString());
89 73
        repository.setRegisteredBy(datasource.get("registeredby").toString());
90 74

  
91
        if(Objects.equals(repository.getRegisteredBy(),"null"))
92
            repository.setRegistered(true);
75
        /* managed field */
76
        repository.setRegistered(Boolean.parseBoolean(datasource.get("managed").toString()));
93 77

  
94
//        repository.setReleaseEndDate(convertStringToDate(datasource.get("releaseenddate").toString()));
95
//        repository.setReleaseStartDate(convertStringToDate(datasource.get("releasestartdate").toString()));
96
//        repository.setServiceProvider(Boolean.valueOf(datasource.get("serviceprovider").toString()));
97
        //datasource.get("subjects");
98
        Double timezone = toDouble(datasource.get("timezone").toString());
99
        repository.setTimezone(timezone!=null?timezone:0.0);
100
        repository.setTypology(datasource.get("platform").toString());
101
//        repository.setVersioning(Boolean.valueOf(datasource.get("versioning").toString()));
102
        repository.setWebsiteUrl(datasource.get("websiteurl").toString());
103
        repository.setDatasourceClass(datasource.get("typology").toString());
78
        //subjects
79
        repository.setAggregator(datasource.get("aggregator").toString());
104 80

  
105
        //TODO change organization to list
106
        JSONArray organizations = ((JSONArray)datasource.get("organizations"));
107
        if(organizations.length() != 0) {
108
            repository.setOrganization(((JSONArray) datasource.get("organizations")).getJSONObject(0).get("legalname").toString());
109
            String countryCode = ((JSONArray) datasource.get("organizations")).getJSONObject(0).get("country").toString();
110
            repository.setCountryCode(countryCode);
111
        }
112

  
113
        
114 81
        String collectedFrom = datasource.get("collectedfrom").toString();
115 82
        //TODO check data consistency
116 83
        String type = "UNKNOWN";
......
121 88
        } else if (collectedFrom.equalsIgnoreCase("infrastruct_::openaire")) {
122 89
            type = "journal";
123 90
        }
91
        /* collected from field  */
124 92
        repository.setDatasourceType(type);
93
        repository.setCollectedFrom(collectedFrom);
94

  
95
        //TODO change organization to list
96
        JSONArray organizations = ((JSONArray)datasource.get("organizations"));
97
        if(organizations.length() != 0) {
98
            repository.setOrganization(((JSONArray) datasource.get("organizations")).getJSONObject(0).get("legalname").toString());
99
            String countryCode = ((JSONArray) datasource.get("organizations")).getJSONObject(0).get("country").toString();
100
            repository.setCountryCode(countryCode);
101
        }
102

  
103
        /* identities field  */
104

  
125 105
        return repository;
126 106
    }
127 107

  
......
177 157

  
178 158
        RepositoryInterface repositoryInterface = new RepositoryInterface();
179 159

  
180
        repositoryInterface.setBaseUrl(repositoryInterfaceObject.get("baseurl").toString());
181
        repositoryInterface.setContentDescription(repositoryInterfaceObject.get("contentdescription").toString());
182 160
        repositoryInterface.setId(repositoryInterfaceObject.get("id").toString());
183
       // repositoryInterface.setMetadataIdentifierPath(repositoryInterfaceObject.get("metadataIdentifierPath").toString());
184 161
        repositoryInterface.setAccessProtocol(repositoryInterfaceObject.get("protocol").toString());
162
        repositoryInterface.setContentDescription(repositoryInterfaceObject.get("contentdescription").toString());
185 163
        repositoryInterface.setTypology(repositoryInterfaceObject.get("typology").toString());
186
        repositoryInterface.setDesiredCompatibilityLevel(repositoryInterfaceObject.get("compatibility").toString());
187
        //repositoryInterface.setActive(Boolean.parseBoolean(repositoryInterfaceObject.get("active").toString()));
188
        repositoryInterface.setRemovable(Boolean.parseBoolean(repositoryInterfaceObject.get("removable").toString()));
189 164
        repositoryInterface.setCompliance(repositoryInterfaceObject.get("compatibility").toString());
190 165
        repositoryInterface.setLastCollectionDate(repositoryInterfaceObject.get("lastCollectionDate").toString());
191 166

  
167
        repositoryInterface.setBaseUrl(repositoryInterfaceObject.get("baseurl").toString());
168
        repositoryInterface.setRemovable(Boolean.parseBoolean(repositoryInterfaceObject.get("removable").toString()));
192 169

  
170

  
171
       // repositoryInterface.setMetadataIdentifierPath(repositoryInterfaceObject.get("metadataIdentifierPath").toString());
172
        repositoryInterface.setDesiredCompatibilityLevel(repositoryInterfaceObject.get("compatibility").toString());
173
        //repositoryInterface.setActive(Boolean.parseBoolean(repositoryInterfaceObject.get("active").toString()));
174

  
175

  
193 176
        Map<String, String> accessParams = new HashMap<>();
194 177
        Map<String, String> extraFields = new HashMap<>();
195 178

  
......
199 182
        for(int i=0;i<apiparams.length();i++)
200 183
            accessParams.put(apiparams.getJSONObject(i).getString("param"),apiparams.getJSONObject(i).getString("value"));
201 184

  
185
        repositoryInterface.setAccessParams(accessParams);
186

  
202 187
        return repositoryInterface;
203 188
    }
204 189

  
......
219 204
        jsonObject.put("namespaceprefix",repository.getNamespacePrefix());
220 205
        jsonObject.put("languages",repository.getOdLanguages());
221 206
        jsonObject.put("dateofvalidation",convertDateToString(repository.getDateOfValidation()));
222
        jsonObject.put("typology",repository.getTypology());
207

  
208
        /*
209
        * typology -> platform
210
        * datasource class -> typology
211
        * */
212
        jsonObject.put("typology",repository.getDatasourceClass());
213
        jsonObject.put("platform",repository.getTypology());
214

  
223 215
        jsonObject.put("dateofcollection",convertDateToString(repository.getDateOfCollection()));
224
//        jsonObject.put("platform",repository.getPlatform());
225 216
        jsonObject.put("activationId",repository.getActivationId());
226 217
        jsonObject.put("description",repository.getDescription());
227 218
        jsonObject.put("eissn",repository.getEissn());
228 219
        jsonObject.put("issn",repository.getIssn());
229 220
        jsonObject.put("lissn",repository.getLissn());
230 221
        jsonObject.put("registeredby",repository.getRegisteredBy());
231
//        jsonObject.put("subjects",repository.getSubjects());
222

  
232 223
        jsonObject.put("aggregator",repository.getAggregator());
233 224
        jsonObject.put("collectedfrom",repository.getCollectedFrom());
234
//        jsonObject.put("managed",repository.getIsManaged());
235 225

  
236
//        jsonObject.put("organizations",repository.getOrganization());
237
//        for(repository.getOrganization())
226
        jsonObject.put("managed",repository.isRegistered());
238 227

  
228
        JSONObject organization = new JSONObject();
229
        organization.put("legalname",repository.getOrganization());
230
        organization.put("country",repository.getCountryCode());
231
        organization.put("legalshortname","");
232
        organization.put("websiteurl","");
233
        organization.put("logourl","");
234

  
235
        JSONArray organizations = new JSONArray();
236
        organizations.put(organization);
237
        jsonObject.put("organizations",organizations);
238

  
239

  
240

  
241

  
239 242
        //TODO check fields
240 243
       /* jsonObject.put("certificates",repository.getCertificates());
241 244
        jsonObject.put("citationguidelineurl",repository.getCitationGuidelineUrl());
......
262 265

  
263 266
        JSONObject jsonObject = new JSONObject();
264 267

  
265
        jsonObject.put("baseurl",repositoryInterface.getBaseUrl());
266
        jsonObject.put("contentdescription",repositoryInterface.getContentDescription());
267 268
        jsonObject.put("id",repositoryInterface.getId());
268
        jsonObject.put("metadataIdentifierPath",repositoryInterface.getMetadataIdentifierPath());
269 269
        jsonObject.put("protocol",repositoryInterface.getAccessProtocol());
270
        jsonObject.put("datasource",repository.getId());
271
        jsonObject.put("contentdescription",repositoryInterface.getContentDescription());
270 272
        jsonObject.put("typology",repositoryInterface.getTypology());
271 273
        jsonObject.put("compatibility",repositoryInterface.getDesiredCompatibilityLevel());
272
        jsonObject.put("datasource",repository.getId());
273
        jsonObject.put("metadataIdentifierPath",repositoryInterface.getMetadataIdentifierPath());
274
        jsonObject.put("protocol",repositoryInterface.getAccessProtocol());
274
        jsonObject.put("compatibilityOverride",repositoryInterface.getDesiredCompatibilityLevel());
275

  
276
        jsonObject.put("lastCollectionTotal","");
277

  
278
        jsonObject.put("lastCollectionDate",repositoryInterface.getLastCollectionDate());
279
        jsonObject.put("lastAggregationTotal","");
280
        jsonObject.put("lastAggregationDate","");
281
        jsonObject.put("lastDownloadTotal","");
282
        jsonObject.put("lastDownloadDate","");
283

  
284
        jsonObject.put("baseurl",repositoryInterface.getBaseUrl());
275 285
        jsonObject.put("removable",repositoryInterface.isRemovable());
276
        jsonObject.put("active",repositoryInterface.isActive());
277 286

  
278

  
287
        
279 288
        JSONArray apiparams = new JSONArray();
280 289
        for(String param: repositoryInterface.getAccessParams().keySet()){
281 290
            JSONObject jo = new JSONObject();
......
283 292
            jo.put("value",repositoryInterface.getAccessParams().get(param));
284 293
            apiparams.put(jo);
285 294
        }
286
        jsonObject.put("apiparam",apiparams);
295
        jsonObject.put("apiParams",apiparams);
287 296

  
288 297

  
289
        jsonObject.put("lastCollectionDate",repositoryInterface.getLastCollectionDate());
290
        //jsonObject.put("lastCollectionMdid",repositoryInterface);
291
        //jsonObject.put("lastCollectionTotal");
292
        //jsonObject.put("lastDownloadDate");
293
//        jsonObject.put("lastDownloadMdid");
294
//        jsonObject.put("lastDownloadTotal");
295
//        jsonObject.put("lastValidationJob");
296
        //jsonObject.put("lastAggregationDate");
297
        //jsonObject.put("lastAggregationMdid");
298
        //jsonObject.put("lastAggregationTotal");
298
//        jsonObject.put("metadataIdentifierPath",repositoryInterface.getMetadataIdentifierPath());
299 299

  
300

  
300 301
        return jsonObject.toString();
301 302
    }
302 303

  

Also available in: Unified diff