Esempio n. 1
0
def load_entity(tx, entity):
    log.info("Load node [%s]: %s", entity.id, entity.name)
    fp = fingerprint(entity.name)
    node = EntityNode.get_cache(tx, fp)
    if node is not None:
        return node

    country_code = entity.jurisdiction_code
    if country_code is not None:
        country_code = country_code.upper()
    node = EntityNode.merge(tx, name=entity.name,
                            fingerprint=fp,
                            alephState=entity.state,
                            alephEntity=entity.id)
    add_to_collections(tx, node, entity.collections)

    seen = set([fp])
    for other_name in entity.other_names:
        fp = fingerprint(other_name.display_name)
        if fp in seen or fingerprint is None:
            continue
        seen.add(fp)

        alias = EntityNode.merge(tx, name=other_name.display_name,
                                 fingerprint=fp,
                                 alephEntity=entity.id,
                                 isAlias=True)
        AKA.merge(tx, node, alias)
        add_to_collections(tx, node, entity.collections)

    # TODO contact details, addresses
    return node
Esempio n. 2
0
def load_entity(tx, entity):
    log.info("Load node [%s]: %s", entity.id, entity.name)
    fp = fingerprint(entity.name)
    node = EntityNode.get_cache(tx, fp)
    if node is not None:
        return node

    country_code = entity.jurisdiction_code
    if country_code is not None:
        country_code = country_code.upper()
    node = EntityNode.merge(tx,
                            name=entity.name,
                            fingerprint=fp,
                            alephState=entity.state,
                            alephEntity=entity.id)
    add_to_collections(tx, node, entity.collections)

    seen = set([fp])
    for other_name in entity.other_names:
        fp = fingerprint(other_name.display_name)
        if fp in seen or fingerprint is None:
            continue
        seen.add(fp)

        alias = EntityNode.merge(tx,
                                 name=other_name.display_name,
                                 fingerprint=fp,
                                 alephEntity=entity.id,
                                 isAlias=True)
        AKA.merge(tx, node, alias)
        add_to_collections(tx, node, entity.collections)

    # TODO contact details, addresses
    return node
Esempio n. 3
0
def load_entity(tx, entity):
    if tx is None:
        return
    if entity.state != Entity.STATE_ACTIVE:
        return remove_entity(tx, entity.id)
    log.info("Graph node [%s]: %s", entity.id, entity.name)
    fp = entity.fingerprint
    node = EntityNode.get_cache(tx, fp)
    if node is not None:
        return node

    country_code = entity.jurisdiction_code
    if country_code is not None:
        country_code = country_code.upper()
    node = EntityNode.merge(tx,
                            name=entity.name,
                            fingerprint=fp,
                            alephSchema=entity.type,
                            alephState=entity.state,
                            alephEntity=entity.id)
    add_to_collections(tx,
                       node,
                       entity.collections,
                       alephEntity=entity.id,
                       alephCanonical=entity.id)

    seen = set([fp])
    for other_name in entity.other_names:
        fp = other_name.fingerprint
        if fp in seen or fp is None:
            continue
        seen.add(fp)

        alias = EntityNode.merge(tx,
                                 name=other_name.display_name,
                                 fingerprint=fp,
                                 alephEntity=entity.id,
                                 alephSchema=entity.type)
        AKA.merge(tx, node, alias, alephEntity=entity.id)
        add_to_collections(tx,
                           alias,
                           entity.collections,
                           alephEntity=entity.id)

    # TODO contact details, addresses
    return node
Esempio n. 4
0
def load_entity(tx, entity):
    if tx is None:
        return
    if entity.state != Entity.STATE_ACTIVE:
        return remove_entity(tx, entity.id)
    log.info("Graph node [%s]: %s", entity.id, entity.name)
    fp = entity.fingerprint
    node = EntityNode.get_cache(tx, fp)
    if node is not None:
        return node

    country_code = entity.jurisdiction_code
    if country_code is not None:
        country_code = country_code.upper()
    node = EntityNode.merge(tx, name=entity.name,
                            fingerprint=fp,
                            alephSchema=entity.type,
                            alephState=entity.state,
                            alephEntity=entity.id)
    add_to_collections(tx, node, entity.collections,
                       alephEntity=entity.id,
                       alephCanonical=entity.id)

    seen = set([fp])
    for other_name in entity.other_names:
        fp = other_name.fingerprint
        if fp in seen or fp is None:
            continue
        seen.add(fp)

        alias = EntityNode.merge(tx, name=other_name.display_name,
                                 fingerprint=fp,
                                 alephEntity=entity.id,
                                 alephSchema=entity.type)
        AKA.merge(tx, node, alias, alephEntity=entity.id)
        add_to_collections(tx, alias, entity.collections,
                           alephEntity=entity.id)

    # TODO contact details, addresses
    return node