Эскиз скрипта с JDBC запросом временных рядов


import groovy.swing.SwingBuilder
import groovy.sql.Sql
import java.awt.*

def font=new Font ("Arial", Font.BOLD, 20);
SwingBuilder.build {
  frame=frame( title: "is09-20: Oracle BI Publisher/JDBC -Журнал недостоверных значений/Groovy-GUI/JDBC",
         pack: true, show:true) {
    //
    gridLayout( cols: 2, rows: 3 )
    label( text: "Исторический уровень").setFont(font)
    pH=comboBox(items:['минутный', '10-минутный', 'часовой', 'сменный', 'суточный', 'месячный'],
      actionPerformed: { //evt ->
        pStamp.removeAllItems()
    });pH.setFont(font)

    button( "Получить временные ряды",
      actionPerformed: { //evt ->
        request="select tstamp from th" + pH.getSelectedIndex() + " order by 1 desc;";
        pStamp.removeAllItems()
        sql=Sql.newInstance("jdbc:mysql://advanta.sytes.net:3306/airs", "userairs",
                     "userairs", "com.mysql.jdbc.Driver")
        sql.eachRow(request) {
          t=it[0]
          pStamp.addItem(t[0..3]+"-"+t[4,5]+"-"+t[6,7]+" "+t[8,9]+":"+t[10,11])
        }
        optionPane().showMessageDialog(null, "Временные ряды получены.")
    }).setFont(font)
    pStamp=comboBox(items:[]);pStamp.setFont(font)

    button( "Получить отчёт", actionPerformed: { //evt ->
      if(pStamp.selectedIndex<0){
        optionPane().showMessageDialog(null, "Не выбран временной ряд !")
        return
      }
      /* .. */
      callXMLP="http://advanta.sytes.net:8206/xmlpserver/~XMLP_GUEST/invalid/h5/h5.xdo?_xpf=&_xpt=0&_xmode=4&pType=a&pServ=0&pStamp=201103010000&pLevel=h5&pLevelName=%D0%BC%D0%B5%D1%81%D1%8F%D1%87%D0%BD%D1%8B%D0%B9&pTypeName=%D0%B0%D0%BD%D0%B0%D0%BB%D0%BE%D0%B3%D0%BE%D0%B2%D1%8B%D0%B9&pServName=%D0%BE%D0%B1%D1%89%D0%B5%D1%81%D1%82%D0%B0%D0%BD%D1%86%D0%B8%D0%BE%D0%BD%D0%BD%D0%BE%D0%B5+%D0%BE%D0%B1%D0%BE%D1%80%D1%83%D0%B4%D0%BE%D0%B2%D0%B0%D0%BD%D0%B8%D0%B5&pStampName=2011-03-01+00%3A00&_xt=invalid0&_xf=html"
      java.awt.Desktop.getDesktop().browse(new URI(callXMLP))
    }).setFont(font)
   }
   frame.size= [870,frame.height]
}


Подсказки для доработки

    ...
    def mkBox={lbText,cbText ->
      label( text: lbText).setFont(font);
      cb=comboBox(items:cbText);cb.setFont(font)
      return cb
    }
    ...
    pType=mkBox("Тип сигнала",['аналоговый', 'расчётный', 'дискретный'])
    ...
    def enc={URLEncoder.encode(it,"UTF-8")}
    ...
    pServ_name=enc(pServ.getSelectedItem())
    ...
    pType_val= pType.getSelectedIndex()==0 ? "a" : pType.getSelectedIndex()==1 ? "m" : "d"
    ...
    _xdo=    "/~XMLP_GUEST/invalid/${pH_val}/${pH_val}.xdo"
    ...
    switch(_xf.getSelectedIndex()){
        case 0:  _xf_val="html";break;
        ...
        default: _xf_val="xml";
    }
    ...
    pStamp_val=pStamp.selectedItem[0..3,5,6,8,9,11,12,14,15]
    ...
    callXMLP= "http://advanta.sytes.net:8206/xmlpserver${_xdo}?_xpf=&_xpt=0&_xmode=4"+
        "&pType=${pType_val}&pServ=${pServ_val}&pStamp=${pStamp_val}&pLevel=${pH_val}"+
        ...

HTTP/JSON/REQUEST example

http://advanta.sytes.net/sql2json.php?select * from th5 order by 1 desc

import groovy.json.JsonSlurper
def sql=URLEncoder.encode("select * from th5 order by 1 desc","UTF-8")
def page = new URL("http://advanta.sytes.net/sql2json.php?${sql}" ).text[3..-1]

def slurper = new JsonSlurper()
def result = slurper.parseText(page)
result[1].each{println it.tstamp}
/*
201103010000
201102010000
201101010000
201012010000
201011010000
201010010000
201009010000
201008010000
201007010000
201006010000
201005010000
201004010000
201003010000
201002010000
201001010000
200912010000
200911010000
200910010000
200909010000
200908010000
200907010000
200906010000
200905010000
200904010000
200903010000
200902010000
200901010000
200812010000
*/