3 import iotinstaller.MySQLInterface;
4 import iotinstaller.TableProperty;
5 import iotinstaller.Table;
9 import java.util.Scanner;
10 import java.util.Properties;
12 /** A class that creates an object for IoT device/entity installation into database
14 * @author Rahmadi Trimananda <rahmadi.trimananda @ uci.edu>
18 public final class IoTInstaller {
21 * IoTInstaller class properties
26 * IoTInstaller class constants
28 private static final String STR_MAIN_TABLE_NAME = "IoTMain";
29 private static final String STR_COMM_TABLE_NAME = "IoTComm";
30 private static final String STR_HOST_TABLE_NAME = "IoTComputeNode";
31 private static final String STR_ADDRESS_TABLE_NAME = "IoTAddress";
32 private static final String STR_DEV_ADD_TABLE_NAME = "IoTDeviceAddress";
33 private static final String STR_ZB_ADD_TABLE_NAME = "IoTZigbeeAddress";
34 private static final int INT_NUM_COMM_FIELDS = 5;
35 private static final int INT_NUM_HOST_FIELDS = 3;
37 private static final String STR_INSTALL_ENTITY_CMD = "-install_ent";
38 private static final String STR_INSTALL_COMMUNICATION_CMD = "-install_comm";
39 private static final String STR_INSTALL_COMPLETE_CMD = "-install_comp";
40 private static final String STR_INSTALL_ADDRESS_CMD = "-install_add";
41 private static final String STR_INSTALL_DEV_ADDRESS_CMD = "-install_dev_add";
42 private static final String STR_INSTALL_ZB_ADDRESS_CMD = "-install_zb_add";
43 private static final String STR_INSTALL_HOST_CMD = "-install_host";
44 private static final String STR_DELETE_ENTITY_CMD = "-delete_ent";
45 private static final String STR_DELETE_ADDRESS_CMD = "-delete_add";
46 private static final String STR_DELETE_DEV_ADD_CMD = "-delete_dev_add";
47 private static final String STR_DELETE_ZB_ADD_CMD = "-delete_zb_add";
48 private static final String STR_DELETE_HOST_CMD = "-delete_host";
49 private static final String STR_HELP_CMD = "-help";
54 public IoTInstaller() {
56 // Make this not verbose by default
57 tbl = new Table(false);
58 System.out.println("IoTInstaller: Initializing installation..");
62 * A method to insert a new entry to the main table (IoTMain)
64 * This entry can be a new device or a new entity that we should keep track about
65 * A new entry will need a unique ID and a type name from the driver
67 * @param strID string ID to insert device into the main table
68 * @param strType string type to insert device into the main table
71 private void insertMainDBEntry(String strID, String strType) {
73 // Creating String array
74 String[] strFlds = new String[2];
75 for(int i=0; i<2; i++) {
76 strFlds[i] = new String();
81 // Insert entry through Table object
82 tbl.setTableName(STR_MAIN_TABLE_NAME);
83 tbl.insertEntry(strFlds);
84 System.out.println("IoTInstaller: Inserting a new entry into main table");
88 * A method to extract device/entity information from the user
90 * Users are supposed to supply the information needed for installation
91 * This is the core of the operation after getting the Scanner object.
93 * @param scanFile Scanner object of source
96 public void extractTableAndInstallCore(Scanner scanFile) {
98 // Parse configuration file
99 // Assumption here is that .config file is written with the correct syntax (need typechecking)
100 //File file = new File(strCfgFileName);
101 //Scanner scanFile = new Scanner(new FileReader(file));
102 //System.out.println("IoTInstaller: Extracting information from config file: " + strCfgFileName);
104 // Initialize String for ID and TYPE
107 String strTypeSpecific = "";
109 // Initialize TableProperty for devices and specific devices
111 // e.g. ProximitySensor - table of many ProximitySensor devices
112 // ProximitySensorBrandA - table that contains the constructor
113 // information for a specific device
114 TableProperty[] tpDevice = new TableProperty[1];
115 TableProperty[] tpDeviceSpecific = new TableProperty[1];
117 // Initialize array of string
118 String[] strFields = new String[1];
119 String[] strFieldsSpecific = new String[1];
121 // String for scanning the file
124 // Store number of fields here
126 while (scanFile.hasNext()) {
128 strScan = scanFile.next();
129 if (strScan.equals("IoTMain")) {
131 while (scanFile.hasNext()) {
132 strScan = scanFile.next();
135 if (strScan.equals("ID")) {
136 strID = scanFile.next();
139 else if (strScan.equals("TYPE")) {
140 strType = scanFile.next();
143 else if (strScan.equals("TYPESPECIFIC")) {
144 strTypeSpecific = scanFile.next();
145 } else if (strScan.equals("END")) {
150 } else if (strScan.equals("Table")) {
152 // Get number of fields, e.g. Table 3
153 iFields = scanFile.nextInt();
155 // We have device ID and device specific names
156 // e.g. ID = PS1; TYPE
157 tpDevice = new TableProperty[2];
158 tpDevice[0] = new TableProperty();
159 tpDevice[0].setField("ID");
160 tpDevice[0].setType("VARCHAR");
161 tpDevice[0].setLength("5");
162 tpDevice[1] = new TableProperty();
163 tpDevice[1].setField("TYPE");
164 tpDevice[1].setType("VARCHAR");
165 tpDevice[1].setLength("30");
167 // Prepare properties for a specific device
168 tpDeviceSpecific = new TableProperty[iFields];
169 for (int i=0; i<iFields; i++) {
170 tpDeviceSpecific[i] = new TableProperty();
172 // Looping over the fields
173 strScan = scanFile.next();
174 tpDeviceSpecific[i].setField(strScan);
175 strScan = scanFile.next();
176 tpDeviceSpecific[i].setType(strScan);
177 strScan = scanFile.next();
178 tpDeviceSpecific[i].setLength(strScan);
180 } else if (strScan.equals("Data")) {
182 // Get the device information
183 strFields = new String[2];
184 strFields[0] = strID;
185 strFields[1] = strTypeSpecific;
187 if ((tpDeviceSpecific.length == 1) &&
188 (tpDeviceSpecific[0].getField().equals("EMPTY"))) {
190 // Get the fields for specific device
191 strFieldsSpecific = null;
192 System.out.println("IoTInstaller: Empty constructor for: " + strTypeSpecific);
196 // Get the fields for specific device
197 strFieldsSpecific = new String[iFields];
198 for (int i=0; i<iFields; i++) {
199 strScan = scanFile.next();
200 strFieldsSpecific[i] = strScan;
206 installNewEntity(strType, strTypeSpecific, strID, tpDevice,
207 tpDeviceSpecific, strFields, strFieldsSpecific);
208 System.out.println("IoTInstaller: Installing a new entity/device into the system");
212 * A method to extract device/entity information from the user
214 * Users are supposed to supply the information needed for installation
216 * @param strCfgFileName String config file name for device/entity
219 public void extractTableAndInstall(String strCfgFileName) {
220 // TO DO: WE PROBABLY NEED TO IMPROVE THE FILE PARSING BUT FOR NOW KEEP IT MINIMUM
224 // Parse configuration file
225 // Assumption here is that .config file is written with the correct syntax (need typechecking)
226 File file = new File(strCfgFileName);
227 Scanner scanFile = new Scanner(new FileReader(file));
228 System.out.println("IoTInstaller: Extracting information from config file: " + strCfgFileName);
230 extractTableAndInstallCore(scanFile);
232 } catch (FileNotFoundException ex) {
234 System.out.println("IoTInstaller: Exception: ");
235 ex.printStackTrace();
241 * A method to install a new entity/device into the database
243 * 1) Insert this device/entity into the main table IoTMain
244 * 2) Create a new device/entity table if it doesn't exist yet
245 * 3) Insert this entry into the specific device/entity table
247 * @param strType String device type
248 * @param strTypeSpecific String device specific type
249 * @param strID String unique device/entity ID
250 * @param tpDevice array of TableProperty to construct the new table
251 * @param tpDeviceSpecific array of TableProperty to construct the new table
252 * @param strFields field values of device table
253 * @param strFieldsSpecific field values of device specific table
255 private void installNewEntity(String strType, String strTypeSpecific, String strID,
256 TableProperty[] tpDevice, TableProperty[] tpDeviceSpecific, String[] strFields, String[] strFieldsSpecific) {
258 // Create a new IoTInstaller object
259 System.out.println("IoTInstaller: Installing device " + strType + " with specific type " + strTypeSpecific);
260 tbl.setTableName(strType);
262 // 1) Insert this device/entity into the main table IoTMain
263 insertMainDBEntry(strID, strType);
266 // 2) Create a new device/entity table if it doesn't exist yet
267 tbl.setTableName(strType);
268 if (tbl.isTableExisting()) {
270 System.out.println("IoTInstaller: Table " + strType + " exists.. just insert new entry!");
272 // table does not exist yet
273 tbl.createTable(tpDevice, "ID");
276 // 3) Insert this entry into the device/entity table
277 tbl.insertEntry(strFields);
279 // Device specific table
280 // 2) Create a new device/entity table if it doesn't exist yet
281 // P.S. We should assume that table doesn't exist yet, and we throw error otherwise!
282 tbl.setTableName(strTypeSpecific + strID);
283 tbl.createTable(tpDeviceSpecific, null);
285 // 3) Insert this entry into the device/entity table
286 if (strFieldsSpecific != null) {
287 tbl.insertEntry(strFieldsSpecific);
292 * A method to extract device/entity communication configuration from the user
294 * Users are supposed to supply the information needed for installation
296 * @param strCfgFileName String config file name for device/entity
299 public void extractCommAndInstall(String strCfgFileName) {
300 // TODO: WE PROBABLY NEED TO IMPROVE THE FILE PARSING BUT FOR NOW KEEP IT MINIMUM
304 // Parse configuration file
305 // Assumption here is that .config file is written with the correct syntax (need typechecking)
306 File file = new File(strCfgFileName);
307 Scanner scanFile = new Scanner(new FileReader(file));
309 System.out.println("IoTInstaller: Extracting information from config file: " + strCfgFileName);
314 // Initialize array of string
315 String[] strFields = new String[INT_NUM_COMM_FIELDS];
316 for(int i=0; i<INT_NUM_COMM_FIELDS; i++) {
317 strFields[i] = new String();
319 while (scanFile.hasNext() && (iFieldCnt < INT_NUM_COMM_FIELDS)) {
321 strFields[iFieldCnt++] = scanFile.next();
324 // Create a new installer object
325 tbl.setTableName(STR_COMM_TABLE_NAME);
326 tbl.insertEntry(strFields);
328 System.out.println("IoTInstaller: Installing a new communication pattern into the system");
330 } catch (FileNotFoundException ex) {
332 System.out.println("IoTInstaller: Exception: ");
333 ex.printStackTrace();
339 * A method to extract device/entity addresses information
341 * Users are supposed to supply the information needed for installation
343 * @param is InputStream of the input source
346 public void installDeviceAddressCore(InputStream is) {
348 Properties prop = new Properties();
351 } catch (IOException ex) {
352 ex.printStackTrace();
355 // We can only install one device address per one time with the following sequence
356 String[] strFields = new String[2];
357 String[] strFieldsAddress = null;
358 // Check for wildcard feature
359 if ((prop.getProperty("SOURCEWILDCARD", null) != null) &&
360 (prop.getProperty("DESTWILDCARD", null) != null)) {
361 strFieldsAddress = new String[5];
362 strFieldsAddress[3] = prop.getProperty("SOURCEWILDCARD");
363 strFieldsAddress[4] = prop.getProperty("DESTWILDCARD");
365 strFieldsAddress = new String[3];
367 strFields[0] = prop.getProperty("ID");
368 strFields[1] = prop.getProperty("ADDRESSFOR");
369 strFieldsAddress[0] = prop.getProperty("DEVICEADDRESS");
370 strFieldsAddress[1] = prop.getProperty("PORTNUMBER");
371 strFieldsAddress[2] = prop.getProperty("PROTOCOL");
373 // Insert this entry into the main device address table
374 tbl.setTableName(STR_DEV_ADD_TABLE_NAME);
375 tbl.insertEntry(strFields);
377 // Create a new table for a specific device address
378 // e.g. AmcrestCameraAdd + CM1 = AmcrestCameraAddCM1
379 tbl.setTableName(strFields[1] + strFields[0]);
381 // Table does not exist yet
382 // Set TableProperty for device address (MAC address)
383 TableProperty[] tp = null;
384 // Check for wildcard feature
385 if (strFieldsAddress.length == 5) {
386 tp = new TableProperty[5];
387 tp[3] = new TableProperty();
388 tp[3].setField("SOURCEWILDCARD");
389 tp[3].setType("VARCHAR");
390 tp[3].setLength("5");
391 tp[4] = new TableProperty();
392 tp[4].setField("DESTWILDCARD");
393 tp[4].setType("VARCHAR");
394 tp[4].setLength("5");
396 tp = new TableProperty[3];
398 tp[0] = new TableProperty();
399 tp[0].setField("DEVICEADDRESS");
400 tp[0].setType("VARCHAR");
401 tp[0].setLength("20");
402 tp[1] = new TableProperty();
403 tp[1].setField("PORTNUMBER");
404 tp[1].setType("INT");
405 tp[1].setLength("11");
406 tp[2] = new TableProperty();
407 tp[2].setField("PROTOCOL");
408 tp[2].setType("VARCHAR");
409 tp[2].setLength("5");
410 tbl.createTable(tp, "DEVICEADDRESS");
412 // Insert new address entry
413 tbl.insertEntry(strFieldsAddress);
415 System.out.println("IoTInstaller: Installing a new device/entity address into the system");
419 * A method to extract device/entity addresses information
421 * Users are supposed to supply the information needed for installation
423 * @param strCfgFileName String config file name for device/entity
426 public void installDeviceAddress(String strCfgFileName) {
430 // Parse configuration file
431 File file = new File(strCfgFileName);
432 FileInputStream fis = new FileInputStream(file);
433 System.out.println("IoTInstaller: Extracting information from config file: " + strCfgFileName);
435 installDeviceAddressCore(fis);
437 } catch (FileNotFoundException ex) {
439 System.out.println("IoTInstaller: Exception: ");
440 ex.printStackTrace();
446 * A method to extract Zigbee device addresses information
448 * Users are supposed to supply the information needed for installation
450 * @param strCfgFileName String config file name for device/entity
453 public void installZigbeeAddress(String strCfgFileName) {
457 // Parse configuration file
458 Properties prop = new Properties();
459 File file = new File(strCfgFileName);
460 FileInputStream fis = new FileInputStream(file);
463 } catch (IOException ex) {
464 ex.printStackTrace();
466 System.out.println("IoTInstaller: Extracting information from config file: " + strCfgFileName);
468 // We can only install one device address per one time with the following sequence
469 String[] strFields = new String[2];
470 String[] strFieldsAddress = new String[1];
471 strFields[0] = prop.getProperty("ID");
472 strFields[1] = prop.getProperty("ADDRESSFOR");
473 strFieldsAddress[0] = prop.getProperty("DEVICEADDRESS");
475 // Insert this entry into the main device address table
476 tbl.setTableName(STR_ZB_ADD_TABLE_NAME);
477 tbl.insertEntry(strFields);
479 // Create a new table for a specific device address
480 // e.g. AmcrestCameraZBAdd + CM1 = AmcrestCameraZBAddCM1
481 tbl.setTableName(strFields[1] + strFields[0]);
483 // Table does not exist yet
484 // Set TableProperty for device address (MAC address)
485 TableProperty[] tp = new TableProperty[1];
486 tp[0] = new TableProperty();
487 tp[0].setField("DEVICEADDRESS");
488 tp[0].setType("VARCHAR");
489 tp[0].setLength("25");
490 tbl.createTable(tp, "DEVICEADDRESS");
492 // Insert new address entry
493 tbl.insertEntry(strFieldsAddress);
495 System.out.println("IoTInstaller: Installing a new device/entity address into the system");
497 } catch (FileNotFoundException ex) {
499 System.out.println("IoTInstaller: Exception: ");
500 ex.printStackTrace();
506 * A method to extract simple addresses information, e.g. www.google.com
508 * Users are supposed to supply the information needed for installation
510 * @param strCfgFileName String config file name for device/entity
513 public void installAddress(String strCfgFileName) {
517 // Parse configuration file
518 Properties prop = new Properties();
519 File file = new File(strCfgFileName);
520 FileInputStream fis = new FileInputStream(file);
523 } catch (IOException ex) {
524 ex.printStackTrace();
526 System.out.println("IoTInstaller: Extracting information from config file: " + strCfgFileName);
528 // We can only install one device address per one time with the following sequence
529 String[] strFields = new String[2];
530 String[] strFieldsAddress = new String[1];
531 strFields[0] = prop.getProperty("ID");
532 strFields[1] = prop.getProperty("ADDRESSFOR");
533 strFieldsAddress[0] = prop.getProperty("ADDRESS");
535 // Insert this entry into the main device address table
536 tbl.setTableName(STR_ADDRESS_TABLE_NAME);
537 tbl.insertEntry(strFields);
539 // Create a new table for a specific device address
540 // e.g. WeatherForecastAdd + WF1 = WeatherForecastAddCM1
541 tbl.setTableName(strFields[1] + strFields[0]);
543 // Table does not exist yet
544 // Set TableProperty for device address (MAC address)
545 TableProperty[] tp = new TableProperty[1];
546 tp[0] = new TableProperty();
547 tp[0].setField("ADDRESS");
548 tp[0].setType("VARCHAR");
549 tp[0].setLength("50");
550 tbl.createTable(tp, "ADDRESS");
552 // Insert new address entry
553 tbl.insertEntry(strFieldsAddress);
555 System.out.println("IoTInstaller: Installing a new device/entity address into the system");
557 } catch (FileNotFoundException ex) {
559 System.out.println("IoTInstaller: Exception: ");
560 ex.printStackTrace();
566 * A method to extract host information for host installation
568 * Users are supposed to supply the information needed for installation
570 * @param strCfgFileName String config file name for device/entity
573 public void installHost(String strCfgFileName) {
575 // Parse configuration file
576 Properties prop = new Properties();
577 File file = new File(strCfgFileName);
578 FileInputStream fis = new FileInputStream(file);
581 } catch (IOException ex) {
582 ex.printStackTrace();
584 System.out.println("IoTInstaller: Extracting information from config file: " + strCfgFileName);
585 // Initialize array of string
586 String[] strFields = new String[3];
587 strFields[0] = prop.getProperty("HOSTADDRESS");
588 strFields[1] = prop.getProperty("PROCESSOR");
589 strFields[2] = prop.getProperty("MEMORY");
590 // Create a new installer object
591 tbl.setTableName(STR_HOST_TABLE_NAME);
592 tbl.insertEntry(strFields);
594 System.out.println("IoTInstaller: Installing a new host into the system");
596 } catch (FileNotFoundException ex) {
598 System.out.println("IoTInstaller: Exception: ");
599 ex.printStackTrace();
605 * A method to delete host information from database by putting in host address
607 * @param strHostAddress String for host address
610 public void deleteHost(String strHostAddress) {
612 tbl.setTableName(STR_HOST_TABLE_NAME);
613 String strWhere = "HOSTADDRESS='" + strHostAddress + "';";
614 tbl.deleteEntry(strWhere);
616 System.out.println("IoTInstaller: Deleting a host from the system");
620 * A method to delete entity information from database
622 * @param strEntID String for entity ID
623 * @param strEntType String for entity type
624 * @param strEntName String for entity name
627 public void deleteEntity(String strEntID, String strEntType, String strEntName) {
629 // Delete from table IoTMain
630 tbl.setTableName(STR_MAIN_TABLE_NAME);
631 String strWhere = "ID='" + strEntID + "';";
632 tbl.deleteEntry(strWhere);
633 System.out.println("IoTInstaller: Removing entity from table " + STR_MAIN_TABLE_NAME);
635 // Delete from table with type name, e.g. Camera
636 tbl.setTableName(strEntType);
637 strWhere = "ID='" + strEntID + "';";
638 tbl.deleteEntry(strWhere);
639 System.out.println("IoTInstaller: Removing entity from table type: " + strEntType);
640 // Drop table if this was the last entry
641 if (tbl.isTableEmpty()) {
643 System.out.println("IoTInstaller: Dropping the table.. It was the last entry!");
646 // Drop the table that contains constructor information
647 tbl.setTableName(strEntName + strEntID);
649 System.out.println("IoTInstaller: Dropping class constructor table...");
651 System.out.println("IoTInstaller: Deleting an entry from the system...");
655 * A method to delete address information from database
657 * @param strTableName String for main table, i.e. IoTAddress, IoTDeviceAddress, or IoTZigbeeAddress
658 * @param strEntID String for entity ID, e.g. CM1
659 * @param strEntAddType String for entity address type, e.g. AmcrestCameraAdd
662 public void deleteAddress(String strTableName, String strEntID, String strEntAddType) {
664 // Delete from main table, e.g. IoTAddress, IoTDeviceAddress, or IoTZigbeeAddress
665 tbl.setTableName(strTableName);
666 String strWhere = "ID='" + strEntID + "';";
667 tbl.deleteEntry(strWhere);
668 System.out.println("IoTInstaller: Removing entity from table " + strTableName);
670 // Drop the table that contains constructor information
671 tbl.setTableName(strEntAddType + strEntID);
673 System.out.println("IoTInstaller: Dropping class constructor table...");
675 System.out.println("IoTInstaller: Deleting an entry from the system...");
680 * A method to install a pair of new devices with their communication pattern
682 * @param strFirstDeviceFile String that contains the file name of the fist device
683 * @param strSecondDeviceFile String that contains the file name of the second device
684 * @param strCommFile String that contains the file name of the communication file
687 public void installPairOfEntities(String strFirstEntityFile,
688 String strSecondEntityFile, String strCommFile) {
689 // TODO: NEED TO DO THE INPUT FAILURE CHECKING HERE
690 // NOW JUST ASSUME THAT THE INPUT FILES ARE GOOD
692 extractTableAndInstall(strFirstEntityFile);
693 extractTableAndInstall(strSecondEntityFile);
694 extractCommAndInstall(strCommFile);
698 * A method to output help messages
702 public void helpMessages() {
703 System.out.println();
704 System.out.println("IoTInstaller: Command line options:");
705 System.out.println("IoTInstaller: 1) Install one device, e.g. java iotinstaller.IoTInstaller -install_ent <filename>");
706 System.out.println("IoTInstaller: 2) Install comm pattern, e.g. java iotinstaller.IoTInstaller -install_comm <filename>");
707 System.out.print("IoTInstaller: 3) Install two devices and comm pattern, e.g. java iotinstaller.IoTInstaller ");
708 System.out.println("-install_comp <first_entity_filename> <second_entity_filename> <communication_filename>");
709 System.out.println("IoTInstaller: 4) Install address, e.g. java iotinstaller.IoTInstaller -install_add <filename>");
710 System.out.println("IoTInstaller: 5) Install device address, e.g. java iotinstaller.IoTInstaller -install_dev_add <filename>");
711 System.out.println("IoTInstaller: 6) Install zigbee device address, e.g. java iotinstaller.IoTInstaller -install_zb_add <filename>");
712 System.out.println("IoTInstaller: 7) Install host, e.g. java iotinstaller.IoTInstaller -install_host <filename>");
713 System.out.println("IoTInstaller: 8) Delete entity, e.g. java iotinstaller.IoTInstaller -delete_ent <ent_id> <ent_type> <ent_name>");
714 System.out.println("IoTInstaller: 9) Delete address, e.g. java iotinstaller.IoTInstaller -delete_add <ent_id> <ent_type>");
715 System.out.println("IoTInstaller: 10) Delete device address, e.g. java iotinstaller.IoTInstaller -delete_dev_add <ent_id> <ent_type>");
716 System.out.println("IoTInstaller: 11) Delete zigbee device address, e.g. java iotinstaller.IoTInstaller -delete_zb_add <ent_id> <ent_type>");
717 System.out.println("IoTInstaller: 12) Delete host, e.g. java iotinstaller.IoTInstaller -delete_host <host_address>");
718 System.out.println("IoTInstaller: Type 'java iotinstaller.IoTInstaller -help' to display this help.");
719 System.out.println();
723 * A method to output help messages
727 public String helpMessagesString() {
728 String helpTxt = "\n";
729 helpTxt = helpTxt + "IoTInstaller: Command line options:\n";
730 helpTxt = helpTxt + "IoTInstaller: 1) Install one device, e.g. java iotinstaller.IoTInstaller -install_ent <filename>\n";
731 helpTxt = helpTxt + "IoTInstaller: 2) Install comm pattern, e.g. java iotinstaller.IoTInstaller -install_comm <filename>\n";
732 helpTxt = helpTxt + "IoTInstaller: 3) Install two devices and comm pattern, e.g. java iotinstaller.IoTInstaller ";
733 helpTxt = helpTxt + "-install_comp <first_entity_filename> <second_entity_filename> <communication_filename>\n";
734 helpTxt = helpTxt + "IoTInstaller: 4) Install address, e.g. java iotinstaller.IoTInstaller -install_add <filename>\n";
735 helpTxt = helpTxt + "IoTInstaller: 5) Install device address, e.g. java iotinstaller.IoTInstaller -install_dev_add <filename>\n";
736 helpTxt = helpTxt + "IoTInstaller: 6) Install zigbee device address, e.g. java iotinstaller.IoTInstaller -install_zb_add <filename>\n";
737 helpTxt = helpTxt + "IoTInstaller: 7) Install host, e.g. java iotinstaller.IoTInstaller -install_host <filename>\n";
738 helpTxt = helpTxt + "IoTInstaller: 8) Delete entity, e.g. java iotinstaller.IoTInstaller -delete_ent <ent_id> <ent_type> <ent_name>\n";
739 helpTxt = helpTxt + "IoTInstaller: 9) Delete address, e.g. java iotinstaller.IoTInstaller -delete_add <ent_id>\n";
740 helpTxt = helpTxt + "IoTInstaller: 10) Delete device address, e.g. java iotinstaller.IoTInstaller -delete_dev_add <ent_id>\n";
741 helpTxt = helpTxt + "IoTInstaller: 11) Delete zigbee device address, e.g. java iotinstaller.IoTInstaller -delete_zb_add <ent_id>\n";
742 helpTxt = helpTxt + "IoTInstaller: 12) Delete host, e.g. java iotinstaller.IoTInstaller -delete_host <host_address>\n";
743 helpTxt = helpTxt + "IoTInstaller: Type 'java iotinstaller.IoTInstaller -help' to display this help.\n";
744 helpTxt = helpTxt + "\n";
750 * Main method that accepts inputs for installation
752 * @param args[0] String that contains the command line parameter
753 * @param args[1] String that contains the first file name / entity ID / host address
754 * @param args[2] String that contains the second file name
755 * @param args[3] String that contains the third file name
758 public static void main(String[] args) {
760 // Testing IoTInstaller object
761 IoTInstaller iotinst = new IoTInstaller();
763 // TODO: PROBABLY NEED A BETTER ERROR HANDLING FOR INPUTS HERE
764 // NOW ASSUME MINIMAL ERROR FOR INPUTS
765 if (args.length > 0) {
766 // Check for input parameters
767 if (args[0].equals(STR_INSTALL_ENTITY_CMD)) {
768 iotinst.extractTableAndInstall(args[1]);
770 } else if (args[0].equals(STR_INSTALL_COMMUNICATION_CMD)) {
771 iotinst.extractCommAndInstall(args[1]);
773 } else if (args[0].equals(STR_INSTALL_COMPLETE_CMD)) {
774 iotinst.installPairOfEntities(args[1], args[2], args[3]);
776 } else if (args[0].equals(STR_INSTALL_ADDRESS_CMD)) {
777 iotinst.installAddress(args[1]);
779 } else if (args[0].equals(STR_INSTALL_DEV_ADDRESS_CMD)) {
780 iotinst.installDeviceAddress(args[1]);
782 } else if (args[0].equals(STR_INSTALL_ZB_ADDRESS_CMD)) {
783 iotinst.installZigbeeAddress(args[1]);
785 } else if (args[0].equals(STR_INSTALL_HOST_CMD)) {
786 iotinst.installHost(args[1]);
788 } else if (args[0].equals(STR_DELETE_ENTITY_CMD)) {
789 iotinst.deleteEntity(args[1], args[2], args[3]);
791 } else if (args[0].equals(STR_DELETE_ADDRESS_CMD)) {
792 iotinst.deleteAddress(STR_ADDRESS_TABLE_NAME, args[1], args[2]);
794 } else if (args[0].equals(STR_DELETE_DEV_ADD_CMD)) {
795 iotinst.deleteAddress(STR_DEV_ADD_TABLE_NAME, args[1], args[2]);
797 } else if (args[0].equals(STR_DELETE_ZB_ADD_CMD)) {
798 iotinst.deleteAddress(STR_ZB_ADD_TABLE_NAME, args[1], args[2]);
800 } else if (args[0].equals(STR_DELETE_HOST_CMD)) {
801 iotinst.deleteHost(args[1]);
803 } else if (args[0].equals(STR_HELP_CMD)) {
804 iotinst.helpMessages();
807 System.out.println("IoTInstaller: ERROR: Wrong input parameters!");
808 iotinst.helpMessages();
811 System.out.println("IoTInstaller: ERROR: No input parameters detected!");
812 iotinst.helpMessages();