Commit 1921119e authored by R.W.Majeed's avatar R.W.Majeed
Browse files

JAXB marshalling/unmarshalling of export descriptor

parent d3fb5649
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -66,4 +66,15 @@ public class FactClassAnnotator {
			((Element)fact).setAttribute("class", clazz);
		}
	}
	
	public void annotateFactSiblings(Node first){
		annotateFact(first);
		Node next = first.getNextSibling();
		while( next != null ){
			if( next.getNodeType() == Node.ELEMENT_NODE && next.getLocalName().equals("fact") ){
				annotateFact(next);
			}
			next = next.getNextSibling();
		}
	}
}
+13 −3
Original line number Diff line number Diff line
@@ -2,13 +2,23 @@ package de.sekmi.histream.export.config;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlTransient;

@XmlTransient
@XmlAccessorType(XmlAccessType.NONE)
public abstract class AbstractTable {

	public abstract String[] getHeaders();
	public abstract AbstractColumn getColumn(int index);
	public abstract AbstractColumn getColumnByHeader(String header);
	@XmlElement(name="column")
	Column[] columns;
	public String[] getHeaders(){
		String[] headers = new String[columns.length];
		for( int i=0; i<columns.length; i++ ){
			headers[i] = columns[i].header;
		}
		return headers;
	}
	public Column getColumn(int index){
		return columns[index];
	}
}
+39 −0
Original line number Diff line number Diff line
@@ -3,13 +3,9 @@ package de.sekmi.histream.export.config;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlSeeAlso;
import javax.xml.bind.annotation.XmlTransient;

@XmlTransient
@XmlAccessorType(XmlAccessType.NONE)
@XmlSeeAlso({SequenceColumn.class, IdColumn.class})
public abstract class AbstractColumn {
public class Column {

	/**
	 * Column header name
@@ -28,25 +24,16 @@ public abstract class AbstractColumn {
	String na;
	
	/**
	 * Prepare the column for the next row. This
	 * method is called once for every row. 
	 * <p> The default implementation does nothing.</p>
	 * XPath expression to select the column's value
	 */
	protected void prepareRow(){
	@XmlAttribute(required=true)
	String xpath;
	
	public Column(String header, String xpath){
		this.header = header;
		this.xpath = xpath;
	}
	
	/**
	 * Initializes the column. This method will be called
	 * only once and before any other method.
	 */
	protected void initialize(){
		
	// constructor for JAXB
	protected Column(){
	}
	
	/**
	 * Get the column value for the current row.
	 * @return String value or {@code null} for NA.
	 */
	public abstract Object getValueString();
}
+31 −0
Original line number Diff line number Diff line
package de.sekmi.histream.export.config;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;

@XmlAccessorType(XmlAccessType.NONE)
public class Concept {
	@XmlAttribute
	String iri;
	@XmlAttribute
	String notation;
	@XmlAttribute(name="wildcard-notation")
	String wildcardNotation;
	
	public static Concept newWildcard(String wildcardNotation){
		Concept c = new Concept();
		c.wildcardNotation = wildcardNotation;
		return c;
	}
	public static Concept newIRI(String iri){
		Concept c = new Concept();
		c.iri = iri;
		return c;	
	}
	public static Concept newNotation(String notation){
		Concept c = new Concept();
		c.notation = notation;
		return c;	
	}
}
+24 −0
Original line number Diff line number Diff line
package de.sekmi.histream.export.config;

import java.util.ArrayList;
import java.util.List;

import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlID;

public class ConceptGroup {
	public ConceptGroup(String clazz){
		this.clazz = clazz;
		this.concepts = new ArrayList<>();
	}
	// constructor for JAXB
	protected ConceptGroup(){
	}
	
	@XmlID
	@XmlAttribute(name="class")
	String clazz;
	@XmlElement(name="concept")
	List<Concept> concepts;
}
 No newline at end of file
Loading