use of com.netsteadfast.greenstep.vo.DataSourceDriverVO in project bamboobsc by billchen198318.
the class DataSourceConfManagementAction method loadDataSourceConfData.
private void loadDataSourceConfData() throws ServiceException, Exception {
this.transformFields2ValueObject(this.dataSourceConf, new String[] { "oid" });
DefaultResult<DataSourceConfVO> result = this.dataSourceConfService.findObjectByOid(dataSourceConf);
if (result.getValue() == null) {
throw new ServiceException(result.getSystemMessage().getValue());
}
this.dataSourceConf = result.getValue();
DataSourceDriverVO driver = new DataSourceDriverVO();
driver.setId(dataSourceConf.getDriverId());
DefaultResult<DataSourceDriverVO> dResult = this.dataSourceDriverService.findByUK(driver);
if (dResult.getValue() != null) {
this.getFields().put("driverOid", dResult.getValue().getOid());
}
}
use of com.netsteadfast.greenstep.vo.DataSourceDriverVO in project bamboobsc by billchen198318.
the class DataSourceLogicServiceImpl method updateConf.
@ServiceMethodAuthority(type = { ServiceMethodType.UPDATE })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@Override
public DefaultResult<DataSourceConfVO> updateConf(String driverOid, DataSourceConfVO dataSourceConf) throws ServiceException, Exception {
if (super.isBlank(driverOid) || null == dataSourceConf) {
throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
}
DefaultResult<DataSourceConfVO> oldResult = this.dataSourceConfService.findObjectByOid(dataSourceConf);
if (oldResult.getValue() == null) {
throw new ServiceException(oldResult.getSystemMessage().getValue());
}
// ID 是 UK, 不允許變動
dataSourceConf.setId(oldResult.getValue().getId());
DataSourceDriverVO driver = new DataSourceDriverVO();
driver.setOid(driverOid);
DefaultResult<DataSourceDriverVO> dResult = this.dataSourceDriverService.findObjectByOid(driver);
if (dResult.getValue() == null) {
throw new ServiceException(dResult.getSystemMessage().getValue());
}
driver = dResult.getValue();
dataSourceConf.setDriverId(driver.getId());
if (super.defaultString(dataSourceConf.getJdbcUrl()).length() > MAX_JDBC_URL_LENGTH) {
throw new ServiceException("jdbc-url Only allows " + String.valueOf(MAX_JDBC_URL_LENGTH) + " characters!");
}
if (null == dataSourceConf.getDescription()) {
dataSourceConf.setDescription("");
}
this.setStringValueMaxLength(dataSourceConf, "description", MAX_DESCRIPTION_LENGTH);
return dataSourceConfService.updateObject(dataSourceConf);
}
use of com.netsteadfast.greenstep.vo.DataSourceDriverVO in project bamboobsc by billchen198318.
the class DataSourceLogicServiceImpl method createConf.
@ServiceMethodAuthority(type = { ServiceMethodType.INSERT })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@Override
public DefaultResult<DataSourceConfVO> createConf(String driverOid, DataSourceConfVO dataSourceConf) throws ServiceException, Exception {
if (super.isBlank(driverOid) || null == dataSourceConf) {
throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
}
DataSourceDriverVO driver = new DataSourceDriverVO();
driver.setOid(driverOid);
DefaultResult<DataSourceDriverVO> dResult = this.dataSourceDriverService.findObjectByOid(driver);
if (dResult.getValue() == null) {
throw new ServiceException(dResult.getSystemMessage().getValue());
}
driver = dResult.getValue();
dataSourceConf.setDriverId(driver.getId());
if (super.defaultString(dataSourceConf.getJdbcUrl()).length() > MAX_JDBC_URL_LENGTH) {
throw new ServiceException("jdbc-url Only allows " + String.valueOf(MAX_JDBC_URL_LENGTH) + " characters!");
}
if (null == dataSourceConf.getDescription()) {
dataSourceConf.setDescription("");
}
this.setStringValueMaxLength(dataSourceConf, "description", MAX_DESCRIPTION_LENGTH);
return this.dataSourceConfService.saveObject(dataSourceConf);
}
use of com.netsteadfast.greenstep.vo.DataSourceDriverVO 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;
}
Aggregations