Search in sources :

Example 6 with SmsConfiguration

use of org.hisp.dhis.sms.config.SmsConfiguration in project dhis2-core by dhis2.

the class SmsConfigurationController method getTest.

@GetMapping("test")
@ResponseBody
public SmsConfiguration getTest() {
    SmsConfiguration smsConfiguration = new SmsConfiguration();
    SmsGatewayConfig gatewayConfig = new GenericHttpGatewayConfig();
    gatewayConfig.setUrlTemplate("http://storset.org/");
    smsConfiguration.setGateways(Collections.singletonList(gatewayConfig));
    return smsConfiguration;
}
Also used : SmsConfiguration(org.hisp.dhis.sms.config.SmsConfiguration) SmsGatewayConfig(org.hisp.dhis.sms.config.SmsGatewayConfig) GenericHttpGatewayConfig(org.hisp.dhis.sms.config.GenericHttpGatewayConfig) GetMapping(org.springframework.web.bind.annotation.GetMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 7 with SmsConfiguration

use of org.hisp.dhis.sms.config.SmsConfiguration in project dhis2-core by dhis2.

the class V2_34_6__Convert_systemsetting_value_column_from_bytea_to_string method fetchExistingSystemSettings.

private Set<SystemSetting> fetchExistingSystemSettings(final Context context) throws SQLException {
    Set<SystemSetting> systemSettingsToConvert = new HashSet<>();
    try (Statement stmt = context.getConnection().createStatement();
        ResultSet rs = stmt.executeQuery("select * from systemsetting")) {
        while (rs.next()) {
            String name = rs.getString("name");
            SystemSetting systemSetting = new SystemSetting();
            systemSetting.setId(rs.getLong("systemsettingid"));
            systemSetting.setName(name);
            if (SMS_CONFIGURATION_SETTING_NAME.equals(name)) {
                SmsConfiguration smsConfiguration = (SmsConfiguration) SerializationUtils.deserialize(rs.getBytes("value"));
                updateSmsConfiguration(smsConfiguration);
                systemSetting.setValue(smsConfiguration);
            } else {
                systemSetting.setValue((Serializable) SerializationUtils.deserialize(rs.getBytes("value")));
            }
            systemSettingsToConvert.add(systemSetting);
        }
    }
    return systemSettingsToConvert;
}
Also used : PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) SmsConfiguration(org.hisp.dhis.sms.config.SmsConfiguration) ResultSet(java.sql.ResultSet) HashSet(java.util.HashSet)

Example 8 with SmsConfiguration

use of org.hisp.dhis.sms.config.SmsConfiguration in project dhis2-core by dhis2.

the class DefaultSmsConfigurationManager method initializeSmsConfig.

private void initializeSmsConfig() {
    SmsConfiguration smsConfiguration = getSmsConfiguration();
    if (smsConfiguration == null) {
        log.info("SMS configuration not found");
        return;
    }
    List<SmsGatewayConfig> gatewayList = smsConfiguration.getGateways();
    if (gatewayList == null || gatewayList.isEmpty()) {
        log.info("Gateway configuration not found");
        return;
    }
    log.info("Gateway configurations found: " + gatewayList);
    gatewayAdminService.loadGatewayConfigurationMap(smsConfiguration);
}
Also used : SmsConfiguration(org.hisp.dhis.sms.config.SmsConfiguration) SmsGatewayConfig(org.hisp.dhis.sms.config.SmsGatewayConfig)

Example 9 with SmsConfiguration

use of org.hisp.dhis.sms.config.SmsConfiguration in project dhis2-core by dhis2.

the class DefaultSmsConfigurationManager method setDefaultSMSGateway.

@Override
public boolean setDefaultSMSGateway(String gatewayId) {
    boolean result = false;
    SmsConfiguration config = getSmsConfiguration();
    if (config == null) {
        return result;
    }
    List<SmsGatewayConfig> smsGatewayList = config.getGateways();
    for (SmsGatewayConfig gw : smsGatewayList) {
        if (gw.getName().equals(gatewayId)) {
            gw.setDefault(true);
            result = true;
        } else {
            gw.setDefault(false);
        }
    }
    updateSmsConfiguration(config);
    return result;
}
Also used : SmsConfiguration(org.hisp.dhis.sms.config.SmsConfiguration) SmsGatewayConfig(org.hisp.dhis.sms.config.SmsGatewayConfig)

Example 10 with SmsConfiguration

use of org.hisp.dhis.sms.config.SmsConfiguration in project dhis2-core by dhis2.

the class DefaultSmsConfigurationManager method checkInstanceOfGateway.

@Override
public SmsGatewayConfig checkInstanceOfGateway(Class<?> clazz) {
    if (getSmsConfiguration() == null) {
        SmsConfiguration smsConfig = new SmsConfiguration(true);
        updateSmsConfiguration(smsConfig);
    }
    for (SmsGatewayConfig gateway : getSmsConfiguration().getGateways()) {
        if (gateway.getClass().equals(clazz)) {
            return gateway;
        }
    }
    return null;
}
Also used : SmsConfiguration(org.hisp.dhis.sms.config.SmsConfiguration) SmsGatewayConfig(org.hisp.dhis.sms.config.SmsGatewayConfig)

Aggregations

SmsConfiguration (org.hisp.dhis.sms.config.SmsConfiguration)14 SmsGatewayConfig (org.hisp.dhis.sms.config.SmsGatewayConfig)8 BulkSmsGatewayConfig (org.hisp.dhis.sms.config.BulkSmsGatewayConfig)4 ClickatellGatewayConfig (org.hisp.dhis.sms.config.ClickatellGatewayConfig)3 GenericHttpGatewayConfig (org.hisp.dhis.sms.config.GenericHttpGatewayConfig)3 HashSet (java.util.HashSet)2 PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1 Statement (java.sql.Statement)1 Date (java.util.Date)1 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)1 ProgramMessageQueryParams (org.hisp.dhis.program.message.ProgramMessageQueryParams)1 ProgramMessageRecipients (org.hisp.dhis.program.message.ProgramMessageRecipients)1 GetMapping (org.springframework.web.bind.annotation.GetMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1