2017-12-19 13:53:46 +01:00
export class ParsingFunctions {
constructor ( ) { }
public ngOnDestroy() { }
public parseFundingByProjects ( fundedByProjects : { "id" : string , "acronym" : string , "title" : string ,
"funderShortname" : string , "funderName" : string ,
"funding" : string , "code" : string ,
"provenanceAction" : string , "inline" : boolean
} [ ] ,
relation : any , projectsProvenanceVocabulary : any ) :
{ "id" : string , "acronym" : string , "title" : string ,
"funderShortname" : string , "funderName" : string ,
"funding" : string , "code" : string ,
"provenanceAction" : string , "inline" : boolean
} [ ] {
if ( fundedByProjects == undefined ) {
fundedByProjects = new Array < { "id" : string , "acronym" : string , "title" : string ,
"funderShortname" : string , "funderName" : string ,
"funding" : string , "code" : string ,
"provenanceAction" : string , "inline" : boolean
} > ( ) ;
}
let fundedByProject : { "id" : string , "acronym" : string , "title" : string ,
"funderShortname" : string , "funderName" : string ,
"funding" : string , "code" : string ,
"provenanceAction" : string , "inline" : boolean
} = { "id" : "" , "acronym" : "" , "title" : "" ,
"funderShortname" : "" , "funderName" : "" ,
"funding" : "" , "code" : "" , "provenanceAction" : "" , "inline" : false
} ;
if ( relation . title != 'unidentified' ) {
fundedByProject [ 'id' ] = relation [ 'to' ] . content ;
fundedByProject [ 'acronym' ] = relation . acronym ;
fundedByProject [ 'title' ] = relation . title ;
fundedByProject [ 'code' ] = relation . code ;
if ( relation . provenanceaction in projectsProvenanceVocabulary ) {
fundedByProject [ 'provenanceAction' ] = projectsProvenanceVocabulary [ relation . provenanceaction ] ;
}
} else {
fundedByProject [ 'id' ] = "" ;
fundedByProject [ 'acronym' ] = "" ;
fundedByProject [ 'title' ] = "" ;
fundedByProject [ 'code' ] = "" ;
fundedByProject [ 'provenanceAction' ] = "" ;
}
if ( relation . hasOwnProperty ( "funding" ) ) {
let funding : { "funderName" : string , "funderShortname" : string , "stream" : string } ;
funding = this . parseFundingTrees ( relation . funding ) ;
if ( funding . funderName ) {
fundedByProject [ 'funderName' ] = funding . funderName ;
}
if ( funding . funderShortname ) {
fundedByProject [ 'funderShortname' ] = funding . funderShortname ;
}
if ( funding . stream ) {
fundedByProject [ 'funding' ] = funding . stream ;
}
}
fundedByProjects . push ( fundedByProject ) ;
return fundedByProjects ;
}
// publication & research data : for fundedByProjects | project landing : for funding
public parseFundingTrees ( fundingTree : any ) : { "funderName" : string , "funderShortname" : string , "stream" : string } {
let funding : { "funderName" : string , "funderShortname" : string , "stream" : string } = { "funderName" : "" , "funderShortname" : "" , "stream" : "" } ;
let length = Array . isArray ( fundingTree ) ? fundingTree.length : 1 ;
for ( let i = 0 ; i < length ; i + + ) {
let fundingData = Array . isArray ( fundingTree ) ? fundingTree [ i ] : fundingTree ;
if ( fundingData . hasOwnProperty ( "funder" ) ) {
funding . funderShortname = fundingData [ 'funder' ] . shortname ;
funding . funderName = fundingData [ 'funder' ] . name ;
}
funding . stream = this . addFundingLevel0 ( fundingData , funding . stream ) ;
funding . stream = this . addFundingLevel1 ( fundingData , funding . stream ) ;
funding . stream = this . addFundingLevel2 ( fundingData , funding . stream ) ;
}
return funding ;
}
addFundingLevel0 ( parent : string , fundingStream : string ) : string {
if ( parent . hasOwnProperty ( "funding_level_0" ) ) {
let level0 = parent [ 'funding_level_0' ] ;
fundingStream += ( fundingStream ) ? " ; " : "" ;
fundingStream += level0 . name ;
}
return fundingStream ;
}
addFundingLevel1 ( parent : string , fundingStream : string ) : string {
if ( parent . hasOwnProperty ( "funding_level_1" ) ) {
let level1 = parent [ 'funding_level_1' ] ;
// For projects' parsing
if ( level1 . hasOwnProperty ( "parent" ) ) {
fundingStream = this . addFundingLevel0 ( level1 . parent , fundingStream ) ;
}
fundingStream += ( fundingStream ) ? " | " : "" ;
fundingStream += level1 . name ;
}
return fundingStream ;
}
addFundingLevel2 ( parent : string , fundingStream : string ) : string {
if ( parent . hasOwnProperty ( "funding_level_2" ) ) {
let level2 = parent [ 'funding_level_2' ] ;
// For projects' parsing
if ( level2 . hasOwnProperty ( "parent" ) ) {
fundingStream = this . addFundingLevel1 ( level2 . parent , fundingStream ) ;
}
fundingStream += ( fundingStream ) ? " | " : "" ;
fundingStream += level2 . name ;
}
return fundingStream ;
}
// publication & dataset landing : for collectedFrom
parseCollectedFrom ( collectedFrom : { "name" : string , "id" : string } [ ] ,
_collectedFrom : any ) {
let length : number = collectedFrom . length ;
collectedFrom [ length ] = { "name" : "" , "id" : "" } ;
collectedFrom [ length ] [ 'name' ] = _collectedFrom . name ;
collectedFrom [ length ] [ 'id' ] = _collectedFrom . id ;
}
// publication & dataset landing : for downloadFrom
addPublisherToHostedBy_collectedFrom ( hostedBy_collectedFrom : { "downloadName" : string , "downloadUrl" : string [ ] , "collectedName" : string , "collectedId" : string , "accessMode" : string [ ] , "bestAccessMode" : string , "type" : string , "year" : string } [ ] ,
publisher : string , journal : { "journal" : string , "issn" : string , "lissn" : string } ,
2018-06-28 16:52:45 +02:00
identifiers : Map < string , string [ ] > /*, title: { "name": string, "url": string, "accessMode": string}*/ ) {
2017-12-19 13:53:46 +01:00
if ( publisher && identifiers != null && identifiers . has ( 'doi' ) ) {
if ( hostedBy_collectedFrom == null ) {
hostedBy_collectedFrom = new Array < { "downloadName" : string , "downloadUrl" : string [ ] , "collectedName" : string , "collectedId" : string , "accessMode" : string [ ] , "bestAccessMode" : string , "type" : string , "year" : string } > ( ) ;
}
let available : { "downloadName" : string , "downloadUrl" : string [ ] , "collectedName" : string , "collectedId" : string , "accessMode" : string [ ] , "bestAccessMode" : string , "type" : string , "year" : string } ;
available = { "downloadName" : "" , "downloadUrl" : null , "collectedName" : "" , "collectedId" : "" , "accessMode" : null , "bestAccessMode" : null , "type" : "" , "year" : "" } ;
if ( journal && journal . journal ) {
available . downloadName = publisher + "/ " + journal [ 'journal' ] ;
} else {
available . downloadName = publisher ;
}
2018-02-05 14:14:59 +01:00
let url = "https://dx.doi.org/" + identifiers . get ( "doi" ) [ 0 ] ;
2017-12-19 13:53:46 +01:00
available . downloadUrl = new Array < string > ( ) ;
available . accessMode = new Array < string > ( ) ;
available . downloadUrl . push ( url ) ;
2018-06-28 16:52:45 +02:00
/ *
2017-12-19 13:53:46 +01:00
if ( title != undefined && title [ 'url' ] == "" ) {
title [ 'url' ] = url ;
}
2018-06-28 16:52:45 +02:00
* /
2017-12-19 13:53:46 +01:00
hostedBy_collectedFrom . push ( available ) ;
}
return hostedBy_collectedFrom ;
}
// publication & dataset landing : for downloadFrom
parseDownloadFrom ( downloadFrom : Map < string , { " url " : string [ ] , " accessMode " : string [ ] , " bestAccessMode " : string } > , instance : any , url : string )
{
let key : string = instance [ 'hostedby' ] . name ;
if ( key ) {
this . addUrlAndAccessMode ( downloadFrom , instance , key , url ) ;
}
}
// publication & dataset landing : for publishedIn
parsePublishedIn ( publishedIn : Map < string , { " url " : string [ ] , " accessMode " : string [ ] , " bestAccessMode " : string } > , instance : any , result : any , url : string , counter : number ) : number {
if ( result != null && result . hasOwnProperty ( "source" ) ) {
let key : string ;
if ( Array . isArray ( result . source ) ) {
if ( counter == result . source . length ) {
counter -- ;
}
key = result [ 'source' ] [ counter ] ;
} else {
key = result [ 'source' ] ;
}
if ( key ) {
this . addUrlAndAccessMode ( publishedIn , instance , key , url ) ;
counter ++ ;
}
}
return counter ;
}
// publication & dataset landing : for downloadFrom and publishedIn
addUrlAndAccessMode ( mapStructure : Map < string , { " url " : string [ ] , " accessMode " : string [ ] , " bestAccessMode " : string } > , instance : any , key : string , url : string ) {
if ( ! mapStructure . has ( key ) ) {
mapStructure . set ( key , { "url" : null , "accessMode" : null , "bestAccessMode" : null } ) ;
}
if ( mapStructure . get ( key ) [ 'url' ] == null ) {
mapStructure . get ( key ) [ 'url' ] = new Array < string > ( ) ;
}
if ( url ) {
mapStructure . get ( key ) [ 'url' ] . push ( url ) ;
}
if ( mapStructure . get ( key ) [ 'accessMode' ] == null ) {
mapStructure . get ( key ) [ 'accessMode' ] = new Array < string > ( ) ;
}
if ( instance . hasOwnProperty ( "accessright" ) ) {
if ( url ) {
mapStructure . get ( key ) [ 'accessMode' ] . push ( instance [ 'accessright' ] . classid ) ;
}
if ( this . changeBestAccessMode ( mapStructure . get ( key ) [ 'bestAccessMode' ] , instance [ 'accessright' ] ) ) {
mapStructure . get ( key ) [ 'bestAccessMode' ] = instance [ 'accessright' ] . classid ;
}
} else if ( url ) {
mapStructure . get ( key ) [ 'accessMode' ] . push ( "" ) ;
}
}
parseHostedBy_collectedFrom ( hostedBy_collectedFrom : { "downloadName" : string , "downloadUrl" : string [ ] ,
"collectedName" : string , "collectedId" : string ,
"accessMode" : string [ ] , "bestAccessMode" : string ,
"type" : string , "year" : string } [ ] ,
2018-06-28 16:52:45 +02:00
instance : any , data : any , url : string , counter : number / * ,
title : { "name" : string , "url" : string , "accessMode" : string } * / , a c c e s s M o d e : s t r i n g ) : n u m b e r {
2017-12-19 13:53:46 +01:00
let available : { "downloadName" : string , "downloadUrl" : string [ ] , "collectedName" : string , "collectedId" : string , "accessMode" : string [ ] , "bestAccessMode" : string , "type" : string , "year" : string } ;
available = { "downloadName" : "" , "downloadUrl" : null , "collectedName" : "" , "collectedId" : "" , "accessMode" : null , "bestAccessMode" : null , "type" : "" , "year" : "" } ;
if ( instance [ 'hostedby' ] . name && instance [ 'hostedby' ] . name != "other resources" && instance [ 'hostedby' ] . name != "Unknown Repository" ) {
available . downloadName = instance [ 'hostedby' ] . name ;
} else {
if ( data != null && data . hasOwnProperty ( "source" ) ) {
let downloadName : string ;
if ( Array . isArray ( data . source ) ) {
if ( counter == data . source . length ) {
counter -- ;
}
downloadName = data [ 'source' ] [ counter ] ;
} else {
downloadName = data [ 'source' ] ;
}
if ( downloadName ) {
counter ++ ;
available . downloadName = downloadName ;
}
}
}
if ( available . downloadName ) {
if ( instance . hasOwnProperty ( "collectedfrom" ) ) {
available . collectedId = instance [ 'collectedfrom' ] . id ;
available . collectedName = instance [ 'collectedfrom' ] . name ;
}
if ( instance . hasOwnProperty ( "instancetype" ) && instance [ 'instancetype' ] . classname ) {
available . type = instance [ 'instancetype' ] . classname ;
}
if ( instance . hasOwnProperty ( "dateofacceptance" ) ) {
var date :string = ( instance . dateofacceptance ) + "" ; // transform to string in case it is an integer
available . year = ( date && ( date ) . indexOf ( '-' ) !== - 1 ) ? date . split ( '-' ) [ 0 ] : date ;
}
available . accessMode = new Array < string > ( ) ;
available . downloadUrl = new Array < string > ( ) ;
available [ 'downloadUrl' ] . push ( url ) ;
if ( instance . hasOwnProperty ( "accessright" ) ) {
if ( url ) {
available [ 'accessMode' ] . push ( instance [ 'accessright' ] . classid ) ;
}
if ( this . changeBestAccessMode ( available . bestAccessMode , instance [ 'accessright' ] ) ) {
available . bestAccessMode = instance [ 'accessright' ] . classid ;
2018-06-28 16:52:45 +02:00
/ *
2017-12-19 13:53:46 +01:00
if ( title != undefined ) {
if ( this . changeBestAccessMode ( title [ 'accessMode' ] , instance [ 'accessright' ] ) ) {
title [ 'accessMode' ] = instance [ 'accessright' ] . classid ;
title [ 'url' ] = url ;
}
}
2018-06-28 16:52:45 +02:00
* /
if ( this . changeBestAccessMode ( accessMode , instance [ 'accessright' ] ) ) {
accessMode = instance [ 'accessright' ] . classid ;
}
2017-12-19 13:53:46 +01:00
}
2018-06-28 16:52:45 +02:00
/ *
2017-12-19 13:53:46 +01:00
if ( title != undefined ) {
if ( ! title [ 'url' ] ) {
title [ 'url' ] = url ;
}
}
2018-06-28 16:52:45 +02:00
* /
2017-12-19 13:53:46 +01:00
} else if ( url ) {
available [ 'accessMode' ] . push ( "" ) ;
}
hostedBy_collectedFrom . push ( available ) ;
}
return counter ;
}
// publication & dataset landing : for downloadFrom and publishedIn
changeBestAccessMode ( currentAccessMode : string , accessMode : any ) : boolean {
if ( ! accessMode ) {
return false ;
}
accessMode = accessMode . classid ;
switch ( currentAccessMode ) {
case null :
2018-06-28 16:52:45 +02:00
if ( accessMode != "UNKNOWN" ) {
return true ;
}
return false ;
2017-12-19 13:53:46 +01:00
case "CLOSED" :
if ( accessMode == "OPEN" ||
2018-06-28 16:52:45 +02:00
accessMode == "OPEN SOURCE" ||
2017-12-19 13:53:46 +01:00
accessMode == "EMBARGO" ||
accessMode == "RESTRICTED" ) {
return true ;
}
return false ;
case "RESTRICTED" :
if ( accessMode == "OPEN" ||
2018-06-28 16:52:45 +02:00
accessMode == "OPEN SOURCE" ||
2017-12-19 13:53:46 +01:00
accessMode == "EMBARGO" ) {
return true ;
}
return false ;
case "EMBARGO" :
2018-06-28 16:52:45 +02:00
if ( accessMode == "OPEN" ||
accessMode == "OPEN SOURCE" ) {
2017-12-19 13:53:46 +01:00
return true ;
2018-06-28 16:52:45 +02:00
}
return false ;
case "OPEN SOURCE" :
if ( accessMode == "OPEN" ) {
return true ;
}
return false ;
2017-12-19 13:53:46 +01:00
}
return false ;
}
2018-07-26 18:38:59 +02:00
// publication & dataset & software & orp landing : for relatedResearchResults
2017-12-19 13:53:46 +01:00
parseRelatedResearchResults ( relatedResearchResults : Map < string , { " name " : string , " id " : string , " date " : string ,
2018-05-18 17:56:15 +02:00
"percentage" : number , "class" : string } [ ] > , relation : any , provenanceAction : string ) :
2017-12-19 13:53:46 +01:00
Map < string , { " name " : string , " id " : string , " date " : string ,
2018-05-18 17:56:15 +02:00
"percentage" : number , "class" : string } [ ] > {
2017-12-19 13:53:46 +01:00
if ( relatedResearchResults == undefined ) {
relatedResearchResults = new Map < string , { " name " : string , " id " : string , " date " : string ,
2018-05-18 17:56:15 +02:00
"percentage" : number , "class" : string } [ ] > ( ) ;
2017-12-19 13:53:46 +01:00
}
if ( ! relatedResearchResults . has ( provenanceAction ) ) {
relatedResearchResults . set ( provenanceAction ,
new Array < { "name" : string , "id" : string , "date" : string ,
2018-05-18 17:56:15 +02:00
"percentage" : number , "class" : string } > ( ) ) ;
2017-12-19 13:53:46 +01:00
}
2018-05-18 17:56:15 +02:00
relatedResearchResults . get ( provenanceAction ) . push ( this . parseRelatedOrSimilarResearchResult ( relation , "trust" ) ) ;
2017-12-19 13:53:46 +01:00
return relatedResearchResults ;
}
2018-07-26 18:38:59 +02:00
// publication & dataset & software & orp landing : for similarResearchResults
2017-12-19 13:53:46 +01:00
parseSimilarResearchResults ( similarResearchResults : { "name" : string , "id" : string , "date" : string ,
2018-05-18 17:56:15 +02:00
"percentage" : number , "class" : string } [ ] , relation : any ) :
{ "name" : string , "id" : string , "date" : string , "percentage" : number , "class" : string } [ ] {
2017-12-19 13:53:46 +01:00
if ( similarResearchResults == undefined ) {
similarResearchResults = new Array < { "name" : string , "id" : string , "date" : string ,
2018-05-18 17:56:15 +02:00
"percentage" : number , "class" : string } > ( ) ;
2017-12-19 13:53:46 +01:00
}
2018-05-18 17:56:15 +02:00
similarResearchResults . push ( this . parseRelatedOrSimilarResearchResult ( relation , "similarity" ) ) ;
2017-12-19 13:53:46 +01:00
return similarResearchResults ;
}
2018-07-26 18:38:59 +02:00
// publication & dataset & software & orp landing : for relatedResearchResults and similarResearchResults
2018-05-18 17:56:15 +02:00
parseRelatedOrSimilarResearchResult ( relation : any , percentageName : string ) : { "name" : string , "id" : string , "date" : string , "percentage" : number , "class" : string } {
let researchResult : { "name" : string , "id" : string , "date" : string , "percentage" : number , "class" : string }
= { "name" : "" , "id" : "" , "date" : "" , "percentage" : null , "class" : "" }
2017-12-19 13:53:46 +01:00
if ( relation [ 'resulttype' ] . classname == "publication" ) {
researchResult [ 'class' ] = "publication" ;
} else if ( relation [ 'resulttype' ] . classname == "dataset" ) {
researchResult [ 'class' ] = "dataset" ;
2018-07-26 18:38:59 +02:00
} else if ( relation [ 'resulttype' ] . classname == "software" ) {
2017-12-19 13:53:46 +01:00
researchResult [ 'class' ] = "software" ;
2018-07-26 18:38:59 +02:00
} else if ( relation [ 'resulttype' ] . classname == "other" ) {
researchResult [ 'class' ] = "other" ;
2017-12-19 13:53:46 +01:00
}
researchResult [ 'id' ] = relation [ 'to' ] . content ;
let titleName = Array . isArray ( relation [ 'title' ] ) ? relation [ 'title' ] [ 0 ] . content : relation [ 'title' ] . content ;
researchResult [ 'name' ] = titleName ;
2018-06-28 16:52:45 +02:00
if ( relation . hasOwnProperty ( "dateofacceptance" ) ) {
var date :string = ( ( Array . isArray ( relation . dateofacceptance ) ) ? ( relation . dateofacceptance [ 0 ] ) : ( relation . dateofacceptance ) ) + "" ; // transform to string in case it is an integer
researchResult [ 'date' ] = ( date && ( date ) . indexOf ( '-' ) !== - 1 ) ? date . split ( '-' ) [ 0 ] : date ;
}
2017-12-19 13:53:46 +01:00
//researchResult['date'] = relation.dateofacceptance.substring(0,4);;
2018-05-18 17:56:15 +02:00
researchResult [ 'percentage' ] = Math . round ( relation [ percentageName ] * 100 ) ;
2017-12-19 13:53:46 +01:00
return researchResult ;
}
2018-05-21 14:31:19 +02:00
sortByPercentage ( results : { "name" : string , "id" : string , "date" : string , "percentage" : number , "class" : string } [ ] ) : { "name" : string , "id" : string , "date" : string , "percentage" : number , "class" : string } [ ] {
if ( results ) {
return results . sort ( function ( a , b ) { return b [ "percentage" ] - a [ "percentage" ] } ) ;
}
return results ;
}
2017-12-19 13:53:46 +01:00
// publication & dataset landing : for identifiers
parseIdentifiers ( pid : any ) : Map < string , string [ ] > {
let identifiers = new Map < string , string [ ] > ( ) ;
if ( pid . hasOwnProperty ( "classname" ) && pid [ 'classname' ] != "" ) {
if ( pid . classname == "doi" || pid . classname == "pmc" || pid . classname == "handle" ) {
if ( ! identifiers . has ( pid . classname ) ) {
identifiers . set ( pid . classname , new Array < string > ( ) ) ;
}
identifiers . get ( pid . classname ) . push ( pid . content ) ;
}
} else {
for ( let i = 0 ; i < pid.length ; i + + ) {
if ( pid [ i ] . classname == "doi" || pid [ i ] . classname == "pmc" || pid [ i ] . classname == "handle" ) {
if ( ! identifiers . has ( pid [ i ] . classname ) ) {
identifiers . set ( pid [ i ] . classname , new Array < string > ( ) ) ;
}
identifiers . get ( pid [ i ] . classname ) . push ( pid [ i ] . content ) ;
}
}
}
return identifiers ;
}
// publication & dataset landing : for subjects and otherSubjects and classifiedSubjects
parseAllSubjects ( _subjects : any ) : [ string [ ] , Map < string , string [ ] > , Map < string , string [ ] > ] {
let subjects : string [ ] ;
let otherSubjects : Map < string , string [ ] > ;
let classifiedSubjects : Map < string , string [ ] > ;
let subject ;
let length = Array . isArray ( _subjects ) ? _subjects.length : 1 ;
for ( let i = 0 ; i < length ; i + + ) {
subject = Array . isArray ( _subjects ) ? _subjects [ i ] : _subjects ;
if ( subject . classid != "" ) {
if ( subject . inferred && subject . inferred == true ) {
if ( classifiedSubjects == undefined ) {
classifiedSubjects = new Map < string , string [ ] > ( ) ;
}
if ( ! classifiedSubjects . has ( subject . classname ) ) {
classifiedSubjects . set ( subject . classname , new Array < string > ( ) ) ;
}
classifiedSubjects . get ( subject . classname ) . push ( subject . content ) ;
} else {
if ( subject . classid == "keyword" ) {
if ( subjects == undefined ) {
subjects = new Array < string > ( ) ;
}
subjects . push ( subject . content ) ;
} else {
if ( otherSubjects == undefined ) {
otherSubjects = new Map < string , string [ ] > ( ) ;
}
if ( ! otherSubjects . has ( subject . classname ) ) {
otherSubjects . set ( subject . classname , new Array < string > ( ) ) ;
}
otherSubjects . get ( subject . classname ) . push ( subject . content ) ;
}
}
}
}
return [ subjects , otherSubjects , classifiedSubjects ] ;
}
parseContexts ( _contexts : any ) : { "labelContext" : string , "labelCategory" : string ,
"labelConcept" : string , inline :boolean } [ ] {
let contexts = new Array < { "labelContext" : string , "labelCategory" : string ,
"labelConcept" : string , inline :boolean } > ( ) ;
let position = 0 ;
let labels = "" ;
let context ;
let length = Array . isArray ( _contexts ) ? _contexts.length : 1 ;
for ( let i = 0 ; i < length ; i + + ) {
context = Array . isArray ( _contexts ) ? _contexts [ i ] : _contexts ;
2018-07-19 12:47:21 +02:00
if ( context . hasOwnProperty ( "type" ) && ( context [ 'type' ] == "community" || context [ 'type' ] == "ri" ) ) {
2017-12-19 13:53:46 +01:00
if ( context . hasOwnProperty ( "category" ) ) {
if ( context [ 'category' ] . hasOwnProperty ( "concept" ) ) {
let categoryConcept ;
let length1 = Array . isArray ( context [ 'category' ] [ 'concept' ] ) ? context [ 'category' ] [ 'concept' ] . length : 1 ;
for ( let j = 0 ; j < length1 ; j + + ) {
categoryConcept = Array . isArray ( context [ 'category' ] [ 'concept' ] ) ? context [ 'category' ] [ 'concept' ] [ j ] : context [ 'category' ] [ 'concept' ] ;
contexts [ position ] = { "labelContext" : "" , "labelCategory" : "" , "labelConcept" : "" , inline : false } ;
contexts [ position ] [ 'labelContext' ] = context . label ;
contexts [ position ] [ 'labelCategory' ] = context [ 'category' ] . label ;
contexts [ position ] [ 'labelConcept' ] = categoryConcept . label ;
position ++ ;
}
} else {
contexts [ position ] = { "labelContext" : "" , "labelCategory" : "" , "labelConcept" : "" , inline : false } ;
contexts [ position ] [ 'labelContext' ] = context . label ;
contexts [ position ] [ 'labelCategory' ] = context [ 'category' ] . label ;
contexts [ position ] [ 'labelConcept' ] = null ;
}
} else {
contexts [ position ] = { "labelContext" : "" , "labelCategory" : "" , "labelConcept" : "" , inline : false } ;
contexts [ position ] [ 'labelContext' ] = context . label ;
contexts [ position ] [ 'labelCategory' ] = null ;
contexts [ position ] [ 'labelConcept' ] = null ;
contexts [ position ] [ 'new' ] = false ;
}
}
}
return contexts ;
}
parseTypes ( types : string [ ] , uniqueTypes : Set < string > , instance : any ) {
if ( instance . hasOwnProperty ( "instancetype" ) && instance [ 'instancetype' ] . classname ) {
if ( ! uniqueTypes . has ( instance [ 'instancetype' ] . classname ) ) {
types . push ( instance [ 'instancetype' ] . classname ) ;
uniqueTypes . add ( instance [ 'instancetype' ] . classname ) ;
}
}
}
2018-02-13 15:52:23 +01:00
parseLanguages ( _languages : any ) {
var languages = new Array < string > ( ) ;
if ( ! Array . isArray ( _languages ) ) {
if ( _languages . classname != "Undetermined" && _languages . classname ) {
languages . push ( _languages . classname ) ;
}
} else {
for ( let i = 0 ; i < _languages.length ; i + + ) {
if ( _languages [ i ] . classname != "Undetermined" && _languages [ i ] . classname ) {
languages . push ( _languages [ i ] . classname ) ;
}
}
}
return languages ;
}
2018-06-28 16:52:45 +02:00
parseCountries ( _countries : any ) {
var countries = new Array < string > ( ) ;
if ( ! Array . isArray ( _countries ) ) {
if ( _countries . classname != "Undetermined" && _countries . classname ) {
countries . push ( _countries . classname ) ;
}
} else {
for ( let i = 0 ; i < countries.length ; i + + ) {
if ( _countries [ i ] . classname != "Undetermined" && _countries [ i ] . classname ) {
countries . push ( _countries [ i ] . classname ) ;
}
}
}
return countries ;
}
parseProgrammingLanguages ( _pLanguages ) {
var pLanguages = new Array < string > ( ) ;
if ( ! Array . isArray ( _pLanguages ) ) {
if ( _pLanguages . classname != "Undetermined" && _pLanguages . classname ) {
pLanguages . push ( _pLanguages . classname ) ;
}
} else {
for ( let i = 0 ; i < _pLanguages.length ; i + + ) {
if ( _pLanguages [ i ] . classname != "Undetermined" && _pLanguages [ i ] . classname ) {
pLanguages . push ( _pLanguages [ i ] . classname ) ;
}
}
}
return pLanguages ;
}
2017-12-19 13:53:46 +01:00
}