Skip to content

Commit a519b0d

Browse files
committed
- documentation (not finished yet)
1 parent 686423a commit a519b0d

File tree

8 files changed

+87
-90
lines changed

8 files changed

+87
-90
lines changed

src/main/java/analyzer/CSSAnalyzeInterface.java

Lines changed: 0 additions & 33 deletions
This file was deleted.

src/main/java/analyzer/CSSAnalyzer.java

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,20 @@
11
package analyzer;
22

33
import java.io.File;
4-
import java.io.FileInputStream;
5-
import java.io.FileNotFoundException;
64
import java.io.IOException;
7-
import java.io.InputStream;
8-
import java.io.InputStreamReader;
95
import java.nio.file.Files;
106
import java.nio.file.Path;
117
import java.nio.file.Paths;
128
import java.util.ArrayList;
139
import java.util.List;
1410
import java.util.stream.Collectors;
1511
import java.util.stream.Stream;
16-
17-
import org.w3c.css.sac.InputSource;
18-
19-
20-
import creator.CSSCreator;
2112
import git.GitProvider;
2213
import logger.Logger;
2314
import storage.StorageAdmin;
2415
import storage.StorageAdminInterface;
2516

26-
public class CSSAnalyzer implements CSSAnalyzeInterface, Runnable {
17+
public class CSSAnalyzer implements Runnable {
2718

2819
/**
2920
* GITHUB Cloned folder. NOT css style folder!
@@ -40,6 +31,10 @@ public class CSSAnalyzer implements CSSAnalyzeInterface, Runnable {
4031
*/
4132
private List<File> files;
4233

34+
/**
35+
* Runs the GitProvider, which will download the latest git repo with css-styles.
36+
* Will collect all CSS Files and store it to the artifact folder.
37+
*/
4338
public CSSAnalyzer() {
4439
files = new ArrayList<File>();
4540
this.stylesFolder = "osm-styles";

src/main/java/analyzer/DBAnalyzer.java

Lines changed: 48 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,63 @@
55
import java.sql.SQLException;
66
import java.util.ArrayList;
77
import java.util.List;
8-
98
import logger.Logger;
109
import models.MyTable;
1110
import psql.PostgreConnection;
1211
import storage.StorageAdmin;
1312
import storage.StorageAdminInterface;
1413

1514
public class DBAnalyzer {
16-
15+
16+
/**
17+
* PostgreConnection
18+
*/
1719
private PostgreConnection connection;
20+
21+
/**
22+
* List of database tables
23+
*/
1824
private List<MyTable> tables;
19-
25+
26+
/**
27+
* DatasetMeta of database
28+
*/
2029
private DatabaseMetaData md;
30+
31+
/**
32+
* ResultSet for the tables of the given database
33+
*/
2134
private ResultSet rsTables;
35+
36+
/**
37+
* ResultSet for the columns of a specific table, in a given database
38+
*/
2239
private ResultSet rsColumns;
23-
24-
private int counter;
25-
40+
41+
/**
42+
* Analyzes the database for tables and column of these tables.
43+
* Stores informations in the artifact folder.
44+
*
45+
* @param connection
46+
*/
2647
public DBAnalyzer(PostgreConnection connection) {
2748
this.connection = connection;
2849
this.tables = new ArrayList<MyTable>();
29-
counter = 1;
3050
}
3151

3252
public void start() {
3353
this.getTables();
3454
}
35-
55+
56+
/**
57+
* Collects all tables from the database under a specific schema.
58+
* Schema was set in the databaseconfig file, which will be anaylized after the
59+
* program starts.
60+
*
61+
* Databaseconfigfile = first parameter/argument
62+
*
63+
* @return
64+
*/
3665
private boolean getTables() {
3766
Logger.log("**************************************");
3867
Logger.log("Getting tablenames and colomnnames...");
@@ -57,21 +86,28 @@ private boolean getTables() {
5786
}
5887

5988
this.tables.add(tempTable);
60-
Logger.log("Added " + counter + " tables.");
61-
counter++;
89+
Logger.log("Added " + this.tables.size() + " tables.");
6290
}
6391

6492
this.storeData();
6593

6694
} catch (SQLException e) {
67-
// TODO Auto-generated catch block
6895
e.printStackTrace();
6996
return false;
7097
}
7198

7299
return true;
73100
}
74101

102+
/**
103+
* Converts the tableslist, to a list of strings, just with the name of the tables.
104+
* Calls the StorageAdmin, to store this data.
105+
*
106+
* TODO
107+
* Collect also the column names.
108+
* Use the StorageAdminHelper and implement in this class a new helpermethod.
109+
*
110+
*/
75111
public void storeData(){
76112
StorageAdminInterface sa = new StorageAdmin();
77113
List<String> tableNames = new ArrayList<>();
@@ -82,8 +118,5 @@ public void storeData(){
82118

83119
sa.storeList(tableNames, StorageAdminInterface.TABLE_NAMES, true);
84120
}
85-
86-
public List<MyTable> tables(){
87-
return this.tables;
88-
}
121+
89122
}

src/main/java/creator/CSSCreator.java

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,22 @@
55
import models.Match;
66

77
public class CSSCreator implements Runnable {
8-
9-
private Match[] accordances;
10-
11-
public CSSCreator(Match[] accordances) {
12-
File folder = new File("output");
13-
folder.mkdir();
14-
15-
this.accordances = accordances;
16-
}
8+
9+
10+
/**
11+
* TODO
12+
*
13+
* Implement: this class should be able, to generate
14+
* all the CSS files, which should be modified, as they can
15+
* be used for the geoserver, in connection with the database of is.
16+
*
17+
* CSSClasses / Files needs the same name as the tables in the database are named.
18+
*
19+
* Hint: Store the Matches out of the artifact folder.
20+
* For this, you can use the StorageAdmin-Method: stringToList(CSSIdentifier.MATCHES, ...)
21+
* and the StorageAdminHelper-Method: stringToMatch(..)
22+
*
23+
*/
1724

1825
@Override
1926
public void run() {

src/main/java/enumerations/CSSIdentifier.java

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,42 @@
11
package enumerations;
22

33
/**
4-
* Contains several important CSS identifiers/rules
5-
* @author Mario
4+
* Contains several CSS identifiers/rules
5+
*
6+
* You can use this in the FileAnalyzer, to scan the files for this identifiers.
7+
*
8+
* @author Mario Teklic
69
*
710
*/
811
public enum CSSIdentifier {
9-
10-
//Its important to let these whitespaces in the enums, because other methods will directly start to scan for the class/type/... value
1112

1213
/*
1314
* TODO:
1415
* Should add identifiers like "... and type in ..." to get more precise results
16+
* If you add new identifiers, you also need to scan for them.
17+
* For this you need the checkForMatches()-method, which calls the scanFile(...) method.
18+
* Both methods are in the FileAnalyzer.
19+
*
1520
*/
1621

17-
/**
18-
* CSS Rules:
19-
*/
22+
2023
CLASSNAME("[class = '"),
2124
TYPE("[type = '"),
2225
AND_TYPE_IN("and type in");
23-
26+
27+
/**
28+
* Identifier
29+
*/
2430
private String identifier;
2531

2632
CSSIdentifier(String identifier) {
2733
this.identifier = identifier;
2834
}
2935

36+
/**
37+
* Returns the identifier
38+
* @return
39+
*/
3040
public String getString() {
3141
return this.identifier;
3242
}

src/main/java/exceptions/WrongClassException.java

Lines changed: 0 additions & 12 deletions
This file was deleted.

src/main/java/git/GitProvider.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package git;
22

33
import java.io.File;
4-
import java.nio.file.Paths;
5-
64
import org.eclipse.jgit.api.Git;
75
import org.eclipse.jgit.api.errors.GitAPIException;
86
import org.eclipse.jgit.api.errors.JGitInternalException;

src/main/java/storage/StorageAdminHelper.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import models.CssClass;
44
import models.Match;
55
import models.MyTable;
6-
76
import java.io.File;
87
import java.util.ArrayList;
98
import java.util.List;

0 commit comments

Comments
 (0)