
it.unitn.disi.common.pipelines.BasePipeline Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of s-match Show documentation
Show all versions of s-match Show documentation
A version of S-Match semantic matching framework for Open Data
The newest version!
package it.unitn.disi.common.pipelines;
import it.unitn.disi.common.components.Configurable;
import it.unitn.disi.common.components.ConfigurableException;
import it.unitn.disi.nlptools.components.PipelineComponentException;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
/**
* Base pipeline class.
*
* @author Aliaksandr Autayeu
*/
public class BasePipeline extends Configurable implements IBasePipeline {
private static final Logger log = Logger.getLogger(BasePipeline.class);
protected List> pipelineComponents;
public void process(E instance) throws PipelineComponentException {
for (IBasePipelineComponent c : pipelineComponents) {
c.beforeInstanceProcessing(instance);
}
for (IBasePipelineComponent c : pipelineComponents) {
c.process(instance);
}
for (IBasePipelineComponent c : pipelineComponents) {
c.afterInstanceProcessing(instance);
}
}
@Override
@SuppressWarnings({"unchecked"})
public boolean setProperties(Properties newProperties) throws ConfigurableException {
Properties oldProperties = new Properties();
oldProperties.putAll(properties);
pipelineComponents = new ArrayList>();
boolean result = super.setProperties(newProperties);
if (result) {
int componentIndex = 1;
String strComponentIndex = "1";
boolean componentFound = newProperties.containsKey(strComponentIndex);
while (componentFound) {
IBasePipelineComponent component = null;
component = (IBasePipelineComponent) configureComponent(component, oldProperties, newProperties, "pipeline component #" + strComponentIndex, strComponentIndex, IBasePipelineComponent.class);
if (null != component) {
pipelineComponents.add(component);
}
componentIndex++;
strComponentIndex = Integer.toString(componentIndex);
componentFound = newProperties.containsKey(strComponentIndex);
}
if (log.isEnabledFor(Level.INFO)) {
log.info("Loaded pipeline components: " + Integer.toString(componentIndex - 1));
}
}
return result;
}
public void beforeProcessing() throws PipelineComponentException {
//nop
}
public void afterProcessing() throws PipelineComponentException {
//nop
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy