Skip to content

Instantly share code, notes, and snippets.

View AlBaker's full-sized avatar

Al Baker AlBaker

View GitHub Profile
@AlBaker
AlBaker / DailyBatch.groovy
Created May 27, 2011 17:41
Groovy Quartz and Spring Batch
package org.test.quartz.jobs;
import org.springframework.batch.core.JobParameters;
import org.springframework.batch.core.JobParametersBuilder;
import org.springframework.batch.core.launch.JobLauncher;
class DailyBatch {
static triggers = {
simple name:'simpleTrigger', startDelay:90000, repeatInterval: 600000
@AlBaker
AlBaker / TestDateTime.java
Created June 4, 2011 19:19
Jena and DateTime
package testjena;
import static org.junit.Assert.*;
import org.junit.Test
import org.junit.Before;
import com.hp.hpl.jena.query.ResultSetFormatter;
import com.hp.hpl.jena.query.Query;
@AlBaker
AlBaker / DateController.java
Created June 12, 2011 17:28
Spring Controller with Date objects
package mypackage;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import org.springframework.stereotype.Controller;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
@AlBaker
AlBaker / ExampleGroovySparql.groovy
Created June 27, 2011 05:30
Groovy SPARQL Example
@Grab('com.hp.hpl.jena:jena:2.6.4')
@Grab('com.hp.hpl.jena:arq:2.8.8')
import groovy.sparql.Sparql
// Can also take a Jena model as an argument
def sparql = new Sparql("http://dbpedia.org/sparql")
def query = """
SELECT ?abstract
@AlBaker
AlBaker / build.gradle
Created June 29, 2011 04:32
Simple Gradle POM Generation Example
configure(install.repositories.mavenInstaller) {
pom.project {
version '1.0'
artifactId 'your.artifact.id'
groupId 'your.group.id'
}
}
@AlBaker
AlBaker / TestSpringJena.java
Created July 6, 2011 03:05
Spring Jena Example
package com.example;
import org.springframework.data.rdf.sparql.*;
import org.springframework.data.rdf.jena.*;
import org.junit.Before;
import org.junit.Test;
public class TestSpringJena {
private Model model;
@AlBaker
AlBaker / grapeConfig.xml
Created July 7, 2011 22:27
GrapeConfig.xml example
<?xml version="1.0"?>
<ivysettings>
<settings defaultResolver="downloadGrapes"/>
<resolvers>
<chain name="downloadGrapes">
<!-- todo add 'endorsed groovy extensions' resolver here -->
<ibiblio name="local" root="file:${user.home}/.m2/repository/" m2compatible="true"/>
<filesystem name="cachedGrapes">
<ivy pattern="${user.home}/.groovy/grapes/[organisation]/[module]/ivy-[revision].xml"/>
<artifact pattern="${user.home}/.groovy/grapes/[organisation]/[module]/[type]s/[artifact]-[revision].[ext]"/>
@AlBaker
AlBaker / DbpediaQuery.groovy
Created July 9, 2011 16:51
DBPedia Query example
@Grab('org.codehaus.groovy.sparql:groovy-sparql:0.1')
import groovy.sparql.*
def sparql = new Sparql("http://dbpedia.org/sparql")
def query = """
PREFIX owl: <http://www.w3.org/2002/07/owl#>
SELECT distinct ?c ?p WHERE { ?c a owl:Class } LIMIT 10
"""
@AlBaker
AlBaker / RDFDSL.groovy
Created July 13, 2011 07:30
Groovy SPARQL RDFBuilder DSL
@Grab('org.codehaus.groovy.sparql:groovy-sparql:0.2')
import groovy.sparql.*
/**
Can be constructed with:
- Outputstream
- PrintWriter
- Model (all statements built will be copied into the input model
via model.add(List<Statement>)
@AlBaker
AlBaker / GMavenGroovy18.xml
Created July 16, 2011 18:20
GMaven Snippet
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>gmaven-plugin</artifactId>
<version>1.3</version>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>1.8.0</version>
</dependency>