Repository navigation
Expand file tree
/
Copy pathProjectManagerDriver.java
More file actions
66 lines (61 loc) · 2.77 KB
/
Copy pathProjectManagerDriver.java
File metadata and controls
66 lines (61 loc) · 2.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Scanner;
// property manager driver
public class ProjectManagerDriver {
public static void main(String[] args) {
ArrayList<Property> modelPropertyList = new ArrayList<>();
try {
modelPropertyList = readPropertiesFromFiles();
projectManagerController controller = new projectManagerController(modelPropertyList, MyJFrame.getMyJFrame());
controller.initLoginPage();
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
// read all "approved" properties from files
public static ArrayList<Property> readPropertiesFromFiles() throws FileNotFoundException {
ArrayList<Property> propertyList = new ArrayList<>();
File mainDir = new File("System/Property Manager/");
File[] listOfManagersDir = mainDir.listFiles();
for(File file : listOfManagersDir) {
if(file.isDirectory()){
File propertiesDir = new File(file.getPath() + "/Properties/");
File[] propertiesOfManager = propertiesDir.listFiles();
for(File property : propertiesOfManager) {
File propertyInfo = new File(property.getPath() + "/propertyInfo.txt");
File propertyPic = new File(property.getPath()+ "/propertyPics");
String[] propertyPicPath = new String[propertyPic.list().length];
for(int i = 0; i < propertyPicPath.length; ++i){
propertyPicPath[i] = "System/" + mainDir.getName() + "/" + file.getName() +"/" + propertiesDir.getName() + "/" + property.getName() + "/" + propertyPic.getName() + "/" + propertyPic.list()[i];
System.out.println(propertyPicPath[i]);
}
Scanner propertyInfoScanner = new Scanner(propertyInfo);
Property readProperty = new Property(Integer.parseInt(propertyInfoScanner.nextLine()), //using the reading constructor (without incrementing the lastID)
propertyInfoScanner.nextLine(),
Double.parseDouble(propertyInfoScanner.nextLine()),
Integer.parseInt(propertyInfoScanner.nextLine()),
propertyPicPath,
new Address (propertyInfoScanner.nextLine(), propertyInfoScanner.nextLine()),
Integer.parseInt(propertyInfoScanner.nextLine()),
Integer.parseInt(propertyInfoScanner.nextLine()),
propertyInfoScanner.nextLine(),
propertyInfoScanner.nextLine(),
propertyInfoScanner.nextLine(),
propertyInfoScanner.nextLine(),
propertyInfoScanner.nextLine().split("\\|"),
propertyInfoScanner.nextLine().split("\\|"),
propertyInfoScanner.nextLine(),
propertyInfoScanner.nextLine(),
propertyInfoScanner.nextLine()
);
if(readProperty.getPropertyApprovalStatus().equals("Approved"))
propertyList.add(readProperty);
propertyInfoScanner.close();
}
}
}
return propertyList;
}
}