Package com.ordobill.flex.common

Source Code of com.ordobill.flex.common.FiguresTable

package com.ordobill.flex.common;

import java.util.ArrayList;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.ibatis.sqlmap.client.SqlMapClient;
import com.ordobill.webapp.beans.Figures;
import com.ordobill.webapp.common.SqlMapClientManager;

public class FiguresTable {
    @SuppressWarnings("unused")
    private Log log = LogFactory.getFactory().getInstance(this.getClass().getName());
    private static SqlMapClient sqlMap = SqlMapClientManager.getSqlMapClient();
   
    /**
     * 수치테이블의 데이터를 Array형태로 반환하는 메소드 입니다.
     *
     * @param projectUid 해당 Project의 Uid를 입력합니다.
     * @param figEqUid 호출하고자 하는 수치의 부모 Equipment에 대한 Uid를 입력합니다.
     * @return Figures[]
     * @throws Exception
     */
    @SuppressWarnings("unchecked")
    public static Figures[] figuresList(int projectUid, String figEqUid) throws Exception{

        ArrayList<Figures> getFiguresList = (ArrayList<Figures>) sqlMap.queryForList("Figures.list", new Figures(projectUid, figEqUid, 0));
       
        Figures[] figuresArr = new Figures[getFiguresList.size()];
       
        getFiguresList.toArray(figuresArr);
       
        return figuresArr;
    }
   
    /**
     *
     * 수치테이블의 데이터를 Figures형태로 반환하는 메소드 입니다.
     *
     * @param projectUid 해당 Project의 Uid를 입력합니다.
     * @param figEqUid 호출하고자 하는 수치의 부모 Equipment에 대한 Uid를 입력합니다.
     * @param figSelf 호출하고자 하는 수치의 Uid를 입력합니다.
     * @return Figures
     * @throws Exception
     *
     */
    public static Figures figuresBean(int projectUid, String figEqUid, int figSelf) throws Exception{
        Figures getFigures = (Figures) sqlMap.queryForObject("Figures.list", new Figures(projectUid, figEqUid, figSelf));
        return getFigures;
    }
   
    /**
     *
     * @param sqlMap Transaction 처리가된 sqlMap을 받아 Transaction 처리를 합니다.
     * @param figures
     * @return message : {@code message > 0 : true, message < 0 : false}
     * @throws Exception
     */
    public static int figuresInsert(SqlMapClient sqlMap, Figures[] figures) throws Exception {
        int message = -1;
       
        if(figures.length == 0){
            throw new Exception("Figures[]의 길이가 0입니다.");
        }
       
        if(figures.length > 0){
            for(Figures fig : figures){
                message = (Integer)sqlMap.insert("Figures.figuresInsert", fig);
               
                if(message < 0){
                    return message;
                }
            }
        }
       
        return message;
    }
   
    /**
     *
     * @param sqlMap Transaction 처리가된 sqlMap을 받아 Transaction 처리를 합니다.
     * @param figures
     * @return message : {@code message > 0 : true, message < 0 : false}
     * @throws Exception
     */
    public static int figuresUpdate(SqlMapClient sqlMap, Figures[] figures) throws Exception {
        int message = -1;
       
        if(figures.length == 0){
            throw new Exception("Figures[]의 길이가 0입니다.");
        }
       
        if(figures.length > 0){
            for(Figures fig : figures){
                message = sqlMap.update("Figures.figuresUpdate",fig);
               
                if(message < 0){
                    return message;
                }
            }
        }

        return message;
    }
   
    /**
     *
     * @param sqlMap Transaction 처리가된 sqlMap을 받아 Transaction 처리를 합니다.
     * @param figures
     * @return message : {@code message > 0 : true, message < 0 : false}
     * @throws Exception
     */
    public static int figuresDelete(SqlMapClient sqlMap, Figures[] figures) throws Exception {
        int message = -1;
       
        if(figures.length == 0){
            throw new Exception("Figures[]의 길이가 0입니다.");
        }
       
        if(figures.length > 0){
            //Figures fig = figures[0];
            ArrayList<Figures> _Figures = new ArrayList<Figures>();
            for (int i=0; i<figures.length;i++) {
              _Figures.add(figures[i]);
            }
            message = sqlMap.delete("Figures.figuresPreDelete",_Figures );
           
            if(message < 0){
                return message;
            }
           
        }
       
        return message;
    }
   
    /**
     *
     * @param sqlMap Transaction 처리가된 sqlMap을 받아 Transaction 처리를 합니다.
     * @param figUid Figures ID
     * @return message : {@code message > 0 : true, message < 0 : false}
     * @throws Exception
     */
    public static int figursDelete(SqlMapClient sqlMap, int figUid) throws Exception {
        int message = -1;
       
        if(figUid == 0){
            throw new Exception("figUid값이 0입니다.");
        }
       
        if(figUid != 0){
            message = sqlMap.delete("Figures.figuresDelete", new Figures(figUid));
        }
       
        return message;
    }
}
TOP

Related Classes of com.ordobill.flex.common.FiguresTable

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.