Git Product home page Git Product logo

portfolio's Introduction

This service manages a stock portfolio. The data is backed by two DB2 tables, communicated with via JDBC. The following operations are available:

GET / - gets summary data for all portfolios.

POST /{owner} - creates a new portfolio for the specified owner.

GET /{owner} - gets details for the specified owner.

PUT /{owner} - updates the portfolio for the specified owner (by adding a stock).

DELETE /{owner} - removes the portfolio for the specified owner.

All operations return JSON. A portfolio object contains fields named owner, total, and loyalty, plus an array of stocks. A stock object contains fields named symbol, shares, price, total, and date. The only operation that takes any query params is the 'PUT' operation, which expects params named symbol and shares.

For example, doing a PUT http://localhost:9080/portfolio/John?symbol=IBM&shares=123 (against a freshly created portfolio for John) would return JSON like {"owner": "John", "total": 19120.35, "loyalty": "Bronze", "stocks": [{"symbol": "IBM", "shares": 123, "price": 155.45, "total": 19120.35, "date": "2017-06-26"}]}.

The above REST call would also add a row to the Stocks table via a SQL statement like INSERT INTO Stock (owner, symbol, shares, price, total, dateQuoted) VALUES ('John', 'IBM', 123, 155.45, 19120.35, '2017-06-26'), and would update the corresponding row in the Portfolio table via a SQL statement like UPDATE Portfolio SET total = 19120.35, loyalty = 'Bronze' WHERE owner = 'John'.

Note that the db2jcc4.jar file needs to be in the war file's 'WEB-INF/lib' directory. As a to-do, need to update the code to use a Liberty datasource, and make corresponding updates to the server.xml to define a JDBC provider for DB2 and to make that datasource available via JNDI lookup. For now, this service just talks to JDBC the Java SE way instead.

portfolio's People

Watchers

James Cloos 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.