package br.com.colegio.carga;
import java.util.HashMap;
import java.util.Map;
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.PreparedQuery;
import com.google.appengine.api.datastore.Query;
import com.google.appengine.tools.remoteapi.RemoteApiInstaller;
import com.google.appengine.tools.remoteapi.RemoteApiOptions;
public class CopiarBoletoToCloud
{
public static void main(String[] args)
{
// String username = System.console().readLine("username: ");
// String password = new String(System.console().readPassword("password: "));
String username = args[0];
String password = args[1];
RemoteApiOptions options = (new RemoteApiOptions())
.server("sistemamariamorato.appspot.com", 443)
.credentials(username, password);
RemoteApiInstaller installer = new RemoteApiInstaller();
RemoteApiOptions options2 = (new RemoteApiOptions())
.server("colegio-iemam.appspot.com", 443)
.credentials(username, password);
RemoteApiInstaller installer2 = new RemoteApiInstaller();
try
{
installer.install(options);
DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
Query q = new Query("Boleto");
Map<String, Entity> mB = new HashMap<String, Entity>();
PreparedQuery pq = ds.prepare(q);
Iterable<Entity> it = pq.asIterable();
for (Entity e : it)
mB.put((String)e.getProperty("codigo"), e);
System.out.println("RES : " + mB.size());
installer.uninstall();
installer2.install(options2);
DatastoreService dsDestino = DatastoreServiceFactory.getDatastoreService();
// dsDestino.put(it);
Map<String, Entity> mB2 = new HashMap<String, Entity>();
PreparedQuery pq2 = dsDestino.prepare(q);
Iterable<Entity> it2 = pq2.asIterable();
for (Entity e : it2)
mB2.put((String)e.getProperty("codigo"), e);
System.out.println("RES : " + mB2.size());
installer2.uninstall();
}
catch (Exception e)
{
e.printStackTrace();
}
finally
{
}
}
}