After generating your CRUD templates, you'll need to use them to manage data. This section explains how to execute the read , create , update , and delete templates for the EditorialObject class. To view existing instances of the EditorialObject class, follow these steps: Access Template Execution API: Navigate to the API documentation where you can execute templates by name. Prepare to Execute the Read Template: Locate the execute-template by name endpoint. Click the Try it out button to enable input. Against the templateName key, enter readEditorialObject , which is the name of the read template for the EditorialObject class. Ensure that any existing variables are cleared out before executing to avoid any unintended filtering. Click the Execute button to send the request. Image ModifiedUpon successful execution, the API will return a response displaying all instances of the EditorialObject class. This verifies that the read operation is functioning correctly. Image Modified
To create a new instance of the EditorialObject class, you'll need to understand the IRI (Internationalized Resource Identifier), a unique identifier that ensures each instance is distinct and aligns with global web standards. If an IRI is not provided, it automatically generates one to guarantee each instance's uniqueness. Alternatively, you can specify your own IRI to maintain control over the identifier of your instance, adhering to standard HTTP practices. Set Up Creation Request: Go back to the execute-template-by-name endpoint if you aren't already there. Click Try it out button again to set up a new request. Enter createEditorialObject against the templateName key, which is the name of the create template for the EditorialObject class. Provide necessary variables for the new instance. Typically, this would be in JSON format in the request's body, for example. Code Block |
---|
{
"title": "M - A City Hunts a Murderer",
"productionSynopsis": "Directed by Fritz Lang, this thriller is one of the earliest masterpieces of sound cinema, exploring themes of justice, vigilance, and societal response to crime.",
"shotLog": "Iconic scenes using shadows and sound to create suspense, notably the murderers eerie whistling of In the Hall of the Mountain King."
} |
When you send a request to create a new instance, a unique IRI (Internationalized Resource Identifier) is involved. This IRI acts like a unique id for your instance that complies with global web standards. If you do not provide an IRI, it automatically generates one for you, ensuring that each instance is uniquely identified. However, if you have a specific IRI you wish to use, you can include it in your variables JSON object. This allows you to control the unique identifier of your instance, following the standard HTTP practices. Click the Execute button to send the creation request. Image ModifiedThe response will confirm that the new instance has been successfully created. Look for a success message and any details provided about the newly created instance. Image Modified
After creating a new instance of the EditorialObject class, to confirm if the record has been successfully created, you can follow these steps to verify the addition to the graph database: Re-execute the Read Template: Navigate back to the execute-template-by-name endpoint in the View Management Service documentation. Click the Try it out button to enable input for a new request. Against the templateName key, enter readEditorialObject again. This is the same read template you used earlier to view instances. Click the Execute button to send the request once more. Image ModifiedThe response will now include the list of all current instances of the EditorialObject class. Look through the list to find the newly created instance. You should see the details you entered for the instance, such as the label or any other identifiers, confirming that it has been successfully persisted in the database. Image Modified
You can verify the changes made to the graph database re-executing the read template after performing CRUD operations provides an option to transparently. To update an existing instance within your graph database, you first need to know which instance you're targeting. This is where the IRI (Internationalized Resource Identifier) comes in - it acts as a unique identifier, much like an id for each instance. You can find the IRI by reading the instances of the class you're interested in. Once you have the IRI , it serves as an identifier to specify which instance to update. Along with the IRI , you need to pass the properties and their new values that you want to update. Access Update Template Execution: Navigate to the execute-template-by-name endpoint in the View Management Service documentation. Click the Try it out button. Enter the name of the update template (e.g., updateEditorialObject ) against the templateName key. In the variables object, specify the iri of the instance you wish to update, which you can obtain through reading the instance data. Also, include the properties and their values you want to change. For example, Code Block |
---|
{
"iri": "http://ont.enapso.com/sparql-template#EditorialObject_bf161f6f-4b89-431f-8f83-eb7b51b9a89f",
"contentDescription": "In Berlin during the Weimar Republic, the police and the criminal underworld scramble to capture a child murderer who has caused panic across the city."
} |
Click the Execute button to send the update request. Image ModifiedThe response should indicate whether the update was successful, including a confirmation message or status code. It's important to note that an HTTP 200 status is returned whether the specific instance whose IRI was provided exists or not. This status also indicates successful query execution, not necessarily that any update was performed. Even if no update occurs due to specific conditions not being met, you will still receive a 200 OK, signifying that the query itself was processed without errors. Image Modified
To delete an instance from your ontology, you need to specify which instance to remove by using its IRI (Internationalized Resource Identifier). The IRI serves as a unique identifier for each instance and can be obtained by reading the instance data beforehand. Once you have the IRI, use it to indicate which instance you wish to delete.: Access Delete Template Execution: Go to the execute-template-by-name endpoint in the View Management Service documentation. Click the Try it out button. Enter the name of the delete template (e.g., deleteEditorialObject ) against the templateName key. In the variables object, provide the IRI of the instance you wish to delete. For example, Code Block |
---|
{
"iri": "http://ont.enapso.com/sparql-template#EditorialObject_bf161f6f-4b89-431f-8f83-eb7b51b9a89f"
} |
Click the Execute button to send the delete request. Image ModifiedThe response should confirm that the instance has been successfully deleted from the graph database repository. Even if the instance with the specified IRI doesn't exist or if a delete wasn't performed due to certain conditions, the request will still return a 200 status code. This indicates that the query was executed successfully, even if no actual deletion occurred. Image Modified
|