Skip to content

Instructions for adding new fields

Grunthos edited this page Feb 28, 2013 · 14 revisions

Version 5.0+ Notes

As of version 5.0 it seems like a good idea to update this section. Rather than writing exhaustive documentation, I will link to specific commits where a field was added. If necessary I will add a field to demonstrate. This is a work in progress.

To collect new data

this commit shows how new fields (price & format) were obtained from Amazon. Ignore the SearchManager changes — they were about handling ASINs better. Other search providers follow a similar pattern.

Note that this commit all fields added in this commit already had key names defined in CatalogueDBAdapter.java. See “Repairing the Damage” below for a brief dicussion of using DOM_[ name ] instead of KEY_[ name ].

To display, update and manage new fields

This commit shows all changes needed to support a new field within the application.

It does not include the code for retrieving that field from the internet (not all can be), and does not (oops) include export/import code.

To handle import/export, including archival

This commit shows the changes need to support export/import/archival.

Note that no changes are needed for import so long as the column name matches the field name. Since Archival uses CSV exports, there are also no changes to the archive.

BookRowView.java was changed just because it makes code more readable and efficient.

Adding Suggestions to an AutoText

This commit shows how to add ‘Suggestions’ to the Language AutoText field.

(It also contains some minor layout cleanups).

Support for “Update from Internet”

This small commit shows the simple changes needed to support ‘Update From Internet’, assuming one of the data sources provides the field.

Adding a new style/sort grouping

This commit shows adding a new sort/style for the ‘Language’ field.

The basic approach is search for the text ‘NEWKIND’ and do what it says.

It is more complex when searching sub-tables etc, but see the other fields for examples.

Note: This commit had some deletions of specific static imports (replace with one wildcard), mainly to reduce maintenance in the future.

Repairing the damage

Early in adding the field I chose to be lazy and add KEY_LANGUAGE to CataogueDBAdapter; in recent versions I have been trying to use code in DatabaseDefinitions to manage domains and tables. It allows us to use one source for data fields and their definitions.

In this commit I just deleted KEY_LANGUAGE and repaired the resulting breakages by creating and using a DOM_LANGUAGE object.

Old Notes

This is considerably changed as of (somewhere around) v3.4. See notes below.

CatalogueDBAdapter

  1. Add to CREATE
  2. Add to onUpgrade
  3. Add to exportBooks
  4. (3.4) Add to getBookFields
  5. Add to fetchAllBooks (3.4: not needed)
  6. Add to fetchAllBooksByAuthor (3.4: not needed)
  7. Add to fetchAllBooksByLoan (3.4: not needed)
  8. Add to fetchAllBooksBySeries (3.4: not needed)
  9. Add to fetchBook (3.4: not needed)
  10. Add to fetchBookByISBN (3.4: not needed)
  11. fetchBookByISBNOrCombo (3.4: not needed)
  12. Add to searchBooks (3.4: not needed)
  13. Add to createBook (3.4: not needed)
  14. Add to updateBook (3.4: not needed)

edit_book / edit_book_notes.xml

  1. Update edit_book.xml

BookEditFields / BookEditNotes / BookEditAnthology

  1. Add private class variable (3.4: not needed)
  2. Add to onCreate (3.4: add a field to myFields — see, eg, KEY_PUBLISHER — may want validator, formatter etc)
  3. Update populateFields (from database) (3.4: not needed, if it’s just a ‘simple’ field)
  4. Update populateFields (from variable / activity – Fields only) (3.4: not needed, if it’s just a ‘simple’ field)
  5. Update saveState (3.4: not needed, if it’s just a ‘simple’ field)

BookISBNSearch

  1. Update comment in go
  2. Update searchGoogle
  3. Update searchAmazon

LibraryThingManager (3.4)
update SearchLibraryThingEntryHandler

SearchAmazonHandler

  1. Create public class variable (not in 3.4)
  2. update GetBook

SearchGoogleBooksEntryHandler

  1. Create public class variable (not in 3.4)
  2. update GetBook

FieldVisibility

  1. Add to setupFields (fields, fieldRs and compulsary)

AdminstrationFunctions

  1. Add to exportData (title and rows; moved in 3.4 – now in ExportThread.java)
  2. Add to ImportData (not needed in 3.4)