Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package org.jleaf.erp.master.bo.upload;
- import javax.persistence.NoResultException;
- import javax.persistence.Query;
- import org.jleaf.core.AbstractBusinessFunction;
- import org.jleaf.core.BusinessFunction;
- import org.jleaf.core.Dto;
- import org.jleaf.core.GeneralConstants;
- import org.jleaf.core.annotation.ErrorList;
- import org.jleaf.core.annotation.Info;
- import org.jleaf.core.annotation.InfoIn;
- import org.jleaf.core.annotation.InfoOut;
- import org.jleaf.erp.master.dao.ProductDao;
- import org.jleaf.util.ValidationUtil;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- /**
- * Find Upload Parameter By Index
- * @author Cong, 2017-05-10
- *
- * BF ini digunakan untuk mengambil value dari param upload csv dengan key header id dan key parameter
- * BF ini tidak menghasilkan exception
- * Jika param tidak di temukan, akan mengembalikan empty string
- *
- */
- @Service
- @InfoIn(value = {
- @Info(name = "ulHeaderId", description = "Upload header parameter id", type = Long.class, required = true),
- @Info(name = "key", description = "Key parameter", type = String.class, required = true)
- })
- @InfoOut(value = {
- @Info(name = "value", description = "result value parameter", type = String.class, required = true)
- })
- @ErrorList(errorKeys = {
- })
- public class FindUploadParameterByIndex extends AbstractBusinessFunction implements BusinessFunction{
- @Autowired
- ProductDao productDao;
- @Override
- public Dto execute(Dto inputDto) throws Exception {
- ValidationUtil.valDtoContainsKey(inputDto, "ulHeaderId");
- ValidationUtil.valDtoContainsKey(inputDto, "key");
- Long ulHeaderId = inputDto.getLong("ulHeaderId");
- String key = inputDto.getString("key");
- Dto outputDto = new Dto();
- Query query = productDao.createNativeQuery(" SELECT f_get_upload_parameter(:ulHeaderId, :key) as result ");
- query.setParameter("ulHeaderId", ulHeaderId);
- query.setParameter("key", key);
- Object result = null;
- try {
- result = query.getSingleResult();
- } catch (NoResultException e) {}
- if (result!=null) {
- outputDto.putString("value", result.toString());
- } else {
- outputDto.putString("value", GeneralConstants.EMPTY_VALUE);
- }
- return outputDto;
- }
- @Override
- public String getDescription() {
- return "Find Upload Parameter By Index";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement