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.address.*;
020: import com.sourcetap.sfa.security.*;
021:
022: import org.ofbiz.entity.*;
023: import org.ofbiz.entity.model.*;
024: import org.ofbiz.base.util.*;
025:
026: import java.util.*;
027:
028: /**
029: * This class is used for replication of the Contact entity. <P>
030: *
031: * @author <a href='mailto:jnutting@sourcetap.com'>John Nutting</a>
032: */
033: public class ContactReplicator extends EntityReplicator {
034: public static final String module = ContactReplicator.class
035: .getName();
036:
037: /**
038: * Populate the related entity map vector. This method is called from the constructors
039: * to allow the related entities to be specified before replication begins.
040: *
041: * @author <a href='mailto:jnutting@sourcetap.com'>John Nutting</a>
042: */
043: public void populateRelatedEntityMapVector() {
044: // Add related entity maps for all entities to be replicated for each
045: // replicated account.
046:
047: addRelatedEntityMap("", "Address", null, false, false, "");
048: addRelatedEntityMap("", "ContactFile", null, false, false,
049: "com.sourcetap.sfa.replication.FileReplicator");
050: addRelatedEntityMap("", "Party", null, false, false, "");
051: addRelatedEntityMap("", "UserLogin", null, false, false, "");
052: addRelatedEntityMap("", "Url", null, false, false, "");
053:
054: return;
055: }
056:
057: /**
058: * This method finds all instances of an entity related to the main entity.
059: *
060: * This method overrides the ancestor to filter out instances for the SFA application.
061: *
062: * @author <a href='mailto:jnutting@sourcetap.com'>John Nutting</a>
063: *
064: * @param mainInstance Main entity instance for which related entities will be replicated
065: * @param relationTitle Relation title to be used by the entity engine to find related
066: * entity instances
067: * @param relatedEntityName Name of the related entity to be replicated
068: * @param filterMap HashMap containing additional filter values to be used by the entity
069: * engine when finding related entity instances
070: *
071: * @return List of generic values related to the main entity instance
072: */
073: protected List findOneRelated(GenericDelegator delegator,
074: GenericValue mainInstance, String relationTitle,
075: String relatedEntityName, HashMap filterMap, boolean findAll) {
076:
077: if (delegator == null) {
078: Debug.logError("[findOneRelated] Delegator is required.",
079: module);
080:
081: return null;
082: }
083:
084: if (userInfo == null) {
085: Debug.logError(
086: "[findOneRelated] User info object is required.",
087: module);
088:
089: return null;
090: }
091:
092: GenericPK entityPK = null;
093: String entityKeyString = null;
094:
095: List relatedGVL = null;
096:
097: if (relatedEntityName.equals("Address")) {
098: // Special processing for Address entity.
099: return AddressHelper.findRelated(getUserInfo(), delegator,
100: mainInstance, relationTitle);
101: } else {
102: // Default processing for all other entities.
103: return super.findOneRelated(delegator, mainInstance,
104: relationTitle, relatedEntityName, filterMap,
105: findAll);
106: }
107: }
108: }
|