Assignment 3 -- PTT13

Preparation

Always make sure to pull/clone/download the latest 101simplejava repo.

See the instructions here:

https://github.com/101companies/101simplejava/blob/master/README.md

Starting point

http://101companies.org/wiki/Contribution:javaParser (A recursive descent parser with event handling)

Task

The task consists of two milestones. First, extend the Contribution:javaParser to contain an implementation Feature:Depth. Second, revise the code to use a flat (denormalized) representation of companies.

Hint

First milestone

You need to override the methods openDept and closeDept to observe departmental nesting. Clone the parser for Feature:Total to have a starting point for Feature:Depth.

Second milestone

Let us clarify what is meant by "denormalized representation".

Here is the representation that is used by Contribution:javaParser:

company "ACME Corporation" {
        department "Research" {
                manager "Craig" {
                        address "Redmond"
                        salary 123456
                }
                employee "Erik" {
                        address "Utrecht"
                        salary 12345
                }
                employee "Ralf" {
                        address "Koblenz"
                        salary 1234
                }
        }
        department "Development" {
                manager "Ray" {
                        address "Redmond"
                        salary 234567
                }
                department "Dev1" {
                        manager "Klaus" {
                                address "Boston"
                                salary 23456
                        }
                        department "Dev1.1" {
                                manager "Karl" {
                                        address "Riga"
                                        salary 2345
                                }
                                employee "Joe" {
                                        address "Wifi City"
                                        salary 2344
                                }                       
                        }
                }
        }
}

Here is a proposal for a denormalized representation; there is just a flat list of companies, departments, and employees, where employees are qualified with data components for their company and department and departments are qualified by their company and parent department (if any).

company {
    name  "ACME Corporation"
}

department {
    name "Research"
    company "ACME Corporation"
}

department {
    name "Development"
    company "ACME Corporation"
}

department {
    name "Dev1"
    company "ACME Corporation"
    parent "Development"
}

department {
    name "Dev1.1"
    company "ACME Corporation"
    parent "Dev1"
}

employee {
    name "Craig"
    company "ACME Corporation"
    department "Research"
    address "Redmond"
    salary 123456
    manager true
}

employee {
    name "Erik"
    company "ACME Corporation"
    department "Research"
    address "Utrecht"
    salary 12345
    manager false
}

employee {
    name "Ralf"
    company "ACME Corporation"
    department "Research"
    address "Koblenz"
    salary 1234
    manager false
}

employee {
    name "Ray"
    company "ACME Corporation"
    department "Development"
    address "Redmond"
    salary 234567
    manager true
}

employee {
    name "Klaus"
    company "ACME Corporation"
    department "Dev1"
    address "Boston"
    salary 23456
    manager true
}

employee {
    name "Karl"
    company "ACME Corporation"
    department "Dev1.1"
    address "Riga"
    salary 2345
    manager true
}

employee {
    name  "Joe"
    company "ACME Corporation"
    department "Dev1.1"
    address "Wifi City"
    salary 2344
    manager false
}

You may want to define a grammar for this presentation before you start changing the parser.

Testing

You are allowed to kick out the implementation of Feature:Cut and the associated test case. You need to keep alive the tests for Feature:Total. You need to add basic tests for Feature:Depth, as requested per the first milestone of this assignment.