Tuesday, June 30, 2009

Netbeans 6.7 Released!

Netbeans is really becoming "the only IDE you need", with an amazing PHP support, try it:

http://www.netbeans.org/downloads/

Don't Eclipse the Sun: Netbeans is easier to use and powerfull.

Friday, June 26, 2009

Hibernate Search and Class Inheritance Mapping - HowTo

Today tutorial is on two arguments: Implementing Class Inheritance Mapping with Hibernate and applying Hibernate Search Indexing on it.


Prefaction:

The Class Inheritance Strategy selected is Joined Sublcass and the dbms used for the demo is mysql (yes, inheritance in mysql is possible thanks to hibernate obviously! :P)



1) Database Structure:

CREATE TABLE `NetworkAsset` (
`dbId` int NOT NULL AUTO_INCREMENT PRIMARY KEY,
`inventoryNo` varchar,
`macAddress` varchar,
`vendor` varchar,
`model` varchar
)

CREATE TABLE `PresonalComputer` (
`employee` varchar,
`operativeSystem` varchar,
`ipAddress` varchar
`dbId` int NOT NULL PRIMARY KEY
CONSTRAINT `PCInheritanceLaze` FOREIGN KEY (`dbId`) REFERENCES `NetworkAsset` (`dbId`)
(Note: this way is the best way to implement a joined-subclass constraint on a DBMS that
doesn't supports native inheritance)

)

CREATE TABLE `Switch` (
`portCount` int NOT NULL,
`managmentIpAddress` varchar NOT NULL,
`LanDescription` varchar NULL,
`dbId` int NOT NULL PRIMARY KEY,
CONSTRAINT `SWInheritanceLaze` FOREIGN KEY (`dbId`) REFERENCES `NetworkAsset` (`dbId`)
)



2) Hibernate CTI Mapping POJOs (with Annotations)

Note: the used annotations import is:
import javax.persistence.*



@Entity
@Table(name="NetworkAsset"
,catalog="CreativeProgrammingDemoDB"
)
@Inheritance(strategy=InheritanceType.JOINED)
public class NetworkAsset implements java.io.Serializable {
private int dbId;
private String inventoryNo
...other filelds...

@Id

@Column(name="db_id", unique=true, nullable=false)
@GeneratedValue
public int getDbId() {
return this.dbId;
}

public void setDbId(int dbId) {
this.dbId = dbId;
}
...other getter and setters...
}

@Entity
@Table(name="PersonalComputer"
,catalog="CreativeProgrammingDemoDB"
)

public class PersonalComputer extends NetworkAsset {
//private int dbId; Note: don't add the id field in subclass POJO: it's inherited!
private String ipAddress;
private String employee;
...other filelds...

@Id

@Column(name="employee", unique=true, nullable=false)
public int getEmployee() {
return this.dbId;
}

public void setEmployee(String employee) {
this.employee = employee;
}
...other getter and setters...
}


That's all for mapping joined sublass inheritance with annotations...

isn't easy? :)



3) Hibernate Search






Friday, June 12, 2009

Java Browser API

I found this interesting web browser enterly written in java:

http://lobobrowser.org/


it is GPL, supports HTML 4,CSS2, JavaFX and Javascript* (with AJAX support)

http://lobobrowser.org/browser/api-info.jsp


*Javascript support is limited, for instance some dojo and extjs apps doesn't works with the browser..

Wednesday, June 10, 2009

Redmine - project managment and bug tracking made simple

Looking for an open source project managment tool?

Redmine is an evolved an easy to use multi-project managment environment

Looking for enterprise collaborative teaming tool with activity reports?

Redmine does it, and integrates LDAP for authentication.

Looking for an integrated svn or mercurial extention more simple and powerfull than trac?

Redimine manages repository in an awesome way, for instance the following svn commit:

svn commit -m "this patch closes #245"

closes the ticket and relates the diffs to the ticket history.

Your system support team has planned to kill you at your next request?

Redmine is entireley configurable by his web interface: no system support effort is required after installation
.

Installation is a "next request" and you want to live enough see redmine working?

download the cross-platform bundled installer
(provided by bitnami.org - Open Soruce. Simplified. )


Issues with subversion repository LDAP authentication?

I'm going to write an how to on this. stay tuned!

Wednesday, June 3, 2009

javascript is evolving!

Googlers introduces the ecmascript5 (aka javascript2) changes:

http://ajaxian.com/archives/ecmascript-5-changes-to-javascript

i can't still wait for it!!

Thursday, October 16, 2008

Save the forest: don't destroy() dijit.Trees!

Some messages in various ajax forums ask for a solution to reload the whole content of a dojo tree with a dynamic item store.

No one has proposed a good response:

Someone said: destroy the tree and re-make it! Sure.. but what will happen to my dojo connects on the tree nodes? and the dojo tree status (opened folders ecc.)? a bloodshed! no one of my connected widgets will survive after this brutal operation..

Some other said: use a ContentPane to embed the tree and reload its href: Fantastic.. ^_^ This is the same to destroy and recreate the tree but with an extra overhead due to the contentPane.

Some other other said: Use my customized reload() function.. good.! i'm just sorry to see that non one of these solutions works..

Some infidels said: This is not possible.

I say: you can save a dijit.Tree.. don't cut it: prune it! and it'll re-grow wonderfully

This is my reload function that works:


dojo.extend(dijit.Tree, {
refresh: function(){
var root=this._getRootOrFirstNode();
while((node=this._getNextNode(root))!=null){
var parent = node.getParent();
if(parent){
parent.removeChild(node);
}
node.destroyRecursive();
}
this._itemNodeMap={};
this.store._loadFinished = false;
this.store.fetch();
this._store2model();
this._load();
var parent = root.getParent();
if(parent){
parent.removeChild(root);
}
root.destroyRecursive();
}
});


that you can simply use in this way:

dijit.byId('mytree').refresh();

good dojing to all!
Bye.

Thursday, August 21, 2008

How to lookup SNMP Textual-Conventions in Perl (Net-SNMP)

For the series: Demystifing SNMP

if you need to programmatically convert a value of a varbind that is defined in the mib file with a textual-convention here you can find a perl code that works:


use SNMP; #pay attention this isn't Net::SNMP!!

&SNMP::addMibDirs("/yourpathtomibfiles/mibs");
$SNMP::save_descriptions=1;
&SNMP::initMib();
&SNMP::loadModules('ALL');
...
...
my $obj = $SNMP::MIB{$the_varbind_oid};
$TextConvention_To_IntegerValue_HashTable = $obj->{enum};
#now enjoy with this hash table and your integer value



For example ifAdminStatus is an INTEGER, but this integer means:
(1)->up
(2)->down

whit TextConvention_To_IntegerValue_HashTable hash table you can lookup numbers to associated string values..
but attention: you need to invert keys and values in the hash table.


here is it one example that shows how hard is to manually parse mib files:


jnxCmCfgChgEventSource OBJECT-TYPE
SYNTAX JnxCmCfChgSource
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"The source of the configuration event."
::= { jnxCmCfgChgEventEntry 4 }


JnxCmCfChgSource ::= TEXTUAL-CONVENTION
STATUS current
DESCRIPTION "Identifies the source of config event."
SYNTAX INTEGER {
other (1),
cli (2),
junoscript (3),
synchronize (4),
snmp (5),
button (6),
autoinstall (7),
unknown (8)
}


Net-SNMP rocks!