Package flex.remoteObjectTest

Source Code of flex.remoteObjectTest.RemoteJava

package flex.remoteObjectTest;

import java.math.BigDecimal;
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.flex.common.EconomicTable;
import com.ordobill.flex.common.FiguresTable;
import com.ordobill.flex.common.ModelingTable;
import com.ordobill.webapp.action.ProjectAction;
import com.ordobill.webapp.beans.Economic;
import com.ordobill.webapp.beans.Figures;
import com.ordobill.webapp.beans.Modeling;
import com.ordobill.webapp.beans.Oreda;
import com.ordobill.webapp.beans.Scenario;
import com.ordobill.webapp.beans.SimulationFields;
import com.ordobill.webapp.beans.SystemImg;
import com.ordobill.webapp.common.SqlMapClientManager;

import flex.messaging.MessageBroker;
import flex.messaging.util.UUIDUtils;


public class RemoteJava {
   
    private Log log = LogFactory.getFactory().getInstance(this.getClass().getName());
    private SqlMapClient sqlMap = SqlMapClientManager.getSqlMapClient();
   
    private MessageBroker msgBroker=MessageBroker.getMessageBroker(null);
    private String clientID = UUIDUtils.createUUID(false);
   
    public RemoteJava(){
        System.out.println("RemoteJava");
    }
   
   
    //로드데이터를 플렉스로 보내주는 메서
    public Modeling[] sendLoadData(String prdUid) throws Exception{
     
      return ModelingTable.modelingList(new Modeling(prdUid));
    }
   
    public Item getItem(){
        Item subItem1 = new Item();
            subItem1.setName("subITem1");
//          subItem1.setSubItems(null);
        Item subItem2 = new Item();
            subItem2.setName("subItem2");
//          subItem2.setSubItems(null);
        Item branchItem = new Item();
            branchItem.setName("branchItem");
            Item subItems[] = {subItem2,subItem2};
            branchItem.setSubItems(subItems);
        return branchItem;
    }
   
    public int setModeling(Modeling[] arr) throws Exception{
        //System.out.println("setItem : "+arr.length);
        int message = -1;
        int proUid = 0;
        try{
            sqlMap.startTransaction();
            message = ModelingTable.modelingPreDelete(sqlMap, arr);
            //log.debug("1:"+message);
            if(message < 0){
                return message;
            }
           
            message = ModelingTable.modelingInsert(sqlMap,arr);
            //log.debug("2:"+message);
            if(message < 0){
                return message;
            }
            //log.debug("3:"+message);
            proUid = arr[0].getMoProject();
            sqlMap.insert("Project.projectLogInsert", proUid);
            sqlMap.commitTransaction();
           
        }catch(Exception e){
            System.out.println(e.getMessage());
            log.debug(e.getMessage());
        }finally{
            sqlMap.endTransaction();
        }
       
        return message;
       
    }
   
    public int setScenarioModeling(Scenario[] arr) throws Exception{
        //System.out.println("setItem : "+arr.length);
        int message = -1;
        int proUid = 0;
        try{
            sqlMap.startTransaction();
            message = ModelingTable.SNmodelingDelete(sqlMap, arr);
            //log.debug("1:"+message);
            if(message < 0){
                return message;
            }
           
            message = ModelingTable.SNmodelingInsert(sqlMap,arr);
            //log.debug("2:"+message);
            if(message < 0){
                return message;
            }
            //log.debug("3:"+message);
            //proUid = arr[0].getMoProject();
            //sqlMap.insert("Project.projectLogInsert", proUid);
            sqlMap.commitTransaction();
           
        }catch(Exception e){
            System.out.println(e.getMessage());
            log.debug(e.getMessage());
        }finally{
            sqlMap.endTransaction();
        }
       
        return message;
       
    }
   
   
    public int setEconomic(Economic[] arr) throws Exception{
      //System.out.println("setItem : "+arr.length);
        int message = -1;
        //int proUid = 0;
        try{
            sqlMap.startTransaction();
            message = EconomicTable.EconomicDelete(sqlMap, arr);
            //log.debug("1:"+message);
            if(message < 0){
                return message;
            }
           
            message = EconomicTable.EconomicInsert(sqlMap,arr);
            //log.debug("2:"+message);
            if(message < 0){
                return message;
            }
            //log.debug("3:"+message);
            //proUid = arr[0].getMoProject();
            //sqlMap.insert("Project.projectLogInsert", proUid);
            sqlMap.commitTransaction();
           
        }catch(Exception e){
            System.out.println(e.getMessage());
            log.debug(e.getMessage());
        }finally{
            sqlMap.endTransaction();
        }
       
        return message;
    }
   
    public Economic getEconomic(String _figUid) throws Exception {
      Economic ec = new Economic();
      try
      {
       ec = EconomicTable.Geteconomic(_figUid);
      }catch(Exception e)
      {
        System.out.println(e.getMessage());
            log.debug(e.getMessage());
      }
      if (ec == null) ec = new Economic();
      return ec;
    }
   
    public int setFigures(Figures[] arr) throws Exception{
        log.debug("1.FIgures count is "+arr.length);

        int message = -1;
        try{
            sqlMap.startTransaction();
            message = FiguresTable.figuresDelete(sqlMap, arr);
           
            if(message < 0){
                return message;
            }
            //임시로 널값 처리
            for (int i=0;i<arr.length;i++) {
              if (arr[i].getFigFlaring() == null) {
                arr[i].setFigFlaring(new BigDecimal(0));
             
            }
           
            message = FiguresTable.figuresInsert(sqlMap, arr);
            log.debug(message);
            if(message < 0){
                return message;
            }
            sqlMap.commitTransaction();
        }catch(Exception e){
            System.out.println(e.getMessage());
            log.debug(e.getMessage());           
        }finally{
            sqlMap.endTransaction();
        }
       
        return message;
    }
   
    public int deleteFigure(int figUid) throws Exception {
       int message = -1;
      
       try{
           sqlMap.startTransaction();
           message =  FiguresTable.figursDelete(sqlMap, figUid);
          
           if(message < 0){
               return message;
           }
          
           sqlMap.commitTransaction();
       }catch(Exception e){
           System.out.println(e.getMessage());
           log.debug(e.getMessage());
       }finally{
           sqlMap.endTransaction();
       }
      
       return message;
    }
   
    public Figures[] getFigures(int projectUid, String figEqUid) throws Exception {
        return FiguresTable.figuresList(projectUid, figEqUid);
    }
   
    public SimulationFields[] getSimulationFigures(String sessionId){
        log.debug("Parameter Session Id is :"+sessionId);
        SimulationFields[] simFields = ProjectAction.simulationArr.get(sessionId);
        ProjectAction.simulationArr.remove(sessionId);
        return simFields;
    }
 
  @SuppressWarnings("unchecked")
    public String[] sendIconImgToFlex() throws Exception{
    ArrayList<SystemImg> imgList = (ArrayList<SystemImg>) sqlMap.queryForList("SystemImg.list", new SystemImg());
    String[] imgName = new String[imgList.size()];
    int _idx = 0;
    for(SystemImg img : imgList){
        imgName[_idx] = img.getSysimgFile();
        _idx++;
    }
   
    return imgName;
  }
 
  @SuppressWarnings("unchecked")
  public String getOredaDataXML() throws Exception {
    String xml = "";
    int controlNum = 0;
    int categoryUid = 0; // db 검색 pk 0일경우 전체 검색 0< 경우 단일row 검색
    Oreda _Oreda = new Oreda();
    _Oreda.setCategoryUid(categoryUid);
   
    ArrayList<Oreda> tableList = (ArrayList<Oreda>) sqlMap.queryForList("Oreda.tableList", _Oreda);
   
   
    if (tableList.size()>0) {
      xml = "<oreda label='MACHINERY' key='0'>";
      for (int i=0;i<tableList.size();i++) {
        if (controlNum > tableList.get(i).getCateDepth()) {
          for (int j=0;j<(controlNum-tableList.get(i).getCateDepth())+1;j++) {
            xml += "</oreda>";
          }
        } else if (controlNum == tableList.get(i).getCateDepth()) {
          xml += "</oreda>";
        }
        if (tableList.get(i).getDelYN().equals("Y")) {
          xml += "<data label='"+tableList.get(i).getThisName()+"' key='"+tableList.get(i).getCategoryUid()+"'></data>";
          controlNum = tableList.get(i).getCateDepth()-1;
        } else {
          xml += "<oreda label='"+tableList.get(i).getThisName()+"' key='"+tableList.get(i).getCategoryUid()+"'>";
          controlNum = tableList.get(i).getCateDepth();
        }
      }
      for (int j=0;j<controlNum;j++) {
        xml += "</oreda>";
      }
      xml += "</oreda>";
    }
   
    return xml;
  }
}
TOP

Related Classes of flex.remoteObjectTest.RemoteJava

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.