Giter Club home page Giter Club logo

project-6-working-copy's Introduction

Dictionary Aggregator Application

This is an example of a microservice application.

Aggregator Application

The aggregator application used for this microservice acts as a front-end for our application. It also aggregates and runs various algorithms to return the appropriate data.

The aggregator app has examples of:

  • REST services
  • REST client
  • 3-tier architecture
  • Basic POJO
  • Service layer
  • Controller layer
  • (Spring) dependency injection
  • HTTP request objects
  • Logging API

Dictionary Application

The dictionary used for this microservice is from https://github.com/matthewreagan/WebstersEnglishDictionary

The dictionary app has examples of:

  • REST services
  • 3-tier architecture
  • Basic POJO
  • Static methods
  • Static block
  • Private methods
  • Service layer
  • Controller layer
  • Data validation
  • (Spring) dependency injection
  • File I/O using the Java Stream API
  • Mapping JSON to an object
  • Logging API
  • Usage of constants
  • Logging performance metrics

Project 6 (Final) - 200 points

The following are instructions on how to complete project 6 for a grade as well as what you can do for extra credit.

Dictionary Application
  1. Add a method to the DictionaryService that returns all words that end with a certain value. To do this:
  • Copy the getWordsStartingWith method
  • Change the new method name to getWordsEndingWith
  • Change the method call inside your new method from .startsWith to .endsWith
  1. Add a method to the DictionaryController that calls your new service method and returns the words to the calling process. To do this:
  • Copy the getWordsStartingWith method
  • Change the new method name to getWordsEndingWith
  • Change the method call to the service to getWordsEndingWith, which calls the method you created in step 1 above.
  • Change the wording of the log message to reflect the new method's functionality.
  1. Test your new endpoint using a browser or Postman
Aggregation Application
  1. Add a method to the AggregatorRestClient that calls your new endpoint from above. To do this:
  • Copy the getWordsStartingWith method
  • Change the new method name to getWordsEndingWith
  • Change the URI to the URI of your new dictionary endpoint
  1. Add a method to the AggregatorService using the code below:
    public List<Entry> getAllPalindromes() {

        final List<Entry> candidates = new ArrayList<>();

        // Iterate from a to z
        IntStream.range('a', '{')
                 .mapToObj(i -> Character.toString(i))
                 .forEach(c -> {

                     // get words starting and ending with character
                     List<Entry> startsWith = restClient.getWordsStartingWith(c);
                     List<Entry> endsWith = restClient.getWordsEndingWith(c);

                     // keep entries that exist in both lists
                     List<Entry> startsAndEndsWith = new ArrayList<>(startsWith);
                     startsAndEndsWith.retainAll(endsWith);

                     // store list with existing entries
                     candidates.addAll(startsAndEndsWith);

                 });

        // test each entry for palindrome, sort and return
        return candidates.stream()
                         .filter(entry -> {
                             String word = entry.getWord();
                             String reverse = new StringBuilder(word).reverse()
                                                                     .toString();
                             return word.equals(reverse);
                         })
                         .sorted()
                         .collect(Collectors.toList());
    }
  1. Add a method to the AggregatorController that consumes the list of Entries generated by your new service method created in step 2 above. To do this:
  • Copy the method getDefinitionFor
  • Change the @GetMapping path of your new method to /getAllPalindromes
  • Remove the formal parameters from your new method (this endpoint doesn't take any user input).
  • On the method header, change the return type to List<Entry>
  • Change the service call to call the new service method created in step 2 above.
  1. Test your new aggregator endpoint using a browser or Postman
Extra Credit - 20 points
  • For extra credit, rewrite the palindrome service method to NOT use streams.
  • You get to decide when/where to use loops, if-statements, etc...
  • Method must return the same type (List<Entry>)
  • You can use an array or whatever you want to generate an array of alpha characters to iterate over.
  • Follow the pseudocode in the comments to come up with your own algorithm
  • The ultimate idea is to create an algorithm that gets words that start and end with the same letter and combine them and determine which are palindromes.

project-6-working-copy's People

Contributors

spyro1001 avatar

Stargazers

Keyth M Citizen  avatar

Watchers

 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.