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

Implement variable replacer for copy data #4112

Merged

Conversation

Kathrin-Huber
Copy link
Contributor

integrates variable replacer for #3368
follow-up PR to #4111

@Kathrin-Huber Kathrin-Huber force-pushed the implement_variableReplacerForCopyData branch from 403fef5 to ad864c7 Compare December 1, 2020 09:56
@Kathrin-Huber Kathrin-Huber force-pushed the implement_variableReplacerForCopyData branch from aca0a1a to b5051a9 Compare December 2, 2020 09:14
@Kathrin-Huber Kathrin-Huber force-pushed the implement_variableReplacerForCopyData branch from 5b02879 to 0fd979e Compare December 3, 2020 08:02
@Kathrin-Huber Kathrin-Huber requested a review from solth December 9, 2020 08:23
@@ -19,6 +19,7 @@
import org.apache.commons.configuration.ConfigurationException;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.kitodo.production.services.ServiceManager;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
import org.kitodo.production.services.ServiceManager;

Comment on lines 33 to 34
import org.kitodo.production.services.data.ImportService;
import org.primefaces.PrimeFaces;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
import org.kitodo.production.services.data.ImportService;
import org.primefaces.PrimeFaces;

import org.kitodo.exceptions.MetadataException;
import org.kitodo.production.helper.Helper;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
import org.kitodo.production.helper.Helper;

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

Choose a reason for hiding this comment

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

Use Helper or logger instead of System.out.println

*/
protected abstract int getMinObjects();
for (IncludedStructuralElement child : allIncludedStructuralElements) {
Collection<Metadata> metadata = child.getMetadata();
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Collection<Metadata> metadata = child.getMetadata();

metadata is never used

Comment on lines 28 to 29
import org.kitodo.data.elasticsearch.exceptions.CustomResponseException;
import org.kitodo.data.exceptions.DataException;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
import org.kitodo.data.elasticsearch.exceptions.CustomResponseException;
import org.kitodo.data.exceptions.DataException;

import org.kitodo.data.elasticsearch.exceptions.CustomResponseException;
import org.kitodo.data.exceptions.DataException;
import org.kitodo.production.helper.metadata.legacytypeimplementations.LegacyMetsModsDigitalDocumentHelper;
import org.kitodo.production.services.ServiceManager;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
import org.kitodo.production.services.ServiceManager;

Comment on lines 44 to 45
List<Metadata> metadataCollectionCopy = new ArrayList<>();
metadataCollectionCopy.addAll(metadataCollection);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
List<Metadata> metadataCollectionCopy = new ArrayList<>();
metadataCollectionCopy.addAll(metadataCollection);
List<Metadata> metadataCollectionCopy = new ArrayList<>(metadataCollection);

Helper.setMessage("overwriteDataOk", currentProcessTitle);
}
} catch (IOException e) {
Helper.setErrorMessage("overwriteDataError", currentProcessTitle + ":" + e.getMessage(), logger, e);
Copy link
Member

Choose a reason for hiding this comment

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

I am not sure if this will work. AFAIK only CDI managed beans have access to the FacesContext that is needed to render messages in the frontend pages. (same goes for the other usages of Helper.setMessage or Helper.setErrorMessage in this class.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is actually working!


import java.util.Collection;
import java.util.List;
import java.util.Objects;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
import java.util.Objects;

List<IncludedStructuralElement> allIncludedStructuralElements = workpiece
.getAllIncludedStructuralElements();

IncludedStructuralElement child = allIncludedStructuralElements.get(0);
Copy link
Member

Choose a reason for hiding this comment

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

Same as above. I think you should check if allIncludedStructuralElements contains an element before "getting" it.

@Kathrin-Huber Kathrin-Huber force-pushed the implement_variableReplacerForCopyData branch from a5913ba to 6660bca Compare December 11, 2020 13:39
@Kathrin-Huber Kathrin-Huber merged commit 178499f into kitodo:master Dec 14, 2020
@Kathrin-Huber Kathrin-Huber deleted the implement_variableReplacerForCopyData branch December 14, 2020 11:15
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