public String build(DataSource source, String classTable,
			List<List<Object>> classData) {

		StringBuilder sb = new StringBuilder();

		// -- PAL setup

		sb.append(SqlGenerator.setSchema(schemaName));

		List<TableType> allTypes = algorithm.getSignature().getAllTypes();
		for (TableType type : allTypes) {
			sb.append(type.drop());
			sb.append(type.create());
		}

		sb.append(getSignature().drop());
		sb.append(getSignature().create());

		List<Object> lstProcedureParam = new ArrayList<Object>();
		lstProcedureParam.add(algorithm.getProcedureName());
		sb.append(SqlGenerator.callProcedure("SYSTEM.AFL_WRAPPER_ERASER",
				lstProcedureParam));

		lstProcedureParam.clear();
		lstProcedureParam.add(algorithm.getProcedureName());
		lstProcedureParam.add(algorithm.getLibraryName());
		lstProcedureParam.add(algorithm.getName());
		lstProcedureParam.add(getSignature().getName());
		sb.append(SqlGenerator.callProcedure("SYSTEM.AFL_WRAPPER_GENERATOR",
				lstProcedureParam));

		// -- App setup

		sb.append(SqlGenerator.setSchema(schemaName));

		if (source.containsView()) {
			sb.append(SqlGenerator.drop("VIEW", source.getViewName()));
			sb.append(SqlGenerator.createView(source.getViewName(),
					source.getViewDefination()));
		} else {
			sb.append(SqlGenerator.drop("TABLE", source.getTableName()));
			sb.append(SqlGenerator.createTableByType(source.getTableName(),
					getSignature().getDataSourceType().getTypeName()));
		}
		sb.append(getSignature().getParamTableType().createTableByType(
				algorithm.getParamTableName(this.schemaName)));

		if (!source.containsView()) {
			sb.append(SqlGenerator.truncateTable(source.getTableName()));
			List<List<Object>> tableData = source.getData();
			for (List<Object> row : tableData) {
				sb.append(SqlGenerator.insert(source.getTableName(), row));
			}
		}
		
		if (classTable != null && classTable.length() >0 && classData != null) {
			sb.append(SqlGenerator.truncateTable(classTable));
			for (List<Object> row : classData) {
				sb.append(SqlGenerator.insert(classTable, row));
			}
		}


		int idx = 1;
		for (TableType type : getSignature().getResultTableTypes()) {
			sb.append(type.createTableByType(type.getSchemaName() + "."
					+ algorithm.getName() + "RESULT" + idx));
			idx++;
		}

		sb.append(algorithm.initParams());

		System.out.println(sb);

		return sb.toString();
	}