com.pureinfo.srm.view.function.GetShenTeam.java Source code

Java tutorial

Introduction

Here is the source code for com.pureinfo.srm.view.function.GetShenTeam.java

Source

/**
 * PureInfo Command-phase2
 * @(#)GetShenTeam.java   1.0 2008-7-15
 * 
 * Copyright(c) 2004-2005, PureInfo Information Technology Corp. Ltd. 
 * All rights reserved, see the license file.
 * 
 * www.pureinfo.com.cn
 */

package com.pureinfo.srm.view.function;

import java.util.Iterator;
import java.util.List;

import org.apache.commons.lang.StringUtils;

import com.pureinfo.dolphin.context.LocalContextHelper;
import com.pureinfo.dolphin.model.IObjects;
import com.pureinfo.dolphin.persister.IStatement;
import com.pureinfo.dolphinview.context.model.IDVContext;
import com.pureinfo.dolphinview.parser.function.FunctionHandlerDVImplBase;
import com.pureinfo.force.exception.PureException;
import com.pureinfo.srm.org.model.ObjDeptMapping;
import com.pureinfo.srm.org.model.Organization;
import com.pureinfo.srm.reports.table.data.pinggu.constants.PingGuConstants;
import com.pureinfo.srm.reports.table.data.pinggu.constants.TeamPingGuHelper;
import com.pureinfo.srm.reports.table.data.pinggu.form.PingGuParameterVO;
import com.pureinfo.srm.team.model.Team;

/**
 * <P>
 * Created on 2008-7-15 12:33:41<BR>
 * Last modified on 2008-7-15
 * </P>
 * 
 * 
 * @author jie.sun
 * @version 1.0, 2008-7-15
 * @since Command-phase2 1.0
 */
public class GetShenTeam extends FunctionHandlerDVImplBase {
    final int SCORE = 1;

    public Object perform(Object[] _s_args, IDVContext _s_context) throws PureException {
        PingGuParameterVO vo = (PingGuParameterVO) LocalContextHelper
                .getAttribute(PingGuConstants.ATTRIBUTE_NAME_OF_PARAMETER);
        if (vo == null) {
            return "";
        }
        IObjects objs = null;
        IStatement query = null;
        Organization org = (Organization) _s_context.getObject();
        double totalScale = 0;

        try {
            objs = TeamPingGuHelper.getObjs(org.getCode(), vo.getStartDate(), vo.getEndDate());
            Team team = null;
            while ((team = (Team) objs.next()) != null) {
                String teamHonor = team.getTeamHonor();
                if (StringUtils.isNotEmpty(teamHonor) && teamHonor.indexOf("02") != -1) {// 
                    List deptList = team.getDeptList();
                    for (Iterator iterator = deptList.iterator(); iterator.hasNext();) {
                        ObjDeptMapping deptMapping = (ObjDeptMapping) iterator.next();
                        if (deptMapping.getDeptId() == org.getId()) {
                            totalScale += deptMapping.getWeightScale();
                            break;
                        }
                    }
                } else {
                    continue;
                }
            }

            return new Double(SCORE * totalScale);
        } finally {
            if (objs != null)
                objs.clear();
            if (query != null)
                query.clear();
        }
    }

}