List of usage examples for com.google.gson GsonBuilder create
public Gson create()
From source file:com.goplace.service.generic.specific.implementation.ComentarioServiceGenSpImpl.java
License:Open Source License
@Override public String get(Integer id) throws Exception { String data = null;// w w w. ja v a 2 s .c om try { oConnection.setAutoCommit(false); ComentarioDaoGenSpImpl oComentarioDAO = new ComentarioDaoGenSpImpl(strObjectName, oConnection); ComentarioBeanGenSpImpl oComentario = new ComentarioBeanGenSpImpl(id); oComentario = oComentarioDAO.get(oComentario, AppConfigurationHelper.getJsonDepth()); GsonBuilder gsonBuilder = new GsonBuilder(); gsonBuilder.setDateFormat("dd/MM/yyyy HH:mm:ss"); Gson gson = gsonBuilder.create(); data = gson.toJson(oComentario); oConnection.commit(); } catch (Exception ex) { oConnection.rollback(); ExceptionBooster.boost(new Exception(this.getClass().getName() + ":get ERROR: " + ex.getMessage())); } return data; }
From source file:com.goplace.service.generic.specific.implementation.ComentarioServiceGenSpImpl.java
License:Open Source License
public String getPageComentarios(int id_evento, int intRegsPerPag, int intPage, ArrayList<FilterBeanHelper> alFilter, HashMap<String, String> hmOrder) throws Exception { String data = null;/*from w ww.j a v a 2 s.c om*/ try { oConnection.setAutoCommit(false); ComentarioDaoGenSpImpl oComentarioDAO = new ComentarioDaoGenSpImpl(strObjectName, oConnection); List<ComentarioBeanGenSpImpl> oComentarios = oComentarioDAO.getPageComentarios(id_evento, intRegsPerPag, intPage, alFilter, hmOrder); GsonBuilder gsonBuilder = new GsonBuilder(); gsonBuilder.setDateFormat("dd/MM/yyyy HH:mm:ss"); Gson gson = gsonBuilder.create(); data = gson.toJson(oComentarios); data = "{\"list\":" + data + "}"; oConnection.commit(); } catch (Exception ex) { oConnection.rollback(); ExceptionBooster.boost(new Exception(this.getClass().getName() + ":getPage ERROR: " + ex.getMessage())); } return data; }
From source file:com.goplace.service.generic.specific.implementation.PublicacionServiceGenSpImpl.java
License:Open Source License
@Override public String get(Integer id) throws Exception { String data = null;// w w w. j a va2 s.c o m try { oConnection.setAutoCommit(false); PublicacionDaoGenSpImpl oPublicacionDAO = new PublicacionDaoGenSpImpl(strObjectName, oConnection); PublicacionBeanGenSpImpl oPublicacion = new PublicacionBeanGenSpImpl(id); oPublicacion = oPublicacionDAO.get(oPublicacion, AppConfigurationHelper.getJsonDepth()); GsonBuilder gsonBuilder = new GsonBuilder(); gsonBuilder.setDateFormat("dd/MM/yyyy"); Gson gson = gsonBuilder.create(); data = gson.toJson(oPublicacion); oConnection.commit(); } catch (Exception ex) { oConnection.rollback(); ExceptionBooster.boost(new Exception(this.getClass().getName() + ":get ERROR: " + ex.getMessage())); } return data; }
From source file:com.goplace.service.generic.specific.implementation.PublicacionServiceGenSpImpl.java
License:Open Source License
public String getPageEventos(int id_usuario, int intRegsPerPag, int intPage, ArrayList<FilterBeanHelper> alFilter, HashMap<String, String> hmOrder) throws Exception { String data = null;/*from ww w . j a v a 2 s . c om*/ try { oConnection.setAutoCommit(false); PublicacionDaoGenSpImpl oPublicacionDAO = new PublicacionDaoGenSpImpl(strObjectName, oConnection); List<PublicacionBeanGenSpImpl> oPublicacions = oPublicacionDAO.getPageEventos(id_usuario, intRegsPerPag, intPage, alFilter, hmOrder); GsonBuilder gsonBuilder = new GsonBuilder(); gsonBuilder.setDateFormat("dd/MM/yyyy HH:mm:ss"); Gson gson = gsonBuilder.create(); data = gson.toJson(oPublicacions); data = "{\"list\":" + data + "}"; oConnection.commit(); } catch (Exception ex) { oConnection.rollback(); ExceptionBooster.boost(new Exception(this.getClass().getName() + ":getPage ERROR: " + ex.getMessage())); } return data; }
From source file:com.greensopinion.finance.services.persistence.PersistenceGsonProvider.java
License:Apache License
public Gson get() { GsonBuilder gsonBuilder = builder(); gsonBuilder.registerTypeAdapter(Date.class, new DateTypeAdapter()); gsonBuilder.registerTypeAdapterFactory(TransactionsTypeAdapter.factory(encryptorProviderService)); gsonBuilder.registerTypeAdapterFactory(CategoriesTypeAdapter.factory(encryptorProviderService)); return gsonBuilder.create(); }
From source file:com.greensopinion.finance.services.web.WebGsonProvider.java
License:Apache License
@Override public Gson get() { GsonBuilder gsonBuilder = builder(); gsonBuilder.registerTypeAdapter(Date.class, new DateTypeAdapter()); return gsonBuilder.create(); }
From source file:com.gst.infrastructure.core.serialization.CommandProcessingResultJsonSerializer.java
License:Apache License
public CommandProcessingResultJsonSerializer() { final GsonBuilder builder = new GsonBuilder(); builder.registerTypeAdapter(LocalDate.class, new JodaLocalDateAdapter()); builder.registerTypeAdapter(DateTime.class, new JodaDateTimeAdapter()); builder.registerTypeAdapter(MonthDay.class, new JodaMonthDayAdapter()); builder.serializeNulls();//from w w w.j av a 2 s . c om this.gson = builder.create(); }
From source file:com.gst.infrastructure.core.serialization.ExcludeNothingWithPrettyPrintingOffJsonSerializerGoogleGson.java
License:Apache License
public ExcludeNothingWithPrettyPrintingOffJsonSerializerGoogleGson() { final GsonBuilder builder = new GsonBuilder(); builder.registerTypeAdapter(LocalDate.class, new JodaLocalDateAdapter()); builder.registerTypeAdapter(DateTime.class, new JodaDateTimeAdapter()); builder.registerTypeAdapter(MonthDay.class, new JodaMonthDayAdapter()); this.gson = builder.create(); }
From source file:com.gst.infrastructure.core.serialization.ExcludeNothingWithPrettyPrintingOnJsonSerializerGoogleGson.java
License:Apache License
public ExcludeNothingWithPrettyPrintingOnJsonSerializerGoogleGson() { final GsonBuilder builder = new GsonBuilder(); builder.registerTypeAdapter(LocalDate.class, new JodaLocalDateAdapter()); builder.registerTypeAdapter(DateTime.class, new JodaDateTimeAdapter()); builder.registerTypeAdapter(MonthDay.class, new JodaMonthDayAdapter()); builder.setPrettyPrinting();//from ww w . j a va 2s .c om this.gson = builder.create(); }
From source file:com.gst.infrastructure.core.serialization.GoogleGsonSerializerHelper.java
License:Apache License
public Gson createGsonBuilder(final boolean prettyPrint) { final GsonBuilder builder = new GsonBuilder(); builder.registerTypeAdapter(LocalDate.class, new JodaLocalDateAdapter()); builder.registerTypeAdapter(DateTime.class, new JodaDateTimeAdapter()); builder.registerTypeAdapter(MonthDay.class, new JodaMonthDayAdapter()); if (prettyPrint) { builder.setPrettyPrinting();//from w ww . j a v a2 s . co m } return builder.create(); }