01: /*
02: *
03: * Copyright (c) 2004 SourceTap - www.sourcetap.com
04: *
05: * The contents of this file are subject to the SourceTap Public License
06: * ("License"); You may not use this file except in compliance with the
07: * License. You may obtain a copy of the License at http://www.sourcetap.com/license.htm
08: * Software distributed under the License is distributed on an "AS IS" basis,
09: * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
10: * the specific language governing rights and limitations under the License.
11: *
12: * The above copyright notice and this permission notice shall be included
13: * in all copies or substantial portions of the Software.
14: *
15: */
16:
17: package com.sourcetap.sfa.replication;
18:
19: import com.sourcetap.sfa.security.*;
20:
21: import org.ofbiz.entity.*;
22: import org.ofbiz.entity.model.*;
23: import org.ofbiz.base.util.*;
24:
25: import java.util.*;
26:
27: /**
28: * This class is used for replication of the EntityAccess entity. <P>
29: *
30: * @author <a href='mailto:jnutting@sourcetap.com'>John Nutting</a>
31: */
32: public class EntityAccessReplicator extends EntityReplicator {
33: public static final String module = EntityAccessReplicator.class
34: .getName();
35:
36: /**
37: * Populate the related entity map vector. This method is called from the constructors
38: * to allow the related entities to be specified before replication begins.
39: *
40: * @author <a href='mailto:jnutting@sourcetap.com'>John Nutting</a>
41: */
42: public void populateRelatedEntityMapVector() {
43: // Add related entity maps for all entities to be replicated for each
44: // replicated account.
45: Debug.logVerbose("[populateRelatedEntityMapVector] Start",
46: module);
47:
48: addRelatedEntityMap("", "Team", null, false, false,
49: "com.sourcetap.sfa.replication.TeamReplicator");
50:
51: return;
52: }
53:
54: /**
55: * This method finds all instances of an entity related to the main entity.
56: *
57: * This method overrides the ancestor to filter out instances for the SFA application.
58: *
59: * @author <a href='mailto:jnutting@sourcetap.com'>John Nutting</a>
60: *
61: * @param mainInstance Main entity instance for which related entities will be replicated
62: * @param relationTitle Relation title to be used by the entity engine to find related
63: * entity instances
64: * @param relatedEntityName Name of the related entity to be replicated
65: * @param filterMap HashMap containing additional filter values to be used by the entity
66: * engine when finding related entity instances
67: *
68: * @return List of generic values related to the main entity instance
69: */
70: protected List findOneRelated(GenericDelegator delegator,
71: GenericValue mainInstance, String relationTitle,
72: String relatedEntityName, HashMap filterMap, boolean findAll) {
73:
74: GenericPK entityPK = null;
75:
76: String entityKeyString = null;
77:
78: List relatedGVL = null;
79:
80: if (relatedEntityName.equals("Team")) {
81: // Special processing for EntityAccess entity.
82: return TeamHelper.findRelated(getUserInfo(), delegator,
83: mainInstance, relationTitle);
84: } else {
85: // Default processing for all other entities.
86: return super.findOneRelated(delegator, mainInstance,
87: relationTitle, relatedEntityName, filterMap,
88: findAll);
89: }
90: }
91: }
|