Revision 54457
Added by Panagiotis Kanakakis over 5 years ago
Converter.java | ||
---|---|---|
1 | 1 |
package eu.dnetlib.repo.manager.service.utils; |
2 | 2 |
|
3 |
import com.fasterxml.jackson.core.JsonProcessingException; |
|
3 | 4 |
import com.fasterxml.jackson.databind.ObjectMapper; |
4 | 5 |
import eu.dnetlib.domain.data.Repository; |
5 | 6 |
import eu.dnetlib.domain.data.RepositoryInterface; |
... | ... | |
222 | 223 |
return repositoryInterface; |
223 | 224 |
} |
224 | 225 |
|
225 |
public static String repositoryObjectToJson(Repository repository) throws JSONException { |
|
226 |
public static String repositoryObjectToJson(Repository repository) throws JSONException, JsonProcessingException {
|
|
226 | 227 |
|
227 | 228 |
JSONObject jsonObject = new JSONObject(); |
228 | 229 |
|
... | ... | |
236 | 237 |
jsonObject.put("longitude",repository.getLongitude().toString()); |
237 | 238 |
jsonObject.put("latitude",repository.getLatitude().toString()); |
238 | 239 |
jsonObject.put("timezone",repository.getTimezone()); |
239 |
// jsonObject.put("namespaceprefix",repository.getNamespacePrefix()); |
|
240 |
// jsonObject.put("languages",repository.getOdLanguages()); |
|
241 |
jsonObject.put("dateofvalidation",convertDateToString(repository.getDateOfValidation())); |
|
242 | 240 |
|
241 |
jsonObject.put("namespaceprefix",repository.getNamespacePrefix()!=null?repository.getNamespacePrefix():""); |
|
242 |
jsonObject.put("languages",repository.getOdLanguages()!=null?repository.getOdLanguages():""); |
|
243 |
|
|
244 |
jsonObject.put("dateofcollection",repository.getDateOfCollection()!=null?convertDateToString(repository.getDateOfCollection()):""); |
|
245 |
|
|
243 | 246 |
/* |
244 | 247 |
* typology -> platform |
245 | 248 |
* datasource class -> typology |
... | ... | |
247 | 250 |
jsonObject.put("typology",repository.getDatasourceClass()); |
248 | 251 |
jsonObject.put("platform",repository.getTypology()); |
249 | 252 |
|
250 |
// jsonObject.put("dateofcollection",convertDateToString(repository.getDateOfCollection())); |
|
251 |
// jsonObject.put("activationId",repository.getActivationId()); |
|
253 |
jsonObject.put("dateofvalidation",repository.getDateOfCollection()!=null?convertDateToString(repository.getDateOfCollection()):""); |
|
254 |
jsonObject.put("activationId",repository.getActivationId()!=null?repository.getActivationId():""); |
|
255 |
|
|
252 | 256 |
jsonObject.put("description",repository.getDescription()); |
253 |
// jsonObject.put("eissn",repository.getEissn()); |
|
254 |
// jsonObject.put("issn",repository.getIssn()); |
|
255 |
// jsonObject.put("lissn",repository.getLissn()); |
|
257 |
|
|
258 |
jsonObject.put("eissn",repository.getEissn()!=null?repository.getEissn():""); |
|
259 |
jsonObject.put("issn",repository.getIssn()!=null?repository.getIssn():""); |
|
260 |
jsonObject.put("lissn",repository.getLissn()!=null?repository.getLissn():""); |
|
261 |
|
|
256 | 262 |
jsonObject.put("registeredby",repository.getRegisteredBy()); |
257 | 263 |
|
258 |
// jsonObject.put("aggregator",repository.getAggregator());
|
|
259 |
// jsonObject.put("collectedfrom",repository.getCollectedFrom());
|
|
264 |
jsonObject.put("aggregator",repository.getAggregator()!=null?repository.getAggregator():"");
|
|
265 |
jsonObject.put("collectedfrom",repository.getCollectedFrom()!=null?repository.getCollectedFrom():"");
|
|
260 | 266 |
|
261 | 267 |
jsonObject.put("managed",repository.isRegistered()); |
262 | 268 |
|
... | ... | |
269 | 275 |
|
270 | 276 |
JSONArray organizations = new JSONArray(); |
271 | 277 |
organizations.put(organization); |
272 |
// jsonObject.put("organizations",organizations);
|
|
278 |
jsonObject.put("organizations",organizations); |
|
273 | 279 |
|
280 |
//TODO check identitites |
|
281 |
JSONArray identities = new JSONArray(); |
|
282 |
identities.put(identities); |
|
283 |
jsonObject.put("identities",identities); |
|
274 | 284 |
|
275 | 285 |
|
276 | 286 |
|
... | ... | |
293 | 303 |
jsonObject.put("versioning",repository.getVersioning()); |
294 | 304 |
//datasource.get("platform"); |
295 | 305 |
//datasource.get("subjects");*/ |
296 |
return jsonObject.toString(); |
|
306 |
|
|
307 |
ObjectMapper mapper = new ObjectMapper(); |
|
308 |
return mapper.writeValueAsString(jsonObject); |
|
297 | 309 |
} |
298 | 310 |
|
299 | 311 |
public static String repositoryInterfaceObjectToJson(Repository repository,RepositoryInterface repositoryInterface) throws JSONException { |
Also available in: Unified diff
Fixes on converter