Skip to content

Commit

Permalink
point to new endpoint and make strings into URIRefs
Browse files Browse the repository at this point in the history
  • Loading branch information
TShapinsky committed Oct 18, 2023
1 parent afa2eb5 commit 305b88e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class ShapeValidationService {
validateModelShape(modelId: number, shape_collection_ids: number[], shape_uris: string[], target_class: string) {
const headers = {'Content-Type': "application/json"}

return this.http.post<ValidationResponse>(`http://localhost:5000/models/${modelId}/validate`,
return this.http.post<ValidationResponse>(`http://localhost:5000/models/${modelId}/validate_shape`,
{shape_collection_ids, shape_uris, target_class},
{headers, responseType: 'json'}
)
Expand Down
14 changes: 11 additions & 3 deletions buildingmotif/api/views/model.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import flask
from flask import Blueprint, current_app, jsonify, request
from flask_api import status
from rdflib import Graph
from rdflib import Graph, URIRef
from rdflib.plugins.parsers.notation3 import BadSyntax
from sqlalchemy.orm.exc import NoResultFound

Expand Down Expand Up @@ -232,11 +232,19 @@ def validate_shape(models_id: int) -> flask.Response:
"message": f"shape collections with ids {nonexistent_shape_collections} do not exist"
}, status.HTTP_400_BAD_REQUEST

if body.get("target_class", None) is None:
return {
"message": "target class is required to execute this endpoint"
}, status.HTTP_400_BAD_REQUEST

shape_uris = [URIRef(shape_uri) for shape_uri in body.get("shape_uris", [])]
target_class = URIRef(body.get("target_class"))

# test
conformance = model.test_model_against_shapes(
shape_collections=shape_collections,
shapes_to_test=body.get("shape_uris", []),
target_class=body.get("target_class", None),
shapes_to_test=shape_uris,
target_class=target_class,
)
result = {
shape_uri: validation_context.report_string
Expand Down

0 comments on commit 305b88e

Please sign in to comment.