Update "validation-panel-table" with custom values
Having trouble deploying Oxygen XML Web Author? Got a bug to report? Post it all here.
Update "validation-panel-table" with custom values
Hello,
We use oxygen 27 and we want to add customs elements in the validation panel (validation-panel-table).
We have our own validation rules (functional rules) and we want to add errors to your existing validation panel.
In our sdk application, we have extended ValidationProblemsFilter api and it works fine.
We have override filterValidationProblems method and add our class in WSEditor like this
wsEditor.addValidationProblemsFilter(validationProblemsFilter);
I have found the WebappDocumentValidator api, and I retrieve correctly the existing xsd errors with documentValidator.getValidationTask().call();
But how can I add our functional errors into your validator ?
Thanks
Regards,
Isabelle
We use oxygen 27 and we want to add customs elements in the validation panel (validation-panel-table).
We have our own validation rules (functional rules) and we want to add errors to your existing validation panel.
In our sdk application, we have extended ValidationProblemsFilter api and it works fine.
We have override filterValidationProblems method and add our class in WSEditor like this
wsEditor.addValidationProblemsFilter(validationProblemsFilter);
I have found the WebappDocumentValidator api, and I retrieve correctly the existing xsd errors with documentValidator.getValidationTask().call();
But how can I add our functional errors into your validator ?
Thanks
Regards,
Isabelle
Re: Update "validation-panel-table" with custom values
Hello,
You can use the method: ro.sync.exml.workspace.api.editor.validation.ValidationProblems.addValidationProblems(ValidationProblems) [1] to add validation problems.
Another way to add validation problems is to use a Schematron schema into your framework [2].
If none of these proposals suit you, please provide us with more details about what you want to achieve/use case.
[1] https://www.oxygenxml.com/InstData/Edit ... nProblems)
[2] https://www.oxygenxml.com/doc/versions/ ... chema.html
You can use the method: ro.sync.exml.workspace.api.editor.validation.ValidationProblems.addValidationProblems(ValidationProblems) [1] to add validation problems.
Another way to add validation problems is to use a Schematron schema into your framework [2].
If none of these proposals suit you, please provide us with more details about what you want to achieve/use case.
[1] https://www.oxygenxml.com/InstData/Edit ... nProblems)
[2] https://www.oxygenxml.com/doc/versions/ ... chema.html
Cosmin Eftenie
www.oxygenxml.com
www.oxygenxml.com
Re: Update "validation-panel-table" with custom values
Hello Cosmin,
Thank you for your reply.
Can you show me an example of ValidationProblems use ?
How can I retrieve this element ? From WSEditor ?
Thanks.
Regards,
Isabelle
Thank you for your reply.
Can you show me an example of ValidationProblems use ?
How can I retrieve this element ? From WSEditor ?
Thanks.
Regards,
Isabelle
Re: Update "validation-panel-table" with custom values
Hello,
We have a sample plugin [1] in this regard.
In sample code [2], a filter is demonstrated that removes all validation problems with a SEVERITY_WARN level from the list.
To add a validation error with SEVERITY_ERROR level, you can use something like this:
and to see the custom error, you need to test it on an invalid document with validation errors; if the document is valid, the errors will not appear.
Best,
Cosmin
[1] https://github.com/oxygenxml/web-author ... ems-filter
[2] https://github.com/oxygenxml/web-author ... ilter.java
We have a sample plugin [1] in this regard.
In sample code [2], a filter is demonstrated that removes all validation problems with a SEVERITY_WARN level from the list.
To add a validation error with SEVERITY_ERROR level, you can use something like this:
Code: Select all
DocumentPositionedInfo newProblem = new DocumentPositionedInfo(DocumentPositionedInfo.SEVERITY_ERROR, "This is a custom error");
problemsList.add(newProblem);
Best,
Cosmin
[1] https://github.com/oxygenxml/web-author ... ems-filter
[2] https://github.com/oxygenxml/web-author ... ilter.java
Cosmin Eftenie
www.oxygenxml.com
www.oxygenxml.com
Re: Update "validation-panel-table" with custom values
Hello,
I still have issue with your solution.
To do our own validation, we need the AuthorDocumentModel.
To implement your solution I have done this :
When we call validation from toolbar, we use this
And I get an error because wsEditorAccess.checkValid(); is not available for web app.
How can I launch a document validation in JAVA ?
Thanks,
Regards,
Isabelle
I still have issue with your solution.
To do our own validation, we need the AuthorDocumentModel.
To implement your solution I have done this :
Code: Select all
public class CustomWorkspaceAccessPluginExtension implements WorkspaceAccessPluginExtension {
@Override
public void applicationStarted(StandalonePluginWorkspace pluginWorkspaceAccess) {
WebappPluginWorkspace workspace = (WebappPluginWorkspace) pluginWorkspaceAccess;
EditorChangeListener.init(pluginWorkspaceAccess);
workspace.addEditingSessionLifecycleListener(new WebappEditingSessionLifecycleListener() {
@Override
public void editingSessionStarted(String sessionId, AuthorDocumentModel documentModel) {
EditorChangeListener.getInstance().openingDocument(documentModel);
}
});
workspace.addEditorChangeListener(EditorChangeListener.getInstance(), PluginWorkspace.MAIN_EDITING_AREA);
}
}
Code: Select all
public class EditorChangeListener extends WSEditorChangeListener {
private static EditorChangeListener instance;
private final StandalonePluginWorkspace workspace;
private AuthorDocumentModel authorDocumentModel;
private Validation validation;
private EditorChangeListener(StandalonePluginWorkspace workspace) {
this.workspace = workspace;
}
public static void init(StandalonePluginWorkspace workspace) {
instance = new EditorChangeListener(workspace);
}
public static EditorChangeListener getInstance() {
return instance;
}
public void openingDocument(AuthorDocumentModel document) {
authorDocumentModel = document;
}
@Override
public void editorOpened(URL url) {
super.editorOpened(url);
validation = new Validation(authorDocumentModel);
final WSEditor editorAccess = workspace.getCurrentEditorAccess(PluginWorkspace.MAIN_EDITING_AREA);
if (editorAccess != null) {
editorAccess.addValidationProblemsFilter(brexValidation);
}
}
public BrexValidation getBrexValidation() {
return brexValidation;
}
public StandalonePluginWorkspace getWorkspace() {
return workspace;
}
}
Code: Select all
public final class Validation extends ValidationProblemsFilter {
private final AuthorDocumentModel authorDocumentModel;
private List<DocumentPositionedInfo> lastBusinessRulesErrorList = null;
public Validation(AuthorDocumentModel authorDocumentModel) {
this.authorDocumentModel = authorDocumentModel;
}
@Override
public void filterValidationProblems(ValidationProblems validationProblems) {
super.filterValidationProblems(validationProblems);
List<DocumentPositionedInfo> documentPositionedInfoList = validationProblems.getProblemsList();
if (documentPositionedInfoList == null) {
documentPositionedInfoList = new ArrayList<>();
}
lastBusinessRulesErrorList = getBusinessRulesErrorList();
documentPositionedInfoList.addAll(lastBusinessRulesErrorList);
validationProblems.setProblemsList(documentPositionedInfoList);
}
public Map<String, Integer> validateEntireDocument() {
lastBusinessRulesErrorList = getBusinessRulesErrorList();
WSEditor wsEditorAccess = EditorChangeListener.getInstance().getWorkspace().getCurrentEditorAccess(PluginWorkspace.MAIN_EDITING_AREA);
wsEditorAccess.checkValid();
return new HashMap<>();
}
private List<DocumentPositionedInfo> getBusinessRulesErrorList() {
List<DocumentPositionedInfo> businessRulesErrorList = new ArrayList<>();
// launch business rule validation based on authorDocumentModel information.
return businessRulesErrorList;
}
}
Code: Select all
@WebappCompatible
@WebappRestSafe
public class ValidationOperation extends AuthorOperationWithResult {
@Override
public String doOperation(AuthorDocumentModel authorDocumentModel, ArgumentsMap argumentsMap) throws IllegalArgumentException, AuthorOperationException {
try {
final BrexValidation validation = EditorChangeListener.getInstance().getBrexValidation();
validation.validateEntireDocument();
return "validation_ok";
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
How can I launch a document validation in JAVA ?
Thanks,
Regards,
Isabelle
Re: Update "validation-panel-table" with custom values
Hello,
When the automatic validation is performed in Web Author, the filterValidationProblems method is called. Here is how you should implement this method so that your problems appear in the in the Validation view, on each automatic validation:
Since your errors will be collected and rendered at each automatic validation, I think there is no need to add your own operation on the toolbar to trigger the validation. If I am wrong, please give us more details about your use case.
Best Regards,
Mihaela
When the automatic validation is performed in Web Author, the filterValidationProblems method is called. Here is how you should implement this method so that your problems appear in the in the Validation view, on each automatic validation:
Code: Select all
@Override
public void filterValidationProblems(ValidationProblems validationProblems) {
validationProblems.addValidationProblems(new ValidationProblems(getBusinessRulesErrorList(), ValidationProblems.VALIDATION_AUTOMATIC));
}
Since your errors will be collected and rendered at each automatic validation, I think there is no need to add your own operation on the toolbar to trigger the validation. If I am wrong, please give us more details about your use case.
Best Regards,
Mihaela
Mihaela Calotescu
http://www.oxygenxml.com
http://www.oxygenxml.com
Re: Update "validation-panel-table" with custom values
Hello,
We have to show a report validation in a modal.
Adding our own errors in your validation panel is only a part of our need.
That is why we need to add our own operation on the toolbar to trigger the validation.
Regards,
Isabelle
We have to show a report validation in a modal.
Adding our own errors in your validation panel is only a part of our need.
That is why we need to add our own operation on the toolbar to trigger the validation.
Regards,
Isabelle
Re: Update "validation-panel-table" with custom values
Hello,
Your operation should use the following code to obtain all the validation errors:
Best Regards,
Mihaela
Your operation should use the following code to obtain all the validation errors:
Code: Select all
AuthorDocumentModel authorDocumentModel = docModel.getAuthorDocumentModel();
WebappDocumentValidator documentValidator = authorDocumentModel.getDocumentValidator();
Callable<List<DocumentPositionedInfo>> validationTask = documentValidator.getValidationTask();
List<DocumentPositionedInfo> dpis = validationTask.call();
Mihaela
Mihaela Calotescu
http://www.oxygenxml.com
http://www.oxygenxml.com
Re: Update "validation-panel-table" with custom values
Hello,
I can add our functional errors in your validationProblems.
But regarding validation-panel-table panel, it is not refreshed.
Here is my use case :
I have to update the document (the value of an attribute for exemple) and then the panel is well refreshed with all errors.
Is it possible to force the refresh of the validation-panel-table panel ?
Thanks,
Regrads,
Isabelle
I can add our functional errors in your validationProblems.
But regarding validation-panel-table panel, it is not refreshed.
Here is my use case :
- I click on my toolbar button to launch the validation manualy
- Our code uses the method documentValidator.getValidationTask().call(); to launch filterValidationProblems(ValidationProblems validationProblems)
- In method filterValidationProblems(ValidationProblems validationProblems) we add our own functional errors to validationProblems [validationProblems.addValidationProblems(new ValidationProblems(lastBusinessRulesErrorList, ValidationProblems.VALIDATION_AUTOMATIC));]
- Our modal is well display with all the required informaions
I have to update the document (the value of an attribute for exemple) and then the panel is well refreshed with all errors.
Is it possible to force the refresh of the validation-panel-table panel ?
Thanks,
Regrads,
Isabelle
Re: Update "validation-panel-table" with custom values
Hello,
I understand that you want to trigger an automatic validation when your toolbar action is invoked, so that the Validation View to present the newly added custom validation problems.
There is no API to trigger an automatic validation, this happens only when the document is changed.
Best Regards,
Mihaela
I understand that you want to trigger an automatic validation when your toolbar action is invoked, so that the Validation View to present the newly added custom validation problems.
There is no API to trigger an automatic validation, this happens only when the document is changed.
Best Regards,
Mihaela
Mihaela Calotescu
http://www.oxygenxml.com
http://www.oxygenxml.com
Re: Update "validation-panel-table" with custom values
Hello,
Here is another idea: you can implement your own view that lists all the custom validation problems.
In this way you do not depend on the automatic validation.
Here is a a sample side-view implementation:
https://github.com/oxygenxml/web-author ... ments-view
Best Regards,
Mihaela
Here is another idea: you can implement your own view that lists all the custom validation problems.
In this way you do not depend on the automatic validation.
Here is a a sample side-view implementation:
https://github.com/oxygenxml/web-author ... ments-view
Best Regards,
Mihaela
Mihaela Calotescu
http://www.oxygenxml.com
http://www.oxygenxml.com
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service