Search in sources :

Example 1 with SqlServerEntity

use of com.microsoft.azure.toolkit.lib.sqlserver.model.SqlServerEntity in project azure-tools-for-java by Microsoft.

the class SqlServerPropertyView method showProperty.

// @Override
public void showProperty(SqlServerProperty property) {
    SqlServerEntity entity = property.getServer().entity();
    Subscription subscription = Azure.az(AzureAccount.class).account().getSubscription(entity.getSubscriptionId());
    if (subscription != null) {
        overview.getSubscriptionTextField().setText(subscription.getName());
    }
    databaseComboBox.setServer(property.getServer());
    overview.getResourceGroupTextField().setText(entity.getResourceGroupName());
    overview.getStatusTextField().setText(entity.getState());
    overview.getLocationTextField().setText(entity.getRegion().getLabel());
    overview.getSubscriptionIDTextField().setText(entity.getSubscriptionId());
    overview.getServerNameTextField().setText(entity.getFullyQualifiedDomainName());
    overview.getServerNameTextField().setCaretPosition(0);
    overview.getServerAdminLoginNameTextField().setText(entity.getAdministratorLoginName() + "@" + entity.getName());
    overview.getServerAdminLoginNameTextField().setCaretPosition(0);
    overview.getVersionTextField().setText(entity.getVersion());
    if ("Ready".equals(entity.getState())) {
        List<FirewallRuleEntity> firewallRules = property.getFirewallRules();
        originalAllowAccessToAzureServices = firewallRules.stream().anyMatch(e -> FirewallRuleEntity.ACCESS_FROM_AZURE_SERVICES_FIREWALL_RULE_NAME.equalsIgnoreCase(e.getName()));
        connectionSecurity.getAllowAccessFromAzureServicesCheckBox().setSelected(originalAllowAccessToAzureServices);
        originalAllowAccessToLocal = firewallRules.stream().anyMatch(e -> StringUtils.equalsIgnoreCase(FirewallRuleEntity.getAccessFromLocalFirewallRuleName(), e.getName()));
        connectionSecurity.getAllowAccessFromLocalMachineCheckBox().setSelected(originalAllowAccessToLocal);
    } else {
        connectionSecuritySeparator.collapse();
        connectionSecuritySeparator.setEnabled(false);
        connectionStringsSeparator.collapse();
        connectionStringsSeparator.setEnabled(false);
    }
}
Also used : Azure(com.microsoft.azure.toolkit.lib.Azure) VirtualFile(com.intellij.openapi.vfs.VirtualFile) FirewallRuleEntity(com.microsoft.azure.toolkit.lib.database.entity.FirewallRuleEntity) Node(com.microsoft.tooling.msservices.serviceexplorer.Node) HashMap(java.util.HashMap) StringUtils(org.apache.commons.lang3.StringUtils) SqlServerEntity(com.microsoft.azure.toolkit.lib.sqlserver.model.SqlServerEntity) AzureTask(com.microsoft.azure.toolkit.lib.common.task.AzureTask) FileEditorManager(com.intellij.openapi.fileEditor.FileEditorManager) SqlDatabaseEntity(com.microsoft.azure.toolkit.lib.sqlserver.model.SqlDatabaseEntity) Map(java.util.Map) Project(com.intellij.openapi.project.Project) Nonnull(javax.annotation.Nonnull) SqlServerModule(com.microsoft.tooling.msservices.serviceexplorer.azure.sqlserver.SqlServerModule) Subscription(com.microsoft.azure.toolkit.lib.common.model.Subscription) ConnectionStringsOutputPanel(com.microsoft.azure.toolkit.intellij.database.ui.ConnectionStringsOutputPanel) ItemEvent(java.awt.event.ItemEvent) AzureToolkitRuntimeException(com.microsoft.azure.toolkit.lib.common.exception.AzureToolkitRuntimeException) ActionConstants(com.microsoft.azuretools.ActionConstants) SqlServerProperty(com.microsoft.tooling.msservices.serviceexplorer.azure.sqlserver.SqlServerProperty) MySQLPropertyActionPanel(com.microsoft.azure.toolkit.intellij.database.ui.MySQLPropertyActionPanel) SqlServer(com.microsoft.azure.toolkit.lib.sqlserver.SqlServer) BaseEditor(com.microsoft.azure.toolkit.intellij.common.BaseEditor) ActionEvent(java.awt.event.ActionEvent) JdbcUrl(com.microsoft.azure.toolkit.lib.database.JdbcUrl) DatabaseTemplateUtils(com.microsoft.azure.toolkit.lib.database.utils.DatabaseTemplateUtils) DatabaseComboBox(com.microsoft.azure.toolkit.intellij.database.DatabaseComboBox) List(java.util.List) AzureSqlServer(com.microsoft.azure.toolkit.lib.sqlserver.AzureSqlServer) EventType(com.microsoft.azuretools.telemetrywrapper.EventType) AzureAccount(com.microsoft.azure.toolkit.lib.auth.AzureAccount) TelemetryConstants(com.microsoft.azuretools.telemetry.TelemetryConstants) MvpView(com.microsoft.azuretools.core.mvp.ui.base.MvpView) AzureEventBus(com.microsoft.azure.toolkit.lib.common.event.AzureEventBus) EventUtil(com.microsoft.azuretools.telemetrywrapper.EventUtil) AzureHideableTitledSeparator(com.microsoft.azure.toolkit.intellij.common.AzureHideableTitledSeparator) NotNull(org.jetbrains.annotations.NotNull) ConnectionSecurityPanel(com.microsoft.azure.toolkit.intellij.database.ui.ConnectionSecurityPanel) Utils(com.microsoft.azuretools.azurecommons.util.Utils) AzureTaskManager(com.microsoft.azure.toolkit.lib.common.task.AzureTaskManager) javax.swing(javax.swing) SqlServerEntity(com.microsoft.azure.toolkit.lib.sqlserver.model.SqlServerEntity) FirewallRuleEntity(com.microsoft.azure.toolkit.lib.database.entity.FirewallRuleEntity) Subscription(com.microsoft.azure.toolkit.lib.common.model.Subscription)

Example 2 with SqlServerEntity

use of com.microsoft.azure.toolkit.lib.sqlserver.model.SqlServerEntity in project azure-tools-for-java by Microsoft.

the class SqlServerPropertyView method onDatabaseComboBoxChanged.

private void onDatabaseComboBoxChanged(ItemEvent e) {
    if (e.getStateChange() == ItemEvent.SELECTED && e.getItem() instanceof SqlDatabaseEntity) {
        final SqlDatabaseEntity database = (SqlDatabaseEntity) e.getItem();
        SqlServerEntity entity = this.property.getServer().entity();
        JdbcUrl jdbcUrl = this.getJdbcUrl(entity.getFullyQualifiedDomainName(), database.getName(), overview.getServerAdminLoginNameTextField().getText());
        connectionStringsJDBC.getOutputTextArea().setText(DatabaseTemplateUtils.toJdbcTemplate(jdbcUrl));
        connectionStringsSpring.getOutputTextArea().setText(DatabaseTemplateUtils.toSpringTemplate(jdbcUrl, SQLSERVER_DRIVER_CLASS_NAME));
    }
}
Also used : JdbcUrl(com.microsoft.azure.toolkit.lib.database.JdbcUrl) SqlServerEntity(com.microsoft.azure.toolkit.lib.sqlserver.model.SqlServerEntity) SqlDatabaseEntity(com.microsoft.azure.toolkit.lib.sqlserver.model.SqlDatabaseEntity)

Example 3 with SqlServerEntity

use of com.microsoft.azure.toolkit.lib.sqlserver.model.SqlServerEntity in project azure-tools-for-java by Microsoft.

the class OpenSqlServerByToolsAction method doActionPerformed.

@AzureOperation(name = "sqlserver|server.open_by_database_tools", params = { "this.node.getServer().entity().getName()" }, type = AzureOperation.Type.ACTION)
private void doActionPerformed(Project project) {
    SqlServerEntity entity = node.getServer().entity();
    IntellijDatasourceService.DatasourceProperties properties = IntellijDatasourceService.DatasourceProperties.builder().name(String.format(NAME_PREFIX, entity.getName())).driverClassName(DEFAULT_DRIVER_CLASS_NAME).url(JdbcUrl.sqlserver(entity.getFullyQualifiedDomainName()).toString()).username(entity.getAdministratorLoginName() + "@" + entity.getName()).build();
    IntellijDatasourceService.getInstance().openDataSourceManagerDialog(project, properties);
}
Also used : SqlServerEntity(com.microsoft.azure.toolkit.lib.sqlserver.model.SqlServerEntity) IntellijDatasourceService(com.microsoft.azure.toolkit.intellij.common.IntellijDatasourceService) AzureOperation(com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)

Example 4 with SqlServerEntity

use of com.microsoft.azure.toolkit.lib.sqlserver.model.SqlServerEntity in project azure-tools-for-java by Microsoft.

the class SqlServerPropertyView method refreshProperty.

private void refreshProperty(String sid, String resourceGroup, String name) {
    // find server
    try {
        SqlServer server = Azure.az(AzureSqlServer.class).sqlServer(sid, resourceGroup, name);
        this.property.setServer(server);
    } catch (Exception ex) {
        String error = "find Azure Database for MySQL server information";
        String action = "confirm your network is available and your server actually exists.";
        throw new AzureToolkitRuntimeException(error, action);
    }
    SqlServerEntity entity = property.getServer().entity();
    if ("Ready".equals(entity.getState())) {
        // find firewalls
        List<FirewallRuleEntity> firewallRules = Azure.az(AzureSqlServer.class).sqlServer(entity.getId()).firewallRules();
        this.property.setFirewallRules(firewallRules);
    }
}
Also used : AzureSqlServer(com.microsoft.azure.toolkit.lib.sqlserver.AzureSqlServer) SqlServerEntity(com.microsoft.azure.toolkit.lib.sqlserver.model.SqlServerEntity) AzureToolkitRuntimeException(com.microsoft.azure.toolkit.lib.common.exception.AzureToolkitRuntimeException) FirewallRuleEntity(com.microsoft.azure.toolkit.lib.database.entity.FirewallRuleEntity) SqlServer(com.microsoft.azure.toolkit.lib.sqlserver.SqlServer) AzureSqlServer(com.microsoft.azure.toolkit.lib.sqlserver.AzureSqlServer) AzureToolkitRuntimeException(com.microsoft.azure.toolkit.lib.common.exception.AzureToolkitRuntimeException)

Aggregations

SqlServerEntity (com.microsoft.azure.toolkit.lib.sqlserver.model.SqlServerEntity)4 AzureToolkitRuntimeException (com.microsoft.azure.toolkit.lib.common.exception.AzureToolkitRuntimeException)2 JdbcUrl (com.microsoft.azure.toolkit.lib.database.JdbcUrl)2 FirewallRuleEntity (com.microsoft.azure.toolkit.lib.database.entity.FirewallRuleEntity)2 AzureSqlServer (com.microsoft.azure.toolkit.lib.sqlserver.AzureSqlServer)2 SqlServer (com.microsoft.azure.toolkit.lib.sqlserver.SqlServer)2 SqlDatabaseEntity (com.microsoft.azure.toolkit.lib.sqlserver.model.SqlDatabaseEntity)2 FileEditorManager (com.intellij.openapi.fileEditor.FileEditorManager)1 Project (com.intellij.openapi.project.Project)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 AzureHideableTitledSeparator (com.microsoft.azure.toolkit.intellij.common.AzureHideableTitledSeparator)1 BaseEditor (com.microsoft.azure.toolkit.intellij.common.BaseEditor)1 IntellijDatasourceService (com.microsoft.azure.toolkit.intellij.common.IntellijDatasourceService)1 DatabaseComboBox (com.microsoft.azure.toolkit.intellij.database.DatabaseComboBox)1 ConnectionSecurityPanel (com.microsoft.azure.toolkit.intellij.database.ui.ConnectionSecurityPanel)1 ConnectionStringsOutputPanel (com.microsoft.azure.toolkit.intellij.database.ui.ConnectionStringsOutputPanel)1 MySQLPropertyActionPanel (com.microsoft.azure.toolkit.intellij.database.ui.MySQLPropertyActionPanel)1 Azure (com.microsoft.azure.toolkit.lib.Azure)1 AzureAccount (com.microsoft.azure.toolkit.lib.auth.AzureAccount)1 AzureEventBus (com.microsoft.azure.toolkit.lib.common.event.AzureEventBus)1