Example #1
0
  /**
   * A helper method for creating a PartyRelationship entity from partyIdTo to partyIdFrom with
   * specified partyRelationshipTypeId, roleTypeIdFrom, a List of valid roles for the to-party, and
   * a flag to expire any existing relationships between the two parties of the same type. The idea
   * is that several services would do validation and then use this method to do all the work.
   *
   * @param partyIdTo
   * @param partyIdFrom
   * @param roleTypeIdFrom
   * @param partyRelationshipTypeId
   * @param securityGroupId
   * @param validToPartyRoles List of roleTypeIds which are valid for the partyIdTo in the create
   *     relationship. It will cycle through until the first of these roles is actually associated
   *     with partyIdTo and then create a PartyRelationship using that roleTypeId. If none of these
   *     are associated with partyIdTo, then it will return false
   * @param fromDate
   * @param expireExistingRelationships If set to true, will look for all existing
   *     PartyRelationships of partyIdFrom, partyRelationshipTypeId and expire all of them as of the
   *     passed in fromDate
   * @return false if no relationship was created or true if operation succeeds
   */
  public static boolean createNewPartyToRelationship(
      String partyIdTo,
      String partyIdFrom,
      String roleTypeIdFrom,
      String partyRelationshipTypeId,
      String securityGroupId,
      List<String> validToPartyRoles,
      Timestamp fromDate,
      boolean expireExistingRelationships,
      GenericValue userLogin,
      Delegator delegator,
      LocalDispatcher dispatcher)
      throws GenericEntityException, GenericServiceException {

    return org.opentaps.common.party.PartyHelper.createNewPartyToRelationship(
        partyIdTo,
        partyIdFrom,
        roleTypeIdFrom,
        partyRelationshipTypeId,
        securityGroupId,
        validToPartyRoles,
        fromDate,
        expireExistingRelationships,
        userLogin,
        delegator,
        dispatcher);
  }
Example #2
0
  /**
   * Retrieve the view url with partyId.
   *
   * @param partyId
   * @param delegator
   * @param externalLoginKey
   * @return view page url
   * @deprecated Use <code>org.opentaps.domain.party.Party.createViewPageURL()</code>
   */
  public static String createViewPageURL(
      String partyId, Delegator delegator, String externalLoginKey) throws GenericEntityException {
    GenericValue party =
        delegator.findByPrimaryKey("PartySummaryCRMView", UtilMisc.toMap("partyId", partyId));

    return org.opentaps.common.party.PartyHelper.createViewPageURL(
        party, CLIENT_PARTY_ROLES, externalLoginKey);
  }
Example #3
0
 /** Expires a list of PartyRelationships that are still active on expireDate. */
 public static void expirePartyRelationships(
     List<GenericValue> partyRelationships,
     Timestamp expireDate,
     LocalDispatcher dispatcher,
     GenericValue userLogin)
     throws GenericServiceException {
   org.opentaps.common.party.PartyHelper.expirePartyRelationships(
       partyRelationships, expireDate, dispatcher, userLogin);
 }
Example #4
0
 /**
  * Common method used by getCurrentlyResponsibleParty and related methods. This method will obtain
  * the first PartyRelationship found with the given criteria and return the PartySummaryCRMView
  * with partyId = partyRelationship.partyIdTo.
  *
  * @param partyRelationshipTypeId The party relationship (e.g., reps that are RESPONSIBLE_FOR an
  *     account)
  * @param partyIdFrom The partyId of the account/contact/lead
  * @param roleTypeIdFrom The role of the account/contact/lead (e.g., ACCOUNT, CONTACT, LEAD)
  * @param securityGroupId Optional securityGroupId of the relationship
  * @param activeDate Check only for active relationships as of this timestamp
  * @return First non-expired PartySummaryCRMView or null if none found
  */
 public static GenericValue getActivePartyByRole(
     String partyRelationshipTypeId,
     String partyIdFrom,
     String roleTypeIdFrom,
     String securityGroupId,
     Timestamp activeDate,
     Delegator delegator)
     throws GenericEntityException {
   return org.opentaps.common.party.PartyHelper.getActivePartyByRole(
       partyRelationshipTypeId,
       partyIdFrom,
       roleTypeIdFrom,
       securityGroupId,
       activeDate,
       delegator);
 }
Example #5
0
  /**
   * Method to copy all "To" relationships of a From party to another From party. For instance, use
   * this method to copy all relationships of an account (or optionally a specific relationship),
   * such as the managers and reps, over to a team. NOTE: This service works on unexpired
   * relationships as of now and will need to be refactored for other Dates.
   *
   * @param partyIdFrom
   * @param roleTypeIdFrom
   * @param partyRelationshipTypeId optional
   * @param newPartyIdFrom
   * @param newRoleTypeIdFrom
   */
  public static void copyToPartyRelationships(
      String partyIdFrom,
      String roleTypeIdFrom,
      String partyRelationshipTypeId,
      String newPartyIdFrom,
      String newRoleTypeIdFrom,
      GenericValue userLogin,
      Delegator delegator,
      LocalDispatcher dispatcher)
      throws GenericEntityException, GenericServiceException {

    org.opentaps.common.party.PartyHelper.copyToPartyRelationships(
        partyIdFrom,
        roleTypeIdFrom,
        partyRelationshipTypeId,
        newPartyIdFrom,
        newRoleTypeIdFrom,
        userLogin,
        delegator,
        dispatcher);
  }
Example #6
0
  /**
   * Generates a hyperlink to the correct view profile page for the given party with the standard
   * CRM party using createViewPageURL description string ${groupName} ${firstName} ${lastName}
   * (${partyId}). Some pages show list of all kinds of parties, including Leads, Accounts, and
   * non-CRM parties. This method generate a hyperlink to the correct view page, such as viewAccount
   * for Accounts, or partymgr viewprofile for non-CRM parties.
   *
   * @param partyId
   * @param delegator
   * @param externalLoginKey
   * @return view page url
   * @deprecated Use <code>org.opentaps.domain.party.Party.createViewPageLink()</code>
   */
  public static String createViewPageLink(
      String partyId, Delegator delegator, String externalLoginKey) throws GenericEntityException {
    GenericValue party =
        delegator.findByPrimaryKeyCache("PartySummaryCRMView", UtilMisc.toMap("partyId", partyId));
    if (party == null) {
      Debug.logError(
          "No PartySummaryCRMView found for partyId [" + partyId + "], cannot create link", MODULE);
      return "";
    }

    // generate the contents of href=""
    String uri =
        org.opentaps.common.party.PartyHelper.createViewPageURL(
            party, CLIENT_PARTY_ROLES, externalLoginKey);
    // generate the display name
    StringBuffer name = new StringBuffer(getCrmsfaPartyName(party));

    // put everything together
    StringBuffer buff = new StringBuffer("<a class=\"linktext\" href=\"");
    buff.append(uri).append("\">");
    buff.append(name).append("</a>");
    return buff.toString();
  }
Example #7
0
 /**
  * Retrieve the oldest current email address with a PRIMARY_EMAIL purposeTypeId for a party.
  *
  * @param partyId
  * @param delegator
  * @return The email address
  * @deprecated Use <code>org.opentaps.domain.party.Party.getPrimaryEmail()</code>
  */
 @Deprecated
 public static String getPrimaryEmailForParty(String partyId, Delegator delegator) {
   return org.opentaps.common.party.PartyHelper.getPrimaryEmailForParty(partyId, delegator);
 }
Example #8
0
 /**
  * A helper method which finds the first valid roleTypeId for a partyId, using a List of possible
  * roleTypeIds.
  *
  * @param partyId
  * @param possibleRoleTypeIds a List of roleTypeIds
  * @param delegator
  * @return the first roleTypeId from possibleRoleTypeIds which is actually found in PartyRole for
  *     the given partyId
  * @throws GenericEntityException
  */
 public static String getFirstValidRoleTypeId(
     String partyId, List<String> possibleRoleTypeIds, Delegator delegator)
     throws GenericEntityException {
   return org.opentaps.common.party.PartyHelper.getFirstValidRoleTypeId(
       partyId, possibleRoleTypeIds, delegator);
 }