Package com.sourcetap.sfa.security

Source Code of com.sourcetap.sfa.security.TeamHelper

/*
*
* Copyright (c) 2004 SourceTap - www.sourcetap.com
*
*  The contents of this file are subject to the SourceTap Public License
* ("License"); You may not use this file except in compliance with the
* License. You may obtain a copy of the License at http://www.sourcetap.com/license.htm
* Software distributed under the License is distributed on an  "AS IS"  basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
* the specific language governing rights and limitations under the License.
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
*/

package com.sourcetap.sfa.security;

import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;

import org.ofbiz.base.util.Debug;
import org.ofbiz.entity.GenericDelegator;
import org.ofbiz.entity.GenericEntityException;
import org.ofbiz.entity.GenericPK;
import org.ofbiz.entity.GenericValue;

import com.sourcetap.sfa.util.UserInfo;


/**
* DOCUMENT ME!
*
*/
public class TeamHelper {
  public static final String module = TeamHelper.class.getName();

    /**
     * DOCUMENT ME!
     *
     * @param userInfo
     * @param delegator
     * @param entityGV
     * @param relationTitle
     *
     * @return
     */
    public static List findRelated(UserInfo userInfo,
        GenericDelegator delegator, GenericValue entityGV, String relationTitle) {

        String mainEntityName = entityGV.getEntityName();
        String relatedEntityName = "Team";

        // Finding related Team records. Need special processing because the relationship cannot be
        // defined in the sfa-config.xml file.
        GenericPK entityPK = null;
        String entityKeyString = null;

        List relatedGVL = null;

        try {
                Debug.logVerbose("[findRelated] Retrieving all " +
                    relatedEntityName + " records related to " +
                    entityKeyString, module);

            HashMap findMap = new HashMap();
            String partyEntityType = (entityGV.getString("partyEntityType") == null)
                ? "" : entityGV.getString("partyEntityType");

            if (partyEntityType.equals("Team")) {
                // This EntityAccess record is tied to a team.  Need to return this team if it exists.
                String teamId = (entityGV.getString("partyId") == null) ? ""
                                                                        : entityGV.getString(
                        "partyId");

                findMap.put("teamId", teamId);
                relatedGVL = delegator.findByAnd(relatedEntityName, findMap);
            } else {
                // The party is a role. Don't need to return anything.
                return new LinkedList();
            }
        } catch (GenericEntityException e) {
            Debug.logWarning("[findRelated] Error getting the related " +
                relatedEntityName + " records: " + e.getLocalizedMessage(), module);

            return new LinkedList();
        }

        return relatedGVL;
    }
}
TOP

Related Classes of com.sourcetap.sfa.security.TeamHelper

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.