Java Code Examples for com.google.cloud.datastore.Entity#getString()
The following examples show how to use
com.google.cloud.datastore.Entity#getString() .
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: MessageRepositoryImpl.java From java-docs-samples with Apache License 2.0 | 6 votes |
@Override public List<String> retrieveClaims(int limit) { // Get claim saved in Datastore Datastore datastore = getDatastoreInstance(); Query<Entity> query = Query.newEntityQueryBuilder().setKind(claimsKind).setLimit(limit).build(); QueryResults<Entity> results = datastore.run(query); List<String> claims = new ArrayList<>(); while (results.hasNext()) { Entity entity = results.next(); String claim = entity.getString("claim"); if (claim != null) { claims.add(claim); } } return claims; }
Example 2
Source File: MessageRepositoryImpl.java From java-docs-samples with Apache License 2.0 | 6 votes |
@Override public List<String> retrieveTokens(int limit) { // Get token saved in Datastore Datastore datastore = getDatastoreInstance(); Query<Entity> query = Query.newEntityQueryBuilder().setKind(tokensKind).setLimit(limit).build(); QueryResults<Entity> results = datastore.run(query); List<String> tokens = new ArrayList<>(); while (results.hasNext()) { Entity entity = results.next(); String token = entity.getString("token"); if (token != null) { tokens.add(token); } } return tokens; }
Example 3
Source File: GoogleJobStore.java From data-transfer-project with Apache License 2.0 | 5 votes |
@Override public <T extends DataModel> T findData(UUID jobId, String key, Class<T> type) { Key entityKey = getDataKey(jobId, key); Entity entity = datastore.get(entityKey); if (entity == null) { return null; } String serializedEntity = entity.getString(type.getName()); try { return objectMapper.readValue(serializedEntity, type); } catch (IOException t) { throw new RuntimeException("Failed to deserialize entity: " + serializedEntity, t); } }
Example 4
Source File: DatastoreStorage.java From styx with Apache License 2.0 | 5 votes |
private WorkflowInstance parseWorkflowInstance(Entity activeWorkflowInstance) { final String componentId = activeWorkflowInstance.getString(PROPERTY_COMPONENT); final String workflowId = activeWorkflowInstance.getString(PROPERTY_WORKFLOW); final String parameter = activeWorkflowInstance.getString(PROPERTY_PARAMETER); return WorkflowInstance.create(WorkflowId.create(componentId, workflowId), parameter); }
Example 5
Source File: MessageRepositoryImpl.java From java-docs-samples with Apache License 2.0 | 5 votes |
@Override public List<Message> retrieve(int limit) { // Get Message saved in Datastore Datastore datastore = getDatastoreInstance(); Query<Entity> query = Query.newEntityQueryBuilder() .setKind(messagesKind) .setLimit(limit) .addOrderBy(StructuredQuery.OrderBy.desc("publishTime")) .build(); QueryResults<Entity> results = datastore.run(query); List<Message> messages = new ArrayList<>(); while (results.hasNext()) { Entity entity = results.next(); Message message = new Message(entity.getString("messageId")); String data = entity.getString("data"); if (data != null) { message.setData(data); } String publishTime = entity.getString("publishTime"); if (publishTime != null) { message.setPublishTime(publishTime); } messages.add(message); } return messages; }
Example 6
Source File: UserService.java From java-docs-samples with Apache License 2.0 | 5 votes |
/** * Return the user with the given id. */ User getUser(String id) { Entity entity = datastore.get(keyFactory.newKey(id)); return entity == null ? null : new User(entity.getString("id"), entity.getString("name"), entity.getString("email")); }
Example 7
Source File: MessageRepositoryImpl.java From java-docs-samples with Apache License 2.0 | 5 votes |
@Override public List<Message> retrieve(int limit) { // Get Message saved in Datastore Datastore datastore = getDatastoreInstance(); Query<Entity> query = Query.newEntityQueryBuilder() .setKind(messagesKind) .setLimit(limit) .addOrderBy(StructuredQuery.OrderBy.desc("publishTime")) .build(); QueryResults<Entity> results = datastore.run(query); List<Message> messages = new ArrayList<>(); while (results.hasNext()) { Entity entity = results.next(); Message message = new Message(entity.getString("messageId")); String data = entity.getString("data"); if (data != null) { message.setData(data); } String publishTime = entity.getString("publishTime"); if (publishTime != null) { message.setPublishTime(publishTime); } messages.add(message); } return messages; }
Example 8
Source File: MessageRepositoryImpl.java From java-docs-samples with Apache License 2.0 | 5 votes |
@Override public List<Message> retrieve(int limit) { // Get Message saved in Datastore Datastore datastore = getDatastoreInstance(); Query<Entity> query = Query.newEntityQueryBuilder() .setKind(messagesKind) .setLimit(limit) .addOrderBy(StructuredQuery.OrderBy.desc("publishTime")) .build(); QueryResults<Entity> results = datastore.run(query); List<Message> messages = new ArrayList<>(); while (results.hasNext()) { Entity entity = results.next(); Message message = new Message(entity.getString("messageId")); String data = entity.getString("data"); if (data != null) { message.setData(data); } String publishTime = entity.getString("publishTime"); if (publishTime != null) { message.setPublishTime(publishTime); } if (entity.contains("sourceLang")) { String sourceLang = entity.getString("sourceLang"); if (sourceLang != null) { message.setSourceLang(sourceLang); } } if (entity.contains("targetLang")) { String targetLang = entity.getString("targetLang"); if (targetLang != null) { message.setTargetLang(targetLang); } } messages.add(message); } return messages; }
Example 9
Source File: Greeting.java From java-docs-samples with Apache License 2.0 | 5 votes |
public Greeting(Entity entity) { key = entity.hasKey() ? entity.getKey() : null; authorEmail = entity.contains("authorEmail") ? entity.getString("authorEmail") : null; authorId = entity.contains("authorId") ? entity.getString("authorId") : null; date = entity.contains("date") ? entity.getTimestamp("date").toSqlTimestamp() : null; content = entity.contains("content") ? entity.getString("content") : null; }