1
0
Fork 0

code formatting

This commit is contained in:
Claudio Atzori 2022-07-29 11:56:01 +02:00
parent 0727f0ef48
commit f62c4e05cd
6 changed files with 53 additions and 72 deletions

View File

@ -255,7 +255,6 @@ public class PMArticle implements Serializable {
return grants;
}
public String getPmcId() {
return pmcId;
}

View File

@ -56,13 +56,11 @@ object PubMedToOaf {
null
}
def createOriginalOpenaireId(article: PMArticle): String = {
if (StringUtils.isNotEmpty(article.getPmcId)) {
val md5 = DHPUtils.md5(s"$OAI_HEADER${article.getPmcId.replace("PMC", "")}")
s"$OLD_PMC_PREFIX$md5"
}
else
} else
null
}
@ -150,9 +148,7 @@ object PubMedToOaf {
dataInfo
)
if (StringUtils.isNotBlank(article.getPmcId))
{
if (StringUtils.isNotBlank(article.getPmcId)) {
pidList += OafMapperUtils.structuredProperty(
article.getPmcId,
PidType.pmc.toString,

View File

@ -48,9 +48,6 @@ class DataciteToOAFTest extends AbstractVocabularyTest {
}
@Test
def testConvert(): Unit = {
@ -76,11 +73,8 @@ class DataciteToOAFTest extends AbstractVocabularyTest {
assertEquals(100, nativeSize)
val result: Dataset[String] = spark.read.text(targetPath).as[String].map(DataciteUtilityTest.convertToOAF)(Encoders.STRING)
val result: Dataset[String] =
spark.read.text(targetPath).as[String].map(DataciteUtilityTest.convertToOAF)(Encoders.STRING)
result
.groupBy(col("value").alias("class"))

View File

@ -10,7 +10,6 @@ object DataciteUtilityTest {
implicit lazy val formats: DefaultFormats.type = org.json4s.DefaultFormats
lazy val json = parse(input)
val isRelation: String = (json \\ "source").extractOrElse("NULL")
if (isRelation != "NULL") {

View File

@ -76,7 +76,6 @@ class BioScholixTest extends AbstractVocabularyTest {
}
private def checkPMArticle(article: PMArticle): Unit = {
assertNotNull(article.getPmid)
assertNotNull(article.getTitle)
@ -90,12 +89,13 @@ class BioScholixTest extends AbstractVocabularyTest {
@Test
def testParsingPubmedXML(): Unit = {
val xml = new XMLEventReader(Source.fromInputStream(getClass.getResourceAsStream("/eu/dnetlib/dhp/sx/graph/bio/pubmed.xml")))
val xml = new XMLEventReader(
Source.fromInputStream(getClass.getResourceAsStream("/eu/dnetlib/dhp/sx/graph/bio/pubmed.xml"))
)
val parser = new PMParser(xml)
parser.foreach(checkPMArticle)
}
private def checkPubmedPublication(o: Oaf): Unit = {
assertTrue(o.isInstanceOf[Publication])
val p: Publication = o.asInstanceOf[Publication]
@ -112,22 +112,20 @@ class BioScholixTest extends AbstractVocabularyTest {
assertNotNull(p.getOriginalId)
p.getOriginalId.asScala.foreach(oId => assertNotNull(oId))
val hasPMC = p.getInstance().asScala.exists(i => i.getPid.asScala.exists(pid => pid.getQualifier.getClassid.equalsIgnoreCase(PidType.pmc.toString)))
val hasPMC = p
.getInstance()
.asScala
.exists(i => i.getPid.asScala.exists(pid => pid.getQualifier.getClassid.equalsIgnoreCase(PidType.pmc.toString)))
if (hasPMC) {
assertTrue(p.getOriginalId.asScala.exists(oId => oId.startsWith("od_______267::")))
}
}
@Test
def testPubmedOriginalID(): Unit = {
val article: PMArticle = new PMArticle
article.setPmid("1234")
article.setTitle("a Title")
@ -146,7 +144,6 @@ class BioScholixTest extends AbstractVocabularyTest {
// VERIFY ORIGINAL ID GENERATE IN OLD WAY USING PMC IDENTIFIER EXISTS
val oldOpenaireID = "od_______267::0000072375bc0e68fa09d4e6b7658248"
val hasOldOpenAIREID = publication.getOriginalId.asScala.exists(o => o.equalsIgnoreCase(oldOpenaireID))
@ -154,22 +151,18 @@ class BioScholixTest extends AbstractVocabularyTest {
assertTrue(hasOldOpenAIREID)
}
@Test
def testPubmedMapping(): Unit = {
val xml = new XMLEventReader(Source.fromInputStream(getClass.getResourceAsStream("/eu/dnetlib/dhp/sx/graph/bio/pubmed.xml")))
val xml = new XMLEventReader(
Source.fromInputStream(getClass.getResourceAsStream("/eu/dnetlib/dhp/sx/graph/bio/pubmed.xml"))
)
val parser = new PMParser(xml)
val results = ListBuffer[Oaf]()
parser.foreach(x => results += PubMedToOaf.convert(x, vocabularies))
results.foreach(checkPubmedPublication)
}
@Test