Package com.google.appengine.tools.remoteapi

Examples of com.google.appengine.tools.remoteapi.RemoteApiInstaller


    RemoteApiOptions options = (new RemoteApiOptions())
              .server("sistemamariamorato.appspot.com", 443)
              .credentials(username, password);

    RemoteApiInstaller installer = new RemoteApiInstaller();

    try
    {
      installer.install(options);
      DatastoreService ds = DatastoreServiceFactory.getDatastoreService();

      Query q = new Query("Boleto");
      //q.addFilter("statusBoleto", Query.FilterOperator.EQUAL, "A");

      Map<String, Entity> mB = new HashMap<String, Entity>();
      for (Entity e : ds.prepare(q).asIterable())
        mB.put((String)e.getProperty("codigo"), e);

      System.out.println("RES : " + mB.size());

      int tUpdate2 = 0;
      int tUpdate = 0;
      int tInsert = 0;

      for (String s : FileUtil.pegaURL("e:/_escola/conta-corrente/boletos2012-05-04.csv", "\n").split("\n"))
      {
        String[] c = s.split(";");
        Entity e = mB.get(c[3].replaceAll("'", "").trim());

        if (e == null)
        {
          e = new Entity("Boleto");

          e.setProperty("codigo", c[3].replaceAll("'", "").trim());
          e.setProperty("alunoBoleto", c[1].replaceAll("'", "").trim());
          e.setProperty("grupo", c[2].replaceAll("'", "").trim());
          e.setProperty("dataVencimento", UtilData.parser(c[4].replaceAll("'", "").trim()));
          e.setProperty("dataEmissao", UtilData.parser(c[5].replaceAll("'", "").trim()));
          e.setProperty("valorTotal", Double.valueOf(c[6].replaceAll("'", "").trim().replaceAll(",", ".")));
          e.setProperty("desconto", Double.valueOf(c[7].replaceAll("'", "").trim().replaceAll(",", ".")));
          e.setProperty("multa", Double.valueOf(c[8].replaceAll("'", "").trim().replaceAll(",", ".")));
          e.setProperty("dataMulta", UtilData.parser(c[9].replaceAll("'", "").trim()));
          e.setProperty("jurosDia", Double.valueOf(c[10].replaceAll("'", "").trim().replaceAll(",", ".")));
          e.setProperty("descricao", c[11].replaceAll("'", "").trim());
          e.setProperty("descricaoCompleta", c[12].replaceAll("'", "").trim().replaceAll("\\.\\.", "."));

          if (!c[14].replaceAll("'", "").trim().equals(""))
          {
            e.setProperty("dataPagamento", UtilData.format(UtilData.parser(c[14].replaceAll("'", "").trim()), "yyyy-MM-dd HH:mm:ss"));
            e.setProperty("pagamentoValor", Double.valueOf(c[15].replaceAll("'", "").trim().replaceAll(",", ".")));
            e.setProperty("pagamentoDesconto", Double.valueOf(c[16].replaceAll("'", "").trim().replaceAll(",", ".")));
            e.setProperty("pagamentoMulta", Double.valueOf(c[17].replaceAll("'", "").trim().replaceAll(",", ".")));
            e.setProperty("pagamentoTarifa", Double.valueOf(c[18].replaceAll("'", "").trim().replaceAll(",", ".")));
            e.setProperty("codigoRetornoBoleto", Integer.valueOf(c[13].replaceAll("'", "").trim().replaceAll(",", ".")));
            e.setProperty("pagamentoCanalBoleto", Integer.valueOf(c[20].replaceAll("'", "").trim()));
            e.setProperty("statusBoleto", (!c[20].replaceAll("'", "").trim().equals("") ? "P" : "A"));
            e.setProperty("pagamentoTipo", "BANCO");

            if (!c[19].replaceAll("'", "").trim().equals(""))
              e.setProperty("creditoData", UtilData.format(UtilData.parser(c[19].replaceAll("'", "").trim()), "yyyy-MM-dd HH:mm:ss"));
          }
          else
          {
            e.setProperty("dataPagamento", null);
            e.setProperty("pagamentoValor", null);
            e.setProperty("pagamentoDesconto", null);
            e.setProperty("pagamentoMulta", null);
            e.setProperty("pagamentoTarifa", null);
            e.setProperty("codigoRetornoBoleto", null);
            e.setProperty("pagamentoCanalBoleto", null);
            e.setProperty("statusBoleto", "A");
            e.setProperty("pagamentoTipo", null);
            e.setProperty("creditoData", null);
          }

//          ds.put(e);

          tInsert++;
        }
        else if (!c[20].replaceAll("'", "").trim().equals(""))
        {
          String statusBoleto = (String)e.getProperty("statusBoleto");

          if (statusBoleto == null || statusBoleto.equalsIgnoreCase("A"))
          {
            e.setProperty("alunoBoleto", c[1].replaceAll("'", "").trim());
            e.setProperty("grupo", c[2].replaceAll("'", "").trim());
            e.setProperty("dataVencimento", UtilData.parser(c[4].replaceAll("'", "").trim()));
            e.setProperty("dataEmissao", UtilData.parser(c[5].replaceAll("'", "").trim()));
            e.setProperty("valorTotal", Double.valueOf(c[6].replaceAll("'", "").trim().replaceAll(",", ".")));
            e.setProperty("desconto", Double.valueOf(c[7].replaceAll("'", "").trim().replaceAll(",", ".")));
            e.setProperty("multa", Double.valueOf(c[8].replaceAll("'", "").trim().replaceAll(",", ".")));
            e.setProperty("dataMulta", UtilData.parser(c[9].replaceAll("'", "").trim()));
            e.setProperty("jurosDia", Double.valueOf(c[10].replaceAll("'", "").trim().replaceAll(",", ".")));
            e.setProperty("descricao", c[11].replaceAll("'", "").trim());
            e.setProperty("descricaoCompleta", c[12].replaceAll("'", "").trim().replaceAll("\\.\\.", "."));

            if (!c[14].replaceAll("'", "").trim().equals(""))
            {
              e.setProperty("dataPagamento", UtilData.format(UtilData.parser(c[14].replaceAll("'", "").trim()), "yyyy-MM-dd HH:mm:ss"));
              e.setProperty("pagamentoValor", Double.valueOf(c[15].replaceAll("'", "").trim().replaceAll(",", ".")));
              e.setProperty("pagamentoDesconto", Double.valueOf(c[16].replaceAll("'", "").trim().replaceAll(",", ".")));
              e.setProperty("pagamentoMulta", Double.valueOf(c[17].replaceAll("'", "").trim().replaceAll(",", ".")));
              e.setProperty("pagamentoTarifa", Double.valueOf(c[18].replaceAll("'", "").trim().replaceAll(",", ".")));
              e.setProperty("codigoRetornoBoleto", Integer.valueOf(c[13].replaceAll("'", "").trim().replaceAll(",", ".")));
              e.setProperty("pagamentoCanalBoleto", Integer.valueOf(c[20].replaceAll("'", "").trim()));
              e.setProperty("statusBoleto", (!c[20].replaceAll("'", "").trim().equals("") ? "P" : "A"));
              e.setProperty("pagamentoTipo", "BANCO");

              if (!c[19].replaceAll("'", "").trim().equals(""))
                e.setProperty("creditoData", UtilData.format(UtilData.parser(c[19].replaceAll("'", "").trim()), "yyyy-MM-dd HH:mm:ss"));
            }
            else
            {
              e.setProperty("dataPagamento", null);
              e.setProperty("pagamentoValor", null);
              e.setProperty("pagamentoDesconto", null);
              e.setProperty("pagamentoMulta", null);
              e.setProperty("pagamentoTarifa", null);
              e.setProperty("codigoRetornoBoleto", null);
              e.setProperty("pagamentoCanalBoleto", null);
              e.setProperty("statusBoleto", "A");
              e.setProperty("pagamentoTipo", null);
              e.setProperty("creditoData", null);
            }

//            ds.put(e);

            tUpdate++;
          }
        }
        else
        {
          if (!e.hasProperty("statusBoleto"))
          {
            e.setProperty("alunoBoleto", c[1].replaceAll("'", "").trim());
            e.setProperty("grupo", c[2].replaceAll("'", "").trim());
            e.setProperty("dataVencimento", UtilData.parser(c[4].replaceAll("'", "").trim()));
            e.setProperty("dataEmissao", UtilData.parser(c[5].replaceAll("'", "").trim()));
            e.setProperty("valorTotal", Double.valueOf(c[6].replaceAll("'", "").trim().replaceAll(",", ".")));
            e.setProperty("desconto", Double.valueOf(c[7].replaceAll("'", "").trim().replaceAll(",", ".")));
            e.setProperty("multa", Double.valueOf(c[8].replaceAll("'", "").trim().replaceAll(",", ".")));
            e.setProperty("dataMulta", UtilData.parser(c[9].replaceAll("'", "").trim()));
            e.setProperty("jurosDia", Double.valueOf(c[10].replaceAll("'", "").trim().replaceAll(",", ".")));
            e.setProperty("descricao", c[11].replaceAll("'", "").trim());
            e.setProperty("descricaoCompleta", c[12].replaceAll("'", "").trim().replaceAll("\\.\\.", "."));

            if (!c[14].replaceAll("'", "").trim().equals(""))
            {
              e.setProperty("dataPagamento", UtilData.format(UtilData.parser(c[14].replaceAll("'", "").trim()), "yyyy-MM-dd HH:mm:ss"));
              e.setProperty("pagamentoValor", Double.valueOf(c[15].replaceAll("'", "").trim().replaceAll(",", ".")));
              e.setProperty("pagamentoDesconto", Double.valueOf(c[16].replaceAll("'", "").trim().replaceAll(",", ".")));
              e.setProperty("pagamentoMulta", Double.valueOf(c[17].replaceAll("'", "").trim().replaceAll(",", ".")));
              e.setProperty("pagamentoTarifa", Double.valueOf(c[18].replaceAll("'", "").trim().replaceAll(",", ".")));
              e.setProperty("codigoRetornoBoleto", Integer.valueOf(c[13].replaceAll("'", "").trim().replaceAll(",", ".")));
              e.setProperty("pagamentoCanalBoleto", Integer.valueOf(c[20].replaceAll("'", "").trim()));
              e.setProperty("statusBoleto", (!c[20].replaceAll("'", "").trim().equals("") ? "P" : "A"));
              e.setProperty("pagamentoTipo", "BANCO");

              if (!c[19].replaceAll("'", "").trim().equals(""))
                e.setProperty("creditoData", UtilData.format(UtilData.parser(c[19].replaceAll("'", "").trim()), "yyyy-MM-dd HH:mm:ss"));
            }
            else
            {
              e.setProperty("dataPagamento", null);
              e.setProperty("pagamentoValor", null);
              e.setProperty("pagamentoDesconto", null);
              e.setProperty("pagamentoMulta", null);
              e.setProperty("pagamentoTarifa", null);
              e.setProperty("codigoRetornoBoleto", null);
              e.setProperty("pagamentoCanalBoleto", null);
              e.setProperty("statusBoleto", "A");
              e.setProperty("pagamentoTipo", null);
              e.setProperty("creditoData", null);
            }

//            ds.put(e);

            tUpdate2++;
          }
        }

//        ds.put(e);
      }

      System.out.println("-INSERIDOS : " + tInsert);
      System.out.println("-ALTERADOS : " + tUpdate);
      System.out.println("-ALTERADOS 2 : " + tUpdate2);
    }
    catch (Exception e)
    {
      e.printStackTrace();
    }
    finally
    {
      installer.uninstall();
    }
  }
View Full Code Here


    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();
    }
View Full Code Here

  public RemoteTest(String host, int port, String projectId, String username, String password) throws IOException {
    options = new RemoteApiOptions()
            .server(host, port)
            .credentials(username, password)
            .remoteApiPath("/_ah/remote_api");
    remoteApiInstaller = new RemoteApiInstaller();
    remoteApiInstaller.install(options);
    options.reuseCredentials(username,
                             remoteApiInstaller.serializeCredentials());

View Full Code Here

    public void run() {
        RemoteApiOptions options = new RemoteApiOptions()
            .server("11-9-prod.sortmybox.appspot.com", 443)
            .credentials(System.getenv("user"), System.getenv("password"))
            .remoteApiPath("/remote_api");
        RemoteApiInstaller installer = new RemoteApiInstaller();
//        ApiProxy.setEnvironmentForCurrentThread(new PlayDevEnvironment());
        try {
            installer.install(options);
            innerRun();
        } catch (IOException e) {
            Logger.error(e, "Unable to install");
        } finally {
            try {
                installer.uninstall();
            } catch (Throwable e) {
//                Logger.error(e, "Unable to uninstall");
            }
        }
    }
View Full Code Here

TOP

Related Classes of com.google.appengine.tools.remoteapi.RemoteApiInstaller

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.