Example #1
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();
        NumpapelDao oNumpapelDao = new NumpapelDao(oConnection);
        NumpapelBean oNumpapelBean = new NumpapelBean(id);
        oNumpapelBean = oNumpapelDao.get(oNumpapelBean, AppConfigurationHelper.getJsonDepth());
        Gson gson = AppConfigurationHelper.getGson();
        data = JsonMessage.getJson("200", AppConfigurationHelper.getGson().toJson(oNumpapelBean));
      } 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");
    }
  }
Example #2
0
 @Override
 public String getcount() throws Exception {
   if (this.checkpermission("getcount")) {
     String data = null;
     ArrayList<FilterBeanHelper> alFilter = ParameterCook.prepareFilter(oRequest);
     Connection oConnection = null;
     ConnectionInterface oDataConnectionSource = null;
     try {
       oDataConnectionSource = getSourceConnection();
       oConnection = oDataConnectionSource.newConnection();
       NumpapelDao oNumpapelDao = new NumpapelDao(oConnection);
       data = JsonMessage.getJson("200", Integer.toString(oNumpapelDao.getCount(alFilter)));
     } catch (Exception ex) {
       ExceptionBooster.boost(
           new Exception(this.getClass().getName() + ":getCount ERROR: " + ex.getMessage()));
     } finally {
       if (oConnection != null) {
         oConnection.close();
       }
       if (oDataConnectionSource != null) {
         oDataConnectionSource.disposeConnection();
       }
     }
     return data;
   } else {
     return JsonMessage.getJsonMsg("401", "Unauthorized");
   }
 }
Example #3
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);
       NumpapelDao oNumpapelDao = new NumpapelDao(oConnection);
       resultado = JsonMessage.getJson("200", (String) oNumpapelDao.remove(id).toString());
       oConnection.commit();
     } catch (Exception ex) {
       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");
   }
 }
Example #4
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();
       NumpapelDao oNumpapelDao = new NumpapelDao(oConnection);
       List<NumpapelBean> arrBeans =
           oNumpapelDao.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");
   }
 }
Example #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);
       NumpapelDao oNumpapelDao = new NumpapelDao(oConnection);
       NumpapelBean oNumpapelBean = new NumpapelBean();
       oNumpapelBean = AppConfigurationHelper.getGson().fromJson(jason, oNumpapelBean.getClass());
       if (oNumpapelBean != null) {
         Integer iResult = oNumpapelDao.set(oNumpapelBean);
         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) {
       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");
   }
 }