Blog do projektu Open Source JavaHotel

niedziela, 20 lipca 2014

New version of JavaHotel application

Description
I uploaded a new version of JavaHotel application. It is available here (U/P user/user), source code is available here. The main change is adding some charts reflecting hotel room occupancy. it is the first, draft version, visualization of different hotel activities will be elaborated more.
The charts are available: (upper menu) -> Administrator -> List of rooms -> Info (right column)
Next step
Reservation confirmation by e-mail

sobota, 19 lipca 2014

Byliśmy na koncercie

18 czerwca 2014 roku byliśmy na koncercie w ramach XXIV Festiwalu Mozartowskiego organizowanym przez Warszawską Operę Kameralną. Koncert odbył się w surowym wnętrzu warszawskiego Kościoła Ewangelicko-Reformowanego, zaś głównym punktem koncertu były tzw. Sonaty kościelne Wolfganga Amadeusza Mozarta. Podobało nam się bardzo, gdyż to muzyka bardzo ładna, ale w Polsce rzadko wykonywana, jakby przytłoczona przez inne, bardziej popularne dzieła Mozarta.
Sonaty kościelne Mozarta nawiązują do dawnej tradycji wykonywania krótkich utworów instrumentalnych w przerwach między czytaniami podczas odprawiania Mszy Świętej. Jest to muzyka na niewielki zespół instrumentów oraz organy. Nie mogą to być utwory zbyt lekkie ze względu na powagę uroczystości ani zbyt ciężkie, aby nie odciągały uwagi słuchaczu od głównego celu obrzędu. W Salzburgu Mozart napisał 17 takich sonat w latach 1772-1780. Krótko po wyjeździe Mozarta z Salzburga sonaty przestały być tam wykonywane jako część nabożeństwa liturgicznego, ale zaczęły drugie życie jako muzyka kameralna.
Wykonawcą podczas koncertu w Kościole Ewangelicko-Refomowanym był zespół muzyków z Warszawskiej Opery Kameralnej. Trochę było szkoda, że podczas wykonywania Sonat organy zostały zastąpione przez pozytyw, stały za tym zapewne trudności wykonawcze.  Może wyjściem byłoby przeniesieniu instrumentalistów z prezbiterium do chóru i wyznaczenie słuchaczom miejsce na bocznych antresolach ? Ale wykonanie ogromnie się podobało, muzycy jako bis powtórzyli jeden z utworów. Jest bardzo miłą tradycją, że w ramach Festiwalu Mozartowskiego w Warszawie przypominany jest także mniej znany repertuar Mozarta.

niedziela, 6 lipca 2014

MVP Jython framwork and visualization

Introduction
I added visualization diagramss to the framework. The brief description is available here and the sample application is available here ('Charts' submenu). Adding visualization to the application is very simple: just add chart tag to the dialog xml specification and enhance Jython backing code to set sequence with proper names and numbers.
To implement visualization I used GWT wrapper around Google Charts. For the time being only basic charts are implemented: Pie Chart, Area Chart, Bar Chart, Column Chart, Line Chart and Scatter Chart. Also a subset of available option is implemented. It will be enhanced gradually.
Pie Chart
Pie Chart is a circular chart divided into sectors illustrating proportion between different data category.
In sample application it is possinle dynamically modify the numbers and texts (also adding new ones and removing existing) to see the effect.
XML definition for this chart and Jython backing code.
Scatter Chart
Scatter chart simply plots points using Cartesian coordinates.
 Another example of scatter chart.

It is possible dynamically change the data for this charts and see the effect.
XML definition : plot and circle.
Jython backing code: plot and circle.
Bar, Column, Area and Line Charts
These charts are very similar to each other. They use horizontal (or vertical) axis for names and another axis for numbers and illustrates proportion between different categories.
XML definition for charts.
Jython backing code for charts.
Next step
Add visualization to JavaHotel application

środa, 2 lipca 2014

MS SQL, SP and Python

Introduction
MS SQL allows exporting database objects into sql script file (for instance: stored procedures with the body). ( Database -> Tasks->Generate Scripts) This option allows creating one single script file for all objects exported or separate file for every object.
But what to do if we have one single file with all stored procedures without an access to MS SQL. Or if we want pure SP body not enriched by additional stuff created by "Generate Scripts".
Sometimes we have two versions of the script file (earlier and later) and want to compare what was developed in the meantime. It is much easier to compare having every SP in different file, we can use a standard comparing software (like Meld).
Facing this problem I created a simple Python script which extracts all SP from a single script file and put them into separate files.
Python code - Extract class
'''
Created on 2 lip 2014

@author: sbartkowski
'''

import logging
import os
import shutil

LOGNAME="EXTRACT"

_L = logging.getLogger(LOGNAME)

_CREATE="CREATE"
_PROCEDURE="PROCEDURE"
_GO="GO"

class EXTRACT() :
    '''
    Extracts SP from single export file. Every SP extracted is placed in a separate file.
    It is assumed that the body of the SP is enclosed by CREATE PROCEDURE and GO statements.
    The file naming convention is : schema_SP name.sql
    Example: 
       CREATE PROCEDURE [sales].[SelectUnsold] 
       ....
       GO
       file name: sales_SelectUnsold.sql
    The output directory is created or cleaned if exists   
       
    Attributes:
      infile : the name of the input file containg a bunch of SP
      outdir : output directory
      f : 'file' object' opened as 'infile'        
    '''


    def __init__(self, infile,outdir):
        '''
        Constructor
          Args:
            infile : input file
            outdir : output directory
        '''
        self.infile = infile
        self.outdir = outdir
        self.f = None
        
    def _isProc(self,l):
        '''
        Test if the line contains CREATE PROCEDURE
        Args:
          l : source line
        Returns: 
          True : if CREATE PROCEDURE
          False: otherwise  
        '''
        tokens = l.split()
        if len(tokens) < 3 : return None
        if tokens[0].upper() != _CREATE or tokens[1].upper() != _PROCEDURE : return None
        return tokens[2]
     
    def _isClosingGo(self,l):
        '''
          Test if the line contains GO statement (denoting the end of SP)
          Args:
           l : source line
          Returns:
          True: line with GO
          False: otherwise         
        '''
        
                    
        tokens = l.upper().split()
        if len(tokens) != 1 : return False
        return tokens[0] == _GO
    
    def _outFileName(self,procName) :
        '''
          Constructs the name of the output file related to the SP name
          Args:
            SP name in shape of [schema name].[proc name]
          Returns:
            The output file name (without path)   
        '''
        pName = procName.replace("[","").replace("]","").replace(".","_")
        outFileName = os.path.join(self.outdir,pName) + ".sql"
        return outFileName
   
    def _writeFile(self,fileName,listofl):
        '''
          Flushes the body of the SP to the output file
          Args:
            fileName : the name of the output file
            listofl : the list of lines with SP body          
        '''
        f = open(fileName,"w")
        f.writelines(listofl)
        f.close()          
        
    def run(self):
        '''
          The main method, bounding them all          
        '''
#        print self.infile, self.outdir
        _L.info("Start executing")
        _L.info("Source : "  + self.infile)
        _L.info("Output dir :" + self.outdir)
        if os.path.exists(self.outdir):
            _L.info("Removing content of " + self.outdir)
            shutil.rmtree(self.outdir)         
        _L.info("Creating directory " + self.outdir)
        os.mkdir(self.outdir)
        _L.info("Opening source file")
        self.f = open(self.infile, 'r')
        _L.info("Success, opened")
        listofl = None
        procName = None
        noprocs = 0
        nolines = 0
        # read line by line
        for l in self.f :
            if listofl == None :
                procName = self._isProc(l)
                if procName : 
                    _L.info(procName)
                    listofl = [l,]
                    noprocs = noprocs + 1
                continue
            else :
                listofl.append(l)
                if self._isClosingGo(l) :
                    _L.info("End of " + procName + " found")
                    outfileName = self._outFileName(procName)
                    nolines = nolines + len(listofl)
                    _L.info("Creating " + outfileName + " lines:" + str(len(listofl)))
                    self._writeFile(outfileName,listofl)                    
                    listofl = None
                    
        _L.info("Closing source file")
        _L.info(str(noprocs) + " SP extracted with " + str(nolines) + " lines of code")
        
        self.f.close()    

Python code -  main
Below is an example of usage of this files. It reads two scripts file containing SP and put them into two directories, "old" and "new"
'''
Created on 2 lip 2014

@author: sbartkowski
'''
import logging

from extr import extr

def setLogger():
    logger = logging.getLogger(extr.LOGNAME)
    logger.setLevel(logging.INFO)
    ch = logging.StreamHandler()
    ch.setLevel(logging.INFO)
#formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
#ch.setFormatter(formatter)
    logger.addHandler(ch)


INDIR1="/home/sbartkowski/Dokumenty/db2/SP/2014-03-22"
INDIR2="/home/sbartkowski/Dokumenty/db2/SP/2014-06-22"

OUTDIR1="/home/sbartkowski/Dokumenty/db2/SP/old"
OUTDIR2="/home/sbartkowski/Dokumenty/db2/SP/new"

INFILE="SP.sql"

def main() :
    setLogger()
    E = extr.EXTRACT(INDIR1+INFILE,OUTDIR1)
    E.run()
    E = extr.EXTRACT(INDIR2+INFILE,OUTDIR2)
    E.run()
    

if __name__ == '__main__':
    main()

niedziela, 29 czerwca 2014

JavaHotel, new version

Introduction
I deployed next version of JavaHotel application. Demo version (Google App Engine) is available here (U/P user/user) and source code here.
Searching
I added a searching (so far new reservation was activated after clicking in the hotel room/day cell).
After clicking "Search" button a list of hotel rooms available is displayed :
and the user can select a room and a reservation can be started.
Reservation extension
After reservation is booked it is possible to extend it by adding another room to the reservation or extend the reservation period for the room already booked.  This option is available after clicking "Extend reservation" button.
 It is the same searching mechanism as above but after clicking "Add to reservation" button the room selected is added to the existing reservation.
Reservation modification
Also more detailed modification of existing reservation is possible after clicking "Modify reservation" button.

The user can modify reservation for the single day/room line, remove one line from the reservation and add a new line.
Customer/guest info
This option is available through "Upper menu" -> "Administrator" -> "List of customers" -> "Info".
This window shows the activity of the particular customer.
Room/service info
"Upper menu" -> "Administrator" -> "Services" -> "Modify" -> "Show rooms"
List of hotel rooms sharing this service.
Additional changes
  • Modifying list of guests (checked in) also during a stay.
  • "Administrator" - blockage for removal objects (rooms, customers, services, price list) if there exists any dependent object (for instance: cannot remove a hotel room if there is exist a reservation for this room). Future: add option "out of use" or "deactivate" the object.
  • "Spinner" widget (look above) to make user interface more user friendly.
Next step
Implements charts (I'm going to use Google Charts ) to visualize room, service or customer activity.

piątek, 20 czerwca 2014

MVP Jython framework, new enhancements

Introduction
I added several enhancement to MVP Jython framework. Sample application is available here, source code here.
URL parameters
Access to URL parameters in the Jython backing code. It allows passing some additional parameters to the application.  Description is available here. In the sample application : Different lists -> URL params.
Additional standard toolbars for list
It is the small enhancement but allows to avoid repeating the same sequence of buttons. Description is available here.
Application parameters
This enhancement allows injecting some application parameters into the dialog definition. Description is available here.
Spinner widget
Spinner widget allows entering integer values without typing keyboard. It is convenient method if the range limit is not very big. Sample application : Status -> Spinner and Status -> List with spinner. For dialog form spinner range values can be modified dynamically. Description is available here.
JavaScript backing method
JavaScript function can be defined as a response action. Because JavaScript is executed at the client side and it makes user interface more agile. Defining JavaScript response action is possible only if server side action (for instance database querying) is not required. Sample application : Alert -> Dialog with JS. Description is available here.

środa, 18 czerwca 2014

Byliśmy na operze

W dniu 24 maja 2014 byliśmy w Warszawskiej Operze Kameralnej na przedstawieniu "Napój miłosny" Gaetano Donizettiego, podobało nam się bardzo, chociaż nie wszystkim byliśmy zachwyceni.
"Napój miłosny" to jedno z najbardziej znanych dzieł Donizetttiego, stało się sukcesem niemal od pierwszego wystawienia i po dziś dzień jest jednym z najbardziej popularnych i najchętniej wystawianych dzieł z operowego repertuaru.
"Napó̉j miłosny" jest obecny  w repertuarze Warszawskiej Opery Kameralne od wielu lat, całe przedstawienie jest bardzo dobrze przygotowane i zaśpiewane. Czasami się tylko wydawało, ze głosy śpiewaków rozsadzają skromną scenę teatru. Znakomicie się zaprezentowała młoda śpiewaczka, Agnieszka Kozłowska w roli Aldiny, bardzo dobrze jej partnerowali pozostali soliści.
Natomiast nie spodobała się scenografia. Scenę, oprócz solistów, ożywiają mimowie ubrani w stroje z włoskiej komediu dell'arte, na scenie widzimy postacie przypominające Arlekina i Kolombinę. Mimowie gestami i ruchami podkreślają rozwój akcji, czasami biorąc w niej aktywny udział. Bardzo dobrze się to sprawdza w początkowej scenie, gdy Adina głośno opowiada przeczytaną historię Tristana i Izoldy i mimowie na drugim planie odgrywają tę scenę. Ale taka konwencja nadaje całemu przedstawieniu wyraz ogromnej sztuczności, umowności. "Napój" to przecież historia wielkiej miłości biednego, niepiśmiennego i nieśmiałego wieśniaka Nemorina do bogatej i kapryśnej dziedziczki Adiny. Z pozoru wszystko przemawia przeciwko Nemorinowi, ale jego uczucie jest tak gorące i szczere, że "doktor" oszust Dulcamara przemienia się w prawdziwego cudotwórcę, fałszywa mikstura staje się magicznym napojem, sierżant Belcore, istny bóg wojny Mars któremu pada w ramiona nawet bogini miłości Wenus, poddaje się i rejteruje, sam Nemorino dziedziczy majątek i na końcu zdobywa uczucie pięknej Adiny. Rzeczy fałszywe i niemożliwe stają się prawdziwe i osiągalne.
Jest to historia bajkowa, ale przecież nie baśniowa, nierealistyczna, i to właśnie trochę zgrzyta ze scenografią.
Od premiery tej opery w Warszawskiej Operze Kameralnej minęło już 7 lat, może czas najwyższy aby odświeżyć sceniczną koncepcję przedstawienia i dać lepszą oprawę do wspaniałej gry solistów.