Revision 50278
Added by Michele Artini over 6 years ago
DatasourceFunctions.java | ||
---|---|---|
27 | 27 |
import eu.dnetlib.enabling.datasources.common.Identity; |
28 | 28 |
import eu.dnetlib.enabling.datasources.common.Organization; |
29 | 29 |
import eu.dnetlib.enabling.datasources.common.SearchApisEntry; |
30 |
import eu.dnetlib.enabling.datasources.common.SimpleDatasource; |
|
30 | 31 |
import eu.dnetlib.miscutils.datetime.DateUtils; |
31 | 32 |
|
32 | 33 |
public class DatasourceFunctions { |
... | ... | |
35 | 36 |
|
36 | 37 |
private static final Resource baseDsProfile = new ClassPathResource("/eu/dnetlib/enabling/datasources/templates/datasource_base.xml"); |
37 | 38 |
|
39 |
public static SimpleDatasource mapToSimpleDs(final Map<String, Object> map) { |
|
40 |
final SimpleDatasource ds = new SimpleDatasource(); |
|
41 |
ds.setId(castObject(map.get("id"), String.class)); |
|
42 |
ds.setName(castObject(map.get("name"), String.class)); |
|
43 |
ds.setOrigId(castObject(map.get("id"), String.class)); |
|
44 |
ds.setTypology(castObject(map.get("typology"), String.class)); |
|
45 |
ds.setValid(true); |
|
46 |
try { |
|
47 |
ds.setApis(Arrays.stream((Object[]) castObject(map.get("apis"), Array.class).getArray()) |
|
48 |
.map(Object::toString) |
|
49 |
.collect(Collectors.toSet())); |
|
50 |
} catch (final SQLException e) { |
|
51 |
log.error("Error parsing array (apis)", e); |
|
52 |
throw new RuntimeException("Error parsing array (apis)", e); |
|
53 |
} |
|
54 |
|
|
55 |
return ds; |
|
56 |
} |
|
57 |
|
|
38 | 58 |
public static Datasource<Organization<?>, Identity> mapToDatasource(final Map<String, Object> map) { |
39 | 59 |
final Datasource<Organization<?>, Identity> ds = new Datasource<>(); |
40 | 60 |
ds.setId(castObject(map.get("id"), String.class)); |
... | ... | |
129 | 149 |
a.setRemovable(castObject(map.get("removable"), Boolean.class)); |
130 | 150 |
a.setTypology(castObject(map.get("typology"), String.class)); |
131 | 151 |
a.setCompatibility(castObject(map.get("compatibility"), String.class)); |
152 |
a.setCompatibilityOverrided(castObject(map.get("isCompatibilityOverrided"), Boolean.class)); |
|
132 | 153 |
a.setMetadataIdentifierPath(castObject(map.get("metadataIdentifierPath"), String.class)); |
133 | 154 |
a.setLastCollectionTotal(castObject(map.get("lastCollectionTotal"), Integer.class)); |
134 | 155 |
a.setLastCollectionDate(castObject(map.get("lastCollectionDate"), Date.class)); |
... | ... | |
212 | 233 |
|
213 | 234 |
ifc.addElement("BASE_URL").setText(api.getBaseurl()); |
214 | 235 |
|
215 |
// addInterfaceExtraField(ifc, "overriding_compliance", ); |
|
236 |
if (api.isCompatibilityOverrided()) { |
|
237 |
addInterfaceExtraField(ifc, "overriding_compliance", true); |
|
238 |
} |
|
216 | 239 |
|
217 | 240 |
addInterfaceExtraField(ifc, "metadata_identifier_path", api.getMetadataIdentifierPath()); |
218 | 241 |
addInterfaceExtraField(ifc, "last_collection_date", api.getLastCollectionDate()); |
Also available in: Unified diff
added some methods for repo UI