For the completed code from this exercise see ElandingsClient.zip
The eLandings Look-up Codes files (i.e. Species Codes, Stat Areas Codes, Condition Codes, Gear Codes, etc.) are available for download at:
eLandings Look-up Code Files in XML format and eLandings Look-up Code Files in Human readable format
Download https://elandings.alaska.gov/elandings/XmlCodesLookup?event=xml&xml=species and save it to a file called species.xml within your Netbeans eLandingsClient project.
Within eLandings, we use these lookup code files to:
1. Validate a users data entry within a field
In eLandings, users create landing reports. Each landing report requires the user to define what type of species was caught while fishing. eLandings has a list of accepted species codes. Users are able to type in the species code quicker than typing in the full name of the species. eLanding can then check the species code list to see if the the user entered a species code that is recognized by eLandings.
2. Provide a user with a list of choices
In eLandings, while creating a landing report, users can define how fish were refrigerated on-board the vessel. These refrigeration or chill types are known as Chill codes. eLandings can dynamically create a dropdown combo-box listing all of the chill types available for a user to select from.
3. Communicate information concisely
When eLandings web service encounters a problem, the error, warning or information can often be described with a common message code. The web service client can look up the message id to display the information in a human readable form or lookup additional information associated with the message code.
You may also want to use eLandings codes within the web service client for similar purposes.
To work with eLandings codes download the Codes XSD file from the XML Schema page and save it to codes.xsd within your eLandingsClient project. For the test, training and production like see:
XML Resources and Documentation
We will be repeating several of the steps described in Tutorial 02 - Basic Connection + XML Handling
Go back to NetBeans
Right click on the Source Packages>New>Other
Click on
- XML
- JAXB Binding
- Next
Next, give it a name like codes. Then point it at the codes.xsd file that you placed in your Netbeans ElandingsClient project root. Then click Finished.
Netbeans will generate a number of java classes in Generated Sources (jaxb) folder.
Open the ELandingsClient.java file.
Within the main method copy and paste in the following code:
//Create a generatic unmarshaller javax.xml.bind.JAXBContext jaxbCtx = javax.xml.bind.JAXBContext.newInstance("generated"); javax.xml.bind.Unmarshaller unmarshaller = jaxbCtx.createUnmarshaller(); //Read in the species.xml file and parse it into a Codes object. FileInputStream input = new FileInputStream("species.xml"); Codes codes =(Codes)unmarshaller.unmarshal(input); //Get the list of species contained within the codes object, iterate over the list and display the species codes and names found therein. List<SpeciesDef> species = codes.getSpeciesDef(); for(SpeciesDef speciesDef:species){ System.out.println("Species "+speciesDef.getSpecies().getName()+" -- "+speciesDef.getSpecies().getValue().toString()); }
You now have a list of all the species codes that eLandings currently accepts. This approach can be used to load statareas, gear codes, chill types, etc. Typically, eLandings creates a resource jar file containing all of the lookup code files. These code files can then be bundled with a release.
Be aware that every year, a few minor changes are made to these code files. For example, once a year, a new species might be added or modified within the species.xml file.