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

Java tutorial

Introduction

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

Source

/**
 * PureInfo Command
 * @(#)GetNationTeam.java   1.0 2008-7-14
 * 
 * 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;

public class GetNationTeam extends FunctionHandlerDVImplBase {
    final int SCORE = 3;

    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("01") != -1) {// 3
                    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();
        }
    }

}