コード例 #1
0
 def __init__(self, identifier_strategy, create_strategy):
     self.identifier_strategy = identifier_strategy
     self.create_strategy = create_strategy
     self.bio_crosswalker = BioCrosswalk(identifier_strategy, create_strategy)
     self.affiliations_crosswalker = AffiliationsCrosswalk(identifier_strategy, create_strategy)
     self.funding_crosswalker = FundingCrosswalk(identifier_strategy, create_strategy)
     self.works_crosswalker = WorksCrosswalk(identifier_strategy, create_strategy)
コード例 #2
0
 def setUp(self):
     self.graph = Graph(namespace_manager=ns.ns_manager)
     self.person_uri = ns.D["test"]
     self.create_strategy = SimpleCreateEntitiesStrategy(
         HashIdentifierStrategy(), person_uri=self.person_uri)
     self.crosswalker = AffiliationsCrosswalk(
         identifier_strategy=self.create_strategy,
         create_strategy=self.create_strategy)
コード例 #3
0
class PersonCrosswalk():
    def __init__(self, identifier_strategy, create_strategy):
        self.identifier_strategy = identifier_strategy
        self.create_strategy = create_strategy
        self.bio_crosswalker = BioCrosswalk(identifier_strategy, create_strategy)
        self.affiliations_crosswalker = AffiliationsCrosswalk(identifier_strategy, create_strategy)
        self.funding_crosswalker = FundingCrosswalk(identifier_strategy, create_strategy)
        self.works_crosswalker = WorksCrosswalk(identifier_strategy, create_strategy)

    def crosswalk(self, orcid_id, person_uri, person_class=None, confirmed_orcid_id=False):

        # Create an RDFLib Graph
        graph = Graph(namespace_manager=ns.ns_manager)

        # 0000-0003-3441-946X
        clean_orcid_id = clean_orcid(orcid_id)
        orcid_profile = fetch_orcid_profile(clean_orcid_id)

        # Determine the class to use for the person
        person_clazz = FOAF.Person
        if person_class:
            person_clazz = getattr(VIVO, person_class)

        # ORCID
        PersonCrosswalk._add_orcid_id(person_uri, clean_orcid_id, graph, confirmed_orcid_id)

        self.bio_crosswalker.crosswalk(orcid_profile, person_uri, graph, person_class=person_clazz)
        self.works_crosswalker.crosswalk(orcid_profile, person_uri, graph)
        self.affiliations_crosswalker.crosswalk(orcid_profile, person_uri, graph)
        self.funding_crosswalker.crosswalk(orcid_profile, person_uri, graph)

        return graph, orcid_profile, person_uri

    @staticmethod
    def _add_orcid_id(person_uri, orcid_id, graph, confirmed):
        orcid_id_uriref = URIRef("http://orcid.org/%s" % orcid_id)
        graph.add((person_uri, VIVO.orcidId, orcid_id_uriref))
        graph.add((orcid_id_uriref, RDF.type, OWL.Thing))
        if confirmed:
            graph.add((orcid_id_uriref, VIVO.confirmedOrcidId, person_uri))
コード例 #4
0
class TestAffiliations(TestCase):

    def setUp(self):
        self.graph = Graph(namespace_manager=ns.ns_manager)
        self.person_uri = ns.D["test"]
        self.create_strategy = SimpleCreateEntitiesStrategy(HashIdentifierStrategy(), person_uri=self.person_uri)
        self.crosswalker = AffiliationsCrosswalk(identifier_strategy=self.create_strategy,
                                        create_strategy=self.create_strategy)

    def test_no_activities(self):
        orcid_profile = json.loads("""
{
    "message-version": "1.2",
    "orcid-profile": {
        "orcid-activities": null
    }
}
        """)
        self.crosswalker.crosswalk(orcid_profile, self.person_uri, self.graph)
        self.assertEqual(0, len(self.graph))

    def test_no_affiliations(self):
        orcid_profile = json.loads("""
{
    "message-version": "1.2",
    "orcid-profile": {
        "orcid-activities": {
          "affiliations": null
        }
    }
}
        """)
        self.crosswalker.crosswalk(orcid_profile, self.person_uri, self.graph)
        self.assertEqual(0, len(self.graph))

    def test_no_education(self):
        orcid_profile = json.loads("""
{
    "message-version": "1.2",
    "orcid-profile": {
        "orcid-bio": {
            "orcid-activities": {
                "affiliations": {
                    "affiliation": [
                        {
                            "type": "EMPLOYMENT",
                            "department-name": "Gelman Library",
                            "role-title": "Science & Engineering Librarian",
                            "start-date": {
                                "year": {
                                    "value": "2013"
                                },
                                "month": {
                                    "value": "07"
                                },
                                "day": null
                            },
                            "end-date": null,
                            "organization": {
                                "name": "George Washington University",
                                "address": {
                                    "city": "Washington",
                                    "region": "DC",
                                    "country": "US"
                                },
                                "disambiguated-organization": {
                                    "disambiguated-organization-identifier": "8367",
                                    "disambiguation-source": "RINGGOLD"
                                }
                            },
                            "source": {
                                "source-orcid": {
                                    "value": null,
                                    "uri": "http://orcid.org/0000-0002-4192-3392",
                                    "path": "0000-0002-4192-3392",
                                    "host": "orcid.org"
                                },
                                "source-client-id": null,
                                "source-name": {
                                    "value": "Hope Lappen"
                                },
                                "source-date": {
                                    "value": 1386877638912
                                }
                            },
                            "created-date": {
                                "value": 1386877638912
                            },
                            "last-modified-date": {
                                "value": 1386877750045
                            },
                            "visibility": "PUBLIC",
                            "put-code": "25495"
                        }
                    ]
                }
            }
        }
    }
}
        """)
        self.crosswalker.crosswalk(orcid_profile, self.person_uri, self.graph)
        self.assertEqual(0, len(self.graph))

    def test_education(self):
        orcid_profile = json.loads("""
{
    "message-version": "1.2",
    "orcid-profile": {
        "orcid-activities": {
            "affiliations": {
                "affiliation": [
                    {
                        "type": "EDUCATION",
                        "department-name": "Neurosciences",
                        "role-title": "PhD",
                        "start-date": {
                            "year": {
                                "value": "1995"
                            },
                            "month" : {
                              "value" : "06"
                            },
                            "day" : {
                              "value" : "11"
                            }
                        },
                        "end-date": {
                            "year": {
                                "value": "1997"
                            },
                            "month" : {
                              "value" : "07"
                            },
                            "day" : {
                              "value" : "03"
                            }
                        },
                        "organization": {
                            "name": "Stanford University School of Medicine",
                            "address": {
                                "city": "Stanford",
                                "region": "California",
                                "country": "US"
                            },
                            "disambiguated-organization": null
                        },
                        "source": {
                            "source-orcid": {
                                "value": null,
                                "uri": "http://orcid.org/0000-0001-5109-3700",
                                "path": "0000-0001-5109-3700",
                                "host": "orcid.org"
                            },
                            "source-client-id": null,
                            "source-name": {
                                "value": "Laurel L Haak"
                            },
                            "source-date": {
                                "value": 1385568459467
                            }
                        },
                        "created-date": {
                            "value": 1385568459467
                        },
                        "last-modified-date": {
                            "value": 1406092743932
                        },
                        "visibility": "PUBLIC",
                        "put-code": "1006"
                    }
                ]
            }
        }
    }
}
        """)
        self.crosswalker.crosswalk(orcid_profile, self.person_uri, self.graph)
        self.assertTrue(bool(self.graph.query("""
            ask where {
                ?awdgre a vivo:AwardedDegree .
                ?awdgre rdfs:label "PhD" .
                ?awdgre obo:RO_0002353 ?awdgreproc .
                ?awdgre vivo:assignedBy ?org .
                ?awdgre vivo:relates d:test, ?dgre .
                ?org a foaf:Organization .
                ?org rdfs:label "Stanford University School of Medicine" .
                ?org obo:RO_0001025 ?geo .
                ?geo rdfs:label "Stanford, California" .
                ?awdgreproc a vivo:EducationalProcess .
                ?awdgreproc obo:RO_0000057 ?org, d:test .
                ?awdgreproc vivo:dateTimeInterval ?awdgreprocint .
                ?awdgreproc vivo:departmentOrSchool "Neurosciences" .
                ?awdgreprocint a vivo:DateTimeInterval .
                ?awdgreprocint vivo:end ?awdgreprocintend .
                ?awdgreprocintend a vivo:DateTimeValue .
                ?awdgreprocintend rdfs:label "1997" .
                ?awdgreprocintend vivo:dateTime "1997-01-01T00:00:00"^^xsd:dateTime .
                ?awdgreprocintend vivo:dateTimePrecision vivo:yearPrecision .
                ?awdgreprocint vivo:start ?awdgreprocintstart .
                ?awdgreprocintstart a vivo:DateTimeValue .
                ?awdgreprocintstart rdfs:label "1995" .
                ?awdgreprocintstart vivo:dateTime "1995-01-01T00:00:00"^^xsd:dateTime .
                ?awdgreprocintstart vivo:dateTimePrecision vivo:yearPrecision .
            }
        """)))

    def test_education_minimal(self):
        orcid_profile = json.loads("""
{
    "message-version": "1.2",
    "orcid-profile": {
        "orcid-activities": {
            "affiliations": {
                "affiliation": [
                    {
                        "type": "EDUCATION",
                        "department-name": null,
                        "start-date": null,
                        "end-date": null,
                        "organization": {
                            "name": "Stanford University School of Medicine",
                            "address": {
                                "city": "Stanford",
                                "region": "California",
                                "country": "US"
                            },
                            "disambiguated-organization": null
                        },
                        "source": {
                            "source-orcid": {
                                "value": null,
                                "uri": "http://orcid.org/0000-0001-5109-3700",
                                "path": "0000-0001-5109-3700",
                                "host": "orcid.org"
                            },
                            "source-client-id": null,
                            "source-name": {
                                "value": "Laurel L Haak"
                            },
                            "source-date": {
                                "value": 1385568459467
                            }
                        },
                        "created-date": {
                            "value": 1385568459467
                        },
                        "last-modified-date": {
                            "value": 1406092743932
                        },
                        "visibility": "PUBLIC",
                        "put-code": "1006"
                    }
                ]
            }
        }
    }
}
        """)
        self.crosswalker.crosswalk(orcid_profile, self.person_uri, self.graph)
        self.assertTrue(bool(self.graph.query("""
            ask where {
                ?org a foaf:Organization .
                ?org rdfs:label "Stanford University School of Medicine" .
                ?org obo:RO_0001025 ?geo .
                ?geo rdfs:label "Stanford, California" .
                ?awdgreproc a vivo:EducationalProcess .
                ?awdgreproc obo:RO_0000057 ?org, d:test .
                filter not exists {
                    ?awdgreproc vivo:departmentOrSchool ?awdgredept .
                }
            }
        """)))
コード例 #5
0
 def setUp(self):
     self.graph = Graph(namespace_manager=ns.ns_manager)
     self.person_uri = ns.D["test"]
     self.create_strategy = SimpleCreateEntitiesStrategy(HashIdentifierStrategy(), person_uri=self.person_uri)
     self.crosswalker = AffiliationsCrosswalk(identifier_strategy=self.create_strategy,
                                     create_strategy=self.create_strategy)
コード例 #6
0
class TestAffiliations(TestCase):
    def setUp(self):
        self.graph = Graph(namespace_manager=ns.ns_manager)
        self.person_uri = ns.D["test"]
        self.create_strategy = SimpleCreateEntitiesStrategy(
            HashIdentifierStrategy(), person_uri=self.person_uri)
        self.crosswalker = AffiliationsCrosswalk(
            identifier_strategy=self.create_strategy,
            create_strategy=self.create_strategy)

    def test_no_activities(self):
        orcid_profile = json.loads("""
{
    "message-version": "1.2",
    "orcid-profile": {
        "orcid-activities": null
    }
}
        """)
        self.crosswalker.crosswalk(orcid_profile, self.person_uri, self.graph)
        self.assertEqual(0, len(self.graph))

    def test_no_affiliations(self):
        orcid_profile = json.loads("""
{
    "message-version": "1.2",
    "orcid-profile": {
        "orcid-activities": {
          "affiliations": null
        }
    }
}
        """)
        self.crosswalker.crosswalk(orcid_profile, self.person_uri, self.graph)
        self.assertEqual(0, len(self.graph))

    def test_no_education(self):
        orcid_profile = json.loads("""
{
    "message-version": "1.2",
    "orcid-profile": {
        "orcid-bio": {
            "orcid-activities": {
                "affiliations": {
                    "affiliation": [
                        {
                            "type": "EMPLOYMENT",
                            "department-name": "Gelman Library",
                            "role-title": "Science & Engineering Librarian",
                            "start-date": {
                                "year": {
                                    "value": "2013"
                                },
                                "month": {
                                    "value": "07"
                                },
                                "day": null
                            },
                            "end-date": null,
                            "organization": {
                                "name": "George Washington University",
                                "address": {
                                    "city": "Washington",
                                    "region": "DC",
                                    "country": "US"
                                },
                                "disambiguated-organization": {
                                    "disambiguated-organization-identifier": "8367",
                                    "disambiguation-source": "RINGGOLD"
                                }
                            },
                            "source": {
                                "source-orcid": {
                                    "value": null,
                                    "uri": "http://orcid.org/0000-0002-4192-3392",
                                    "path": "0000-0002-4192-3392",
                                    "host": "orcid.org"
                                },
                                "source-client-id": null,
                                "source-name": {
                                    "value": "Hope Lappen"
                                },
                                "source-date": {
                                    "value": 1386877638912
                                }
                            },
                            "created-date": {
                                "value": 1386877638912
                            },
                            "last-modified-date": {
                                "value": 1386877750045
                            },
                            "visibility": "PUBLIC",
                            "put-code": "25495"
                        }
                    ]
                }
            }
        }
    }
}
        """)
        self.crosswalker.crosswalk(orcid_profile, self.person_uri, self.graph)
        self.assertEqual(0, len(self.graph))

    def test_education(self):
        orcid_profile = json.loads("""
{
    "message-version": "1.2",
    "orcid-profile": {
        "orcid-activities": {
            "affiliations": {
                "affiliation": [
                    {
                        "type": "EDUCATION",
                        "department-name": "Neurosciences",
                        "role-title": "PhD",
                        "start-date": {
                            "year": {
                                "value": "1995"
                            },
                            "month" : {
                              "value" : "06"
                            },
                            "day" : {
                              "value" : "11"
                            }
                        },
                        "end-date": {
                            "year": {
                                "value": "1997"
                            },
                            "month" : {
                              "value" : "07"
                            },
                            "day" : {
                              "value" : "03"
                            }
                        },
                        "organization": {
                            "name": "Stanford University School of Medicine",
                            "address": {
                                "city": "Stanford",
                                "region": "California",
                                "country": "US"
                            },
                            "disambiguated-organization": null
                        },
                        "source": {
                            "source-orcid": {
                                "value": null,
                                "uri": "http://orcid.org/0000-0001-5109-3700",
                                "path": "0000-0001-5109-3700",
                                "host": "orcid.org"
                            },
                            "source-client-id": null,
                            "source-name": {
                                "value": "Laurel L Haak"
                            },
                            "source-date": {
                                "value": 1385568459467
                            }
                        },
                        "created-date": {
                            "value": 1385568459467
                        },
                        "last-modified-date": {
                            "value": 1406092743932
                        },
                        "visibility": "PUBLIC",
                        "put-code": "1006"
                    }
                ]
            }
        }
    }
}
        """)
        self.crosswalker.crosswalk(orcid_profile, self.person_uri, self.graph)
        self.assertTrue(
            bool(
                self.graph.query("""
            ask where {
                ?awdgre a vivo:AwardedDegree .
                ?awdgre rdfs:label "PhD" .
                ?awdgre obo:RO_0002353 ?awdgreproc .
                ?awdgre vivo:assignedBy ?org .
                ?awdgre vivo:relates d:test, ?dgre .
                ?org a foaf:Organization .
                ?org rdfs:label "Stanford University School of Medicine" .
                ?org obo:RO_0001025 ?geo .
                ?geo rdfs:label "Stanford, California" .
                ?awdgreproc a vivo:EducationalProcess .
                ?awdgreproc obo:RO_0000057 ?org, d:test .
                ?awdgreproc vivo:dateTimeInterval ?awdgreprocint .
                ?awdgreproc vivo:departmentOrSchool "Neurosciences" .
                ?awdgreprocint a vivo:DateTimeInterval .
                ?awdgreprocint vivo:end ?awdgreprocintend .
                ?awdgreprocintend a vivo:DateTimeValue .
                ?awdgreprocintend rdfs:label "1997" .
                ?awdgreprocintend vivo:dateTime "1997-01-01T00:00:00"^^xsd:dateTime .
                ?awdgreprocintend vivo:dateTimePrecision vivo:yearPrecision .
                ?awdgreprocint vivo:start ?awdgreprocintstart .
                ?awdgreprocintstart a vivo:DateTimeValue .
                ?awdgreprocintstart rdfs:label "1995" .
                ?awdgreprocintstart vivo:dateTime "1995-01-01T00:00:00"^^xsd:dateTime .
                ?awdgreprocintstart vivo:dateTimePrecision vivo:yearPrecision .
            }
        """)))

    def test_education_minimal(self):
        orcid_profile = json.loads("""
{
    "message-version": "1.2",
    "orcid-profile": {
        "orcid-activities": {
            "affiliations": {
                "affiliation": [
                    {
                        "type": "EDUCATION",
                        "department-name": null,
                        "start-date": null,
                        "end-date": null,
                        "organization": {
                            "name": "Stanford University School of Medicine",
                            "address": {
                                "city": "Stanford",
                                "region": "California",
                                "country": "US"
                            },
                            "disambiguated-organization": null
                        },
                        "source": {
                            "source-orcid": {
                                "value": null,
                                "uri": "http://orcid.org/0000-0001-5109-3700",
                                "path": "0000-0001-5109-3700",
                                "host": "orcid.org"
                            },
                            "source-client-id": null,
                            "source-name": {
                                "value": "Laurel L Haak"
                            },
                            "source-date": {
                                "value": 1385568459467
                            }
                        },
                        "created-date": {
                            "value": 1385568459467
                        },
                        "last-modified-date": {
                            "value": 1406092743932
                        },
                        "visibility": "PUBLIC",
                        "put-code": "1006"
                    }
                ]
            }
        }
    }
}
        """)
        self.crosswalker.crosswalk(orcid_profile, self.person_uri, self.graph)
        self.assertTrue(
            bool(
                self.graph.query("""
            ask where {
                ?org a foaf:Organization .
                ?org rdfs:label "Stanford University School of Medicine" .
                ?org obo:RO_0001025 ?geo .
                ?geo rdfs:label "Stanford, California" .
                ?awdgreproc a vivo:EducationalProcess .
                ?awdgreproc obo:RO_0000057 ?org, d:test .
                filter not exists {
                    ?awdgreproc vivo:departmentOrSchool ?awdgredept .
                }
            }
        """)))
コード例 #7
0
class TestAffiliations(TestCase):
    def setUp(self):
        self.graph = Graph(namespace_manager=ns.ns_manager)
        self.person_uri = ns.D["test"]
        self.create_strategy = SimpleCreateEntitiesStrategy(
            HashIdentifierStrategy(), person_uri=self.person_uri)
        self.crosswalker = AffiliationsCrosswalk(
            identifier_strategy=self.create_strategy,
            create_strategy=self.create_strategy)

    def test_no_affiliations(self):
        orcid_profile = json.loads("""
{
  "activities-summary": {
  }
}
        """)
        self.crosswalker.crosswalk(orcid_profile, self.person_uri, self.graph)
        self.assertEqual(0, len(self.graph))

    def test_no_education(self):
        orcid_profile = json.loads("""
{
  "activities-summary": {
    "educations": {
        "education-summary": []
    }
  }
}
""")
        self.crosswalker.crosswalk(orcid_profile, self.person_uri, self.graph)
        self.assertEqual(0, len(self.graph))

    def test_education(self):
        orcid_profile = json.loads("""
{
  "activities-summary": {
    "educations": {
      "last-modified-date": {
        "value": 1486085029078
      },
      "education-summary": [
        {
          "created-date": {
            "value": 1385568459467
          },
          "last-modified-date": {
            "value": 1486085026897
          },
          "source": {
            "source-orcid": {
              "uri": "http://orcid.org/0000-0001-5109-3700",
              "path": "0000-0001-5109-3700",
              "host": "orcid.org"
            },
            "source-client-id": null,
            "source-name": {
              "value": "Laurel L Haak"
            }
          },
          "department-name": "Neurosciences",
          "role-title": "PhD",
          "start-date": {
            "year": {
              "value": "1995"
            },
            "month": null,
            "day": null
          },
          "end-date": {
            "year": {
              "value": "1997"
            },
            "month": null,
            "day": null
          },
          "organization": {
            "name": "Stanford University School of Medicine",
            "address": {
              "city": "Stanford",
              "region": "California",
              "country": "US"
            },
            "disambiguated-organization": null
          },
          "visibility": "PUBLIC",
          "put-code": 1006,
          "path": "/0000-0001-5109-3700/education/1006"
        }
      ],
      "path": "/0000-0001-5109-3700/educations"
    }
  }  
}
        """)
        # Changed start date to 1995
        self.crosswalker.crosswalk(orcid_profile, self.person_uri, self.graph)
        self.assertTrue(
            bool(
                self.graph.query("""
            ask where {
                ?awdgre a vivo:AwardedDegree .
                ?awdgre rdfs:label "PhD" .
                ?awdgre obo:RO_0002353 ?awdgreproc .
                ?awdgre vivo:assignedBy ?org .
                ?awdgre vivo:relates d:test, ?dgre .
                ?org a foaf:Organization .
                ?org rdfs:label "Stanford University School of Medicine" .
                ?org obo:RO_0001025 ?geo .
                ?geo rdfs:label "Stanford, California" .
                ?awdgreproc a vivo:EducationalProcess .
                ?awdgreproc obo:RO_0000057 ?org, d:test .
                ?awdgreproc vivo:dateTimeInterval ?awdgreprocint .
                ?awdgreproc vivo:departmentOrSchool "Neurosciences" .
                ?awdgreprocint a vivo:DateTimeInterval .
                ?awdgreprocint vivo:end ?awdgreprocintend .
                ?awdgreprocintend a vivo:DateTimeValue .
                ?awdgreprocintend rdfs:label "1997" .
                ?awdgreprocintend vivo:dateTime "1997-01-01T00:00:00"^^xsd:dateTime .
                ?awdgreprocintend vivo:dateTimePrecision vivo:yearPrecision .
                ?awdgreprocint vivo:start ?awdgreprocintstart .
                ?awdgreprocintstart a vivo:DateTimeValue .
                ?awdgreprocintstart rdfs:label "1995" .
                ?awdgreprocintstart vivo:dateTime "1995-01-01T00:00:00"^^xsd:dateTime .
                ?awdgreprocintstart vivo:dateTimePrecision vivo:yearPrecision .
            }
        """)))

    def test_education_minimal(self):
        orcid_profile = json.loads("""
{
  "activities-summary": {
    "educations": {
      "last-modified-date": {
        "value": 1486085029078
      },
      "education-summary": [
        {
          "created-date": {
            "value": 1385568459467
          },
          "last-modified-date": {
            "value": 1486085026897
          },
          "source": {
            "source-orcid": {
              "uri": "http://orcid.org/0000-0001-5109-3700",
              "path": "0000-0001-5109-3700",
              "host": "orcid.org"
            },
            "source-client-id": null,
            "source-name": {
              "value": "Laurel L Haak"
            }
          },
          "department-name": null,
          "role-title": "PhD",
          "start-date": null,
          "end-date": null,
          "organization": {
            "name": "Stanford University School of Medicine",
            "address": {
              "city": "Stanford",
              "region": "California",
              "country": "US"
            },
            "disambiguated-organization": null
          },
          "visibility": "PUBLIC",
          "put-code": 1006,
          "path": "/0000-0001-5109-3700/education/1006"
        }
      ],
      "path": "/0000-0001-5109-3700/educations"
    }
  }  
}
        """)
        self.crosswalker.crosswalk(orcid_profile, self.person_uri, self.graph)
        self.assertTrue(
            bool(
                self.graph.query("""
            ask where {
                ?org a foaf:Organization .
                ?org rdfs:label "Stanford University School of Medicine" .
                ?org obo:RO_0001025 ?geo .
                ?geo rdfs:label "Stanford, California" .
                ?awdgreproc a vivo:EducationalProcess .
                ?awdgreproc obo:RO_0000057 ?org, d:test .
                filter not exists {
                    ?awdgreproc vivo:departmentOrSchool ?awdgredept .
                }
            }
        """)))
コード例 #8
0
class TestAffiliations(TestCase):

    def setUp(self):
        self.graph = Graph(namespace_manager=ns.ns_manager)
        self.person_uri = ns.D["test"]
        self.create_strategy = SimpleCreateEntitiesStrategy(HashIdentifierStrategy(), person_uri=self.person_uri)
        self.crosswalker = AffiliationsCrosswalk(identifier_strategy=self.create_strategy,
                                                 create_strategy=self.create_strategy)

    def test_no_affiliations(self):
        orcid_profile = json.loads("""
{
  "activities-summary": {
  }
}
        """)
        self.crosswalker.crosswalk(orcid_profile, self.person_uri, self.graph)
        self.assertEqual(0, len(self.graph))

    def test_no_education(self):
        orcid_profile = json.loads("""
{
  "activities-summary": {
    "educations": {
        "education-summary": []
    }
  }
}
""")
        self.crosswalker.crosswalk(orcid_profile, self.person_uri, self.graph)
        self.assertEqual(0, len(self.graph))

    def test_education(self):
        orcid_profile = json.loads("""
{
  "activities-summary": {
    "educations": {
      "last-modified-date": {
        "value": 1486085029078
      },
      "education-summary": [
        {
          "created-date": {
            "value": 1385568459467
          },
          "last-modified-date": {
            "value": 1486085026897
          },
          "source": {
            "source-orcid": {
              "uri": "http://orcid.org/0000-0001-5109-3700",
              "path": "0000-0001-5109-3700",
              "host": "orcid.org"
            },
            "source-client-id": null,
            "source-name": {
              "value": "Laurel L Haak"
            }
          },
          "department-name": "Neurosciences",
          "role-title": "PhD",
          "start-date": {
            "year": {
              "value": "1995"
            },
            "month": null,
            "day": null
          },
          "end-date": {
            "year": {
              "value": "1997"
            },
            "month": null,
            "day": null
          },
          "organization": {
            "name": "Stanford University School of Medicine",
            "address": {
              "city": "Stanford",
              "region": "California",
              "country": "US"
            },
            "disambiguated-organization": null
          },
          "visibility": "PUBLIC",
          "put-code": 1006,
          "path": "/0000-0001-5109-3700/education/1006"
        }
      ],
      "path": "/0000-0001-5109-3700/educations"
    }
  }  
}
        """)
        # Changed start date to 1995
        self.crosswalker.crosswalk(orcid_profile, self.person_uri, self.graph)
        self.assertTrue(bool(self.graph.query("""
            ask where {
                ?awdgre a vivo:AwardedDegree .
                ?awdgre rdfs:label "PhD" .
                ?awdgre obo:RO_0002353 ?awdgreproc .
                ?awdgre vivo:assignedBy ?org .
                ?awdgre vivo:relates d:test, ?dgre .
                ?org a foaf:Organization .
                ?org rdfs:label "Stanford University School of Medicine" .
                ?org obo:RO_0001025 ?geo .
                ?geo rdfs:label "Stanford, California" .
                ?awdgreproc a vivo:EducationalProcess .
                ?awdgreproc obo:RO_0000057 ?org, d:test .
                ?awdgreproc vivo:dateTimeInterval ?awdgreprocint .
                ?awdgreproc vivo:departmentOrSchool "Neurosciences" .
                ?awdgreprocint a vivo:DateTimeInterval .
                ?awdgreprocint vivo:end ?awdgreprocintend .
                ?awdgreprocintend a vivo:DateTimeValue .
                ?awdgreprocintend rdfs:label "1997" .
                ?awdgreprocintend vivo:dateTime "1997-01-01T00:00:00"^^xsd:dateTime .
                ?awdgreprocintend vivo:dateTimePrecision vivo:yearPrecision .
                ?awdgreprocint vivo:start ?awdgreprocintstart .
                ?awdgreprocintstart a vivo:DateTimeValue .
                ?awdgreprocintstart rdfs:label "1995" .
                ?awdgreprocintstart vivo:dateTime "1995-01-01T00:00:00"^^xsd:dateTime .
                ?awdgreprocintstart vivo:dateTimePrecision vivo:yearPrecision .
            }
        """)))

    def test_education_minimal(self):
        orcid_profile = json.loads("""
{
  "activities-summary": {
    "educations": {
      "last-modified-date": {
        "value": 1486085029078
      },
      "education-summary": [
        {
          "created-date": {
            "value": 1385568459467
          },
          "last-modified-date": {
            "value": 1486085026897
          },
          "source": {
            "source-orcid": {
              "uri": "http://orcid.org/0000-0001-5109-3700",
              "path": "0000-0001-5109-3700",
              "host": "orcid.org"
            },
            "source-client-id": null,
            "source-name": {
              "value": "Laurel L Haak"
            }
          },
          "department-name": null,
          "role-title": "PhD",
          "start-date": null,
          "end-date": null,
          "organization": {
            "name": "Stanford University School of Medicine",
            "address": {
              "city": "Stanford",
              "region": "California",
              "country": "US"
            },
            "disambiguated-organization": null
          },
          "visibility": "PUBLIC",
          "put-code": 1006,
          "path": "/0000-0001-5109-3700/education/1006"
        }
      ],
      "path": "/0000-0001-5109-3700/educations"
    }
  }  
}
        """)
        self.crosswalker.crosswalk(orcid_profile, self.person_uri, self.graph)
        self.assertTrue(bool(self.graph.query("""
            ask where {
                ?org a foaf:Organization .
                ?org rdfs:label "Stanford University School of Medicine" .
                ?org obo:RO_0001025 ?geo .
                ?geo rdfs:label "Stanford, California" .
                ?awdgreproc a vivo:EducationalProcess .
                ?awdgreproc obo:RO_0000057 ?org, d:test .
                filter not exists {
                    ?awdgreproc vivo:departmentOrSchool ?awdgredept .
                }
            }
        """)))