Blog do projektu Open Source JavaHotel

czwartek, 1 sierpnia 2013

MVP Jython framework and edit grid

Introduction
I added a new widget to my MVP framework. It is an "edit grid" which allows modification data in the list directly (like in this GWT showcase) but allowing adding and removing rows dynamically.

This widget can be used when a number of fields is relatively small (containable in one line) and line editing is more natural then standard CRUD editing. Google App Engine live demo version is available here. Detailed description here, also source code and Selenium unit tests.
Problem
The main problem I found was to detect "the end of edit single line". There is no any direct "finish" button. This action is necessary to perform data validation and store data in persistence layer (assuming that one line reflects one record). The only solution I found was to discover the end of line editing after moving to the another line. In this case editing of the next line is suspended for moment and actions related to the last line are executed. If data validation fails then user is forced to return to the previous line and fix the data.
From that stems another problem. When user wants to finish editing he simply clicks "Accept" (or any other) button without moving to the next line. So it was necessary also to provide a way to declare which buttons requires validation of the last line.
 There are two ways of making data persisted. One is to persist data after any action relating to data change (after single column or whole line) or store all lines at the end of editing (after pressing "Accept" button or any other). In this case it is necessary to transport all data from the client to the server side. In order to avoid unnecessary traffic there is a way to specify which buttons trigger data transportation and which buttons do not. When data persisting is done at the end of editing there is a risk of losing all data just entered in case of any failure.
Next steps
I plan to use this widget in the JavaHotel application is several cases. The first case will be manually changing list price for reservation and bypass prices provided from regular price list.

wtorek, 30 lipca 2013

Byliśmy na przedstawieniu

20 lipca byliśmy na przedstawieniu filmu operowego "Kopciuszek" wyświetlonego w ramach 13 edycji Festiwalu "Ogrody Muzyczne" na Zamku Królewskim w Warszawie, podobało nam się bardzo.
Opera Rossiniego jest pozbawiona elementów bajkowych w porównaniu do wersji baśni Charles Perraulta, nie ma tutaj czarów dobrej wróżki. Autorzy przedstawienia postanowili jednak przypomnieć baśniowy charakter w postaci pięknych animacji pojawiających się w przerwach miedzy aktami opery.
Samo przedstawienie jest częścią szerszego projektu mającego na celu nagrywanie oper w historycznych wnętrzach z pełnym użyciem nowoczesnej techniki, tutaj za scenę posłużyły zabytkowe budowle z Turynu.
Samo przedstawienie nie ma jednego bohatera czy wiodącego solisty, tutaj wszystkie elementy są tak samo ważne i stanowią istotny element całości.
Autorzy nie zamierzali intrygować widzów jakimś rewolucyjnym i nowatorskim odczytaniem dzieła operowego, a raczej odwrotnie. Za pomocą nowoczesnej techniki wydobyć i pokazać to co najpiękniejsze, czyli wspaniałe wnętrza, piękną muzykę i postacie wykonawców, którzy nie tylko śpiewają swoje role ale także z wielkim talentem je odgrywają.
To zamierzenie udało się z całą pewnością. Mimo  iż cały film trwa blisko trzy godziny, to śledzi się od początku do końca z niesłabnącą przyjemnością i zainteresowaniem.

poniedziałek, 29 lipca 2013

Selenium, python and Firefox 22

Problem
Selenium refuses to work with Firefox22 although it works properly with Firefox21. A lot of posts poured over internet. Example :
https://groups.google.com/forum/#!topic/selenium-users/1psXxdH-zS0
Although there is a fix available for Selenium 2.22 it seems not working for python users.
My solution
By I find a way to force Selenium to use Firefox21 without removing Firefox22.
  • Download and install somewhere Firefox21 (for instance /home/opt/firefox21/firefox)
  • Force selenium starter to use it by adding browserConfigurationOptions parameter to start method. 
selenium = selenium(host, port, browser, http)
selenium.start(("executablePath=/home/opt/firefox21/firefox"))

niedziela, 30 czerwca 2013

MVP Jython framework and dateline widget

Introduction
I added "dateline" (not confuse with "timeline") widget to MVP framework. The demo version is available here (click "Panel date" button at the bottom). Source code for whole solution is available here. Sample screen snapshot.
This widget can be used as a dashboard for hotel application where lines are rooms and columns are rooms availability on timeline (free, reserved, in use).
Technical description is available here.
Features

  1. Buttons for navigating though time line (go to date, next day, previous day etc).
  2. Declaration of some visual behavior: number of lines visible, number of date columns.
  3. Lines customization. Dynamically created list of lines and definition of columns visible.
  4. Cell (line/date) customization. Dynamic definition of cell visualization via custom html. For instance: different visualization for free rooms and reserved rooms.
  5. Customized logic for clicking on cell. Possible to define some business logic to clicking. For instance: after clicking on the cell open a windows to start reservation of the room.
  6. Sorting (lines values only).

Future enhancement

  • Partial refresh. Current version calls for refresh any time something has changed. Optimization is possible, for instance: in case of moving one day forward/backward refresh only one column. 
  • The same for lines, request data only for visible line.
  • More convenient way for moving in time.
  • Customized searching.


poniedziałek, 24 czerwca 2013

Glassfish 4.0 and Guice

Problem
I was using a mixture of EJB3 and Guice injection following method described here. The sample source code is available here.
Glassfish 3.1
It works without problem with Glassfish 3.1 giving the desired result
Glassfish 4.0
But deployment failed when I tried the same code to push into Glassfish 4.0.
deploy?DEFAULT=/home/hotel/NetBeansProjects/Container/TestApp/dist/gfdeploy/TestApp&name=TestApp&force=true failed on GlassFish Server (1) 
 Error occurred during deployment: Exception while loading the app : CDI deployment failure:WELD-001408 Unsatisfied dependencies for type [InjectedService] with qualifiers [@Default] at injection point [[BackedAnnotatedField] @Inject private com.test.myejb.TestSessionBean.iService]. Please see server.log for more details.

It looks that CDI implementation in Glassfish 4.0 is trying to resolve @Inject annotation on its own just ignoring the fact that it should be handled by @Interceptors annotation.

@Stateless
@Interceptors(value = { GuiceInterceptor.class })
@Local
public class TestSessionBean implements TestSessionBeanLocal {

    // Add business logic below. (Right-click in editor and choose
    // "Insert Code > Add Business Method"
    @Inject
    private InjectedService iService;
    
    
    @Override
    public String getHello() {
        return "Hello, I'm your test session bean";
    }

    @Override
    public String getMessageFromInjected() {
        return iService.helloFromInjected();
    }


}
Solution 
Solution was quite simple, just replace:
//import com.google.inject.Inject;
import com.google.inject.Inject;
Another remedy was adding empty bean.xml file to META-INF directory.
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://java.sun.com/xml/ns/javaee"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">

niedziela, 23 czerwca 2013

Byliśmy na koncercie

5 czerwca 2013 roku byliśmy na koncercie organowym w ramach XXIII Międzynarodowego Festiwalu Muzyki Sakralnej, bardzo nam się podobało.
Uczeń Franciszka Lista, Julius Reubke, zmarł młodo i zostawił po sobie niewiele kompozycji. Ale jednak z nich, Sonata "Psalm 94", jest jednym z najchętniej wykonywanych utworów organowych epoki Romantyzmu.
Franciszek List rzadko tworzył muzykę na organy, tylko dwa większe utwory zyskały sobie większą popularność. Jeden z nich, Fantasie und Fuge über den Choral „Ad nos, ad salutarem undam”, był w repertuarze koncertu.
Pomimo, że nazwisko Franciszek List dużo więcej dzisiaj mówi niż Julius Reubke, to jednak pierwszy utwór bardziej zapadał w pamięć. List zdecydowanie bardziej się podoba jako autor muzyki fortepianowej czy symfonicznej, niż organowej.
Solistą na koncercie był Giampaolo Di Rosa, na bis wykonał bardzo szybki i efektowny utwór, ale nie udało nam się rozpoznać co to było.
Bardzo miłą zaletą koncertu w Katedrze Polowej Wojska Polskiego był telebim umieszczony w prezbiterium, który dawał możliwość obserwacji solisty w trakcie koncertu. Nie wszyscy sobie zdają sprawę, że muzyka organowa wymaga także obsługi klawiatury nożnej. Intensywne wykorzystanie pedałów widać było wyraźnie w utworze Juliusa Reubke. Wadą koncertów organowych jest dystans dzielący wykonawcę od publiczności, ale dzięki nowoczesnej technice ten dystans udało się zniwelować.

wtorek, 4 czerwca 2013

Number grid and JavaHotel application

Information
I added grid number to the JavaHotel application.





















It is used to define a price list for services offered by hotel (launch, U/P user/user -> Price list).
Next step
Hotel rooms, list of customers and dashboard to reserve/book and present hotel status