NINAnor / NOFAInsert

QGIS plugin for batch inserting Darwin Core fish occurrence data into Norwegian Fish Atlas (NOFA) database.
https://ninanor.github.io/NOFAInsert/
GNU General Public License v3.0
3 stars 2 forks source link

Set most suitable default values for data entry #59

Open ninsbl opened 7 years ago

ninsbl commented 7 years ago

Currently, the default values are not always the most likely used values, so users almost always have to change / click. E.g.: default for "establishmentMeans" (as for all other non mandatory fields" should be "unknown" or NULL (esp. in Ecotype)... This seems to be new behavior.

svoboond commented 7 years ago

@ninsbl yes this is a new behaviour. The reason why I did it is because I had changed a way a user work with the occurrence table. Right now a user has to enter location only. Everything else is pre-selected. It was the easiest way otherwise I would have to check if everything compulsory was set. This check would have to be performed either before adding a new occurrence row or before inserting into the NOFA database. AFAIK this would be a bit complicated because you can not set a validator for QTableWidgetItem. One possibility is to use QLineEdit instead of QTableWidgetItem but then the table looks bad and some handy function like resizeColumnsToContents did not work.

svoboond commented 7 years ago

@ninsbl I didn't want to set any default value because there is no guarantee that the value will not be deleted from the database. Then there would be more problems in the future.

ninsbl commented 7 years ago

@svobond, OK, I think I get your very valid point. Smart to keep DB and Plugin/GUI as much as possible separated.

Do you think it would it help if we define default values on the DB level. Then you could fetch the defaults from there (see e.g.: https://stackoverflow.com/questions/8146448/get-the-default-values-of-table-columns-in-postgres if defaults exist) and use NULL otherwise... What do you think? Good default values can save quite some clicks/time when entering data...

svoboond commented 7 years ago

@ninsbl yes that would quite good

ninsbl commented 7 years ago

OK, I would say that this means we should do the following:

For starters, I defined default values in the occurrence table, so @svoboond has something to work with:

ALTER TABLE nofa.occurrence
    ALTER COLUMN "populationTrend" SET DEFAULT 'unknown';
ALTER TABLE nofa.occurrence
    ALTER COLUMN "spawningLocation" SET DEFAULT 'unknown';
ALTER TABLE nofa.occurrence
    ALTER COLUMN "spawningCondition" SET DEFAULT 'unknown';

I hope the defaults work, I was not sure if single quotes were required here or not...

@andersfi : We should go through the DB and check esp. in the primary tables where we can define default values. Maybe the meta tables could get default values too?

andersfi commented 7 years ago

A few more suggestions (not implemented in DB)

ALTER TABLE nofa.occurrence
    ALTER COLUMN "populationTrend" SET DEFAULT 'unknown';
ALTER TABLE nofa.occurrence
    ALTER COLUMN "spawningLocation" SET DEFAULT 'unknown';
ALTER TABLE nofa.occurrence
    ALTER COLUMN "spawningCondition" SET DEFAULT 'unknown';
ALTER TABLE nofa.occurrence
    ALTER COLUMN "organismQuantityType" SET DEFAULT NULL;
ALTER TABLE nofa.occurrence
    ALTER COLUMN "occurrenceStatus" SET DEFAULT 'unknown';
ALTER TABLE nofa.occurrence
    ALTER COLUMN "occurrenceStatus" SET DEFAULT NULL;
ALTER TABLE nofa.occurrence
    ALTER COLUMN "ecotypeID" SET DEFAULT NULL;
ALTER TABLE nofa.occurrence
    ALTER COLUMN "establishmentMeans" SET DEFAULT 'unknown';
ALTER TABLE nofa.event
    ALTER COLUMN "sampleSizeUnit" SET DEFAULT NULL;
ALTER TABLE nofa.event
    ALTER COLUMN "reliability" SET DEFAULT 'high';
ALTER TABLE nofa.event
    ALTER COLUMN "samplingProtocol" SET DEFAULT 'survey';
svoboond commented 7 years ago

@ninsbl @andersfi This is in contradiction with issue #66 where @andersfi wrote that only columns "occurrenceStatus" and "establishmentMeans" in table "nofa.occurrence" are mandatory and have default values.

What is correct then?

andersfi commented 7 years ago

Uh.. i probably forgot taxonID information that should be entered. Off course occurrence and event Id's, but they are invisible.

I'm on vacation rest of this week (will be offline - out off cell phone coverage)..

A.

Sendt fra min Samsung Galaxy-smarttelefon.

-------- Opprinnelig melding -------- Fra: svoboond notifications@github.com Dato: 17.08.2017 09:04 (GMT+01:00) Til: NINAnor/NOFAInsert NOFAInsert@noreply.github.com Ko: "Anders G. Finstad" anders.finstad@ntnu.no, Mention mention@noreply.github.com Emne: Re: [NINAnor/NOFAInsert] Set most suitable default values for data entry (#59)

@ninsblhttps://github.com/ninsbl @andersfihttps://github.com/andersfi This is in contradiction with issue #66https://github.com/NINAnor/NOFAInsert/issues/66 where @andersfihttps://github.com/andersfi wrote that only columns "occurrenceStatus" and "establishmentMeans" in table "nofa.occurrence" are mandatory and have default values.

What is correct then?

- You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/NINAnor/NOFAInsert/issues/59#issuecomment-322986575, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AKEIPV6E3tAOalpNzIWCP1RFZjJX3V-Eks5sY-W9gaJpZM4Onwk-.

svoboond commented 7 years ago

I will try to explain it in a different way.

In #66 you say "Note that non-mandatory fields when occurring in drop-down lists MUST have NULL as default value.". But here you say that even non-mandatory fields should have default values. What is the point of having null default value in plugin combo box when there is a default value set in database?

andersfi commented 7 years ago

Ah.. good point. Miss from my side.

A.

Sendt fra min Samsung Galaxy-smarttelefon.

-------- Opprinnelig melding -------- Fra: svoboond notifications@github.com Dato: 17.08.2017 09:23 (GMT+01:00) Til: NINAnor/NOFAInsert NOFAInsert@noreply.github.com Ko: "Anders G. Finstad" anders.finstad@ntnu.no, Mention mention@noreply.github.com Emne: Re: [NINAnor/NOFAInsert] Set most suitable default values for data entry (#59)

I will try to explain it in a different way.

In #66https://github.com/NINAnor/NOFAInsert/issues/66 you say "Note that non-mandatory fields when occurring in drop-down lists MUST have NULL as default value.". But here you say that even non-mandatory fields should have default values. What is the point of having null default value in plugin combo box when there is a default value set in database?

- You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/NINAnor/NOFAInsert/issues/59#issuecomment-322990411, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AKEIPY7L22NOg79Otsbcw34GKBFj3Rp5ks5sY-pfgaJpZM4Onwk-.

svoboond commented 7 years ago

From my point of view this has already been solved in #66, but for now I am changing milestone.

ninsbl commented 7 years ago

@svoboond I agree. We might provide default for example for recordedBy or the like, but that is fine tuning and nice to have. Changed it therefore to enhancement....