File: admin_link_tables.vsp

package info (click to toggle)
virtuoso-opensource 6.1.6+dfsg2-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid, stretch
  • size: 260,992 kB
  • ctags: 125,220
  • sloc: ansic: 652,748; sql: 458,419; xml: 282,834; java: 61,031; sh: 40,031; cpp: 36,890; cs: 25,240; php: 12,692; yacc: 9,523; lex: 7,018; makefile: 6,157; jsp: 4,484; awk: 1,643; perl: 1,013; ruby: 1,003; python: 326
file content (384 lines) | stat: -rw-r--r-- 14,472 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
<?vsp 
--
--  $Id$
--  
--  This file is part of the OpenLink Software Virtuoso Open-Source (VOS)
--  project.
--  
--  Copyright (C) 1998-2012 OpenLink Software
--  
--  This project is free software; you can redistribute it and/or modify it
--  under the terms of the GNU General Public License as published by the
--  Free Software Foundation; only version 2 of the License, dated June 1991.
--  
--  This program is distributed in the hope that it will be useful, but
--  WITHOUT ANY WARRANTY; without even the implied warranty of
--  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
--  General Public License for more details.
--  
--  You should have received a copy of the GNU General Public License along
--  with this program; if not, write to the Free Software Foundation, Inc.,
--  51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--  
--  
 adm_pre_page(lines);

  --dbg_obj_print ('params : ', params);
  if (not adm_check_auth (lines)) { adm_tell_unauth (lines); return (0); }

  declare _se, _dsn, _step, _two_views, _user, _pass varchar;
  declare _se_ad, _se_re, _tbl_name, _rname, _type varchar;
  declare _len, _prev_sel, _check_all varchar;
  declare _dsn, _user, _pass varchar;
  declare _idx_n varchar;
  declare _denote_text integer;
  declare _left_v, _right_v, _tables, _views, _sys_tables any;
  declare _keys_c, _keys_cv, _keys_in, temp any;
  declare _keys, _keys_v, _keys_s any;
  declare apos, _ch_key, _ch_key_s any;

  _dsn := get_keyword ('dsn', params, '');
  _tbl_name := get_keyword ('tbl_name', params, '');
  _se_ad := get_keyword ('def_keys', params, get_keyword ('colname_add', params, ''));
  _se_re := get_keyword ('new_key', params, get_keyword ('colname_rmv', params, ''));
  _left_v :=  deserialize (decode_base64 (get_keyword ('vec_l', params, '')));
  _right_v :=  deserialize (decode_base64 (get_keyword ('vec_r', params, '')));
  _step := get_keyword ('step', params, '');
  _two_views := get_keyword ('two_views', params, '00');
  _denote_text := 0;

  if ('' <> get_keyword ('login', params, ''))
    {
      if ('' <> get_keyword ('login_2', params, ''))
	  aset (_two_views, 0, ascii ('1'));
      if ('' <> get_keyword ('login_3', params, ''))
	  aset (_two_views, 1, ascii ('1'));
    }
  _user := get_keyword ('user', params, '');
  _pass := get_keyword ('pass', params, '');
  if (_user = '')
    _pass := '';
  _ch_key :=  deserialize (decode_base64 (get_keyword ('ch_key', params, '')));
  _ch_key_s :=  deserialize (decode_base64 (get_keyword ('ch_key_s', params, '')));
  _keys :=  deserialize (decode_base64 (get_keyword ('keys', params, '')));
  _keys_s :=  deserialize (decode_base64 (get_keyword ('keys_s', params, '')));
  _keys_v :=  deserialize (decode_base64 (get_keyword ('keys_v', params, '')));
  _views :=  deserialize (decode_base64 (get_keyword ('views', params, '')));
  _sys_tables :=  deserialize (decode_base64 (get_keyword ('sys_tables', params, '')));
  _tables :=  deserialize (decode_base64 (get_keyword ('tables', params, '')));
  apos := adm_button_check ('pm_k', params);
  if (not is_empty_or_null (apos))
    {
	_step := '4';
        _se := get_keyword (concat ('se_', apos), params, '');
        _type := "LEFT" (apos, 1);
        _idx_n := subseq (apos, 1);
        _keys_in :=  deserialize (decode_base64 (get_keyword (concat ('key_send_', apos), params, '')));
    }
?>

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">

<html>
  <head>
  <link rel="stylesheet" type="text/css" href="<?=adm_what_css()?>">
  <script language="javascript" src="admin_link_tables.js"></script>
    <title>External table management</title>
    <meta name="AUTHOR" content="OpenLink Software">
    <meta name="DESCRIPTION" content="Link External Tables into Virtuoso using VSP">
  </head>
  <BODY>
<?vsp if ('4' <> _step and not ('3' = _step and '' <> get_keyword ('link', params, '')))
        adm_page_header('External Table Management', NULL); ?>

<?vsp
  if ('4' = _step)
    {
      adm_page_header('Change Primary Keys', NULL);
      adm_key_init (params, _dsn, _se, _left_v, _right_v, _se_ad, _se_re, _keys_in);
?>
<TABLE class="genlist" BORDER="0" CELLPADDING="0">
<FORM method="POST" enctype="multipart/form-data" name="creat_key" action="admin_link_tables.vsp">
  <TR><TD CLASS="genhead" COLSPAN="4">
<?vsp
  if ('T' = _type)
    {
      http ('TABLE: ');
      _rname := aref ( aref (_tables, atof (_idx_n)), 2);
    }
  else if ('V' = _type)
    {
      http ('VIEW: ');
      _rname := aref ( aref (_views, atof (_idx_n)), 2);
    }
  else if ('S' = _type)
    {
      http ('SYSTEM TABLE: ');
      _rname := aref ( aref (_sys_tables, atof (_idx_n)), 2);
    }
  http (sprintf ('%V', _rname));
?>
</TD></TR>
  <TR><TD CLASS="AdmBorders" COLSPAN="4"><IMG SRC="images/1x1.gif" WIDTH="1" HEIGHT="2" ALT=""></TD></TR>
  <TR>
    <TD class="genlistheadt" COLSPAN="2" WIDTH="50%">Available Columns</TD>
    <TD class="genlistheadt" COLSPAN="2" WIDTH="50%">Selected Columns</TD>
  </TR>
  <TR>
  <TD ALIGN="right" VALIGN="center">
    <SELECT name="def_keys" Size="10" onDBLClick="javascript:def_keys_add(this);"><?vsp adm_l_key_options (_left_v);?></select></TD>
  <TD VALIGN="center" ALIGN="middle" WIDTH="10%" CLASS="geninput">
    <INPUT type="hidden" NAME="colname_add" VALUE="">
    <INPUT type="hidden" NAME="colname_rmv" VALUE="">
    <INPUT type="submit" CLASS="geninput" id="select_k" name="select_k" value=" &gt&gt "><BR /><BR />
    <INPUT type="submit" CLASS="geninput" name="un_select_k" value=" &lt&lt "></TD>
  <TD VALIGN="left" ALIGN="left">
    <select name="new_key" Size="10" onDBLClick="javascript:def_keys_rmv(this);"><?vsp adm_l_key_options (_right_v);?></select></TD>
  <TD VALIGN="center" ALIGN="left">
    <INPUT type="submit" name="up" value="Up"><BR /><BR />
    <INPUT type="submit" name="down" value="Down">
  </TD>
  </TR>

  <TR><TD VALIGN="center" ALIGN="middle" COLSPAN="4">

<?vsp
    if (not (_right_v = vector()))
      {
        if ('T' = _type)
	  {
            aset (_keys, atof (_idx_n), _right_v);
            aset (_ch_key, atof (_idx_n), '1');
	  }
        else if ('V' = _type)
	  {
            aset (_keys_v, atof (_idx_n), _right_v);
	  }
	else if ('S' = _type)
	  {
            aset (_keys_s, atof (_idx_n), _right_v);
            aset (_ch_key_s, atof (_idx_n), '1');
	  }
      }
    else
      _right_v := vector ('Add');
    _keys := encode_base64 (serialize (_keys));
    _keys_v := encode_base64 (serialize (_keys_v));
    _keys_s := encode_base64 (serialize (_keys_s));
    if (aref (_right_v, 0) = 'Add')
      _right_v := '';
?>
  <INPUT type="hidden" name="dsn" value="<?= _dsn ?>">
  <INPUT type="hidden" name="R_NAME_" value="<?= _rname ?>">
  <INPUT type="hidden" name="type_" value="<?= _type ?>">
  <INPUT type="hidden" name="keys" value="<?= _keys ?>">
  <INPUT type="hidden" name="keys_v" value="<?= _keys_v ?>">
  <INPUT type="hidden" name="keys_s" value="<?= _keys_s ?>">
  <INPUT type="hidden" name="idx" value="<?= _idx_n ?>">
  <?vsp _left_v := encode_base64 (serialize (_left_v));
        _right_v := encode_base64 (serialize (_right_v));
        _tables := encode_base64 (serialize (_tables));
        _views := encode_base64 (serialize (_views));
        _sys_tables := encode_base64 (serialize (_sys_tables));
        _ch_key := encode_base64 (serialize (_ch_key));
        _ch_key_s := encode_base64 (serialize (_ch_key_s));
        http (sprintf ('<INPUT type="hidden" name="pm_k%s" value="1">', apos));
?>
  <INPUT type="hidden" name="vec_l" value="<?= _left_v ?>">
  <INPUT type="hidden" name="idx" value="<?= _idx_n ?>">
  <INPUT type="hidden" name="vec_r" value="<?= _right_v ?>">
  <INPUT type="hidden" name="step" value="<?= _step ?>">
  <INPUT type="hidden" name="two_views" value="<?= _two_views ?>">
  <INPUT type="hidden" name="user" value="<?= _user ?>">
  <INPUT type="hidden" name="pass" value="<?= _pass ?>">
  <INPUT type="hidden" name="tables" value="<?= _tables ?>">
  <INPUT type="hidden" name="views" value="<?= _views ?>">
  <INPUT type="hidden" name="sys_tables" value="<?= _sys_tables ?>">
  <INPUT type="hidden" name="ch_key" value="<?= _ch_key ?>">
  <INPUT type="hidden" name="ch_key_s" value="<?= _ch_key_s ?>">
<?vsp adm_save_state (params); ?>
</FORM>
<FORM method="POST" name="finish" action="admin_link_tables.vsp">
  <INPUT type="submit" name="finish" value="Finish">
  <INPUT type="hidden" name="tables" value="<?= _tables ?>">
  <INPUT type="hidden" name="views" value="<?= _views ?>">
  <INPUT type="hidden" name="sys_tables" value="<?= _sys_tables ?>">
  <INPUT type="hidden" name="user" value="<?= _user ?>">
  <INPUT type="hidden" name="pass" value="<?= _pass ?>">
  <INPUT type="hidden" name="step" value="3">
  <INPUT type="hidden" name="dsn" value="<?= _dsn ?>">
  <INPUT type="hidden" name="two_views" value="<?= _two_views ?>">
  <INPUT type="hidden" name="ch_key" value="<?= _ch_key ?>">
  <INPUT type="hidden" name="ch_key_s" value="<?= _ch_key_s ?>">
  <INPUT type="hidden" name="keys" value="<?= _keys ?>">
  <INPUT type="hidden" name="keys_v" value="<?= _keys_v ?>">
  <INPUT type="hidden" name="keys_s" value="<?= _keys_s ?>">
<?vsp adm_save_state (params); ?>
</FORM></TD></TR>
</TABLE>

<?vsp
    }
  else if (_step = 5)
    {
status_page_display:
      adm_page_header('Tables Linked Successfully', NULL);
?>
    <FORM method="POST" name="link_form" action="admin_link_tables.vsp">
     <TABLE CLASS="genlist" BORDER="0" CELLPADDING="0">
      <TR>
        <TD CLASS="genlisthead">Remote Name</TD>
        <TD CLASS="genlisthead">Type</TD>
        <TD CLASS="genlisthead">Linked From</TD>
        <TD CLASS="genlisthead">Linked As</TD>
      </TR>
<?vsp
 adm_lt_status_display ('T', params, _dsn);

 adm_lt_status_display ('S', params, _dsn);

 adm_lt_status_display ('V', params, _dsn);
?>
     </TABLE>
     <input type="submit" name="OK" value="OK">
    </FORM>
<?vsp
    }
  else
    {
?>

<?vsp     adm_lt_init (params, _step, _dsn, _user, _pass, _prev_sel, _two_views,
    _keys, _keys_v, _keys_s, _tables, _views, _sys_tables);
    if (_step = 5)
      goto status_page_display;
?>
    <FORM method="POST" name="link_form" action="admin_link_tables.vsp">
    <input type="hidden" name="step" value="<?= _step ?>">
    <input type="hidden" name="two_views" value="<?= _two_views ?>">

<TABLE><TR><TD VALIGN="top">
   <TABLE CLASS="genlist" BORDER="0" CELLPADDING="0">
   <TR><TD CLASS="genhead" COLSPAN="2">Currently Linked</TD></TR>
   <TR><TD CLASS="AdmBorders" COLSPAN="2"><IMG SRC="images/1x1.gif" WIDTH="1" HEIGHT="2" ALT=""></TD></TR>
   <TR><TD CLASS="genselect" ALIGN="right">
      <select name="remote_tbls" onChange="javascript:rtbls_chg();" MULTIPLE Size="10">
      <?vsp adm_lt_rt_options(); ?>
      </select></TD></TR>
    <TR><TD VALIGN="bottom" ALIGN="right"><input type="submit" name="unlink" value="Unlink"></TD>
    </TD>
  </TR>
  </TABLE>
</TD>

<TD VALIGN="top">
<TABLE class="genlist" BORDER="0" CELLPADDING="0">
  <TR><TD class="genhead" COLSPAN="3">Link from Data Source</TD></TR>
  <TR><TD CLASS="AdmBorders" COLSPAN="3"><IMG SRC="images/1x1.gif" WIDTH="1" HEIGHT="2" ALT=""></TD></TR>
  <TR><TD class="genselect" ROWSPAN="3">
    <select name="dsns" onChange="javascript:dsns_chg(this);" MULTIPLE Size="12">
    <?vsp adm_lt_dsn_options(_dsn); ?></select></TD>
  <TD></TD><TD VALIGN="top">
    <TABLE class="genlist" BORDER="0" CELLPADDING="0">
    <TR><TD class="genlisthead" NOWRAP>Data Source</TD><TD class="geninput">
    <input type="text" size="25" name="dsn" value="<?= _dsn ?>"></TD></TR>
    <TR><TD class="genlisthead">Username</TD><TD class="geninput">
    <input type="text" size="25" name="user" value="<?= _user ?>"></TD></TR>
    <TR><TD class="genlisthead">Password</TD><TD class="geninput">
    <input type="password" size="25" name="pass" value="<?= _pass ?>"></TD></TR>
    <TR><TD COLSPAN="2" ALIGN="right">
      <table>
        <tr>
	  <td>
	    <input type="checkbox" name="login_2" value="Views"
	       <?= case chr (aref (_two_views, 0)) when '1' then 'CHECKED' else '' end?>>Views
	  </td><td>
	    <input type="checkbox" name="login_3" value="System tables"
	    <?= case chr (aref (_two_views, 1)) when '1' then 'CHECKED' else '' end?>>System Tables
	  </td>
	<tr>
      </table>
    </TR>
    <TR>
      <TD COLSPAN="2" ALIGN="right">
        <input type="submit" name="login" value="List">
      </TD>
    </TR>
    </TABLE>
  </TD></TR>
</TABLE>
</TD></TR></TABLE>

<?vsp
      if ('2' = _step or '3' = _step)
        {
?>
<TABLE class="genlist" BORDER="0" CELLPADDING="0">
<?vsp adm_lt_table_r (_dsn, params, _len, _two_views, _keys, _step, _user, _pass, _keys_v, _keys_s, _tables, _views, _sys_tables, _ch_key, _ch_key_s, _denote_text);
        if ( 0 < _len)
          {
	    if ('2' = _step)
	      {
?>
  <TR><TD COLSPAN="6" ALIGN="right">
  <INPUT type="submit" name="select_all" value="Select All" >
  <INPUT type="submit" name="link" value="Next">
  </TD></TR>
<?vsp
	      }
	    else
              {
?>
  <TR><TD COLSPAN="7" ALIGN="right">
  <INPUT type="submit" name="select_all" value="Select All">
  <INPUT type="submit" name="link" value="Link Selected">
  </TD></TR>
<?vsp
	      }
	  }
	if (_denote_text)
	  {
?>

  <TR><TD COLSPAN="7">* Denotes table already linked.  Unlink first. </TD></TR>

<?vsp
	  }
	if (length (_views) and _step = '3')
	  {
?>

  <TR><TD COLSPAN="7">You must select a primary key before VIEWS can be linked.</TD></TR>

<?vsp
	  }
?>

</TD></TR></TABLE>

<?vsp
	}
      _ch_key := encode_base64 (serialize (_ch_key));
      _ch_key_s := encode_base64 (serialize (_ch_key_s));
      _keys := encode_base64 (serialize (_keys));
      _keys_v := encode_base64 (serialize (_keys_v));
      _keys_s := encode_base64 (serialize (_keys_s));
      _tables := encode_base64 (serialize (_tables));
      _views := encode_base64 (serialize (_views));
      _sys_tables := encode_base64 (serialize (_sys_tables)); ?>
<INPUT type="hidden" name="keys" value="<?=_keys?>">
<INPUT type="hidden" name="ch_key" value="<?= _ch_key ?>">
<INPUT type="hidden" name="ch_key_s" value="<?= _ch_key_s ?>">
<INPUT type="hidden" name="keys_v" value="<?=_keys_v?>">
<INPUT type="hidden" name="keys_s" value="<?=_keys_s?>">
<INPUT type="hidden" name="tables" value="<?=_tables?>">
<INPUT type="hidden" name="views" value="<?=_views?>">
<INPUT type="hidden" name="sys_tables" value="<?=_sys_tables?>">
</FORM>

<?vsp
    }
?>
<?vsp adm_page_footer(); ?>
</BODY>
</HTML>