Coder Social home page Coder Social logo

suhlig / hdm-haushaltsbuch Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 3.55 MB

Demo app for a Bluemix workshop at HDM Stuttgart

Home Page: http://www.hhb.eu-gb.mybluemix.net/

License: Apache License 2.0

Java 82.87% CSS 7.67% Ruby 7.58% JavaScript 1.88%
academic hdm stuttgart workshop

hdm-haushaltsbuch's Introduction

HDM-Haushaltsbuch

The app is deployed to www.hhb.eu-gb.mybluemix.net.

Run

  1. Install eclipse tools
  2. Add a liberty-profile server for local testing
  3. Import the app into Eclipse
  4. Add a 'turtle'-sized ElephantSQL service instance
  5. Run on Server => Bluemix (the database tables will be auto-created)

Additional Information about the Eclipse tools is available at the Bluemix documentation site.

Exercises

Using TDD, implement the following features:

  1. Show a list of all categories at /categories/all
  2. Show all entries of a certain category at /entries/by-category

For each feature, add unit, integration and acceptance tests.

Tests

  • There are unit- and integration tests that can be run from Eclipse
  • The integration- and acceptance tests require a local Postgres
  • Acceptance tests require ruby. See the separate README.

Local Development

Context Root

The application specifies the context root itself as /, which can be changed in WEB-INF/ibm-web-ext.xml. It should override the setting in the server's server.xml, but in case it doesn't the contextRoot attribute of the webApplication element should be removed from server.xml.

Database connection

Bluemix provides the datasource for a bound service in JDNI. We could configure the local dev server in the same way, but to make development even simpler, we take a shortcut and manually initialize the PostgreSQL JDBC driver when testing locally. The code does this automatically; there are no manual steps to be taken.

Local PostgreSQL server

Add the currently logged on user as a new (password-less) PostgreSQL user:

# create a user
$ postgres -c "createuser --createdb --no-superuser --no-createrole $USER"

# start postgres
$ postgres -D /usr/local/var/postgres

# create the user's database (prereq for tests)
$ createdb

# create the database
$ createdb haushaltsbuch

If the database URL is specified without a host component (e.g. postgres:///haushaltsbuch), a local domain socket will be used for the Postgres connection. This avoids having to provide a separate password for the TCP connection.

The entries table auto-generates the UUID on insert. This requires the uuid-ossp extension to be available. It will be enabled automatically.

PostgreSQL Statement Logging

In order to see the raw SQL statements, logging can be enabled for the local postgres process:

$ psql postgres:///haushaltsbuch
# ALTER SYSTEM SET log_destination = 'stderr';
# ALTER SYSTEM SET log_statement = 'all';
# SELECT pg_reload_conf();

The last statement will apply the values. Alternatively, restart with pg_ctl reload -D /usr/local/var/postgres.

Troubleshooting

  • If Eclipse complains about Can not find the tag library descriptor for "http://java.sun.com/jsp/jstl/core", simply right-click the project and choose "Validate".

Design Notes

  • Input validation happens at two places: client-side (HTML form validation), where we are nice with the user, and at the database level, where we make sure only valid data enters the system. Right now there is no need for additional validation on the domain layer.

Contributing

Please see CONTRIBUTING.md.

License

HDM-Haushaltsbuch is Copyright© 2016 Steffen Uhlig. It is free software, and may be redistributed under the terms specified in the LICENSE file.

hdm-haushaltsbuch's People

Contributors

suhlig avatar

Watchers

 avatar  avatar

hdm-haushaltsbuch's Issues

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.