GeoNetwork From Scratch I : The Phantom Catalog

This post was originally posted on the blog of a former company. But since they have decided to violate my authorship rights, here is a copy of it.

GeoNetwork, your friendly spatial catalog, never has been an easy software to deal with. But specially after the 3.0 version release, many things have changed. On this series of posts we will try to help new developers start with it.

GeoNetwork logo
The yoga man

The source code is available on a public repository on Github. This means that you can clone, fork and propose pushes of your custom changes. If you are not familiar with repositories of code or git, you should check this quick manual.

Continuar leyendo “GeoNetwork From Scratch I : The Phantom Catalog”

¿Qué es GeoNetwork?

GeoNetwork is a server side application that allows you to maintain a geographic referenced metadata catalogue. This means: a search portal that allows to view metadata combined with maps.

GeoNetwork logo
The yoga man

Based on Free and Open Source Software, it strictly follows different standards for metadata, from Inspire to OGC. It implements the CSW interface to be able to interact with generic clients looking for data. It also has built-in harvesters to connect to other servers and populate data.

This has allowed GeoNetwork su gran expansión en muchas organizaciones. For example: the geoportal suizo  o el brasileño,pasando por el neozelandés. GeoNetwork is the most used open sourced spatial catalog in the world. You can find it in most of the public administrations that use free and open source software.

The catalogue deploys on a java application container (like tomcat o jetty). It works over the Jeeves framework. Jeeves is based on XSLT transformation server library. This allows a powerful development of interfaces, for humans (HTML) or machines (XML). Therefore, it makes metadata from GeoNetwork to be easily accessible by different platforms.

Recently half-refactored to Spring and AngularJS, GeoNetwork has a REST API and an event hook system to make extensions and customizations easier.

Anotaciones y Decoradores en Java

Las anotaciones o decoradores sobre el código se han vuelto muy comunes en los últimos tiempos. Permiten al programador añadir información útil extra ya sea para comentar mejor el código o para modificar la forma de compilar/ejecutar una clase concreta. Son una extensión a Java para permitir la programación orientada a aspectos.

We have three types of annotations based on the moment of usage:

Información para el Compilador

Estas anotaciones permiten al compilador indicar si debe o no omitir errores y warnings o qué hacer con ellos. A nada que se haya trabajado con un IDE Java (como eclipse) probably you would have used this type of annotations. For example, you can use usando @Override on a function to indicate that you are overwriting a method defined on a parent class. 

This annotation is completely optional, but allows both the compiler and the developer to check that they are indeed overwriting existing hierarchical functionality.

Por ejemplo:

public class Parent {     
    public void do(){

public class Son extends Parent{     
    usando @Override
    public void do(){
Anotaciones en Tiempo de Compilación y Despliegue

These annotations allow the compiler to add extra information about how to generate the code. By adding or modifying functionality from that in the source code you can alter how a class behaves. Also to create new classes (based on a file descriptor), etc …

These annotations will only be visible at this point. They are not compiled to the .class files. Therefore they are not available at runtime.

Anotaciones en Tiempo de Ejecución

You can use this annotations on runtime and they work on a very similar way as an interface.

Veamos directamente un ejemplo de cómo crear una anotación Runtime y cómo se puede utilizar. La anotación MyAnnotation se podrá aplicar a elementos de tipo field, es decir, a atributos de una clase:

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

     public @interface MyAnnotation {

Ahora podemos crear una clase que esté anotada con esta anotación:

public class myObject
 public String field;

De esta forma, en cualquier otra parte del código, podemos comprobar mediante reflexión si un objeto tiene un campo marcado con la anotación:

Class<?> res = objeto.getClass();
for (Field f : res.getFields()) {
     if (f.isAnnotationPresent(MyAnnotation.class)) {

Más información: