bump product version to 4.1.6.2
[LibreOffice.git] / qadevOOo / runner / stats / FatDataBaseOutProducer.java
blobbaa6bb4a4e7a0c8f4f3f9c1b2ca8a2f0156faab0
1 /*
2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 package stats;
20 import java.text.DecimalFormat;
21 import share.LogWriter;
22 import java.util.HashMap;
23 import java.util.Calendar;
24 import java.util.GregorianCalendar;
27 /**
30 public class FatDataBaseOutProducer extends DataBaseOutProducer {
33 /** Creates a new instance of APIDataBaseOutProducer */
34 public FatDataBaseOutProducer(HashMap<String,String> param) {
35 super(param);
36 String testBase = (String)mSqlInput.get("TestBase");
37 int sep = testBase.indexOf('_');
38 String testLanguage = testBase.substring(0,sep);
39 testBase = testBase.substring(sep+1);
40 String apiVersion = (String)mSqlInput.get("Version");
41 String descriptionString = testLanguage+":"+(String)mSqlInput.get("OperatingSystem")+":"+testBase+":"+apiVersion;
42 apiVersion = apiVersion.substring(0, 6);
43 // build date
44 if (mSqlInput.get("Date") != null) {
45 mSqlInput.put("date", mSqlInput.get("Date"));
47 if (mSqlInput.get("date") == null) {
48 // build date if it's not there
49 Calendar cal = new GregorianCalendar();
50 DecimalFormat dfmt = new DecimalFormat("00");
51 String year = Integer.toString(cal.get(GregorianCalendar.YEAR));
52 // month is starting with "0"
53 String month = dfmt.format(cal.get(GregorianCalendar.MONTH) + 1);
54 String day = dfmt.format(cal.get(GregorianCalendar.DATE));
55 String dateString = year + "-" + month + "-" + day;
57 mSqlInput.put("date", dateString);
60 setWriteableEntryTypes(new String[]{"property", "method", "component", "interface", "service"});
62 mSqlInput.put("test_run.description", descriptionString);
63 mSqlInput.put("api_version_name", apiVersion);
66 protected boolean prepareDataBase(LogWriter log) {
67 executeSQLCommand("SHOW TABLES");
69 executeSQLCommand("SELECT id AS \"test_run.id\", api_version_id, description, date FROM test_run" +
70 " WHERE date = \"$date\" AND description = \"$test_run.description\";", true);
71 String id = (String)mSqlInput.get("test_run.id");
72 // create an entry for this test run
73 if (id == null) {
74 executeSQLCommand("SELECT id AS api_version_id FROM api_version" +
75 " WHERE version = \"$api_version_name\";", true);
76 String api_version_id = (String)mSqlInput.get("api_version_id");
77 // create an entry for this API
78 if (api_version_id == null) {
79 executeSQLCommand("INSERT api_version (api_name, version)" +
80 " VALUES (\"soapi\", \"$api_version_name\")");
81 executeSQLCommand("SELECT id AS api_version_id FROM api_version" +
82 " WHERE version = \"$api_version_name\";", true);
84 // complete entry for the test run
85 executeSQLCommand("INSERT test_run (api_version_id, description, date)" +
86 " VALUES ($api_version_id, \"$test_run.description\", \"$date\");");
87 executeSQLCommand("SELECT test_run.id AS \"test_run.id\", api_version_id, description, date FROM test_run" +
88 " WHERE date = \"$date\" AND description = \"$test_run.description\";", true);
90 return true;
93 // check the database afterwards
94 protected boolean checkDataBase(LogWriter log) {
95 return true;
98 protected boolean insertEntry(LogWriter log) {
100 executeSQLCommand("SELECT id AS \"entry.id\", name AS \"entry.name\" FROM entry WHERE name = \"$EntryLongName\";", true);
101 if (mSqlInput.get("entry.id") == null) {
102 executeSQLCommand("INSERT entry (name, type)" +
103 " VALUES (\"$EntryLongName\", \"$EntryType\");");
104 executeSQLCommand("SELECT id AS \"entry.id\", name AS \"entry.name\" FROM entry WHERE name = \"$EntryLongName\";", true);
106 executeSQLCommand("SELECT id AS \"api_entry.id\", api_version_id AS \"api_entry.api_version_id\", entry_id AS \"api_entry.entry_id\" FROM api_entry" +
107 " WHERE entry_id = $entry.id;", true);
108 if (mSqlInput.get("api_entry.id") == null) {
109 executeSQLCommand("INSERT api_entry (entry_id, api_version_id)"+
110 " VALUES ($entry.id, $api_version_id);");
111 executeSQLCommand("SELECT id AS \"api_entry.id\", api_version_id AS \"api_entry.api_version_id\", entry_id AS \"api_entry.entry_id\" FROM api_entry" +
112 " WHERE entry_id = $entry.id;", true);
114 executeSQLCommand("SELECT status AS \"test_state.status\" FROM test_state"+
115 " WHERE test_run_id = $test_run.id AND entry_id = $entry.id;", true);
117 String status = (String)mSqlInput.get("test_state.status");
118 if (status == null) {
119 executeSQLCommand("INSERT test_state (test_run_id, entry_id, status)"+
120 " VALUES ($test_run.id, $entry.id, \"$EntryState\");");
122 else {
123 if (!status.endsWith("OK")) {
124 executeSQLCommand("UPDATE test_state SET status = \"$EntryState\""+
125 " WHERE test_run_id = $test_run.id AND entry_id = $entry.id;");
128 return true;
131 public Object getWatcher() {
132 return null;
135 public void setWatcher(Object watcher) {