Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some enhancements and cleanups related to dates #1575

Merged
merged 14 commits into from
Jul 26, 2016

Conversation

oscargus
Copy link
Contributor

Based on the discussion in another PR (primarily @Siedlerchr as I recall) the date selector now returns the date in ISO format when applicable. Basically, it returns in ISO format for all BibLatex fields related to dates, while e.g. timestamp is still based on the preferences (there is a property FieldProperties.ISO_DATE which can be set to enable ISO format).

I also replaced some of the SimpelDateFormat usage with the new thread safe API.

Question: should we still support a user defined date format?

@oscargus oscargus added type: enhancement type: question cleanup-ops status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers labels Jul 12, 2016
@oscargus oscargus removed the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Jul 12, 2016
@oscargus oscargus added the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Jul 13, 2016
@@ -184,7 +184,8 @@ private InternalBibtexFields() {
add(new BibtexSingleField("eid", true, BibtexSingleField.SMALL_W));

dummy = new BibtexSingleField("date", true);
dummy.setPrivate();
dummy.setExtras(EnumSet.of(FieldProperties.DATE));
dummy.setPrivate(); // TODO: Why private?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I currently have no clear picture about private fields. This is the context of #574 😄

@simonharrer
Copy link
Contributor

Where is the configurable date format usable?

@oscargus
Copy link
Contributor Author

Right now it is used in the timestamp field as far as I know. I guess that people may have their own format and then if we remove it, there will be a bit of hassle...

if (isoFormat) {
dateFormatter = DateTimeFormatter.ISO_LOCAL_DATE;
} else {
String format = Globals.prefs.get(JabRefPreferences.TIME_STAMP_FORMAT);
Copy link
Member

@tobiasdiez tobiasdiez Jul 16, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we want to get away from using Globals.prefs in logic classes, I would propose to add constructors which takes the format as input. E.g.

EasyDateFormat(String dateFormat)
   this(DateTimeFormatter.ofPattern(dateFormat))

EasyDateFormat(DateTimeFormatter dateFormat)
   this.dateFormat = dateFormat;

static EasyDateFormat fromPreferences(JabRefPreferences preferences)
    return new EasyDateFormat(preferences.get(JabRefPreferences.TIME_STAMP_FORMAT));

static EasyDateFormat IsoDateFormat = new EasyDateFormat(DateTimeFormatter.ISO_LOCAL_DATE)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea! I changed it.

@tobiasdiez tobiasdiez removed the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Jul 16, 2016
@oscargus oscargus added the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Jul 16, 2016
@oscargus oscargus force-pushed the datefix branch 3 times, most recently from 15d6001 to 1ce26fa Compare July 17, 2016 18:36
@Siedlerchr
Copy link
Member

In general, JabRef should only focus on the bibtex/biblatex specification for the standard fields.
Only user defined fields should accept a different style.

@oscargus
Copy link
Contributor Author

oscargus commented Jul 20, 2016 via email

@koppor
Copy link
Member

koppor commented Jul 20, 2016

@oscargus The time discussion refs koppor#130. Maybe, we should migrate away from timestamp to date-added and date-modified and use the format already provided by some other software.

@Siedlerchr
Copy link
Member

I like the idea of having those two fields instead of the timestamp. We
should only make clear, that these fields are non standard biblatex/bibtex
fields.
As far as I found out, at least BibDesk uses them, from what I read maybe
Citavi or Mendely, too.

2016-07-20 19:18 GMT+02:00 Oliver Kopp notifications@github.com:

@oscargus https://github.com/oscargus The time discussion refs
koppor#130 koppor#130. Maybe, we
should migrate away from timestamp to date-added and date-modified and
use the format already provided by some other software.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#1575 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AATi5JgJtRf67CEiMMSVicRbsm1aCMi3ks5qXliAgaJpZM4JKNkH
.

@oscargus
Copy link
Contributor Author

Fine with me. I guess we should provide a migration functionality before dropping the configurable format and field name support.

@oscargus
Copy link
Contributor Author

I've rebased. Anything else at the moment?

@simonharrer
Copy link
Contributor

Could you sum up what has been done here, and the associated pros and cons? Especially regarding a CHANGELOG entry, this is required anyway.

@oscargus
Copy link
Contributor Author

oscargus commented Jul 21, 2016 via email

@oscargus
Copy link
Contributor Author

And: JabRef preferences are injected in a few places plus replacing an array with a List in ZipFileChooser.

@oscargus oscargus force-pushed the datefix branch 2 times, most recently from f5aaba6 to 1ff3337 Compare July 22, 2016 16:09
@simonharrer
Copy link
Contributor

What I think would be cool:

  1. Create two new fields (date-added, date-modified) which use default ISO-based time stamps which cannot be configured by the user. The user can only say that he wants these fields or not.
  2. Create a migration from timestamp to the new fields.
  3. Reuse the existing preference setting for the new fields. We should still use one setting to enable both fields and should not make it too fine granular.

@oscargus
Copy link
Contributor Author

I agree that those two fields are better. Won't happen in this PR though as it is a quite big job. See koppor#130 as well.

Anything else in this PR? See it as primarily making the format of the date field independent of the preferences (which it should be) and that we got rid of some of the SimpleDateFormat uses (see #1154, second checkbox almost clickable...).

@simonharrer
Copy link
Contributor

Then this is good to be merged.

@oscargus
Copy link
Contributor Author

Anyone has a good idea why the tests are failing? Locally they pass and Cookie is not even executed when running the test...

@Siedlerchr
Copy link
Member

Siedlerchr commented Jul 25, 2016

The problem is our custom Cookie handler which seems to be implicitly called by the HTTPUrlConnection.getResponseCode, considering the stacktrace:
And I guess it comes from the User Agent and is some Travis related stuff. Maybe travis uses some kind of proxy/whatever

Edit// Maybe you can change the date usage of the CookieHandler, too? Still uses SDF

 at net.sf.jabref.logic.net.Cookie.<init>(Cookie.java:85)

            at net.sf.jabref.logic.net.CookieHandlerImpl.put(CookieHandlerImpl.java:58)

            at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:728)

            at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:647)

            at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1536)

            at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1441)

            at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:480)

            ... 2 more

@oscargus
Copy link
Contributor Author

OK, turns out the problem was that the server started to use a two-digit year in the last few days... Now that format is also supported, although, as I understand it, it is not a valid format for a cookie.

@oscargus oscargus merged commit be338d9 into JabRef:master Jul 26, 2016
@oscargus oscargus deleted the datefix branch July 26, 2016 08:01
Siedlerchr added a commit to Siedlerchr/jabref that referenced this pull request Jul 26, 2016
* master:
  define xjc input/ouput dir (subsequent builds will be faster) (JabRef#1628)
  Consistent file name casing (and other localization improvements) (JabRef#1629)
  Builds are now stored via build-upload.jabref.org
  Some enhancements and cleanups related to dates (JabRef#1575)
  changes should be tested manually
  Cleanup FindFile and asssociated tests (JabRef#1596)
  More field names and a method (JabRef#1627)
  Moved, removed, and used String constants (JabRef#1618)
  Updated preview entries (JabRef#1606)
  Improved LaTeX to Unicode/HTML formatters to output more sensible values for unknown commands (JabRef#1622)
  Fixed JabRef#636 by using DOICheck and DOIStrip in export filters (JabRef#1624)
  Converted a few getField to getFieldOptional (JabRef#1625)
ayanai1 pushed a commit to ayanai1/jabref that referenced this pull request Aug 1, 2016
Move event (JabRef#1601)

* Move event package to model

Update dependencies: postgres 9.4.1208 -> 9.4.1209 and wiremock from 2.1.6 to 2.1.7

Added ISBN integrity checker (JabRef#1586)

 Added ISBN integrity checker

* Extracted ISBN class

Reenable errorprone (see http://errorprone.info/)

Extend the OpenConsoleFeature (JabRef#1582)

* Extend the OpenConsoleFeature by selection of custom terminal emulator.

- Add radio selection to the AdvancedTab
- Add new JabRefPreferences
- Add file check and execution commands
- Add localization keys

* Fix localization key.

* Move console selection to ExternalTab.java

* Change localization entry.

* Add command executor.

* Fix placeholder replacement.

* Fix codacy.

* Update localization key.

* Remove "Specify terminal emulator" option. Add GUI outputs.

* Set default command for Windows. Fix localization entries.

* Remove empty lines in language files.

* Use lambda expressions insead of ActionListeners

* Refactoring.

* Update CHANGELOG.md.

* Small refactorings.

Move preferences (JabRef#1604)

* Move preferences-related classes into separate package

* Rename JabRefPreferencesFilterDialog -> PreferencesFilterDialog and move it to gui

* Fix checkstyle warning

Set user agent to fix 403 status error

Replace getField with getFieldOptional in all of the tests and in som… (JabRef#1591)

* Replace getField with getFieldOptional in all of the tests and in some more code

* Some more conversions

Added filter to not show selected integrity checks (JabRef#1588)

* Added filter to not show selected integrity checks

* Removed unused variable

Some Globals.prefs injection in logic and model (JabRef#1593)

* Some Globals.prefs injection in logic and model

* Some more conversions and some fixes

* More injections

* Even more injections

* Yes, even more injections

* Indeed, even more injections

* Probably the last injections for now

* Removed unrequired dependency and fixed issue

* Dropped support for selecting sub/super to equations

* Added preference classes for LatexFieldFormatter and FieldContentParser

* Removed some left over code

* Added JournalAbbreviationPreferences

* Encapsulated LatexFieldFormatterPreferences in SavePreferences

* Changed getShortDescription to accept boolean argument

* Removed Globals.prefs from tests and removed unused imports

* Unused import

* Unused import

Rewrite MedlineImporter with JAXB and add nbib fields (JabRef#1479)

Add test in BibEntryWriterTest for type change

When clicking on a tab, the first field now has the focus (JabRef#988)

* the first Field does now have focus when clicking on a tab in the entry editor
* Make first field focused when selecting a tab in entry editor

The field list gets the focus as soon as it is focused (JabRef#1541)

Test CustomImporter (JabRef#1501)

* Test CustomImporter

Fixes imports

Added model.entry.FieldName that contains field name constants (JabRef#1602)

* Added model.entry.FieldName that contains field name constants

* More constants

* Renamed and added more constants

* Some more fields and cleanups

* Removed MedlineHandler left from merge conflicts

More fields added to FieldName (JabRef#1614)

* More fields added to FieldName

* Some Medline fixes

[WIP] Create new fetcher infrastructure (JabRef#1594)

* Introduce new Fetcher interfaces

* Refactor arXiv fulltext fetcher

* Add query based arXiv fetcher

* Reformat code

* Add a few tests for the arxiv parser

* Make new arXiv fetcher available

* Fix small problems related to files

* Fix tests

* Rename interface methods

* Add changelog entry

* Mark old EntryFetcher interface as deprecated

* Move fetcher to importer \ fetcher

* Move HelpFile from gui.help to logic.help

* Rename fetchers

* Rename FulltextFinder

* Optimize imports

* Fix failing test

* Ignore failing test

Added LayoutFormatterPreferences (and related files) (JabRef#1608)

* Added LayoutFormatterPreferences (and related files)

* Rebased

* Included JournalAbbreviationLoader in LayoutPreferences

Added more fields and fixed some issues (JabRef#1617)

Resolves JabRef#1613 Use Jabref default icon for uninstaller for now (JabRef#1616)

Always use https for help files (JabRef#1615)

Implemented JabRef#1345 - cleanup ISSN (JabRef#1590)

* Implemented JabRef#1345 - cleanup ISSN

* Fixed comments

* Extracted ISSN class

* Added tests for ISSN and ISBN

Added DateFormatter to LayoutEntry so that it actually works... (JabRef#1619)

Converted a few getField to getFieldOptional (JabRef#1625)

* Converted a few getField to getFieldOptional

Fixed JabRef#636 by using DOICheck and DOIStrip in export filters (JabRef#1624)

Improved LaTeX to Unicode/HTML formatters to output more sensible values for unknown commands (JabRef#1622)

Updated preview entries (JabRef#1606)

* Updated preview entries, which return new entry

Moved, removed, and used String constants (JabRef#1618)

* Moved, removed, and used String constants

* Some more fixes

* Moved NEWLINE, made FILE_SEPARATOR public and used it

* Moved NEWLINE and FILE_SEPARATOR to OS

* Moved ENCODING_PREFIX and SIGNATURE

* Corrected Globals in a few comments...

* Apparently the localization tests find commented out text...

More field names and a method (JabRef#1627)

* Introduced FieldName in ArXiV

* Some more field names

* More field names

Cleanup FindFile and asssociated tests (JabRef#1596)

* Cleanup FindFile and rework it using Streams and nio methods-
* Unignore test for trying on CI
* Use explicit List and Set in findFiles and caller methods
* Use Lazy Stream to find files

changes should be tested manually

Some enhancements and cleanups related to dates (JabRef#1575)

* Some enhancements and cleanups related to dates

* Fixed some time zone issues

* Replaced SimpleDateFormat in ZipFileChooser and replaced arrays with Lists

* Changed EasyDateFormat constructors

* Fixed stupid mistake

* Added CHANGELOG entry

* Maybe tests are passing now?

* Some server side print debugging...

* As it should be

* Tryng LocalDateTime

* No time zone

* Added test for Cookie

* Fixed imports...

* Added a third possible date format as it turns out that the server changed while developing this PR

Builds are now stored via build-upload.jabref.org

Consistent file name casing (and other localization improvements) (JabRef#1629)

* AUX files

* ZIP files

* BIB files

* JAR files

* didn't

* Couldn't what's

* Consistent casing

* AUX apparently is commonly used in French words...

* Fixed the flawed quick-and-dirty find-and-replace failures

define xjc input/ouput dir (subsequent builds will be faster) (JabRef#1628)

Execute task only when input/output dir changed.

Fixed a minor issue and refactored MergeEntries (JabRef#1634)

* Fixed a minor issue and refactored MergeEntries

* Fixed import

* Added CHANGELOG entry

Added LabelPatternPreferences (JabRef#1607)

* Added LabelPatternPreferences

* Removed static initializer

More tests (JabRef#1635)

* Added more tests for Cookie

* Enabled some layout tests and added test for StringUtil.intValueOfWithNull

* Updated a test

* Split tests

Updated Errorprone to 2.0.11 (JabRef#1636)

* Updated Errorprone to 2.0.11

* Corrected test

Keep @comment text in a bib file (JabRef#1638)

* Kep @comment text in a bib file

* Add test for @comment that contains regular entries

Replaced some getField and fixed some bugs (JabRef#1631)

* Replaced some getField and fixed some bugs

* Fixed a few things

* Added CHANGELOG entries

* Improved equals implementation

* Text book equals and hashCode

Fixed JabRef#1639 (JabRef#1641)

* Fixed JabRef#1639

* Removed old code

Export OO/LO citations to new database (JabRef#1630)

* Export OO/LO citations to new database

* Fixed problem with duplicates

* Added some comments

* Fixed spelling in comment

* Removed general Exception

Unified some equals (JabRef#1640)

* Unified some equals

* Imported correct Objects...

Fixed one more NPE which should have been fixed in JabRef#1631 (JabRef#1649)

Finished method to hide visible fields and show hidden fields

- Hide method done
- Show method done
- ToDo repaint hidden field
- ToDo test class

finished field repaint

remove sysouts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cleanup-ops status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers type: enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants