Commit 9a9b66ea authored by R.W.Majeed's avatar R.W.Majeed

allow set-concept, set-value directly in map element

parent 30dab98b
......@@ -99,6 +99,18 @@ public abstract class Column<T> {
private void applyMapRules(String value, MapFeedback action){
boolean match = false;
// always perform operations specified in the map element
// regardless of matching value
if( map.setConcept != null ){
action.overrideConcept(map.setConcept);
}
if( map.setValue != null ){
action.overrideValue(map.setValue);
}
// XXX TODO implement setUnit
// iterate through listed cases
// no case may be present at all
if( map.cases != null ){
for( MapCase mc : map.cases ){
......@@ -216,6 +228,8 @@ public abstract class Column<T> {
// string processing (na, regex-replace, mapping) only performed on string values
if( rowval == null ){
ret = null; // null value
// XXX FIXME allow map processing for null values
ret = processedValue((String)null, mapFeedback);
}else if( rowval instanceof String ){
// non null string value
ret = processedValue((String)rowval, mapFeedback);
......
......@@ -5,16 +5,10 @@ import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
@XmlAccessorType(XmlAccessType.NONE)
public class MapCase {
public class MapCase extends MapReplace{
@XmlAttribute
String value;
@XmlAttribute(name="set-value")
String setValue;
@XmlAttribute(name="set-concept")
String setConcept;
// TODO use enum
@XmlAttribute
String action;
......
package de.sekmi.histream.etl.config;
import javax.xml.bind.annotation.XmlAttribute;
/**
* Replace informations in facts.
* Used as base class providing attributes to map case and map
*
* @author R.W.Majeed
*
*/
public abstract class MapReplace {
@XmlAttribute(name="set-value")
String setValue;
@XmlAttribute(name="set-concept")
String setConcept;
@XmlAttribute(name="set-unit")
String setUnit;
}
......@@ -3,11 +3,14 @@ package de.sekmi.histream.etl.config;
import javax.xml.bind.annotation.XmlElement;
/**
* Map rules for columns or concepts
* Map rules for columns or concepts.
* The actual mapping implementation is in
* {@link Column#valueOf(Object, de.sekmi.histream.etl.MapFeedback)}
*
* @author R.W.Majeed
*
*/
public class MapRules {
public class MapRules extends MapReplace{
@XmlElement(name="case")
MapCase[] cases;
......
......@@ -112,10 +112,10 @@
<virtual>
<!-- for eav facts, the map always applies to the fact value -->
<value column="f_eav_x" na="" xsi:type="string">
<map>
<case value="1" set-value="" set-concept="f_eav_x_1"/>
<map set-value="">
<case value="1" set-concept="f_eav_x_1"/>
<!-- action inplace is default -->
<case value="0" set-value="" set-concept="f_eav_x_0"/>
<case value="0" set-concept="f_eav_x_0"/>
<!-- action drop will not produce any fact -->
<otherwise log-warning="Unexpected value" action="drop-fact" />
<!-- action generate will produce a new concept with the given values -->
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment