Skip to content

Commit

Permalink
chore: prepare 2.39.1 (#1657)
Browse files Browse the repository at this point in the history
  • Loading branch information
jachro authored Aug 11, 2023
2 parents ebdf3a6 + eef57ba commit 9ca086b
Show file tree
Hide file tree
Showing 32 changed files with 531 additions and 217 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,12 @@ object DatasetsQuery extends EntityQuery[Entity.Dataset] {
| # textQuery
| ${textQueryPart(criteria.filters.maybeQuery)}
|
| Graph schema:Dataset {
| GRAPH schema:Dataset {
| #creator
| $sameAsVar schema:creator / schema:name ?creatorName.
| $sameAsVar schema:creator ?creatorId.
| GRAPH ${GraphClass.Persons.id} {
| ?creatorId schema:name ?creatorName
| }
|
| #keywords
| $keywords
Expand All @@ -105,7 +108,7 @@ object DatasetsQuery extends EntityQuery[Entity.Dataset] {
| $images
| }
|
| Graph ?projId {
| GRAPH ?projId {
| # project namespaces
| ${namespacesPart(criteria.filters.namespaces)}
|
Expand All @@ -121,7 +124,7 @@ object DatasetsQuery extends EntityQuery[Entity.Dataset] {
|
| ${creatorsPart(criteria.filters.creators)}
|
| Graph schema:Dataset {
| GRAPH schema:Dataset {
| # name
| $sameAsVar renku:slug $nameVar
|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,12 @@ private case object ProjectsQuery extends EntityQuery[model.Entity.Project] {
| ${namespacesPart(criteria.filters.namespaces)}
| }
|
| OPTIONAL { $projectIdVar schema:creator/schema:name $someCreatorNameVar }
| OPTIONAL {
| $projectIdVar schema:creator ?creatorId.
| GRAPH ${GraphClass.Persons.id} {
| ?creatorId schema:name $someCreatorNameVar
| }
| }
| ${filters.maybeOnCreatorName(someCreatorNameVar)}
|
| OPTIONAL { $projectIdVar schema:description $maybeDescriptionVar }
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,15 @@ package io.renku.entities.searchgraphs.datasets
import cats.Show
import cats.data.NonEmptyList
import cats.syntax.all._
import io.renku.entities.searchgraphs.PersonInfo
import io.renku.graph.model.images.Image
import io.renku.graph.model.{datasets, projects}
import io.renku.graph.model.{datasets, persons, projects}

private final case class DatasetSearchInfo(topmostSameAs: datasets.TopmostSameAs,
name: datasets.Name,
visibility: projects.Visibility,
createdOrPublished: datasets.CreatedOrPublished,
maybeDateModified: Option[datasets.DateModified],
creators: NonEmptyList[PersonInfo],
creators: NonEmptyList[persons.ResourceId],
keywords: List[datasets.Keyword],
maybeDescription: Option[datasets.Description],
images: List[Image],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ package io.renku.entities.searchgraphs.datasets
import cats.MonadThrow
import cats.data.NonEmptyList
import cats.syntax.all._
import io.renku.entities.searchgraphs.PersonInfo.toPersonInfo
import io.renku.graph.model.datasets
import io.renku.graph.model.entities.{Dataset, Project}

Expand Down Expand Up @@ -65,7 +64,7 @@ private object SearchInfoExtractor {
project.visibility,
createdOrPublished,
maybeDateModified,
ds.provenance.creators.map(toPersonInfo),
ds.provenance.creators.map(_.resourceId),
ds.additionalInfo.keywords,
ds.additionalInfo.maybeDescription,
ds.additionalInfo.images,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,18 @@
package io.renku.entities.searchgraphs.datasets.commands

import cats.syntax.all._
import io.renku.entities.searchgraphs.PersonInfo
import io.renku.entities.searchgraphs.datasets.Link.{ImportedDataset, OriginalDataset}
import io.renku.entities.searchgraphs.datasets.{DatasetSearchInfo, DatasetSearchInfoOntology, Link, LinkOntology}
import io.renku.graph.model.Schemas.{rdf, renku}
import io.renku.graph.model.datasets
import io.renku.graph.model.entities.Person
import io.renku.graph.model.images.Image
import io.renku.graph.model.{datasets, persons}
import io.renku.jsonld.Property
import io.renku.jsonld.syntax._
import io.renku.triplesstore.client.model.{Quad, QuadsEncoder, TripleObject}
import io.renku.triplesstore.client.syntax._

private object Encoders {

implicit val personInfoEncoder: QuadsEncoder[PersonInfo] = QuadsEncoder.instance {
case PersonInfo(resourceId, name) =>
Set(
DatasetsQuad(resourceId, rdf / "type", Person.Ontology.typeClass.id),
DatasetsQuad(resourceId, Person.Ontology.nameProperty.id, name.asObject)
)
}

implicit val imageEncoder: QuadsEncoder[Image] = QuadsEncoder.instance { case Image(resourceId, uri, position) =>
Set(
DatasetsQuad(resourceId, rdf / "type", Image.Ontology.typeClass.id),
Expand Down Expand Up @@ -84,9 +74,8 @@ private object Encoders {
searchInfoQuad(DatasetSearchInfoOntology.descriptionProperty.id, d.asObject)
}

val creatorsQuads = info.creators.toList.toSet.flatMap { (pi: PersonInfo) =>
pi.asQuads +
searchInfoQuad(DatasetSearchInfoOntology.creatorProperty, pi.resourceId.asEntityId)
val creatorsQuads = info.creators.toList.toSet.map { (resourceId: persons.ResourceId) =>
searchInfoQuad(DatasetSearchInfoOntology.creatorProperty, resourceId.asEntityId)
}

val keywordsQuads = info.keywords.toSet.map { (k: datasets.Keyword) =>
Expand All @@ -107,6 +96,7 @@ private object Encoders {
searchInfoQuad(rdf / "type", DatasetSearchInfoOntology.typeDef.clazz.id).some,
searchInfoQuad(DatasetSearchInfoOntology.slugProperty.id, info.name.asObject).some,
searchInfoQuad(DatasetSearchInfoOntology.visibilityProperty.id, info.visibility.asObject).some,
searchInfoQuad(DatasetSearchInfoOntology.visibilityProperty.id, info.visibility.asObject).some,
createdOrPublishedQuad.some,
maybeDateModifiedQuad,
maybeDescriptionQuad
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ package io.renku.entities.searchgraphs.datasets.commands
import cats.data.NonEmptyList
import cats.effect.Async
import io.renku.entities.searchgraphs
import io.renku.entities.searchgraphs.PersonInfo
import io.renku.entities.searchgraphs.datasets.{DatasetSearchInfo, Link, links}
import io.renku.graph.model.datasets.TopmostSameAs
import io.renku.graph.model.{GraphClass, projects}
Expand Down Expand Up @@ -78,16 +77,12 @@ private class SearchInfoFetcherImpl[F[_]: Async: Logger: SparqlQueryTimeRecorder
| } {
| GRAPH ${GraphClass.Datasets.id} {
| ?topSameAs renku:slug ?name;
| renku:projectVisibility ?visibility.
| renku:projectVisibility ?visibility;
| schema:creator ?creator.
| OPTIONAL { ?topSameAs schema:description ?maybeDescription }
| OPTIONAL { ?topSameAs schema:dateCreated ?maybeDateCreated }
| OPTIONAL { ?topSameAs schema:datePublished ?maybeDatePublished }
| OPTIONAL { ?topSameAs schema:dateModified ?maybeDateModified }
| {
| ?topSameAs schema:creator ?creatorId.
| ?creatorId schema:name ?creatorName.
| BIND (CONCAT(STR(?creatorId), STR(';;'), STR(?creatorName)) AS ?creator)
| }
| OPTIONAL { ?topSameAs schema:keywords ?keyword }
| OPTIONAL {
| ?topSameAs schema:image ?imageId.
Expand Down Expand Up @@ -138,18 +133,15 @@ private class SearchInfoFetcherImpl[F[_]: Async: Logger: SparqlQueryTimeRecorder
_.map(decode[datasets.Keyword](map = toKeyword, sort = _.sorted))
.getOrElse(List.empty.asRight[DecodingFailure])

val toCreator: String => Decoder.Result[PersonInfo] = {
case s"$id;;$name" =>
(persons.ResourceId.from(id) -> persons.Name.from(name))
.mapN(PersonInfo(_, _))
.leftMap(ex => DecodingFailure(DecodingFailure.Reason.CustomReason(ex.getMessage), cur))
case other =>
DecodingFailure(DecodingFailure.Reason.CustomReason(s"'$other' not a valid creator record"), cur)
.asLeft[PersonInfo]
}
val toCreatorId: String => Decoder.Result[persons.ResourceId] =
persons.ResourceId
.from(_)
.leftMap(ex => DecodingFailure(DecodingFailure.Reason.CustomReason(ex.getMessage), cur))

def toListOfCreators(implicit topmostSameAs: TopmostSameAs): String => Decoder.Result[NonEmptyList[PersonInfo]] =
decode[PersonInfo](map = toCreator, sort = _.sortBy(_.name))(_)
def toListOfCreators(implicit
topmostSameAs: TopmostSameAs
): String => Decoder.Result[NonEmptyList[persons.ResourceId]] =
decode[persons.ResourceId](map = toCreatorId, sort = _.sorted)(_)
.flatMap(toNonEmptyList(s"No creators found for $topmostSameAs"))

val toImage: String => Decoder.Result[images.Image] = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ object DatasetSearchInfoOntology {
lazy val typeDef: Type = Type.Def(
Class(renku / "DiscoverableDataset"),
ObjectProperties(
ObjectProperty(creatorProperty, PersonInfoOntology.typeDef),
ObjectProperty(creatorProperty, Person.Ontology.typeDef),
ObjectProperty(imageProperty, Image.Ontology.typeDef),
ObjectProperty(linkProperty, LinkOntology.typeDef)
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,16 @@ package io.renku.entities.searchgraphs.projects

import cats.Show
import cats.syntax.all._
import io.renku.entities.searchgraphs.PersonInfo
import io.renku.graph.model.images.Image
import io.renku.graph.model.projects
import io.renku.graph.model.{persons, projects}

private final case class ProjectSearchInfo(id: projects.ResourceId,
name: projects.Name,
slug: projects.Slug,
visibility: projects.Visibility,
dateCreated: projects.DateCreated,
dateModified: projects.DateModified,
maybeCreator: Option[PersonInfo],
maybeCreator: Option[persons.ResourceId],
keywords: List[projects.Keyword],
maybeDescription: Option[projects.Description],
images: List[Image]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

package io.renku.entities.searchgraphs.projects

import io.renku.entities.searchgraphs.PersonInfo.toPersonInfo
import io.renku.graph.model.entities.Project

private object SearchInfoExtractor {
Expand All @@ -31,7 +30,7 @@ private object SearchInfoExtractor {
project.visibility,
project.dateCreated,
project.dateModified,
project.maybeCreator.map(toPersonInfo),
project.maybeCreator.map(_.resourceId),
project.keywords.toList,
project.maybeDescription,
project.images
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,16 @@ package io.renku.entities.searchgraphs.projects
package commands

import cats.syntax.all._
import io.renku.entities.searchgraphs.PersonInfo
import io.renku.graph.model.Schemas.rdf
import io.renku.graph.model.entities.Person
import io.renku.graph.model.images.Image
import io.renku.graph.model.projects
import io.renku.graph.model.{persons, projects}
import io.renku.jsonld.Property
import io.renku.jsonld.syntax._
import io.renku.triplesstore.client.model.{Quad, QuadsEncoder, TripleObject}
import io.renku.triplesstore.client.syntax._

private object Encoders {

implicit val personInfoEncoder: QuadsEncoder[PersonInfo] = QuadsEncoder.instance {
case PersonInfo(resourceId, name) =>
Set(
ProjectsQuad(resourceId, rdf / "type", Person.Ontology.typeClass.id),
ProjectsQuad(resourceId, Person.Ontology.nameProperty.id, name.asObject)
)
}

implicit val imageEncoder: QuadsEncoder[Image] = QuadsEncoder.instance { case Image(resourceId, uri, position) =>
Set(
ProjectsQuad(resourceId, rdf / "type", Image.Ontology.typeClass.id),
Expand All @@ -56,8 +46,8 @@ private object Encoders {
searchInfoQuad(ProjectSearchInfoOntology.descriptionProperty.id, d.asObject)
}

val creatorQuads = info.maybeCreator.toSet.flatMap { (c: PersonInfo) =>
c.asQuads + searchInfoQuad(ProjectSearchInfoOntology.creatorProperty, c.resourceId.asEntityId)
val creatorQuads = info.maybeCreator.toSet.map { (resourceId: persons.ResourceId) =>
searchInfoQuad(ProjectSearchInfoOntology.creatorProperty, resourceId.asEntityId)
}

val keywordsQuads = info.keywords.toSet.map { (k: projects.Keyword) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ object ProjectSearchInfoOntology {
lazy val typeDef: Type = Type.Def(
Class(renku / "DiscoverableProject"),
ObjectProperties(
ObjectProperty(creatorProperty, PersonInfoOntology.typeDef),
ObjectProperty(creatorProperty, Person.Ontology.typeDef),
ObjectProperty(imageProperty, Image.Ontology.typeDef)
),
DataProperties(
Expand All @@ -56,17 +56,6 @@ object ProjectSearchInfoOntology {
)
}

object PersonInfoOntology {

val nameProperty: DataProperty.Def = Person.Ontology.nameProperty

lazy val typeDef: Type = Type.Def(
Class(renku / "DiscoverableDatasetPerson"),
ObjectProperties(),
DataProperties(nameProperty)
)
}

object LinkOntology {

val project: Property = renku / "project"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,13 @@

package io.renku.entities.searchgraphs

import io.renku.entities.searchgraphs.PersonInfo.toPersonInfo
import io.renku.graph.model.entities
import io.renku.graph.model.testentities._
import io.renku.triplesstore.SparqlQuery
import io.renku.triplesstore.client.TriplesStoreGenerators.quads
import io.renku.triplesstore.client.syntax._
import org.scalacheck.Gen

private object Generators {

lazy val personInfos: Gen[PersonInfo] =
personEntities.map(_.to[entities.Person]).map(toPersonInfo)

val insertUpdateCommands: Gen[UpdateCommand] =
quads.map(UpdateCommand.Insert)
val deleteUpdateCommands: Gen[UpdateCommand] =
Expand Down

This file was deleted.

Loading

0 comments on commit 9ca086b

Please sign in to comment.