forked from D-Net/dnet-hadoop
added alternateIdentifiers to oaf
This commit is contained in:
parent
2f5caef77b
commit
7f9636ef00
|
@ -28,6 +28,11 @@ case class RelatedIdentifierType(
|
||||||
relatedIdentifierType: String
|
relatedIdentifierType: String
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
|
case class IdentifierType(
|
||||||
|
identifier: String,
|
||||||
|
identifierType: String
|
||||||
|
) {}
|
||||||
|
|
||||||
case class NameIdentifiersType(
|
case class NameIdentifiersType(
|
||||||
nameIdentifierScheme: Option[String],
|
nameIdentifierScheme: Option[String],
|
||||||
schemeUri: Option[String],
|
schemeUri: Option[String],
|
||||||
|
|
|
@ -37,7 +37,7 @@ object BioschemaToOAFTransformation {
|
||||||
val PEDCollectedFrom: KeyValue = OafMapperUtils.keyValue(
|
val PEDCollectedFrom: KeyValue = OafMapperUtils.keyValue(
|
||||||
//TODO create pedDatasourceId and update this value
|
//TODO create pedDatasourceId and update this value
|
||||||
"10|ped_________::pedDatasourceId",
|
"10|ped_________::pedDatasourceId",
|
||||||
"PED"
|
"Protein Ensemble Database"
|
||||||
)
|
)
|
||||||
PEDCollectedFrom.setDataInfo(DATA_INFO)
|
PEDCollectedFrom.setDataInfo(DATA_INFO)
|
||||||
|
|
||||||
|
@ -254,19 +254,8 @@ object BioschemaToOAFTransformation {
|
||||||
titles
|
titles
|
||||||
.filter(t => t.title.nonEmpty)
|
.filter(t => t.title.nonEmpty)
|
||||||
.map(t => {
|
.map(t => {
|
||||||
if (t.titleType.isEmpty) {
|
|
||||||
OafMapperUtils
|
OafMapperUtils
|
||||||
.structuredProperty(t.title.get, ModelConstants.MAIN_TITLE_QUALIFIER, null)
|
.structuredProperty(t.title.get, ModelConstants.MAIN_TITLE_QUALIFIER, dataInfo)
|
||||||
} else {
|
|
||||||
OafMapperUtils.structuredProperty(
|
|
||||||
t.title.get,
|
|
||||||
t.titleType.get,
|
|
||||||
t.titleType.get,
|
|
||||||
ModelConstants.DNET_DATACITE_TITLE,
|
|
||||||
ModelConstants.DNET_DATACITE_TITLE,
|
|
||||||
null
|
|
||||||
)
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.asJava
|
.asJava
|
||||||
)
|
)
|
||||||
|
@ -339,8 +328,20 @@ object BioschemaToOAFTransformation {
|
||||||
|
|
||||||
val instance = result.getInstance().get(0)
|
val instance = result.getInstance().get(0)
|
||||||
|
|
||||||
|
val ids: List[IdentifierType] = for {
|
||||||
|
JObject(identifiers) <- json \\ "identifiers"
|
||||||
|
JField("identifier", JString(identifier)) <- identifiers
|
||||||
|
JField("identifierType", JString(identifierType)) <- identifiers
|
||||||
|
} yield IdentifierType(identifier, identifierType)
|
||||||
|
|
||||||
|
instance.setUrl(
|
||||||
|
ids
|
||||||
|
.map(id => {
|
||||||
|
id.identifier
|
||||||
|
})
|
||||||
|
.asJava
|
||||||
|
)
|
||||||
instance.setCollectedfrom(collectedFromMap("ped"))
|
instance.setCollectedfrom(collectedFromMap("ped"))
|
||||||
instance.setUrl(List(s"https://proteinensemble.org/$pid").asJava)
|
|
||||||
instance.setPid(result.getPid)
|
instance.setPid(result.getPid)
|
||||||
|
|
||||||
result.setId(IdentifierFactory.createIdentifier(result))
|
result.setId(IdentifierFactory.createIdentifier(result))
|
||||||
|
@ -349,6 +350,33 @@ object BioschemaToOAFTransformation {
|
||||||
if (result.getId == null)
|
if (result.getId == null)
|
||||||
return List()
|
return List()
|
||||||
|
|
||||||
|
val alternativeIdentifierUrls: List[String] = for {
|
||||||
|
JObject(alternateIdentifiers) <- json \\ "alternateIdentifiers"
|
||||||
|
JField("alternateIdentifier", JString(alternateIdentifier)) <- alternateIdentifiers
|
||||||
|
foundResolvedURLId = resolvedURL
|
||||||
|
.map(k => {
|
||||||
|
if (alternateIdentifier.contains(s"${k._1}:"))
|
||||||
|
k._1
|
||||||
|
else
|
||||||
|
null
|
||||||
|
})
|
||||||
|
.find(s => s != null)
|
||||||
|
alternativeIdentifierUrl = StringUtils.substringAfter(alternateIdentifier, s"${foundResolvedURLId.get}:")
|
||||||
|
} yield alternativeIdentifierUrl
|
||||||
|
|
||||||
|
alternativeIdentifierUrls.map(id => {
|
||||||
|
var alternateIdentifier: StructuredProperty = null
|
||||||
|
alternateIdentifier = OafMapperUtils.structuredProperty(
|
||||||
|
id,
|
||||||
|
"uniprot",
|
||||||
|
"uniprot",
|
||||||
|
ModelConstants.DNET_PID_TYPES,
|
||||||
|
ModelConstants.DNET_PID_TYPES,
|
||||||
|
dataInfo
|
||||||
|
)
|
||||||
|
instance.setAlternateIdentifier(List(alternateIdentifier).asJava)
|
||||||
|
})
|
||||||
|
|
||||||
if (exportLinks) {
|
if (exportLinks) {
|
||||||
val rels: List[RelatedIdentifierType] = for {
|
val rels: List[RelatedIdentifierType] = for {
|
||||||
JObject(relIdentifier) <- json \\ "relatedIdentifiers"
|
JObject(relIdentifier) <- json \\ "relatedIdentifiers"
|
||||||
|
@ -364,18 +392,6 @@ object BioschemaToOAFTransformation {
|
||||||
pid
|
pid
|
||||||
)
|
)
|
||||||
|
|
||||||
val identifiers: List[RelatedIdentifierType] = for {
|
|
||||||
JObject(alternateIdentifier) <- json \\ "alternateIdentifiers"
|
|
||||||
JField("alternateIdentifier", JString(alternateIdentifierValue)) <- alternateIdentifier
|
|
||||||
} yield RelatedIdentifierType("IsIdenticalTo", alternateIdentifierValue, "URL")
|
|
||||||
|
|
||||||
relations = relations ::: generateRelations(
|
|
||||||
identifiers,
|
|
||||||
result.getId,
|
|
||||||
if (i_date.isDefined && i_date.get.isDefined) i_date.get.get else null,
|
|
||||||
pid
|
|
||||||
)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
if (relations != null && relations.nonEmpty) {
|
if (relations != null && relations.nonEmpty) {
|
||||||
List(result) ::: relations
|
List(result) ::: relations
|
||||||
|
@ -404,12 +420,14 @@ object BioschemaToOAFTransformation {
|
||||||
|
|
||||||
rel.setProperties(List(dateProps).asJava)
|
rel.setProperties(List(dateProps).asJava)
|
||||||
|
|
||||||
val foundResolvedURLId = resolvedURL.map(k => {
|
val foundResolvedURLId = resolvedURL
|
||||||
|
.map(k => {
|
||||||
if (r.relatedIdentifier.contains(s"${k._1}:"))
|
if (r.relatedIdentifier.contains(s"${k._1}:"))
|
||||||
k._1
|
k._1
|
||||||
else
|
else
|
||||||
null
|
null
|
||||||
}).find(s => s != null);
|
})
|
||||||
|
.find(s => s != null);
|
||||||
if (foundResolvedURLId.nonEmpty) {
|
if (foundResolvedURLId.nonEmpty) {
|
||||||
val relatedId = StringUtils.substringAfter(r.relatedIdentifier, s"${foundResolvedURLId.get}:")
|
val relatedId = StringUtils.substringAfter(r.relatedIdentifier, s"${foundResolvedURLId.get}:")
|
||||||
rel.setTarget(s"${resolvedURL(foundResolvedURLId.get)}${relatedId}")
|
rel.setTarget(s"${resolvedURL(foundResolvedURLId.get)}${relatedId}")
|
||||||
|
|
Loading…
Reference in New Issue