BLOG SPOSTATO
CIao,
il Blog di MYTI si è spostato su www.myti.it/blog
sheepfilms
The Bowery Presents
almost home
RMH

Jar Jar Binks Fan Club
No title available
Xuebing Du

roma★
NASA
Today's Document

blake kathryn
Color Me Curious

No title available
Monterey Bay Aquarium
PUT YOUR BEARD IN MY MOUTH

Origami Around
Sade Olutola
todays bird
Not today Justin

pixel skylines
seen from Bangladesh
seen from Netherlands

seen from United Kingdom
seen from Iraq
seen from United States
seen from United Kingdom

seen from Sweden
seen from United States
seen from Vietnam
seen from Portugal
seen from United States
seen from Kuwait
seen from Malaysia
seen from Brazil

seen from Sweden
seen from Indonesia

seen from Türkiye
seen from United States
seen from United States
seen from Indonesia
@myti-blog
BLOG SPOSTATO
CIao,
il Blog di MYTI si è spostato su www.myti.it/blog
PENTAHO DATA INTEGRATION (KETTLE): Connessioni dinamiche al DB attraverso gli Shared Objects
In Kettle esiste una funzionalità, ben nascosta a dire la verità, che permette di sostituire tutti i parametri di una connessione esistente, sia quelli normalmente parametrizzabili nel corso dell'ETL sia quelli non parametrizzabili.
Prestando attenzione al dialetto del motore, è possibile creare job e trasformazioni in cui anche il tipo di database sia parametrico.
Come si può fare?
Innanzitutto, è importante ricordare che la priorità di lettura delle connessioni è la seguente:
1) repository
2) file shared.xml
3) trasformazione
Per cui, per sfruttare la sovrascrittura delle connessioni da uno shared object, non si può lavorare in un repository.
Cliccando prima con il tasto destro del mouse sulla connessione che ci interessa (in questo esempio è una connessione a un SQL Server ed è chiamata "connessione") e poi su Share, Kettle crea un file shared.xml nella cartella predefinita dal parametro KETTLE_SHARED_OBJECTS (si veda il file kettle.properties).
Questo file contiene tutti i dettagli di "connessione".
Rinominiamo quindi il file shared.xml appena creato in shared_sqlserver.xml. Possiamo ripetere questi passaggi, creando tanti xml quanti sono i motori di database che ci interessano, e rinominandone ognuno di conseguenza.
Ora possiamo creare una trasformazione di test, definire una connessione a un qualsiasi motore che non sia SQL Server, e salvarla come "connessione". E' fondamentale che nei job e nelle trasformazioni del nostro ETL la connessione abbia lo stesso nome di quella con cui intendiamo sostituirla..
A questo punto apriamo le Transformation Properties, e in Miscellaneous impostiamo "Shared Objects File" come ${SHARED_CONNECTION}.
Ora lanciamo la trasformazione, e valorizziamo (per comodità, a mano) la variabile SHARED_CONNECTION come shared_sqlserver.xml.
Una volta terminata la trasformazione, se apriamo la connessione "input", vediamo che la connessione che abbiamo creato è stata sovrascritta dalla connessione al SQL Server memorizzata nel file shared_sqlserver.xml.
Questo approccio è efficace nel caso in cui si debba progettare un ETL adatto al deploy in una serie di ambienti in cui non sia nota, al momento dello sviluppo, la tecnologia dei database che verranno utilizzati in produzione.
E' possibile così creare un ETL fortemente parametrizzato, che possa generare un datawarehouse su un motore "generico", e in cui la fase di configurazione sia minima.
Fiera Affidabilità e Tecnologie
Siamo alla fiera Affidabilità e Tecnologie
ll salone specialistico dell’Innovazione:Tecnologie, Soluzioni, Strumenti e Servizi
Lingotto Fiere 18-19 Aprile stand G35
Vai al sito
Automatically show the content of a specific Lotus notes mail
REQUIREMENTS
The IMAP id of the Gmail email to be open
Lotus notes needs to be installed in the client machine and you need to know the path of the executable
Install and configure the Domingo API for Lotus notes see
Basic knowledge of Java Programming
CODE
The program consist of two main classes
DBService – this class creates a connection to the Lotus Notes database using the Domingo API. Il contains a method getDDocuments(String gmailImapID) that searches the Lotus Notes database for the Lotus Notes document using the gmailIMapID.
DBService class
package it.myti.lotusNotes.integrator.db; import java.util.Iterator; import de.bea.domingo.DBaseItem; import de.bea.domingo.DDatabase; import de.bea.domingo.DDocument; import de.bea.domingo.DNotesException; import de.bea.domingo.DNotesFactory; import de.bea.domingo.DSession; public class DBService { private DDatabase database = null; private DNotesFactory factory = DNotesFactory.getInstance(); private DSession session = factory.getSession(); public DBService() { try { database = session.getMailDatabase(); } catch (DNotesException e) { e.printStackTrace(); } } public DDatabase getDatabase() { return database; } public DDocument getDDocument(String gmailImapID) { DDocument document = null; if( database != null) { Iterator docs = database.search("$MessageID = \"" + gmailImapID + "\"") ; while( docs.hasNext()) { document = (DDocument)docs.next(); break; } }else { System.out.println("Error: cannot connect to lotus database"); } return document; }
DomingoMain – This class contains the Java main method. In this class, I invoked the method getDDocument(gmailImapID) on the DBService db object to get the Lotus Notes document passing the gmailIMapID of the Lotus Notes to be opened. Then I launched the Lotus Notes program using the method Runtime.getRuntime().exec(execString). Where
execString = Lotus Notes executable path + space + Lotus Notes Universal Unique ID
as can be seen in the screenshot below.
DomingoMain class
package it.myti.lotusNotes.integrator.core; import java.io.IOException; import de.bea.domingo.DDocument; import it.myti.lotusNotes.integrator.db.DBService; public class DomingoMain { public static void main(String[] args) { //search by Gmail IMAP ID String gmailImapID= ""; //Path to the Lotus Notes executable String path = "C:\\Program Files\\IBM\\Lotus\\Notes\\notes.exe"; DBService db = new DBService(); DDocument document = db.getDDocument(gmailImapID); String exeString = path + " " + document.getURL(); if(document != null ) { try { Runtime.getRuntime().exec( exeString ); } catch (IOException e) { e.printStackTrace(); } }else { System.out.println("Error: Lotus Notes document non found."); } } }
RESULT
La presentazione "NFC Programming in Android" che è stata presentata 24 Novembre 2011 nell'incontro di GTUG (Google Technology User Group) Milano.
Liferay: Disable the IE Compatibility View
If Internet Explorer detects that a web page is not compatible, the address bar displays the Compatibility View button. When you turn on Compatibility View, the Web site open appears as if you were using an earlier version of Internet Explorer. However, this is an emulation of an earlier version of Explorer, which creates additional display problems when compared with other browsers like Firefox and Chrome. The solution to this problem is to disable the choice (sometimes automatic) browser by entering this meta tag
<meta http-equiv="X-UA-Compatible" content="IE=edge">
In Liferay , this meta is to be included as soon as the first command after <head> portal_normal.vm within the file that is located in the Templates folder of the theme used.
<head> <meta http-equiv=”X-UA-Compatible” content=”IE=edge”> <script type=”text/javascript” src=”http://code.jquery.com/jquery-1.4.2.min.js”> </ script> <title> $ the_title - $ company_name </ title> $ theme.include ($ top_head_include) </ head>
Split svn repository into multiple repositories
Sometimes it appends that a project is divided in different sub project. Each one then, can earn ti's own prioriry and become a full project.
If everything was stored into the same svn repository, how can you move away one directory of it without loosing all the commit history?
Here's how :
1. create a dump from the repository
To create a dump file use the svnadmin dump command or your svn online service admin page.
svnadmin dump [my repo url] | gzip > dump.gz
2. check the first directory level
use this script to check the first directory level contained in your dump file
gzcat dump.gz | egrep -a "^Node-path" | cut -d '/' -f 1 | cut -d ':' -f2 | sort | uniq
3. split into multiple dumps
Now it's time to split this. To achieve this we can use svndumpfilter.
Exec this line for every directory you want to separate
gzcat dump.gz | svndumpfilter include directory1 | gzip > dump_directory1.gz
You can even separate more than one directory per file
gzcat dump.gz | svndumpfilter include directory1 directory2 | gzip > dump_directory12.gz
4. import every dump into different repositories
gzcat dump_directory1.gz | svnadmin load [my new repo url 1] gzcat dump_directory2.gz | svnadmin load [my new repo url 2]
NFC operating modes
In these days you should probably heard talking about NFC. Through Google's new mobile payment method news, rumors which talk about up coming iPhone's NFC functionality and so on.
NFC (Near Field Communication) is a short-range (< 5cm) wireless communication technology. Working in Myti I got some opportunities to implements several mobile applications which based on this technology. Here I'd like to describe one of the many things I learned during the implementation of those applications. It's about operating (using) modes of NFC. According to specification it has three different operating modes.
The first mode is Read/Write Mode. This mode gives ability to read and write a passive RFID tag using NFC enabled divides. Common example of utility of this mode is smart poster which you can get more information/contents from those posters by swiping your mobile device over it .
The second mode is communication between two NFC devices (P2P Mode). Using this mode divides can exchange data between each other like virtual business cars or photos.
The last mode is Card Emulation Mode. These devices can emulate an existing contactless card which give a possibility to communicate with contactless reader for example to make a payment by swiping over a payment terminal.
But unfortunately these operating modes depend on device implementation. Not every device has all these modes. I got a possibility to work with three NFC enabled mobile phones and only two of them (Nokia 6212 classic and Nokia 6131 NFC) have all three modes. The other phone (Samsung GT-5230N) doesn't have P2P mode implemented.
It's important to know about what are the operating modes and which devices support them before you start your NFC project.
Creating a osx app bundle in Java registered to a protocol url
Recently we extended our enterprise search engine bleen adding a desktop utility automatically launched clicking on a result link.
To achieve this we created a native applciation ( for windows and osx ) registered to the protocol url bleen://
In this tutorial we will see how to build this utility in Java for Mac OS X.
The base code is a simple java class displaying a Dialog
Application bundle
Creating a OSX application bundle is as easy as creating a directory structure following some simple rules.
Out directory tree will contain :
a jar with out classes
the dependency jars
the info.plist file
a native executable
The following is a ant tast that creates the dir tree.
<target name="application-bundle" depends="jar" description="create mac Os X Application bundle"> <mkdir dir="${dist.appbundle}/Contents/MacOS" /> <mkdir dir="${dist.appbundle}/Contents/Resources/Java" /> <copy file="${auxes.dir}/JavaApplicationStub" todir="${dist.appbundle}/Contents/MacOS" /> <exec executable="chmod"> <arg value="755" /> <arg value="${dist.appbundle}/Contents/MacOS/JavaApplicationStub" /> </exec> <copy file="${auxes.dir}/Info.plist" todir="${dist.appbundle}/Contents" /> <copy file="${auxes.dir}/icon.icns" todir="${dist.appbundle}/Contents/Resources" /> <copy file="${dist.dir}/application.jar" todir="${dist.appbundle}/Contents/Resources/Java" /> <copy file="lib/libreria1.jar" todir="${dist.appbundle}/Contents/Resources/Java"/> </target>
The result is a directory tree viewed ad a application document by OSX.
URL protocol
The application runtime information are stored in info.plist file.
We edited this file inserting a couple of new keys. These keys link out app to the protocol demo://
URL Types
URL Identifier
URL Schemes
Now, the system will launch our utility every time the user clicks on a link starting with demo://
To allow osx to know out utility exist we must :
copy the app to /Application directory
or manually launch it at least once
OpenURL
Now we reached our target but we don’t use the clicked url in our code, yet.
To use it, we must relay on a system event osx raises to ask applications to manage urls. We use an extension library provided by Apple, registering a handler to the OpenURI event.
public static void main(final String[] args) { Application.getApplication().setOpenURIHandler( new OpenURIHandler() { @Override public void openURI(final OpenURIEvent pEvent) { JOptionPane.showMessageDialog ( null, pEvent.getURI().toString(), “demo”, JOptionPane.ERROR_MESSAGE); } }); }
Dependencies
Note that our dependencies jar must be located in Contents/Resources/Java and every jar must be declared in Info.plist under the keys Java/Classpath
Download
You can find a demo project download on our public space in Assembla - link
References
Handling URL shemes in Cocoa
JavaApplicationStub
AppleJavaExtensions
MRJAdapter - java library to enhance osx integration
Apple doc - References to the java info.plist keys
Apple doc - References to application bundles creations
Apple javadoc - Javadoc for Apple Java extensions
Benvenuto Tomson
Da oggi abbiamo un nuovo collega. Tomson è uno sviluppatore java, viene dal Camerun e la seconda laurea (!) l'ha presa alla facoltà di Ingegneria di Brescia. Tomson mangerà pane-grails-e-liferay per le prossime settimane. Buon lavoro!
Cloud computing e Enterprise Search
In questo periodo di forte fermento della IT, tutta eccitata dall'avvento del Cloud, quali sono le prospettive a medio periodo di una applicazione di Enterprise Search, per sua natura funzionante in rete locale (in-premise)? Credo che l'Enterprise Search sarà uno dei pochi ambiti di applicazioni Enterprise che otterrà vantaggi dal Cloud. Innanzitutto dal punto di vista tecnico può permettere di ricercare tra informazioni in rete come anche residenti nella nuvola. Qualunque altra applicazione standard, non di nicchia, venduta nel mercato delle applicazioni in-premise si troverà davanti ad una esplosione di fornitori on-demand, del tutto comparabili dal punto di vista delle funzioni, con il vantaggio di approcci commerciali innovativi ed aggressivi. Un gestionale commerciale qualsiasi (fatture, ordini bolle tc) avrà come concorrenti applicazioni di vari fornitori di tutto il mondo che si offrono cloud con prezzi a utente più bassi e nessun costo di infrastruttura. Questo però non porterà alla completa distruzione del mercato delle applicazioni in-premise. Si avrà una "dispersione" nella nuvola di tutti i servizi standard e che non creano valore aggiunto. Gli altri resteranno:
il gestionale di produzione
il file system (anche a causa della banda disponibile in italia) per tenere i documenti e tutto il materiale vicino al "ciclo caratteristico" dell'azienda
I database di dati sensibili e privati
Tutte le applicazioni specifiche, di processo, di nicchia, quelle insomma che rendono una azienda diversa dalle altre
In questo contesto un sistema di Enterprise Search Engine può fare da enabler di applicazioni Cloud. E ne prende tutti i vantaggi. Bleen, ad esempio, si propone come sistema unico per accedere a tutte le informazioni aziendali. Per "accedere" intendo trovare ed usare. "Usare " significa agire sull'oggetto trovato in modo rispettoso della sorgente dati o in modo innovativo. Un cliente mi ha chiesto: "Ho un problema che vorrei mi risolvesse Bleen. Mi capita spesso di dovere richiamare backup di file dai miei DAT perché gli utenti li cancellano o li alterano in modo errato. Perché non fate gestire le versioni a Bleen?" Io ho risposto: "Comprati Egnyte (applicazione cloud based che tra le varie cose ti fa il backup dei file nella rete gestendo le versioni. www.egnyte.com), ha costi bassi a utente e a tera" E lui: "Ma vorrei che l'utente fosse autonomo nell'estrarre le versioni" E io: "Ti faccio il connettore per Egnyte così l'utente cerca in Bleen, trova il file e le versioni e da lì fa il download. Una unica interfaccia per tutti i sistemi. Una sola metafora da spiegare all'utente per agire sui dati dell'azienda"
Ascii art in groovy
Giocando con groovy, ho scritto un semplice programma per trasformare un'immagine in "ascii art".
(su gist trovate il codice completo)
Il programma è molto semplice: un ciclo recupera, per ogni pixel dell'immagine un intero (tramite il metodo image.getRGB) che rappresenta il valore RGB del pixel stesso.
Il metodo image.getRGB ritorna un unsigned integer nella forma AARRGGBB, quindi le istruzioni:
r = 0xff & (argb >>16)
g = 0xff & (argb >> 8)
b = 0xff & argb
servono naturalmente per recuperare i valori delle componenti R (rosso), G (verde) e B (blue).
Il valore massimo tra r, g, b è poi utilizzato per la scelta del carattere che rappresenta il pixel.
Naturalmente si possono pensare algoritmi più evoluti per la scelta del carattere, nonchè espandere il set di caratteri utilizzabili.
A titolo di esempio, questo è un fantastico ritratto del Venni trasformato in ascii art:
Cambiando le impostazioni del terminale si può anche ottenere il negativo :)
Leggere e denormalizzare una tabella con un campo XPath in Kettle
Lo step "Get Data From XML" di Kettle è decisamente versatile: ci permette, infatti, non solo di leggere e trasformare un file XML, ma ci consente anche di effettuare le medesime operazioni sfruttando un campo di una tabella, che usiamo come input. Come fare?
Innanzitutto, dovremo necessariamente alimentare il "Get Data From XML" con un "Table Input":
Questa volta, la configurazione dello step sarà un po' più complessa rispetto alla normale amministrazione, in cui viene alimentato da un file: in particolare, con questo disegno, non sarà infatti possibile che il sistema intuisca la struttura XPath che stiamo leggendo.
Per cui, dovremo prima specificare il campo di origine XML:
In seguito, andremo a definire il loop dell'XPath:
E, infine, i campi che andremo a generare tramite la denormalizzazione.
Anche in questo caso, non potremo sfruttare l'intelligenza del sistema nella definizione di questi ultimi (tramite la funzione "Preleva Campi"), ma dovremo specificarli manualmente.
Notate che, allo stesso modo, non avremo la possibilità di usufruire della funzione di anteprima contestualmente allo step, e non potremo fare altro che, prima, confermare le modifiche allo step, e, in un secondo momento, lanciare l'anteprima della trasformazione.
Un'ultima nota: personalmente, su Postgres, definire il datatype nel medesimo step ("Get Data From XML") mi ha creato problemi, per cui, in un primo tempo, ho definito tutti i campi come String. In seguito, aggiungendo al flusso lo step "Select Values", ho potuto alterare i datatype.
Grails portlets : eager fetching in service class
Developing portlets with Grails is great but there are still some issue to solve. Today I would talk about two problems related to GORM and Hibernate.
First: some GORM stuff works, while some others don't and cause exceptions about the Hibernate session not being found.
For example, if we have a domain class like this:
class Car { Manufacturer manufacturer Engine engine Tyre tyres Integer seats }
calling
Car.get(id)
will works, but
Car.findByManufacturer()
won't.
There are also different behaviours by calling this methods in the render phase or in the action phase.
Second: lazy load doesn't work in .gsp views and portlet classes.
So writing
<label> ${car.manufacturer.name} </label>
cause an exception
org.codehaus.groovy.runtime.InvokerInvocationException: org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here
and, of course, the portal isn't able to render the page.
In summary, it turns out the problem is that the OpenSessionInViewFilter doesn't work properly in a portlet environment.
I faced this problem a few days ago and I found this solution:
first of all, I suggest to put the code that use GORM in a service class and call the service method from the portlet class. That's because service classes can get the hibernate session with no problems and use all of the cool dynamic methods for domain classes.
Then, that service method must use domain class dynamic methods with the fetch argument set to "eager", so the model will be fully loaded.
Your renderView closure in the portlet class will look like this:
def renderView = { def cars = carService.loadAllCars() ['cars' : cars] }
and here is the service method:
def loadAllCars() { Car.findAll([fetch:[manufacturer:"eager", engine:"eager", tyres:"eager"]]) }
Of course setting the fetch mode to eager leads into using fewer queries than the lazy mode, because the Car model and its associations will be loaded all at once. However, if you have many associations loaded with eager fetching you will have a lots of objects loaded into memory, so be careful and pay attention while designing your service methods.
Clojure first steps
This post is the first (I hope) of a series about my adventure in Clojure land.
Being Clojure hosted on the JVM, it's a natural choice for a Java developer wanting to study and learn functional languages.
A simple exercise
I started with a simple exercise: add all the natural numbers between 1 and 100 which are multiple of 5 or 7
; Add all the natural numbers below 100 that are multiples of 5 or 7. (def r (range 1 100))
The lines starting with ; are comments.
The second line creates a range of numbers, starting from 1 to 100, and assigns the sequence to the symbol r.
I then defined a function which, given a number, returns true if the number is divisible by 5 or 7.
(defn divisibile [x] (if (== 0 (mod x 5)) true (if (== 0 (mod x 7)) true false)))
The following statement filters the range returning a list of the values which are divisible by 5 or 7.
(def validValues (filter #(divisibile %) r))
Then I sum the validValues, using the reduce function; int the following statement it applies the + operator to the elements of the sequence: if the sequence is (a b c), the expression returns (a+b)+c
(def tot (reduce + validValues)) ; print the result (println tot)
I'm an absolute beginner in clojure and functional programming, so I would be happy to receive comments or suggestions. Thanks!
Enrico
Custom property editor for Grails
Problem:
Create a custom property editor between Model and View to show it as we need. (example: we wanted to change how shows the java Date.class in a view, from default format ‘yyyy-MM-dd HH:mm:ss.S’ to ‘dd-MM-yyyy’).
Solution:
There are 2 solutions which I can see now. The first one is, when every time we show a Date object, format it using a java DateFormat implement and show it. But the pretty solution is the second one, create a custom property editor to show it. So you don’t have to modify every date field that views show. To do that you have to create your property editor by implementing PropertyEditor and property editor registrar by implementing PropertyEditorRegistrar to register your property editor. For example we created our ‘CustomPropertyEditorRegistrar’ as property editor register and we used spring’s CustomDateEditor as a property editor:
import java.util.Date import java.text.SimpleDateFormat import org.springframework.beans.propertyeditors.CustomDateEditor import org.springframework.beans.PropertyEditorRegistrar import org.springframework.beans.PropertyEditorRegistry public class CustomPropertyEditorRegistrar implements PropertyEditorRegistrar { public void registerCustomEditors(PropertyEditorRegistry registry) { registry.registerCustomEditor(Date.class, new CustomDateEditor(new SimpleDateFormat("dd-MM-yyyy"), true)); } }
And finally you must add your custom property editor registrar to grails resources (‘grails-app/config/spring/resources.groovy’):
beans = { customPropertyEditorRegistrar(CustomPropertyEditorRegistrar) }
That’s all!
Groovy tip for simpler test case
When writing a groovy test case you almost want to be concise and expressive... next time you'll see the test you must undestand it quickly.
Here's a small tip to enhance test writing.
Having :
def car = new Car() def jack = new People() def tom = new Cat();
Instead of writing somethings like :
car.addPeople ( people ) car.addCat ( tom )
it's really simpler to write:
car += jack car += tom
To achieve this it's as easy as writing a plus method in you model object.
public Object plus(Object o) { if(o instanceof People) { this.addPeople((People)o); } if(o instanceof Cat) { this.addCat((Cat)o); } return this; }
Just remember this method must return this.