001: /*
002: *
003: * Copyright (c) 2004 SourceTap - www.sourcetap.com
004: *
005: * The contents of this file are subject to the SourceTap Public License
006: * ("License"); You may not use this file except in compliance with the
007: * License. You may obtain a copy of the License at http://www.sourcetap.com/license.htm
008: * Software distributed under the License is distributed on an "AS IS" basis,
009: * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
010: * the specific language governing rights and limitations under the License.
011: *
012: * The above copyright notice and this permission notice shall be included
013: * in all copies or substantial portions of the Software.
014: *
015: */
016:
017: package com.sourcetap.sfa.replication;
018:
019: import com.sourcetap.sfa.security.*;
020:
021: import org.ofbiz.entity.*;
022: import org.ofbiz.entity.model.*;
023: import org.ofbiz.base.util.*;
024:
025: import java.util.*;
026:
027: /**
028: * This class is used for replication of the Deal entity. <P>
029: *
030: * @author <a href='mailto:jnutting@sourcetap.com'>John Nutting</a>
031: */
032: public class DealReplicator extends EntityReplicator {
033: /**
034: * Debug switch
035: */
036: public static final String module = DealReplicator.class.getName();
037:
038: /**
039: * Populate the related entity map vector. This method is called from the constructors
040: * to allow the related entities to be specified before replication begins.
041: *
042: * @author <a href='mailto:jnutting@sourcetap.com'>John Nutting</a>
043: */
044: public void populateRelatedEntityMapVector() {
045: // Add related entity maps for all entities to be replicated for each
046: // replicated account.
047:
048: addRelatedEntityMap("", "DealStageStepsTracking", null, false,
049: false, "");
050: addRelatedEntityMap("", "EntityAccess", null, false, false,
051: "com.sourcetap.sfa.replication.EntityAccessReplicator");
052: addRelatedEntityMap("", "OpportunityStatusTracking", null,
053: false, false, "");
054: addRelatedEntityMap("", "OpportunityProduct", null, false,
055: false, "");
056: addRelatedEntityMap("", "OpportunityContact", null, false,
057: false, "");
058: addRelatedEntityMap("", "DealFile", null, false, false,
059: "com.sourcetap.sfa.replication.FileReplicator");
060: addRelatedEntityMap("", "Url", null, false, false, "");
061:
062: return;
063: }
064:
065: /**
066: * This method finds all instances of an entity related to the main entity.
067: *
068: * This method overrides the ancestor to filter out instances for the SFA application.
069: *
070: * @author <a href='mailto:jnutting@sourcetap.com'>John Nutting</a>
071: *
072: * @param mainInstance Main entity instance for which related entities will be replicated
073: * @param relationTitle Relation title to be used by the entity engine to find related
074: * entity instances
075: * @param relatedEntityName Name of the related entity to be replicated
076: * @param filterMap HashMap containing additional filter values to be used by the entity
077: * engine when finding related entity instances
078: *
079: * @return List of generic values related to the main entity instance
080: */
081: protected List findOneRelated(GenericDelegator delegator,
082: GenericValue mainInstance, String relationTitle,
083: String relatedEntityName, HashMap filterMap, boolean findAll) {
084:
085: if (delegator == null) {
086: Debug.logError("[findOneRelated] Delegator is required.",
087: module);
088:
089: return null;
090: }
091:
092: if (userInfo == null) {
093: Debug.logError(
094: "[findOneRelated] User info object is required.",
095: module);
096:
097: return null;
098: }
099:
100: GenericPK entityPK = null;
101: String entityKeyString = null;
102:
103: List relatedGVL = null;
104:
105: if (relatedEntityName.equals("EntityAccess")) {
106: // Special processing for EntityAccess entity.
107: return EntityAccessHelper.findRelated(getUserInfo(),
108: delegator, mainInstance, relationTitle);
109: } else {
110: // Default processing for all other entities.
111: return super.findOneRelated(delegator, mainInstance,
112: relationTitle, relatedEntityName, filterMap,
113: findAll);
114: }
115: }
116: }
|