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

refactor(api-v2): Use SparqlExtendedConstructResponse in ConstructResponseUtilV2 #1367

Merged
merged 15 commits into from
Jul 9, 2019

Conversation

benjamingeer
Copy link

@benjamingeer benjamingeer commented Jul 2, 2019

This PR improves type safety in ConstructResponseUtilV2 by using SparqlExtendedConstructResponse, which provides the types returned by the triplestore.

  • Change SparqlExtendedConstructResponse to use SmartIri for predicates.
  • Refactor ConstructResponseUtilV2 and related classes.
  • Fix datatype typo in v2/generateInsertStatementsForValueContent.scala.txt (was xsd:valueHasDecimal, should be xsd:decimal).
  • Add upgrade script in case anyone was affected by that typo.
  • Add test.

Resolves #763.

@benjamingeer benjamingeer mentioned this pull request Jul 2, 2019
@benjamingeer
Copy link
Author

@tobiasschweizer Issue #763 says to:

  • Take the language tag into account. But we don't use language tags in data in the triplestore, do we?
  • Not return a list node's label for a list value. This was done in Handle List Nodes in Response #1321, right?

@tobiasschweizer
Copy link
Contributor

Take the language tag into account. But we don't use language tags in data in the triplestore, do we?

No, I don't think so. We do have a language property for text values (ISO language code) but it's not the same that is used for labels etc. in the ontology.

Not return a list node's label for a list value. This was done in #1321, right?

This was already done, yes.

@tobiasschweizer
Copy link
Contributor

@benjamingeer I think I can review this PR next week. Would that be ok?

@benjamingeer
Copy link
Author

I think I can review this PR next week. Would that be ok?

Sure, no problem. Would you have time to look at #1259 with @andreas-aeschlimann this week?

@tobiasschweizer
Copy link
Contributor

Would you have time to look at #1259 with @andreas-aeschlimann this week?

He said he would look at it. I will remind him :-)

@benjamingeer
Copy link
Author

I will remind him :-)

Thanks!

@tobiasschweizer
Copy link
Contributor

The update script is needed in case someone created decimal values using v2, correct?

@benjamingeer
Copy link
Author

The update script is needed in case someone created decimal values using v2, correct?

Yes.

case (pred, obj) =>
pred == OntologyConstants.KnoraBase.IsMainResource && obj.toBoolean
val subjectIsMainResource: Boolean = assertions.get(OntologyConstants.KnoraBase.IsMainResource.toSmartIri) match {
case Some(objs) => objs.contains(BooleanLiteralV2(true))
Copy link
Contributor

Choose a reason for hiding this comment

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

Couldn't you just check for the first element with headOption? There should be only one statement IsMainResource.

Copy link
Author

Choose a reason for hiding this comment

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

Yes, you‘re right.

Copy link
Contributor

Choose a reason for hiding this comment

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

ok

Copy link
Author

Choose a reason for hiding this comment

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

Done in 3d26cf3.

Copy link
Contributor

@tobiasschweizer tobiasschweizer left a comment

Choose a reason for hiding this comment

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

I think it would make sense to add a basic test case for ConstructResponseUtilV2. Do you think that is feasible?

@benjamingeer
Copy link
Author

I think it would make sense to add a basic test case for ConstructResponseUtilV2. Do you think that is feasible?

I could refactor HttpTriplestoreConnector to make it possible to parse Turtle and construct a SparqlExtendedConstructResponse without actually connecting to the triplestore. Then I could add a test that took some hard-coded Turtle, parsed it, and ran it through ConstructResponseUtilV2. Would that be what you have in mind?

@tobiasschweizer
Copy link
Contributor

Would that be what you have in mind?

Yes, no actual connection the triplestore is needed. Also we can get an idea how much time complex results need for processing (nested resources).

@benjamingeer
Copy link
Author

Yes, no actual connection the triplestore is needed.

Done in 3d26cf3.

Also we can get an idea how much time complex results need for processing (nested resources).

We can't really see this now, because ConstructResponseUtilV2 does additional SPARQL queries, e.g. to get project info.

Copy link
Contributor

@tobiasschweizer tobiasschweizer left a comment

Choose a reason for hiding this comment

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

That looks great, thanks!

Unfortunately, I am not able to test any of this locally (see #1370).

@benjamingeer benjamingeer merged commit cf8f23d into develop Jul 9, 2019
@benjamingeer benjamingeer deleted the wip/763-construct branch July 9, 2019 12:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

refactor splitMainResourcesAndValueRdfData so it uses SparqlExtendedConstructResponse
2 participants