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

Changeset user info #369

Closed
wants to merge 12 commits into from
Closed

Conversation

litvinovg
Copy link
Contributor

VIVO GitHub issue

What does this pull request do?

Provide information about actor who requested model changes to change listeners.

What's new?

Extended ModelChange interface with getUserId and setUserId methods
Modified ModelChangeImpl, ChangeSetImpl to provide utility methods that requires userId.
Deprecated methods that don't require userId.
Use RDFService to write changes in ProcessRdfForm defined by n3 generators, deprecated old public method.
Provide information with ChangeSets in DeleteIndividualController, JenaIngestController, TranslationConverter, ABoxRecomputer, RDFUploadController.
Modified ModelSelector's interface and implementations to provide information about graphs defined in EditConfigurationVTwo
Added tests to cover RDFService model changes notifications

How should this be tested?

  • Run tests
  • Try using n3 generators to add/delete data in profiles

Interested parties

@brianjlowe @chenejac

@ghost ghost linked an issue Feb 28, 2023 that may be closed by this pull request
Copy link
Contributor

@chenejac chenejac left a comment

Choose a reason for hiding this comment

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

@litvinovg thanks for the contribution. Can you please take a look into my comments?

@@ -659,7 +660,7 @@ private String processRenameResourceRequest(VitroRequest vreq) {
vreq.setAttribute("title","Rename Resource");
return RENAME_RESOURCE;
} else {
String result = doRename(oldNamespace, newNamespace);
String result = doRename(oldNamespace, newNamespace, vreq);
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you have some vision that some properties from VitroRequest might be needed into doRename method? I mean why you are not passing only N3EditUtils.getEditorURI(vreq) as you did in the ChangeSet addRemoval method?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@@ -315,7 +317,7 @@ private long operateOnModel(WebappDaoFactory webappDaoFactory,
OntModelSelector ontModelSelector,
boolean remove,
boolean makeClassgroups,
String userURI) {
String userURI, String userId) {
Copy link
Contributor

Choose a reason for hiding this comment

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

one parameter per line (it might be fixed by code style formatting, but please fix this if it is possible now :-) )

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

Comment on lines 286 to 319
public static void applyChangesToWriteModel(AdditionsAndRetractions changes, RDFService rdfService,
String defaultGraphUri, String editorUri) {
appyChangesToWriteModel(changes, editorUri, rdfService, defaultGraphUri);
}

@Deprecated
public static void applyChangesToWriteModel(AdditionsAndRetractions changes, Model writeModel, String editorUri) {
RDFService rdfService = new RDFServiceModel(writeModel);
appyChangesToWriteModel(changes, editorUri, rdfService, null);
}

private static void appyChangesToWriteModel(AdditionsAndRetractions changes, String editorUri,
RDFService rdfService, String graphUri) {
ChangeSet cs = rdfService.manufactureChangeSet();
cs.addPreChangeEvent(new BulkUpdateEvent(null, true));
cs.addPostChangeEvent(new BulkUpdateEvent(null, false));

ByteArrayOutputStream additionsStream = new ByteArrayOutputStream();
changes.getAdditions().write(additionsStream, "N3");
InputStream additionsInputStream = new ByteArrayInputStream(additionsStream.toByteArray());

ByteArrayOutputStream retractionsStream = new ByteArrayOutputStream();
changes.getRetractions().write(retractionsStream, "N3");
InputStream retractionsInputStream = new ByteArrayInputStream(retractionsStream.toByteArray());

cs.addAddition(additionsInputStream, RDFServiceUtils.getSerializationFormatFromJenaString("N3"), graphUri, editorUri);
cs.addRemoval(retractionsInputStream, RDFServiceUtils.getSerializationFormatFromJenaString("N3"), graphUri, editorUri);

try {
rdfService.changeSetUpdate(cs);
} catch (RDFServiceException e) {
log.error(e, e);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure I understand the reason for existence (decoupling) of the first and third methods in this part. Can you please double check can we merge that into one method? Also, I am not sure it is a good practice having methods only different in order of parameters.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should be fixed now

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 removed deprecated method as it is not used anywhere in the code and creation RDFService from model is not considered as a good practice.

Comment on lines +330 to +332
private String getClassUri() {
return "java:" + this.getClass().getCanonicalName();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

so, here the information about the user who requested changes will be actually java class, right? For me it is ok to log that as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. Class uri.

import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceUtils;
import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.jena.model.RDFServiceModel;

public class RDFServiceNotifictaionTest {
Copy link
Contributor

Choose a reason for hiding this comment

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

there is a typo in the name of the class - Notification

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@litvinovg litvinovg requested a review from chenejac March 1, 2023 11:14
Copy link
Contributor

@chenejac chenejac left a comment

Choose a reason for hiding this comment

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

well done, thanks

@@ -24,4 +24,9 @@ public OntModel getModel(HttpServletRequest request, ServletContext context) {

public static final ModelSelector selector = new StandardModelSelector();

@Override
public String getDefaultGraphUri() {
return ABOX_UNION;
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 found some errors in forms while using ABOX_UNION.
I haven't found any problems with ABOX_ASSERTIONS as default graph.
@brianjlowe Do you think it is ok to use ABOX_ASSERTIONS as a default graph?

@litvinovg
Copy link
Contributor Author

Superseded by #390

@litvinovg litvinovg closed this May 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants