Revize cc39413d
Přidáno uživatelem Michal Linha před asi 4 roky(ů)
src/main/java/vldc/aswi/service/SqlQueryManagerImpl.java | ||
---|---|---|
4 | 4 |
import org.springframework.beans.factory.annotation.Autowired; |
5 | 5 |
import org.springframework.stereotype.Service; |
6 | 6 |
import vldc.aswi.database.DatabaseInterface; |
7 |
import vldc.aswi.domain.Assembly; |
|
8 |
import vldc.aswi.domain.Configuration; |
|
9 |
import vldc.aswi.domain.Function; |
|
10 |
import vldc.aswi.domain.parameter.ParameterInConfiguration; |
|
7 | 11 |
import vldc.aswi.model.table.NameUserName; |
8 | 12 |
import vldc.aswi.model.table.TableColumn; |
9 | 13 |
import vldc.aswi.model.table.ValueFunction; |
... | ... | |
11 | 15 |
import vldc.aswi.utils.Converter; |
12 | 16 |
|
13 | 17 |
import javax.sql.DataSource; |
14 |
import java.util.ArrayList; |
|
15 |
import java.util.List; |
|
16 |
import java.util.Map; |
|
18 |
import java.util.*; |
|
19 |
import java.util.concurrent.TimeUnit; |
|
17 | 20 |
|
18 | 21 |
/** |
19 | 22 |
* Manager for SqlQuery. |
... | ... | |
28 | 31 |
|
29 | 32 |
/** |
30 | 33 |
* Get list of contingencyTableRow. |
31 |
* @param sqlQuery - SQL query.
|
|
34 |
* @param configuration - configuration from which table will be created.
|
|
32 | 35 |
* @return List of contingencyTableRow. |
33 | 36 |
*/ |
34 | 37 |
@Override |
35 |
public List<ContingencyTableRow> getContingencyTableRow(String sqlQuery) { |
|
36 |
Map<String, TableColumn> tableColumns = this.databaseInterface.executeQueryAndReturnTableColumns(sqlQuery); |
|
38 |
public List<ContingencyTableRow> getContingencyTableRow(Configuration configuration) { |
|
39 |
long startTime = System.nanoTime(); |
|
40 |
Map<String, TableColumn> tableColumns = this.databaseInterface.executeQueryAndReturnTableColumns( |
|
41 |
configuration.getAssembly().getSQLQuery() |
|
42 |
); |
|
43 |
long stopTime = System.nanoTime(); |
|
44 |
System.out.println("Select:" + TimeUnit.MILLISECONDS.convert((stopTime - startTime), TimeUnit.NANOSECONDS)); |
|
37 | 45 |
List<NameUserName> rowNames = new ArrayList<>(); |
38 |
rowNames.add(new NameUserName("PROGRAM_STUDIA", "d")); |
|
39 |
rowNames.add(new NameUserName("TYP_STUDIA", "d")); |
|
40 |
|
|
41 | 46 |
List<NameUserName> columnNames = new ArrayList<>(); |
42 |
columnNames.add(new NameUserName("FAKULTA_STUDIA", "d")); |
|
43 |
columnNames.add(new NameUserName("FORMA_STUDIA", "d")); |
|
44 |
|
|
45 | 47 |
List<ValueFunction> valueFunctions = new ArrayList<>(); |
46 |
valueFunctions.add(new ValueFunction("VEK", "d")); |
|
47 |
Converter c = new Converter(); |
|
48 |
return c.convertTableColumnsToContingencyTableRows(tableColumns, rowNames, columnNames, valueFunctions); |
|
48 |
|
|
49 |
// sort parameters in configuration to have them in order set by user |
|
50 |
Collections.sort(configuration.getParametersInConfiguration()); |
|
51 |
|
|
52 |
// TODO: 28.05.2020 map would be better |
|
53 |
for(ParameterInConfiguration parameterInConfiguration : configuration.getParametersInConfiguration()) { |
|
54 |
if (parameterInConfiguration.getLocation() != null && parameterInConfiguration.getLocation().getName().equals("Řádek")) { |
|
55 |
rowNames.add(new NameUserName(parameterInConfiguration.getParameter().getNameOfSelect().toUpperCase(), |
|
56 |
parameterInConfiguration.getColumnName())); |
|
57 |
} |
|
58 |
else if (parameterInConfiguration.getLocation() != null && parameterInConfiguration.getLocation().getName().equals("Sloupec")) { |
|
59 |
columnNames.add(new NameUserName(parameterInConfiguration.getParameter().getNameOfSelect().toUpperCase(), |
|
60 |
parameterInConfiguration.getColumnName())); |
|
61 |
} |
|
62 |
else if(parameterInConfiguration.getLocation() != null && parameterInConfiguration.getLocation().getName().equals("Hodnota")) { |
|
63 |
for (Function function : parameterInConfiguration.getFunctions()) { |
|
64 |
valueFunctions.add(new ValueFunction(parameterInConfiguration.getParameter().getNameOfSelect().toUpperCase(), |
|
65 |
function.getName().toUpperCase())); |
|
66 |
} |
|
67 |
} |
|
68 |
} |
|
69 |
|
|
70 |
Converter converter = new Converter(); |
|
71 |
return converter.convertTableColumnsToContingencyTableRows(tableColumns, rowNames, columnNames, valueFunctions); |
|
49 | 72 |
} |
50 | 73 |
|
51 | 74 |
/** |
Také k dispozici: Unified diff
re #7885 added SUM and ability to work with multiple values and sorted parameters in configuration, optimization