-
Notifications
You must be signed in to change notification settings - Fork 1
/
eg.txt
106 lines (71 loc) · 3.46 KB
/
eg.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
package com.gaesuperadmin.client.desktop;
import java.io.IOException;
import java.util.List;
import com.gaesuperadmin.service.AbstractRemoteApiInstaller;
import com.google.appengine.api.datastore.DatastoreService;
import com.google.appengine.api.datastore.DatastoreServiceFactory;
import com.google.appengine.api.datastore.Entity;
import com.google.appengine.api.datastore.FetchOptions;
import com.google.appengine.api.datastore.PreparedQuery;
import com.google.appengine.api.datastore.Query;
public class RemoteApiDemo extends AbstractRemoteApiInstaller{
public static void main(String[] args) throws IOException {
new RemoteApiDemo().install();
DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
System.out.println("Key of new entity is " + ds.put(new Entity("111")));
Query query = new Query("Event");
/*query.setKeysOnly();
Set keys = new HashSet();
for (Entity entity : ds.prepare(query).asList(FetchOptions.Builder.withLimit(500))) {
keys.add(entity.getKey());
}*/
PreparedQuery preparedQuery = ds.prepare(query);
FetchOptions fetchOptions = FetchOptions.Builder.withDefaults();
List<Entity> entities = preparedQuery.asList(fetchOptions);
for (Entity entity : entities) {
System.out.println(entity);
// System.out.println(entity.getProperty("state"));
}
/*int count = 0;
//while(true) {
String username = "";
String password = "";
//RemoteApiOptions options = new RemoteApiOptions().server("qa-metacampus.appspot.com",443).credentials(username, password);
RemoteApiOptions options = new RemoteApiOptions().server("localhost",9876).credentials(username, password);
RemoteApiInstaller installer = new RemoteApiInstaller();
installer.install(options);
try {
DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
//System.out.println("Key of new entity is " + ds.put(new Entity("Hello Remote API!")));
Query query = new Query("ConsolidationStage");
Key key = KeyFactory.createKey("ConsolidationStage", "6597069766656000");
//query.addFilter("__key__", FilterOperator.EQUAL, key);
PreparedQuery preparedQuery = ds.prepare(query);
FetchOptions fetchOptions = FetchOptions.Builder.withDefaults();
List<Entity> entities = preparedQuery.asList(fetchOptions);
for (Entity entity : entities) {
entity.setProperty("state", "COMPLETED");
ds.put(entity);
System.out.println(entity);
// System.out.println(entity.getProperty("state"));
}
System.out.println("----Done stage " + count++);
query = new Query("ConsolidationStage");
key = KeyFactory.createKey("Consolidation", 15382015);
query.addFilter("consolidationKey", FilterOperator.EQUAL, key);
preparedQuery = ds.prepare(query);
fetchOptions = FetchOptions.Builder.withDefaults();
entities = preparedQuery.asList(fetchOptions);
for (Entity entity : entities) {
//System.out.println(entity);
System.out.println(entity.getProperty("state"));
}
System.out.println("----Done2 consolidation " + count++);
} catch (Exception e) {
e.printStackTrace();
} finally {
installer.uninstall();
}*/
//}
}
}