RSS

JSON Arrray parsing with com.ibm.commons.util.io.json.JsonJavaFactory

I’m currently developing the backendservices for our new absenceplanner. We submit all data to a rest service (CustomRestService in the ExtLib). So this service should be able to parse an array of json data. The data has the following format:

{
“dates”:[
{“div”:”dt20120827″,”dt”:”27.08.2012″,”metadata”:{“absenceType”:”Holiday”,”allDay”:true}},
{“div”:”dt20120829″,”dt”:”29.08.2012″,”metadata”:{“absenceType”:”Compensation”,”allDay”:true}}
],
“reqTitle”:”meine wohlverdienten ferien”,
“method”:”request.submit”
}

To parse the stream in to a JsonJavaObject I’ve used:

JsonJavaFactory factory = JsonJavaFactory.instanceEx;
Reader r = request.getReader();
json = (JsonJavaObject) JsonParser.fromJson(factory, r);
String strMethod = json.getString(“method”);

It’s very easy to extract all properties. An object can also be accessed with json.getJsonObject(“name”) . But no arrays. There is no getter.

But, how did others (like the ExtLib programmers) solve this? With this question I’ve read the code of the “twitter parsing” in the sbt of the ExtLib. And I found the solution in the com.ibm.xsp.extlib.sbt.services.client.DataNavigator class, which guides me to the following code:

 

Object arrDates = factory.getProperty(json, “dates”);
for (Iterator<Object> itDate = factory.iterateArrayValues(arrDates); itDate.hasNext();) {

JsonJavaObject jsDate = (JsonJavaObject)itDate.next();
//-> here do all the funny stuff with the jsDate object.
}

Thanks to Philippe Riand (IBM) for sharing your code. Its so inspiring to read your code.

 
6 Comments

Posted by on September 11, 2012 in Java, XPages

 

Tags: , , , ,

Documents and Spreadsheets with XPages – the Idea (Part I)

In several projects we are faced with the request to export data to a spreadsheet (mostly excel) or build a document for ms-word. So our development team requested the following: “Build an extension that helps us generate word documents or export datasets to spreadsheets”.
After some research, I found a project called Apache POI.

Apache POI covers all the stories, which we try to implement. So let’s begin with the first story: “Generating a new ms-word document”.
The story is very simple, but also very powerful. In our example the starting point is a document like the OpenNTF Contributor License Agreement. This document is needed for a company to contribute code to OpenNTF. Typically, this document has some lines (fields), which you have to fill in with your values.  Let’s try to automate this process. We will build a form in the XPages application, where you can fill in your company name, address and other things. Then we modify the standard OpenNTF form a little bit, as you can see on the screenshot below:


In your XPages form we implement the new POI Document element and then we do some wiring:

  1. We define where the modified OpenNTF Licence Agreement is. This could be a file resource in the application, or a document accessible via view and a predefined key.
  2. Defining “Bookmarks”:
    As you see on the word document, we have defined several “<<NAME OF BOOKMARK>>” tags in the text. This text must be in the same style, so they are in the same “run” Element on the document.
  3. In our “POI Document” – Control could we now define a bookmark for each <<…>> element, which contains the name and a value.
  4. As you see, the value can be computed (so a binding to a viewScope variable is possible)
  5. We define a “download” button and connect the onClick event on a new action called “Generate Document”

The user can now fill in their values on the page and generate a customized word document.  Developers are able to build in applications to produce customized documents in a very short time.
In the next blog entries, we will show you how we have build an extension of this function.

 

Tags: , , , ,

The upcoming myWebGate Release 1.2 – some Pictures

It was not on our wish list or requested. But Richie Schmid has found a brand new api in the WebKit of the latest chrome browser. It extends the capabilty of the browser to use a webcam. After a prototype, he has implemented a brand new photo uploader version. Here are some screenshots:

By clicking on “take snapshot” the picture can be cropped and uploaded as your new avatar. Directly from your webcam!
Thanks Richie for this brand new feature.
The upcoming myWebGate release is now in the final testing stage and will bring more than 10 new features.

 

 
2 Comments

Posted by on August 25, 2012 in Building Process, myWebGate, SocialBusiness

 

How open source protects your work – a short story.

Hello my readers

during the next days I’m preparing the 8th edition of Kids and Teeniedays in Effretikon. So many of my blogs will cover my social engagement. But this one is related to two different stories in my it-life, that now merges.

The first story began in the 90s. My former employer gave me the chance to learn all things about lotus notes and domino. During our work, we decided to change our development model to object orientated lotus script. One of my first work was a “FormBase” class. This class could handle a simple validation. based on empty fields. After a while, this class was a part of every application in this company. External consultants joined the company, and after a while I found this class in commercial products, in other companies.

As you could imagine, I was disappointed and a bit angry for several reasons. First, I missed my name on the source code. Later I was afraid, if anyone could know that this code was one of my first object orientated work in lotus script. Because it was not so brilliant. After reading design pattern, a great book, i was shocked, which fundamental mistake I did make. But this is another story. But how to handle, that your brilliant work is not copied? And is reinventing the wheel also coping?

There are other typical problems that you are facing, by preventing your code. But there is a very interesting other way to protect your work. Make it openSource. Put it under a openSource license, like Apache or GPL, and go to public. So anybody can see your work and give the credits to your work. An example?

The notesUI of myWebGate

The notesUI of myWebGate

Im really proud of the NotesUI of myWebGate. Even if nobody sees this. Richie Schmid did a brilliant user interface which is in many of our applications and loved by our customers. . Richie has made it several years before we even think about setting this under the terms of the Apache V2 license.

But I think this nice UI has the power to be a quasi standard like the oneUI of IBM. And I was a little bit surprised how fast we see the first adaption. Take a look at this link

So how to implement our UI in your application? Its very simple. You have to give credits to the myWebGate project, as we did with the silk icons we used (and several other brilliant open source work).

Go ahead, make brilliant software, use our UI, but give honor to the right people.

 
Leave a comment

Posted by on August 6, 2012 in Design Pattern, myWebGate

 

myWebGate – Social Software Development Process – Lessons learned.

During the lotussphere 2012 I was inspired to build our myWebGate Framework totaly new from scratch. The powere and the energy of the ibm developers and system architects has forced me to rethink my mindset about the whole XPages technologie. But rewriting a one year old framwork, with over a hunder days of manpower investigated, to have the same new made?

A crule idea but our executive board gave us the order to do this, under the focus of training, learning and transforming our development approach. It was a great time.

Yesterday we released the version 1.1 of myWebGate. This version completes some open user stories (see the release notes here) and it also completes a very new way of working together.

Our whole myWebGate development team was at the project start something we called consulting ninijas. High skilled and very talented in any aspect of development and administration of lotus notes domino. At the project start my co-pilot Peter Luder and I decide to change the model. Not a typical vertical approach: We transformed the team to a horizontal development approach. Richard became the role of our UI Guru, Peter does the project controlling and my job was the architecture. Barbara, Arthur and Marco are focused on serveral businessprocesses in the myWebGate Framwork.

This leads us to a better teamplay. Interaction was mandatory and every piece of code we build must fit. This pressure and this model of work, has effected any discussion. Normally you would expect more inefficiency, but it was vice versa. Focussing of the core competence and the delivering of brilliant work, leads to an unexpected effort and more features in the initial release as planned. And also a lot more in release 1.1.

Learn more about myWebGate -> Read This (german) and the documentation (english).

 
Leave a comment

Posted by on June 26, 2012 in Building Process, myWebGate, SCRUM, XPages

 

Tags: , , ,

Accessing Beans from Java Code in XPages (learned by Reading the SourceCode of the ExtensionLibrary)

Hello Java and XPages Fans

During our work for the myWebGate 2.0 OpenNTF Edition i was faced with a very simple Problem. I had to access a public method in one of our managed beans. This managed beans are designed to act as session facade. So the bean name is directory bean and the scope is session. The ClassName is based on our internal guidlines DirectorySessionFasade.

In this class, is a method called getMySelf() witch gives me some information about my current user in context of the myWebGate Framework. The powerfull thing about managed beans is, that the object exists only one time baed on the scope, in this case one time each session.

For our activtystream implementation I have to acces this getMySelf() methode, because all my relations are stored in the returning object. A short google search doesnt help, but I rember that I’ve ready a pattern in the ExtensionLibrary, that maby can help. An voilaz there it was, written by Phillip Riand, I found some thing that I changed to this for my situation:

public static final String BEAN_NAME = “directoryBean”; //$NON-NLS-1$
    
public static DirectorySessionFacade get(FacesContext context) {
        DirectorySessionFacade bean = (DirectorySessionFacade)context.getApplication().getVariableResolver().resolveVariable(context, BEAN_NAME);
        return bean;
    }
    
    public static DirectorySessionFacade get() {
        return get(FacesContext.getCurrentInstance());
    }

This simple codesnipped gives you the capability to execute DirectorySessionFacade.get().getMySelf(). The DirectorySessionFacade.get() Code calls the get( FacesContext context() and there the inmemory Variable directoryBean can be accessed.

What a simple construct to access the same instance in java as in the SSJS and XPAGES. Thanks to IBM for sharing the ExtensionLibrary as OpenSource.

 

myWebGate Building Process – Dojo und Templates

Das Benutzerverzeichnis ist ein Kernteil des myWebGate Framworks. Um dem Benutzer ein besonderes Erlebnis bei der Bedienung zu bieten, ist das Benutzerverzeichnis als “OnePage” Applikation designet. D.h. wir präsentieren alle Inhalte dynamisch. Die Daten werden via REST API direkt vom Server gelesen und dann on the Fly gerendert.

JSON 2 HTML Renderer gibts wie Sand am Meer. Unser Ehrgeiz war aber, dass wir das Problem mittels DOJO lösen (naja auch einige Lizenzfragen sind dann einfach geklärt). Leider ist es mit DOJO so, wie mit manchem genialen Projekt. Irgendwie hat der Dokumentator frei gehabt. Erschwerend kommt dazu, dass im Gebrauch mit XPages noch ein paar Dinge zu beachten sind.

Also zuerst das Kleingedruckte (oder wie krieg ich so ein Design hin, wie es Rechts zu sehen ist).

  1. Wir haben das HTML Template als PAGE erfasst und dort den Contentype auf HTML gesetzt.
  2. Das HTML Template darf nur 1 Root Element haben, sonst hat DOJO ein Problem
  3. Das neue DOJO Modul muss mittels
    <xp:dojoModulePath url=”biz.webgate.mywebgate.person”
    prefix=”mywebgate.Person”>
            </xp:dojoModulePath>
    eingebunden werden.

Tja und dann ist alles ziemlich simpel. Wir erstellen eine Javascript Client -Library, die wir biz.webgate.mywebgate.person.js nenne und schreiben dort folgenden Code rein:

Mittels dojo.provide definieren wir, was dieses File liefert, dojo.require definiert was wir alles brauchen, hier ist dojox.dtl._Templated die Rendering Enginge, die auf django basiert. Im dojo.declare geschieht die Magie. Mittel der cache Anweisung lesen wir das HTML File ein und peron:null erweitert unser Widget um ein neues Objekt.

In der Funktion openPersonTab() fügen wir dann die Person ein. Dabei greifen wir auf ein Spezielles TAB Objekt zu, dass uns das dynamische generieren der Tabs erlaubt. Die Variable xhrArgs definiert den Zugriff auf unser REST Service und lädt von dort das Personen Objekt. Der effektive Aufruf geschicht dann mit dojo.xhrGet(…), aber im Objekt haben wir auch die Verarbeitung des Resultats definiert. load wird dann aufgerufen, wenn wir erfolgreich die Daten abgegriffen haben. Innerhalb dieser Funktion initalisieren wir ein neues Widget und geben die data (das ist das Person Objekt vom Rest Service) direkt an das Widget weiter. dojox.dtl._Template redert dann das Template. Und durch placeAt() hängen wir das Renderresulat an das richtige Ort.

Blicken wir noch in das HTML Template:

Der Zugriff erfolgt über die {{person.____ }} Anweisungen. Wie man aus dem Code erkennen kann sind sowohl IF abfragen, wie auch for Schleifen möglich. Der Sprachumfang von DJANGO wird hier detailiert beschrieben.

Der REST Service liefert übrigens folgenden Code zurück:

Dieses Konstrukt lässt es nun zu, dass wir ohne Rendering Aufgabe für den Server die verschiedensten Personen öffnen:

Der vollständige Code wird im Juni auf openNTF veröffentlicht und ist unter der Apache Lizenz verfügbar.

 

Die Welt smarter machen?

Als ich 13 Jahre alt war, war ich total in ein Mädchen meiner Parallelklasse verliebt. Nun was tut man im Haifischbecken von 13 Jährigen Jungs, um sich selber zu positionieren? Man sucht einen USP (Unique Selling Proposition), ein Alleinstellungsmerkmal. Nun weder mit sportlicher Leistung, noch genialem Aussehen, war etwas zu machen, also habe ich meine Vision vermittelt. In einfachen Worten gefasst habe ich in einem Brief behauptet, dass ich eine Strategie hätte, um den Hungern in Afrika zu bekämpfen.

Als ich heute die Beacon Award Finalist – Auszeichnung in den Händen hielt, musste ich unweigerlich an diese Geschichte denken. Wir (die WebGate Consulting AG) haben einen Preis gewonnen, weil wir mittels Collaboration Software versuchen die Welt Smarter zu machen. Und wo machen wir das? In Afrika! Und wie machen wir das? Wir bringen Bauern mit Produzenten zusammen und helfen dabei, dass die Konditionen zwischen Bauern und Produzenten von Anfang an klar geregelt sind, wie auch die Transportkosten. Neben transparenten Preisen, führt dies auch zu einer besseren Wertschöpfung, und dies ist in der Nahrungsmittelproduktion extrem wichtig, da ich glaube, dass wir in 10-20 Jahren eine weltweite Nahrungsmittelknappheit sehen.

Ich behaupte, dass die Bekämpfung der Armut dazu führen wird, dass Nahrungsmittel viel stärker veredelt werden müssen, was zu einem höheren Rohstoffbedarf bedeutet. Naja, dazu später mal ein paar Gedanken.

Ist eine Vision wahr geworden? Ich glaube nicht so wirklich. Mein mutiger Brief von damals enthält aber eine grosse Sehnsucht: Ich will, dass mein Leben zählt, dass es wertvoll ist. Eine Sehnsucht, die mich persönlich antreibt eine extra Meile zu gehen und mehr zu investieren, als normal.

Ich glaube aber, dass viele Menschen diese Sehnsucht mit mir teilen. Wer will schon ein Leben, das nicht zählt? Die Beacon Award Finalist Auszeichnung ist für mich die Rosine auf dem Kuchen. Während den letzten 10 Jahren durfte ich erleben, wie durch Gott mein Leben plötzlich zählbar wurde. Ich hatte das Privileg, dass ich eine tolle Jugendarbeit aufbauen durfte, die etliche Junge Menschen zu einer lebendigen Beziehung mit Gott geführt hat. Wir konnten die Kids und Teeniedays ins Leben rufen und erleben jetzt wieder eine ganz spannende Zeit.

Ich bin aber auch gespannt, wie es mit unserem Engagement in Afrika weiter geht. Die Welt smarter machen, bedeutet, dass im Einzelfall auch Verzicht gefordert ist. Die Welt smarter machen, bedeutet viel Demut und Bescheidenheit und viel mehr ringen um wirkliche Lösungen. Vieleicht wussten die Franziskaner Mönche ein grosses Geheimnis als sie ihr Motto Ora et Labor definierten….

… to be continued

 
2 Comments

Posted by on March 15, 2012 in Gedanken, Leadership

 

Core Values are more important than processes

While I was reading and answering to a blog post of Sandy Carter about GenX and management,  I was inspired to share some stories and ideas about  how social business can change the way management works.

My First Idea – Management is about steering a ship in heavy waters
Following process guidelines and watching if the kpi’s are reached needs less leadership skills than we think. But what’s up if something unexcepted happens, if clouds arise on the sky and a storm is about to start.

Last year, during the presentation of the new iphone 4S I saw such a storm. Tim Cook had his first presentation as CEO without Steve Jobs in the background. Today we know under what pressure the new CEO of Apple has been. During the anoncment of Tim Cook as CEO, I asked myself “Was Steve Jobs a good teacher?” and after Tims Cooks first persentation, I thought it was ok, but as a CEO I would point out to the audience what powerful Siri is. In all the other points, I was suprised how strong the Jobs DNA was recognizable. Last week, we saw the announcement of the new ipad. A powerfull presentation with Tim Cook’s message, that we are in the post PC time. He has taken the next step. He is now forming the market. But how can this happen so fast? I think the base to this success is founded on a managment that is dedicated to core values.( If you want to know more about core values and why they are so important, read the Walter Isacsson’s biography or Jim Collins book “build to last”).

But how to teach a managment team or a company in core values? I think one of the important thing is to tell stories. And with the social business software you have an excellent platform to share your strories and get in closer touch with your people. Your personal way to tell them and the way you act and react shows the core values you stand for.

This will prepare you for bad weather, when established processes may fail. When you are in heavy water, its important to have a crew on your side that belives in you and helps you out of this. At this point managment changes from process oriented to people orientated business. You need the right persons with the right knowlede at your side. You need communications accross all organisation and hirarchies. You need people that undestand the core values and are acting accordingly.

In good times 80% of all our business runs smoothly and needs no intervention. But you habe to be prepared for the remaining 20% when you are faced with all kind of changes  in your processes and for your people. The question ist not “Will they change?”, the question is “When do the change?”. And every change, every process that is running out order, is heavy water and need intervention and improvisation. For these tasks let me train my team and myself to act based on the core values, to build the right team with the best experts and to share the expirence with others.

If you want to be successfull in this,  you have to get social. Doing this steps alone, isolated, without my friends is a typical GenX horroscenario, but doing this embedded in your community, with your experts, is challange and fun at the same time.

(Thanks to Peter Luder for reviewing and optimizing)

 
Leave a comment

Posted by on March 14, 2012 in Leadership, SocialBusiness

 

Tags:

Warum FAST Prototyping nicht RAD (Rapid Application Development) ist… und warum wir lieber SCRUM einsetzen

Innerhalb der WebGate Consulting AG, meinem Arbeitgeber, sind wir es gewohnt, wichtige Themen kontrovers zu diskutieren. Dabei werden natürlich auch Argumente von Spezialisten ins Feld geführt. Eine solche Diskussion hat mich zu folgendem Video geführt:

Natürlich bin ich nicht mit allem Einverstanden, was Herr Goslin innerhalb dieses Videos sagt, aber vieles davon hat mich zum Nachdenken angeregt. Vorallem die Aussage, dass ein Prototyp weggeschmissen wird, und danach wird nochmals neu begonnen. Gemäss James Gossling ist das Ziel eines Prototyps zu sehen, ob etwas so funktionieren kann, während Entwicklung mit Architektur und Engineering zu tun hat.

Ich glaube, dass wir gerade in der Notes / Domino Welt bezüglich FAST Prototyping und RAD einen grossen Fehler gemacht hatten. Betrachtet man RAD nämlich unter der Lupe, so sind im RAD sehr viele Ähnlichkeiten zu SCRUM zu entdecken. Und dabei geht es NICHT darum einen Prototypen zu bauen, sonderen Elemente um Element wird lauffähige Software entwickelt. Auch wenn dem Endkunden in kurzen Zyklen jeweils ein lauffähiges Element seiner Software gezeigt wird, sollte bei RAD vom Endprodukt her entwickelt werden.

Nun wird aber schon in der Beschreibung von RAD das Wort Prototype verwendet, was nicht sehr förderlich ist. Das Problem beim Prototype ist, dass “Abkürzungen” gemacht werden. So werden zum Beispiel Schichten vermischt oder gar übersprungen. Error Handling wird nicht implementiert und noch vieles weiteres wird nicht korrekt umgesetzt. Das gleiche Problem ergibt sich auch den vielen CodeSnippets, die im Internet herumschwirren. Die Snippets zeigen eine isolierte Funktionsweise eines Elementes auf. Auch hier werden einfach starke Vereinfachungen gemacht.

Wer jetzt bereits bei SCRUM nachgeschaut hat, fragt sich sicher, was denn anderst ist als bei RAD. Nun für mich ist eines der signifikaten Elemente, dass der Fokus auf den Stories des Users liegt. In kurzen Sätzen (3 Zeiler) definiert der Kunde, was er will. Und er gewichtet, was er haben will. Der Architekt der Software hingegen ermittelt die Abhängigkeiten der Stories und kann so aufgrund der Kundengewichtung ermitteln, welche Stories wie miteinander zusammen hängen. Das iterationsbasierte Vorgehen liefert dem Kunden lauffähige Software mit abgeschlossenen Userstories. Und abgeschossen heisst eben: ABGESCHLOSSEN. Kein Prototype, sondern es ist für die Userstorie alles umgesetzt und es wurde (da auch hier der Scope auf dem Endzustand ist) eine saubere Architektur und korrekte Entwicklungsprinzipien umgesetzt.

Mit dem Fokus auf die Userstory wird automatisch auch der Fokus auf den Kundennutzen gelegt. Ich glaube dies hilft auch in der Offertphase. Die Frage ist dann nämlich ganz simpel, ist die Umsetzung der Userstories die Offerte wert? Ist mein Nutzen so gross, dass ich sehr gerne das Geld ausgebe?

 

Tags: , , , ,