Project

General

Profile

« Previous | Next » 

Revision 50093

added transient openaire id to the datasource entity

View differences:

modules/dnet-openaire-exporter/trunk/src/main/java/eu/dnetlib/openaire/exporter/model/datasource/db/Datasource.java
24 24

  
25 25
	@Id
26 26
	private String id = null;
27

  
28
	@Transient
29
	private String openaireId = null;
30

  
27 31
	private String officialname = null;
28 32
	private String englishname = null;
29 33
	private String websiteurl = null;
......
79 83

  
80 84
	private Boolean managed;
81 85

  
82
	/*
83
	@JsonIgnore
84
	@OneToMany(mappedBy = "datasource", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
85
	private Set<Api> api = null;
86
	*/
87

  
88 86
	@ManyToMany(cascade = { CascadeType.PERSIST, CascadeType.MERGE }, fetch = FetchType.LAZY)
89 87
	@JoinTable(
90 88
			name = "dsm_datasource_organization",
......
280 278
		return this;
281 279
	}
282 280

  
281
	public Datasource setOpenaireId(final String openaireId) {
282
		this.openaireId = openaireId;
283
		return this;
284
	}
285

  
283 286
	public Datasource setOfficialname(final String officialname) {
284 287
		this.officialname = officialname;
285 288
		return this;
......
490 493
		return this;
491 494
	}
492 495

  
496
	public String getOpenaireId() {
497
		return openaireId;
498
	}
493 499
}
494 500

  
modules/dnet-openaire-exporter/trunk/src/main/java/eu/dnetlib/openaire/exporter/datasource/clients/DatasourceDao.java
10 10
import com.google.common.collect.Lists;
11 11
import com.google.common.util.concurrent.*;
12 12
import eu.dnetlib.OpenaireExporterConfig;
13
import eu.dnetlib.data.transform.xml.AbstractDNetXsltFunctions;
13 14
import eu.dnetlib.openaire.exporter.datasource.ApiException;
14 15
import eu.dnetlib.openaire.exporter.datasource.clients.utils.IndexDsInfo;
15 16
import eu.dnetlib.openaire.exporter.datasource.clients.utils.IndexRecordsInfo;
......
37 38
public class DatasourceDao {
38 39

  
39 40
	private static final Log log = LogFactory.getLog(DatasourceDao.class);
41
	public static final String ID_SEPARATOR = "::";
40 42

  
41 43
	@Autowired
42 44
	private OpenaireExporterConfig config;
......
184 186
				} else {
185 187
					datasources.forEach(d -> {
186 188
						final DatasourceResponse response = new DatasourceResponse();
187
						response.setDatasource(d);
189
						response.setDatasource(d.setOpenaireId(asOpenaireId(d.getId())));
188 190
						getAggregationHistory(d.getId(), outerLatch, errors, response);
189 191
						getIndexDsInfo(d.getId(), outerLatch, errors, response);
190 192
						datasourceResponse.add(response);
......
193 195
				}
194 196
			}
195 197

  
198
			private String asOpenaireId(final String id) {
199
				final String prefix = StringUtils.substringBefore(id, ID_SEPARATOR);
200
				final String md5 = StringUtils.substringAfter(id, ID_SEPARATOR);
201

  
202
				return prefix + ID_SEPARATOR + AbstractDNetXsltFunctions.md5(md5);
203
			}
204

  
196 205
			@Override
197 206
			public void onFailure(final Throwable e) {
198 207
				errors.offer(e);

Also available in: Unified diff