|
|||||||
loadEntityFromJson
Время создания: 09.09.2020 18:11
Раздел: INFO - JOB - CUBA - GroovyScripts - TestingScripts
Запись: wwwlir/Tetra/master/base/1599646277acbkso4zwa/text.html на raw.githubusercontent.com
|
|||||||
|
|||||||
//Глобальные import com.haulmont.cuba.core.global.*; import com.groupstp.rtneo.entity.* import java.text.DateFormat; import java.text.SimpleDateFormat; // import com.groupstp.rtneo.service.ContractServiceBean; import java.lang.reflect.* def helper = AppBeans.get(ContractServiceBean.NAME) //'5321e07a-bbb6-5f3f-5618-ad3ea3be539b' helper.loadEntityFromJson(UUID.fromString('5321e07a-bbb6-5f3f-5618-ad3ea3be539b')) /** * Логирование */ import com.haulmont.cuba.core.app.serialization.EntitySerializationAPI; import com.groupstp.rtneo.util.JsonUtil; import java.text.DateFormat; import java.text.SimpleDateFormat; private _(Object obj, String... options){ if(obj == null){log("LOG.ERROR: Object is null!!!");return} if(options.size() == 0){log(obj)} for(def option : options){ if(option.equals("str")){log(obj)} if(option.equals("for")){obj.each({_(it)})} if(option.equals("json")){ EntitySerializationAPI entitySerializationAPI = AppBeans.get(EntitySerializationAPI.NAME) try{log(entitySerializationAPI.toJson(obj))} catch(Exception e){log("LOG.ERROR: JSON entity serialization failed")} } if(option.equals("objJson")){ JsonUtil jsonUtil = AppBeans.get(JsonUtil.NAME) try{log.(jsonUtil.toJson(obj))} catch(Exception e){log("LOG.ERROR: JSON object serialization failed")} } if(option.equals("date")){ DateFormat df = new SimpleDateFormat("dd.MM.yyyy"); try{log(df.format(obj))} catch(Exception e){log("LOG.ERROR: Failed date format")} } } } private log(Object obj){log.debug(obj)} |
|||||||
Так же в этом разделе:
|
|||||||
|
|||||||
|