Search in sources :

Example 1 with UserInformation

use of il.ac.technion.cs.smarthouse.system.user_information.UserInformation in project Smartcity-Smarthouse by TechnionYP5777.

the class AlertsManager method sendAlert.

/**
     * Report an abnormality in the expected schedule. The system will contact
     * the needed personal, according to the urgency level
     * 
     * @param message
     *            Specify the abnormality, will be presented to the contacted
     *            personal
     * @param eLevel
     *            The level of personnel needed in the situation
     */
public final void sendAlert(final String message, final EmergencyLevel eLevel) {
    final UserInformation user = systemCore.getUser();
    if (user == null) {
        log.debug("systemCore.getUser() returned a null");
        return;
    }
    final PhoneService ps = (PhoneService) getAnotherService(ServiceType.PHONE_SERVICE);
    final SmsService ss = (SmsService) getAnotherService(ServiceType.SMS_SERVICE);
    final EmailService es = (EmailService) getAnotherService(ServiceType.EMAIL_SERVICE);
    final List<Contact> $ = user.getContacts(eLevel);
    switch(eLevel) {
        case SMS_EMERGENCY_CONTACT:
            $.stream().forEach(c -> ss.sendMsg(c.getPhoneNumber(), message));
            break;
        case CALL_EMERGENCY_CONTACT:
        case CONTACT_HOSPITAL:
        case CONTACT_POLICE:
        case CONTACT_FIRE_FIGHTERS:
            $.stream().forEach(c -> ps.makeCall(c.getPhoneNumber()));
            break;
        case EMAIL_EMERGENCY_CONTACT:
            $.stream().forEach(c -> es.sendMsg(c.getEmailAddress(), message));
            break;
        default:
            log.warn(eLevel + " is not handled");
    }
}
Also used : UserInformation(il.ac.technion.cs.smarthouse.system.user_information.UserInformation) PhoneService(il.ac.technion.cs.smarthouse.system.services.communication_services.PhoneService) SmsService(il.ac.technion.cs.smarthouse.system.services.communication_services.SmsService) EmailService(il.ac.technion.cs.smarthouse.system.services.communication_services.EmailService) Contact(il.ac.technion.cs.smarthouse.system.user_information.Contact)

Example 2 with UserInformation

use of il.ac.technion.cs.smarthouse.system.user_information.UserInformation in project Smartcity-Smarthouse by TechnionYP5777.

the class SystemCore method initializeUser.

public void initializeUser(final String name, final String id, final String phoneNumber, final String homeAddress) {
    user = new UserInformation(name, id, phoneNumber, homeAddress);
    userInitialized = true;
}
Also used : UserInformation(il.ac.technion.cs.smarthouse.system.user_information.UserInformation)

Example 3 with UserInformation

use of il.ac.technion.cs.smarthouse.system.user_information.UserInformation in project Smartcity-Smarthouse by TechnionYP5777.

the class UserInfoController method setButtons.

private void setButtons() {
    userSaveField.setOnAction(event -> {
        final String name = userNameField.getText(), id = userIDField.getText(), phoneNum = userPhoneNumField.getText(), address = userHomeAddressField.getText();
        if (!validateUserInput(name, id, phoneNum, address))
            alertMessageUnvalidInput();
        else if (getModel().isUserInitialized()) {
            final UserInformation temp = getModel().getUser();
            temp.setHomeAddress(address);
            temp.setPhoneNumber(phoneNum);
        } else {
            getModel().initializeUser(name, id, phoneNum, address);
            userNameField.setEditable(false);
            userIDField.setEditable(false);
        }
    });
    saveButton.setOnAction(event -> {
        if (getModel().isUserInitialized())
            if (validateUserInput(addNameField.getText(), addIDField.getText(), addPhoneField.getText(), addEmailField.getText()))
                addContactToTable(event);
            else
                alertMessageUnvalidInput();
        else {
            final Alert alert = new Alert(AlertType.ERROR);
            alert.setTitle("Error Dialog");
            alert.setHeaderText("User Not Registered");
            alert.setContentText("Make sure to register the user before adding any contacts");
            alert.showAndWait();
        }
    });
}
Also used : UserInformation(il.ac.technion.cs.smarthouse.system.user_information.UserInformation) Alert(javafx.scene.control.Alert)

Aggregations

UserInformation (il.ac.technion.cs.smarthouse.system.user_information.UserInformation)3 EmailService (il.ac.technion.cs.smarthouse.system.services.communication_services.EmailService)1 PhoneService (il.ac.technion.cs.smarthouse.system.services.communication_services.PhoneService)1 SmsService (il.ac.technion.cs.smarthouse.system.services.communication_services.SmsService)1 Contact (il.ac.technion.cs.smarthouse.system.user_information.Contact)1 Alert (javafx.scene.control.Alert)1