Search in sources :

Example 1 with ChainWalker

use of org.walkmod.ChainWalker in project walkmod-core by walkmod.

the class DefaultChainWalkerInvocation method invoke.

@Override
public void invoke() throws WalkModException {
    ChainWalker walker = walkerAdapter.getWalker();
    if (walker != null) {
        try {
            walker.execute();
        } catch (Exception e) {
            throw new WalkModException("An exeception has been produced during the " + walkerAdapter.getName() + " transformation", e);
        }
    }
    LOG.debug("The transformation [" + walkerAdapter.getName() + "] has been executed");
}
Also used : ChainWalker(org.walkmod.ChainWalker) WalkModException(org.walkmod.exceptions.WalkModException) WalkModException(org.walkmod.exceptions.WalkModException)

Example 2 with ChainWalker

use of org.walkmod.ChainWalker in project walkmod-core by walkmod.

the class DefaultChainAdapter method prepare.

@Override
public void prepare() throws WalkModException {
    setName(ac.getName());
    ReaderConfig readerConfig = ac.getReaderConfig();
    WriterConfig writerConfig = ac.getWriterConfig();
    String modelName = readerConfig.getPath();
    String modelType = readerConfig.getType();
    ChainReader reader = readerConfig.getModelReader();
    if (reader == null) {
        try {
            reader = (ChainReader) ac.getConfiguration().getBean(modelType, readerConfig.getParameters());
        } catch (Exception e2) {
            throw new WalkModException("The model " + modelName + ", whose type is " + modelType + "in the architecture " + getName() + " cannot be loaded ", e2);
        }
    }
    readerConfig.setModelReader(reader);
    reader.setPath(readerConfig.getPath());
    reader.setExcludes(readerConfig.getExcludes());
    reader.setIncludes(readerConfig.getIncludes());
    try {
        setResource(reader.read());
        LOG.debug("Model " + modelName + " loaded");
    } catch (Exception e2) {
        throw new WalkModException("The model " + modelName + ", whose type is " + modelType + "in the architecture " + getName() + " cannot be read ", e2);
    }
    WalkerConfig wc = ac.getWalkerConfig();
    ChainWalkerAdapter wa = new DefaultChainWalkerAdapter();
    setWalkerAdapter(wa);
    ChainWalker walker = wc.getWalker();
    if (walker == null) {
        walker = (ChainWalker) ac.getConfiguration().getBean(wc.getType(), wc.getParams());
    }
    wc.setWalker(walker);
    wa.setWalker(walker);
    wa.setWalkerConfig(wc);
    wa.setArchitectureProxy(this);
    wa.setWalkerInvocation(new DefaultChainWalkerInvocation());
    ChainWriter writer = writerConfig.getModelWriter();
    if (writer == null) {
        try {
            writer = (ChainWriter) ac.getConfiguration().getBean(writerConfig.getType(), writerConfig.getParams());
        } catch (Exception e2) {
            throw new WalkModException("The writer " + ", whose type is " + writerConfig.getType() + "in the architecture " + getName() + " cannot be read ", e2);
        }
    }
    writerConfig.setModelWriter(writer);
    writer.setPath(writerConfig.getPath());
    setChainWriter(writer);
    wa.prepare();
    ai.init(this);
}
Also used : ChainWalker(org.walkmod.ChainWalker) ChainWriter(org.walkmod.ChainWriter) WalkModException(org.walkmod.exceptions.WalkModException) ChainReader(org.walkmod.ChainReader) WalkerConfig(org.walkmod.conf.entities.WalkerConfig) ReaderConfig(org.walkmod.conf.entities.ReaderConfig) ChainWalkerAdapter(org.walkmod.ChainWalkerAdapter) WalkModException(org.walkmod.exceptions.WalkModException) WriterConfig(org.walkmod.conf.entities.WriterConfig)

Aggregations

ChainWalker (org.walkmod.ChainWalker)2 WalkModException (org.walkmod.exceptions.WalkModException)2 ChainReader (org.walkmod.ChainReader)1 ChainWalkerAdapter (org.walkmod.ChainWalkerAdapter)1 ChainWriter (org.walkmod.ChainWriter)1 ReaderConfig (org.walkmod.conf.entities.ReaderConfig)1 WalkerConfig (org.walkmod.conf.entities.WalkerConfig)1 WriterConfig (org.walkmod.conf.entities.WriterConfig)1