xref: /AOO41X/main/testgraphical/source/dbhelper.pm (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir#
2*cdf0e10cSrcweir# # ------------------------------------------------------------------------------
3*cdf0e10cSrcweir#
4*cdf0e10cSrcweir# sub DB_INSERT_INTO_TABLE_STATUS()
5*cdf0e10cSrcweir# {
6*cdf0e10cSrcweir#     # my $sDocID = shift;
7*cdf0e10cSrcweir#     # my $sDBDistinct = shift;
8*cdf0e10cSrcweir#
9*cdf0e10cSrcweir#     my $sHostname = hostname;
10*cdf0e10cSrcweir#
11*cdf0e10cSrcweir#     my $sSQL = "INSERT INTO status (docid, dbdistinct2, hostname)";
12*cdf0e10cSrcweir#     $sSQL .= "  VALUES ($docid, '$dbdistinct', '$sHostname')";
13*cdf0e10cSrcweir#     ExecSQL($sSQL);
14*cdf0e10cSrcweir# }
15*cdf0e10cSrcweir# sub DB_UPDATE_TABLE_STATUS_SET_INFO($)
16*cdf0e10cSrcweir# {
17*cdf0e10cSrcweir#     # my $sDocID = shift;
18*cdf0e10cSrcweir#     # my $sDBDistinct = shift;
19*cdf0e10cSrcweir#     my $sInfo = shift;
20*cdf0e10cSrcweir#
21*cdf0e10cSrcweir#     # my $sHostname = hostname;
22*cdf0e10cSrcweir#
23*cdf0e10cSrcweir#     my $sInsertSQL = "UPDATE status SET info='$sInfo' WHERE docid=$docid AND dbdistinct2='$dbdistinct'";
24*cdf0e10cSrcweir#     ExecSQL($sInsertSQL);
25*cdf0e10cSrcweir# }
26*cdf0e10cSrcweir#
27*cdf0e10cSrcweir# sub DB_UPDATE_TABLE_DOCUMENTS_SET_STATE_INFO($$)
28*cdf0e10cSrcweir# {
29*cdf0e10cSrcweir#     # my $sDocID = shift;
30*cdf0e10cSrcweir#     my $sStatus = shift;
31*cdf0e10cSrcweir#     my $sError = shift;
32*cdf0e10cSrcweir#
33*cdf0e10cSrcweir#     my $sSQL = "UPDATE documents";
34*cdf0e10cSrcweir#     $sSQL .= " SET state='" . $sStatus . "'";
35*cdf0e10cSrcweir#     $sSQL .= ",info='" . $sError . "'";
36*cdf0e10cSrcweir#     $sSQL .= " WHERE docid=$docid";
37*cdf0e10cSrcweir#     ExecSQL($sSQL);
38*cdf0e10cSrcweir# }
39*cdf0e10cSrcweir# sub DB_UPDATE_TABLE_STATUS_SET_STATE($)
40*cdf0e10cSrcweir# {
41*cdf0e10cSrcweir#     # my $sDocID = shift;
42*cdf0e10cSrcweir#     my $sStatus = shift;
43*cdf0e10cSrcweir#
44*cdf0e10cSrcweir#     my $sSQL = "UPDATE status";
45*cdf0e10cSrcweir#     $sSQL .= " SET state='" . $sStatus . "'";
46*cdf0e10cSrcweir#     $sSQL .= " WHERE docid=$docid";
47*cdf0e10cSrcweir#     ExecSQL($sSQL);
48*cdf0e10cSrcweir# }
49*cdf0e10cSrcweir#
50*cdf0e10cSrcweir# # sub DB_UPDATE_TABLE_STATUS_SET_STATE_FAILED()
51*cdf0e10cSrcweir# # {
52*cdf0e10cSrcweir# #     DB_UPDATE_TABLE_STATUS_SET_STATE("FAILED-FAILED");
53*cdf0e10cSrcweir# # }
54*cdf0e10cSrcweir# # ------------------------------------------------------------------------------
55*cdf0e10cSrcweir# # sub getDBConnectionString()
56*cdf0e10cSrcweir# # {
57*cdf0e10cSrcweir# #     # return "server:jakobus,db:jobs_convwatch,user:admin,passwd:admin";
58*cdf0e10cSrcweir# #     return "server:unoapi,db:jobs_convwatch,user:convwatch,passwd:convwatch";
59*cdf0e10cSrcweir# # }
60*cdf0e10cSrcweir# # ------------------------------------------------------------------------------
61*cdf0e10cSrcweir# sub getSourceInfo($)
62*cdf0e10cSrcweir# {
63*cdf0e10cSrcweir#     my $sDBStr = shift;
64*cdf0e10cSrcweir#
65*cdf0e10cSrcweir#     my $sSourceVersion;
66*cdf0e10cSrcweir#     if ( $sDBStr =~ / sourceversion='(.*?)',/ )
67*cdf0e10cSrcweir#     {
68*cdf0e10cSrcweir#         $sSourceVersion = $1;
69*cdf0e10cSrcweir#         log_print( "sSourceVersion: $sSourceVersion\n");
70*cdf0e10cSrcweir#     }
71*cdf0e10cSrcweir#     if (! $sSourceVersion)
72*cdf0e10cSrcweir#     {
73*cdf0e10cSrcweir#         log_print( "Error: no value for sourceversion found.\n");
74*cdf0e10cSrcweir#         return;
75*cdf0e10cSrcweir#     }
76*cdf0e10cSrcweir#     my $sSourceName;
77*cdf0e10cSrcweir#     if ( $sDBStr =~ / sourcename='(.*?)',/ )
78*cdf0e10cSrcweir#     {
79*cdf0e10cSrcweir#         $sSourceName = $1;
80*cdf0e10cSrcweir#         log_print( "sSourceName: $sSourceName\n");
81*cdf0e10cSrcweir#     }
82*cdf0e10cSrcweir#     my $sSourceCreatorType;
83*cdf0e10cSrcweir#     if ( $sDBStr =~ / sourcecreatortype='(.*?)',/ )
84*cdf0e10cSrcweir#     {
85*cdf0e10cSrcweir#         $sSourceCreatorType = $1;
86*cdf0e10cSrcweir#         log_print( "sSourceCreatorType: $sSourceCreatorType\n");
87*cdf0e10cSrcweir#     }
88*cdf0e10cSrcweir#     return $sSourceVersion, $sSourceName, $sSourceCreatorType;
89*cdf0e10cSrcweir# }
90*cdf0e10cSrcweir# # ------------------------------------------------------------------------------
91*cdf0e10cSrcweir# sub getDestinationInfo($)
92*cdf0e10cSrcweir# {
93*cdf0e10cSrcweir#     my $sDBStr = shift;
94*cdf0e10cSrcweir#
95*cdf0e10cSrcweir#     my $sDestinationVersion;
96*cdf0e10cSrcweir#     if ( $sDBStr =~ / destinationversion='(.*?)',/ )
97*cdf0e10cSrcweir#     {
98*cdf0e10cSrcweir#         $sDestinationVersion = $1;
99*cdf0e10cSrcweir#         log_print( "sDestinationVersion: $sDestinationVersion\n");
100*cdf0e10cSrcweir#     }
101*cdf0e10cSrcweir#     if (! $sDestinationVersion)
102*cdf0e10cSrcweir#     {
103*cdf0e10cSrcweir#         log_print( "Error: no value for destinationversion found.\n");
104*cdf0e10cSrcweir#         return;
105*cdf0e10cSrcweir#     }
106*cdf0e10cSrcweir#     my $sDestinationName;
107*cdf0e10cSrcweir#     if ( $sDBStr =~ / destinationname='(.*?)',/ )
108*cdf0e10cSrcweir#     {
109*cdf0e10cSrcweir#         $sDestinationName = $1;
110*cdf0e10cSrcweir#         log_print( "sDestinationName: $sDestinationName\n");
111*cdf0e10cSrcweir#     }
112*cdf0e10cSrcweir#     my $sDestinationCreatorType;
113*cdf0e10cSrcweir#     if ( $sDBStr =~ / destinationcreatortype='(.*?)',/ )
114*cdf0e10cSrcweir#     {
115*cdf0e10cSrcweir#         $sDestinationCreatorType = $1;
116*cdf0e10cSrcweir#         log_print( "sDestinationCreatorType: $sDestinationCreatorType\n");
117*cdf0e10cSrcweir#     }
118*cdf0e10cSrcweir#     return $sDestinationVersion, $sDestinationName, $sDestinationCreatorType;
119*cdf0e10cSrcweir# }
120*cdf0e10cSrcweir# # ------------------------------------------------------------------------------
121*cdf0e10cSrcweir# # sub getMailAddress($)
122*cdf0e10cSrcweir# # {
123*cdf0e10cSrcweir# #     my $sDBStr = shift;
124*cdf0e10cSrcweir# #     my $sMailAddress = "";
125*cdf0e10cSrcweir# #     if ( $sDBStr =~ / mailfeedback='(.*?)',/ )
126*cdf0e10cSrcweir# #     {
127*cdf0e10cSrcweir# #         $sMailAddress = $1;
128*cdf0e10cSrcweir# #         log_print( "sMailAddress: $sMailAddress\n");
129*cdf0e10cSrcweir# #     }
130*cdf0e10cSrcweir# #     return $sMailAddress;
131*cdf0e10cSrcweir# # }
132*cdf0e10cSrcweir#
133*cdf0e10cSrcweir# # sub getDocumentInfo($)
134*cdf0e10cSrcweir# # {
135*cdf0e10cSrcweir# #     my $sDBStr = shift;
136*cdf0e10cSrcweir# #
137*cdf0e10cSrcweir# #     my $sDocumentPoolPath;
138*cdf0e10cSrcweir# #     if ( $sDBStr =~ / documentpoolpath='(.*?)',/ )
139*cdf0e10cSrcweir# #     {
140*cdf0e10cSrcweir# #         $sDocumentPoolPath = $1;
141*cdf0e10cSrcweir# #         log_print( "sDocumentPoolPath: $sDocumentPoolPath\n");
142*cdf0e10cSrcweir# #     }
143*cdf0e10cSrcweir# #     if (! $sDocumentPoolPath)
144*cdf0e10cSrcweir# #     {
145*cdf0e10cSrcweir# #         log_print( "Error: no value for documentpoolpath found.\n");
146*cdf0e10cSrcweir# #         return;
147*cdf0e10cSrcweir# #     }
148*cdf0e10cSrcweir# #     my $sDocumentPool;
149*cdf0e10cSrcweir# #     if ( $sDBStr =~ / documentpool='(.*?)',/ )
150*cdf0e10cSrcweir# #     {
151*cdf0e10cSrcweir# #         $sDocumentPool = $1;
152*cdf0e10cSrcweir# #         log_print( "sDocumentPool: $sDocumentPool\n");
153*cdf0e10cSrcweir# #     }
154*cdf0e10cSrcweir# #     if (! $sDocumentPool)
155*cdf0e10cSrcweir# #     {
156*cdf0e10cSrcweir# #         log_print( "Error: no value for documentpool found.\n");
157*cdf0e10cSrcweir# #         return;
158*cdf0e10cSrcweir# #     }
159*cdf0e10cSrcweir# #     my $sDocumentName;
160*cdf0e10cSrcweir# #     if ( $sDBStr =~ / name='(.*?)',/ )
161*cdf0e10cSrcweir# #     {
162*cdf0e10cSrcweir# #         $sDocumentName = $1;
163*cdf0e10cSrcweir# #         log_print( "sDocumentName: $sDocumentName\n");
164*cdf0e10cSrcweir# #     }
165*cdf0e10cSrcweir# #     return $sDocumentPoolPath, $sDocumentPool, $sDocumentName;
166*cdf0e10cSrcweir# # }
167*cdf0e10cSrcweir#
168*cdf0e10cSrcweir# sub getDistinct($)
169*cdf0e10cSrcweir# {
170*cdf0e10cSrcweir#     my $sDBStr = shift;
171*cdf0e10cSrcweir#     my $sDBDistinct;
172*cdf0e10cSrcweir#     if ( $sDBStr =~ / dbdistinct2='(\S*?)',/ )
173*cdf0e10cSrcweir#     {
174*cdf0e10cSrcweir#         $sDBDistinct = $1;
175*cdf0e10cSrcweir#         log_print( "dbdistinct2: $sDBDistinct\n");
176*cdf0e10cSrcweir#     }
177*cdf0e10cSrcweir#     return $sDBDistinct;
178*cdf0e10cSrcweir# }
179*cdf0e10cSrcweir#
180*cdf0e10cSrcweir# sub getIDInfo($)
181*cdf0e10cSrcweir# {
182*cdf0e10cSrcweir#     my $sDBStr = shift;
183*cdf0e10cSrcweir#     # my $dbdistinct;
184*cdf0e10cSrcweir#
185*cdf0e10cSrcweir#     my $sDBDistinct = getDistinct($sDBStr);
186*cdf0e10cSrcweir#     # if ( $sDBStr =~ / dbdistinct2='(\S*?)',/ )
187*cdf0e10cSrcweir#     # {
188*cdf0e10cSrcweir#     #     $sDBDistinct = $1;
189*cdf0e10cSrcweir#     #     log_print( "dbdistinct2: $sDBDistinct\n");
190*cdf0e10cSrcweir#     # }
191*cdf0e10cSrcweir#     if (! $sDBDistinct)
192*cdf0e10cSrcweir#     {
193*cdf0e10cSrcweir#         log_print( "Error: no dbdistinct given.\n");
194*cdf0e10cSrcweir#         return;
195*cdf0e10cSrcweir#     }
196*cdf0e10cSrcweir#     my $sDocID;
197*cdf0e10cSrcweir#     if ( $sDBStr =~ / docid=(\S*?),/ )
198*cdf0e10cSrcweir#     {
199*cdf0e10cSrcweir#         $sDocID = $1;
200*cdf0e10cSrcweir#         log_print( "docid: $sDocID\n");
201*cdf0e10cSrcweir#     }
202*cdf0e10cSrcweir#     if (! $sDocID)
203*cdf0e10cSrcweir#     {
204*cdf0e10cSrcweir#         log_print( "Error: no docid given.\n");
205*cdf0e10cSrcweir#         return;
206*cdf0e10cSrcweir#     }
207*cdf0e10cSrcweir#     return $sDBDistinct, $sDocID;
208*cdf0e10cSrcweir# }
209*cdf0e10cSrcweir#
210