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

Dynapi parameters, io re-engineering #319

Merged
merged 39 commits into from Aug 23, 2022

Conversation

litvinovg
Copy link
Contributor

@litvinovg litvinovg commented Jul 20, 2022

What does this pull request do?

  • Align dynamic API ontology class names with convention
  • Convert dynamic API ontology to n3
  • renamed DefaultAction into NullAction
  • Re-engineering of OperationData and Converters in progress
  • Use jsonPath to load data from requests
  • Use json schema validation to validate input and output json.
  • Resource id is injected into input json body before processing by JsonConverter
  • Parameter can be declared as local. Local parameters are auto-created by api before processing input data.
  • ModelComponent was removed. Instead of ModelComponent DynapiModelFactory is used to create links to Vitro|VIVO models. Links are created by API for each request it required as done for all other local parameters.
  • Old data types were removed
  • ParameterTypes now store SerializationType and ImplementationType, also can contain type in case of arrays.
  • ImplementationType store serialisation and deserialization configs and class name to be created as a result of de-serialization.
  • View classes created to sort Data in DataStore, get data in most specific types required for components
  • Created Implementation configurations to store information how serialization and de-serialization should be done
  • Parameter conversion is done with information stored in ImplementationConfig. ConversionMethod that should do the conversion is created during Action initialization and stored in ImplementationType. Added tests for conversion.
  • Old converters were removed
  • requiredParameters were renamed to InputParameters
  • providedParameters were renamed to OutputParameters
  • DataStore replaced OperationData
  • Data class was removed and replaced with new Data class that stores Object data and serialized value provided by converters.
  • Defined parameter type JsonObjectArrayOfPairs to store all results of SPARQL Query.
  • Created ModelWriter component + unit and integration tests
  • Implemented content type negotiation in converter, added tests

@litvinovg litvinovg force-pushed the params branch 4 times, most recently from c9d7ac5 to 428b182 Compare July 29, 2022 13:20
@litvinovg litvinovg marked this pull request as ready for review August 10, 2022 15:45
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 I have reviewed your PR, it looks very well. I have provided a couple of comments. Moreover, the list of classes in the data.types package is a little bit strange, maybe that should be split into two packages.

Comment on lines +108 to +110
public Parameters getInternalParams() {
return internalParams;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the idea for definition of those internalParams? Is that also defined in n3 description of a dynamic action?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Parameters not required in request, but created for each action. VIVO models is one of such examples

import edu.cornell.mannlib.vitro.webapp.dynapi.components.Parameters;
import edu.cornell.mannlib.vitro.webapp.utils.configuration.Property;

public class JsonObjectSerializationType extends SerializationType {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why part of this serialization type is Json, and it is not the case for primitive and array serialization types (other classes in this package)?

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 represents tree structures. So it should be separate, but maybe renamed in future.

}
} else {
try {
if (!isInteger(data.getJsonValue())) {
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 this is the best way to decouple validator and data, I mean here is explicitly mentioned JSON format.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not really. It is serialized value, I will rename the method. It is also a json representation. So the validator always work with Strings.
Still we will need data specific validators to be applied only to specific data types. That should be resolved in future.

import edu.cornell.mannlib.vitro.webapp.dynapi.components.Parameter;
import edu.cornell.mannlib.vitro.webapp.dynapi.components.Parameters;

public class SimpleDataView {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not an extension of View?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, interface wasn't used. Should be removed.

@@ -0,0 +1,5 @@
package edu.cornell.mannlib.vitro.webapp.dynapi.data;

public interface View {
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be better that we can really define some interface here (I mean some methods), in this way I am not sure what is the benefit of making hierarchy of object implementing this view

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 don't think it is possible. I think that interface should be removed.

@chenejac
Copy link
Contributor

  • Parameter can be declared as local. Local parameters are auto-created by api before processing input data.

Is this idea for InternalParameters?

@litvinovg
Copy link
Contributor Author

  • Parameter can be declared as local. Local parameters are auto-created by api before processing input data.

Is this idea for InternalParameters?
Yes

@litvinovg
Copy link
Contributor Author

@litvinovg I have reviewed your PR, it looks very well. I have provided a couple of comments. Moreover, the list of classes in the data.types package is a little bit strange, maybe that should be split into two packages.

Yes. I split that files into two packages.

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.

It looks ok for me now. I still don't like the name JsonObjectSerializationType, but we can consider renaming that later.

@chenejac chenejac merged commit 5a1e1f5 into vivo-project:sprint-dynapi-2022-feb-staging Aug 23, 2022
This was referenced Sep 14, 2022
@chenejac chenejac mentioned this pull request Oct 6, 2022
litvinovg added a commit to litvinovg/Vitro that referenced this pull request Jun 30, 2023
* renamed classes

* Converted dynamic api ontology to n3

* renamed DefaultAction to NullAction

* Moved RESOURCE_ID to RESTEndpoint class

* added data view classes

* local parameters

* started working with json converter

* Json validation and jsonPath data loading

* get serialized type from ParameterType

* tests: fixes for REST endpoint integration test

* set required parameters in json schema

* inject resource id from url path into json request before validation

* refact: move prepareResponse to Converter class from OperationResult

* if no acceptContentTypes found use the same content type as input

* tests fixes, refactoring, form data converter improvements

* Started working on JSON output conversion

* Check param json paths for params input/output conversion, if not set check action json paths, if not set use default.

* save initializer draft code

* fix: fix NPE in RPCEndpointTest

* renamed old ParameterType to SerializationType. Created new ParameterType

* get serialization info from serialization type name

* Extracted RDFType from SerializationType

* refact: created isLiteral, isUri, isRdfType methods in ParamterType, moved rdf related checks from Parameters class

* feat: added implementation type

* added parameter implementation configuration

* created parameter converter

* array conversion

* Removed old converters, operation data, model component.

* refact: renamed RawData to Data, renamed requiredParams to inputParams and providedParams to outputParams

* Refactored parameter converter. Cache conversion method.

* added ModelWriter, restricted access to Data.setObject

* content type negotiation

* n3 syntax fix

* created a few SPARQL query tests, refactored and improved code in SPARQL Query and N3Template

* fixes related to review comments

* refact: moved implementation related classes to separate package

* added sparql query uri input test

* refact: removed unused imports and variables.

* restricted Data.getObject access modifier to protected
litvinovg added a commit to litvinovg/Vitro that referenced this pull request Jul 6, 2023
* renamed classes

* Converted dynamic api ontology to n3

* renamed DefaultAction to NullAction

* Moved RESOURCE_ID to RESTEndpoint class

* added data view classes

* local parameters

* started working with json converter

* Json validation and jsonPath data loading

* get serialized type from ParameterType

* tests: fixes for REST endpoint integration test

* set required parameters in json schema

* inject resource id from url path into json request before validation

* refact: move prepareResponse to Converter class from OperationResult

* if no acceptContentTypes found use the same content type as input

* tests fixes, refactoring, form data converter improvements

* Started working on JSON output conversion

* Check param json paths for params input/output conversion, if not set check action json paths, if not set use default.

* save initializer draft code

* fix: fix NPE in RPCEndpointTest

* renamed old ParameterType to SerializationType. Created new ParameterType

* get serialization info from serialization type name

* Extracted RDFType from SerializationType

* refact: created isLiteral, isUri, isRdfType methods in ParamterType, moved rdf related checks from Parameters class

* feat: added implementation type

* added parameter implementation configuration

* created parameter converter

* array conversion

* Removed old converters, operation data, model component.

* refact: renamed RawData to Data, renamed requiredParams to inputParams and providedParams to outputParams

* Refactored parameter converter. Cache conversion method.

* added ModelWriter, restricted access to Data.setObject

* content type negotiation

* n3 syntax fix

* created a few SPARQL query tests, refactored and improved code in SPARQL Query and N3Template

* fixes related to review comments

* refact: moved implementation related classes to separate package

* added sparql query uri input test

* refact: removed unused imports and variables.

* restricted Data.getObject access modifier to protected
litvinovg added a commit to litvinovg/Vitro that referenced this pull request Mar 7, 2024
* renamed classes

* Converted dynamic api ontology to n3

* renamed DefaultAction to NullAction

* Moved RESOURCE_ID to RESTEndpoint class

* added data view classes

* local parameters

* started working with json converter

* Json validation and jsonPath data loading

* get serialized type from ParameterType

* tests: fixes for REST endpoint integration test

* set required parameters in json schema

* inject resource id from url path into json request before validation

* refact: move prepareResponse to Converter class from OperationResult

* if no acceptContentTypes found use the same content type as input

* tests fixes, refactoring, form data converter improvements

* Started working on JSON output conversion

* Check param json paths for params input/output conversion, if not set check action json paths, if not set use default.

* save initializer draft code

* fix: fix NPE in RPCEndpointTest

* renamed old ParameterType to SerializationType. Created new ParameterType

* get serialization info from serialization type name

* Extracted RDFType from SerializationType

* refact: created isLiteral, isUri, isRdfType methods in ParamterType, moved rdf related checks from Parameters class

* feat: added implementation type

* added parameter implementation configuration

* created parameter converter

* array conversion

* Removed old converters, operation data, model component.

* refact: renamed RawData to Data, renamed requiredParams to inputParams and providedParams to outputParams

* Refactored parameter converter. Cache conversion method.

* added ModelWriter, restricted access to Data.setObject

* content type negotiation

* n3 syntax fix

* created a few SPARQL query tests, refactored and improved code in SPARQL Query and N3Template

* fixes related to review comments

* refact: moved implementation related classes to separate package

* added sparql query uri input test

* refact: removed unused imports and variables.

* restricted Data.getObject access modifier to protected
litvinovg added a commit to litvinovg/Vitro that referenced this pull request Mar 8, 2024
* renamed classes

* Converted dynamic api ontology to n3

* renamed DefaultAction to NullAction

* Moved RESOURCE_ID to RESTEndpoint class

* added data view classes

* local parameters

* started working with json converter

* Json validation and jsonPath data loading

* get serialized type from ParameterType

* tests: fixes for REST endpoint integration test

* set required parameters in json schema

* inject resource id from url path into json request before validation

* refact: move prepareResponse to Converter class from OperationResult

* if no acceptContentTypes found use the same content type as input

* tests fixes, refactoring, form data converter improvements

* Started working on JSON output conversion

* Check param json paths for params input/output conversion, if not set check action json paths, if not set use default.

* save initializer draft code

* fix: fix NPE in RPCEndpointTest

* renamed old ParameterType to SerializationType. Created new ParameterType

* get serialization info from serialization type name

* Extracted RDFType from SerializationType

* refact: created isLiteral, isUri, isRdfType methods in ParamterType, moved rdf related checks from Parameters class

* feat: added implementation type

* added parameter implementation configuration

* created parameter converter

* array conversion

* Removed old converters, operation data, model component.

* refact: renamed RawData to Data, renamed requiredParams to inputParams and providedParams to outputParams

* Refactored parameter converter. Cache conversion method.

* added ModelWriter, restricted access to Data.setObject

* content type negotiation

* n3 syntax fix

* created a few SPARQL query tests, refactored and improved code in SPARQL Query and N3Template

* fixes related to review comments

* refact: moved implementation related classes to separate package

* added sparql query uri input test

* refact: removed unused imports and variables.

* restricted Data.getObject access modifier to protected
litvinovg added a commit that referenced this pull request Apr 19, 2024
* renamed classes

* Converted dynamic api ontology to n3

* renamed DefaultAction to NullAction

* Moved RESOURCE_ID to RESTEndpoint class

* added data view classes

* local parameters

* started working with json converter

* Json validation and jsonPath data loading

* get serialized type from ParameterType

* tests: fixes for REST endpoint integration test

* set required parameters in json schema

* inject resource id from url path into json request before validation

* refact: move prepareResponse to Converter class from OperationResult

* if no acceptContentTypes found use the same content type as input

* tests fixes, refactoring, form data converter improvements

* Started working on JSON output conversion

* Check param json paths for params input/output conversion, if not set check action json paths, if not set use default.

* save initializer draft code

* fix: fix NPE in RPCEndpointTest

* renamed old ParameterType to SerializationType. Created new ParameterType

* get serialization info from serialization type name

* Extracted RDFType from SerializationType

* refact: created isLiteral, isUri, isRdfType methods in ParamterType, moved rdf related checks from Parameters class

* feat: added implementation type

* added parameter implementation configuration

* created parameter converter

* array conversion

* Removed old converters, operation data, model component.

* refact: renamed RawData to Data, renamed requiredParams to inputParams and providedParams to outputParams

* Refactored parameter converter. Cache conversion method.

* added ModelWriter, restricted access to Data.setObject

* content type negotiation

* n3 syntax fix

* created a few SPARQL query tests, refactored and improved code in SPARQL Query and N3Template

* fixes related to review comments

* refact: moved implementation related classes to separate package

* added sparql query uri input test

* refact: removed unused imports and variables.

* restricted Data.getObject access modifier to protected
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