Java tutorial
package com.castis.xylophone.adsmadapter.connectors; import java.sql.Timestamp; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Set; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; import com.castis.tambourine.bizobject.constants.InventoryConstants; import com.castis.tambourine.bizobject.inventory.TimeAxisTree; import com.castis.tambourine.bizobject.ktadsm.ADSMJobNameType; import com.castis.tambourine.bizobject.ktadsm.ADSMSchedulerStatus; import com.castis.tambourine.bizobject.ktadsm.CategoryIdForDisableContent; import com.castis.tambourine.bizobject.ktadsm.ClientUIData; import com.castis.tambourine.bizobject.ktadsm.ImportSyncVersion; import com.castis.tambourine.bizobject.ktadsm.InventoryBox; import com.castis.tambourine.bizobject.ktadsm.TargetMap; import com.castis.tambourine.bizobject.ktadsm.cuetone.ChannelScheduleInfo; import com.castis.tambourine.bizobject.ktadsm.cuetone.ChannelScheduleMeta; import com.castis.tambourine.bizobject.mapper.Mapper; import com.castis.tambourine.bizobject.policy.PolicyGenericAxisItem; import com.castis.tambourine.converter.Converter; import com.castis.tambourine.dto.cueTone.ChannelMetaDTO; import com.castis.tambourine.dto.inventory.AxisTreeDTO; import com.castis.tambourine.dto.inventory.GenericAxisItemIDSet; import com.castis.tambourine.dto.inventory.NodeDTO; import com.castis.tambourine.dto.ktadsm.ADSMSchedulerLogDTO; import com.castis.tambourine.dto.ktadsm.AxisTreeLogDTO; import com.castis.tambourine.dto.ktadsm.CategoryDTO; import com.castis.tambourine.dto.ktadsm.CategoryDataDTO; import com.castis.tambourine.dto.ktadsm.ChannelScheduleInfoDTO; import com.castis.tambourine.dto.ktadsm.ChannelServiceDTO; import com.castis.tambourine.dto.ktadsm.ClientUIDataDTO; import com.castis.tambourine.dto.ktadsm.ContentDataDTO; import com.castis.tambourine.dto.ktadsm.ContentGroupDTO; import com.castis.tambourine.dto.ktadsm.FeSyncNoticeboardDTO; import com.castis.tambourine.dto.ktadsm.GenericAxisItemIDDTO; import com.castis.tambourine.dto.ktadsm.InventoryBoxDTO; import com.castis.tambourine.dto.ktadsm.InventoryDataDTO; import com.castis.tambourine.dto.ktadsm.NodeDataDTO; import com.castis.tambourine.dto.ktadsm.NodeInfoLicenseDTO; import com.castis.tambourine.dto.ktadsm.NodeInfoWithLinkNodeDTO; import com.castis.tambourine.dto.ktadsm.RegionDataDTO; import com.castis.tambourine.dto.ktadsm.SubInventoryDTO; import com.castis.tambourine.dto.ktadsm.SubInventoryMemberDTO; import com.castis.tambourine.dto.ktadsm.TimeDTO; import com.castis.tambourine.dto.ktadsm.TimeDefineDTO; import com.castis.tambourine.dto.ktadsm.VirtualCategoryDefineDTO; import com.castis.tambourine.dto.ktadsm.axistree.AxisTreeNodeDTO; import com.castis.tambourine.dto.policy.CategoryInfoForDiableContentDTO; import com.castis.tambourine.enumeration.ClientUIType; import com.castis.tambourine.enumeration.DeleteDataType; import com.castis.tambourine.enumeration.FeSyncNoticeboardStatus; import com.castis.tambourine.enumeration.InventoryType; import com.castis.tambourine.enumeration.MapperAxisType; import com.castis.tambourine.enumeration.PlacementOpportunityTypeEnum; import com.castis.tambourine.enumeration.Platform; import com.castis.tambourine.enumeration.PriceTypeEnum; import com.castis.tambourine.enumeration.SyncDataType; import com.castis.tambourine.enumeration.SyncType; import com.castis.tambourine.enumeration.TreeType; import com.castis.tambourine.exception.CanNotFoundExIdWrappingException; import com.castis.tambourine.exception.WrappingException; import com.castis.tambourine.inventorydomain.bizcomp.export.IChannelBizComp; import com.castis.tambourine.inventorydomain.bizcomp.export.IClientUIBizComp; import com.castis.tambourine.inventorydomain.bizcomp.export.IImportSyncVersionBizComp; import com.castis.tambourine.inventorysysdomain.syscomp.export.IInventoryCubeSysComp; import com.castis.tambourine.inventorysysdomain.syscomp.export.IInventoryExportSysCompForAdapter; import com.castis.tambourine.logger.TheLogger; import com.castis.tambourine.util.DateUtil; import com.castis.xylophone.adsmadapter.common.enumeration.FileResultCode; import com.castis.xylophone.adsmadapter.common.enumeration.InputDataType; import com.castis.xylophone.adsmadapter.common.exception.CiRuntimeException; import com.castis.xylophone.adsmadapter.common.util.ResultFileUtil; import com.castis.xylophone.adsmadapter.convert.axistree.ConvertChannelAxisTreeDTO; import com.castis.xylophone.adsmadapter.convert.axistree.ConvertRegionAxisTreeDTO; import com.castis.xylophone.adsmadapter.filePolling.FilePolling; /** * @author Leftie */ public class TambourineConnector { static final String name = "TambourineConnector"; IInventoryCubeSysComp invenCubeSysComp; IInventoryExportSysCompForAdapter inventoryExportSysCompForAdapter; IImportSyncVersionBizComp importSyncVersionBizComp; IChannelBizComp channelBizComp; IClientUIBizComp clientUIBizComp; public String clientID = "ADSMAdapter"; // public final static String OPPORTUNITY_TREE_NAME = "opportunity_tree"; // public final static String SLOT_TREE_NAME = "slot_tree"; public final static String PRICE_TREE_NAME = "price_tree"; static final Log log = LogFactory.getLog(TambourineConnector.class); //---------------------------------------------------------- // Constructor and destroyer public TambourineConnector() { log.info(" ### " + name + " was created."); } public void close() { log.info(" # " + name + " is shutting down."); } public IInventoryCubeSysComp getInvenCubeSysComp() { return invenCubeSysComp; } public void setInvenCubeSysComp(IInventoryCubeSysComp invenCubeSysComp) { this.invenCubeSysComp = invenCubeSysComp; } public void setInventoryExportSysCompForAdapter( IInventoryExportSysCompForAdapter inventoryExportSysCompForAdapter) { this.inventoryExportSysCompForAdapter = inventoryExportSysCompForAdapter; } public IImportSyncVersionBizComp getImportSyncVersionBizComp() { return importSyncVersionBizComp; } public void setImportSyncVersionBizComp(IImportSyncVersionBizComp importSyncVersionBizComp) { this.importSyncVersionBizComp = importSyncVersionBizComp; } public void setChannelBizComp(IChannelBizComp channelBizComp) { this.channelBizComp = channelBizComp; } public void setClientUIBizComp(IClientUIBizComp clientUIBizComp) { this.clientUIBizComp = clientUIBizComp; } public int registerRegionAxisTree(AxisTreeDTO axisTreeDTO, Date date) { try { if (axisTreeDTO != null) return inventoryExportSysCompForAdapter.registerRegionAxisTree(axisTreeDTO, date, DateUtil.string2Date("9999-12-31")); else { log.error("Fail to get axisTreeDTO. "); return InventoryConstants.AXIS_TREE__INVALID_TREE_ID; } } catch (Exception e) { log.error("Fail to register RegionAxisTree. Exception Type : Exception | " + e.getMessage()); return InventoryConstants.AXIS_TREE__INVALID_TREE_ID; } } public int registerCategoryAxisTree(AxisTreeDTO axisTreeDTO, Date date) { try { if (axisTreeDTO != null) return inventoryExportSysCompForAdapter.registerCategoryAxisTree(axisTreeDTO, date, DateUtil.string2Date("9999-12-31")); else { log.error("Fail to get axisTreeDTO. "); return InventoryConstants.AXIS_TREE__INVALID_TREE_ID; } } catch (Exception e) { log.error("Fail to register CategoryAxisTree. Exception Type : Exception | ", e); return InventoryConstants.AXIS_TREE__INVALID_TREE_ID; } } @Transactional(rollbackFor = Exception.class) public int generateTree(String treeName, String rootNodeName, TreeType treeType, String publisher, Platform platformType) { int treeId = inventoryExportSysCompForAdapter.generateTree(treeName, rootNodeName, treeType, publisher, platformType); insertTreeLogNSyncNoticeboard(treeId, treeType, treeName, null, null, null); return treeId; } @Transactional(rollbackFor = Exception.class) public int generateContentTree(String contentTreeName, String rootNodeName, String rootContentParent, String publisher, Platform platformType) { int treeId = inventoryExportSysCompForAdapter.generateContentTree(contentTreeName, rootNodeName, rootContentParent); insertTreeLogNSyncNoticeboard(treeId, TreeType.VOD_CONTENTS_AXIS, contentTreeName, null, publisher, platformType); return treeId; } public int registerContentAxisTree(AxisTreeDTO axisTreeDTO, Date date) { try { if (axisTreeDTO != null) return inventoryExportSysCompForAdapter.registerContentAxisTree(axisTreeDTO, date, DateUtil.string2Date("9999-12-31")); else { log.error("Fail to get axisTreeDTO. "); return InventoryConstants.AXIS_TREE__INVALID_TREE_ID; } } catch (Exception e) { log.error("Fail to register ContentAxisTree. Exception Type : Exception | " + e.getMessage()); return InventoryConstants.AXIS_TREE__INVALID_TREE_ID; } } public int registerAxisTree(AxisTreeDTO axisTreeDTO, Date date, TreeType treeType) { try { if (axisTreeDTO != null) return inventoryExportSysCompForAdapter.registerAxisTree(axisTreeDTO, date, DateUtil.string2Date("9999-12-31"), treeType); else { log.error("Fail to get axisTreeDTO. "); return InventoryConstants.AXIS_TREE__INVALID_TREE_ID; } } catch (Exception e) { log.error("Fail to register AxisTree. Exception Type : Exception | " + e.getMessage()); return InventoryConstants.AXIS_TREE__INVALID_TREE_ID; } } public int registerUserAxisTree(AxisTreeDTO axisTreeDTO, Date date) { try { if (axisTreeDTO != null) return inventoryExportSysCompForAdapter.registerUserAxisTree(axisTreeDTO, date, DateUtil.string2Date("9999-12-31")); else { log.error("Fail to get axisTreeDTO. "); return InventoryConstants.AXIS_TREE__INVALID_TREE_ID; } } catch (Exception e) { log.error("Fail to register UserAxisTree. Exception Type : Exception | " + e.getMessage()); return InventoryConstants.AXIS_TREE__INVALID_TREE_ID; } } @Transactional(rollbackFor = Exception.class) public void generatePriceTree() { try { if (getAxisTreeId(TreeType.PRICE_AXIS, PRICE_TREE_NAME, null, null, false) <= 0) { log.info("### Generate Price Tree"); int treeId = inventoryExportSysCompForAdapter.generatePriceTree(PRICE_TREE_NAME); if (treeId > 0) { insertTreeLogNSyncNoticeboard(treeId, TreeType.PRICE_AXIS, PRICE_TREE_NAME, null, null, null); inventoryExportSysCompForAdapter.saveClosureNodes(treeId); } } } catch (Exception e) { log.error("Fail to paidTypeTree. Exception Type : Exception | ", e); return; } } public boolean insertCategoryData(List<CategoryDataDTO> categoryDataList, ADSMSchedulerLogDTO schedulerLog, String resultDirectory, String dataFileName, InputDataType inputDataType, DeleteDataType deleteData, ADSMJobNameType jobType) { boolean result = false; ADSMSchedulerLogDTO deleteSchedulerLog = null; try { deleteSchedulerLog = startLog(ADSMJobNameType.COLLECT_DELETE_DATA.name(), deleteData.name()); if (deleteSchedulerLog == null) { result = false; ResultFileUtil.writeResultFile(dataFileName, "deleteSchedulerLog ?? .", FileResultCode.RESULT_FAIL.getValue(), resultDirectory, inputDataType); } else { inventoryExportSysCompForAdapter.insertCategoryDataList(categoryDataList, schedulerLog, deleteData.name(), deleteSchedulerLog.getId(), jobType); schedulerLog.setSchedulerStatus(ADSMSchedulerStatus.SUCCESS); deleteSchedulerLog.setSchedulerStatus(ADSMSchedulerStatus.SUCCESS); endLog(deleteSchedulerLog); result = true; ResultFileUtil.writeResultFile(dataFileName, "? ? . [size:" + categoryDataList.size() + "]", FileResultCode.RESULT_OK.getValue(), resultDirectory, inputDataType); } } catch (Exception e) { //log.error("",e); //TheLogger.getWriter().error(schedulerLog.getParam() + " Category Data insert "); schedulerLog.setMessage(e.getMessage()); schedulerLog.setSchedulerStatus(ADSMSchedulerStatus.FAIL); StackTraceElement[] stackTraces = e.getStackTrace(); if (stackTraces.length > 0) { String failProcess = stackTraces[0].getClassName() + " - " + stackTraces[0].getMethodName() + "(" + stackTraces[0].getLineNumber() + ")"; schedulerLog.setFailProcess(failProcess); deleteSchedulerLog.setFailProcess(failProcess); } deleteSchedulerLog.setMessage(e.getMessage()); deleteSchedulerLog.setSchedulerStatus(ADSMSchedulerStatus.FAIL); endLog(deleteSchedulerLog); result = false; ResultFileUtil.writeResultFile(dataFileName, e.getMessage(), FileResultCode.RESULT_FAIL.getValue(), resultDirectory, inputDataType); } return result; } public boolean insertContentData(List<ContentDataDTO> contentDataList, ADSMSchedulerLogDTO schedulerLog, String resultDir, String dataFileName) { boolean result = false; ADSMSchedulerLogDTO deleteSchedulerLog = null; try { deleteSchedulerLog = startLog(ADSMJobNameType.COLLECT_DELETE_DATA.name(), DeleteDataType.CONTENT_DATA.name()); if (deleteSchedulerLog == null) { result = false; ResultFileUtil.writeResultFile(dataFileName, "deleteSchedulerLog ?? .", FileResultCode.RESULT_FAIL.getValue(), resultDir, InputDataType.INVENTORY_DAT); } else { inventoryExportSysCompForAdapter.insertContentDataList(contentDataList, schedulerLog, DeleteDataType.CONTENT_DATA.name(), deleteSchedulerLog.getId()); schedulerLog.setSchedulerStatus(ADSMSchedulerStatus.SUCCESS); deleteSchedulerLog.setSchedulerStatus(ADSMSchedulerStatus.SUCCESS); endLog(deleteSchedulerLog); result = true; ResultFileUtil.writeResultFile(dataFileName, "? ? . [size:" + contentDataList.size() + "]", FileResultCode.RESULT_OK.getValue(), resultDir, InputDataType.INVENTORY_DAT); } } catch (Exception e) { //log.error("",e); //TheLogger.getWriter().error(schedulerLog.getParam() + " Content Data insert "); schedulerLog.setMessage(e.getMessage()); schedulerLog.setSchedulerStatus(ADSMSchedulerStatus.FAIL); StackTraceElement[] stackTraces = e.getStackTrace(); if (stackTraces.length > 0) { String failProcess = stackTraces[0].getClassName() + " - " + stackTraces[0].getMethodName() + "(" + stackTraces[0].getLineNumber() + ")"; schedulerLog.setFailProcess(failProcess); deleteSchedulerLog.setFailProcess(failProcess); } deleteSchedulerLog.setMessage(e.getMessage()); deleteSchedulerLog.setSchedulerStatus(ADSMSchedulerStatus.FAIL); endLog(deleteSchedulerLog); result = false; ResultFileUtil.writeResultFile(dataFileName, e.getMessage(), FileResultCode.RESULT_FAIL.getValue(), resultDir, InputDataType.INVENTORY_DAT); } return result; } public boolean insertNodeData(List<NodeDataDTO> nodeDataList, ADSMSchedulerLogDTO schedulerLog) { boolean result = false; try { inventoryExportSysCompForAdapter.insertNodeDataList(nodeDataList, schedulerLog); schedulerLog.setSchedulerStatus(ADSMSchedulerStatus.SUCCESS); result = true; } catch (Exception e) { //log.error("",e); TheLogger.getWriter().error(schedulerLog.getParam() + " Node Data insert "); schedulerLog.setMessage(e.getMessage()); schedulerLog.setSchedulerStatus(ADSMSchedulerStatus.FAIL); StackTraceElement[] stackTraces = e.getStackTrace(); if (stackTraces.length > 0) { schedulerLog.setFailProcess(stackTraces[0].getClassName() + " - " + stackTraces[0].getMethodName() + "(" + stackTraces[0].getLineNumber() + ")"); } result = false; } return result; } public boolean insertRegionData(List<RegionDataDTO> regionDataList, ADSMSchedulerLogDTO schedulerLog, String resultDir, String dataFileName) { boolean result = false; try { inventoryExportSysCompForAdapter.insertRegionDataList(regionDataList, schedulerLog); schedulerLog.setSchedulerStatus(ADSMSchedulerStatus.SUCCESS); result = true; ResultFileUtil.writeResultFile(dataFileName, "? ? . [size:" + regionDataList.size() + "]", FileResultCode.RESULT_OK.getValue(), resultDir, InputDataType.INVENTORY_DAT); } catch (Exception e) { //log.error("",e); schedulerLog.setMessage(e.getMessage()); schedulerLog.setSchedulerStatus(ADSMSchedulerStatus.FAIL); StackTraceElement[] stackTraces = e.getStackTrace(); if (stackTraces.length > 0) { schedulerLog.setFailProcess(stackTraces[0].getClassName() + " - " + stackTraces[0].getMethodName() + "(" + stackTraces[0].getLineNumber() + ")"); } result = false; ResultFileUtil.writeResultFile(dataFileName, e.getMessage(), FileResultCode.RESULT_FAIL.getValue(), resultDir, InputDataType.INVENTORY_DAT); } return result; } /** * ? : ?, dat ?? * @param inventoryDataDTOList dat * @param schedulerLog * @param previousSuccessLogList * @throws Exception */ public void insertInventoryData(List<InventoryDataDTO> inventoryDataDTOList, ADSMSchedulerLogDTO schedulerLog, List<ADSMSchedulerLogDTO> previousSuccessLogList) throws Exception { ADSMSchedulerLogDTO deleteSchedulerLog = null; try { int deleteSchedulerLogId = -1; if (previousSuccessLogList != null && previousSuccessLogList.size() > 0) { deleteSchedulerLog = startLog(ADSMJobNameType.COLLECT_DELETE_DATA.name(), DeleteDataType.INVENTORY_DATA.name()); if (deleteSchedulerLog == null) { throw new CiRuntimeException("deleteSchedulerLog ? "); } else { deleteSchedulerLogId = deleteSchedulerLog.getId(); } } inventoryExportSysCompForAdapter.insertInventoryData(inventoryDataDTOList, schedulerLog, deleteSchedulerLogId, previousSuccessLogList); schedulerLog.setSchedulerStatus(ADSMSchedulerStatus.SUCCESS); if (deleteSchedulerLog != null) { deleteSchedulerLog.setSchedulerStatus(ADSMSchedulerStatus.SUCCESS); } } catch (Exception e) { if (deleteSchedulerLog != null) { deleteSchedulerLog.setMessage(e.getMessage()); deleteSchedulerLog.setSchedulerStatus(ADSMSchedulerStatus.FAIL); StackTraceElement[] stackTraces = e.getStackTrace(); if (stackTraces.length > 0) { String failProcess = stackTraces[0].getClassName() + " - " + stackTraces[0].getMethodName() + "(" + stackTraces[0].getLineNumber() + ")"; deleteSchedulerLog.setFailProcess(failProcess); } } throw e; } finally { if (deleteSchedulerLog != null) endLog(deleteSchedulerLog); } } public VirtualCategoryDefineDTO getVirtualCategoryDefineList(Date date) { return inventoryExportSysCompForAdapter.getVirtualCategoryDefine(date); } public List<CategoryDTO> getCategoryListFromInventoryBox(Date date) { return inventoryExportSysCompForAdapter.getCategoryListFromInventoryBox(date); } public List<CategoryDataDTO> getCategoryData() { return inventoryExportSysCompForAdapter.getCategoryData(); } public List<CategoryDataDTO> getCategoryData(ADSMJobNameType srcJopType) { return inventoryExportSysCompForAdapter.getCategoryData(srcJopType); } public List<ContentDataDTO> getContentData() { return inventoryExportSysCompForAdapter.getContentData(); } public List<NodeDataDTO> getNodeData() { return inventoryExportSysCompForAdapter.getNodeData(); } public List<RegionDataDTO> getRegionData() { return inventoryExportSysCompForAdapter.getRegionData(); } public List<RegionDataDTO> getRegionDataBySchedulerLogId(int schedulerLogId) { return inventoryExportSysCompForAdapter.getRegionDataBySchedulerLogId(schedulerLogId); } public List<CategoryDataDTO> getCategoryDataByParentId(int scheduleLogId, String parentId) { return inventoryExportSysCompForAdapter.getCategoryDataByParentId(scheduleLogId, parentId); } public List<CategoryDataDTO> getCategoryDataByCcSeriesId(int scheduleLogId, String ccSeriesId) { return inventoryExportSysCompForAdapter.getCategoryDataByCcSeriesId(scheduleLogId, ccSeriesId); } public List<InventoryDataDTO> getInventoryDataByParentId(int scheduleLogId, String parentId) { return inventoryExportSysCompForAdapter.getInventoryDataByParentId(scheduleLogId, parentId); } public ADSMSchedulerLogDTO getLatestADSMSchedulerLog(String jobName) { return inventoryExportSysCompForAdapter.getLatestADSMSchedulerLog(jobName); } public int getPreviousSuccessSchedulerLogId(String jobName, String message) { int previousSuccessSchedulerLogId = -1; try { ADSMSchedulerLogDTO previousSuccessSchedulerLog = inventoryExportSysCompForAdapter .getLatestADSMSchedulerLogWithMessage(jobName, message); if (previousSuccessSchedulerLog != null) previousSuccessSchedulerLogId = previousSuccessSchedulerLog.getId(); } catch (Exception e) { log.error("?? ? [jobName:" + jobName + ", message:" + message + "] ? ? ."); } return previousSuccessSchedulerLogId; } public ADSMSchedulerLogDTO getLatestADSMSchedulerLogwithMessage(String jobName, String message) { return inventoryExportSysCompForAdapter.getLatestADSMSchedulerLogWithMessage(jobName, message); } public ADSMSchedulerLogDTO getLatestADSMSchedulerLog(String jobName, String message, String param) { return inventoryExportSysCompForAdapter.getLatestADSMSchedulerLog(jobName, message, param); } public List<ADSMSchedulerLogDTO> getADSMSchedulerLogList(String jobName, String message) { return inventoryExportSysCompForAdapter.getADSMSchedulerLogList(jobName, message); } public ADSMSchedulerLogDTO getLatestADSMSchedulerLogWithJobList(List<String> jobNames) { return inventoryExportSysCompForAdapter.getLatestADSMSchedulerLogWithJobList(jobNames); } public List<String> findDisablePolicyContentLinkTreeId() { return inventoryExportSysCompForAdapter.findDisablePolicyContentLinkTreeId(); } public int getInventoryBoxLogId(Date date) { InventoryBox inventoryBox = inventoryExportSysCompForAdapter.getLastInventoryBoxID(date, null); int inventoryLogId = -1; if (inventoryBox != null) { inventoryLogId = inventoryBox.getAdsmSchedulerLog(); } return inventoryLogId; } public ADSMSchedulerLogDTO findNewMgadScheduleLog() { try { // ? ? mgad xml ?? . ADSMSchedulerLogDTO mgadLog = getLatestADSMSchedulerLog(ADSMJobNameType.ADS_INFO.name()); ADSMSchedulerLogDTO adScheduleLog = getLatestADSMSchedulerLog(ADSMJobNameType.AD_SCHEDULE.name()); if (mgadLog != null && adScheduleLog != null) { int mgadLogId = mgadLog.getId(); int latestMgadLogId = Integer.parseInt((String) adScheduleLog.getParamValue("mgadLogId")); if (latestMgadLogId == mgadLogId) //? ?? ? return null; } log.info("new mgad schedulelog - " + mgadLog); return mgadLog; } catch (Exception e) { log.error("find NewMgadScheduleLog fail", e); return null; } } public ADSMSchedulerLogDTO findNewExportScheduleLog(List<String> jobNames) { try { // ? ? ?? . ADSMSchedulerLogDTO latestJobLog = getLatestADSMSchedulerLogWithJobList(jobNames); ADSMSchedulerLogDTO adScheduleLog = getLatestADSMSchedulerLog(ADSMJobNameType.AD_SCHEDULE.name()); if (latestJobLog != null && adScheduleLog != null) { int latestJobLogId = latestJobLog.getId(); int latestMgadLogId = Integer.parseInt((String) adScheduleLog.getParamValue("ScheduleLogId")); if (latestMgadLogId == latestJobLogId) //? ?? ? return null; } log.info(" - " + latestJobLog); return latestJobLog; } catch (Exception e) { log.error("find findNewExportScheduleLog fail", e); return null; } } /*** * ?? * @param jobName ? ?? * @param stayPeriodDayMap ?? ? * @return false : ? ? , true : ? ? */ public boolean deleteDataJob(String jobName, Map<String, Date> stayPeriodDayMap, int deleteCampaignSize, int deleteDataSize) { try { ADSMSchedulerLogDTO schedulerLogDTO = null; // ?? ? ? DATA ? for (String key : stayPeriodDayMap.keySet()) { ADSMSchedulerLogDTO deleteSchedulerLogDTO = inventoryExportSysCompForAdapter .getADSMSchedulerLogByDate(jobName, ADSMSchedulerStatus.SUCCESS, stayPeriodDayMap.get(key), key); if (deleteSchedulerLogDTO == null) continue; else if (schedulerLogDTO == null) schedulerLogDTO = deleteSchedulerLogDTO; else schedulerLogDTO = (schedulerLogDTO.getId() > deleteSchedulerLogDTO.getId()) ? deleteSchedulerLogDTO : schedulerLogDTO; } if (schedulerLogDTO == null) return false; log.info("Start deleteDataJob schedulerLog Parameter - " + schedulerLogDTO.getParam() + ", schedulerLogID - " + schedulerLogDTO.getId() + ", pagingInfo - " + schedulerLogDTO.getMessage()); inventoryExportSysCompForAdapter.deleteData(schedulerLogDTO, deleteCampaignSize, deleteDataSize); } catch (Exception e) { log.error("deleteDataJob Fail. (jobName-" + jobName + ") Restored to the previous data Message - " + e.getMessage()); } return true; } public InventoryBoxDTO findNewInventoryBox(ADSMJobNameType jobName, String sizePolicyType) { int inventoryLogId = -1; InventoryBoxDTO inventoryBox; try {// inventoryBox id . InventoryBox inventoryBoxId = inventoryExportSysCompForAdapter.getLastInventoryBoxID(new Date(), jobName); if (inventoryBoxId != null) inventoryLogId = inventoryBoxId.getAdsmSchedulerLog(); // inventoryBox? ?? ?. ADSMSchedulerLogDTO inventorySizePolicyLog = getLatestADSMSchedulerLog(sizePolicyType); if (inventorySizePolicyLog != null) { int latestInventoryLogId = Integer .parseInt((String) inventorySizePolicyLog.getParamValue("inventoryLogId")); if (latestInventoryLogId == inventoryLogId) //? ?? ? return null; //? ? . } inventoryBox = inventoryExportSysCompForAdapter.findInventoryBox(inventoryLogId); if (inventoryBox != null) { inventoryBox.setSchedulerLogId(inventoryLogId); log.info("inventoryBox:" + inventoryBox.getInventoryVer() + ", scheduleLogId:" + inventoryLogId + " need to create size policy"); } } catch (Exception e) { log.error("find NewInventoryBox fail(logId-" + inventoryLogId + ")", e); return null; } return inventoryBox; } public int getAxisTreeId(TreeType treeType, String treeName, String publisher, Platform platformType, Boolean isReferenceTree) { return inventoryExportSysCompForAdapter.getAxisTreeId(treeType, treeName, publisher, platformType, isReferenceTree); } public NodeDTO mergeNode(int treeId, String parentExternalId, NodeDTO nodeInfo) throws Exception { return invenCubeSysComp.mergeNode(treeId, parentExternalId, nodeInfo); } //fxpark(mergeNode ? ) public NodeDTO mergeNodeUsingMemory(int treeId, String parentExternalId, NodeDTO nodeInfo) throws Exception { return invenCubeSysComp.mergeNodeUsingMemory(treeId, parentExternalId, nodeInfo); } public void insertOnlyNewNodeUsingMemory(int treeId, String parentExternalId, NodeDTO nodeInfo) throws Exception { invenCubeSysComp.insertOnlyNewNodeUsingMemory(treeId, parentExternalId, nodeInfo); } /* * mergeNodeUsingMemory ? */ public void mergeNodeAfterMemoryClear() { invenCubeSysComp.nodeListForMergeClear(); } public void invalidateAxisTreeNodeExceptRootNode(int treeID, Date date) throws Exception { inventoryExportSysCompForAdapter.invalidateAxisTreeNodeExceptRootNode(treeID, date); invenCubeSysComp.setAxisTreeUpdateTime(treeID); } public boolean saveClosureNodes(int treeID) { return inventoryExportSysCompForAdapter.saveClosureNodes(treeID); } public void insertTreeLogNSyncNoticeboard(int treeId, TreeType treeType, String treeName, FeSyncNoticeboardDTO feSyncNoticeboardDTO, String publisher, Platform platformType) { Calendar nowDate = Calendar.getInstance(); AxisTreeLogDTO axisTreeLogDTO = new AxisTreeLogDTO(); axisTreeLogDTO.setTreeType(treeType); axisTreeLogDTO.setTreeId(treeId); axisTreeLogDTO.setUpdateDate(nowDate.getTime()); inventoryExportSysCompForAdapter.insertAxisTreeLog(axisTreeLogDTO); //? syncNoticeboard default . if (feSyncNoticeboardDTO == null) { String param = "treeId:" + treeId + "/treeType:" + treeType.toString() + "/treeName:" + treeName; feSyncNoticeboardDTO = generateFeSyncNoticeboardData(SyncDataType.TREEDATA, nowDate.getTime(), param, publisher, FeSyncNoticeboardStatus.NEWDATA, platformType, null, null); } //treeLog ? syncNoticeboard?? ? . inventoryExportSysCompForAdapter.insertFeSyncNoticeboard(feSyncNoticeboardDTO); } public FeSyncNoticeboardDTO insertSyncNoticeboard(FeSyncNoticeboardDTO feSyncNoticeboardDTO) { feSyncNoticeboardDTO.setId(inventoryExportSysCompForAdapter.insertFeSyncNoticeboard(feSyncNoticeboardDTO)); return feSyncNoticeboardDTO; } public void updateSyncNoticeboard(FeSyncNoticeboardDTO feSyncNoticeboardDTO) { inventoryExportSysCompForAdapter.updateFeSyncNoticeboard(feSyncNoticeboardDTO); } public int insertADSMSchedulerLog(ADSMSchedulerLogDTO schedulerLog) { int schedulerLogId = inventoryExportSysCompForAdapter.insertADSMSchedulerLog(schedulerLog); schedulerLog.setId(schedulerLogId); return schedulerLogId; } public void insertInventoryBox(InventoryBoxDTO inventoryBox, ADSMSchedulerLogDTO schedulerLog) { inventoryExportSysCompForAdapter.insertInventoryBox(inventoryBox, schedulerLog); } public void updateADSMSchedulerLog(ADSMSchedulerLogDTO schedulerLog) { inventoryExportSysCompForAdapter.updateADSMSchedulerLog(schedulerLog); } public void mergeADSMSchedulerLog(ADSMSchedulerLogDTO schedulerLog) { inventoryExportSysCompForAdapter.mergeADSMSchedulerLog(schedulerLog); } public ADSMSchedulerLogDTO getADSMSchedulerLog(int schedulerLogId) { return inventoryExportSysCompForAdapter.getADSMSchedulerLog(schedulerLogId); } public List<NodeInfoWithLinkNodeDTO> getContentNodeInfoByCatId(String catId, int conSchedulerId, int ownerId) { return inventoryExportSysCompForAdapter.getContentNodeInfoByCatId(catId, conSchedulerId, ownerId); } public List<NodeInfoWithLinkNodeDTO> getBannerNodeInfoByMenuId(String menuId, int ownerId) { return inventoryExportSysCompForAdapter.getBannerNodeInfoByMenuId(menuId, ownerId); } public List<String> getNodeExternalIdbyTreeId(int treeId) { return inventoryExportSysCompForAdapter.getNodeExternalIdbyTreeId(treeId); } public Map<String, Integer> getNodeInfobyTreeId(int treeId) { return inventoryExportSysCompForAdapter.getNodeInfoByTreeId(treeId); } public Map<String, NodeInfoLicenseDTO> getNodeInfoLicenseByTreeId(int treeId) { return inventoryExportSysCompForAdapter.getNodeInfoLicenseByTreeId(treeId); } public AxisTreeDTO getAxisTree(int treeID, Date date) { try { return inventoryExportSysCompForAdapter.getAxisTree(treeID, DateUtil.date2String(date), DateUtil.date2String(date)); // } // catch (RemoteException e) { // log.error( "Fail to get AxisTree. Exception Type : RemoteException | tree ID : " + treeID , e ); // return null; } catch (Exception e) { log.error("Fail to get AxisTree. Exception Type : Exception | tree ID : " + treeID, e); return null; } } public List<ContentDataDTO> getContentDataByContentIds(List<String> contentIds, int adsmSchedulerLogId) { return inventoryExportSysCompForAdapter.getContentDataByContentIds(contentIds, adsmSchedulerLogId); } public List<ContentDataDTO> getContentDataByCategoryIds(List<String> categoryIds, int adsmSchedulerLogId) { return inventoryExportSysCompForAdapter.getContentDataByCategoryIds(categoryIds, adsmSchedulerLogId); } public SubInventoryDTO generateSubInventory(String startDate, String endDate, String time_id, String week_id, String nodeCds, List<String> category_id, List<String> content_id, List<String> targetSlot, PlacementOpportunityTypeEnum opportunityType, PriceTypeEnum priceType, Map<String, List<String>> timeDefineMap, List<String> userIdList, List<String> userGroupIdList, List<String> content_group_id, String channel_id) throws Exception { List<PlacementOpportunityTypeEnum> opportunityTypeList = new ArrayList<PlacementOpportunityTypeEnum>(); if (opportunityType != null) opportunityTypeList.add(opportunityType); return generateSubInventory(startDate, endDate, time_id, week_id, nodeCds, category_id, false, content_id, targetSlot, opportunityTypeList, priceType, timeDefineMap, userIdList, userGroupIdList, content_group_id, channel_id); } public SubInventoryDTO generateSubInventory(String startDate, String endDate, String time_id, String week_id, String nodeCds, List<String> categoryIdList, boolean useLinkContentTree, List<String> contentIdList, List<String> targetSlotList, List<PlacementOpportunityTypeEnum> opportunityTypeList, PriceTypeEnum priceType, Map<String, List<String>> timeDefineMap, List<String> userIdList, List<String> userGroupIdList, List<String> contentGroupIdList, String channelId) throws Exception { return generateSubInventory(startDate, endDate, time_id, week_id, nodeCds, categoryIdList, useLinkContentTree, contentIdList, targetSlotList, opportunityTypeList, priceType, timeDefineMap, userIdList, userGroupIdList, false, contentGroupIdList, channelId); } //publisher, platformType ? ?? ? ? public SubInventoryDTO generateSubInventory(String startDate, String endDate, String time_id, String week_id, String nodeCds, List<String> categoryIdList, boolean useLinkContentTree, List<String> contentIdList, List<String> targetSlotList, List<PlacementOpportunityTypeEnum> opportunityTypeList, PriceTypeEnum priceType, Map<String, List<String>> timeDefineMap, List<String> userIdList, List<String> userGroupIdList, boolean catchCategoryException, List<String> contentGroupIdList, String channelId) throws Exception { SubInventoryDTO subInventoryDTO = new SubInventoryDTO(); // subInventoryDTO.setStartDate(startDate); subInventoryDTO.setEndDate(endDate); SubInventoryMemberDTO member = new SubInventoryMemberDTO(); member.setSubInventory(subInventoryDTO); String logStr = ""; // if (time_id != null && week_id != null) { logStr = logStr + "(time:" + time_id + ",week:" + week_id + ")"; List<GenericAxisItemIDDTO> timeIdList = inventoryExportSysCompForAdapter .getKTTimeAxisItemIDList(time_id, week_id, timeDefineMap); for (GenericAxisItemIDDTO timeId : timeIdList) { timeId.setSubInventoryMember(member); member.addAxisItemID(timeId); } } // if (nodeCds != null && (!nodeCds.equals(ConvertRegionAxisTreeDTO.REGION_DATA_ROOT_NODE_NAME))) { logStr = logStr + "(nodeCds:" + nodeCds + ")"; List<GenericAxisItemIDDTO> regionIdList = inventoryExportSysCompForAdapter .getRegionAxisItemIDList(nodeCds, null, null, null); for (GenericAxisItemIDDTO regionId : regionIdList) { regionId.setSubInventoryMember(member); member.addAxisItemID(regionId); } } // if (categoryIdList != null && categoryIdList.size() > 0) { for (String categoryId : categoryIdList) { if (categoryId == null || categoryId.isEmpty()) continue; logStr = logStr + "(categoryId:" + categoryId + ")"; GenericAxisItemIDDTO categoryItemId = inventoryExportSysCompForAdapter .getGenericAxisItemIDDTO(TreeType.CATEGORY_AXIS_TREE, null, categoryId, null, null); categoryItemId.setSubInventoryMember(member); member.addAxisItemID(categoryItemId); } } //? if (contentIdList != null && contentIdList.size() > 0) { //String contentTreeName = (useLinkContentTree == false) ? ConvertContentAxisTreeDTO.TREE_NAME : ConvertContentAxisTreeDTO.LINK_TREE_NAME; int okCnt = 0; for (String contentId : contentIdList) { if (contentId == null || contentId.isEmpty()) continue; logStr = logStr + "(contentId:" + contentId + ")"; try { GenericAxisItemIDDTO contentsItemId = inventoryExportSysCompForAdapter .getGenericAxisItemIDDTO(TreeType.VOD_CONTENTS_AXIS, null, contentId, null, null); contentsItemId.setSubInventoryMember(member); member.addAxisItemID(contentsItemId); okCnt++; } catch (CanNotFoundExIdWrappingException e) { if (catchCategoryException) { // ? true . log.warn(e.getMessage()); } else { throw e; } } } if (okCnt == 0 && catchCategoryException) throw new WrappingException( "? ? exId Subinventory ?(" + contentIdList + ")"); } //? if (contentGroupIdList != null && contentGroupIdList.size() > 0) { for (String contentGroupId : contentGroupIdList) { if (contentGroupId == null || contentGroupId.isEmpty()) continue; logStr = logStr + "(contentGroupId:" + contentGroupId + ")"; GenericAxisItemIDDTO contentGroupItemId = inventoryExportSysCompForAdapter .getGenericAxisItemIDDTO(TreeType.VOD_CONTENTS_AXIS, null, contentGroupId, null, null); contentGroupItemId.setSubInventoryMember(member); member.addAxisItemID(contentGroupItemId); } } // if (priceType != null) { String priceTypeString = priceType.toString(); logStr = logStr + "(priceType:" + priceTypeString + ")"; GenericAxisItemIDDTO opportunityTypeId = inventoryExportSysCompForAdapter .getGenericAxisItemIDDTO(TreeType.PRICE_AXIS, "price_tree", priceTypeString, null, null); opportunityTypeId.setSubInventoryMember(member); member.addAxisItemID(opportunityTypeId); } //? if (userIdList != null) { for (String userId : userIdList) { if (userId == null || userId.isEmpty()) continue; logStr = logStr + "(userId:" + userId + ")"; GenericAxisItemIDDTO userItemId = inventoryExportSysCompForAdapter .getGenericAxisItemIDDTO(TreeType.USER_AXIS_TREE, null, userId, null, null); userItemId.setSubInventoryMember(member); member.addAxisItemID(userItemId); } } //? if (userGroupIdList != null) { for (String userGroupId : userGroupIdList) { if (userGroupId == null || userGroupId.isEmpty()) continue; logStr = logStr + "(userGroupId:" + userGroupId + ")"; GenericAxisItemIDDTO userGroupItemId = inventoryExportSysCompForAdapter .getGenericAxisItemIDDTO(TreeType.USER_AXIS_TREE, null, userGroupId, null, null); userGroupItemId.setSubInventoryMember(member); member.addAxisItemID(userGroupItemId); } } //? if (channelId != null && channelId.equals("") == false && channelId.equals(ConvertChannelAxisTreeDTO.ROOT_NODE_NAME) == false) { logStr = logStr + "(channelId:" + channelId + ")"; GenericAxisItemIDDTO channelItemId = inventoryExportSysCompForAdapter .getGenericAxisItemIDDTO(TreeType.CHANNEL_AXIS_TREE, null, channelId, null, null); channelItemId.setSubInventoryMember(member); member.addAxisItemID(channelItemId); } if (!logStr.isEmpty()) log.debug("generateSubInventory " + logStr); subInventoryDTO.addMember(member); return subInventoryDTO; } public SubInventoryMemberDTO generateSubInventoryMember(String time_id, String week_id, String nodeCds, List<String> categoryIdList, List<String> contentIdList, List<String> targetSlotList, List<PlacementOpportunityTypeEnum> opportunityTypeList, PriceTypeEnum priceType, Map<String, List<String>> timeDefineMap) throws Exception { SubInventoryMemberDTO member = new SubInventoryMemberDTO(); String logStr = ""; // if (time_id != null && week_id != null) { logStr = logStr + "(time:" + time_id + ",week:" + week_id + ")"; List<GenericAxisItemIDDTO> timeIdList = inventoryExportSysCompForAdapter .getKTTimeAxisItemIDList(time_id, week_id, timeDefineMap); for (GenericAxisItemIDDTO timeId : timeIdList) { member.addAxisItemID(timeId); } } // if (nodeCds != null && (!nodeCds.equals(ConvertRegionAxisTreeDTO.REGION_DATA_ROOT_NODE_NAME))) { logStr = logStr + "(nodeCds:" + nodeCds + ")"; List<GenericAxisItemIDDTO> regionIdList = inventoryExportSysCompForAdapter .getRegionAxisItemIDList(nodeCds, null, null, null); for (GenericAxisItemIDDTO regionId : regionIdList) { member.addAxisItemID(regionId); } } // if (categoryIdList != null) { for (String categoryId : categoryIdList) { if (categoryId == null || categoryId.isEmpty()) continue; logStr = logStr + "(categoryId:" + categoryId + ")"; GenericAxisItemIDDTO categoryItemId = inventoryExportSysCompForAdapter .getGenericAxisItemIDDTO(TreeType.CATEGORY_AXIS_TREE, null, categoryId, null, null); member.addAxisItemID(categoryItemId); } } //? if (contentIdList != null) { //String contentTreeName = (useLinkContentTree == false) ? ConvertContentAxisTreeDTO.TREE_NAME : ConvertContentAxisTreeDTO.LINK_TREE_NAME; for (String contentId : contentIdList) { if (contentId == null || contentId.isEmpty()) continue; logStr = logStr + "(contentId:" + contentId + ")"; GenericAxisItemIDDTO contentsItemId = inventoryExportSysCompForAdapter .getGenericAxisItemIDDTO(TreeType.VOD_CONTENTS_AXIS, null, contentId, null, null); member.addAxisItemID(contentsItemId); } } // if (priceType != null) { String priceTypeString = priceType.toString(); logStr = logStr + "(priceType:" + priceTypeString + ")"; GenericAxisItemIDDTO opportunityTypeId = inventoryExportSysCompForAdapter .getGenericAxisItemIDDTO(TreeType.PRICE_AXIS, "price_tree", priceTypeString, null, null); member.addAxisItemID(opportunityTypeId); } if (!logStr.isEmpty()) log.info("generateSubInventoryMember " + logStr); return member; } public GenericAxisItemIDDTO getGenericAxisItemIDDTO(TreeType treeType, String externalId, String publisher, Platform platformType) throws Exception { return inventoryExportSysCompForAdapter.getGenericAxisItemIDDTO(treeType, null, externalId, publisher, platformType); } public List<GenericAxisItemIDDTO> getTimeGenericAxisItemIDList(String time_id, String week_id) throws Exception { log.debug("getTimeAxisItemIDList(time:" + time_id + ",week:" + week_id + ")"); return inventoryExportSysCompForAdapter.getTimeAxisItemIDList(time_id, week_id); } public List<GenericAxisItemIDDTO> getKTTimeGenericAxisItemIDList(String time_id, String week_id, Map<String, List<String>> timeDefineMap) throws Exception { log.debug("getKTTimeAxisItemIDList(time:" + time_id + ",week:" + week_id + ")"); return inventoryExportSysCompForAdapter.getKTTimeAxisItemIDList(time_id, week_id, timeDefineMap); } public SubInventoryDTO generateSubInventory(String startDate, String endDate, Set<GenericAxisItemIDDTO> genericAxisItems) throws Exception { SubInventoryDTO subInventoryDTO = new SubInventoryDTO(); // subInventoryDTO.setStartDate(startDate); subInventoryDTO.setEndDate(endDate); SubInventoryMemberDTO member = new SubInventoryMemberDTO(); for (GenericAxisItemIDDTO genericAxisItemIDDTO : genericAxisItems) { genericAxisItemIDDTO.setSubInventoryMember(member); } member.addAllAxisItemID(genericAxisItems); member.setSubInventory(subInventoryDTO); subInventoryDTO.addMember(member); return subInventoryDTO; } //@Transactional(propagation=Propagation.REQUIRED, rollbackFor=Exception.class) public GenericAxisItemIDSet generateGenericAxisItemIDDTO(String publisher, Platform platformType, List<String> categoryIdList, boolean useLinkContentTree, List<String> contentIdList, List<String> contentGroupIdList, List<String> userIdList, List<String> userGroupIdList, String nodeCds, String channelId) throws Exception { GenericAxisItemIDSet genericAxisItemIDSet = new GenericAxisItemIDSet(); String logStr = ""; // if (categoryIdList != null) { for (String categoryId : categoryIdList) { if (categoryId == null || categoryId.isEmpty()) continue; GenericAxisItemIDDTO categoryItemId = inventoryExportSysCompForAdapter.getGenericAxisItemIDDTO( TreeType.CATEGORY_AXIS_TREE, null, categoryId, publisher, platformType); genericAxisItemIDSet.addGenericAxisItemID(categoryItemId, TreeType.CATEGORY_AXIS_TREE); logStr += "(categoryId:" + categoryId + ")"; } } //? if (contentIdList != null) { for (String contentId : contentIdList) { if (contentId == null || contentId.isEmpty()) continue; GenericAxisItemIDDTO contentsItemId = inventoryExportSysCompForAdapter.getGenericAxisItemIDDTO( TreeType.VOD_CONTENTS_AXIS, null, contentId, publisher, platformType); genericAxisItemIDSet.addGenericAxisItemID(contentsItemId, TreeType.VOD_CONTENTS_AXIS); logStr += "(contentId:" + contentId + ")"; } } //? if (contentGroupIdList != null) { for (String contentGroupId : contentGroupIdList) { if (contentGroupId == null || contentGroupId.isEmpty()) continue; GenericAxisItemIDDTO contentGroupItemId = inventoryExportSysCompForAdapter.getGenericAxisItemIDDTO( TreeType.VOD_CONTENTS_AXIS, null, contentGroupId, publisher, platformType); genericAxisItemIDSet.addGenericAxisItemID(contentGroupItemId, TreeType.VOD_CONTENTS_AXIS); logStr += "(contentGroupId:" + contentGroupId + ")"; } } // if (nodeCds != null && (!nodeCds.equals(ConvertRegionAxisTreeDTO.REGION_DATA_ROOT_NODE_NAME))) { List<GenericAxisItemIDDTO> regionIdList = inventoryExportSysCompForAdapter .getRegionAxisItemIDList(nodeCds, null, publisher, platformType); genericAxisItemIDSet.addGenericAxisItemID(regionIdList, TreeType.REGION_AXIS_TREE); logStr += "(nodeCds:" + nodeCds + ")"; } //? if (userIdList != null) { for (String userId : userIdList) { if (userId == null || userId.isEmpty()) continue; GenericAxisItemIDDTO userItemId = inventoryExportSysCompForAdapter .getGenericAxisItemIDDTO(TreeType.USER_AXIS_TREE, null, userId, publisher, platformType); genericAxisItemIDSet.addGenericAxisItemID(userItemId, TreeType.USER_AXIS_TREE); logStr += "(userId:" + userId + ")"; } } //? if (userGroupIdList != null) { for (String userGroupId : userGroupIdList) { if (userGroupId == null || userGroupId.isEmpty()) continue; GenericAxisItemIDDTO userGroupItemId = inventoryExportSysCompForAdapter.getGenericAxisItemIDDTO( TreeType.USER_AXIS_TREE, null, userGroupId, publisher, platformType); genericAxisItemIDSet.addGenericAxisItemID(userGroupItemId, TreeType.USER_AXIS_TREE); logStr += "(userGroupId:" + userGroupId + ")"; } } //? if (channelId != null && channelId.equals("") == false && channelId.equals(ConvertChannelAxisTreeDTO.ROOT_NODE_NAME) == false) { GenericAxisItemIDDTO channelItemId = inventoryExportSysCompForAdapter .getGenericAxisItemIDDTO(TreeType.CHANNEL_AXIS_TREE, null, channelId, publisher, platformType); genericAxisItemIDSet.addGenericAxisItemID(channelItemId, TreeType.CHANNEL_AXIS_TREE); logStr += "(channelId:" + channelId + ")"; } if (!logStr.isEmpty()) log.debug("getGenericAxisItemID " + logStr); return genericAxisItemIDSet; } public void setAxisTreeUpdateTime(int treeID) { invenCubeSysComp.setAxisTreeUpdateTime(treeID); } //KT ? @Transactional(rollbackFor = Exception.class) public void generateKtTimeTableTree(TimeDefineDTO timeDefine, String InvenBoxStartDate) { if (timeDefine == null) return; // 1. inventory Box? TimeDefine . List<TimeDTO> timeList = timeDefine.getTimeList(); if (timeList == null) return; Map<String, List<String>> timeDefineMap = new HashMap<String, List<String>>(); for (TimeDTO dto : timeList) { if (dto.getTime_ID() != null && dto.getTimeValueList() != null) timeDefineMap.put(dto.getTime_ID(), dto.getTimeValueList()); } // 2. KT Time Table Tree . buildKtTimeTableTree(timeDefineMap, InvenBoxStartDate); } public Map<Integer, Integer> getKTTimeTreeNodeChildCountMap(Map<String, List<String>> timeDefineMap) throws Exception { return inventoryExportSysCompForAdapter.getKTTimeTreeNodeChildCountMap(timeDefineMap); } @Transactional(rollbackFor = Exception.class) public void buildKtTimeTableTree(Map<String, List<String>> timeDefineMap, String InvenBoxStartDate) { boolean isTreeUpdated = invenCubeSysComp.buildKtTimeTableTree(timeDefineMap, InvenBoxStartDate); //ktTimeTree ?? ? AxisTreeLog syncNoticeBoard? ?. if (isTreeUpdated) { TimeAxisTree ktTimeTree = invenCubeSysComp.getKtTimeTableTree(); insertTreeLogNSyncNoticeboard(ktTimeTree.getTreeID(), TreeType.TIME_AXIS_TREE, ktTimeTree.getTreeName(), null, null, null); } } public TimeAxisTree getKtTimeTableTree() { return invenCubeSysComp.getKtTimeTableTree(); } public Map<String, List<String>> getTimeDefineMap() { return invenCubeSysComp.getTimeDefineMap(); } /* public void insertMapperList(List<Mapper> mapperList, String deleteByTreeName, boolean isBatch) { inventoryExportSysCompForAdapter.saveMapper(mapperList, deleteByTreeName, null, null, null, isBatch); } */ public void updateSchedulerLogStateById(int schedulerLogId, ADSMSchedulerStatus status) { inventoryExportSysCompForAdapter.updateSchedulerLogStateById(schedulerLogId, status); } @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) public void saveMapper(List<Mapper> mapperList, MapperAxisType mapperType, String mappingIdDomain, String treeName, Date mapperStartDate, Date syncStartDate, int previousSuccessSchedulerLogId) { inventoryExportSysCompForAdapter.saveMapper(mapperList, mapperType, mappingIdDomain, treeName, mapperStartDate); if (previousSuccessSchedulerLogId > 0) { inventoryExportSysCompForAdapter.updateSchedulerLogStateById(previousSuccessSchedulerLogId, ADSMSchedulerStatus.DONE); } //fe sync String syncParam = "mapperAxisType:" + mapperType; insertFeSyncNoticeboard(SyncDataType.MAPPER, syncStartDate, syncParam, mappingIdDomain, null, null, null); } public Mapper getMapper(MapperAxisType mapperAxisType, String mappingIdDomain, String mappingId, String externalId) { return inventoryExportSysCompForAdapter.getMapper(mapperAxisType, mappingIdDomain, mappingId, externalId); } /// public ADSMSchedulerLogDTO startLog(String jobName, String param) { return startLog(jobName, param, null); } public ADSMSchedulerLogDTO startLog(String jobName, String param, String message) { long start = System.currentTimeMillis(); ADSMSchedulerLogDTO schedulerLog = new ADSMSchedulerLogDTO(); schedulerLog.setWorkThread(Thread.currentThread().getName()); schedulerLog.setJobName(jobName); schedulerLog.setSchedulerStatus(ADSMSchedulerStatus.UNKNOWN); schedulerLog.setProcessStartTime(DateUtil.date2String(new Date(start), "yyyy-MM-dd HH:mm:ss.SSS")); schedulerLog.setParam(param); schedulerLog.setMessage(message); try { int schedulerLogId = inventoryExportSysCompForAdapter.insertADSMSchedulerLog(schedulerLog); schedulerLog.setId(schedulerLogId); log.info(" Start DB Log" + schedulerLog); } catch (Exception e) { log.error(schedulerLog + " Fail to Register DB Log, " + e); return null; } return schedulerLog; } public boolean endLog(ADSMSchedulerLogDTO schedulerLog) { if (schedulerLog == null) return false; long end = System.currentTimeMillis(); schedulerLog.setProcessEndTime(DateUtil.date2String(new Date(end), "yyyy-MM-dd HH:mm:ss.SSS")); try { inventoryExportSysCompForAdapter.updateADSMSchedulerLog(schedulerLog); log.info(" End DB Log" + schedulerLog); } catch (Exception e) { log.error(schedulerLog + " Fail to Register DB Log, " + e); return false; } return true; } public List<PolicyGenericAxisItem> selectPolicyGenericAxisItemList(PlacementOpportunityTypeEnum oppType) { return inventoryExportSysCompForAdapter.selectPolicyGenericAxisItemList(oppType); } public List<Mapper> getMapperList(MapperAxisType mapperAxisType) { List<Mapper> mapperList = inventoryExportSysCompForAdapter.getMapperList(mapperAxisType); return mapperList; } /** * * */ public String getNewSchedulerLogParam(ADSMJobNameType srcJopType, ADSMJobNameType myJopType, String myParamValue) { ADSMSchedulerLogDTO srcLog = getLatestADSMSchedulerLog(srcJopType.name()); ADSMSchedulerLogDTO myLog = getLatestADSMSchedulerLog(myJopType.name()); if (srcLog == null) { // ? ? return null; } int srcLogId = srcLog.getId(); if (myLog != null) { String doneSrcLogId = (String) myLog.getParamValue(myParamValue); if (doneSrcLogId != null && srcLogId == Integer.parseInt(doneSrcLogId)) { //?? return null; } } String schedulerLogParam = myParamValue + ":" + srcLogId; return schedulerLogParam; } /** * * */ public Map<ADSMSchedulerLogDTO, String> getNewSchedulerLogByTreeName(ADSMJobNameType srcJopType, String defaultTreeName) { Map<ADSMSchedulerLogDTO, String> schedulerLogMap = new LinkedHashMap<ADSMSchedulerLogDTO, String>(); try { List<ADSMSchedulerLogDTO> dataLogList = getADSMSchedulerLogList(srcJopType.name(), null); if (dataLogList == null || dataLogList.isEmpty()) { return null; } for (ADSMSchedulerLogDTO schedulerLog : dataLogList) { String fileName = (String) schedulerLog.getParamValue(FilePolling.PARAM_FILE_NAME_PREFIX); if (fileName == null || fileName.isEmpty()) continue; String treeName = (String) schedulerLog.getParamValue(FilePolling.PARAM_TREE_NAME); if (treeName == null || treeName.isEmpty()) schedulerLogMap.put(schedulerLog, defaultTreeName); else schedulerLogMap.put(schedulerLog, treeName); } } catch (Exception e) { log.error("", e); } return schedulerLogMap; } public ImportSyncVersion selectSyncVersion(SyncType syncType) { return importSyncVersionBizComp.selectSyncVersion(syncType); } public void mergeSyncVersion(ImportSyncVersion importSyncVersion) { ImportSyncVersion SyncVersion = importSyncVersionBizComp.selectSyncVersion(importSyncVersion.getSyncType()); if (SyncVersion != null) importSyncVersion.setId(SyncVersion.getId()); importSyncVersionBizComp.mergeSyncVersion(importSyncVersion); } public void disableFeSyncNoticeboard(FeSyncNoticeboardDTO feSyncNoticeboardDTO) { inventoryExportSysCompForAdapter.disableFeSyncNoticeboard(feSyncNoticeboardDTO); } public FeSyncNoticeboardDTO insertFeSyncNoticeboard(SyncDataType dataType, Date syncStartTime, String param, String addsSite, Platform platform, InventoryType inventoryType, PlacementOpportunityTypeEnum opportunityType) { FeSyncNoticeboardDTO notice = generateFeSyncNoticeboardData(dataType, syncStartTime, param, addsSite, FeSyncNoticeboardStatus.NEWDATA, platform, inventoryType, opportunityType); try { int id = inventoryExportSysCompForAdapter.insertFeSyncNoticeboard(notice); notice.setId(id); log.info("Register Fe Sync Reservation" + notice); } catch (Exception e) { log.error(notice + "Fail to register Fe Sync Reservation, " + e); return null; } return notice; } public FeSyncNoticeboardDTO generateFeSyncNoticeboardData(SyncDataType dataType, Date syncStartTime, String param, String publisher, FeSyncNoticeboardStatus status, Platform platform, InventoryType inventoryType, PlacementOpportunityTypeEnum opportunityType) { return inventoryExportSysCompForAdapter.generateFeSyncNoticeboardData(dataType, syncStartTime, param, publisher, status, platform); } public int getSumADCampaignDailyExposure(String externalCampaignId, Date exposureDate) { return inventoryExportSysCompForAdapter.getSumADCampaignDailyExposure(externalCampaignId, exposureDate); } public List<String> getFamilyExternalIdList(String parentExternalId, int treeId) { return inventoryExportSysCompForAdapter.getFamilyExternalIdList(parentExternalId, treeId); } public boolean saveNodeList(List<AxisTreeNodeDTO> nodeDTOList) { return inventoryExportSysCompForAdapter.saveNodeList(nodeDTOList); } public int getNodeId(int treeId, String externalId) throws Exception { return inventoryExportSysCompForAdapter.getNodeId(treeId, externalId); } public List<CategoryIdForDisableContent> findAllCategoryIdForDisableConten() { return inventoryExportSysCompForAdapter.findAllCategoryIdForDisableConten(); } public List<CategoryIdForDisableContent> findCategoryIdForDisableContentByPpsSlotExceptYN( boolean ppsSlotExceptYN) { return inventoryExportSysCompForAdapter.findCategoryIdForDisableContentByPpsSlotExceptYN(ppsSlotExceptYN); } public boolean updateDisableContentPolicy(Map<Integer, CategoryInfoForDiableContentDTO> policyMap, int deleteSchedulerLogId, int treeId, boolean ppsSlotExceptYN) throws Exception { return inventoryExportSysCompForAdapter.updateDisableContentPolicy(policyMap, deleteSchedulerLogId, treeId, ppsSlotExceptYN); } @SuppressWarnings("rawtypes") public void saveTargetMapByOppType(Map<String, List<String>> targetMap, PlacementOpportunityTypeEnum oppType, TreeType treeType, InventoryType inventoryType) { List<TargetMap> targetMapList = new ArrayList<TargetMap>(); if (!targetMap.isEmpty()) { Iterator it = targetMap.keySet().iterator(); while (it.hasNext()) { String key = it.next().toString(); //string parse List<String> mapValueList = targetMap.get(key); for (String v : mapValueList) { TargetMap tm = new TargetMap(); tm.setKey(key); tm.setValue(v); tm.setOppType(oppType); tm.setTreeType(treeType); tm.setInventoryType(inventoryType); targetMapList.add(tm); } } } inventoryExportSysCompForAdapter.saveTargetMapByOppType(targetMapList, oppType, treeType, inventoryType); } public List<TargetMap> getAllTargetMap(TreeType treeType) { return inventoryExportSysCompForAdapter.getAllTargetMap(treeType); } public void saveContentGroupByOppType(List<String> contentGroupIdList, PlacementOpportunityTypeEnum oppType) { inventoryExportSysCompForAdapter.saveContentGroupByOppType(contentGroupIdList, oppType); } public List<ContentGroupDTO> getAllContentGroupId() { return inventoryExportSysCompForAdapter.getAllContentGroupId(); } public boolean insertChannelData(List<ChannelServiceDTO> channelInfoList, ADSMSchedulerLogDTO schedulerLog, String resultDir, String fileName, InputDataType inputDataType, ADSMJobNameType jobType) { boolean result = false; try { inventoryExportSysCompForAdapter.insertChannelDataList(channelInfoList, schedulerLog, jobType); schedulerLog.setSchedulerStatus(ADSMSchedulerStatus.SUCCESS); result = true; ResultFileUtil.writeResultFile(fileName, "? ? . [size:" + channelInfoList.size() + "]", FileResultCode.RESULT_OK.getValue(), resultDir, inputDataType); } catch (Exception e) { schedulerLog.setMessage(e.getMessage()); schedulerLog.setSchedulerStatus(ADSMSchedulerStatus.FAIL); StackTraceElement[] stackTraces = e.getStackTrace(); if (stackTraces.length > 0) { String failProcess = stackTraces[0].getClassName() + " - " + stackTraces[0].getMethodName() + "(" + stackTraces[0].getLineNumber() + ")"; schedulerLog.setFailProcess(failProcess); } result = false; ResultFileUtil.writeResultFile(fileName, e.getMessage(), FileResultCode.RESULT_FAIL.getValue(), resultDir, inputDataType); } return result; } public List<ChannelServiceDTO> getChannelData() { return inventoryExportSysCompForAdapter.getChannelData(); } public boolean insertOttData(List<ChannelServiceDTO> channelInfoList, ADSMSchedulerLogDTO schedulerLog, String resultDirectory, String fileName, InputDataType inputDataType, ADSMJobNameType jobType) { boolean result = false; try { inventoryExportSysCompForAdapter.insertOttData(channelInfoList, schedulerLog, jobType); schedulerLog.setSchedulerStatus(ADSMSchedulerStatus.SUCCESS); result = true; ResultFileUtil.writeResultFile(fileName, "? ? . [size:" + channelInfoList.size() + "]", FileResultCode.RESULT_OK.getValue(), resultDirectory, inputDataType); } catch (Exception e) { schedulerLog.setMessage(e.getMessage()); schedulerLog.setSchedulerStatus(ADSMSchedulerStatus.FAIL); StackTraceElement[] stackTraces = e.getStackTrace(); if (stackTraces.length > 0) { String failProcess = stackTraces[0].getClassName() + " - " + stackTraces[0].getMethodName() + "(" + stackTraces[0].getLineNumber() + ")"; schedulerLog.setFailProcess(failProcess); } result = false; ResultFileUtil.writeResultFile(fileName, e.getMessage(), FileResultCode.RESULT_FAIL.getValue(), resultDirectory, inputDataType); } return result; } @SuppressWarnings("unchecked") @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) public void replaceChannelMetaList(List<ChannelMetaDTO> channelMetaDTOList, String fileName) { List<ChannelScheduleMeta> channelMetaInfoList = (List<ChannelScheduleMeta>) Converter .listMap(channelMetaDTOList, ChannelScheduleMeta.class); channelBizComp.replaceChannelMetaList(channelMetaInfoList); PlacementOpportunityTypeEnum oppType = PlacementOpportunityTypeEnum.PREROLL; InventoryType inventoryType = InventoryType.CUETONE; Platform platformType = Platform.STB; String param = "oppType:" + oppType.toString() + "/inventoryType:" + inventoryType.toString() + "/plaformType:" + platformType.toString() + "/fileName:" + fileName; FeSyncNoticeboardDTO feSyncNoticeboardDTO = generateFeSyncNoticeboardData(SyncDataType.SCHEDULE, new Date(), param, null, FeSyncNoticeboardStatus.NEWDATA, platformType, inventoryType, oppType); // feSyncNoticeboardDTO.setOpportunityType(oppType); // feSyncNoticeboardDTO.setInventoryType(inventoryType); // feSyncNoticeboardDTO.setPlatform(platformType); //feSyncNoticeboardDTO.setStatus(FeSyncNoticeboardStatus.NEWDATA); //Timestamp timestamp = new Timestamp(new Date().getTime()); //feSyncNoticeboardDTO.setSyncStartTime(timestamp); feSyncNoticeboardDTO = insertSyncNoticeboard(feSyncNoticeboardDTO); } @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) public boolean insertChannelScheduleInfoList(List<ChannelScheduleInfoDTO> channelScheduleInfoDTOList, ADSMSchedulerLogDTO schedulerLog, String resultDirectory, String fileName, InputDataType inputDataType, ADSMJobNameType jobType) { boolean result = false; try { List<ChannelScheduleInfo> channelScheduleInfoList = new ArrayList<ChannelScheduleInfo>(); for (ChannelScheduleInfoDTO channelScheduleInfoDTO : channelScheduleInfoDTOList) { String channelId = channelScheduleInfoDTO.getChannelId(); List<Date> dateList = channelScheduleInfoDTO.getScheduleTime(); for (Date date : dateList) { channelScheduleInfoList.add(new ChannelScheduleInfo(channelId, date)); } } channelBizComp.replaceChannelScheduleInfoList(channelScheduleInfoList); PlacementOpportunityTypeEnum oppType = PlacementOpportunityTypeEnum.PREROLL; InventoryType inventoryType = InventoryType.CUETONE; Platform platformType = Platform.STB; String param = "oppType:" + oppType.toString() + "/inventoryType:" + inventoryType.toString() + "/plaformType:" + platformType.toString() + "/fileName:" + fileName; FeSyncNoticeboardDTO feSyncNoticeboardDTO = generateFeSyncNoticeboardData(SyncDataType.SCHEDULE, new Date(), param, null, FeSyncNoticeboardStatus.NEWDATA, platformType, inventoryType, oppType); // feSyncNoticeboardDTO.setOpportunityType(oppType); // feSyncNoticeboardDTO.setInventoryType(inventoryType); // feSyncNoticeboardDTO.setPlatform(platformType); //feSyncNoticeboardDTO.setStatus(FeSyncNoticeboardStatus.NEWDATA); //Timestamp timestamp = new Timestamp(new Date().getTime()); //feSyncNoticeboardDTO.setSyncStartTime(timestamp); feSyncNoticeboardDTO = insertSyncNoticeboard(feSyncNoticeboardDTO); schedulerLog.setSchedulerStatus(ADSMSchedulerStatus.SUCCESS); result = true; ResultFileUtil.writeResultFile(fileName, "? ? . [size:" + channelScheduleInfoList.size() + "]", FileResultCode.RESULT_OK.getValue(), resultDirectory, inputDataType); } catch (Exception e) { schedulerLog.setMessage(e.getMessage()); schedulerLog.setSchedulerStatus(ADSMSchedulerStatus.FAIL); StackTraceElement[] stackTraces = e.getStackTrace(); if (stackTraces.length > 0) { String failProcess = stackTraces[0].getClassName() + " - " + stackTraces[0].getMethodName() + "(" + stackTraces[0].getLineNumber() + ")"; schedulerLog.setFailProcess(failProcess); } result = false; ResultFileUtil.writeResultFile(fileName, e.getMessage(), FileResultCode.RESULT_FAIL.getValue(), resultDirectory, inputDataType); } return result; } public void replaceClientUIDataList(List<ClientUIDataDTO> clientUIDataDTOList) { List<ClientUIData> clientUIDataList = convertClientUIDataList(clientUIDataDTOList); clientUIBizComp.replaceClientUIDataList(clientUIDataList); } public List<ClientUIData> convertClientUIDataList(List<ClientUIDataDTO> clientUIDataDTOList) { List<ClientUIData> clientUIDataList = new ArrayList<ClientUIData>(); for (ClientUIDataDTO clientUIDataDTO : clientUIDataDTOList) { clientUIDataList.add(new ClientUIData(clientUIDataDTO)); } return clientUIDataList; } public List<ClientUIData> getClientUIDataByType(ClientUIType type) { return clientUIBizComp.getClientUIDataList(type); } public List<ClientUIData> getClientUIDataByParentId(ClientUIType type, String parentId) { return clientUIBizComp.getClientUIDataByParentId(type, parentId); } }