Code Monkey home page Code Monkey logo

liferay-training's Introduction

Introduction to Liferay development

This source is a implementation of the training materials to Liferay development.

All steps to create this app can be found at Developing a Web Application section.

Update Search to Liferay 7.1

More information about how Liferay search api works can be found at:

Section 7.0 7.1
Search Link Coming soon
Introduction to liferay search Link Coming soon
Leveraging Search Link Coming soon

Steps

All changes are made on the guestbook-service module, search package. The steps are merged from this PR: #2 - Update Searching to Liferay 7.1

  1. Update dependencies.

    Add the api and spi search packages as dependencies on build.gradle.

    compileOnly group: "com.liferay", name: "com.liferay.portal.search.api", version: "2.0.0"
    compileOnly group: "com.liferay", name: "com. liferay.portal.search.spi", version: "2.0.0"

    See build.gradle.

  2. Refactor the BaseIndexer constructor.

    1. Implement the interface BaseSearcher.

      • Sets the default selected field names;
      • Makes the search results permissions-aware at search time, as well as in the index;
      • Sets filter search to true, enabling a document-by-document check of the search results’ VIEW permissions.

      See GuestbookSearcher.

    2. Create the SearchRegistrar components to register the new search service

      Those services do the following:

      • Sets the default selected field names;
      • Sets the default selected localized field names;
      • Sets the contributors (modelIndexWriterContributor and modelSummaryContributor);
      • Allow search on all languages.

      See EntrySearchRegistrar and GuestbookSearchRegistrar.

  3. Implement ModelPreFilterContributor.

    The same feature of BaseIndexer#postProcessContextBooleanFilter. This method is invoked while the main search query is being constructed.

    • Ensures that entities with the status STATUS_IN_TRASH are not added to the query.

    See EntryModelPreFilterContributor and GuestbookModelPreFilterContributor.

  4. Implement KeywordQueryContributor.

    The same feature of BaseIndexer#postProcessSearchQuery.

    • Add the localized values of any full text fields that might contribute to search relevance.

    See EntryKeywordQueryContributor and GuestbookKeywordQueryContributor.

  5. Implement ModelDocumentContributor.

    The same feature of BaseIndexer#doGetDocument.

    • Select the entity’s fields to build a search document that’s indexed by the search engine.

    See EntryModelDocumentContributor and GuestbookModelDocumentContributor.

  6. Implement ModelSummaryContributor.

    The same feature of BaseIndexer#createSummary.

    • Show a condensed, text-based version of the entity that can be displayed generically.

    See EntryModelSummaryContributor and GuestbookModelSummaryContributor.

  7. Implement ModelIndexerWriterContributor.

    The same feature of BaseIndexer#doReindex with an addition of a batch re-indexer.

    • Implements the classes which gets called when an entity is updated or a user explicitly triggers a reindex.
    • Reindex the Entry records when the Guestbook is guestbook has its name changed.

    See EntryModelSummaryContributor and GuestbookModelSummaryContributor.

  8. Deprecate the implementations of BaseIndexer.

Notice

  1. The implementation of hasPermission and doDelete is no longer needed.

  2. On the original doc (setting-the-guestbook-status and setting-the-entry-workflow-status) does not mention the use of @Indexable annotation above the updateStatus methods. It turns out that without this annotation, records are not displayed in search results after being approved in the workflow. Those annotation had been added on this commit before the updating to 7.1.

Use cases

Happy day

This simple use case checks the integration between the guestbook app and the Liferay's search engine.

  1. Add a Entry;
  2. Check if the entry is displayed in search results.

Happy day - Sequence diagram

Using permissions

This use case demonstrates how to test if the permission aware is enable for search.

  1. Add a Entry
  2. Check if the entry is displayed in search results;
  3. Log out from the portal;
  4. Check if the entry is not displayed in search results;

Using permissions - Sequence diagram

Using workflow

Workflow is a review process that ensures a submitted entity isn’t published before it’s reviewed. Enabling workflow in the guestbook application also prevents unapproved entries from appearing in search results.

The guestbook application allows to check if the search is integrated with workflow following this steps:

  1. Create a guestbook entry;
  2. Check if the entry is not displayed in search results;
  3. Approve the new entry in workflow;
  4. Check if the entry is displayed in search results.

Using workflow - Sequence diagram

liferay-training's People

Contributors

ifnazar avatar luanmaoski avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.