Ejemplo n.º 1
0
 @Override
 public String getpages() throws Exception {
   if (this.checkpermission("getpages")) {
     int intRegsPerPag = ParameterCook.prepareRpp(oRequest);
     ArrayList<FilterBeanHelper> alFilter = ParameterCook.prepareFilter(oRequest);
     String data = null;
     Connection oConnection = null;
     ConnectionInterface oDataConnectionSource = null;
     try {
       oDataConnectionSource = getSourceConnection();
       oConnection = oDataConnectionSource.newConnection();
       EstadoDao oEstadoDao = new EstadoDao(oConnection);
       data =
           JsonMessage.getJson(
               "200", Integer.toString(oEstadoDao.getPages(intRegsPerPag, alFilter)));
     } catch (Exception ex) {
       ExceptionBooster.boost(
           new Exception(this.getClass().getName() + ":getPages ERROR: " + ex.getMessage()));
     } finally {
       if (oConnection != null) {
         oConnection.close();
       }
       if (oDataConnectionSource != null) {
         oDataConnectionSource.disposeConnection();
       }
     }
     return data;
   } else {
     return JsonMessage.getJsonMsg("401", "Unauthorized");
   }
 }
Ejemplo n.º 2
0
 @Override
 public String getpage() throws Exception {
   if (this.checkpermission("getpage")) {
     int intRegsPerPag = ParameterCook.prepareRpp(oRequest);
     int intPage = ParameterCook.preparePage(oRequest);
     ArrayList<FilterBeanHelper> alFilter = ParameterCook.prepareFilter(oRequest);
     HashMap<String, String> hmOrder = ParameterCook.prepareOrder(oRequest);
     String data = null;
     Connection oConnection = null;
     ConnectionInterface oDataConnectionSource = null;
     try {
       oDataConnectionSource = getSourceConnection();
       oConnection = oDataConnectionSource.newConnection();
       EstadoDao oEstadoDao = new EstadoDao(oConnection);
       List<EstadoBean> arrBeans =
           oEstadoDao.getPage(
               intRegsPerPag, intPage, alFilter, hmOrder, AppConfigurationHelper.getJsonDepth());
       data = JsonMessage.getJson("200", AppConfigurationHelper.getGson().toJson(arrBeans));
     } catch (Exception ex) {
       ExceptionBooster.boost(
           new Exception(this.getClass().getName() + ":getPage ERROR: " + ex.getMessage()));
     } finally {
       if (oConnection != null) {
         oConnection.close();
       }
       if (oDataConnectionSource != null) {
         oDataConnectionSource.disposeConnection();
       }
     }
     return data;
   } else {
     return JsonMessage.getJsonMsg("401", "Unauthorized");
   }
 }
Ejemplo n.º 3
0
  @Override
  public String get() throws Exception {
    if (this.checkpermission("get")) {
      int id = ParameterCook.prepareId(oRequest);
      String data = null;
      Connection oConnection = null;
      ConnectionInterface oDataConnectionSource = null;
      try {
        oDataConnectionSource = getSourceConnection();
        oConnection = oDataConnectionSource.newConnection();
        EstadoDao oEstadoDao = new EstadoDao(oConnection);
        EstadoBean oEstadoBean = new EstadoBean(id);
        oEstadoBean = oEstadoDao.get(oEstadoBean, AppConfigurationHelper.getJsonDepth());
        Gson gson = AppConfigurationHelper.getGson();
        data = JsonMessage.getJson("200", AppConfigurationHelper.getGson().toJson(oEstadoBean));
      } catch (Exception ex) {
        ExceptionBooster.boost(
            new Exception(this.getClass().getName() + ":get ERROR: " + ex.getMessage()));
      } finally {
        if (oConnection != null) {
          oConnection.close();
        }
        if (oDataConnectionSource != null) {
          oDataConnectionSource.disposeConnection();
        }
      }
      return data;

    } else {
      return JsonMessage.getJsonMsg("401", "Unauthorized");
    }
  }
Ejemplo n.º 4
0
 @Override
 public String remove() throws Exception {
   if (this.checkpermission("remove")) {
     Integer id = ParameterCook.prepareId(oRequest);
     String resultado = null;
     Connection oConnection = null;
     ConnectionInterface oDataConnectionSource = null;
     try {
       oDataConnectionSource = getSourceConnection();
       oConnection = oDataConnectionSource.newConnection();
       oConnection.setAutoCommit(false);
       EstadoDao oEstadoDao = new EstadoDao(oConnection);
       resultado = JsonMessage.getJson("200", (String) oEstadoDao.remove(id).toString());
       oConnection.commit();
     } catch (Exception ex) {
       if (oConnection != null) {
         oConnection.rollback();
       }
       ExceptionBooster.boost(
           new Exception(this.getClass().getName() + ":remove ERROR: " + ex.getMessage()));
     } finally {
       if (oConnection != null) {
         oConnection.close();
       }
       if (oDataConnectionSource != null) {
         oDataConnectionSource.disposeConnection();
       }
     }
     return resultado;
   } else {
     return JsonMessage.getJsonMsg("401", "Unauthorized");
   }
 }
Ejemplo n.º 5
0
 @Override
 public String set() throws Exception {
   if (this.checkpermission("set")) {
     String jason = ParameterCook.prepareJson(oRequest);
     String resultado = null;
     Connection oConnection = null;
     ConnectionInterface oDataConnectionSource = null;
     try {
       oDataConnectionSource = getSourceConnection();
       oConnection = oDataConnectionSource.newConnection();
       oConnection.setAutoCommit(false);
       EstadoDao oEstadoDao = new EstadoDao(oConnection);
       EstadoBean oEstadoBean = new EstadoBean();
       oEstadoBean = AppConfigurationHelper.getGson().fromJson(jason, oEstadoBean.getClass());
       if (oEstadoBean != null) {
         Integer iResult = oEstadoDao.set(oEstadoBean);
         if (iResult >= 1) {
           resultado = JsonMessage.getJson("200", iResult.toString());
         } else {
           resultado = JsonMessage.getJson("500", "Error during registry set");
         }
       } else {
         resultado = JsonMessage.getJson("500", "Error during registry set");
       }
       oConnection.commit();
     } catch (Exception ex) {
       if (oConnection != null) {
         oConnection.rollback();
       }
       ExceptionBooster.boost(
           new Exception(this.getClass().getName() + ":set ERROR: " + ex.getMessage()));
     } finally {
       if (oConnection != null) {
         oConnection.close();
       }
       if (oDataConnectionSource != null) {
         oDataConnectionSource.disposeConnection();
       }
     }
     return resultado;
   } else {
     return JsonMessage.getJsonMsg("401", "Unauthorized");
   }
 }