Upgrading to ubuntu 9.10 “Karmic Koala

A couple of quick notes, have just upgraded my media PC to the latest ubuntu, it did it via the on-line distro upgrade, nice and neatly with no impact on current programs and user accounts (a little slow perhaps but i bet that the servers are having the hell beaten out of them at the moment). first impressions are very very good

Its a even cleaner interface and while it has more than a hint of “apple” about it (boooooo), there are lots of new features, ones like the palimpset Disk Utility,

that does pre-warning on drive failures (a feature that up until now I had only experienced on enterprise raid arrays), this give you confidence in this version as a stable platform, very very impressed

On that note, those of you who use Ubuntu on a serious work machine such as I do, and are still on 8.04, might wonder why you don’t get the “upgrade to” notice on the top of the “Update manager” screen when a new major version comes out, the reason is that you will have your software support updates set to “Long term support Releases Only” (which is what 8.04 is), if you want to get the update option (you will have to go through all the previous versions first, ie 8.10 –> 9.04 –> 9.10), just go.

System –> Administration –> Software Services

and change this to “Normal Releases”

Close that, then reopen your update manager, and you will find (after ensuring that you have no more updates to install) that you are presented with the chance to update to a newer distribution, and given what i see on 9.10 i wish they would hurry up and define the next long term support release, so i can do that on my work laptop 🙂

Eclipse search on XP

This is a REAL old one, but as so many of us corporate developers are still on xp its worth the mention, I was trying to do the same as Ben Poole is doing here with mac stuff, to get over the terriable seach features in eclipse, but on windows alas the same feature does not search the contents of ‘unknown’ file types ie .Java (mutter Microsoft mutter), you fix this as follows (providing you have SP2 installed):

  1. Click Start, and then click Search (or point to Search, and then click For Files or Folders).
  2. Click Change preferences, and then click With Indexing Service (for faster local searches).
  3. Click Change Indexing Service Settings (Advanced). Note that you do not have to turn on the Index service.
  4. On the toolbar, click Show/Hide Console Tree.
  5. In the left pane, right-click Indexing Service on Local Machine, and then click Properties.
  6. On the Generation tab, click to select the Index files with unknown extensions check box, and then click OK.
  7. Close the Indexing Service console.Now the search will stop being such an as and will search the contents of Java files.
    Update**
    turns out on more modern eclipse instances you get the same with the ‘Search’ –> ‘File’ Option, hmmmmm did i miss that coming in??

Oi wheres me config docs Oh bugger I dont have a nsf

Here we go with another example of what to do when cruelly ripped from the
bosom of the notes server

This time its config docs, these as we all know are a happy doddle in notes, we
just store them in what ever db (usually the current one) is suitable and pull
then back with a view (personally i don’t like profile documents as they are a
swine to copy around in comparison to normal docs), when faced this same basic
need in Java, and not wanting to use a relation database (feels like a bit of
an over kill for some things) i went searching and found more wonderful people
who have already done the job, this time at
http://commons.apache.org/configuration/
They have a nice little lib that lets you store stuff in xml docs (as well as
many other things), here is an example (lets call it config.xml)

<?xml version="1.0" encoding="ISO-8859-1" ?>
<project-definition>
    <example1>
     <textexample>im a example</textexample>
    </example1>
    <example2>
     <intexample>15</intexample>
     <list1>
      <name>item1,item2,item</name>
     </list1>
    </example2>
</project-definition>

 

I’m going to save this in the root of my Java project, and now on to the code

import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.XMLConfiguration;
public class EasyConfigDocs{
       public static void main(String[] args) {
          try {
              XMLConfiguration config = new XMLConfiguration("Config.xml");
            String textconfig = config.getString("example1.textexample");
               //Note: to get an indented value you separate with a "."  
              int numberconfig = config.getInt("example2.intexample");
              List buttons = config.getList("example2.list1.name");
               //Note: on multivalue items the default separator is a "," if 
you want to use a "," in a text string you need to either do "," or change the 
default delimiter (easy to do, its on the site) 
          } catch(ConfigurationException cex) {
             System.out.println("config file not found");
          }
       }
}

 

Nearly as simple as Notes (not that i did any work), it also does all the Edit
and Add stuff, but you can get that off the examples at
http://commons.apache.org/configuration/ if you need it, i just want to save
you the pain on the initial search, Oh!, on that note keep a look out at
http://www.benpoole.com hes on the same track as me and has some good blog
tutorials for notes developers fighting with pure Java coming up.

Old Comments
————
##### John(15/07/2011 13:51:29 GDT)
I don’t really like the way that they have write that code
##### Mark Myers(17/07/2011 17:42:12 GDT)
@john really?, i find it a pleasant and easy going way of doing configs, what way do you prefer?

Doing Scheduled agents When not on a Domino server

When you step outside the warmth and comfort of a domino server a lot of things frighten the willies out of you, things you took for granted are suddenly not there, so i thought each time i have to do a notes equivalent in the cold hard
world, I would share:

Today sprig of joy is scheduled agents in Java (on a JBoss server actually), this is all supplied thanks to the amazing people over at http://www.opensymphony.com/quartz/, its far more powerful than my example, but it easy to understand when you come from notes, and you can expand on it as you see fit (instruction are in the comments), have fun (oh, if the code looks cramped just copy it to a bigger text widow as i left all the proper indenting in)

import org.quartz.CronTrigger;
import org.quartz.JobDetail;
import org.quartz.Scheduler;
import org.quartz.impl.StdSchedulerFactory;
public class JustLikeANotesAgent {
    public static void SetUpNotesTypeAgent(String CronTriggerPram) throws 
Exception {
        // setting up the scheduler which is basically the equivalent of agent 
manager
       Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();
        // setting up our "Agent" ie giving it a name and linking it to a chunk 
of code
        JobDetail NotesAgent = new JobDetail("NotesAgentName", null, 
AgentCode.class);
        // setting up our schedule ,there are "simple triggers" and 
"Crontriggers"
        // Crontriggers are more powerful and easy to get a handle on if your 
used to notes
        CronTrigger AgentSchedule=new CronTrigger("AgentScheduleName",null
,CronTriggerPram);
        // linking the Agent to its schedule and "enabling" it
        scheduler.scheduleJob(NotesAgentName, AgentScheduleName);
        scheduler.start(); // and off we go, basically "load Agmr"
    }
    public static void main(String[] args) {
           //the following string is a Cron Trigger that runs every 5 mins
           // tutorial on crontriggers can be found HERE
     String CronTriggerPram = "0 0/5 * * * ?";
     try {
      SetUpNotesTypeAgent(CronTriggerPram);
     } catch (Exception e) {
      e.printStackTrace();
     } 
            //scheduler.shutdown(); this is commented out as its basically like 
"tell agmr quit"     
    }
}

After the honeymoon, Tip 1

Its been about 2 months since i started using adobe flex in billable anger, and
even the best platform looses some of its ability to escape criticism in that
time, flex however is proving to be everything that I had hoped for, but you
still bump into the odd thing that domino does much better, so I’m doing a
series of tips and tricks to help you get everything from both systems
(especially when used together).

Todays tip is sortable date columns in flex data grids

Flex data grids are a wonderful thing, with easy sorting and sizeable columns
and such, but one thing sucks on them, and that’s the fact that they only do
TEXT sorting, dates are just treated like text which means that all of the
common date formats wont sort correctly, Booooo!, but we can fix that
surprisingly easily

First you want to output your date data from notes in YYYYMMDD format, why??
because this formats displays the same when sorted textually or chronologically

so in a view that would be (its a bit long as we need to pad the short
days/months (thanks to Ben Poole for pointing this out))

edited by popular vote to a shorted version

@Text(@Year(LossDate)) + @Right(“0” + @Text(@Month(LossDate));2) + @Right(“0” +
@Text(@Day(LossDate));2)

if your using a web service to return that value, the Java code would be

import java.util.Date;
import java.text.DateFormat;
import java.text.SimpleDateFormat;

Item dateitem = doc.getFirstItem(“DateIWant”);
DateTime notesdate = dateitem.getDateTimeValue();

DateFormat dateFormatordered = new SimpleDateFormat(“yyyyMMdd”);

String UpdDtSort=dateFormatordered.format(notesdate);

if you using lotusscript for you webservice then your on your own!!.

Now into flex and define a “Dateformater”, this is my personal fav date format
(is it sad that i have one) and produces dates like “Tue May 04 2009″, which i
find removes many problems with international formats causing confusion.

 

Next you will need your actual datagrid (which you will already have if you
have discovered this problem).

<mx:DataGrid width=”740″ height=”126″ x=”10″ y=”34″ id=”datesortview”
dataProvider=”{mynotesview}” fontFamily=”Arial”>

 

You will notice the “labelFunction” at the end of the date column, that calls
the following function (and passes the parameters automatically).

private function dateLabel(item:Object, column: DataGridColumn) : String {
if (item[column.dataField] != null) {
var TempDate:Date = DateField.stringToDate(item[column.dataField],
“YYYYMMDD”);
return dateFormatternice.format(TempDate);
} else {
return “”;
}
}

This basically just takes in each value in the column, converts it to a date
using a mask, formats to a pretty format and returns it back to the column. it
is MUCH faster than attempting a code based sort solution (as some people use
in flex using “sortCompareFunction” on a datagrid).

your column now has 2 values the underlying data format in the happily sortable
“20090504” and the label format that the user sees in the format “Tue May 04
2009”, yet again a feature we took for granted in notes requires a bit of
coding to get it in other platforms.