Search in sources :

Example 1 with SMException

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();
}
Also used : SmartCode(BasicCommonClasses.SmartCode) SMException(SMExceptions.SMException) LocalDate(java.time.LocalDate) FXML(javafx.fxml.FXML)

Example 2 with SMException

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");
}
Also used : CLIENT_TYPE(CommonDefs.CLIENT_TYPE) IManager(EmployeeContracts.IManager) EmployeeScreensParameterService(EmployeeCommon.EmployeeScreensParameterService) SMException(SMExceptions.SMException) FXML(javafx.fxml.FXML)

Example 3 with SMException

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();
    }
}
Also used : ICustomer(CustomerContracts.ICustomer) ForgotPasswordData(BasicCommonClasses.ForgotPasswordData) ICustomerProfile(BasicCommonClasses.ICustomerProfile) ICustomerProfile(BasicCommonClasses.ICustomerProfile) CustomerProfile(BasicCommonClasses.CustomerProfile) SMException(SMExceptions.SMException) FXML(javafx.fxml.FXML)

Example 4 with SMException

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();
    }
}
Also used : BarcodeEventHandler(UtilsImplementations.BarcodeEventHandler) CustomerDiConfigurator(CustomerDI.CustomerDiConfigurator) ICustomer(CustomerContracts.ICustomer) SMException(SMExceptions.SMException) SMException(SMExceptions.SMException)

Example 5 with SMException

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());
    }
}
Also used : BufferedInputStream(java.io.BufferedInputStream) FileOutputStream(java.io.FileOutputStream) PackUnpackException(SMExceptions.PackUnpackException) File(java.io.File) BufferedOutputStream(java.io.BufferedOutputStream) PackUnpackException(SMExceptions.PackUnpackException) SMException(SMExceptions.SMException)

Aggregations

SMException (SMExceptions.SMException)12 FXML (javafx.fxml.FXML)7 ICustomer (CustomerContracts.ICustomer)5 SmartCode (BasicCommonClasses.SmartCode)3 BarcodeEventHandler (UtilsImplementations.BarcodeEventHandler)2 CartProduct (BasicCommonClasses.CartProduct)1 CatalogProduct (BasicCommonClasses.CatalogProduct)1 CustomerProfile (BasicCommonClasses.CustomerProfile)1 ForgotPasswordData (BasicCommonClasses.ForgotPasswordData)1 ICustomerProfile (BasicCommonClasses.ICustomerProfile)1 Ingredient (BasicCommonClasses.Ingredient)1 Location (BasicCommonClasses.Location)1 ProductPackage (BasicCommonClasses.ProductPackage)1 CommonDiConfigurator (CommonDI.CommonDiConfigurator)1 CLIENT_TYPE (CommonDefs.CLIENT_TYPE)1 CustomerDiConfigurator (CustomerDI.CustomerDiConfigurator)1 EmployeeScreensParameterService (EmployeeCommon.EmployeeScreensParameterService)1 IEmployeeScreensParameterService (EmployeeCommon.IEmployeeScreensParameterService)1 IManager (EmployeeContracts.IManager)1 IWorker (EmployeeContracts.IWorker)1