Search in sources :

Example 6 with DataSourceConfVO

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

the class DataQueryLogicServiceImpl method create.

@ServiceMethodAuthority(type = { ServiceMethodType.INSERT })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@Override
public DefaultResult<DataQueryVO> create(String dataSourceConfOid, String dataQueryMapperOid, DataQueryVO dataQuery) throws ServiceException, Exception {
    if (super.isNoSelectId(dataSourceConfOid) || super.isNoSelectId(dataQueryMapperOid) || null == dataQuery) {
        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));
    }
    dataQuery.setConf(conf.getId());
    dataQuery.setMapperOid(dataQueryMapperOid);
    return this.dataQueryService.saveObject(dataQuery);
}
Also used : DataSourceConfVO(com.netsteadfast.greenstep.vo.DataSourceConfVO) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) HashMap(java.util.HashMap) ServiceMethodAuthority(com.netsteadfast.greenstep.base.model.ServiceMethodAuthority) Transactional(org.springframework.transaction.annotation.Transactional)

Example 7 with DataSourceConfVO

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

the class ManualJdbcTemplateFactory method getManualJdbcTemplate.

public static NamedParameterJdbcTemplate getManualJdbcTemplate(String confOid) throws ServiceException, Exception {
    if (jdbcTemplateTreadLocal.get() != null && jdbcTemplateTreadLocal.get().getDataSourceConf().getOid().equals(confOid)) {
        return jdbcTemplateTreadLocal.get().getJdbcTemplate();
    }
    DataSourceConfVO conf = new DataSourceConfVO();
    conf.setOid(confOid);
    DefaultResult<DataSourceConfVO> confResult = dataSourceConfService.findObjectByOid(conf);
    if (confResult.getValue() == null) {
        throw new ServiceException(confResult.getSystemMessage().getValue());
    }
    conf = confResult.getValue();
    DataSourceDriverVO driver = new DataSourceDriverVO();
    driver.setId(conf.getDriverId());
    DefaultResult<DataSourceDriverVO> driverResult = dataSourceDriverService.findByUK(driver);
    if (driverResult.getValue() == null) {
        throw new ServiceException(driverResult.getSystemMessage().getValue());
    }
    driver = driverResult.getValue();
    NamedParameterJdbcTemplate jdbcTemplate = DataUtils.getManualJdbcTemplate(Class.forName(driver.getClassName()), conf.getJdbcUrl(), conf.getDbAccount(), conf.getDbPassword());
    DataProperty dataProperty = new DataProperty();
    dataProperty.setDataSourceConf(conf);
    dataProperty.setJdbcTemplate(jdbcTemplate);
    jdbcTemplateTreadLocal.set(dataProperty);
    return jdbcTemplate;
}
Also used : DataSourceConfVO(com.netsteadfast.greenstep.vo.DataSourceConfVO) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) NamedParameterJdbcTemplate(org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate) DataSourceDriverVO(com.netsteadfast.greenstep.vo.DataSourceDriverVO)

Example 8 with DataSourceConfVO

use of com.netsteadfast.greenstep.vo.DataSourceConfVO 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 9 with DataSourceConfVO

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

the class DataSourceConfSaveOrUpdateAction method update.

private void update() throws ControllerException, AuthorityException, ServiceException, Exception {
    this.checkFields();
    DataSourceConfVO conf = new DataSourceConfVO();
    this.transformFields2ValueObject(conf, new String[] { "oid", "id", "name", "jdbcUrl", "dbAccount", "dbPassword", "description" });
    DefaultResult<DataSourceConfVO> result = this.dataSourceLogicService.updateConf(this.getFields().get("driverOid"), conf);
    this.message = result.getSystemMessage().getValue();
    if (result.getValue() != null) {
        this.success = IS_YES;
    }
}
Also used : DataSourceConfVO(com.netsteadfast.greenstep.vo.DataSourceConfVO)

Aggregations

DataSourceConfVO (com.netsteadfast.greenstep.vo.DataSourceConfVO)9 ServiceException (com.netsteadfast.greenstep.base.exception.ServiceException)6 ServiceMethodAuthority (com.netsteadfast.greenstep.base.model.ServiceMethodAuthority)3 DataSourceDriverVO (com.netsteadfast.greenstep.vo.DataSourceDriverVO)3 Transactional (org.springframework.transaction.annotation.Transactional)3 DataQueryVO (com.netsteadfast.greenstep.vo.DataQueryVO)2 HashMap (java.util.HashMap)2 NamedParameterJdbcTemplate (org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate)1