Set the unique identifier by looking through ``mods:identifier``

        See `specs <https://ocr-d.github.io/mets#unique-id-for-the-document-processed>`_ for details.
550724
def unique_identifier(self, purl):
        
        id_el = None
        for t in IDENTIFIER_PRIORITY:
            id_el = self._tree.getroot().find('.//mods:identifier[@type="%s"]' % t, NS)
            if id_el is not None:
                break
        if id_el is None:
            mods = self._tree.getroot().find('.//mods:mods', NS)
            id_el = ET.SubElement(mods, TAG_MODS_IDENTIFIER)
            id_el.set('type', 'purl')
        id_el.text = purl
1106224
def generate_unique_name(name_prefix, reservation_id=None):
    
    if reservation_id and isinstance(reservation_id, str) and len(reservation_id) >= 4:
        unique_id = str(uuid.uuid4())[:4] + "-" + reservation_id[-4:]
    else:
        unique_id = str(uuid.uuid4())[:8]
    return name_prefix + "_" + unique_id
1351676
def set_id(self,pid):
        
        if self.type == 'KAF':
            return self.node.set('pid',pid)
        elif self.type == 'NAF':
            return self.node.set('id',pid)
537404
def _set_id_field(new_class):
        """"""
        # FIXME What does it mean when there are no declared fields?
        #   Does it translate to an abstract entity?
        if new_class.meta_.declared_fields:
            try:
                new_class.meta_.id_field = next(
                    field for _, field in new_class.meta_.declared_fields.items()
                    if field.identifier)
            except StopIteration:
                # If no id field is declared then create one
                new_class._create_id_field()
1344984
def unique_id(self):
        
        chain = self.parent.parent.id
        residue = self.parent.id
        return chain, residue, self.id
92723
def _set_id(infos):
    '''
    
    '''
    if infos:
        cid = None
        if infos.get("Id"): cid = infos["Id"]
        elif infos.get("ID"): cid = infos["ID"]
        elif infos.get("id"): cid = infos["id"]
        if "Id" not in infos:
            infos["Id"] = cid
        infos.pop("id",None)
        infos.pop("ID",None)
    return infos
860217
def id(self, id):
        

        if id is None:
            raise ValueError("Invalid value for `id`, must not be `None`")
        if len(id) > 255:
            raise ValueError("Invalid value for `id`, length must be less than `255`")

        self._id = id
288687
def _unique_id(self, prefix):
        
        _id = self._id_gen
        self._id_gen += 1
        return prefix + str(_id)
738777
def add_unique(self, attr, item):
        
        return self.set(attr, operation.AddUnique([item]))
485824
public function setIdentifier($identifier) {

		if(false === is_array($identifier)) {
			$identifier = [$identifier];
		}

		$this -> identifier = $identifier;
	}
851855
def update(self, document_id, update_spec, namespace, timestamp):
        
        document = self.doc_dict[document_id].doc
        updated = self.apply_update(document, update_spec)
        if "_id" in updated:
            updated.pop("_id")
        updated[self.unique_key] = document_id
        self.upsert(updated, namespace, timestamp)
        return updated
1004321
private static int setID(String prefix, int identifier, IChemObject object, List<String> tabuList) {
        identifier += 1;
        while (tabuList.contains(prefix + identifier)) {
            identifier += 1;
        }
        object.setID(prefix + identifier);
        tabuList.add(prefix + identifier);
        return identifier;
    }
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
269978
def _construct_unique_id(self, id_prefix, lines):
        
        text = []
        for line in lines:
            if isinstance(line, str):
                text.append(line)
            elif isinstance(line, CodeAnswer):
                text.append(line.dump())
        return id_prefix + '\n' + '\n'.join(text)
515361
def set_item_ids(self, item_ids):
        '''

        '''
        if self.get_item_ids_metadata().is_read_only():
            raise NoAccess()
        for item_id in item_ids:
            if not self.my_osid_object_form._is_valid_id(item_id):
                raise InvalidArgument()
        if self.my_osid_object_form._my_map['learningObjectiveIds'][0]:
            raise IllegalState()
        self.my_osid_object_form._my_map['itemIds'] = [str(i) for i in item_ids]
329231
public static void setId(Object document, String id) {
		DocumentAccessor d = getAccessor(document);
		if (d.hasIdMutator()) {
			d.setId(document, id);
		}
	}
692755
def verify_identifiers(identifiers, n_items):
    """"""
    if identifiers is None:
        return identifiers

    identifiers = np.array(identifiers, copy=False)

    # Check length for consistency
    if len(identifiers) != n_items:
        raise ValueError("identifiers has inconsistent dimension.")

    # Check that identifiers are unique
    if len(np.unique(identifiers)) != n_items:
        raise ValueError("identifiers contains duplicate values.")

    return identifiers