All Downloads are FREE. Search and download functionalities are using the official Maven repository.

online.sanen.unabo.sql.pipe.CreateAndInsertSqlPileline Maven / Gradle / Ivy

The newest version!
package online.sanen.unabo.sql.pipe;

import java.util.Collection;

import online.sanen.unabo.api.Handel;
import online.sanen.unabo.api.structure.ChannelContext;
import online.sanen.unabo.api.structure.enums.ProductType;
import online.sanen.unabo.template.SqlTemplate;


/**
 * 
 *
 * @author LazyToShow 
* Date: 2018/09/14
* Time: 10:09:06 */ public class CreateAndInsertSqlPileline implements SimplePileline,Handel { String newTableName; public CreateAndInsertSqlPileline(String newTableName) { this.newTableName = newTableName; } @Override public Object handel(ChannelContext structure, Object product) { String modifier = ProductType.applyTableModifier(structure.productType()); structure.getSql().insert(0, "CREATE TABLE " + modifier + newTableName + modifier + " AS "); Collection paramers = structure.getParamers(); SqlTemplate template = (SqlTemplate) structure.getTemplate(); template.update(structure.getSql().toString(), paramers.toArray()); return this.getSql(structure); } }