Insert jabref-entrytype into meta.xml#16210
Conversation
PR Summary by QodoStore JabRef entry types in LibreOffice meta.xml (jabref-entrytype)
AI Description
Diagram
High-Level Assessment
Files changed (4)
|
Code Review by Qodo
1.
|
| } | ||
|
|
||
| try { | ||
| return Optional.ofNullable(GSON.fromJson(metadata, EntryTypeMetadata.class)); |
There was a problem hiding this comment.
I think GSSon.fromJson is non null
| static List<BibEntry> parseZoteroEntries(List<String> referenceMarkNames, Map<String, String> entryTypesInMetaData) { | ||
| List<BibEntry> entries = new ArrayList<>(); | ||
| for (String referenceMarkName : referenceMarkNames) { | ||
| if (ReferenceMark.isZoteroReferenceMarkName(referenceMarkName)) { |
There was a problem hiding this comment.
private static void applyStoredEntryType(BibEntry entry, Map<String, String> entryTypesByCitationKey) {
entry.getCitationKey()
.map(entryTypesByCitationKey::get)
.filter(entryType -> !StringUtil.isBlank(entryType))
.map(EntryTypeFactory::parse)
.ifPresent(entry::setType);
}
| } | ||
|
|
||
| EntryTypeMetadata entryTypeMetadata = parsedMetadata.get(); | ||
| Map<String, String> result = new LinkedHashMap<>(); |
There was a problem hiding this comment.
you can init the hashmap with the size of the metadata map, you know the size)
| assertEquals(1, entries.size()); | ||
| BibEntry entry = entries.getFirst(); | ||
| assertEquals(StandardEntryType.Book, entry.getType()); | ||
| assertEquals(Optional.of("Zotero-587"), entry.getCitationKey()); |
There was a problem hiding this comment.
use assertEquals over the whole entry
assertEquals(expectedBibEntry, actualEntry)
| private CitationEntryTypeMetadata() { | ||
| } | ||
|
|
||
| public static void storeZoteroEntryTypes(XTextDocument document) |
There was a problem hiding this comment.
I would keep the schema as a POJO and add another class. for the mehtods that work with it
There was a problem hiding this comment.
Extracted schema into CitationEntryTypeMetadata and made a manager
Related issues and pull requests
Closes #16209
PR Description
This PR inserts jabref-entrytype information into LibreOffice document's meta.xml.
Example:
Two scenarios will trigger this logic:
Steps to test
Rename .odt to .zip, unzip and open meta.xml
Look for keyword
meta:user-defined, notice that there are only Zotero side recordsOpen JabRef, connect the same document, repeat 2 again
Notice that there are JabRef side records
AI usage
I use codex 5.5 to help me create test and parsing/inserting metadata logic. All AI-generated code was reviewed by myself.
Checklist
CHANGELOG.mdin a way that can be understood by the average user (if change is visible to the user)AI usage
I use codex 5.5 to help me create test and parsing/inserting metadata logic. All AI-generated code was reviewed by myself.
Checklist
CHANGELOG.mdin a way that can be understood by the average user (if change is visible to the user)