forked from D-Net/dnet-hadoop
fixed mapping for datasource journal info (ISSNs)
This commit is contained in:
parent
2e9e13444d
commit
c2a6e2a9bf
|
@ -38,13 +38,11 @@ import java.io.IOException;
|
||||||
import java.sql.Array;
|
import java.sql.Array;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
@ -197,7 +195,11 @@ public class MigrateDbEntitiesApplication extends AbstractMigrationApplication i
|
||||||
final Datasource ds = new Datasource();
|
final Datasource ds = new Datasource();
|
||||||
|
|
||||||
ds.setId(createOpenaireId(10, rs.getString("datasourceid"), true));
|
ds.setId(createOpenaireId(10, rs.getString("datasourceid"), true));
|
||||||
ds.setOriginalId(Arrays.asList((String[]) rs.getArray("identities").getArray()));
|
ds.setOriginalId(Arrays.asList(
|
||||||
|
(String[]) rs.getArray("identities").getArray())
|
||||||
|
.stream()
|
||||||
|
.filter(StringUtils::isNotBlank)
|
||||||
|
.collect(Collectors.toList()));
|
||||||
ds
|
ds
|
||||||
.setCollectedfrom(
|
.setCollectedfrom(
|
||||||
listKeyValues(
|
listKeyValues(
|
||||||
|
@ -242,8 +244,13 @@ public class MigrateDbEntitiesApplication extends AbstractMigrationApplication i
|
||||||
ds.setPidsystems(field(rs.getString("pidsystems"), info));
|
ds.setPidsystems(field(rs.getString("pidsystems"), info));
|
||||||
ds.setCertificates(field(rs.getString("certificates"), info));
|
ds.setCertificates(field(rs.getString("certificates"), info));
|
||||||
ds.setPolicies(new ArrayList<>()); // The sql query returns an empty array
|
ds.setPolicies(new ArrayList<>()); // The sql query returns an empty array
|
||||||
ds
|
ds.setJournal(
|
||||||
.setJournal(prepareJournal(rs.getString("officialname"), rs.getString("journal"), info)); // Journal
|
journal(
|
||||||
|
rs.getString("officialname"),
|
||||||
|
rs.getString("issnPrinted"),
|
||||||
|
rs.getString("issnOnline"),
|
||||||
|
rs.getString("issnLinking"),
|
||||||
|
info)); // Journal
|
||||||
ds.setDataInfo(info);
|
ds.setDataInfo(info);
|
||||||
ds.setLastupdatetimestamp(lastUpdateTimestamp);
|
ds.setLastupdatetimestamp(lastUpdateTimestamp);
|
||||||
|
|
||||||
|
@ -567,21 +574,13 @@ public class MigrateDbEntitiesApplication extends AbstractMigrationApplication i
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Journal prepareJournal(final String name, final String sj, final DataInfo info) {
|
private Journal prepareJournal(final ResultSet rs, final DataInfo info) throws SQLException {
|
||||||
if (StringUtils.isNotBlank(sj)) {
|
if (Objects.isNull(rs)) {
|
||||||
final String[] arr = sj.split("@@@");
|
return null;
|
||||||
if (arr.length == 3) {
|
} else {
|
||||||
final String issn = StringUtils.isNotBlank(arr[0]) ? arr[0].trim() : null;
|
|
||||||
final String eissn = StringUtils.isNotBlank(arr[1]) ? arr[1].trim() : null;
|
|
||||||
|
|
||||||
final String lissn = StringUtils.isNotBlank(arr[2]) ? arr[2].trim() : null;
|
return journal(rs.getString("officialname"), rs.getString("issnPrinted"), rs.getString("issnOnline"), rs.getString("issnLinking"), info);
|
||||||
|
|
||||||
if (issn != null || eissn != null || lissn != null) {
|
|
||||||
return journal(name, issn, eissn, lissn, null, null, null, null, null, null, null, info);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -153,6 +153,27 @@ public class OafMapperUtils {
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Journal journal(
|
||||||
|
final String name,
|
||||||
|
final String issnPrinted,
|
||||||
|
final String issnOnline,
|
||||||
|
final String issnLinking,
|
||||||
|
final DataInfo dataInfo) {
|
||||||
|
return journal(
|
||||||
|
name,
|
||||||
|
issnPrinted,
|
||||||
|
issnOnline,
|
||||||
|
issnLinking,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
dataInfo);
|
||||||
|
}
|
||||||
|
|
||||||
public static Journal journal(
|
public static Journal journal(
|
||||||
final String name,
|
final String name,
|
||||||
final String issnPrinted,
|
final String issnPrinted,
|
||||||
|
|
|
@ -84,8 +84,10 @@ SELECT
|
||||||
dc.id AS collectedfromid,
|
dc.id AS collectedfromid,
|
||||||
dc.officialname AS collectedfromname,
|
dc.officialname AS collectedfromname,
|
||||||
d.typology||'@@@dnet:datasource_typologies' AS datasourcetype,
|
d.typology||'@@@dnet:datasource_typologies' AS datasourcetype,
|
||||||
'sysimport:crosswalk:entityregistry@@@dnet:provenance_actions' AS provenanceaction,
|
'sysimport:crosswalk:entityregistry@@@dnet:provenance_actions' AS provenanceaction,
|
||||||
concat_ws(' @@@ ', d.issn, d.eissn, d.lissn) AS journal
|
d.issn AS issnPrinted,
|
||||||
|
d.eissn AS issnOnline,
|
||||||
|
d.lissn AS issnLinking
|
||||||
|
|
||||||
FROM dsm_datasources d
|
FROM dsm_datasources d
|
||||||
|
|
||||||
|
|
|
@ -80,9 +80,9 @@ public class MigrateDbEntitiesApplicationTest {
|
||||||
assertEquals(getValueAsString("namespaceprefix", fields), ds.getNamespaceprefix().getValue());
|
assertEquals(getValueAsString("namespaceprefix", fields), ds.getNamespaceprefix().getValue());
|
||||||
assertEquals(getValueAsString("collectedfromname", fields), ds.getCollectedfrom().get(0).getValue());
|
assertEquals(getValueAsString("collectedfromname", fields), ds.getCollectedfrom().get(0).getValue());
|
||||||
assertEquals(getValueAsString("officialname", fields), ds.getJournal().getName());
|
assertEquals(getValueAsString("officialname", fields), ds.getJournal().getName());
|
||||||
assertEquals("2579-5449", ds.getJournal().getIssnPrinted());
|
assertEquals(getValueAsString("issnPrinted", fields), ds.getJournal().getIssnPrinted());
|
||||||
assertEquals("2597-6540", ds.getJournal().getIssnOnline());
|
assertEquals(getValueAsString("issnOnline", fields), ds.getJournal().getIssnOnline());
|
||||||
assertEquals(null, ds.getJournal().getIssnLinking());
|
assertEquals(getValueAsString("issnLinking", fields), ds.getJournal().getIssnLinking());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -228,8 +228,18 @@
|
||||||
"value": "sysimport:crosswalk:entityregistry@@@dnet:provenance_actions"
|
"value": "sysimport:crosswalk:entityregistry@@@dnet:provenance_actions"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"field": "journal",
|
"field": "issnPrinted",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"value": "2579-5449 @@@ 2597-6540 @@@ "
|
"value": "2579-5449"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"field": "issnOnline",
|
||||||
|
"type": "string",
|
||||||
|
"value": "2579-5448"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"field": "issnLinking",
|
||||||
|
"type": "string",
|
||||||
|
"value": "2579-5447"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in New Issue