Biarkan Hati Berbicara dengan Tuntunan Allah SWT

“Na, Kak Dairi ngajak aku nikah..!” dengan suara yang cukup pelan, ku buka percakapanku dengan salah satu rekan kerja ku yang duduk tepat di samping kiri ku.

“Ooh.. aku nggak kaget ris. Ehehe..” Ana menimpali.

“Lah.. kok bisa?” aku semakin terkejut.

“Iya. Di kereta tuh kalau dia bareng aku pas pulang, suka nanyain tentang kamu gitu. Cuma aku nggak cerita ke kamu. Hahaha.. trus gimana kamunya? mau nggak?”

“Gimana yaaa naa.. aku kan nggak tau apa-apa tentang dia. Cuma tahu nama doank lah bisa dibilang. Tapi aku udah janjian se ama dia mau tukeran CV gitu.”

“Ooohh.. yaa sambil istikharah ris. Ohohoho..”

“Insyaa Allah na. Sstt..” aku menutup percakapan karena rekan kerja ku yang lain sudah mulai banyak yang datang. Takut kedengeran gitu deh.. *sok artis :p

Aku memulai solat istikharah untuk menetapkan keputusanku. Dalam doaku yang biasanya hanya meminta kepada Allah untuk diberikan suami yang soleh nan penyayang, kini berubah menjadi pertanyaan yang meminta bimbingan untuk sebuah keputusan dari sebuah nama yang telah datang.

Aku sudah mendapatkan “contekan” template CV dari salah satu kakak seniorku dan juga temanku di SMA. Ku susun serapi yang kubisa, lalu ku kirim ke Uda ( mulai sekarang sebut saja si kakak itu dengan Uda :p ). Uda juga sudah mengirimkan template CV yang ia punya. Setelah itu by chat, kami menyepakati point mana saja yang ingin ada di dalam CV kami dan berjanji akan mengirimkan CV masing-masing dalam dua minggu ke depan.

************

Kupandangi layar laptopku. Hanya ada rangkaian point yang belum terjabarkan dengan baik untuk menggambarkan bagaimana seorang Ariestania Winda. Mendadak ngoding pemrograman terasa lebih baik daripada bikin CV taaruf. Menyesal kenapa cuma minta dua minggu untuk menyelesaikan CV ini. Harusnya minimal sebulan seperti jika aku membuat aplikasi yang sudah lolos QA dan siap migrasi ke production. Continue reading “Biarkan Hati Berbicara dengan Tuntunan Allah SWT”

Advertisements

Darimu yang Menginginkan Kamu dan Aku Menjadi Kita

Seperti biasa, aku memulai hari-hari dengan ngobrol kesana kemari sembari sarapan bersama rekan-rekan kerjaku. Tentunya dengan comot sana sini untuk mencoba sarapan mereka juga. Kalau dipikir-pikir, tanpa aku membawa makanan untuk sarapanku sendiri, aku bisa kenyang dengan “penghasilan” dari comot-comot itu. Tapi berhubung masih jaim, semua rencana itu ku urungkan. Kasian juga kalau mereka jadi masih lapar karena makanannya aku yang makan. Ohohoho..

Selepas sarapan, aku segera kembali ke meja kerjaku. Suasana ruangan agak sepi. Sepertinya banyak yang cuti karena dekat dengan liburan yang “kejepit”. Guna mempersiapkan ketangguhan jiwa dan raga untuk mulai berjibaku dengan coding lagi, aku membuka browser dan mulai berselancar di dunia maya.

“Hai Aris,” sapa salah satu rekan kerjaku. Ia kemudian duduk di kursi sebelahku.

“Ya?” aku melepaskan headset yang sudah nyaman terpasang di telinga. “Kenapa kak?”

“Emm.. bentar. Aku siapain diri dulu,” ia nampak ragu dan bimbang.

“Oh emang kenapa? eeemmm.. tulis di keyboard aja sini di kompi aris kalo susah ngomongnya”.

“Emm.. Aris udah punya calon suami?”

“Belom,” jawabku. Continue reading “Darimu yang Menginginkan Kamu dan Aku Menjadi Kita”

How To Generate Large Excel File in Java Using POI

On my last project, I have to create report on excel format with huge data. The data that I need to print on report can be up to 4 million rows. I tried using HSSF and XSSF class but always got heap space problem even though I already set up my JVM. After some google, I found out that I can use SXSSF class for my case. You can check about it on apache page.

For my code, I changed my query to split the resultset so the memory will not keep all data in one time. Then I divide the rows into some sheets too. Here is some of my code.

package main.xls;

/* import libraries */

/**
 * @author ariestania.winda
 */
public class XLSReportGenerator {

 /**
  * SOME CODE
  */

 public String generate() {
  Connection conn = null;
  try {
   conn = DriverManager.getConnection(Var.CONN_REPORT);

   int maxRow = 60000;
   int rowMaxMemory = 200;
   int defaultStartRownum = 1;
   int defaultEndRownum = 6000;

   String fileName = "mytestrep.xlsx";
   String pathSeparator = BohayUtils.getPathSeparator();
   String path = configuration.getReportPath() + pathSeparator + sdfYear.format(dtTo) + pathSeparator + sdfMonth.format(dtTo) + pathSeparator + fileName;

   File repFile = new File(path);

   if (!repFile.exists()) {
    try (SXSSFWorkbook workbook = new SXSSFWorkbook(rowMaxMemory)) {
     CellStyle boldCenterStyle = ReportGlobalFunction.getBoldFontStyle(workbook, true);
     CellStyle currencyStyle = ReportGlobalFunction.getCellCurrency(workbook);

     SXSSFSheet mySheetSample = workbook.createSheet("My Detail Report");

     //track column to set autoSizeColumn
     mySheetSample.trackAllColumnsForAutoSizing();

     //get my data
     List < MyDatas > jmlMyData = myDBHandler.getMyDatas(startRownum, endRownum);

     int startRownum = defaultStartRownum;
     int endRownum = defaultEndRownum;
     int curColNum = 0;
     int curRowNum = 1;
     int sheetNo = 1;

     //title
     row = mySheetSample.createRow(curRowNum);
     cell = row.createCell(curColNum);
     cell.setCellValue("JUMLAH BOHAY MESIN");
     cell.setCellStyle(boldCenterStyle);
     mySheetSample.addMergedRegion(new CellRangeAddress(curRowNum, curRowNum, 0, 6));
     curRowNum = curRowNum + 2;

     //header table
     row = mySheetSample.createRow(curRowNum);
     cell = row.createCell(curColNum);
     cell.setCellValue("  NO  ");
     cell.setCellStyle(boldCenterStyle);
     mySheetSample.autoSizeColumn(curColNum);
     curColNum++;

     cell = row.createCell(curColNum);
     cell.setCellValue("     BRANCHID     ");
     cell.setCellStyle(boldCenterStyle);
     mySheetSample.autoSizeColumn(curColNum);
     curColNum++;

     cell = row.createCell(curColNum);
     cell.setCellValue("       DESCR       ");
     cell.setCellStyle(boldCenterStyle);
     mySheetSample.autoSizeColumn(curColNum);
     curColNum++;

     cell = row.createCell(curColNum);
     cell.setCellValue("       CASHIN_AMT       ");
     cell.setCellStyle(boldCenterStyle);
     mySheetSample.autoSizeColumn(curColNum);
     curColNum++;
     curRowNum++;

     //release track
     mySheetSample.untrackAllColumnsForAutoSizing();

     curColNum = 0;
     noData = 0;
     if (jmlmyDt.size() > 0) {
      boolean runLoop = true;
      while (runLoop) {
       for (MyDatas myDt: jmlMyData) {
        if (noData == maxRow) {
         sheetTotalTrxTunai = workbook.createSheet(judulSheet + sheetNo);
         noData = 0;
         sheetNo++;
         curRowNum = 0;
         curColNum = 0;
        }
        noData++;

        row = mySheetSample.createRow(curRowNum);

        cell = row.createCell(curColNum);
        cell.setCellValue(myDt.getNO());
        curColNum++;

        cell = row.createCell(curColNum);
        cell.setCellValue(myDt.getBRANCH_ID());
        curColNum++;

        cell = row.createCell(curColNum);
        cell.setCellValue(myDt.getDESCR());
        curColNum++;

        cell = row.createCell(curColNum);
        cell.setCellValue(myDt.getCASHIN_AMT());
        cell.setCellStyle(currencyStyle);
        curColNum++;

        curRowNum++;
        curColNum = 0;
       }
       startRownum = startRownum + defaultEndRownum;
       endRownum = endRownum + defaultEndRownum;
       jmlMyData = myDBHandler.getMyDatas(startRownum, endRownum);
       runLoop = jmlMyData.size() > 0;
      }
     } else {
      row = mySheetSample.createRow(curRowNum);
      cell = row.createCell(curColNum);
      cell.setCellValue("NO DATA");
     }

     jmlmyDt = null;

     repFile.getParentFile().mkdirs();
     repFile.createNewFile();

     try (FileOutputStream fos = new FileOutputStream(repFile)) {
      workbook.write(fos); //write file
      fos.flush();
     }

     //dont forget to dispose the workbook
     workbook.dispose();
    }
   }
  } catch (FileNotFoundException e) {
   e.printStackTrace();
  } catch (IOException ex) {
   ex.printStackTrace();
  } catch (ParseException | SQLException ex) {
   ex.printStackTrace();
  } finally {
   if (conn != null && !conn.isClose()) {
    try {
     conn.close();
    } catch (SQLException ex) {}
   }
  }

  return "SUCCESSFUL";

 }

}

Hope it can be help 🙂

How To Log SOAP Request and Response with Log4j in Axis 1.x

Sometimes we want to log the request that we send to server and the response from server as well. Log4j is one of the library that can help us for this kind of requirement.

First, create class that extend BasicHandler class and implements the invoke method just like this.


package com.ariestania.client.logger;

import org.apache.axis.AxisFault;
import org.apache.axis.MessageContext;
import org.apache.axis.handlers.BasicHandler;
import org.apache.commons.logging.LogFactory;

/**
 * @author ariestania.winda
 */
public class SoapLogHandler extends BasicHandler {

    @Override
    public void invoke(MessageContext mc) throws AxisFault {
        if (mc.getResponseMessage() != null && mc.getResponseMessage().getSOAPPartAsString() != null) {
            String resMsg = mc.getResponseMessage().getSOAPPartAsString();
            //print response on console
            System.out.println("Response: \r\n" + resMsg);
            //print response on log file
            LogFactory.getLog("bohayMessage").info("Response: " + resMsg);
        } else if (mc.getRequestMessage() != null && mc.getRequestMessage().getSOAPPartAsString() != null) {
            String reqMsg = mc.getRequestMessage().getSOAPPartAsString();
            //print request on console
            System.out.println("Request: \r\n" + reqMsg);
            //print request on log file
            LogFactory.getLog("bohayMessage").info("Request: " + reqMsg);
        }
    }
}

Continue reading “How To Log SOAP Request and Response with Log4j in Axis 1.x”

How To Create Simple Web Service Using Netbeans as IDE

This time, I use Netbeans 8.1 and tomcat 8.0.27 as the server. You can choose other version if you want.

Here is step by step to create the web service using Netbeans as the IDE:

Create new java web project. Choose the server and java EE version that you want. Click Finish.

Right click on the project then choose new -> web service. Here my project hierarchy after add new web service.

Add the operation by right click on web service class -> add operation.


package com.ariestania.example;

import javax.jws.WebService;
import javax.jws.WebMethod;
import javax.jws.WebParam;

/**
 * @author ariestania.winda
 */
@WebService(serviceName = "HelloBohayWebService")
public class HelloBohayWebService {

    @WebMethod(operationName = "hello")
    public String hello(@WebParam(name = "name") String txt) {
        return "Hello " + txt + " !";
    }

    @WebMethod(operationName = "doSummary")
    public int doSummary(@WebParam(name = "valOne") int valOne, @WebParam(name = "valTwo") int valTwo) {
        return valOne + valTwo;
    }

}

Continue reading “How To Create Simple Web Service Using Netbeans as IDE”

How To Solve Unable to find required classes (javax.activation.DataHandler and javax.mail.internet.MimeMultipart). Attachment support is disabled

I tried to create simple web service as server and client as well. But when I tried to run the operation as client, I got error:

Unable to find required classes (javax.activation.DataHandler and javax.mail.internet.MimeMultipart). Attachment support is disabled

After some google, I realized that I need to add 2 libraries on my project javax.mail.jar and activation.jar. So I add those libraries to my client and server project. I also add those libraries to my tomcat lib as well. Booms..!! the error has been solved. Thanks to you who give the advice on stackoverflow.. 🙂

How To Set Default Selection for f:selectItem within h:selectOneMenu

Sometimes we want to set default value for our combo box in the page. On HTML we only need to add attribute “selected” on the options of <select> element that we choose to be the default. But will be different on JSF since we can not add “selected” attribute to the option that generated by the bean objects. Here is my colleague do for this case and might be useful for you and me in the future:

<h:selectOneMenu id="myFormOptions" value="#{myBean.dudu}">
	<!-- make the default using selectItem tag -->                             
	<f:selectItem itemLabel="Default Value" itemValue="theDefaultVal" />
	<!-- this are the other options -->
	<f:selectItems value="#{myBean.lulu}" />
</h:selectOneMenu>

Put the default value into selectItem tag and the other options on selectItems tag just like above code. Hope this can be help 🙂