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);
}
}
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));
}
}
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);
}
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);
}
}
Aggregations