{{/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.
*/}}{{/*
   Generates the SQL download connector table.
*/}}
{{ $name := .Get 0 }}
{{ $connectors := .Site.Data.sql_connectors }}
{{ $connector := index $connectors $name }}

<p>In order to use the {{ $connector.name }} {{ $connector.category }} the following
dependencies are required for both projects using a build automation tool (such as Maven or SBT)
and SQL Client with SQL JAR bundles.</p>

{{ if eq $connector.versions nil }}
<table style="display:table;margin-left:auto;margin-right:auto" id="download-table">
  <thead>
    <th style="text-align:left">Maven dependency</th>
    <th style="text-align:left">SQL Client</th>
  </thead>
  <tbody>
    <tr>
        <td style="text-align: left">
          {{ template "maven-artifact" (dict "ArtifactId" $connector.maven ) }}
        </td>
        {{ if eq $connector.builtin true }}
          <td style="text-align: left">Built-in</td>
        {{ else if $.Site.Params.IsStable }}
          {{ if eq $connector.sql_url nil }}
            <td style="text-align:left">There is not sql jar available yet.</td>
          {{ else }}
            <td style="text-align: left"><a href="{{- partial "docs/interpolate" $connector.sql_url -}}">Download</a></td>
          {{ end }}
        {{ else }}
          <td style="text-align: left">Only available for stable releases.</td>
        {{ end }}
    </tr>
  </tbody>
</table>
{{ else }}
<table>
  <thead>
      <th style="text-align: left">{{ $connector.name }} version</th>
      <th style="text-align: left">Maven dependency</th>
      <th style="text-align: left">SQL Client JAR</th>
  </thead>
  <tbody>
    {{ range $connector.versions }}
      <tr>
      <td style="text-align: left">{{ .version }}</td>
      <td style="text-align: left">
        {{ template "maven-artifact" (dict "ArtifactId" .maven ) }}
      </td>
      {{ if eq .builtin true }}
      <td style="text-align: left">Built-in</td>
      {{ else if eq .nosqljar true}}
      {{ else if $.Site.Params.IsStable }}
        {{ if eq .sql_url nil}} 
          <td style="text-align:left">There is no sql jar available yet.</td>
        {{ else }}
          <td style="text-align:left"><a href="{{- partial "docs/interpolate" .sql_url -}}">Download</a></td>
        {{ end }}
      {{ else }}
      <td>Only available for stable releases.</td>
      {{ end }}
      </tr>
    {{ end }}
  </tbody>
</table>
{{ end }}

{{/* 
  Generates an XML snippet for the maven artifact. 
  IMPORTANT: the whitespace is relevant. Do not change without looking at the 
  rendered documentation. 
*/}}
{{ define "maven-artifact" }}{{/* (dict "ArtifactId" .ArtifactId */}}
<div id="{{ .ArtifactId }}" onclick="selectTextAndCopy('{{ .ArtifactId }}')" class="highlight"><pre class="chroma"><code class="language-xml" data-lang="xml">
{{- $artifacts := cond (eq (printf "%T" .ArtifactId) "string") (slice .ArtifactId) .ArtifactId -}}
{{- range $artifact := $artifacts -}}
  <span class="nt">&ltdependency&gt</span>
  <span class="nt">&ltgroupId&gt</span>org.apache.flink<span class="nt">&lt/groupId&gt</span>
  <span class="nt">&ltartifactId&gt</span>{{- partial "docs/interpolate" $artifact -}}<span class="nt">&lt/artifactId&gt</span>
  <span class="nt">&ltversion&gt</span>{{- site.Params.Version -}}<span class="nt">&lt/version&gt</span>
<span class="nt">&lt/dependency&gt</span>
{{- end -}}
</code></pre></div>
<div class="book-hint info" style="text-align:center;display:none" copyable="flink-module" copyattribute="{{ .ArtifactId }}">
Copied to clipboard!
</div>
{{ end }}

