}
public class MisoPrintServiceMapper implements RowMapper<MisoPrintService> {
public MisoPrintService mapRow(ResultSet rs, int rowNum) throws SQLException {
try {
MisoPrintService printService;
PrintContext pc = printManager.getPrintContext(rs.getString("contextName"));
BarcodableSchema barcodableSchema = printManager.getBarcodableSchema(rs.getString("printSchema"));
if (barcodableSchema !=null){
barcodableSchema.getBarcodeLabelFactory().setFilesManager(misoFilesManager);
barcodableSchema.getBarcodeLabelFactory().setSecurityManager(securityManager);
}
if ("net.sf.json.JSONObject".equals(rs.getString("printServiceFor"))) {
printService = new CustomPrintService();
printService.setBarcodableSchema(barcodableSchema);
printService.setServiceId(rs.getLong("serviceId"));
printService.setName(rs.getString("serviceName"));
printService.setEnabled(rs.getBoolean("enabled"));
printService.setPrintServiceFor(JSONObject.class);
JSONObject contextFields = JSONObject.fromObject(rs.getString("contextFields"));
PrintServiceUtils.mapJSONToContextFields(contextFields, pc);
}
else {
printService = new DefaultPrintService();
printService.setBarcodableSchema(barcodableSchema);
printService.setServiceId(rs.getLong("serviceId"));
printService.setName(rs.getString("serviceName"));
printService.setEnabled(rs.getBoolean("enabled"));
printService.setPrintServiceFor(Class.forName(rs.getString("printServiceFor")).asSubclass(Barcodable.class));
JSONObject contextFields = JSONObject.fromObject(rs.getString("contextFields"));
PrintServiceUtils.mapJSONToContextFields(contextFields, pc);
}
printService.setPrintContext(pc);
return printService;
}
catch (ClassNotFoundException e) {
e.printStackTrace();