TODO: what if the ontology terms have multiple IDs?
9232
public String getId(OWLClass entity) {
    for (OWLAnnotationProperty owlObjectProperty : ontology.getAnnotationPropertiesInSignature()) {
      if (ifExistsAnnotation(owlObjectProperty.toString(), "id")) {
        Set<String> annotation = getAnnotation(entity, owlObjectProperty.getIRI().toString());
        if (!annotation.isEmpty()) {
          return annotation.iterator().next();
        }
      }
    }
    return StringUtils.EMPTY;
  }
630448
public void setOntologyId(String v) {
    if (NeurotransmitterProp_Type.featOkTst && ((NeurotransmitterProp_Type)jcasType).casFeat_ontologyId == null)
      jcasType.jcas.throwFeatMissing("ontologyId", "neuroner.NeuroNER.NeurotransmitterProp");
    jcasType.ll_cas.ll_setStringValue(addr, ((NeurotransmitterProp_Type)jcasType).casFeatCode_ontologyId, v);}
1166490
def getGaTermByName(self, name):
        
        # TODO what is the correct value when we have no mapping??
        termIds = self.getTermIds(name)
        if len(termIds) == 0:
            termId = ""
            # TODO add logging for missed term translation.
        else:
            # TODO what is the correct behaviour here when we have multiple
            # IDs matching a given name?
            termId = termIds[0]
        term = protocol.OntologyTerm()
        term.term = name
        term.term_id = termId
        return term
1090478
def _getMultigraphID(self, graph_name, subgraph_name=None):
        
        if self.isMultiInstance and self._instanceName is not None:
            if subgraph_name is None:
                return "%s_%s" % (graph_name, self._instanceName)
            else:
                return "%s_%s.%s_%s" % (graph_name, self._instanceName, 
                                        subgraph_name, self._instanceName)
        else:
            if subgraph_name is None:
                return graph_name
            else:
                return "%s.%s" % (graph_name, subgraph_name)
926704
def process_existing_ids(self, entity: List[dict]) -> List[dict]:
        
        label = entity['label']
        existing_ids = entity['existing_ids']
        for existing_id in existing_ids:
            if 'curie' not in existing_id or 'iri' not in existing_id:
                raise ValueError(
                    f'Missing needing key(s) in existing_ids for label: {label}')
            elif len(existing_id) > 2:
                raise ValueError(
                    f'Extra keys not recognized in existing_ids for label: {label}')
        return entity
1160872
def create_unique_id(prefix, existing_ids):
    
    if prefix in existing_ids:
        suffix = 1
        while True:
            new_id = '{}_{}'.format(prefix, suffix)
            if new_id not in existing_ids:
                return new_id
            suffix += 1

    return prefix
915367
def persistent_identifiers2marc(self, key, value):
    """"""
    return {
        '2': value.get('schema'),
        '9': value.get('source'),
        'a': value.get('value'),
        'q': value.get('material'),
    }
1278391
def get_equivalents(term_id: str) -> List[Mapping[str, Union[str, bool]]]:
    
    try:
        errors = []
        terms = get_terms(term_id)
        if len(terms) == 0:
            return {"equivalents": [], "errors": errors}
        elif len(terms) > 1:
            errors.append(
                f'Too many primary IDs returned. Given term_id: {term_id} matches these term_ids: {[term["id"] for term in terms]}'
            )
            return {"equivalents": [], "errors": errors}
        else:
            term_id = terms[0]["id"]

        term_id_key = bel.db.arangodb.arango_id_to_key(term_id)

        equivalents = []
        query = f"""
        FOR vertex, edge IN 1..5
            ANY 'equivalence_nodes/{term_id_key}' equivalence_edges
            OPTIONS {{bfs: true, uniqueVertices : 'global'}}
            RETURN DISTINCT {{
                term_id: vertex.name,
                namespace: vertex.namespace,
                primary: vertex.primary
            }}
        """

        cursor = belns_db.aql.execute(query, count=True, batch_size=20)
        for doc in cursor:
            if doc.get("term_id", False):
                equivalents.append(doc)

        equivalents.append(
            {"term_id": term_id, "namespace": term_id.split(":")[0], "primary": True}
        )

        return {"equivalents": equivalents, "errors": errors}

    except Exception as e:
        log.error(f"Problem getting term equivalents for {term_id} msg: {e}")
        return {"equivalents": [], "errors": [f"Unexpected error {e}"]}
840986
def id_unique(dict_id, name, lineno):
    """"""
    if dict_id in name_dict:
        global error_occurred
        error_occurred = True
        print(
            "ERROR - {0:s} definition {1:s} at line {2:d} conflicts with {3:s}"
            .format(name, dict_id, lineno, name_dict[dict_id]))
        return False
    else:
        return True
1248000
function isKeyword(id) {
		switch (id.length) {
			case 2:
				return 'do' == id || 'if' == id || 'in' == id || 'or' == id;
			case 3:
				return 'and' == id || 'end' == id || 'for' == id || 'nil' == id ||
					'not' == id;
			case 4:
				return 'else' == id || 'goto' == id || 'then' == id || 'true' == id;
			case 5:
				return 'break' == id || 'false' == id || 'local' == id ||
					'until' == id || 'while' == id;
			case 6:
				return 'elseif' == id || 'repeat' == id || 'return' == id;
			case 8:
				return 'function' == id;
		}
		return false;
	}
261276
def _create_mappings(self):
        ''
        created1 = self._create_tag_mapping()
        created2 = self._create_assoc_mapping()
        return created1 or created2
527947
def id_hash
      @terms.inject({}) {|sum, t| sum.update(t.id.value => t.name.value)}
    end
460352
private OntologyTermSynonym createSynonym(String synonym) {
    OntologyTermSynonym entity = ontologyTermSynonymFactory.create();
    entity.setId(idGenerator.generateId());
    entity.setOntologyTermSynonym(synonym);
    synonymRepository.add(entity);
    return entity;
  }
97861
function (oTreeModel, aAdditionalRuleSetsNames) {

			if (!aAdditionalRuleSetsNames) {
				return;
			}

			aAdditionalRuleSetsNames.forEach(function (sRuleName) {
				Object.keys(oTreeModel).forEach(function(iKey) {
					if (oTreeModel[iKey].name === sRuleName) {
						oTreeModel[iKey].selected = false;
						oTreeModel[iKey].nodes.forEach(function(oRule){
							oRule.selected = false;
						});
					}
				});
			});

			return oTreeModel;
		}
776576
public Set<String> getIdsForIdsWithAncestors(Collection<String> termIds) {
        Stack<String> idsToConsider = new Stack<String>();
        idsToConsider.addAll(termIds);
        Set<String> resultIds = new HashSet<String>();
        while (!idsToConsider.isEmpty()) {
            String id = idsToConsider.pop();
            if (!resultIds.contains(id)) {
                resultIds.add(id);
                if (terms.containsKey(id))
                    idsToConsider.addAll(terms.get(id).getIsA());
            }
        }
        return resultIds;
    }
1310989
def mget(self, ids, index=None, doc_type=None, **query_params):
        
        if not ids:
            return []

        body = []
        for value in ids:
            if isinstance(value, tuple):
                if len(value) == 3:
                    a, b, c = value
                    body.append({"_index": a,
                                 "_type": b,
                                 "_id": c})
                elif len(value) == 4:
                    a, b, c, d = value
                    body.append({"_index": a,
                                 "_type": b,
                                 "_id": c,
                                 "fields": d})

            else:
                if index is None:
                    raise InvalidQuery("index value is required for id")
                if doc_type is None:
                    raise InvalidQuery("doc_type value is required for id")
                body.append({"_index": index,
                             "_type": doc_type,
                             "_id": value})

        results = self._send_request('GET', "/_mget", body={'docs': body},
                                     params=query_params)
        if 'docs' in results:
            model = self.model
            return [model(self, item) for item in results['docs']]
        return []
466484
def t_ID(t):
    '
    if t.value in keywords:
        t.type = t.value.upper()
    return t