/* 
 * Copyright 2012-2017 bambooCORE, greenstep of copyright Chen Xin Nien
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 * -----------------------------------------------------------------------
 * 
 * author: 	Chen Xin Nien
 * contact: chen.xin.nien@gmail.com
 * 
 */
package com.netsteadfast.greenstep.bsc.support;

import javax.servlet.ServletContextEvent;

import org.apache.log4j.Logger;

import com.netsteadfast.greenstep.base.AppContext;
import com.netsteadfast.greenstep.base.exception.ServiceException;
import com.netsteadfast.greenstep.base.model.ContextInitializedAndDestroyedBean;
import com.netsteadfast.greenstep.bsc.service.logic.IEmployeeLogicService;
import com.netsteadfast.greenstep.sys.BackgroundProgramUserUtils;

/**
 * 準備 0.7.1 版本需要的 bb_employee_hier 資料
 *
 */
public class UpgradeVersion071ForContextInitAndDestroy extends ContextInitializedAndDestroyedBean {
	private static final long serialVersionUID = 6662283552130953159L;
	protected static Logger logger = Logger.getLogger(UpgradeVersion071ForContextInitAndDestroy.class);
	
	@Override
	public void execute(ServletContextEvent event) throws Exception {
		logger.info("begin....");
		try {
			BackgroundProgramUserUtils.login();
			IEmployeeLogicService employeeLogicService = (IEmployeeLogicService) AppContext.getBean("bsc.service.logic.EmployeeLogicService");
			logger.info("init employee hierarchy data, since version 0.7.1");			
			employeeLogicService.initHierarchyForFirst();
		} catch (ServiceException se) {
			se.printStackTrace();
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			BackgroundProgramUserUtils.logout();
		}
		logger.info("end....");
	}

}

@@ -1294,20 +1294,77 @@
 er %E8%B3%87%E6%96%99%0A *
-%0A */
+ 0.7.4 %E5%BB%A2%E9%99%A4%E4%BD%BF%E7%94%A8, %E8%AB%8B%E7%94%A8 %2209 - Web Context bean%22 %E4%BE%86%E7%A7%BB%E9%99%A4%E8%A8%AD%E5%AE%9A%0A */%0A@Deprecated
 %0Apublic 
@@ -2202,16 +2202,159 @@
 ();%0A%09%09%7D%0A
+%09%09logger.warn(%22Please use %5B09 - Web Context bean%5D remove %5BUpgradeVersion071ForContextInitAndDestroy%5D config item in 0.7.4 version or later.%22);%0A
 %09%09logger

update code.