package com.chenyang.nse.bussiness.engine.infa.powercenter961.createdata;

import com.chenyang.nse.bussiness.engine.infa.InfoProperty;
import com.chenyang.nse.bussiness.engine.infa.basic.xmlbean.CONFIG;
import com.chenyang.nse.bussiness.engine.infa.basic.xmlbean.FOLDER;
import com.chenyang.nse.bussiness.engine.infa.basic.xmlbean.MAPPING;
import com.chenyang.nse.bussiness.engine.infa.basic.xmlbean.MAPPLET;
import com.chenyang.nse.bussiness.engine.infa.basic.xmlbean.POWERMART;
import com.chenyang.nse.bussiness.engine.infa.basic.xmlbean.REPOSITORY;
import com.chenyang.nse.bussiness.engine.infa.basic.xmlbean.SOURCE;
import com.chenyang.nse.bussiness.engine.infa.basic.xmlbean.TARGET;
import com.chenyang.nse.bussiness.engine.infa.basic.xmlbean.WORKFLOW;
import com.chenyang.nse.bussiness.engine.infa.powercenter961.pubbean.MappingPramaBean;
import com.chenyang.nse.bussiness.engine.infa.powercenter961.pubbean.MappletBean;
import com.chenyang.nse.bussiness.engine.infa.powercenter961.pubtool.ToObjutil;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
import org.springframework.stereotype.Component;

@Component
public class CreateDataCollectiveUtil {
   public void mosaicCreateDataMethod(String taskname, String repositoryName, String dataBaseType, String foldername, String owner, String shaerd, String group, String sdbtype, String sdbname, String sourcename, String sownername, List<String> skytype, List<String> nameList, List<String> typeList, List<String> lengthList, List<String> scalelist, List<String> precisionlist, List<String> tar_skytype, List<String> tar_nameList, List<String> tar_typeList, List<String> tar_lengthList, List<String> tar_scalelist, List<String> tar_precisionlist, String tdbtype, String targetname, String mappingname, String sq_name, List<MappletBean> mapplet, List<MakeMappletBean> mmb, List<String> mtypelist, String workflowname, InfoProperty tengine, List<String> mappletlist, String co_target, List<String> mappinglengthlist, List<MappingPramaBean> paramList, String paramFilepath, String source_ownername, String target_ownername) throws Exception {
      new POWERMART();
      Powermartutil pu = new Powermartutil();
      POWERMART powermart = pu.getPowermart();
      new REPOSITORY();
      Repositoryutil ru = new Repositoryutil();
      REPOSITORY repository = ru.getREPOSITORY(repositoryName, dataBaseType);
      new FOLDER();
      Folderutil fu = new Folderutil();
      FOLDER folder = fu.getFolder(foldername, owner, shaerd, group);
      new SOURCE();
      Sourceutil su = new Sourceutil();
      SOURCE source = su.getSource(sdbtype, sdbname, sourcename, sownername, skytype, nameList, typeList, lengthList, scalelist, precisionlist);
      folder.getFOLDERVERSIONOrCONFIGOrSCHEDULEROrTASKOrSESSIONOrWORKLETOrWORKFLOWOrSOURCEOrTARGETOrTRANSFORMATIONOrMAPPLETOrMAPPINGOrSHORTCUTOrEXPRMACRO().add(source);
      new SOURCE();
      Sourceutil su1 = new Sourceutil();
      List<String> keylist = new ArrayList();
      keylist.add("NOT A KEY");
      List<String> namelist = new ArrayList();
      namelist.add("SEED_COL");
      List<String> typelist = new ArrayList();
      typelist.add("number");
      List<String> lengthlist = new ArrayList();
      lengthlist.add("15");
      List<String> scale = new ArrayList();
      scale.add("0");
      List<String> prec = new ArrayList();
      prec.add("15");
      SOURCE source1 = su1.getSource("Oracle", "DBD_Tab_Seed", "TAB_SEED", "", keylist, namelist, typelist, lengthlist, scale, prec);
      folder.getFOLDERVERSIONOrCONFIGOrSCHEDULEROrTASKOrSESSIONOrWORKLETOrWORKFLOWOrSOURCEOrTARGETOrTRANSFORMATIONOrMAPPLETOrMAPPINGOrSHORTCUTOrEXPRMACRO().add(source1);
      new TARGET();
      Targetutil tu = new Targetutil();
      TARGET target = tu.getTarget(tdbtype, targetname, tar_skytype, tar_nameList, tar_typeList, tar_lengthList, tar_scalelist, tar_precisionlist);
      folder.getFOLDERVERSIONOrCONFIGOrSCHEDULEROrTASKOrSESSIONOrWORKLETOrWORKFLOWOrSOURCEOrTARGETOrTRANSFORMATIONOrMAPPLETOrMAPPINGOrSHORTCUTOrEXPRMACRO().add(target);
      if (mmb != null && mmb.size() > 0) {
         for(int i = 0; i < mmb.size(); ++i) {
            MappletMakingUtil mmu = new MappletMakingUtil();
            MAPPLET mapp = mmu.getMapplet(((MakeMappletBean)mmb.get(i)).getMplt_name(), ((MakeMappletBean)mmb.get(i)).getDataType(), ((MakeMappletBean)mmb.get(i)).getPrecision(), ((MakeMappletBean)mmb.get(i)).getScale(), ((MakeMappletBean)mmb.get(i)).getMb(), ((MakeMappletBean)mmb.get(i)).getMsb(), ((MakeMappletBean)mmb.get(i)).getMspb());
            folder.getFOLDERVERSIONOrCONFIGOrSCHEDULEROrTASKOrSESSIONOrWORKLETOrWORKFLOWOrSOURCEOrTARGETOrTRANSFORMATIONOrMAPPLETOrMAPPINGOrSHORTCUTOrEXPRMACRO().add(mapp);
         }
      }

      new MAPPING();
      MakeDataMappingUtil mu = new MakeDataMappingUtil();
      MAPPING var66 = mu.getMakeDataMapping(mappingname, sq_name, nameList, mtypelist, mappinglengthlist, sourcename, targetname, sdbname, mapplet);
      folder.getFOLDERVERSIONOrCONFIGOrSCHEDULEROrTASKOrSESSIONOrWORKLETOrWORKFLOWOrSOURCEOrTARGETOrTRANSFORMATIONOrMAPPLETOrMAPPINGOrSHORTCUTOrEXPRMACRO().add(var66);
      new CONFIG();
      Configutil cu = new Configutil();
      CONFIG var68 = cu.getConfig();
      folder.getFOLDERVERSIONOrCONFIGOrSCHEDULEROrTASKOrSESSIONOrWORKLETOrWORKFLOWOrSOURCEOrTARGETOrTRANSFORMATIONOrMAPPLETOrMAPPINGOrSHORTCUTOrEXPRMACRO().add(var68);
      new WORKFLOW();
      MakeDataWorkflowUtil wu = new MakeDataWorkflowUtil();
      WORKFLOW workflow = wu.getMakeDataWorkflow(mappingname, workflowname, sourcename, targetname, tengine.getInteservicename(), tengine.getDomainname(), sq_name, mapplet, co_target, sdbname, paramFilepath, source_ownername, target_ownername);
      folder.getFOLDERVERSIONOrCONFIGOrSCHEDULEROrTASKOrSESSIONOrWORKLETOrWORKFLOWOrSOURCEOrTARGETOrTRANSFORMATIONOrMAPPLETOrMAPPINGOrSHORTCUTOrEXPRMACRO().add(workflow);
      repository.getFOLDER().add(folder);
      powermart.getREPOSITORY().add(repository);
      List<Object> alllist = new ArrayList();
      alllist.add(powermart);
      OutputStream f = null;
      OutputStream var69 = new FileOutputStream("C:/infa_work_report/" + taskname + ".xml");
      ToObjutil.marshal("com.chenyang.nse.bussiness.xmlbean", alllist, var69, "");
   }
}
