Package org.silverpeas.components.yellowpages.service

## Class DefaultYellowpagesService

- java.lang.Object
- - org.silverpeas.components.yellowpages.service.DefaultYellowpagesService

- All Implemented Interfaces:
    `YellowpagesService`

      @Service
      public class DefaultYellowpagesService
      extends Object
      implements YellowpagesService

  This is the Yellowpages Service layer to manage the yellow page application.
  Author:
    Nicolas Eysseric

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `DefaultYellowpagesService()` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `addContactToTopic​(org.silverpeas.core.contact.model.ContactPK contactPK, String fatherId)` | Add a contact to a topic and send email alerts to topic subscribers
    `void` | `addGroup​(String groupId, org.silverpeas.core.node.model.NodePK nodePK)` |
    `void` | `addGroup​(List<org.silverpeas.core.node.model.NodeDetail> tree, org.silverpeas.core.admin.user.model.Group group, int level)` |
    `void` | `addToTopic​(org.silverpeas.core.node.model.NodeDetail father, org.silverpeas.core.node.model.NodeDetail subTopic)` | Add a subtopic to a topic.
    `String` | `createContact​(org.silverpeas.core.contact.model.Contact contact, org.silverpeas.core.node.model.NodePK nodePK)` | Create a new Contact (only the header - parameters) to the current Topic
    `void` | `createInfoModel​(org.silverpeas.core.contact.model.ContactPK contactPK, String modelId)` | Create model info attached to a contact
    `void` | `deleteContact​(org.silverpeas.core.contact.model.ContactPK contactPK, org.silverpeas.core.node.model.NodePK nodePK)` | Delete a contact If this contact is in the basket or in the DZ, it's deleted from the database Else it only send to the basket
    `void` | `deleteContactFromTopic​(org.silverpeas.core.contact.model.ContactPK contactPK, String fatherId)` | Delete a path between contact and topic
    `void` | `deleteTopic​(org.silverpeas.core.node.model.NodePK pkToDelete)` | Delete a topic and all descendants.
    `void` | `emptyDZByUserId​(String instanceId, String userId)` |
    `Collection<org.silverpeas.core.contact.model.ContactFatherDetail>` | `getAllContactDetails​(org.silverpeas.core.node.model.NodePK nodePK)` |
    `org.silverpeas.core.contact.model.CompleteContact` | `getCompleteContact​(org.silverpeas.core.contact.model.ContactPK contactPK)` |
    `org.silverpeas.core.contact.model.CompleteContact` | `getCompleteContactInNode​(org.silverpeas.core.contact.model.ContactPK contactPK, String nodeId)` | Return all info of a contact
    `org.silverpeas.core.contact.model.ContactDetail` | `getContactDetail​(org.silverpeas.core.contact.model.ContactPK contactPK)` | Return the detail of a contact (only the Header)
    `Collection<org.silverpeas.core.contact.model.ContactDetail>` | `getContactDetailsByLastName​(org.silverpeas.core.contact.model.ContactPK pk, String query)` |
    `Collection<org.silverpeas.core.contact.model.ContactDetail>` | `getContactDetailsByLastNameAndFirstName​(org.silverpeas.core.contact.model.ContactPK pk, String lastName, String firstName)` |
    `Collection<org.silverpeas.core.contact.model.ContactDetail>` | `getContactDetailsByLastNameOrFirstName​(org.silverpeas.core.contact.model.ContactPK pk, String query)` |
    `Collection<org.silverpeas.core.node.model.NodePK>` | `getContactFathers​(org.silverpeas.core.contact.model.ContactPK contactPK)` |
    `Collection<UserContact>` | `getContacts​(Collection<String> contactIds, String instanceId)` | Return a collection of ContactDetail throught a collection of contact ids
    `List<org.silverpeas.core.admin.user.model.Group>` | `getGroups​(org.silverpeas.core.node.model.NodePK pk)` | Gets `GroupState.VALID` `Group` hosted by the given node.
    `Collection<String>` | `getModelUsed​(String instanceId)` |
    `List<Collection<org.silverpeas.core.node.model.NodeDetail>>` | `getPathList​(org.silverpeas.core.contact.model.ContactPK contactPK)` | Return list of all path to this contact - it's a Collection of NodeDetail collection
    `org.silverpeas.core.node.model.NodeDetail` | `getSubTopicDetail​(org.silverpeas.core.node.model.NodePK pk)` | Return a subtopic to currentTopic
    `List<org.silverpeas.core.node.model.NodeDetail>` | `getTree​(String instanceId)` |
    `TopicDetail` | `goTo​(org.silverpeas.core.node.model.NodePK pk, String userId)` | Return a the detail of a topic
    `void` | `index​(String instanceId)` |
    `void` | `removeGroup​(String groupId)` |
    `void` | `removeGroup​(String groupId, org.silverpeas.core.node.model.NodePK nodePK)` |
    `void` | `setModelUsed​(String[] models, String instanceId)` |
    `void` | `unreferenceOrphanContacts​(org.silverpeas.core.contact.model.ContactPK contactPK)` |
    `void` | `updateContact​(org.silverpeas.core.contact.model.Contact contactDetail)` | Update a contact (only the header - parameters)
    `void` | `updateTopic​(org.silverpeas.core.node.model.NodeDetail topic)` | Update a subtopic to currentTopic.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### DefaultYellowpagesService

          public DefaultYellowpagesService()

  - ### Method Detail

    - #### goTo

          public TopicDetail goTo​(org.silverpeas.core.node.model.NodePK pk,
                                  String userId)

      Return a the detail of a topic
      Specified by:
        `goTo` in interface `YellowpagesService`
      Parameters:
        `pk` - the id of the topic
      Returns:
        a TopicDetail
      See Also:
        `TopicDetail`

    - #### getTree

          public List<org.silverpeas.core.node.model.NodeDetail> getTree​(String instanceId)

      Specified by:
        `getTree` in interface `YellowpagesService`

    - #### addGroup

          public void addGroup​(List<org.silverpeas.core.node.model.NodeDetail> tree,
                               org.silverpeas.core.admin.user.model.Group group,
                               int level)

    - #### addToTopic

          public void addToTopic​(org.silverpeas.core.node.model.NodeDetail father,
                                 org.silverpeas.core.node.model.NodeDetail subTopic)

      Description copied from interface: `YellowpagesService`
      Add a subtopic to a topic. Does nothing if a subtopic with the same name exists in the father topic.
      Specified by:
        `addToTopic` in interface `YellowpagesService`
      Parameters:
        `father` - the father
        `subTopic` - the NodeDetail of the new sub topic
      See Also:
        `NodeDetail`, `NodePK`

    - #### updateTopic

          public void updateTopic​(org.silverpeas.core.node.model.NodeDetail topic)

      Description copied from interface: `YellowpagesService`
      Update a subtopic to currentTopic. Does nothing if the topic to update is at the same level than another sibling topic.
      Specified by:
        `updateTopic` in interface `YellowpagesService`
      Parameters:
        `topic` - the NodeDetail of the updated sub topic
      See Also:
        `NodeDetail`, `NodePK`

    - #### getSubTopicDetail

          public org.silverpeas.core.node.model.NodeDetail getSubTopicDetail​(org.silverpeas.core.node.model.NodePK pk)

      Description copied from interface: `YellowpagesService`
      Return a subtopic to currentTopic
      Specified by:
        `getSubTopicDetail` in interface `YellowpagesService`
      Parameters:
        `pk` - the id of the researched topic
      Returns:
        the detail of the specified topic
      See Also:
        `NodeDetail`

    - #### deleteTopic

          public void deleteTopic​(org.silverpeas.core.node.model.NodePK pkToDelete)

      Delete a topic and all descendants. Delete all links between descendants and contacts. This contacts will be visible in the Declassified zone. Delete All subscriptions and favorites on this topics and all descendants
      Specified by:
        `deleteTopic` in interface `YellowpagesService`
      Parameters:
        `pkToDelete` - the id of the topic to delete

    - #### getContactDetail

          public org.silverpeas.core.contact.model.ContactDetail getContactDetail​(org.silverpeas.core.contact.model.ContactPK contactPK)

      Return the detail of a contact (only the Header)
      Specified by:
        `getContactDetail` in interface `YellowpagesService`
      Parameters:
        `contactPK` - the id of the contact
      Returns:
        a ContactDetail
      See Also:
        `ContactDetail`

    - #### getContactDetailsByLastName

          public Collection<org.silverpeas.core.contact.model.ContactDetail> getContactDetailsByLastName​(org.silverpeas.core.contact.model.ContactPK pk,
                                                                                                         String query)

      Specified by:
        `getContactDetailsByLastName` in interface `YellowpagesService`

    - #### getContactDetailsByLastNameOrFirstName

          public Collection<org.silverpeas.core.contact.model.ContactDetail> getContactDetailsByLastNameOrFirstName​(org.silverpeas.core.contact.model.ContactPK pk,
                                                                                                                    String query)

      Specified by:
        `getContactDetailsByLastNameOrFirstName` in interface `YellowpagesService`

    - #### getContactDetailsByLastNameAndFirstName

          public Collection<org.silverpeas.core.contact.model.ContactDetail> getContactDetailsByLastNameAndFirstName​(org.silverpeas.core.contact.model.ContactPK pk,
                                                                                                                     String lastName,
                                                                                                                     String firstName)

      Specified by:
        `getContactDetailsByLastNameAndFirstName` in interface `YellowpagesService`

    - #### getAllContactDetails

          public Collection<org.silverpeas.core.contact.model.ContactFatherDetail> getAllContactDetails​(org.silverpeas.core.node.model.NodePK nodePK)

      Specified by:
        `getAllContactDetails` in interface `YellowpagesService`

    - #### getPathList

          public List<Collection<org.silverpeas.core.node.model.NodeDetail>> getPathList​(org.silverpeas.core.contact.model.ContactPK contactPK)

      Return list of all path to this contact - it's a Collection of NodeDetail collection
      Specified by:
        `getPathList` in interface `YellowpagesService`
      Parameters:
        `contactPK` - the id of the contact
      Returns:
        a Collection of NodeDetail collection
      See Also:
        `NodeDetail`

    - #### createContact

          public String createContact​(org.silverpeas.core.contact.model.Contact contact,
                                      org.silverpeas.core.node.model.NodePK nodePK)

      Create a new Contact (only the header - parameters) to the current Topic
      Specified by:
        `createContact` in interface `YellowpagesService`
      Parameters:
        `contact` - a contact
      Returns:
        the id of the new contact
      See Also:
        `Contact`

    - #### updateContact

          public void updateContact​(org.silverpeas.core.contact.model.Contact contactDetail)

      Update a contact (only the header - parameters)
      Specified by:
        `updateContact` in interface `YellowpagesService`
      Parameters:
        `contactDetail` - a ContactDetail
      See Also:
        `Contact`

    - #### deleteContact

          public void deleteContact​(org.silverpeas.core.contact.model.ContactPK contactPK,
                                    org.silverpeas.core.node.model.NodePK nodePK)

      Delete a contact If this contact is in the basket or in the DZ, it's deleted from the database Else it only send to the basket
      Specified by:
        `deleteContact` in interface `YellowpagesService`
      Parameters:
        `contactPK` - the id of the contact to delete
      See Also:
        `TopicDetail`

    - #### emptyDZByUserId

          public void emptyDZByUserId​(String instanceId,
                                      String userId)

      Specified by:
        `emptyDZByUserId` in interface `YellowpagesService`

    - #### addContactToTopic

          public void addContactToTopic​(org.silverpeas.core.contact.model.ContactPK contactPK,
                                        String fatherId)

      Add a contact to a topic and send email alerts to topic subscribers
      Specified by:
        `addContactToTopic` in interface `YellowpagesService`
      Parameters:
        `contactPK` - the id of the contact
        `fatherId` - the id of the topic

    - #### deleteContactFromTopic

          public void deleteContactFromTopic​(org.silverpeas.core.contact.model.ContactPK contactPK,
                                             String fatherId)

      Delete a path between contact and topic
      Specified by:
        `deleteContactFromTopic` in interface `YellowpagesService`
      Parameters:
        `contactPK` - the id of the contact
        `fatherId` - the id of the topic

    - #### createInfoModel

          public void createInfoModel​(org.silverpeas.core.contact.model.ContactPK contactPK,
                                      String modelId)

      Create model info attached to a contact
      Specified by:
        `createInfoModel` in interface `YellowpagesService`
      Parameters:
        `contactPK` - the id of the contact
        `modelId` - the id of the selected model

    - #### getCompleteContactInNode

          public org.silverpeas.core.contact.model.CompleteContact getCompleteContactInNode​(org.silverpeas.core.contact.model.ContactPK contactPK,
                                                                                            String nodeId)

      Return all info of a contact
      Specified by:
        `getCompleteContactInNode` in interface `YellowpagesService`
      Parameters:
        `contactPK` - the id of a contact
        `nodeId` - the id of the node
      Returns:
        a CompleteContact
      See Also:
        `CompleteContact`

    - #### getCompleteContact

          public org.silverpeas.core.contact.model.CompleteContact getCompleteContact​(org.silverpeas.core.contact.model.ContactPK contactPK)

      Specified by:
        `getCompleteContact` in interface `YellowpagesService`

    - #### getContacts

          public Collection<UserContact> getContacts​(Collection<String> contactIds,
                                                     String instanceId)

      Return a collection of ContactDetail throught a collection of contact ids
      Specified by:
        `getContacts` in interface `YellowpagesService`
      Parameters:
        `contactIds` - a collection of contact ids
      Returns:
        a collection of ContactDetail
      See Also:
        `ContactDetail`

    - #### getContactFathers

          public Collection<org.silverpeas.core.node.model.NodePK> getContactFathers​(org.silverpeas.core.contact.model.ContactPK contactPK)

      Specified by:
        `getContactFathers` in interface `YellowpagesService`

    - #### unreferenceOrphanContacts

          public void unreferenceOrphanContacts​(org.silverpeas.core.contact.model.ContactPK contactPK)

    - #### getGroups

          public List<org.silverpeas.core.admin.user.model.Group> getGroups​(org.silverpeas.core.node.model.NodePK pk)

      Description copied from interface: `YellowpagesService`
      Gets `GroupState.VALID` `Group` hosted by the given node.
      Specified by:
        `getGroups` in interface `YellowpagesService`
      Parameters:
        `pk` - the reference to a node.
      Returns:
        a list of `GroupState.VALID` `Group` instance.

    - #### addGroup

          public void addGroup​(String groupId,
                               org.silverpeas.core.node.model.NodePK nodePK)

      Specified by:
        `addGroup` in interface `YellowpagesService`

    - #### removeGroup

          public void removeGroup​(String groupId)

      Specified by:
        `removeGroup` in interface `YellowpagesService`

    - #### removeGroup

          public void removeGroup​(String groupId,
                                  org.silverpeas.core.node.model.NodePK nodePK)

      Specified by:
        `removeGroup` in interface `YellowpagesService`

    - #### setModelUsed

          public void setModelUsed​(String[] models,
                                   String instanceId)

      Specified by:
        `setModelUsed` in interface `YellowpagesService`

    - #### getModelUsed

          public Collection<String> getModelUsed​(String instanceId)

      Specified by:
        `getModelUsed` in interface `YellowpagesService`

    - #### index

          public void index​(String instanceId)

      Specified by:
        `index` in interface `YellowpagesService`