Java Code Examples for com.google.appengine.api.datastore.Key#getId()
The following examples show how to use
com.google.appengine.api.datastore.Key#getId() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CableKeyPair.java From webauthndemo with Apache License 2.0 | 6 votes |
public long save(Long sessionId) throws IOException { Key parentKey = KeyFactory.createKey(SessionData.KIND, sessionId); Entity keyEntity = new Entity(KIND, parentKey); // Serialize the KeyPair ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream(baos); out.writeObject(keyPair); keyEntity.setProperty(KEY_PAIR_PROPERTY, BaseEncoding.base64().encode(baos.toByteArray())); keyEntity.setProperty(TIMESTAMP_PROPERTY, new Date()); Key stored = Datastore.getDatastore().put(keyEntity); this.id = stored.getId(); return id; }
Example 2
Source File: SessionData.java From webauthndemo with Apache License 2.0 | 5 votes |
/** * Save the session into the datastore. * * @param currentUser */ public void save(String currentUser) { Key parentKey = KeyFactory.createKey(User.KIND, currentUser); Entity session = new Entity(KIND, parentKey); session.setProperty(CHALLENGE_PROPERTY, challenge); session.setProperty(ORIGIN_PROPERTY, origin); session.setProperty(TIMESTAMP_PROPERTY, new Date()); Key stored = Datastore.getDatastore().put(session); this.id = stored.getId(); }
Example 3
Source File: DatastoreDao.java From getting-started-java with Apache License 2.0 | 5 votes |
@Override public Long createBook(Book book) { Entity incBookEntity = new Entity(BOOK_KIND); // Key will be assigned once written incBookEntity.setProperty(Book.AUTHOR, book.getAuthor()); incBookEntity.setProperty(Book.DESCRIPTION, book.getDescription()); incBookEntity.setProperty(Book.PUBLISHED_DATE, book.getPublishedDate()); incBookEntity.setProperty(Book.TITLE, book.getTitle()); incBookEntity.setProperty(Book.IMAGE_URL, book.getImageUrl()); incBookEntity.setProperty(Book.CREATED_BY, book.getCreatedBy()); incBookEntity.setProperty(Book.CREATED_BY_ID, book.getCreatedById()); Key bookKey = datastore.put(incBookEntity); // Save the Entity return bookKey.getId(); // The ID of the Key }
Example 4
Source File: DatastoreDao.java From getting-started-java with Apache License 2.0 | 5 votes |
@Override public Long createBook(Book book) { Entity incBookEntity = new Entity(BOOK_KIND); // Key will be assigned once written incBookEntity.setProperty(Book.AUTHOR, book.getAuthor()); incBookEntity.setProperty(Book.DESCRIPTION, book.getDescription()); incBookEntity.setProperty(Book.PUBLISHED_DATE, book.getPublishedDate()); incBookEntity.setProperty(Book.TITLE, book.getTitle()); Key bookKey = datastore.put(incBookEntity); // Save the Entity return bookKey.getId(); // The ID of the Key }
Example 5
Source File: DatastoreDao.java From getting-started-java with Apache License 2.0 | 5 votes |
@Override public Long createBook(Book book) { Entity incBookEntity = new Entity(BOOK_KIND); // Key will be assigned once written incBookEntity.setProperty(Book.AUTHOR, book.getAuthor()); incBookEntity.setProperty(Book.DESCRIPTION, book.getDescription()); incBookEntity.setProperty(Book.PUBLISHED_DATE, book.getPublishedDate()); incBookEntity.setProperty(Book.TITLE, book.getTitle()); incBookEntity.setProperty(Book.IMAGE_URL, book.getImageUrl()); Key bookKey = datastore.put(incBookEntity); // Save the Entity return bookKey.getId(); // The ID of the Key }
Example 6
Source File: DatastoreDao.java From getting-started-java with Apache License 2.0 | 5 votes |
@Override public Long createBook(Book book) { Entity incBookEntity = new Entity(BOOK_KIND); // Key will be assigned once written incBookEntity.setProperty(Book.AUTHOR, book.getAuthor()); incBookEntity.setProperty(Book.DESCRIPTION, book.getDescription()); incBookEntity.setProperty(Book.PUBLISHED_DATE, book.getPublishedDate()); incBookEntity.setProperty(Book.TITLE, book.getTitle()); incBookEntity.setProperty(Book.IMAGE_URL, book.getImageUrl()); incBookEntity.setProperty(Book.CREATED_BY, book.getCreatedBy()); incBookEntity.setProperty(Book.CREATED_BY_ID, book.getCreatedById()); Key bookKey = datastore.put(incBookEntity); // Save the Entity return bookKey.getId(); // The ID of the Key }
Example 7
Source File: TaskServlet.java From sc2gears with Apache License 2.0 | 2 votes |
/** * Returns the name of the queue associated for the specified entity key. * @param entityKey entity key to return the queue name for * @return the name of the queue associated for the specified entity key */ private static String getEntityUpdateQueueName( final Key entityKey ) { return QUEUE_NAME_ENTITY_UPDATE + ( entityKey.getId() & QUEUE_ENTITY_MASK ); }