Beispiel #1
0
def create_status_uri(g):
  status_list = ['In oprichting', 'Actief', 'Niet Actief']
  status_concept_scheme, uuid = concept_uri(ns.gift + 'concept-schemes/', 'OrganizationStatusCode')
  g.add((status_concept_scheme, RDF.type, SKOS.ConceptScheme))
  g.add((status_concept_scheme, SKOS.prefLabel, Literal('Organisatie status code')))
  g.add((status_concept_scheme, ns.mu.uuid, Literal(uuid)))

  for status in status_list:
    concept, uuid = concept_uri(ns.gift + 'concepts/', status)
    g.add((concept, RDF.type, ns.gift_v.OrganisatieStatusCode))
    g.add((concept, SKOS.prefLabel, Literal(status)))
    g.add((concept, SKOS.topConceptOf, status_concept_scheme))
    g.add((concept, SKOS.inScheme, status_concept_scheme))
    g.add((concept, ns.mu.uuid, Literal(uuid)))
Beispiel #2
0
def create_type_helft(g):
  type_helft_list = ['Kleine helft', 'Grote helft']

  ere_th_concept_scheme, ere_th_uuid = concept_uri(ns.gift + 'concept-schemes/', 'HelftVerkiezing')
  g.add((ere_th_concept_scheme, RDF.type, SKOS.ConceptScheme))
  g.add((ere_th_concept_scheme, SKOS.prefLabel, Literal('Helft verkiezing')))
  g.add((ere_th_concept_scheme, ns.mu.uuid, Literal(ere_th_uuid)))

  for type_helft in type_helft_list:
    concept, uuid = concept_uri(ns.gift + 'concepts/', type_helft)
    g.add((concept, RDF.type, ns.gift_v.HelftVerkiezing))
    g.add((concept, SKOS.prefLabel, Literal(type_helft)))
    g.add((concept, SKOS.topConceptOf, ere_th_concept_scheme))
    g.add((concept, SKOS.inScheme, ere_th_concept_scheme))
    g.add((concept, ns.mu.uuid, Literal(uuid)))
Beispiel #3
0
def create_type_involvement_ere(g):
  types_involvement_list = ['Toezichthoudend en financierend', 'Enkel adviserend', 'Deel van gebiedsomschrijving']

  types_involvement_concept_scheme, uuid = concept_uri(ns.gift + 'concept-schemes/', 'TypeBetrokkenheid')
  g.add((types_involvement_concept_scheme, RDF.type, SKOS.ConceptScheme))
  g.add((types_involvement_concept_scheme, SKOS.prefLabel, Literal('Type Betrokkenheid')))
  g.add((types_involvement_concept_scheme, ns.mu.uuid, Literal(uuid)))

  for type_invol in types_involvement_list:
    concept, uuid = concept_uri(ns.gift + 'concepts/', type_invol)
    g.add((concept, RDF.type, ns.gift_v.TypeBetrokkenheid))
    g.add((concept, SKOS.prefLabel, Literal(type_invol)))
    g.add((concept, SKOS.topConceptOf, types_involvement_concept_scheme))
    g.add((concept, SKOS.inScheme, types_involvement_concept_scheme))
    g.add((concept, ns.mu.uuid, Literal(uuid)))
Beispiel #4
0
def create_type_ere(g):
  type_list = ['Islamitisch', 'Orthodox', 'Protestants', 'Rooms-Katholiek', 'Anglicaans', 'Israëlitisch']

  ere_te_concept_scheme, ere_te_uuid = concept_uri(ns.gift + 'concept-schemes/', 'TypeEredienst')
  g.add((ere_te_concept_scheme, RDF.type, SKOS.ConceptScheme))
  g.add((ere_te_concept_scheme, SKOS.prefLabel, Literal('Type eredienst')))
  g.add((ere_te_concept_scheme, ns.mu.uuid, Literal(ere_te_uuid)))

  for type_ere in type_list:
    concept, uuid = concept_uri(ns.gift + 'concepts/', type_ere)
    g.add((concept, RDF.type, ns.gift_v.TypeEredienst))
    g.add((concept, SKOS.prefLabel, Literal(type_ere)))
    g.add((concept, SKOS.topConceptOf, ere_te_concept_scheme))
    g.add((concept, SKOS.inScheme, ere_te_concept_scheme))
    g.add((concept, ns.mu.uuid, Literal(uuid)))
Beispiel #5
0
def financering_bedinaar_functies(g):
  financering_list = ['FOD Financiën', 'Zelf gefinancierd']
                  
  financering_concept_scheme, uuid = concept_uri(ns.gift + 'concept-schemes/', 'BedienaarFinanceringCode')
  g.add((financering_concept_scheme, RDF.type, SKOS.ConceptScheme))
  g.add((financering_concept_scheme, SKOS.prefLabel, Literal('Bedienaar Financering Code')))
  g.add((financering_concept_scheme, ns.mu.uuid, Literal(uuid)))

  for financering in financering_list:
    concept, uuid = concept_uri(ns.gift + 'concepts/', financering)
    g.add((concept, RDF.type, ns.gift_v.BedienaarFinanceringCode))
    g.add((concept, SKOS.prefLabel, Literal(financering)))
    g.add((concept, SKOS.topConceptOf, financering_concept_scheme))
    g.add((concept, SKOS.inScheme, financering_concept_scheme))
    g.add((concept, ns.mu.uuid, Literal(uuid)))
Beispiel #6
0
def vestiging_types(g):
  vestiging_type_list = ['Maatschappelijke zetel', 'Hoofdgebouw erediensten']
                  
  vestiging_type_concept_scheme, uuid = concept_uri(ns.gift + 'concept-schemes/', '+ TypeVestiging')
  g.add((vestiging_type_concept_scheme, RDF.type, SKOS.ConceptScheme))
  g.add((vestiging_type_concept_scheme, SKOS.prefLabel, Literal('Type Vestiging')))
  g.add((vestiging_type_concept_scheme, ns.mu.uuid, Literal(uuid)))

  for vestiging_type in vestiging_type_list:
    concept, uuid = concept_uri(ns.gift + 'concepts/', vestiging_type)
    g.add((concept, RDF.type, ns.gift_v.TypeVestiging))
    g.add((concept, SKOS.prefLabel, Literal(vestiging_type)))
    g.add((concept, SKOS.topConceptOf, vestiging_type_concept_scheme))
    g.add((concept, SKOS.inScheme, vestiging_type_concept_scheme))
    g.add((concept, ns.mu.uuid, Literal(uuid)))
Beispiel #7
0
def document_type_criterion(g):
  document_type_criterion_list = ['Bijlage goedkeuring door het Representatief orgaan', 'Bewijststuk status inburgeringsplicht', 'Arbeidskaart',
                                  'Bewijststuk verblijfsvergunning']
  
  document_type_concept_scheme, uuid = concept_uri(ns.gift + 'concept-schemes/', 'BedinaarCriteriumBewijsstuk')
  g.add((document_type_concept_scheme, RDF.type, SKOS.ConceptScheme))
  g.add((document_type_concept_scheme, SKOS.prefLabel, Literal('Bedinaar Criterium Bewijsstuk')))
  g.add((document_type_concept_scheme, ns.mu.uuid, Literal(uuid)))

  for doc_type in document_type_criterion_list:
    concept, uuid = concept_uri(ns.gift + 'concepts/', doc_type)
    g.add((concept, RDF.type, ns.gift_v.BedinaarCriteriumBewijsstuk))
    g.add((concept, SKOS.prefLabel, Literal(doc_type)))
    g.add((concept, SKOS.topConceptOf, document_type_concept_scheme))
    g.add((concept, SKOS.inScheme, document_type_concept_scheme))
    g.add((concept, ns.mu.uuid, Literal(uuid)))
Beispiel #8
0
def bedinaar_criterion_ere(g): 
  bedinaar_criterion_list = ['Bevestiging door het representatief orgaan', 'Inburgeringsplicht (niet EU bedienaren)', 'Arbeidsvergunning (niet EU bedienaren)'
                'Verblijfsvergunning (niet EU bedienaren)']

  bedinaar_concept_scheme, uuid = concept_uri(ns.gift + 'concept-schemes/', 'VoorwaardenBedinaarCriterium')
  g.add((bedinaar_concept_scheme, RDF.type, SKOS.ConceptScheme))
  g.add((bedinaar_concept_scheme, SKOS.prefLabel, Literal('Voorwaarden Bedinaar Criterium')))
  g.add((bedinaar_concept_scheme, ns.mu.uuid, Literal(uuid)))

  for criterion in bedinaar_criterion_list:
    concept, uuid = concept_uri(ns.gift + 'concepts/', criterion)
    g.add((concept, RDF.type, ns.gift_v.VoorwaardenBedinaarCriterium))
    g.add((concept, SKOS.prefLabel, Literal(criterion)))
    g.add((concept, SKOS.topConceptOf, bedinaar_concept_scheme))
    g.add((concept, SKOS.inScheme, bedinaar_concept_scheme))
    g.add((concept, ns.mu.uuid, Literal(uuid)))
Beispiel #9
0
def create_change_event_ere(g):
  change_event_type_list = ['Erkenning aangevraagd', 'Erkenning toegekend', 'Erkenning niet toegekend', 'Samenvoeging', 
                            'Wijziging Gebiedsomschrijving', 'Naamswijziging', 'Erkenning opgeheven', 'Onder sanctieregime',
                            'Opschorting Erkenning']

  change_event_concept_scheme, uuid = concept_uri(ns.gift + 'concept-schemes/', 'Veranderingsgebeurtenis')
  g.add((change_event_concept_scheme, RDF.type, SKOS.ConceptScheme))
  g.add((change_event_concept_scheme, SKOS.prefLabel, Literal('Veranderingsgebeurtenis types')))
  g.add((change_event_concept_scheme, ns.mu.uuid, Literal(uuid)))

  for change_event in change_event_type_list:
    concept, uuid = concept_uri(ns.gift + 'concepts/', change_event)
    g.add((concept, RDF.type, ns.gift_v.Veranderingsgebeurtenis))
    g.add((concept, SKOS.prefLabel, Literal(change_event)))
    g.add((concept, SKOS.topConceptOf, change_event_concept_scheme))
    g.add((concept, SKOS.inScheme, change_event_concept_scheme))
    g.add((concept, ns.mu.uuid, Literal(uuid)))
Beispiel #10
0
def rol_bedinaar_functies(g):
  functies_list = ['Vervanger', 'Pastoor', 'Kerkbedienaar', 'Kapelaan', 'Onderpastoor', 'Parochieassistent', 'Eerste predikant', 'Tweede predikant bij het voorzitterschap van de Synode',
                   'Predikant bij het voorzitterschap van de Synode', 'Secretaris bij het voorzitterschap van de Synode', 'Hulppredikant', 'Pastoor-deken', 'Bedienaar',
                   'Kapelaan van de kerken te Antwerpen en te Elsene (Geünifieerde anglikaanse kerk)', 'Kapelaan van de andere kerken', 'Rabbijn', 'Officiërend bedienaar',
                   'Eerste Imam in rang', 'Tweede Imam in rang', 'Derde Imam in rang']
                  
  bedinaar_functie_concept_scheme, uuid = concept_uri(ns.gift + 'concept-schemes/', 'EredienstBeroepen')
  g.add((bedinaar_functie_concept_scheme, RDF.type, SKOS.ConceptScheme))
  g.add((bedinaar_functie_concept_scheme, SKOS.prefLabel, Literal('Eredienst Beroepen')))
  g.add((bedinaar_functie_concept_scheme, ns.mu.uuid, Literal(uuid)))

  for functie in functies_list:
    concept, uuid = concept_uri(ns.gift + 'concepts/', functie)
    g.add((concept, RDF.type, ns.gift_v.EredienstBeroepen))
    g.add((concept, SKOS.prefLabel, Literal(functie)))
    g.add((concept, SKOS.topConceptOf, bedinaar_functie_concept_scheme))
    g.add((concept, SKOS.inScheme, bedinaar_functie_concept_scheme))
    g.add((concept, ns.mu.uuid, Literal(uuid)))
Beispiel #11
0
def create_bestuursorgaan_ere(g):
  bestuursorgaan_classification_code = ['Kerkraad', 'Kathedrale kerkraad', 'Bestuursraad', 'Kerkfabriekraad', 'Comité', 'Centraal kerkbestuur', 
                                        'Centraal bestuur']
  
  ere_bo_concept_scheme = URIRef(ns.c + 'BestuursorgaanClassificatieCode')
  g.add((ere_bo_concept_scheme, RDF.type, SKOS.ConceptScheme))
  g.add((ere_bo_concept_scheme, SKOS.prefLabel, Literal('Bestuursorgaan classificatie code')))

  for borgaan in bestuursorgaan_classification_code:
    concept, uuid = concept_uri(ns.c + 'BestuursorgaanClassificatieCode/', borgaan)
    g.add((concept, RDF.type, ns.gift_v.BestuursorgaanClassificatieCode))
    g.add((concept, SKOS.prefLabel, Literal(borgaan)))
    g.add((concept, SKOS.topConceptOf, ere_bo_concept_scheme))
    g.add((concept, SKOS.inScheme, ere_bo_concept_scheme))
    g.add((concept, ns.mu.uuid, Literal(uuid)))
Beispiel #12
0
def create_bestuursfuncie_ere(g):
  ere_bestuursfuncie_list = ['Voorzitter van het bestuur van de eredienst', 'Voorzitter van het centraal bestuur van de eredienst', 
  'Secretaris van het bestuur van de eredienst', 'Secretaris van het centraal bestuur van de eredienst', 'Penningmeester van het bestuur van de eredienst',
  'Bestuurslid van het bestuur van de eredienst', 'Bestuurslid van het centraal bestuur van de eredienst', 'Bestuurslid (van rechtswege)  van het bestuur van de eredienst',
  'Expert van het centraal bestuur van de eredienst', 'Vertegenwoordiger aangesteld door het representatief orgaan van het centraal bestuur van de eredienst']

  ere_bf_concept_scheme = URIRef(ns.cs + 'BestuursfunctieCode')
  g.add((ere_bf_concept_scheme, RDF.type, SKOS.ConceptScheme))
  g.add((ere_bf_concept_scheme, SKOS.prefLabel, Literal('Bestuursfunctie code')))

  for bfunctie in ere_bestuursfuncie_list:
    concept, uuid = concept_uri(ns.c + 'BestuursfunctieCode/', bfunctie)
    g.add((concept, RDF.type, ns.gift_v.BestuursfunctieCode))
    g.add((concept, SKOS.prefLabel, Literal(bfunctie)))
    g.add((concept, SKOS.topConceptOf, ere_bf_concept_scheme))
    g.add((concept, SKOS.inScheme, ere_bf_concept_scheme))
    g.add((concept, ns.mu.uuid, Literal(uuid)))
Beispiel #13
0
def main():
    graph = Graph()
    graph.parse('output/20210830182209-codelist-nationality-complete.ttl')

    query = """
            SELECT ?concept ?label ?adjective
            WHERE { 
              ?concept a euvoc:Country; skos:prefLabel ?label; skos-xl:altLabel [ a skos-xl:Label; rdfs:label ?adjective; 
              dct:type <http://publications.europa.eu/resource/authority/label-type/ADJECTIVE> ]
              FILTER(lang(?label) = 'nl') 
              FILTER(lang(?adjective) = 'nl')
            }
          """

    namespaces = {
        "euvoc": URIRef("http://publications.europa.eu/ontology/euvoc#"),
        "skos": SKOS,
        "skos-xl": URIRef("http://www.w3.org/2008/05/skos-xl#"),
        "rdfs": RDFS,
        "dct": URIRef("http://purl.org/dc/terms/")
    }

    qres = graph.query(query, initNs=namespaces)

    nationality_graph = Graph()

    if qres.bindings:
        for row in qres:
            nationality_concept = URIRef(f'{row.concept}')
            _, nationality_uuid = concept_uri(ns.euvoc.Country,
                                              f'{row.concept}')
            nationality_graph.add(
                (nationality_concept, RDF.type, ns.euvoc.Country))
            nationality_graph.add(
                (nationality_concept, ns.mu.uuid, Literal(nationality_uuid)))
            nationality_graph.add(
                (nationality_concept, SKOS.prefLabel, Literal(f'{row.label}')))
            nationality_graph.add(
                (nationality_concept, RDFS.label, Literal(f'{row.adjective}')))

    export_data(nationality_graph, 'codelist-nationality')
Beispiel #14
0
def main(file, mode):
    national_raw = pd.read_excel(file)

    lblod = ns.get_namespace(mode)

    codelist_ere = load_graph('codelist-ere')

    g = Graph()

    for _, row in national_raw.iterrows():
        abb_id, abb_uuid = concept_uri(lblod + 'representatieveOrganen/',
                                       str(row['representatief orgaan']))
        #g.add((abb_id, RDF.type, ns.org.Organization))
        g.add((abb_id, RDF.type, ns.ere.RepresentatiefOrgaan))
        add_literal(g, abb_id, ns.mu.uuid, abb_uuid, XSD.string)

        add_literal(g, abb_id, SKOS.prefLabel,
                    str(row['representatief orgaan']), XSD.string)

        #g.add((abb_id, RDFS.subClassOf, ns.org.Organization))
        #g.add((abb_id, RDFS.subClassOf, ns.org.RegisteredOrganization))

        if str(row['Type Eredienst']) != str(np.nan):
            type_ere = get_concept_id(codelist_ere, str(row['Type Eredienst']))
            g.add((abb_id, ns.ere.typeEredienst, type_ere))

        status = get_concept_id(codelist_ere, str(row['Status']))
        g.add((abb_id, ns.rov.orgStatus, status))

        id_class, id_uuid = concept_uri(lblod + 'identificatoren/',
                                        str(row['KBO_nr']) + 'identificatoren')
        g.add((id_class, RDF.type, ns.adms.Identifier))
        add_literal(g, id_class, SKOS.notation, 'KBO nummer', XSD.string)
        add_literal(g, id_class, ns.mu.uuid, id_uuid, XSD.string)

        kbo_uri, kbo_uuid = concept_uri(
            lblod + 'gestructureerdeIdentificatoren/',
            str(row['KBO_nr']) + 'gestructureerdeIdentificatoren')
        g.add((kbo_uri, RDF.type, ns.generiek.GestructureerdeIdentificator))
        add_literal(g, kbo_uri, ns.mu.uuid, kbo_uuid, XSD.string)
        add_literal(g, kbo_uri, ns.generiek.lokaleIdentificator,
                    str(row['KBO_nr']), XSD.string)
        g.add((id_class, ns.generiek.gestructureerdeIdentificator, kbo_uri))

        g.add((abb_id, ns.adms.identifier, id_class))

        site_id, site_uuid = concept_uri(
            lblod + 'vestigingen/',
            str(row['representatief orgaan']) + 'vestigingen')
        g.add((site_id, RDF.type, ns.org.Site))
        add_literal(g, site_id, ns.mu.uuid, site_uuid, XSD.string)

        contact_id, contact_uuid = concept_uri(
            lblod + 'contact-punten/',
            str(row['representatief orgaan']) + 'contact-punten/1')
        g.add((contact_id, RDF.type, ns.schema.ContactPoint))
        add_literal(g, contact_id, ns.mu.uuid, contact_uuid, XSD.string)
        add_literal(g, contact_id, FOAF.page, str(row['Website']), XSD.anyURI)
        add_literal(g, contact_id, ns.schema.telephone, str(row['Telefoon']),
                    XSD.string)
        add_literal(g, contact_id, ns.schema.faxNumber, str(row['Fax']),
                    XSD.string)
        g.add((site_id, ns.schema.siteAddress, contact_id))

        if str(row['Telefoon 2']) != str(np.nan) or str(row['Fax 2']) != str(
                np.nan):
            contact_2_id, contact_2_uuid = concept_uri(
                lblod + 'contact-punten/',
                str(row['representatief orgaan']) + 'contact-punten/2')
            g.add((contact_2_id, RDF.type, ns.schema.ContactPoint))
            add_literal(g, contact_2_id, ns.mu.uuid, contact_2_uuid,
                        XSD.string)
            add_literal(g, contact_2_id, ns.schema.telephone,
                        str(row['Telefoon 2']), XSD.string)
            add_literal(g, contact_2_id, ns.schema.faxNumber,
                        str(row['Fax 2']), XSD.string)
            g.add((site_id, ns.schema.siteAddress, contact_2_id))

        address_id, address_uuid = concept_uri(
            lblod + 'adressen/',
            str(row['representatief orgaan']) + 'adressen')
        g.add((address_id, RDF.type, ns.locn.Address))
        add_literal(g, address_id, ns.mu.uuid, address_uuid, XSD.string)
        add_literal(g, address_id, ns.locn.thoroughfare,
                    str(row['Straatnaam']), XSD.string)
        add_literal(g, address_id, ns.adres['Adresvoorstelling.huisnummer'],
                    str(row['Huisnummer']), XSD.string)
        add_literal(g, address_id, ns.adres['Adresvoorstelling.busnummer'],
                    str(row['Busnummer']), XSD.string)
        add_literal(g, address_id, ns.locn.postCode, str(row['Postcode']),
                    XSD.string)
        add_literal(g, address_id, ns.adres.gemeentenaam,
                    str(row['Gemeentenaam']), XSD.string)
        add_literal(g, address_id, ns.locn.adminUnitL2, str(row['Provincie']),
                    XSD.string)
        add_literal(g, address_id, ns.adres.land, 'België', XSD.string)

        add_literal(
            g, address_id, ns.locn.fullAddress,
            get_full_address(str(row['Straatnaam']), str(row['Huisnummer']),
                             str(row['Busnummer']), str(row['Postcode']),
                             str(row['Gemeentenaam'])), XSD.string)

        g.add((site_id, ns.organisatie.bestaatUit, address_id))

        g.add((abb_id, ns.org.hasPrimarySite, site_id))

        person_id, person_uuid = concept_uri(
            lblod + 'personen/',
            str(row['Voornaam']) + str(row['Achternaam']) +
            str(row['Gebruikte Voornaam']))
        g.add((person_id, RDF.type, ns.person.Person))
        add_literal(g, person_id, ns.mu.uuid, person_uuid, XSD.string)
        add_literal(g, person_id, FOAF.givenName, str(row['Voornaam']),
                    XSD.string)
        add_literal(g, person_id, FOAF.familyName, str(row['Achternaam']),
                    XSD.string)
        add_literal(g, person_id, ns.persoon.gebruikteVoornaam,
                    str(row['Gebruikte Voornaam']), XSD.string)

        role_id, role_uuid = concept_uri(lblod + 'rollen/', str(row['Rol']))
        g.add((role_id, RDF.type, ns.org.Role))
        add_literal(g, role_id, ns.mu.uuid, role_uuid, XSD.string)
        add_literal(g, role_id, SKOS.prefLabel, str(row['Rol']), XSD.string)

        position_id, position_uuid = concept_uri(
            lblod + 'posities/',
            str(row['representatief orgaan']) + str(row['Rol']))
        g.add((position_id, RDF.type, ns.org.Post))
        add_literal(g, position_id, ns.mu.uuid, position_uuid, XSD.string)
        g.add((position_id, ns.org.role, role_id))
        #g.add((position_id, ns.org.postIn, abb_id))
        g.add((abb_id, ns.org.hasPost, position_id))

        person_position_id, person_position_uuid = concept_uri(
            lblod + 'agentenInPositie/',
            str(row['representatief orgaan']) + str(row['Voornaam']) +
            str(row['Achternaam']) + str(row['Rol']))
        g.add((person_position_id, RDF.type, ns.organisatie.AgentInPositie))
        add_literal(g, person_position_id, ns.mu.uuid, person_position_uuid,
                    XSD.string)
        g.add((person_position_id, ns.org.holds, position_id))
        g.add((person_position_id, ns.org.heldBy, person_id))

    export_data(g, f'national-{mode}')
Beispiel #15
0
def main(file, mode):
    worship_cleansed = get_cleansed_data(file, 'worship')

    lblod = ns.get_namespace(mode)

    g = Graph()
    codelist_ere = load_graph('codelist-ere')
    codelist_bestuurseenheid = load_graph('bestuurseenheid-classificatie-code')
    locations = load_graph('locations')
    central_cleansed = get_cleansed_data(file, 'central')
    central_graph = load_graph('central')
    worship_bestuurseenheid_classification_id = get_concept_id(
        codelist_bestuurseenheid, 'Bestuur van de eredienst')
    VESTIGING_TYPE = URIRef(
        'http://lblod.data.gift/concepts/f1381723dec42c0b6ba6492e41d6f5dd')

    print("########### Mapping started #############")

    for _, row in worship_cleansed.iterrows():
        abb_id, abb_uuid = concept_uri(lblod + 'besturenVanDeEredienst/',
                                       str(row['organization_id']))
        #g.add((abb_id, RDF.type, ns.org.Organization))
        #g.add((abb_id, RDF.type, ns.besluit.Bestuurseenheid))
        g.add((abb_id, RDF.type, ns.ere.BestuurVanDeEredienst))

        add_literal(g, abb_id, ns.mu.uuid, abb_uuid, XSD.string)

        add_literal(g, abb_id, SKOS.prefLabel, str(row['Naam_EB']), XSD.string)
        #add_literal(g, abb_id, ns.rov.legalName, str(row['Naam_EB']), XSD.string)

        g.add((abb_id, ns.org.classification,
               worship_bestuurseenheid_classification_id))

        if str(row['Type_eredienst Cleansed']) != str(np.nan):
            type_ere = get_concept_id(codelist_ere,
                                      str(row['Type_eredienst Cleansed']))
            g.add((abb_id, ns.ere.typeEredienst, type_ere))

        add_literal(g, abb_id, ns.ere.grensoverschrijdend,
                    str(row['Grensoverschrijdend']), XSD.boolean)

        add_literal(g, abb_id, ns.ere.denominatie,
                    str(row['Strekking Cleansed']), XSD.string)

        status = get_concept_id(codelist_ere, str(row['Status_EB Cleansed']))
        g.add((abb_id, ns.rov.orgStatus, status))

        central_titel = str(row['Naam_CKB_EB1'])
        if central_titel != str(np.nan):
            central_kbo, central_name = find_central_info(
                central_cleansed, central_titel)
            ckb_id = find_central_entity(central_graph, central_titel,
                                         central_kbo, central_name)
            #print("out ", central_kbo, central_name)
            g.add((ckb_id, ns.org.hasSubOrganization, abb_id))

        if str(row['Representatief orgaan']) != str(np.nan):
            national_id, _ = concept_uri(lblod + 'representatieveOrganen/',
                                         str(row['Representatief orgaan']))
            g.add((national_id, ns.org.linkedTo, abb_id))

        bo_id, bo_uuid = concept_uri(
            lblod + 'eredienstbestuursorganen/',
            str(row['organization_id']) + 'eredienstbestuursorganen')
        g.add((bo_id, RDF.type, ns.besluit.Bestuursorgaan))
        #g.add((bo_id, RDF.type, ns.ere.Eredienstbestuursorgaan))
        add_literal(g, bo_id, ns.mu.uuid, bo_uuid, XSD.string)

        if str(row['Bestuursorgaan Type']) != str(np.nan):
            bestuursorgaan_classification_id = get_concept_id(
                codelist_ere, str(row['Bestuursorgaan Type']))
            g.add((bo_id, ns.org.classification,
                   bestuursorgaan_classification_id))

        g.add((bo_id, ns.besluit.bestuurt, abb_id))

        if str(row['KBO_EB Cleansed']) != str(np.nan):
            id_class, id_uuid = concept_uri(
                lblod + 'identificatoren/',
                str(row['KBO_EB Cleansed']) + 'identificatoren')
            g.add((id_class, RDF.type, ns.adms.Identifier))
            add_literal(g, id_class, SKOS.notation, 'KBO nummer', XSD.string)
            add_literal(g, id_class, ns.mu.uuid, id_uuid, XSD.string)

            kbo_id, kbo_uuid = concept_uri(
                lblod + 'gestructureerdeIdentificatoren/',
                str(row['KBO_EB Cleansed']) + 'gestructureerdeIdentificatoren')
            g.add((kbo_id, RDF.type, ns.generiek.GestructureerdeIdentificator))
            add_literal(g, kbo_id, ns.mu.uuid, kbo_uuid, XSD.string)
            add_literal(g, kbo_id, ns.generiek.lokaleIdentificator,
                        str(row['KBO_EB Cleansed']), XSD.string)
            g.add((id_class, ns.generiek.gestructureerdeIdentificator, kbo_id))

            g.add((abb_id, ns.adms.identifier, id_class))

        if str(row['Titel']) != str(np.nan):
            id_class, id_uuid = concept_uri(
                lblod + 'identificatoren/',
                str(row['Titel']) + 'identificatoren')
            g.add((id_class, RDF.type, ns.adms.Identifier))
            add_literal(g, id_class, SKOS.notation, 'SharePoint identificator',
                        XSD.string)
            add_literal(g, id_class, ns.mu.uuid, id_uuid, XSD.string)

            naam_uri, naam_uuid = concept_uri(
                lblod + 'gestructureerdeIdentificator/',
                str(row['Titel']) + 'gestructureerdeIdentificator')
            g.add(
                (naam_uri, RDF.type, ns.generiek.GestructureerdeIdentificator))
            add_literal(g, naam_uri, ns.mu.uuid, naam_uuid, XSD.string)
            add_literal(g, naam_uri, ns.generiek.lokaleIdentificator,
                        str(row['Titel']), XSD.string)
            g.add(
                (id_class, ns.generiek.gestructureerdeIdentificator, naam_uri))

            g.add((abb_id, ns.adms.identifier, id_class))

        if row['Change Event Cleansed'] != '{}':
            change_events_ = row['Change Event Cleansed']
            json_acceptable_string = change_events_.replace("'", "\"")
            change_events = json.loads(json_acceptable_string)

            for key, value in change_events.items():
                change_event_id = get_concept_id(codelist_ere, key)

                ce_id, ce_uuid = concept_uri(
                    lblod + 'veranderingsgebeurtenissen/',
                    abb_uuid + row['Change Event Cleansed'])
                g.add((ce_id, RDF.type, ns.org.ChangeEvent))
                add_literal(g, ce_id, ns.mu.uuid, ce_uuid, XSD.string)
                g.add((ce_id, ns.ch.typeWijziging, change_event_id))
                add_literal(g, ce_id, DCTERMS.date, value, XSD.dateTime)
                add_literal(g, ce_id, DCTERMS.description, row['Statusinfo'],
                            XSD.string)

                if key == 'Opschorting Erkenning':
                    g.add((ce_id, ns.org.originalOrganization, abb_id))
                    g.add((abb_id, ns.org.changedBy, ce_id))
                else:
                    g.add((ce_id, ns.org.resultingOrganization, abb_id))
                    g.add((abb_id, ns.org.resultedFrom, ce_id))

        local_eng = row['Local Engagement Cleansed']
        json_acceptable_string = local_eng.replace("'", "\"")
        local_eng = json.loads(json_acceptable_string)

        if len(local_eng['Cross-Border']) > 0:
            type_involvement_perc_not_null = get_concept_id(
                codelist_ere, 'Toezichthoudend en financierend')
            type_involvement_perc_null = get_concept_id(
                codelist_ere, 'Deel van gebiedsomschrijving')
            for municipality, perc in local_eng['Municipality'].items():
                municipality_res = get_adm_unit_concept(
                    municipality, "Gemeente")
                if municipality_res != None:
                    municipality_adminunit = URIRef(
                        municipality_res['s']['value'])
                    pi_id, pi_uuid = concept_uri(
                        lblod + 'betrokkenLokaleBesturen/',
                        municipality + abb_uuid)
                    g.add((pi_id, RDF.type, ns.ere.BetrokkenLokaleBesturen))
                    add_literal(g, pi_id, ns.mu.uuid, pi_uuid, XSD.string)
                    if perc != 0:
                        g.add((pi_id, ns.ere.typebetrokkenheid,
                               type_involvement_perc_not_null))
                    else:
                        g.add((pi_id, ns.ere.typebetrokkenheid,
                               type_involvement_perc_null))

                    add_literal(g, pi_id, ns.ere.financieringspercentage,
                                str(perc), XSD.float)
                    g.add((pi_id, ns.org.organization, abb_id))

                    g.add((municipality_adminunit, ns.ere.betrokkenBestuur,
                           pi_id))
                    g.add((municipality_adminunit, RDF.type,
                           ns.besluit.Bestuurseenheid))
                    g.add((municipality_adminunit, ns.org.classification,
                           URIRef(municipality_res['classificatie']['value'])))
                    add_literal(g, municipality_adminunit, SKOS.prefLabel,
                                municipality, XSD.string)
                    add_literal(g, municipality_adminunit, ns.mu.uuid,
                                municipality_res['uuid']['value'], XSD.string)

            for province, perc in local_eng['Province'].items():
                province_res = get_adm_unit_concept(province, "Provincie")
                if province_res != None:
                    province_adminunit = URIRef(province_res['s']['value'])
                    pi_id, pi_uuid = concept_uri(
                        lblod + 'betrokkenLokaleBesturen/',
                        province + abb_uuid)
                    g.add((pi_id, RDF.type, ns.ere.BetrokkenLokaleBesturen))
                    add_literal(g, pi_id, ns.mu.uuid, pi_uuid, XSD.string)
                    if perc != 0:
                        g.add((pi_id, ns.ere.typebetrokkenheid,
                               type_involvement_perc_not_null))
                    else:
                        g.add((pi_id, ns.ere.typebetrokkenheid,
                               type_involvement_perc_null))

                    add_literal(g, pi_id, ns.ere.financieringspercentage,
                                str(perc), XSD.float)
                    g.add((pi_id, ns.org.organization, abb_id))

                    g.add((province_adminunit, ns.ere.betrokkenBestuur, pi_id))
                    g.add((province_adminunit, RDF.type,
                           ns.besluit.Bestuurseenheid))
                    g.add((province_adminunit, ns.org.classification,
                           URIRef(province_res['classificatie']['value'])))
                    add_literal(g, province_adminunit, SKOS.prefLabel,
                                province, XSD.string)
                    add_literal(g, province_adminunit, ns.mu.uuid,
                                province_res['uuid']['value'], XSD.string)

            if len(local_eng['Cross-Border']
                   ) == 1 and local_eng['Municipality']:
                gemeente_id = get_location_id(locations,
                                              local_eng['Cross-Border'][0],
                                              'Gemeente')
                if gemeente_id != None:
                    g.add((abb_id, ns.besluit.werkingsgebied, gemeente_id))
            elif len(local_eng['Cross-Border']) == 1 and local_eng['Province']:
                provincie_id = get_location_id(locations,
                                               local_eng['Cross-Border'][0],
                                               'Provincie')
                if provincie_id != None:
                    g.add((abb_id, ns.besluit.werkingsgebied, provincie_id))
            else:
                region_label = ', '.join(local_eng['Cross-Border'])
                region_id, region_uuid = concept_uri(
                    lblod + 'werkingsgebieden/', region_label + abb_uuid)
                g.add((region_id, RDF.type, ns.prov.Location))
                add_literal(g, region_id, ns.mu.uuid, region_uuid, XSD.string)
                add_literal(g, region_id, RDFS.label, region_label, XSD.string)
                add_literal(g, region_id, ns.ext.werkingsgebiedNiveau, 'Regio',
                            XSD.string)
                g.add((abb_id, ns.besluit.werkingsgebied, region_id))

        # Vestiging
        if exists_address(row):
            site_id, site_uuid = concept_uri(
                lblod + 'vestigingen/',
                str(row['organization_id']) + 'vestigingen')
            g.add((site_id, RDF.type, ns.org.Site))
            add_literal(g, site_id, ns.mu.uuid, site_uuid, XSD.string)

            address_id, address_uuid = concept_uri(
                lblod + 'adressen/',
                str(row['organization_id']) + 'adressen')
            g.add((address_id, RDF.type, ns.locn.Address))
            add_literal(g, address_id, ns.mu.uuid, address_uuid, XSD.string)

            add_literal(g, address_id, ns.locn.thoroughfare,
                        str(row['Straat']), XSD.string)
            add_literal(g, address_id,
                        ns.adres['Adresvoorstelling.huisnummer'],
                        str(row['Huisnr Cleansed']), XSD.string)
            add_literal(g, address_id, ns.adres['Adresvoorstelling.busnummer'],
                        str(row['Busnummer Cleansed']), XSD.string)
            add_literal(g, address_id, ns.locn.postCode,
                        str(row['Postcode Cleansed']), XSD.string)
            add_literal(g, address_id, ns.adres.gemeentenaam,
                        str(row['Gemeente Cleansed']), XSD.string)
            add_literal(g, address_id, ns.locn.adminUnitL2,
                        str(row['Provincie Cleansed']), XSD.string)
            add_literal(g, address_id, ns.adres.land, 'België', XSD.string)

            add_literal(
                g, address_id, ns.locn.fullAddress,
                get_full_address(str(row['Straat']),
                                 str(row['Huisnr Cleansed']),
                                 str(row['Busnummer Cleansed']),
                                 str(row['Postcode Cleansed']),
                                 str(row['Gemeente Cleansed'])), XSD.string)

            g.add((site_id, ns.organisatie.bestaatUit, address_id))
            g.add((site_id, ns.ere.vestigingstype, VESTIGING_TYPE))
            g.add((abb_id, ns.org.hasPrimarySite, site_id))

        roles = ['voorzitter', 'secretaris', 'penningmeester', 'Lid4', 'Lid5']

        if exists_bestuursperiode_worship(row, roles):
            # Bestuursorgaan (in bestuursperiode)
            start_date_bestuur_temporary_17 = None
            end_date_bestuur_temporary_17 = None
            start_date_bestuur_temporary_20 = None
            end_date_bestuur_temporary_20 = None

            if str(row['Verkiezingen17_Opmerkingen Cleansed']) != str(np.nan):
                start_date_bestuur_temporary_17 = dateparser.parse(
                    str(row['Verkiezingen17_Opmerkingen Cleansed']))

            if str(row['Verkiezingen2020_Opmerkingen Cleansed']) != str(
                    np.nan):
                start_date_bestuur_temporary_20 = dateparser.parse(
                    str(row['Verkiezingen2020_Opmerkingen Cleansed']))

            if bool(row['Verkiezingen17']) == True:
                # Bestuursorgaan in bestuursperiode 2017-2020
                bestuur_temporary_17, bestuur_temporary_17_uuid = concept_uri(
                    lblod + 'eredienstbestuursorganen/',
                    str(row['organization_id']) +
                    'eredienstbestuursorganen/2017')
                g.add((bestuur_temporary_17, RDF.type,
                       ns.besluit.Bestuursorgaan))
                #g.add((bestuur_temporary_17, RDF.type, ns.ere.Eredienstbestuursorgaan))

                add_literal(g, bestuur_temporary_17, ns.mu.uuid,
                            bestuur_temporary_17_uuid, XSD.string)
                g.add((bestuur_temporary_17,
                       ns.generiek.isTijdspecialisatieVan, bo_id))

                # start date of governing body temporary 2017
                if start_date_bestuur_temporary_17 != None:
                    add_literal(g, bestuur_temporary_17,
                                ns.mandaat.bindingStart,
                                start_date_bestuur_temporary_17.isoformat(),
                                XSD.dateTime)

                # end date of governing body temporary 2017
                if start_date_bestuur_temporary_20 != None:
                    end_date_bestuur_temporary_17 = start_date_bestuur_temporary_20
                    #print("from 2020", end_date_bestuur_temporary_17)
                    add_literal(g, bestuur_temporary_17,
                                ns.mandaat.bindingEinde,
                                end_date_bestuur_temporary_17.isoformat(),
                                XSD.dateTime)

                elif start_date_bestuur_temporary_17 != None:
                    remain_years = 2020 - start_date_bestuur_temporary_17.year
                    #print(remain_years)
                    end_date_bestuur_temporary_17 = (
                        start_date_bestuur_temporary_17 +
                        timedelta(days=remain_years * 365)).isoformat()
                    #print("from 2017", end_date_bestuur_temporary_17)
                    add_literal(g, bestuur_temporary_17,
                                ns.mandaat.bindingEinde,
                                end_date_bestuur_temporary_17, XSD.dateTime)

            if str(row['Status_EB Cleansed']) == 'Actief':
                # Bestuursorgaan in bestuursperiode 2020-2023
                bestuur_temporary_20, bestuur_temporary_20_uuid = concept_uri(
                    lblod + 'eredienstbestuursorganen/',
                    str(row['organization_id']) +
                    'eredienstbestuursorganen/2020')
                g.add((bestuur_temporary_20, RDF.type,
                       ns.besluit.Bestuursorgaan))
                #g.add((bestuur_temporary_20, RDF.type, ns.ere.Eredienstbestuursorgaan))
                add_literal(g, bestuur_temporary_20, ns.mu.uuid,
                            bestuur_temporary_20_uuid, XSD.string)
                g.add((bestuur_temporary_20,
                       ns.generiek.isTijdspecialisatieVan, bo_id))

                if start_date_bestuur_temporary_20 != None:
                    add_literal(g, bestuur_temporary_20,
                                ns.mandaat.bindingStart,
                                start_date_bestuur_temporary_20, XSD.dateTime)

                # From 2023 the next bestuursorgaan in bestuursperiode will begin the same day
                if str(row['Type_eredienst Cleansed']) == 'Israëlitisch':
                    end_date_bestuur_temporary_20 = datetime(2023, 5,
                                                             31).isoformat()
                    add_literal(g, bestuur_temporary_20,
                                ns.mandaat.bindingEinde,
                                end_date_bestuur_temporary_20, XSD.dateTime)
                else:
                    end_date_bestuur_temporary_20 = datetime(2023, 4,
                                                             30).isoformat()
                    add_literal(g, bestuur_temporary_20,
                                ns.mandaat.bindingEinde,
                                end_date_bestuur_temporary_20, XSD.dateTime)

            person_lid_mandaat = None
            # Mandaat / Mandataris
            for role in roles:
                if exists_role_worship(
                        row, role) and exists_given_and_family_name(row, role):
                    # Person role
                    person_role, person_uuid = concept_uri(
                        lblod + 'personen/',
                        str(row[f'Naam_{role} First']) +
                        str(row[f'Naam_{role} Last']))
                    add_literal(g, person_role, FOAF.givenName,
                                str(row[f'Naam_{role} First']), XSD.string)
                    add_literal(g, person_role, FOAF.familyName,
                                str(row[f'Naam_{role} Last']), XSD.string)

                    g.add((person_role, RDF.type, ns.person.Person))
                    add_literal(g, person_role, ns.mu.uuid, person_uuid,
                                XSD.string)

                    if str(row[f'Datum verkiezing {role}']) != 'NaT':
                        year_election = dateparser.parse(
                            str(row[f'Datum verkiezing {role}'])).year

                        if year_election <= 2019:
                            if not 'Lid' in role:
                                person_role_mandaat, person_role_mandaat_uuid = concept_uri(
                                    lblod + 'mandaten/',
                                    str(row['organization_id']) +
                                    'eredienstbestuursorganen/2017/' + role)
                                g.add((bestuur_temporary_17, ns.org.hasPost,
                                       person_role_mandaat))
                            person_lid_mandaat, person_lid_mandaat_uuid = concept_uri(
                                lblod + 'mandaten/',
                                str(row['organization_id']) +
                                'eredienstbestuursorganen/2017/Lid')
                            g.add((bestuur_temporary_17, ns.org.hasPost,
                                   person_lid_mandaat))

                            #if str(row[f'Type Helft Cleansed {role}']) == 'Kleine helft':
                            #person_lid_mandaat, person_lid_mandaat_uuid = concept_uri(lblod + 'mandaten/', str(row['organization_id']) + 'eredienstbestuursorganen/2017/Lid')
                            #person_lid_mandaat, person_lid_mandaat_uuid = concept_uri(lblod + 'mandaten/', str(row['organization_id']) + 'eredienstbestuursorganen/2020/Lid')
                        else:
                            if not 'Lid' in role:
                                person_role_mandaat, person_role_mandaat_uuid = concept_uri(
                                    lblod + 'mandaten/',
                                    str(row['organization_id']) +
                                    'eredienstbestuursorganen/2020/' + role)
                                g.add((bestuur_temporary_20, ns.org.hasPost,
                                       person_role_mandaat))

                            person_lid_mandaat, person_lid_mandaat_uuid = concept_uri(
                                lblod + 'mandaten/',
                                str(row['organization_id']) +
                                'eredienstbestuursorganen/2020/Lid')
                            g.add((bestuur_temporary_20, ns.org.hasPost,
                                   person_lid_mandaat))

                    elif str(row['Status_EB Cleansed']) == 'Niet Actief':
                        if not 'Lid' in role:
                            person_role_mandaat, person_role_mandaat_uuid = concept_uri(
                                lblod + 'mandaten/',
                                str(row['organization_id']) +
                                'eredienstbestuursorganen/2017/' + role)
                            g.add((bestuur_temporary_17, ns.org.hasPost,
                                   person_role_mandaat))

                        person_lid_mandaat, person_lid_mandaat_uuid = concept_uri(
                            lblod + 'mandaten/',
                            str(row['organization_id']) +
                            'eredienstbestuursorganen/2017/Lid')
                        g.add((bestuur_temporary_17, ns.org.hasPost,
                               person_lid_mandaat))

                    if person_role_mandaat != None:
                        start_mandataris = None
                        expected_end_mandataris = None
                        end_mandataris = None

                        if str(row[f'Datum verkiezing {role}']) != 'NaT':
                            start_mandataris = dateparser.parse(
                                str(row[f'Datum verkiezing {role}']))

                            year_election = dateparser.parse(
                                str(row[f'Datum verkiezing {role}'])).year
                            if year_election >= 2017 and year_election < 2020 and end_date_bestuur_temporary_17 != None:
                                expected_end_mandataris = end_date_bestuur_temporary_17
                                end_mandataris = expected_end_mandataris
                            elif end_date_bestuur_temporary_17 == None:
                                remain_years = 2020 - year_election
                                expected_end_mandataris = (
                                    start_mandataris + timedelta(
                                        days=remain_years * 365)).isoformat()
                                end_mandataris = expected_end_mandataris
                            elif end_date_bestuur_temporary_20 != None:
                                expected_end_mandataris = end_date_bestuur_temporary_20

                        if 'Lid' not in role:
                            ## Role - Mandaat
                            g.add((person_role_mandaat, RDF.type,
                                   ns.mandaat.Mandaat))
                            add_literal(g, person_role_mandaat, ns.mu.uuid,
                                        person_role_mandaat_uuid, XSD.string)

                            bestuurfunctie_id = get_concept_id(
                                codelist_ere,
                                get_label_role(role + ' worship'))
                            g.add((person_role_mandaat, ns.org.role,
                                   bestuurfunctie_id))

                            ## Role - Mandataris
                            person_role_mandataris, person_role_mandataris_uuid = concept_uri(
                                lblod + 'mandatarissen/',
                                str(row['organization_id']) + person_uuid +
                                role)
                            #g.add((person_role_mandataris, RDF.type, ns.mandaat.Mandataris))
                            g.add((person_role_mandataris, RDF.type,
                                   ns.ere.EredienstMandataris))
                            add_literal(g, person_role_mandataris, ns.mu.uuid,
                                        person_role_mandataris_uuid,
                                        XSD.string)

                            g.add((person_role_mandataris,
                                   ns.mandaat.isBestuurlijkeAliasVan,
                                   person_role))
                            g.add((person_role_mandataris, ns.org.holds,
                                   person_role_mandaat))

                            g.add((person_role_mandataris, ns.mandaat.status,
                                   ns.mandataris_status['Effectief']))
                            g.add((person_role, ns.mandaat.isAangesteldAls,
                                   person_role_mandataris))

                            if start_mandataris != None:
                                add_literal(g, person_role_mandataris,
                                            ns.mandaat.start, start_mandataris,
                                            XSD.dateTime)

                            if expected_end_mandataris != None:
                                add_literal(
                                    g, person_role_mandataris,
                                    ns.ere.geplandeEinddatumAanstelling,
                                    expected_end_mandataris, XSD.dateTime)

                            if end_mandataris != None:
                                add_literal(g, person_role_mandataris,
                                            ns.mandaat.einde, end_mandataris,
                                            XSD.dateTime)

                        # Lid - Mandaat
                        g.add(
                            (person_lid_mandaat, RDF.type, ns.mandaat.Mandaat))
                        add_literal(g, person_lid_mandaat, ns.mu.uuid,
                                    person_lid_mandaat_uuid, XSD.string)

                        bestuurfunctie_id = get_concept_id(
                            codelist_ere, get_label_role('lid worship'))
                        g.add((person_lid_mandaat, ns.org.role,
                               bestuurfunctie_id))

                        person_lid_mandataris, person_lid_mandataris_uuid = concept_uri(
                            lblod + 'mandatarissen/',
                            str(row['organization_id']) + person_uuid + 'lid')
                        #g.add((person_lid_mandataris, RDF.type, ns.mandaat.Mandataris))
                        g.add((person_lid_mandataris, RDF.type,
                               ns.ere.EredienstMandataris))
                        add_literal(g, person_lid_mandataris, ns.mu.uuid,
                                    person_lid_mandataris_uuid, XSD.string)

                        g.add((person_lid_mandataris,
                               ns.mandaat.isBestuurlijkeAliasVan, person_role))
                        g.add((person_lid_mandataris, ns.org.holds,
                               person_lid_mandaat))

                        if str(row[f'Type Helft Cleansed {role}']) != str(
                                np.nan):
                            type_half = get_concept_id(
                                codelist_ere,
                                str(row[f'Type Helft Cleansed {role}']))
                            g.add((person_lid_mandataris, ns.ere.typeHelft,
                                   type_half))

                        g.add((person_lid_mandataris, ns.mandaat.status,
                               ns.mandataris_status['Effectief']))
                        g.add((person_role, ns.mandaat.isAangesteldAls,
                               person_lid_mandataris))

                        if start_mandataris != None:
                            add_literal(g, person_lid_mandataris,
                                        ns.mandaat.start, start_mandataris,
                                        XSD.dateTime)

                        if expected_end_mandataris != None:
                            add_literal(g, person_lid_mandataris,
                                        ns.ere.geplandeEinddatumAanstelling,
                                        expected_end_mandataris, XSD.dateTime)

                        if end_mandataris != None:
                            add_literal(g, person_lid_mandataris,
                                        ns.mandaat.einde, end_mandataris,
                                        XSD.dateTime)

                        ### Mandataris - Contact punt
                        if exists_contact_role(row, role):
                            person_role_contact_uri, person_role_contact_uuid = concept_uri(
                                lblod + 'contact-punten/',
                                str(row['organization_id']) + person_uuid +
                                role + str(row[f'Tel_{role} 1']))
                            g.add((person_role_contact_uri, RDF.type,
                                   ns.schema.ContactPoint))
                            add_literal(g, person_role_contact_uri, ns.mu.uuid,
                                        person_role_contact_uuid, XSD.string)
                            g.add((person_role_mandataris,
                                   ns.schema.contactPoint,
                                   person_role_contact_uri))

                            add_literal(g, person_role_contact_uri,
                                        ns.schema.telephone,
                                        str(row[f'Tel_{role} 1']), XSD.string)
                            add_literal(g, person_role_contact_uri,
                                        ns.schema.email,
                                        str(row[f'Mail_{role} Cleansed']),
                                        XSD.string)

                            if str(row[f'Tel_{role} 2']) != str(np.nan):
                                person_role_contact_2_uri, person_role_contact_2_uuid = concept_uri(
                                    lblod + 'contact-punten/',
                                    str(row['organization_id']) + person_uuid +
                                    role + str(row[f'Tel_{role} 2']))
                                g.add((person_role_contact_2_uri, RDF.type,
                                       ns.schema.ContactPoint))
                                add_literal(g, person_role_contact_2_uri,
                                            ns.mu.uuid,
                                            person_role_contact_2_uuid,
                                            XSD.string)

                                add_literal(g, person_role_contact_2_uri,
                                            ns.schema.telephone,
                                            str(row[f'Tel_{role} 2']),
                                            XSD.string)
                                g.add((person_role_mandataris,
                                       ns.schema.contactPoint,
                                       person_role_contact_2_uri))

                            ### Role - Adres
                            if exists_address_role(row, role):
                                person_role_address_id, person_role_address_uuid = concept_uri(
                                    lblod + 'adressen/',
                                    str(row['organization_id']) + person_uuid +
                                    role + 'adressen')
                                g.add((person_role_address_id, RDF.type,
                                       ns.locn.Address))
                                add_literal(g, person_role_address_id,
                                            ns.mu.uuid,
                                            person_role_address_uuid,
                                            XSD.string)

                                g.add(
                                    (person_role_contact_uri, ns.locn.address,
                                     person_role_address_id))
                                add_literal(g, person_role_address_id,
                                            ns.locn.fullAddress,
                                            str(row[f'Adres_{role} Cleansed']),
                                            XSD.string)

            ####
            # Lids
            # for role in roles_lid:
            #   if exists_role_worship(row, role):
            #     if exists_given_and_family_name(row, role):
            #       lid, lid_uuid =  concept_uri(lblod + 'personen/', str(row[f'Naam_{role} First']) + str(row[f'Naam_{role} Last']))
            #       add_literal(g, lid, FOAF.givenName, str(row[f'Naam_{role} First']), XSD.string)
            #       add_literal(g, lid, FOAF.familyName, str(row[f'Naam_{role} Last']), XSD.string)
            #     else:
            #       lid, lid_uuid =  concept_uri(lblod + 'personen/', str(row[f'Naam_{role} Cleansed']))
            #       add_literal(g, lid, FOAF.givenName, str(row[f'Naam_{role} Cleansed']), XSD.string)

            #     g.add((lid, RDF.type, ns.person.Person))
            #     add_literal(g, lid, ns.mu.uuid, lid_uuid, XSD.string)

            #     ## Lid - Mandaat
            #     #lid_mandaat = None
            #     if str(row[f'Datum verkiezing {role}']) != 'NaT':
            #       year_election = dateparser.parse(str(row[f'Datum verkiezing {role}'])).year

            #       if person_lid_mandaat != None:
            #         if year_election <= 2019:
            #         if str(row[f'Type Helft Cleansed {role}']) == 'Kleine helft':
            #           lid_mandaat, lid_mandaat_uuid = concept_uri(lblod + 'mandaten/', str(row['organization_id']) + 'eredienstbestuursorganen/2017/Lid')
            #         else:
            #           lid_mandaat, lid_mandaat_uuid = concept_uri(lblod + 'mandaten/', str(row['organization_id']) + 'eredienstbestuursorganen/2020/Lid')

            #         g.add((lid_mandaat, ns.org.postIn, bestuur_temporary_17))
            #         lid_mandaat, lid_mandaat_uuid = concept_uri(lblod + 'mandaten/', str(row['organization_id']) + 'eredienstbestuursorganen/2017/Lid')
            #           g.add((bestuur_temporary_17, ns.org.hasPost, person_lid_mandaat))
            #         else:
            #           g.add((bestuur_temporary_20, ns.org.hasPost, person_lid_mandaat))
            #       elif person_lid_mandaat == None and year_election <= 2019:
            #         person_lid_mandaat, person_lid_mandaat_uuid = concept_uri(lblod + 'mandaten/', str(row['organization_id']) + 'eredienstbestuursorganen/2017/Lid')
            #         g.add((bestuur_temporary_20, ns.org.hasPost, person_lid_mandaat))
            #       else:
            #         person_lid_mandaat, person_lid_mandaat_uuid = concept_uri(lblod + 'mandaten/', str(row['organization_id']) + 'eredienstbestuursorganen/2020/Lid')
            #         g.add((bestuur_temporary_20, ns.org.hasPost, person_lid_mandaat))
            #     elif str(row['Status_EB Cleansed']) == 'Niet Actief':
            #       #lid_mandaat, lid_mandaat_uuid = concept_uri(lblod + 'mandaten/', str(row['organization_id']) + 'eredienstbestuursorganen/2017/Lid')
            #       #g.add((lid_mandaat, ns.org.postIn, bestuur_temporary_17))
            #       g.add((bestuur_temporary_17, ns.org.hasPost, person_lid_mandaat))

            #     # if lid_mandaat != None:
            #     #   g.add((lid_mandaat, RDF.type, ns.mandaat.Mandaat))
            #     #   add_literal(g, lid_mandaat, ns.mu.uuid, lid_mandaat_uuid, XSD.string)

            #       # bestuurfunctie_id = get_concept_id(codelist_ere, get_label_role('lid worship'))
            #       # g.add((lid_mandaat, ns.org.role, bestuurfunctie_id))

            #     ## Lid - Mandataris
            #     lid_mandataris, lid_mandataris_uuid = concept_uri(lblod + 'mandatarissen/', str(row['organization_id']) + lid_uuid + role)
            #     #g.add((lid_mandataris, RDF.type, ns.mandaat.Mandataris))
            #     g.add((lid_mandataris, RDF.type, ns.ere.EredienstMandataris))
            #     add_literal(g, lid_mandataris, ns.mu.uuid, lid_mandataris_uuid, XSD.string)

            #     g.add((lid_mandataris, ns.mandaat.isBestuurlijkeAliasVan, lid))
            #     g.add((lid_mandataris, ns.org.holds, person_lid_mandaat))

            #     if str(row[f'Type Helft Cleansed {role}']) != str(np.nan):
            #       type_half = get_concept_id(codelist_ere, str(row[f'Type Helft Cleansed {role}']))
            #       g.add((lid_mandataris, ns.ere.typeHelft, type_half))

            #     if str(row[f'Datum verkiezing {role}']) != 'NaT':
            #       add_literal(g, lid_mandataris, ns.mandaat.start, dateparser.parse(str(row[f'Datum verkiezing {role}'])).isoformat(), XSD.dateTime)
            #       add_literal(g, person_role_mandataris, ns.ere.geplandeEinddatumAanstelling, (dateparser.parse(str(row[f'Datum verkiezing {role}'])) + timedelta(days=1095)).isoformat(), XSD.dateTime)

            #     #g.add((lid_mandaat, ns.org.heldBy, lid_mandataris))
            #     g.add((lid, ns.mandaat.isAangesteldAls, lid_mandataris))

        elif str(row['Status_EB Cleansed']) == 'Actief':
            # Bestuursorgaan in bestuursperiode 2020-2023
            bestuur_temporary_20, bestuur_temporary_20_uuid = concept_uri(
                lblod + 'eredienstbestuursorganen/',
                str(row['organization_id']) + 'eredienstbestuursorganen/2020')
            g.add((bestuur_temporary_20, RDF.type, ns.besluit.Bestuursorgaan))
            #g.add((bestuur_temporary_20, RDF.type, ns.ere.Eredienstbestuursorgaan))
            add_literal(g, bestuur_temporary_20, ns.mu.uuid,
                        bestuur_temporary_20_uuid, XSD.string)
            g.add((bestuur_temporary_20, ns.generiek.isTijdspecialisatieVan,
                   bo_id))

            # From 2023 the next bestuursorgaan in bestuursperiode will begin the same day
            if str(row['Type_eredienst Cleansed']) == 'Israëlitisch':
                add_literal(g, bestuur_temporary_20, ns.mandaat.bindingEinde,
                            datetime(2023, 5, 31).isoformat(), XSD.dateTime)
            else:
                add_literal(g, bestuur_temporary_20, ns.mandaat.bindingEinde,
                            datetime(2023, 4, 30).isoformat(), XSD.dateTime)

    print("########### Mapping finished #############")

    export_data(g, f'worship-{mode}')
Beispiel #16
0
def main(file, mode):
    contact_cleansed = get_cleansed_data(file, 'contact')

    g = Graph()

    for _, row in contact_cleansed.iterrows():
        abb_id, abb_uuid = concept_uri(
            ns.lblod + 'persoon/',
            str(row['Voornaam Contact Cleansed']) +
            str(row['Familienaam Contact Cleansed']))

        g.add((abb_id, RDF.type, ns.person.Person))
        add_literal(g, abb_id, ns.mu.uuid, abb_uuid, XSD.string)
        add_literal(g, abb_id, FOAF.familyName,
                    str(row['Familienaam Contact Cleansed']), XSD.string)
        add_literal(g, abb_id, ns.persoon.gebruikteVoornaam,
                    str(row['Voornaam Contact Cleansed']), XSD.string)

        if exists_contact_cont(row):
            site_id, site_uuid = concept_uri(
                ns.lblod + 'vesting/',
                str(row['Voornaam Contact Cleansed']) +
                str(row['Familienaam Contact Cleansed']))
            g.add((site_id, RDF.type, ns.org.Site))
            add_literal(g, site_id, ns.mu.uuid, site_uuid, XSD.string)

            contact_id, contact_uuid = concept_uri(
                ns.lblod + 'contactpunt/',
                str(row['Voornaam Contact Cleansed']) +
                str(row['Familienaam Contact Cleansed']) + '1')
            g.add((contact_id, RDF.type, ns.schema.ContactPoint))
            add_literal(g, contact_id, ns.mu.uuid, contact_uuid, XSD.string)

            add_literal(g, contact_id, ns.schema.email,
                        str(row['Titel Cleansed']), XSD.string)
            add_literal(g, contact_id, ns.schema.email,
                        str(row['Mail nr2 Cleansed']), XSD.string)
            add_literal(g, contact_id, ns.schema.telephone,
                        str(row['Telefoonnr Contact 1']), XSD.string)
            g.add((site_id, ns.schema.siteAddress, contact_id))

            if str(row['Telefoonnr Contact 2']) != str(np.nan):
                contact_tel2_id, contact_tel2_uuid = concept_uri(
                    ns.lblod + 'contactpunt/',
                    str(row['Voornaam Contact Cleansed']) +
                    str(row['Familienaam Contact Cleansed']) +
                    str(row['Telefoonnr Contact 2']))
                g.add((contact_tel2_id, RDF.type, ns.schema.ContactPoint))
                add_literal(g, contact_tel2_id, ns.mu.uuid, contact_tel2_uuid,
                            XSD.string)

                add_literal(g, contact_tel2_id, ns.schema.telephone,
                            str(row['Telefoonnr Contact 2']), XSD.string)
                g.add((site_id, ns.schema.siteAddress, contact_tel2_id))

            if str(row['GSMnr Contact Cleansed']) != str(np.nan):
                contact_gsm_id, contact_gsm_uuid = concept_uri(
                    ns.lblod + 'contactpunt/',
                    str(row['Voornaam Contact Cleansed']) +
                    str(row['Familienaam Contact Cleansed']) +
                    str(row['GSMnr Contact Cleansed']))
                g.add((contact_gsm_id, RDF.type, ns.schema.ContactPoint))
                add_literal(g, contact_gsm_id, ns.mu.uuid, contact_gsm_uuid,
                            XSD.string)

                add_literal(g, contact_gsm_id, ns.schema.telephone,
                            str(row['GSMnr Contact Cleansed']), XSD.string)
                g.add((site_id, ns.schema.siteAddress, contact_gsm_id))

            g.add((abb_id, ns.org.basedAt, site_id))

        if str(row['Id']) != str(np.nan):
            attr_id, _ = concept_uri(
                ns.lblod + 'gestructureerdeIdentificator/',
                str(row['Voornaam Contact Cleansed']) +
                str(row['Familienaam Contact Cleansed']))
            g.add(
                (attr_id, RDF.type, ns.generiek.GestructureerdeIdentificator))
            add_literal(g, attr_id, ns.generiek.lokaleIdentificator,
                        str(row['Id']), XSD.string)

            g.add((abb_id, ns.generiek.gestructureerdeIdentificator, attr_id))

        org_id, _ = concept_uri(ns.lblod + 'organisatie/',
                                str(row['organisation_id']))
        if (str(row['Decretale functie Cleansed']) == str(np.nan)) and (str(
                row['Functietitel Cleansed']) != str(np.nan)):
            position_id, _ = concept_uri(
                ns.lblod + 'hoedanigheid/',
                str(row['organisation_id']) +
                str(row['Functietitel Cleansed']))
            g.add((position_id, RDF.type, ns.organisatie.Hoedanigheid))

            # TODO: Map Functietitel properly
            role_id, _ = concept_uri(ns.lblod + 'rol/',
                                     str(row['Functietitel Cleansed']))
            g.add((role_id, RDF.type, ns.org.Role))
            add_literal(g, role_id, RDFS.label,
                        str(row['Functietitel Cleansed']), XSD.string)

            g.add((position_id, ns.org.role, role_id))

            g.add((position_id, ns.org.postIn, org_id))
            g.add((org_id, ns.org.hasPost, position_id))

            g.add((abb_id, ns.org.holds, position_id))
            g.add((position_id, ns.org.heldBy, abb_id))
        elif str(row['Decretale functie Cleansed']) != str(np.nan):
            # Bestuur temporary
            bestuur_temporary, bestuur_uuid = concept_uri(
                ns.lblod + 'bestuursorgaan/',
                str(row['organisation_id']) + str(datetime.now()))
            g.add((bestuur_temporary, RDF.type, ns.besluit.Bestuursorgaan))
            add_literal(g, bestuur_temporary, ns.mu.uuid, bestuur_uuid,
                        XSD.string)
            g.add((bestuur_temporary, ns.generiek.isTijdspecialisatieVan,
                   org_id))

            ## Functionaris
            person_functionaris, _ = concept_uri(
                ns.lblod + 'functionaris/',
                str(row['Voornaam Contact Cleansed']) +
                str(row['Familienaam Contact Cleansed']) +
                str(row['organisation_id']) +
                str(row['Decretale functie Cleansed'].lower().replace(" ",
                                                                      "")))
            g.add((person_functionaris, RDF.type, ns.lblodlg.Functionaris))
            g.add((person_functionaris, ns.mandaat.isBestuurlijkeAliasVan,
                   abb_id))
            #start
            #einde
            #status ~ cf loket lokale besturen PoC https://poc-form-builder.relance.s.redpencil.io/codelijsten
            # https://data.vlaanderen.be/id/conceptscheme/MandatarisStatusCode
            g.add((person_functionaris, ns.mandaat.status,
                   ns.functionaris_status[row['Functionaris status']]))
            g.add((abb_id, ns.mandaat.isAangesteldAls, person_functionaris))

            # https://data.vlaanderen.be/doc/conceptscheme/BestuursfunctieCode
            ## Bestuuursfunctie
            person_bestuursfunctie, person_bestuursfunctie_uuid = concept_uri(
                ns.lblod + 'bestuursfunctie/',
                str(row['Voornaam Contact Cleansed']) +
                str(row['Familienaam Contact Cleansed']) +
                str(row['organisation_id']))
            g.add(
                (person_bestuursfunctie, RDF.type, ns.lblodlg.Bestuursfunctie))
            add_literal(g, person_bestuursfunctie, ns.mu.uuid,
                        person_bestuursfunctie_uuid, XSD.string)

            g.add((person_bestuursfunctie, ns.org.role,
                   ns.bestursfunctie_code[row['Decretale functie Cleansed']]))
            g.add((person_bestuursfunctie, ns.org.heldBy, person_functionaris))
            g.add((person_functionaris, ns.org.holds, person_bestuursfunctie))

            g.add((bestuur_temporary, ns.org.hasPost, person_bestuursfunctie))
            g.add((person_bestuursfunctie, ns.org.postIn, bestuur_temporary))

    export_data(g, f'contact-{mode}')
Beispiel #17
0
def main(file, mode):
    # To have a new cleansed data, delete the previous xlsx in the output folder
    central_cleansed = get_cleansed_data(file, 'central')

    lblod = ns.get_namespace(mode)

    g = Graph()
    codelist_ere = load_graph('codelist-ere')
    locations = load_graph('locations')
    codelist_bestuurseenheid = load_graph('bestuurseenheid-classificatie-code')
    bestuurseenheid_classification_id = get_concept_id(
        codelist_bestuurseenheid, 'Centraal bestuur van de eredienst')
    VESTIGING_TYPE = URIRef(
        'http://lblod.data.gift/concepts/f1381723dec42c0b6ba6492e41d6f5dd')

    print("########### Mapping started #############")

    for _, row in central_cleansed.iterrows():
        unique_id = str(row['Titel']) + str(row['KBO_CKB_cleansed']) + str(
            row['Naam_CKB'])
        abb_id, abb_uuid = concept_uri(
            lblod + 'centraleBesturenVanDeEredienst/', unique_id)
        #g.add((abb_id, RDF.type, ns.org.Organization))
        #g.add((abb_id, RDF.type, ns.besluit.Bestuurseenheid))
        g.add((abb_id, RDF.type, ns.ere.CentraalBestuurVanDeEredienst))

        add_literal(g, abb_id, ns.mu.uuid, abb_uuid, XSD.string)

        add_literal(g, abb_id, SKOS.prefLabel, str(row['Naam_CKB']),
                    XSD.string)
        #add_literal(g, abb_id, ns.rov.legalName, str(row['Naam_CKB']), XSD.string)

        g.add(
            (abb_id, ns.org.classification, bestuurseenheid_classification_id))

        if str(row['Type_eredienst_CKB']) != str(np.nan):
            type_ere = get_concept_id(codelist_ere,
                                      str(row['Type_eredienst_CKB']))
            g.add((abb_id, ns.ere.typeEredienst, type_ere))

        status = get_concept_id(codelist_ere, str(row['Status_CKB_cleansed']))
        g.add((abb_id, ns.rov.orgStatus, status))

        if str(row['Gemeente Cleansed']) != str(np.nan):
            location_concept_g = get_location_id(locations,
                                                 str(row['Gemeente Cleansed']),
                                                 'Gemeente')
            if location_concept_g != None:
                g.add((abb_id, ns.besluit.werkingsgebied, location_concept_g))

        if str(row['Representatief orgaan']) != str(np.nan):
            national_id, _ = concept_uri(lblod + 'representatieveOrganen/',
                                         str(row['Representatief orgaan']))
            g.add((national_id, ns.org.linkedTo, abb_id))

        bo_id, bo_uuid = concept_uri(lblod + 'centraleBestuursorgaan/',
                                     unique_id + 'centraleBestuursorgaan')
        g.add((bo_id, RDF.type, ns.besluit.Bestuursorgaan))
        #g.add((bo_id, RDF.type, ns.ere.CentraleBestuursorgaan))
        add_literal(g, bo_id, ns.mu.uuid, bo_uuid, XSD.string)

        bestuursorgaan_classification_id = get_concept_id(
            codelist_ere, str(row['Bestuursorgaan Type']))
        g.add((bo_id, ns.org.classification, bestuursorgaan_classification_id))

        g.add((bo_id, ns.besluit.bestuurt, abb_id))

        if str(row['KBO_CKB_cleansed']) != str(np.nan):
            id_class, id_uuid = concept_uri(
                lblod + 'identificatoren/',
                str(row['KBO_CKB_cleansed']) + 'identificatoren')
            g.add((id_class, RDF.type, ns.adms.Identifier))
            add_literal(g, id_class, SKOS.notation, 'KBO nummer', XSD.string)
            add_literal(g, id_class, ns.mu.uuid, id_uuid, XSD.string)

            kbo_uri, kbo_uuid = concept_uri(
                lblod + 'gestructureerdeIdentificatoren/',
                str(row['KBO_CKB_cleansed']) +
                'gestructureerdeIdentificatoren')
            g.add(
                (kbo_uri, RDF.type, ns.generiek.GestructureerdeIdentificator))
            add_literal(g, kbo_uri, ns.mu.uuid, kbo_uuid, XSD.string)
            add_literal(g, kbo_uri, ns.generiek.lokaleIdentificator,
                        str(row['KBO_CKB_cleansed']), XSD.string)
            g.add(
                (id_class, ns.generiek.gestructureerdeIdentificator, kbo_uri))

            g.add((abb_id, ns.adms.identifier, id_class))

        if str(row['Titel']) != str(np.nan):
            id_class, id_uuid = concept_uri(
                lblod + 'identificatoren/',
                str(row['Titel']) + 'identificatoren')
            g.add((id_class, RDF.type, ns.adms.Identifier))
            add_literal(g, id_class, SKOS.notation, 'SharePoint identificator',
                        XSD.string)
            add_literal(g, id_class, ns.mu.uuid, id_uuid, XSD.string)

            naam_uri, naam_uuid = concept_uri(
                lblod + 'gestructureerdeIdentificatoren/',
                str(row['Titel']) + 'gestructureerdeIdentificatoren')
            g.add(
                (naam_uri, RDF.type, ns.generiek.GestructureerdeIdentificator))
            add_literal(g, naam_uri, ns.mu.uuid, naam_uuid, XSD.string)
            add_literal(g, naam_uri, ns.generiek.lokaleIdentificator,
                        str(row['Titel']), XSD.string)
            g.add(
                (id_class, ns.generiek.gestructureerdeIdentificator, naam_uri))

            g.add((abb_id, ns.adms.identifier, id_class))

        # Vestiging
        if exists_address(row):
            vestiging_uri, vestiging_uuid = concept_uri(
                lblod + 'vestigingen/', unique_id + 'vestigingen')
            g.add((vestiging_uri, RDF.type, ns.org.Site))
            add_literal(g, vestiging_uri, ns.mu.uuid, vestiging_uuid,
                        XSD.string)

            address_uri, address_uuid = concept_uri(lblod + 'adressen/',
                                                    unique_id + 'adressen')
            g.add((address_uri, RDF.type, ns.locn.Address))
            add_literal(g, address_uri, ns.mu.uuid, address_uuid, XSD.string)

            add_literal(g, address_uri, ns.locn.thoroughfare,
                        str(row['Straat']), XSD.string)
            add_literal(g, address_uri,
                        ns.adres['Adresvoorstelling.huisnummer'],
                        str(row['Huisnr Cleansed']), XSD.string)
            add_literal(g, address_uri,
                        ns.adres['Adresvoorstelling.busnummer'],
                        str(row['Busnummer Cleansed']), XSD.string)
            add_literal(g, address_uri, ns.locn.postCode,
                        str(row['Postcode Cleansed']), XSD.string)
            add_literal(g, address_uri, ns.adres.gemeentenaam,
                        str(row['Gemeente Cleansed']), XSD.string)
            add_literal(g, address_uri, ns.locn.adminUnitL2,
                        str(row['Provincie Cleansed']), XSD.string)
            add_literal(g, address_uri, ns.adres.land, 'België', XSD.string)

            add_literal(
                g, address_uri, ns.locn.fullAddress,
                get_full_address(str(row['Straat']),
                                 str(row['Huisnr Cleansed']),
                                 str(row['Busnummer Cleansed']),
                                 str(row['Postcode Cleansed']),
                                 str(row['Gemeente Cleansed'])), XSD.string)

            g.add((vestiging_uri, ns.organisatie.bestaatUit, address_uri))
            g.add((vestiging_uri, ns.ere.vestigingstype, VESTIGING_TYPE))
            g.add((abb_id, ns.org.hasPrimarySite, vestiging_uri))

        roles = ['voorzitter', 'secretaris']

        if exists_bestuursperiode_central(row):
            # Bestuursorgaan (in bestuursperiode)

            bestuur_temporary_17 = None
            if bool(row['Verkiezingen17']) == True:
                # Bestuursorgaan in bestuursperiode 2017-2020
                bestuur_temporary_17, bestuur_temporary_17_uuid = concept_uri(
                    lblod + 'centralebestuursorganen/',
                    unique_id + 'centralebestuursorganen/2017')
                g.add((bestuur_temporary_17, RDF.type,
                       ns.besluit.Bestuursorgaan))
                #g.add((bestuur_temporary_17, RDF.type, ns.ere.CentraleBestuursorgaan))
                add_literal(g, bestuur_temporary_17, ns.mu.uuid,
                            bestuur_temporary_17_uuid, XSD.string)
                g.add((bestuur_temporary_17,
                       ns.generiek.isTijdspecialisatieVan, bo_id))

                if str(row['Verkiezingen17_Opmerkingen Cleansed']) != str(
                        np.nan):
                    add_literal(
                        g, bestuur_temporary_17, ns.mandaat.bindingStart,
                        dateparser.parse(
                            str(row['Verkiezingen17_Opmerkingen Cleansed'])),
                        XSD.dateTime)

                if str(row['Verkiezingen2020_Opmerkingen Cleansed']) != str(
                        np.nan):
                    add_literal(
                        g, bestuur_temporary_17, ns.mandaat.bindingEinde,
                        dateparser.parse(
                            str(row['Verkiezingen2020_Opmerkingen Cleansed'])),
                        XSD.dateTime)
                elif str(row['Verkiezingen17_Opmerkingen Cleansed']) != str(
                        np.nan):
                    # end date = start date + 3 years
                    add_literal(
                        g, bestuur_temporary_17, ns.mandaat.bindingEinde,
                        (dateparser.parse(
                            str(row['Verkiezingen17_Opmerkingen Cleansed'])) +
                         timedelta(days=1095)).isoformat(), XSD.dateTime)
                elif str(row['Status_CKB_cleansed']) == 'Niet Actief':
                    add_literal(
                        g, bestuur_temporary_17, ns.mandaat.bindingEinde,
                        dateparser.parse(str(row['Opmerkingen_CKB Date'])),
                        XSD.dateTime)

            bestuur_temporary_20 = None
            if str(row['Status_CKB_cleansed']) == 'Actief' and bool(
                    row['Verkiezingen2020']) == True:
                # Bestuursorgaan in bestuursperiode 2020-2023
                bestuur_temporary_20, bestuur_temporary_20_uuid = concept_uri(
                    lblod + 'centralebestuursorganen/',
                    unique_id + 'centralebestuursorganen/2020')
                g.add((bestuur_temporary_20, RDF.type,
                       ns.besluit.Bestuursorgaan))
                #g.add((bestuur_temporary_20, RDF.type, ns.ere.CentraleBestuursorgaan))
                add_literal(g, bestuur_temporary_20, ns.mu.uuid,
                            bestuur_temporary_20_uuid, XSD.string)
                g.add((bestuur_temporary_20,
                       ns.generiek.isTijdspecialisatieVan, bo_id))

                if str(row['Verkiezingen2020_Opmerkingen Cleansed']) != str(
                        np.nan):
                    add_literal(
                        g, bestuur_temporary_20, ns.mandaat.bindingStart,
                        dateparser.parse(
                            str(row['Verkiezingen2020_Opmerkingen Cleansed'])),
                        XSD.dateTime)

                # From 2023 the next bestuursorgaan in bestuursperiode will begin the same day
                if str(row['Type_eredienst_CKB']) == 'Israëlitisch':
                    add_literal(g, bestuur_temporary_20,
                                ns.mandaat.bindingEinde,
                                datetime(2023, 5,
                                         31).isoformat(), XSD.dateTime)
                else:
                    add_literal(g, bestuur_temporary_20,
                                ns.mandaat.bindingEinde,
                                datetime(2023, 4,
                                         30).isoformat(), XSD.dateTime)

            if exists_mandate_central(row):
                # Mandaat / Mandataris
                for role in roles:
                    # Person Role
                    if exists_given_and_family_name(row, role):
                        person_role, person_uuid = concept_uri(
                            lblod + 'personen/',
                            str(row[f'Naam_{role} First']) +
                            str(row[f'Naam_{role} Last']))
                        add_literal(g, person_role, FOAF.givenName,
                                    str(row[f'Naam_{role} First']), XSD.string)
                        add_literal(g, person_role, FOAF.familyName,
                                    str(row[f'Naam_{role} Last']), XSD.string)
                    else:
                        person_role, person_uuid = concept_uri(
                            lblod + 'personen/',
                            str(row[f'Naam_{role} Cleansed']))
                        add_literal(g, person_role, FOAF.givenName,
                                    str(row[f'Naam_{role} Cleansed']),
                                    XSD.string)

                    g.add((person_role, RDF.type, ns.person.Person))
                    add_literal(g, person_role, ns.mu.uuid, person_uuid,
                                XSD.string)

                    person_role_mandaat = None
                    if str(row['Status_CKB_cleansed']) == 'Actief' and bool(
                            row['Verkiezingen2020']) == True:
                        person_role_mandaat, person_role_mandaat_uuid = concept_uri(
                            lblod + 'mandaten/',
                            unique_id + 'centralebestuursorganen/2020' + role)
                        g.add((bestuur_temporary_20, ns.org.hasPost,
                               person_role_mandaat))
                    elif str(row['Status_CKB_cleansed']
                             ) == 'Niet Actief' and bool(
                                 row['Verkiezingen17']) == True:
                        person_role_mandaat, person_role_mandaat_uuid = concept_uri(
                            lblod + 'mandaten/',
                            unique_id + 'centralebestuursorganen/2017' + role)
                        g.add((bestuur_temporary_17, ns.org.hasPost,
                               person_role_mandaat))

                    if person_role_mandaat != None:
                        ## Mandaat
                        g.add((person_role_mandaat, RDF.type,
                               ns.mandaat.Mandaat))
                        add_literal(g, person_role_mandaat, ns.mu.uuid,
                                    person_role_mandaat_uuid, XSD.string)

                        bestuurfunctie_id = get_concept_id(
                            codelist_ere, get_label_role(role + ' central'))
                        g.add((person_role_mandaat, ns.org.role,
                               bestuurfunctie_id))

                        ## Mandataris
                        person_role_mandataris, person_role_mandataris_uuid = concept_uri(
                            lblod + 'mandatarissen/',
                            unique_id + person_uuid + 'mandatarissen' + role)
                        #g.add((person_role_mandataris, RDF.type, ns.mandaat.Mandataris))
                        g.add((person_role_mandataris, RDF.type,
                               ns.ere.EredienstMandataris))
                        add_literal(g, person_role_mandataris, ns.mu.uuid,
                                    person_role_mandataris_uuid, XSD.string)

                        ## Mandataris - Contact punt
                        if exists_contact_role(row, role):
                            person_role_contact_uri, person_role_contact_uuid = concept_uri(
                                lblod + 'contact-punten/',
                                unique_id + person_uuid + 'contact-punten' +
                                str(row[f'Tel_{role} 1']))
                            g.add((person_role_contact_uri, RDF.type,
                                   ns.schema.ContactPoint))
                            add_literal(g, person_role_contact_uri, ns.mu.uuid,
                                        person_role_contact_uuid, XSD.string)
                            g.add((person_role_mandataris,
                                   ns.schema.contactPoint,
                                   person_role_contact_uri))

                            add_literal(g, person_role_contact_uri,
                                        ns.schema.telephone,
                                        str(row[f'Tel_{role} 1']), XSD.string)
                            add_literal(g, person_role_contact_uri,
                                        ns.schema.email,
                                        str(row[f'Mail_{role} Cleansed']),
                                        XSD.string)

                            if str(row[f'Tel_{role} 2']) != str(np.nan):
                                person_role_contact_2_uri, person_role_contact_2_uuid = concept_uri(
                                    lblod + 'contact-punten/', unique_id +
                                    person_uuid + 'contact-punten' +
                                    str(row[f'Tel_{role} 2']))
                                g.add((person_role_contact_2_uri, RDF.type,
                                       ns.schema.ContactPoint))
                                add_literal(g, person_role_contact_2_uri,
                                            ns.mu.uuid,
                                            person_role_contact_2_uuid,
                                            XSD.string)

                                add_literal(g, person_role_contact_2_uri,
                                            ns.schema.telephone,
                                            str(row[f'Tel_{role} 2']),
                                            XSD.string)
                                g.add((person_role_mandataris,
                                       ns.schema.contactPoint,
                                       person_role_contact_2_uri))

                        g.add((person_role_mandataris,
                               ns.mandaat.isBestuurlijkeAliasVan, person_role))
                        g.add((person_role_mandataris, ns.org.holds,
                               person_role_mandaat))
                        g.add((person_role_mandataris, ns.mandaat.status,
                               ns.mandataris_status['Effectief']))

                        if str(row['Verkiezingen2020_Opmerkingen Cleansed']
                               ) != str(np.nan):
                            add_literal(
                                g, person_role_mandataris, ns.mandaat.start,
                                dateparser.parse(
                                    str(row[
                                        'Verkiezingen2020_Opmerkingen Cleansed']
                                        )), XSD.dateTime)
                            # possible end date = start date + 3 years
                            add_literal(
                                g, person_role_mandataris,
                                ns.ere.geplandeEinddatumAanstelling,
                                (dateparser.parse(
                                    str(row[
                                        'Verkiezingen2020_Opmerkingen Cleansed']
                                        )) + timedelta(days=1095)).isoformat(),
                                XSD.dateTime)

                        elif str(
                                row['Verkiezingen17_Opmerkingen Cleansed']
                        ) != str(np.nan) and str(
                                row['Status_CKB_cleansed']) == 'Niet Actief':
                            add_literal(
                                g, person_role_mandataris, ns.mandaat.start,
                                dateparser.parse(
                                    str(row[
                                        'Verkiezingen17_Opmerkingen Cleansed'])
                                ), XSD.dateTime)
                            add_literal(
                                g, person_role_mandataris, ns.mandaat.einde,
                                (dateparser.parse(
                                    str(row[
                                        'Verkiezingen17_Opmerkingen Cleansed'])
                                ) + timedelta(days=1095)).isoformat(),
                                XSD.dateTime)

                        g.add((person_role_mandaat, ns.org.heldBy,
                               person_role_mandataris))
                        g.add((person_role, ns.mandaat.isAangesteldAls,
                               person_role_mandataris))
        elif str(row['Status_CKB_cleansed']) == 'Actief':
            # Bestuursorgaan in bestuursperiode 2020-2023
            bestuur_temporary_20, bestuur_temporary_20_uuid = concept_uri(
                lblod + 'centralebestuursorganen/',
                unique_id + 'centralebestuursorganen/2020')
            g.add((bestuur_temporary_20, RDF.type, ns.besluit.Bestuursorgaan))
            add_literal(g, bestuur_temporary_20, ns.mu.uuid,
                        bestuur_temporary_20_uuid, XSD.string)
            g.add((bestuur_temporary_20, ns.generiek.isTijdspecialisatieVan,
                   bo_id))

            # From 2023 the next bestuursorgaan in bestuursperiode will begin the same day
            if str(row['Type_eredienst_CKB']) == 'Israëlitisch':
                add_literal(g, bestuur_temporary_20, ns.mandaat.bindingEinde,
                            datetime(2023, 5, 31).isoformat(), XSD.dateTime)
            else:
                add_literal(g, bestuur_temporary_20, ns.mandaat.bindingEinde,
                            datetime(2023, 4, 30).isoformat(), XSD.dateTime)

    print("########### Mapping finished #############")

    export_data(g, f'central-{mode}')

    g.serialize('input/codelists/central.ttl', format='turtle')
def main(file, mode):

    orgs_cleansed = get_cleansed_data(file, 'org')

    codelist_bestuurseenheid = load_graph('bestuurseenheid-classificatie-code')

    g = Graph()

    for _, row in orgs_cleansed.iterrows():
        #there are more than one type in the file
        abb_id, abb_uuid = concept_uri(ns.lblod + 'bestuurseenheid/',
                                       str(row['organisation_id']))
        #g.add((abb_id, RDF.type, ns.org.Bestuurseenheid))
        add_literal(g, abb_id, ns.mu.uuid, abb_uuid, XSD.string)

        #g.add((abb_id, RDFS.subClassOf, ns.org.Organization))

        add_literal(g, abb_id, SKOS.prefLabel, str(row['Titel']), XSD.string)
        #add_literal(g, abb_id, ns.rov.legalName, str(row['Maatschappelijke Naam']))

        bestuurseenheid_classification_id = get_concept_id(
            codelist_bestuurseenheid, str(row['Type Entiteit']))
        g.add(
            (abb_id, ns.org.classification, bestuurseenheid_classification_id))

        status, _ = concept_uri(ns.os, str(row['Organisatiestatus']))
        g.add((abb_id, ns.rov.orgStatus, status))

        add_literal(g, abb_id, ns.dbpedia.nisCode,
                    str(row['NIScode_cleansed']), XSD.string)

        if str(row['KBOnr_cleansed']) != str(np.nan):
            id_class, id_uuid = concept_uri(ns.lblod + 'identifier/',
                                            str(row['KBO_CKB_cleansed']))
            g.add((id_class, RDF.type, ns.adms.Identifier))
            add_literal(g, id_class, SKOS.notation, 'KBO nummer', XSD.string)
            add_literal(g, id_class, ns.mu.uuid, id_uuid, XSD.string)

            kbo_id, _ = concept_uri(
                ns.lblod + 'gestructureerdeIdentificator/',
                str(row['organisation_id']) + str(row['KBOnr_cleansed']))
            g.add((kbo_id, RDF.type, ns.generiek.GestructureerdeIdentificator))
            add_literal(g, kbo_id, ns.generiek.lokaleIdentificator,
                        str(row['KBOnr_cleansed']), XSD.string)
            g.add((id_class, ns.generiek.gestructureerdeIdentificator, kbo_id))

            g.add((abb_id, ns.adms.identifier, id_class))

        if str(row['Unieke Naam']) != str(np.nan):
            unieke_naam_id, _ = concept_uri(
                ns.lblod + 'gestructureerdeIdentificator/',
                str(row['organisation_id']) + str(row['Unieke Naam']) + '1')
            g.add((unieke_naam_id, RDF.type,
                   ns.generiek.GestructureerdeIdentificator))
            add_literal(g, unieke_naam_id, ns.generiek.lokaleIdentificator,
                        str(row['Unieke Naam']), XSD.string)

            g.add((abb_id, ns.generiek.gestructureerdeIdentificator,
                   unieke_naam_id))

        if str(row['Unieke Naam van actieve organisaties']) != str(np.nan):
            unieke_naam_active_id, _ = concept_uri(
                ns.lblod + 'gestructureerdeIdentificator/',
                str(row['organisation_id']) +
                str(row['Unieke Naam van actieve organisaties']) + '2')
            g.add((unieke_naam_active_id, RDF.type,
                   ns.generiek.GestructureerdeIdentificator))
            add_literal(g, unieke_naam_active_id,
                        ns.generiek.lokaleIdentificator,
                        str(row['Unieke Naam van actieve organisaties']),
                        XSD.string)

            g.add((abb_id, ns.generiek.gestructureerdeIdentificator,
                   unieke_naam_id))

        if exists_site_org(row):
            site_id, _ = concept_uri(ns.lblod + 'vesting/',
                                     str(row['organisation_id']))
            g.add((site_id, RDF.type, ns.org.Site))

            if exists_contact_org(row):
                contact_id, _ = concept_uri(ns.lblod + 'contactinfo/',
                                            str(row['organisation_id']))
                g.add((contact_id, RDF.type, ns.schema.ContactPoint))

                add_literal(g, contact_id, FOAF.page,
                            str(row['Website Cleansed']), XSD.anyURI)
                add_literal(g, contact_id, ns.schema.telephone,
                            str(row['Algemeen telefoonnr']), XSD.string)
                add_literal(g, contact_id, ns.schema.email,
                            str(row['Algemeen mailadres']), XSD.string)

                g.add((site_id, ns.schema.siteAddress, contact_id))

            if exists_address(row):
                address_id, _ = concept_uri(ns.lblod + 'adresvoorstelling/',
                                            str(row['organisation_id']))
                g.add((address_id, RDF.type, ns.locn.Address))
                add_literal(g, address_id, ns.locn.thoroughfare,
                            str(row['Straat']), XSD.string)
                add_literal(g, address_id,
                            ns.adres['Adresvoorstelling.huisnummer'],
                            str(row['Huisnr_cleansed']), XSD.string)
                add_literal(g, address_id,
                            ns.adres['Adresvoorstelling.busnummer'],
                            str(row['Busnr_new']), XSD.string)
                add_literal(g, address_id, ns.locn.postCode,
                            str(row['Postcode van de organisatie_cleansed']),
                            XSD.string)
                add_literal(g, address_id, ns.adres.gemeentenaam,
                            str(row['Gemeente van de organisatie']),
                            XSD.string)
                add_literal(g, address_id, ns.locn.adminUnitL2,
                            str(row['Provincie Cleansed']), XSD.string)
                add_literal(g, address_id, ns.adres.land, 'België', XSD.string)

                g.add((site_id, ns.organisatie.bestaatUit, address_id))

            g.add((abb_id, ns.org.hasPrimarySite, site_id))

        if row['Unieke Naam'] != row['Moederentiteit']:
            find_moeder_kboid = orgs_cleansed[orgs_cleansed['Unieke Naam'] ==
                                              row['Moederentiteit']]
            if len(find_moeder_kboid) > 0:
                org_id, _ = concept_uri(
                    ns.lblod + 'organisatie/',
                    str(find_moeder_kboid.iloc[0]['organisation_id']))
                g.add((abb_id, ns.org.linkedTo, org_id))

        if pd.notna(row['Actief vanaf']):
            change_event_open_id, _ = concept_uri(
                ns.lblod + 'veranderingsgebeurtenis/',
                str(row['organisation_id']) + str(row['Actief vanaf']))
            g.add((change_event_open_id, RDF.type, ns.euro.FoundationEvent))
            add_literal(g, change_event_open_id, DC.date,
                        str(row['Actief vanaf']), XSD.dateTime)
            g.add((abb_id, ns.org.resultedFrom, change_event_open_id))

        if row['Organisatiestatus'] == 'Valt niet meer onder Vlaams toezicht':
            change_event_not_flemish_id, _ = concept_uri(
                ns.lblod + 'veranderingsgebeurtenis/',
                str(row['organisation_id']) + str(row['Actief tot']) +
                str(row['Actief tot']))
            g.add((change_event_not_flemish_id, RDF.type,
                   ns.organisatie.Vervanging))
            g.add((abb_id, ns.org.resultedFrom, change_event_not_flemish_id))

        elif row['Organisatiestatus'] == 'Gefusioneerd':
            change_event_merged_id, _ = concept_uri(
                ns.lblod + 'veranderingsgebeurtenis/',
                str(row['organisation_id']) + str(row['Actief tot']))
            g.add((change_event_merged_id, RDF.type, ns.organisatie.Fusie))
            if pd.notna(row['Actief tot']):
                add_literal(g, change_event_merged_id, DC.date,
                            str(row['Actief tot']), XSD.dateTime)
            # addLiteral(change_event_merged_id, NEED PROPERTY, 'Opmerkingen ivm Organisatie')

            merged_abb_id, _ = concept_uri(ns.lblod + 'organisatie/',
                                           str(row['Resulting organisation']))
            g.add(
                (change_event_merged_id, ns.org.originalOrganization, abb_id))
            g.add((change_event_merged_id, ns.org.resultingOrganization,
                   merged_abb_id))
            g.add((abb_id, ns.org.changedBy, change_event_merged_id))

        elif pd.notna(row['Actief tot']):
            change_event_close_id, _ = concept_uri(
                ns.lblod + 'veranderingsgebeurtenis/',
                str(row['organisation_id']) + str(row['Actief tot']))
            g.add(
                (change_event_close_id, RDF.type, ns.organisatie.Stopzetting))
            add_literal(g, change_event_close_id, DC.date,
                        str(row['Actief tot']), XSD.dateTime)
            g.add((abb_id, ns.org.changedBy, change_event_close_id))

    export_data(g, f'org-{mode}')