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

add script for addData #4104

Closed
wants to merge 2 commits into from

Conversation

Kathrin-Huber
Copy link
Contributor

first part of #3368

only adding a new metadata is supported. Either by a given value or by a given metadata .

Not supported yet:

  • deleting metadata
  • overwriting metadata
  • MetadataGroups overall

@matthias-ronge
Copy link
Collaborator

Before I start my review, first of all: I am pleased that you are making the copyData work again. But, I remember, we wanted to fundamentally reimplement it. Internally, the accesses are still passed on via the redirection interfaces for former UGH classes. In addition, new functionalities should be implemented, for example one should be able to access the parent documents. There was also an intranet page with a draft, but I'd have to look for it first.

Now to the specific pull request: Which of the following functionalities should be included in this PR?

/chapter[*]@destinationMetadataName = /@sourceMetadataName

  1. add source to all destination divisions if source exists and destination metadata does not exist on destination division
  2. overwrite destination metadata on destination division if source exists and destination metadata does exist on destination division
  3. do nothing if destination metadata is unspecified="forbidden" on destination division
  4. do nothing if destination division does not exist

/@kitodoProjectId = $process.project.id

  1. like above, with internal object values

/@constantMetadata = "lorem ipsum"

  1. like above, with strings

/chapter[*]@lastImage = #1/image[>]@index;

  1. like above, but with metadata from the respective structure (in first chapter, use value from last image of first chapter, in second chapter use value from last image in second chapter…)

@Kathrin-Huber
Copy link
Contributor Author

It's the smalles amount of funktionality.
It is adding a metadata at the given goal like @TitleDocMain
Its either filled with a given value (with "value") or it's taking the value of a given metadata (e.g @TitleDocMainShort)
It is always added to the root division, not concerning the ruleset.
Both things will be implemented later.
Also the replacement of object values (e.g. $process.project.id) is implemented later.

Can you point out, where old ugh classes are used?

@matthias-ronge
Copy link
Collaborator

Can you point out, where old ugh classes are used?

  • class CopierData uses LegacyDocStructHelperInterface, LegacyMetsModsDigitalDocumentHelper and LegacyPrefsHelper (imported)
  • class DataCopyrule uses LegacyMetsModsDigitalDocumentHelper (line 51, getDigitalDocument())
  • classes DestinationReferenceSelector, MetadataPathSelector and MetadataSelector use LegacyDocStructHelperInterface (also imported)

@Kathrin-Huber
Copy link
Contributor Author

None of those classes are used anymore in the KitodoScripts.
Stuff for export is adjusted later.

Copy link
Collaborator

@matthias-ronge matthias-ronge left a comment

Choose a reason for hiding this comment

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

What you are doing here is incompatible to the copyData syntax we used so far. Is this intentional? Your test may work, but only because it uses a "wrong" String script (assuming that the old syntax should be retained).

String metadataKey = "LegalNoteAndTermsOfUse";
String script = "action:addData " + metadataKey + "=PDM1.0";

So your copyData command is:

LegalNoteAndTermsOfUse=PDM1.0

But it should look like this:

/@LegalNoteAndTermsOfUse = "PDM1.0"

/ is the logical root element of the structure tree, @ means: descend into attached metadata structure (not in logical structure), here points to a metadata key LegalNoteAndTermsOfUse. White space. It is a question if white space is required for parsing the copyData commands. The old parser needed it. It should at least be optional. = overwrite or create operator. White space. String in quotes, to indicate it is a string.

(Left side argument must always start with a / character, right side arguments must always start with one of the following characters: / (metadata), " (constant string), $ (toString() of internal variable), or # (select division relative to left side).)

I see two different approaches here.

  1. If you want to quickly find a solution to add metadata to the root element of the logical structure tree, implement exactly that in the KitodoScriptService. In that case you don't need any special syntax, just:
  • action:addMetadata key:LegalNoteAndTermsOfUse value:PDM1.0
  • action:copyMetadata key:LegalNoteAndTermsOfUse value:TSL_ATS
  1. If the aim is to bring the copydata functionality back, we should then write tests first (or even: we should first work out the syntax that will be needed in the future. There were approaches to this in the intranet. And then write tests). And then implement the functionality so that the tests no longer fail. There is a large amount of functionality in this. Getting this right is not trivial.

This review is not an approval or a rejection. If you intend to change the existing copyData syntax, your PR should do what it does. In that case, it would be good to document the new syntax.

ServiceManager.getMetsService().save(workpiece, out);
ServiceManager.getProcessService().saveToIndex(data.getProcess(), false);
} catch (IOException | CustomResponseException | DataException e) {
System.out.println("log me");
Copy link
Collaborator

Choose a reason for hiding this comment

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

please use: Helper.setErrorMessage(e.getMessage(), logger, e)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm going to remove this class, and as PRs are stacking up please be generous to spare me conflicts. :-)

@Kathrin-Huber
Copy link
Contributor Author

This is a reimplementation of the copyData script. The resulting syntax may be slightly different, but the implementation is not done yet.
Currently, the metadata is always added at root level, so no selector at the goal metadata is requeired, just the key of the metadata.
If the selector functionality is implemented, a syntax for level selection will be integrated. I'm not sure yet, if this will map the old syntax, by I'm going to try to restore it.

@Kathrin-Huber Kathrin-Huber requested a review from solth December 7, 2020 10:24
@Kathrin-Huber
Copy link
Contributor Author

is replaced by #4112

@Kathrin-Huber Kathrin-Huber deleted the implement_copyData branch July 13, 2021 06:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants