use of java.time.LocalDate in project SmartCity-Market by TechnionYP5777.
the class UpdateProductPicturesEmployeeTest method updateIsNeededTest.
@Test
public void updateIsNeededTest() {
try {
LocalDate currentPicturesDate = PictureManager.getCurrentDate();
Mockito.when(clientRequestHandler.sendRequestWithRespond((new CommandWrapper(w.getClientId(), CommandDescriptor.UPDATE_PRODUCTS_PICTURES, Serialization.serialize(currentPicturesDate))).serialize())).thenReturn(new CommandWrapper(ResultDescriptor.SM_OK, Serialization.serialize(encodedZipFile4Testing)).serialize());
} catch (IOException ยข) {
fail();
}
try {
updateProductPicturesThread.start();
updateProductPicturesThread.join();
} catch (Exception e) {
System.out.println(e + "");
fail();
}
}
use of java.time.LocalDate in project SmartCity-Market by TechnionYP5777.
the class PictureManager method checkIfMostUpdate.
public static boolean checkIfMostUpdate(LocalDate d) throws IOException {
ObjectInputStream objectinputstream = null;
LocalDate updatedDate = null;
try {
FileInputStream streamIn = new FileInputStream(GuiCommonDefs.productsPicturesPathLastUpdate);
objectinputstream = new ObjectInputStream(streamIn);
updatedDate = (LocalDate) objectinputstream.readObject();
} catch (Exception e) {
throw new IOException();
} finally {
if (objectinputstream != null)
objectinputstream.close();
}
return updatedDate != null && d.compareTo(updatedDate) >= 0;
}
use of java.time.LocalDate in project SmartCity-Market by TechnionYP5777.
the class PictureManager method getCurrentDate.
public static LocalDate getCurrentDate() throws IOException {
ObjectInputStream objectinputstream = null;
LocalDate updatedDate = null;
try {
FileInputStream streamIn = new FileInputStream(GuiCommonDefs.productsPicturesPathLastUpdate);
objectinputstream = new ObjectInputStream(streamIn);
updatedDate = (LocalDate) objectinputstream.readObject();
} catch (Exception e) {
throw new IOException();
} finally {
if (objectinputstream != null)
objectinputstream.close();
}
return updatedDate;
}
use of java.time.LocalDate in project SmartCity-Market by TechnionYP5777.
the class SQLJsonGenerator method CostumerProfileToJson.
/**
* convert customerProfile from ResultSet to Json representation of product
*
* @param customer
* - ResultSet of the customer profile. the
* ResultSet need to point to the username to convert). this
* object will point the next product after returning.
* @param customerIngredients
* - ResultSet of the customer\s ingredients (assuming the
* ResultSet ordered by username column) the ResultSet should
* pointing the product to convert, if it has ingredients. if so,
* this object will point the next customer (or after last line) after returning.
* @return
* @throws CriticalError
*/
static String CostumerProfileToJson(ResultSet customer, ResultSet customerIngredients) throws CriticalError {
HashSet<Ingredient> ingredients;
try {
//get customer username
String customerUsername = getStringFromResultset(customer, CustomersTable.customerusernameCol);
// get all customer ingredients
ingredients = createIngredientsListForCustomer(customerUsername, customerIngredients);
String customeraddress = getStringFromResultset(customer, CustomersTable.customerAddressCol), customerCity = getStringFromResultset(customer, CustomersTable.customerCityCol), customerEmail = getStringFromResultset(customer, CustomersTable.customerEmailCol), customerFirstname = getStringFromResultset(customer, CustomersTable.customerFirstnameCol), customerLastname = getStringFromResultset(customer, CustomersTable.customerLastnameCol), customerPhonenumber = getStringFromResultset(customer, CustomersTable.customerPhonenumberCol);
LocalDate customerBirthdate = customer.getDate(CustomersTable.customerBirthdateCol.getColumnNameSQL()).toLocalDate();
customer.next();
return Serialization.serialize(new CustomerProfile(customerUsername, null, customerFirstname, customerLastname, customerPhonenumber, customerEmail, customerCity, customeraddress, customerBirthdate, ingredients, null));
} catch (SQLException e) {
throw new SQLDatabaseException.CriticalError();
}
}
use of java.time.LocalDate 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();
}
Aggregations