Folder : get_schema_validation_statistics
Folder_GetSchemaValidationStatistics.RdGet validation statistics for a container entity.
Examples
if (FALSE) { # \dontrun{
## Using this function
# Retrieving validation statistics for a folder. This example demonstrates
# how to get validation statistics for a container entity after creating
# entities with various validation states. Set the PROJECT_NAME variable to your project name.
library(synapser)
synLogin()
# Define Project and JSON schema info
PROJECT_NAME = "test_json_schema_project" # replace with your project name
FILE_PATH = "~/Sample.txt" # replace with your test file path
PROJECT_ID = synFindEntityId(name = PROJECT_NAME)
ORG_NAME = "UniqueOrg" # replace with your organization name
SCHEMA_NAME = "myTestSchema" # replace with your schema name
FOLDER_NAME = "test_script_folder"
VERSION = "0.0.1"
SCHEMA_URI = sprintf("%s-%s-%s", ORG_NAME, SCHEMA_NAME, VERSION)
# Create the organization and JSON schema used in this example.
my_test_org = Organization(name = ORG_NAME) |> synStore()
schema_definition = list(
"$id" = "mySchema",
type = "object",
properties = list(
foo = list(type = "string"),
baz = list(type = "string", const = "example_value"),
bar = list(type = "integer")
),
required = list("foo")
)
test_schema = JSONSchema(name = SCHEMA_NAME, organization_name = ORG_NAME) |> synStore(
json_schema_options = StoreJSONSchemaOptions(schema_body = schema_definition, version = VERSION)
)
# Create a test folder
test_folder = Folder(name = FOLDER_NAME, parent_id = PROJECT_ID) |> synStore()
cat("Created test folder:", FOLDER_NAME, "\n")
# Bind JSON schema to the folder
bound_schema = test_folder |> synBindSchema(
json_schema_uri = SCHEMA_URI,
enable_derived_annotations = TRUE
)
cat("Bound schema to folder:\n")
bound_schema
# Create a file within the folder with invalid annotations to generate statistics
invalid_file1 = File(
path = FILE_PATH,
parent_id = test_folder$id,
annotations = list(foo = 123, bar = "not_an_integer") # both invalid
) |> synStore()
cat("Created file with invalid annotations\n")
Sys.sleep(2) # Allow time for processing
stats = test_folder |> synGetSchemaValidationStatistics()
cat("Validation statistics:\n")
stats
} # }