Java class plug-in
Here are the pre-defined Java methods for com.workbrain.app.export.payroll.PayrollExportPlugin:
package com.workbrain.app.export.payroll;
import com.workbrain.app.export.payroll.data.*;
import com.workbrain.app.export.payroll.logic.*;
import com.workbrain.app.export.payroll.format.*;
import com.workbrain.sql.*;
import com.workbrain.util.*;
import java.sql.*;
import java.io.*;a
import java.util.*;
import java.util.Date;
public class PayrollExportPlugin {
private PayrollExport export;
void initialize(PayrollExport pd){
export = pd;
}
/**
* Returns PayrollExport object which can be polled for further
* export confing info.
*/
public final PayrollExport getExport(){
return export;
}
/**
* This method allows to resolve field indexes for the fields of
* interest in the Row object.
*/
public int getFieldIndex(String name){
return export.getData().getFieldIndex(name);
}
/**
* This event is called once before even SELECT is executed.
*/
public void beforeExport(){
}
/**
* This event is called once per every data row, before it was
* passed to logic section.
* @return false - if the Row has to be taken out of further
* processing.
*/
public boolean beforeRowLogic(Row r){
return true;
}
/**
* This event is called once per every data row, which was
* produced by logic section, and before is passed to format.
* Any grouping will be already reflected.
* @return false - if the Row has to be taken out of further
* processing.
*/
public boolean beforeRowFormat(Row r){
return true;
}
/**
* This event is called for every field output defined by tags:
* number,string,datetime.
* @return the value to print.
*/
public String beforeFieldOutput(int field, String valueToPrint){
return valueToPrint;
}
/**
* This event is called after all export is done. The value
* returned will be appended to the output.
* @return String to append to the export.
*/
public String appendExport(){
return null;
}
/**
* This event is called once after the export.
*/
public void afterExport(){
}
/**
* This is a standard procedure to adjust payroll dates after the
* export.
* It can be overridden with custom logic.
*/
public void ajustDates(DBConnection c, int payGrpId, Date from,
Date to) throws SQLException{
Statement s = c.createStatement();
ResultSet rs = s.executeQuery(
" SELECT paygrp_end_date, paygrptyp_duration "+
" FROM pay_group g, pay_group_type t "+
" WHERE g.paygrptyp_id = t.paygrptyp_id "+
" AND g.paygrp_id = "+payGrpId
);
if(rs.next()){
Date date = rs.getDate(1);
int days = rs.getInt(2);
PreparedStatement ps = c.prepareStatement(
"UPDATE pay_group "+
" SET paygrp_start_date = ?, paygrp_end_date = ? "+
" WHERE paygrp_id = ? "
);
ps.setTimestamp(1,DateHelper.addDays(date,1));
ps.setTimestamp(2,DateHelper.addDays(date,1+days));
ps.setInt(3,payGrpId);
ps.executeUpdate();
ps.close();
}
s.close();
}
}