Skip to content

Spaces, types & properties

Spaces (client.spaces())

SpaceInformation space = client.spaces().get("myspace", true);   // permissions=true
Page<SpaceInformation> page = client.spaces().list();

client.spaces().createOrUpdateSpecification("myspace", new SpaceSpecification(null, null, true, false, false));  // autorelease=true
client.spaces().deleteSpecification("myspace");

Optional<TypeInSpace> relation = client.spaces().getType("myspace", "https://openminds.ebrains.eu/core/Person");
client.spaces().assignType("myspace", "https://openminds.ebrains.eu/core/Person");
client.spaces().removeType("myspace", "https://openminds.ebrains.eu/core/Person");

client.spaces().triggerInference("myspace");        // re-run inference for one space
client.spaces().triggerInferenceAll(true);          // ... for every space (force=true)
client.spaces().resolveRelations();                  // re-resolve all unresolved links

Types (client.types())

Page<TypeInformation> page = client.types().list(TypeListOptions.builder().withProperties(true).build());
Map<String, TypeInformation> byName = client.types().getByNames(List.of("https://openminds.ebrains.eu/core/Person"));

TypeSpecification spec = client.types().getSpecification("https://openminds.ebrains.eu/core/Person");
TypeSpecification updated = new TypeSpecification(spec.name(), spec.description(), "#336699",
        spec.labelProperty(), spec.searchableProperties(), spec.embeddedOnly());
client.types().createOrUpdateSpecification("https://openminds.ebrains.eu/core/Person", updated);
client.types().deleteSpecification("https://openminds.ebrains.eu/core/Person");

TypeInformation (from list/getByNames) describes a type as observed in the data - occurrences, per-space property breakdowns, etc. TypeSpecification (from getSpecification) is the type's configured metadata (name, color, label property, searchable properties, whether it's embedded-only) - these are two different endpoints returning two different shapes, don't confuse them. TypeSpecification is an immutable record; build a new one (as above) to change a field.

Validation schemas

A type can carry 0..n named JSON-Schema documents. They are written against the instance as returned by client.instances().get (fully qualified property IRIs, single values not wrapped in a list). External $refs are rejected - schemas have to be self-contained. Managing them requires the global functionality DEFINE_VALIDATION_SCHEMAS (granted by the ADMIN role).

String person = "https://openminds.ebrains.eu/core/Person";
client.types().createOrUpdateValidationSchema(person, "basic v1", Map.of(
        "type", "object",
        "required", List.of("https://openminds.ebrains.eu/vocab/familyName")));
List<ValidationSchema> schemas = client.types().listValidationSchemas(person);   // ValidationSchema(name, schema)
ValidationSchema basic = client.types().getValidationSchema(person, "basic v1");
client.types().deleteValidationSchema(person, "basic v1");

See client.instances().validate (instances.md) to run them against an instance.

Scopes

A type can carry 0..n named scopes: the instances related to an instance of the type for a specific use case (e.g. what is consolidated for a search index). A scope is a fixed-depth tree of steps following references - outgoing, or incoming with reverse - optionally restricted to target types. Every instance reached by a step is part of the scope (hops are never shortcut). Managing scopes requires the global functionality DEFINE_SCOPES (granted by the ADMIN role).

String dataset = "https://openminds.ebrains.eu/core/Dataset";
client.types().createOrUpdateScope(dataset, "search", ScopeSpecification.of(
        ScopeSpecification.Step.of(ScopeSpecification.Path.outgoing("https://openminds.ebrains.eu/vocab/hasVersion"),
                ScopeSpecification.Step.of(ScopeSpecification.Path.outgoing("https://openminds.ebrains.eu/vocab/author",
                        "https://openminds.ebrains.eu/core/Person"))),
        ScopeSpecification.Step.of(ScopeSpecification.Path.incoming("https://openminds.ebrains.eu/vocab/hasPart"))));
List<ScopeDefinition> scopes = client.types().listScopes(dataset);   // ScopeDefinition(name, specification)
client.types().deleteScope(dataset, "search");

See client.instances().scope (instances.md) to evaluate them for an instance.

Properties (client.properties())

A PropertySpecification holds the property's display name, the name of the reverse link, the target types, the editor widget, whether it is read-only, a label tooltip, whether it is required and its order number - other keys are not stored (all fields are optional - null means "not specified"):

client.properties().define("http://schema.org/name", new PropertySpecification("Name", null, List.of(), "InputText", null, null, null, null));
Optional<PropertySpecification> spec = client.properties().get("http://schema.org/name");
client.properties().remove("http://schema.org/name");

client.properties().defineForType("http://schema.org/knows", "https://.../Person", new PropertySpecification(
        "Knows", "Is known by", List.of("https://.../Person"), "DynamicDropdown", false, "Who the person knows", true, 1));
Optional<PropertySpecification> typeSpec = client.properties().getForType("http://schema.org/knows", "https://.../Person");
client.properties().removeForType("http://schema.org/name", "https://.../Person");

Statistics (client.statistics())

GraphStatistics statistics = client.statistics().get();   // only reflects the spaces you can read
long instances = statistics.live().instances();
statistics.types();        // the most occurring first
statistics.validation();   // the compliance of the live instances per validation schema name
for (GraphStatistics.ValidationStatistics v : statistics.validation()) {
    v.fullyCompliant(); v.above80Percent(); v.between40And80Percent(); v.below40Percent(); v.notCompliant(); v.notAssessed();
    v.perType();           // the same groups per type (identifier, name, instances, ...), the most instances first
}