use of SMExceptions.SMException in project SmartCity-Market by TechnionYP5777.
the class ManagePackagesTab method searchCodeButtonPressed.
@FXML
private void searchCodeButtonPressed(MouseEvent __) {
try {
LocalDate expirationDate = this.expirationDate != null ? this.expirationDate : datePickerForSmartCode.getValue();
if (expirationDate == null)
barcodeEntered(barcodeTextField.getText());
else
smartcodeEntered(new SmartCode(Long.parseLong(barcodeTextField.getText()), expirationDate));
this.expirationDate = expirationDate;
} catch (SMException e) {
log.fatal(e);
log.debug(StackTraceUtil.getStackTrace(e));
e.showInfoToUser();
return;
}
enableRunTheOperationButton();
}
use of SMExceptions.SMException in project SmartCity-Market by TechnionYP5777.
the class EmployeeLoginScreen method loginButtonPressed.
@FXML
private void loginButtonPressed(ActionEvent __) {
if (loginButton.isDisable())
return;
IManager employee = InjectionFactory.getInstance(Manager.class);
CLIENT_TYPE employeeType = null;
try {
employeeType = employee.login(userNameTextField.getText(), passwordField.getText(), true);
} catch (SMException e) {
log.fatal(e);
log.debug(StackTraceUtil.getStackTrace(e));
e.showInfoToUser();
return;
}
InjectionFactory.getInstance(EmployeeScreensParameterService.class).setClientType(employeeType);
AbstractApplicationScreen.setScene("/EmployeeMenuScreen/EmployeeMenuScreen.fxml");
}
use of SMExceptions.SMException in project SmartCity-Market by TechnionYP5777.
the class CustomerRegistration_FinalStepScreen method registerButtonPressed.
@FXML
void registerButtonPressed(ActionEvent __) {
ICustomer customer = InjectionFactory.getInstance(Customer.class);
ICustomerProfile iProfile = TempCustomerProfilePassingData.customerProfile;
CustomerProfile profile = new CustomerProfile(iProfile.getUserName(), TempCustomerProfilePassingData.password, iProfile.getFirstName(), iProfile.getLastName(), iProfile.getPhoneNumber(), iProfile.getEmailAddress(), iProfile.getCity(), iProfile.getStreet(), iProfile.getBirthdate(), iProfile.getAllergens(), new ForgotPasswordData(TempCustomerProfilePassingData.sequrityQuestion, TempCustomerProfilePassingData.sequrityAnswer));
try {
customer.registerNewCustomer(profile);
AbstractApplicationScreen.setScene("/CustomerLoginScreen/CustomerLoginScreen.fxml");
TempCustomerProfilePassingData.clear();
} catch (SMException e) {
log.fatal(e);
log.debug(StackTraceUtil.getStackTrace(e));
e.showInfoToUser();
}
}
use of SMExceptions.SMException in project SmartCity-Market by TechnionYP5777.
the class CustomerApplicationScreen method start.
@Override
public void start(Stage primaryStage) {
try {
stage = primaryStage;
InjectionFactory.createInjector(new CustomerDiConfigurator());
barcodeEventHandler = InjectionFactory.getInstance(BarcodeEventHandler.class);
barcodeEventHandler.initializeHandler();
barcodeEventHandler.startListening();
setScene("/CustomerWelcomeScreen/CustomerWelcomeScreen.fxml");
stage.setTitle("Smart Market Beta");
stage.setMaximized(true);
stage.setOnCloseRequest(event -> {
try {
ICustomer customer = InjectionFactory.getInstance(Customer.class);
customer.logout();
Platform.exit();
System.exit(0);
} catch (SMException e) {
log.fatal(e);
log.debug(StackTraceUtil.getStackTrace(e));
e.showInfoToUser();
Platform.exit();
System.exit(0);
}
});
stage.show();
} catch (Exception ยข) {
throw new RuntimeException();
}
}
use of SMExceptions.SMException in project SmartCity-Market by TechnionYP5777.
the class Packing method unpack.
public static void unpack(ZipFile zfile, String unpackPath) throws SMException {
if (zfile == null || unpackPath == null || unpackPath.isEmpty()) {
log.fatal("unpacking failed due to invalid parameter.");
throw new PackUnpackException();
}
File unpackDir;
try {
unpackDir = new File(unpackPath);
} catch (Exception e) {
log.error(e + "");
throw new PackUnpackException();
}
if (!unpackDir.isDirectory()) {
log.error("Unpacking failed: Unpack path must be a directory");
throw new PackUnpackException();
}
try {
BufferedOutputStream dest = null;
BufferedInputStream is = null;
ZipEntry entry;
for (Enumeration<? extends ZipEntry> e = zfile.entries(); e.hasMoreElements(); ) {
entry = e.nextElement();
log.debug("Extracting: " + entry);
is = new BufferedInputStream(zfile.getInputStream(entry));
int count;
byte[] data = new byte[bufferSize];
FileOutputStream fos = new FileOutputStream(unpackDir.getAbsolutePath() + '/' + entry.getName());
dest = new BufferedOutputStream(fos, bufferSize);
while ((count = is.read(data, 0, bufferSize)) != -1) dest.write(data, 0, count);
dest.flush();
dest.close();
is.close();
}
} catch (Exception e) {
log.error(e + "");
log.error("Failed extracting zipfile " + zfile + " into " + unpackDir.getAbsolutePath());
}
}
Aggregations