Answer the primary key query to retrieve an Object

@param oid the Identity of the Object to retrieve
@return The resulting query
542315
public Query getPKQuery(Identity oid)
    {
        Object[] values = oid.getPrimaryKeyValues();
        ClassDescriptor cld = pb.getClassDescriptor(oid.getObjectsTopLevelClass());
        FieldDescriptor[] fields = cld.getPkFields();
        Criteria criteria = new Criteria();

        for (int i = 0; i < fields.length; i++)
        {
            FieldDescriptor fld = fields[i];
            criteria.addEqualTo(fld.getAttributeName(), values[i]);
        }
        return QueryFactory.newQuery(cld.getClassOfObject(), criteria);
    }
1122599
public Optional<DTO> get(String id) {
        return Optional.ofNullable(db.findOneById(new ObjectId(id)));
    }
777242
public Object lookup(Identity oid)
    {
        Object ret = null;
        if (oid != null)
        {
            ObjectCache cache = getCache(oid, null, METHOD_LOOKUP);
            if (cache != null)
            {
                ret = cache.lookup(oid);
            }
        }
        return ret;
    }
238122
protected function getSelectObjectIdentityIdSql(ObjectIdentityInterface $oid)
    {
        $query = <<<QUERY
            SELECT o.id
            FROM %s o
            INNER JOIN %s c ON c.id = o.class_id
            WHERE o.object_identifier = %s AND c.class_type = %s
QUERY;

        return sprintf(
            $query,
            $this->options['oid_table_name'],
            $this->options['class_table_name'],
            $this->connection->quote((string) $oid->getIdentifier()),
            $this->connection->quote((string) $oid->getType())
        );
    }
497625
public HashSet<String> getDataById(String id) throws IOException {
    if (idToVersion.containsKey(id)) {
      return get(id);
    } else {
      return null;
    }
  }
1218231
private Identity fetch(final String token) throws IOException {
        // @checkstyle LineLength (1 line)
        final String uri = new Href(this.gapi).path("plus").path("v1")
            .path("people")
            .path("me")
            .with(PsGoogle.ACCESS_TOKEN, token)
            .toString();
        final JsonObject json = new JdkRequest(uri).fetch()
            .as(JsonResponse.class).json()
            .readObject();
        if (json.containsKey(PsGoogle.ERROR)) {
            throw new HttpException(
                HttpURLConnection.HTTP_BAD_REQUEST,
                String.format(
                    "could not retrieve id from Google, possible cause: %s.",
                    json.getJsonObject(PsGoogle.ERROR).get("message")
                )
            );
        }
        return PsGoogle.parse(json);
    }
52456
public TResult queryForId(long id) {
		String where = getPkWhere(id);
		String[] whereArgs = getPkWhereArgs(id);
		TResult result = userDb.query(getTableName(), table.getColumnNames(),
				where, whereArgs, null, null, null);
		prepareResult(result);
		return result;
	}
790142
public ValueContainer[] getKeyValues(ClassDescriptor cld, Identity oid, boolean convertToSql) throws PersistenceBrokerException
    {
        FieldDescriptor[] pkFields = cld.getPkFields();
        ValueContainer[] result = new ValueContainer[pkFields.length];
        Object[] pkValues = oid.getPrimaryKeyValues();

        try
        {
            for(int i = 0; i < result.length; i++)
            {
                FieldDescriptor fd = pkFields[i];
                Object cv = pkValues[i];
                if(convertToSql)
                {
                    // BRJ : apply type and value mapping
                    cv = fd.getFieldConversion().javaToSql(cv);
                }
                result[i] = new ValueContainer(cv, fd.getJdbcType());
            }
        }
        catch(Exception e)
        {
            throw new PersistenceBrokerException("Can't generate primary key values for given Identity " + oid, e);
        }
        return result;
    }
329954
@Override
	public void index(String oid, String pid) throws IndexerException {
		try {
			DigitalObject object = storage.getObject(oid);
			Payload payload = object.getPayload(pid);
			index(object, payload);
		} catch (StorageException ex) {
			throw new IndexerException(ex);
		}
	}
634700
public User getUserById(int id) {
		for (User u : users)
			if (u.getId() == id)
				return u;
		return null;
	}
411030
public X getPrimaryID(T entity) {
		if(mappingContext == null || conversionService == null) {
			fetchMappingContextAndConversionService();
		}

		MongoPersistentEntity<?> persistentEntity = mappingContext.getPersistentEntity(entity.getClass());
		MongoPersistentProperty idProperty = persistentEntity.getIdProperty();
		if(idProperty == null) {
			return null;
		}
		
//		X idValue = BeanWrapper.create(entity, conversionService).getProperty(idProperty, this.primaryIDClass);
		X idValue = (X) this.mappingContext.getPersistentEntity(this.entityClass).getPropertyAccessor(entity).getProperty(idProperty);
		return idValue;
	}
612212
public Object doGetObjectByIdentity(Identity id) throws PersistenceBrokerException
    {
        if (logger.isDebugEnabled()) logger.debug("getObjectByIdentity " + id);

        // check if object is present in ObjectCache:
        Object obj = objectCache.lookup(id);
        // only perform a db lookup if necessary (object not cached yet)
        if (obj == null)
        {
            obj = getDBObject(id);
        }
        else
        {
            ClassDescriptor cld = getClassDescriptor(obj.getClass());
            // if specified in the ClassDescriptor the instance must be refreshed
            if (cld.isAlwaysRefresh())
            {
                refreshInstance(obj, id, cld);
            }
            // now refresh all references
            checkRefreshRelationships(obj, id, cld);
        }

        // Invoke events on PersistenceBrokerAware instances and listeners
        AFTER_LOOKUP_EVENT.setTarget(obj);
        fireBrokerEvent(AFTER_LOOKUP_EVENT);
        AFTER_LOOKUP_EVENT.setTarget(null);

        //logger.info("RETRIEVING object " + obj);
        return obj;
    }
566451
private function createObjectIdentity(ObjectIdentityInterface $oid)
    {
        $classId = $this->createOrRetrieveClassId($oid->getType());

        $this->connection->executeQuery($this->getInsertObjectIdentitySql($oid->getIdentifier(), $classId, true));
    }
808678
public QueryTreeElement getQuery(String id) {
		for (QueryTreeElement query : queries) {
			if (query.getID().equals(id)) {
				return query;
			}
		}
		return null;
	}
1116636
public Extension getExtension(ObjectIdentifier oid) {
        if (info == null) {
            return null;
        }
        try {
            CertificateExtensions extensions;
            try {
                extensions = (CertificateExtensions)info.get(CertificateExtensions.NAME);
            } catch (CertificateException ce) {
                return null;
            }
            if (extensions == null) {
                return null;
            } else {
                Extension ex = extensions.getExtension(oid.toString());
                if (ex != null) {
                    return ex;
                }
                for (Extension ex2: extensions.getAllExtensions()) {
                    if (ex2.getExtensionId().equals((Object)oid)) {
                        //XXXX May want to consider cloning this
                        return ex2;
                    }
                }
                /* no such extension in this certificate */
                return null;
            }
        } catch (IOException ioe) {
            return null;
        }
    }
20521
function getId(id){
        if(_.isObject(id) && !_.isUndefined(id.id)){
            if (objectIdRegex.test(id.id)) {
                id = id.id;
            }
            else {
                id = null;
            }
        }
        return id;
    }
723861
@View(name = "by_uid_otp", map = "function(doc) { if(doc.token && doc.userId) { emit([doc.userId, doc.token], doc) } }")
    public CouchDbGoogleAuthenticatorToken findOneByUidForOtp(final String uid, final Integer otp) {
        val view = createQuery("by_uid_otp").key(ComplexKey.of(uid, otp)).limit(1);
        return db.queryView(view, CouchDbGoogleAuthenticatorToken.class).stream().findFirst().orElse(null);
    }