|
| 1 | +package net.bmagnu.dbfms; |
| 2 | + |
| 3 | +import net.bmagnu.dbfms.database.Collection; |
| 4 | +import net.bmagnu.dbfms.database.LocalDatabase; |
| 5 | +import net.bmagnu.dbfms.database.SQLQueryHelper; |
| 6 | +import net.bmagnu.dbfms.gui.DBFMS; |
| 7 | + |
| 8 | +import static javafx.application.Application.launch; |
| 9 | + |
| 10 | +import java.util.ArrayList; |
| 11 | +import java.util.HashMap; |
| 12 | +import java.util.List; |
| 13 | +import java.util.Map; |
| 14 | +import java.util.Map.Entry; |
| 15 | + |
| 16 | +import javafx.util.Pair; |
| 17 | + |
| 18 | +public class Main { |
| 19 | + public static void main(String[] args) { |
| 20 | + //launch(DBFMS.class, args); |
| 21 | + |
| 22 | + /*List<Map<String, Object>> tables = LocalDatabase.executeSQL("SELECT * FROM sys.systables", "TABLENAME"); |
| 23 | + for(Map<String, Object> table : tables) { |
| 24 | + for(Entry<String, Object> value : table.entrySet()) |
| 25 | + System.out.println(value.getKey() + ": " + (String)value.getValue()); |
| 26 | + }*/ |
| 27 | + |
| 28 | + //LocalDatabase.executeSQL("CREATE TABLE test(Test1 INT, Test2 VARCHAR(255))", true); |
| 29 | + Collection collection = new Collection("test", "a", "b", "c"); |
| 30 | + |
| 31 | + /*tables = LocalDatabase.executeSQL("SELECT * FROM sys.systables", "TABLENAME"); |
| 32 | + for(Map<String, Object> table : tables) { |
| 33 | + for(Entry<String, Object> value : table.entrySet()) |
| 34 | + System.out.println(value.getKey() + ": " + (String)value.getValue()); |
| 35 | + }*/ |
| 36 | + |
| 37 | + collection.emplaceTag("1", ""); |
| 38 | + collection.emplaceTag("2", ""); |
| 39 | + collection.emplaceTag("3", ""); |
| 40 | + |
| 41 | + collection.emplaceTypeValue("a", "1"); |
| 42 | + collection.emplaceTypeValue("a", "2"); |
| 43 | + collection.emplaceTypeValue("b", "1"); |
| 44 | + collection.emplaceTypeValue("b", "2"); |
| 45 | + collection.emplaceTypeValue("c", "1"); |
| 46 | + collection.emplaceTypeValue("c", "2"); |
| 47 | + |
| 48 | + Map<String, String> types1 = new HashMap<>(); |
| 49 | + types1.put("a", "1"); |
| 50 | + types1.put("b", "1"); |
| 51 | + types1.put("c", "1"); |
| 52 | + |
| 53 | + Map<String, String> types2 = new HashMap<>(); |
| 54 | + types2.put("a", "1"); |
| 55 | + types2.put("b", "2"); |
| 56 | + types2.put("c", "2"); |
| 57 | + |
| 58 | + collection.emplaceFile("a", "", 0, types1); |
| 59 | + collection.emplaceFile("b", "", 0, types1); |
| 60 | + collection.emplaceFile("c", "", 0, types2); |
| 61 | + |
| 62 | + collection.connectTag("a", "1"); |
| 63 | + collection.connectTag("a", "2"); |
| 64 | + |
| 65 | + collection.connectTag("b", "2"); |
| 66 | + collection.connectTag("b", "3"); |
| 67 | + |
| 68 | + collection.connectTag("c", "3"); |
| 69 | + collection.connectTag("c", "1"); |
| 70 | + |
| 71 | + collection.emplaceField("a", "f", "te"); |
| 72 | + collection.emplaceField("b", "f", "ttes"); |
| 73 | + collection.emplaceField("c", "f", "banane"); |
| 74 | + collection.emplaceField("c", "g", "obst"); |
| 75 | + |
| 76 | + List<Pair<String, String>> types = new ArrayList<>(); |
| 77 | + types.add(new Pair<>("a","2")); |
| 78 | + |
| 79 | + String query = SQLQueryHelper.queryTypes(collection, types) ; |
| 80 | + |
| 81 | + List<Map<String, Object>>tables = LocalDatabase.executeSQL(query, "fileID"); |
| 82 | + |
| 83 | + |
| 84 | + |
| 85 | + for(Map<String, Object> table : tables) { |
| 86 | + for(Entry<String, Object> value : table.entrySet()) |
| 87 | + System.out.println(value.getKey() + ": " + (Integer)value.getValue()); |
| 88 | + } |
| 89 | + |
| 90 | + System.out.println(); |
| 91 | + |
| 92 | + Map<Integer, String> test = collection.queryFiles("+f:nane +g:o"); |
| 93 | + for(Integer value : test.keySet()) |
| 94 | + System.out.println(value); |
| 95 | + |
| 96 | + System.out.println(); |
| 97 | + |
| 98 | + /*test = collection.queryFiles("1 ~2"); |
| 99 | + for(Integer value : test.keySet()) |
| 100 | + System.out.println(value);*/ |
| 101 | + } |
| 102 | +} |
0 commit comments