Search in sources :

Example 1 with DataSourceConfVO

use of com.netsteadfast.greenstep.vo.DataSourceConfVO 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());
    }
}
Also used : DataSourceConfVO(com.netsteadfast.greenstep.vo.DataSourceConfVO) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) DataSourceDriverVO(com.netsteadfast.greenstep.vo.DataSourceDriverVO)

Example 2 with DataSourceConfVO

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

the class DataSourceConfSaveOrUpdateAction method delete.

private void delete() throws ControllerException, AuthorityException, ServiceException, Exception {
    DataSourceConfVO conf = new DataSourceConfVO();
    this.transformFields2ValueObject(conf, new String[] { "oid" });
    DefaultResult<Boolean> result = this.dataSourceLogicService.deleteConf(conf);
    this.message = result.getSystemMessage().getValue();
    if (result.getValue() != null && result.getValue()) {
        this.success = IS_YES;
    }
}
Also used : DataSourceConfVO(com.netsteadfast.greenstep.vo.DataSourceConfVO)

Example 3 with DataSourceConfVO

use of com.netsteadfast.greenstep.vo.DataSourceConfVO 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);
}
Also used : DataSourceConfVO(com.netsteadfast.greenstep.vo.DataSourceConfVO) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) DataSourceDriverVO(com.netsteadfast.greenstep.vo.DataSourceDriverVO) ServiceMethodAuthority(com.netsteadfast.greenstep.base.model.ServiceMethodAuthority) Transactional(org.springframework.transaction.annotation.Transactional)

Example 4 with DataSourceConfVO

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

the class DataSourceConfSaveOrUpdateAction method save.

private void save() throws ControllerException, AuthorityException, ServiceException, Exception {
    this.checkFields();
    DataSourceConfVO conf = new DataSourceConfVO();
    this.transformFields2ValueObject(conf, new String[] { "id", "name", "jdbcUrl", "dbAccount", "dbPassword", "description" });
    DefaultResult<DataSourceConfVO> result = this.dataSourceLogicService.createConf(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)

Example 5 with DataSourceConfVO

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

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