package kr.co.kihyun.beans.entity;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.io.ByteArrayOutputStream;
import java.io.ByteArrayInputStream;
import java.util.Arrays;

import java.sql.Blob;

import kr.co.kihyun.beans.entity.MDept;
import kr.co.kihyun.beans.entity.MUser;
import kr.co.kihyun.beans.entity.MoumiEntity;
import kr.co.kihyun.beans.entity.SysAuth;
import kr.co.kihyun.beans.entity.TotDoc;
import kr.co.kihyun.beans.entity.TotReport;
import kr.co.kihyun.beans.entity.TotReportProcess;
import kr.co.kihyun.beans.entity.TotReportType;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.jdo.JDOObjectNotFoundException;
import javax.jdo.PersistenceManager;
import javax.jdo.Query;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.NullValue;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import kr.co.kihyun.beans.entity.ecross.IRemotePersistable;
import kr.co.kihyun.beans.entity.util.QueryImpl;
import kr.co.kihyun.io.IUploadable;
import kr.co.kihyun.lang.MString;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import kr.co.kihyun.db.DBManager;
import java.io.File;
import kr.co.kihyun.io.FileUtil;
import kr.co.kihyun.moumi.MoumiConfig;
import java.net.URLDecoder;

public class NoteData  extends DBManager {

   private static final Logger LOG = LoggerFactory.getLogger(NoteData.class);

	private ResultSet rs = null;

	private int count = 0;
    private String note = null;
    private int tCount;

    /******** tmpName 구해오기 ********/
	public void getNoteReson(String docID,String id,String user_id) {
		StringBuilder sql = new StringBuilder(250);
		try {
           sql.append("SELECT CAST(CAST(NOTE AS CLOB(4096)) as varchar(5000)) FROM MOUMI_TOT_REPORT ")
              .append("WHERE DOC_ID = '"+docID+"' AND ID = '"+id+"' AND USER_ID = '"+user_id+"'");
		      rs = execQuery(sql);
			if (rs != null) {
				rs.last();
				count = rs.getRow();
				rs.beforeFirst();
			} else {
				return;
			}

               note  = new String();
                tCount = count;
			for (int i = 0; rs.next(); i++) {
                note = rs.getString(1);
			}

          //System.out.println(sql);

		} catch (SQLException sqlEx) {
			LOG.error("\nSQLState - {}\nMySQL Error Code - {}\nmessage - {}\nsql - {}",
			new Object[] { sqlEx.getSQLState(), sqlEx.getErrorCode(), sqlEx.getMessage()});
			throw new RuntimeException(sqlEx);
		} catch (Exception ex) {
			throw new RuntimeException(ex);
		} finally {
			close(rs);
			execClose();
		}
	}

     public String getNote(){
          return note;
     }

      public int  getCount(){
          return tCount;
      }

}
