private static final String STR_INSTALL_DEV_ADDRESS_CMD = "-install_dev_add";
private static final String STR_INSTALL_ZB_ADDRESS_CMD = "-install_zb_add";
private static final String STR_INSTALL_HOST_CMD = "-install_host";
+ private static final String STR_DELETE_COMMUNICATION_CMD = "-delete_comm";
private static final String STR_DELETE_ENTITY_CMD = "-delete_ent";
private static final String STR_DELETE_ADDRESS_CMD = "-delete_add";
private static final String STR_DELETE_DEV_ADD_CMD = "-delete_dev_add";
// Parse configuration file
// Assumption here is that .config file is written with the correct syntax (need typechecking)
- //File file = new File(strCfgFileName);
- //Scanner scanFile = new Scanner(new FileReader(file));
- //System.out.println("IoTInstaller: Extracting information from config file: " + strCfgFileName);
-
// Initialize String for ID and TYPE
String strID = "";
String strType = "";
*/
public void extractTableAndInstall(String strCfgFileName) {
// TO DO: WE PROBABLY NEED TO IMPROVE THE FILE PARSING BUT FOR NOW KEEP IT MINIMUM
-
try {
// Parse configuration file
strFields[iFieldCnt++] = scanFile.next();
}
-
// Create a new installer object
tbl.setTableName(STR_COMM_TABLE_NAME);
tbl.insertEntry(strFields);
}
}
+
+ /**
+ * A method to delete relation/communication information from database
+ *
+ * @param strEntIDSource String for entity ID source
+ * @param strEntIDDest String for entity ID destination
+ * @return void
+ */
+ public void deleteComm(String strEntIDSource, String strEntIDDest) {
+
+ // Delete from table IoTMain
+ tbl.setTableName(STR_COMM_TABLE_NAME);
+ String strWhere = "ID_SOURCE='" + strEntIDSource + "' AND ID_DESTINATION='" + strEntIDDest + "';";
+ tbl.deleteEntry(strWhere);
+ System.out.println("IoTInstaller: Removing relation/communication from table " + STR_COMM_TABLE_NAME);
+ }
/**
* A method to extract device/entity addresses information
// Insert new address entry
tbl.insertEntry(strFieldsAddress);
-
System.out.println("IoTInstaller: Installing a new device/entity address into the system");
}
File file = new File(strCfgFileName);
FileInputStream fis = new FileInputStream(file);
System.out.println("IoTInstaller: Extracting information from config file: " + strCfgFileName);
-
installDeviceAddressCore(fis);
} catch (FileNotFoundException ex) {
// Insert new address entry
tbl.insertEntry(strFieldsAddress);
-
System.out.println("IoTInstaller: Installing a new device/entity address into the system");
} catch (FileNotFoundException ex) {
// Insert new address entry
tbl.insertEntry(strFieldsAddress);
-
System.out.println("IoTInstaller: Installing a new device/entity address into the system");
} catch (FileNotFoundException ex) {
// Create a new installer object
tbl.setTableName(STR_HOST_TABLE_NAME);
tbl.insertEntry(strFields);
-
System.out.println("IoTInstaller: Installing a new host into the system");
} catch (FileNotFoundException ex) {
tbl.setTableName(STR_HOST_TABLE_NAME);
String strWhere = "HOSTADDRESS='" + strHostAddress + "';";
tbl.deleteEntry(strWhere);
-
System.out.println("IoTInstaller: Deleting a host from the system");
}
String strWhere = "ID='" + strEntID + "';";
tbl.deleteEntry(strWhere);
System.out.println("IoTInstaller: Removing entity from table " + STR_MAIN_TABLE_NAME);
-
// Delete from table with type name, e.g. Camera
tbl.setTableName(strEntType);
strWhere = "ID='" + strEntID + "';";
tbl.setTableName(strEntAddType + strEntID);
tbl.dropTable();
System.out.println("IoTInstaller: Dropping class constructor table...");
-
System.out.println("IoTInstaller: Deleting an entry from the system...");
}
System.out.println("IoTInstaller: 6) Install zigbee device address, e.g. java iotinstaller.IoTInstaller -install_zb_add <filename>");
System.out.println("IoTInstaller: 7) Install host, e.g. java iotinstaller.IoTInstaller -install_host <filename>");
System.out.println("IoTInstaller: 8) Delete entity, e.g. java iotinstaller.IoTInstaller -delete_ent <ent_id> <ent_type> <ent_name>");
- System.out.println("IoTInstaller: 9) Delete address, e.g. java iotinstaller.IoTInstaller -delete_add <ent_id> <ent_type>");
- System.out.println("IoTInstaller: 10) Delete device address, e.g. java iotinstaller.IoTInstaller -delete_dev_add <ent_id> <ent_type>");
- System.out.println("IoTInstaller: 11) Delete zigbee device address, e.g. java iotinstaller.IoTInstaller -delete_zb_add <ent_id> <ent_type>");
- System.out.println("IoTInstaller: 12) Delete host, e.g. java iotinstaller.IoTInstaller -delete_host <host_address>");
+ System.out.println("IoTInstaller: 9) Delete comm pattern, e.g. java iotinstaller.IoTInstaller -delete_comm <ent_id_source> <ent_id_dest>");
+ System.out.println("IoTInstaller: 10) Delete address, e.g. java iotinstaller.IoTInstaller -delete_add <ent_id> <ent_type>");
+ System.out.println("IoTInstaller: 11) Delete device address, e.g. java iotinstaller.IoTInstaller -delete_dev_add <ent_id> <ent_type>");
+ System.out.println("IoTInstaller: 12) Delete zigbee device address, e.g. java iotinstaller.IoTInstaller -delete_zb_add <ent_id> <ent_type>");
+ System.out.println("IoTInstaller: 13) Delete host, e.g. java iotinstaller.IoTInstaller -delete_host <host_address>");
System.out.println("IoTInstaller: Type 'java iotinstaller.IoTInstaller -help' to display this help.");
System.out.println();
}
helpTxt = helpTxt + "IoTInstaller: 6) Install zigbee device address, e.g. java iotinstaller.IoTInstaller -install_zb_add <filename>\n";
helpTxt = helpTxt + "IoTInstaller: 7) Install host, e.g. java iotinstaller.IoTInstaller -install_host <filename>\n";
helpTxt = helpTxt + "IoTInstaller: 8) Delete entity, e.g. java iotinstaller.IoTInstaller -delete_ent <ent_id> <ent_type> <ent_name>\n";
- helpTxt = helpTxt + "IoTInstaller: 9) Delete address, e.g. java iotinstaller.IoTInstaller -delete_add <ent_id>\n";
- helpTxt = helpTxt + "IoTInstaller: 10) Delete device address, e.g. java iotinstaller.IoTInstaller -delete_dev_add <ent_id>\n";
- helpTxt = helpTxt + "IoTInstaller: 11) Delete zigbee device address, e.g. java iotinstaller.IoTInstaller -delete_zb_add <ent_id>\n";
- helpTxt = helpTxt + "IoTInstaller: 12) Delete host, e.g. java iotinstaller.IoTInstaller -delete_host <host_address>\n";
+ helpTxt = helpTxt + "IoTInstaller: 9) Delete comm pattern, e.g. java iotinstaller.IoTInstaller -delete_comm <ent_id_source> <ent_id_dest>\n";
+ helpTxt = helpTxt + "IoTInstaller: 10) Delete address, e.g. java iotinstaller.IoTInstaller -delete_add <ent_id>\n";
+ helpTxt = helpTxt + "IoTInstaller: 11) Delete device address, e.g. java iotinstaller.IoTInstaller -delete_dev_add <ent_id>\n";
+ helpTxt = helpTxt + "IoTInstaller: 12) Delete zigbee device address, e.g. java iotinstaller.IoTInstaller -delete_zb_add <ent_id>\n";
+ helpTxt = helpTxt + "IoTInstaller: 13) Delete host, e.g. java iotinstaller.IoTInstaller -delete_host <host_address>\n";
helpTxt = helpTxt + "IoTInstaller: Type 'java iotinstaller.IoTInstaller -help' to display this help.\n";
helpTxt = helpTxt + "\n";
} else if (args[0].equals(STR_DELETE_ENTITY_CMD)) {
iotinst.deleteEntity(args[1], args[2], args[3]);
+ } else if (args[0].equals(STR_DELETE_COMMUNICATION_CMD)) {
+ iotinst.deleteComm(args[1], args[2]);
+
} else if (args[0].equals(STR_DELETE_ADDRESS_CMD)) {
iotinst.deleteAddress(STR_ADDRESS_TABLE_NAME, args[1], args[2]);