Search in sources :

Example 1 with DataQueryVO

use of com.netsteadfast.greenstep.vo.DataQueryVO in project bamboobsc by billchen198318.

the class DataQueryServiceImpl method findForMap.

@Override
public Map<String, String> findForMap(boolean pleaseSelect) throws ServiceException, Exception {
    Map<String, String> dataMap = this.providedSelectZeroDataMap(pleaseSelect);
    List<DataQueryVO> searchList = this.dataQueryDAO.findForSimple();
    if (searchList == null || searchList.size() < 1) {
        return dataMap;
    }
    for (DataQueryVO query : searchList) {
        dataMap.put(query.getOid(), query.getName());
    }
    return dataMap;
}
Also used : DataQueryVO(com.netsteadfast.greenstep.vo.DataQueryVO)

Example 2 with DataQueryVO

use of com.netsteadfast.greenstep.vo.DataQueryVO in project bamboobsc by billchen198318.

the class QueryDataAction method update.

private void update() throws ControllerException, AuthorityException, ServiceException, Exception {
    this.checkFieldsForCreate();
    String dataSourceConfOid = this.getFields().get("dataSourceConfOid");
    String dataQueryMapperOid = this.getFields().get("dataQueryMapperOid");
    DataQueryVO dataQuery = new DataQueryVO();
    this.transformFields2ValueObject(dataQuery, new String[] { "oid", "name", "queryExpression" });
    DefaultResult<DataQueryVO> result = this.dataQueryLogicService.update(dataSourceConfOid, dataQueryMapperOid, dataQuery);
    this.message = result.getSystemMessage().getValue();
    if (result.getValue() != null) {
        this.success = IS_YES;
    }
}
Also used : DataQueryVO(com.netsteadfast.greenstep.vo.DataQueryVO)

Example 3 with DataQueryVO

use of com.netsteadfast.greenstep.vo.DataQueryVO in project bamboobsc by billchen198318.

the class DataQueryLogicServiceImpl method update.

@ServiceMethodAuthority(type = { ServiceMethodType.UPDATE })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@Override
public DefaultResult<DataQueryVO> update(String dataSourceConfOid, String dataQueryMapperOid, DataQueryVO dataQuery) throws ServiceException, Exception {
    if (super.isBlank(dataSourceConfOid) || super.isBlank(dataQueryMapperOid) || null == dataQuery || super.isBlank(dataQuery.getOid())) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
    }
    DataSourceConfVO conf = new DataSourceConfVO();
    conf.setOid(dataSourceConfOid);
    DefaultResult<DataSourceConfVO> confResult = dataSourceConfService.findObjectByOid(conf);
    if (confResult.getValue() == null) {
        throw new ServiceException(confResult.getSystemMessage().getValue());
    }
    conf = confResult.getValue();
    Map<String, Object> paramMap = new HashMap<String, Object>();
    paramMap.put("oid", dataQueryMapperOid);
    if (this.dataQueryMapperService.countByParams(paramMap) < 1) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.SEARCH_NO_DATA));
    }
    DefaultResult<DataQueryVO> oldResult = this.dataQueryService.findObjectByOid(dataQuery);
    if (oldResult.getValue() == null) {
        throw new ServiceException(oldResult.getSystemMessage().getValue());
    }
    if (oldResult.getValue().getName().equals(dataQuery.getName()) && !oldResult.getValue().getOid().equals(dataQuery.getOid())) {
        // 存在別筆資料但UK相同 , 所以不能 UPDATE
        throw new ServiceException("Please change another name!");
    }
    oldResult.getValue().setQueryExpression(null);
    // 先把BLOB 資料清掉
    this.dataQueryService.updateObject(oldResult.getValue());
    dataQuery.setConf(conf.getId());
    dataQuery.setMapperOid(dataQueryMapperOid);
    return this.dataQueryService.updateObject(dataQuery);
}
Also used : DataSourceConfVO(com.netsteadfast.greenstep.vo.DataSourceConfVO) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) HashMap(java.util.HashMap) DataQueryVO(com.netsteadfast.greenstep.vo.DataQueryVO) ServiceMethodAuthority(com.netsteadfast.greenstep.base.model.ServiceMethodAuthority) Transactional(org.springframework.transaction.annotation.Transactional)

Example 4 with DataQueryVO

use of com.netsteadfast.greenstep.vo.DataQueryVO in project bamboobsc by billchen198318.

the class CommonLoadDataAction method loadQueryHistory.

private void loadQueryHistory() throws ControllerException, AuthorityException, ServiceException, Exception {
    this.transformFields2ValueObject(this.dataQuery, new String[] { "oid" });
    DefaultResult<DataQueryVO> result = this.dataQueryService.findObjectByOid(this.dataQuery);
    if (result.getValue() == null) {
        throw new ServiceException(result.getSystemMessage().getValue());
    }
    this.dataQuery = result.getValue();
    DataSourceConfVO conf = new DataSourceConfVO();
    conf.setId(this.dataQuery.getConf());
    DefaultResult<DataSourceConfVO> confResult = this.dataSourceConfService.findByUK(conf);
    if (confResult.getValue() != null) {
        this.dataQuery.setDataSourceConfOid(confResult.getValue().getOid());
    }
    this.success = IS_YES;
}
Also used : DataSourceConfVO(com.netsteadfast.greenstep.vo.DataSourceConfVO) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) DataQueryVO(com.netsteadfast.greenstep.vo.DataQueryVO)

Example 5 with DataQueryVO

use of com.netsteadfast.greenstep.vo.DataQueryVO in project bamboobsc by billchen198318.

the class QueryDataAction method save.

private void save() throws ControllerException, AuthorityException, ServiceException, Exception {
    this.checkFieldsForCreate();
    String dataSourceConfOid = this.getFields().get("dataSourceConfOid");
    String dataQueryMapperOid = this.getFields().get("dataQueryMapperOid");
    DataQueryVO dataQuery = new DataQueryVO();
    this.transformFields2ValueObject(dataQuery, new String[] { "name", "queryExpression" });
    DefaultResult<DataQueryVO> result = this.dataQueryLogicService.create(dataSourceConfOid, dataQueryMapperOid, dataQuery);
    this.message = result.getSystemMessage().getValue();
    if (result.getValue() != null) {
        this.success = IS_YES;
    }
}
Also used : DataQueryVO(com.netsteadfast.greenstep.vo.DataQueryVO)

Aggregations

DataQueryVO (com.netsteadfast.greenstep.vo.DataQueryVO)6 ServiceException (com.netsteadfast.greenstep.base.exception.ServiceException)2 DataSourceConfVO (com.netsteadfast.greenstep.vo.DataSourceConfVO)2 ServiceMethodAuthority (com.netsteadfast.greenstep.base.model.ServiceMethodAuthority)1 HashMap (java.util.HashMap)1 Transactional (org.springframework.transaction.annotation.Transactional)1