Documentation
¶
Index ¶
- Constants
- Variables
- type ApplicationConstraint
- type Constraint
- type ConstraintViolation
- type DataProvider
- type EntityClass
- type InverseReferenceConstraint
- type IsAbstractConstraint
- type NamespaceResolver
- type PropertyConstraint
- func (c *PropertyConstraint) GetConstrainedEntityClass() (string, error)
- func (c *PropertyConstraint) GetConstrainedPropertyClass() (string, error)
- func (c *PropertyConstraint) GetDataType() string
- func (c *PropertyConstraint) GetIsQueryable() bool
- func (c *PropertyConstraint) GetIsUnique() bool
- func (c *PropertyConstraint) GetMaxAllowedOccurrences() int
- func (c *PropertyConstraint) GetMinAllowedOccurrences() int
- func (c *PropertyConstraint) GetSortable() string
- type PropertyValueConstraint
- type QueryConstraint
- type ReferenceConstraint
- func (aReferenceConstraint *ReferenceConstraint) GetAllowedReferencedClass() (string, error)
- func (aReferenceConstraint *ReferenceConstraint) GetConstrainedEntityClass() (string, error)
- func (aReferenceConstraint *ReferenceConstraint) GetConstrainedPropertyClass() (string, error)
- func (aReferenceConstraint *ReferenceConstraint) GetInverseConstrainedPropertyClass() (string, error)
- func (aReferenceConstraint *ReferenceConstraint) GetMaxAllowedOccurrences() int
- func (aReferenceConstraint *ReferenceConstraint) GetMinAllowedOccurrences() int
- type RemoteDataProvider
- func (r *RemoteDataProvider) GetDatasetEntities(name string) (datahub.EntityIterator, error)
- func (r *RemoteDataProvider) GetEntity(id string, datasets []string) (*egdm.Entity, error)
- func (r *RemoteDataProvider) Hop(sourceEntityId string, reference string, datasets []string, inverse bool, ...) (datahub.EntityIterator, error)
- type Schema
- func (aSchema *Schema) GetConstraintsForEntityClass(entityClassIdentifier string, inherited bool) []any
- func (aSchema *Schema) GetEntityClassById(entityClassIdentifier string) *EntityClass
- func (aSchema *Schema) GetEntityClassClassHierarchy(entityClassIdentifier string) ([]string, error)
- func (aSchema *Schema) GetOutgoingInverseConstraintsForEntityClass(entityClassIdentifier string, inherited bool) []any
- func (aSchema *Schema) IsAbstract(entityClass *EntityClass) bool
- func (aSchema *Schema) IsOfType(entity *egdm.Entity, typeURI string) bool
- type SchemaValidator
- type Validator
- func (v *Validator) CheckConstraint(schema *Schema, constraint any, entity *egdm.Entity) (bool, *ConstraintViolation, error)
- func (v *Validator) CheckEntityIsAbstractConstraint(schema *Schema, entity *egdm.Entity, constraint *IsAbstractConstraint) (bool, *ConstraintViolation, error)
- func (v *Validator) CheckExistenceAndTypeOfReferencedEntity(entityId string, expectedType string) (valid bool, violation *ConstraintViolation, err error)
- func (v *Validator) CheckGlobalIsAbstractConstraint(constraint *IsAbstractConstraint) (bool, *ConstraintViolation, error)
- func (v *Validator) CheckInverseReferenceConstraint(entity *egdm.Entity, constraint *InverseReferenceConstraint) (bool, *ConstraintViolation, error)
- func (v *Validator) CheckPropertyConstraint(entity *egdm.Entity, constraint *PropertyConstraint) (valid bool, violation *ConstraintViolation, err error)
- func (v *Validator) CheckReferenceConstraint(entity *egdm.Entity, constraint *ReferenceConstraint) (bool, *ConstraintViolation, error)
- func (v *Validator) ValidateDataset(schema *Schema, datasetName string) (ok bool, exceptions []*ConstraintViolation, err error)
- func (v *Validator) ValidateEntity(schema *Schema, entity *egdm.Entity) (ok bool, exceptions []*ConstraintViolation, err error)
- func (v *Validator) ValidateEntityCollection(schema *Schema, entityCollection *egdm.EntityCollection) (ok bool, exceptions []*ConstraintViolation, err error)
- func (v *Validator) ValidateSchema(schema *Schema) (ok bool, exceptions []*ConstraintViolation, err error)
- func (v *Validator) WithDataProvider(provider DataProvider) *Validator
- func (v *Validator) WithSettings(settings *ValidatorSettings) *Validator
- type ValidatorSettings
- type ViolationType
Constants ¶
View Source
const ( EGCLsortable = EGCLUriExpansion + "sortable" EGCLqueryable = EGCLUriExpansion + "queryable" EGCLisunique = EGCLUriExpansion + "isunique" EGCLminCardinality = EGCLUriExpansion + "minCard" EGCLmaxCardinality = EGCLUriExpansion + "maxCard" EGCLrule = EGCLUriExpansion + "rule" EGCLinverseMinCardinality = EGCLUriExpansion + "inverseMinCard" EGCLinverseMaxCardinality = EGCLUriExpansion + "inverseMaxCard" )
View Source
const EGCLAny = EGCLUriExpansion + "Any"
View Source
const EGCLApplicationConstraint = EGCLUriExpansion + "ApplicationConstraint"
View Source
const EGCLDescription = EGCLUriExpansion + "description"
View Source
const EGCLEntityClass = EGCLUriExpansion + "EntityClass"
View Source
const EGCLInverseReferenceClass = EGCLUriExpansion + "inverseReferenceClass"
View Source
const EGCLIsAbstractConstraint = EGCLUriExpansion + "IsAbstractConstraint"
View Source
const EGCLLabel = EGCLUriExpansion + "label"
View Source
const EGCLPropertyConstraint = EGCLUriExpansion + "PropertyConstraint"
View Source
const EGCLReferenceConstraint = EGCLUriExpansion + "ReferenceConstraint"
View Source
const EGCLUriExpansion = "http://data.mimiro.io/egcl/"
View Source
const EGCLallowedReferencedClass = EGCLUriExpansion + "referencedEntityClass"
View Source
const EGCLdatatype = EGCLUriExpansion + "datatype"
View Source
const EGCLentityClass = EGCLUriExpansion + "entityClass"
View Source
const EGCLpropertyClass = EGCLUriExpansion + "propertyClass"
View Source
const EGCLreferenceClass = EGCLUriExpansion + "referenceClass"
View Source
const EGCLsubclassOf = EGCLUriExpansion + "subClassOf"
View Source
const MaxInt = math.MaxInt32
for our purposes, we can use math.MaxInt32 as infinity
View Source
const RDFUriExpansion = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
View Source
const RDfTypeURI = RDFUriExpansion + "type"
Variables ¶
View Source
var (
ErrMissingParent = errors.New("referenced super class is not defined in the schema")
)
Functions ¶
This section is empty.
Types ¶
type ApplicationConstraint ¶
type ApplicationConstraint struct {
Constraint
}
func (*ApplicationConstraint) GetRule ¶
func (c *ApplicationConstraint) GetRule() string
func (*ApplicationConstraint) Match ¶
func (c *ApplicationConstraint) Match(namespaceManager egdm.NamespaceManager, rule string) bool
type Constraint ¶
type ConstraintViolation ¶
type ConstraintViolation struct {
Constraint any
Entity *egdm.Entity
ViolationType ViolationType
Message string
}
func NewConstraintViolation ¶
func NewConstraintViolation(constraint any, entity *egdm.Entity, violationType ViolationType, message string) *ConstraintViolation
type DataProvider ¶
type EntityClass ¶
func NewEntityClass ¶
func NewEntityClass(entity *egdm.Entity) *EntityClass
func (*EntityClass) GetDescription ¶
func (entityClass *EntityClass) GetDescription() string
func (*EntityClass) GetLabel ¶
func (entityClass *EntityClass) GetLabel() string
type InverseReferenceConstraint ¶
type InverseReferenceConstraint struct {
Constraint
}
type IsAbstractConstraint ¶
type IsAbstractConstraint struct {
Constraint
}
func (*IsAbstractConstraint) GetEntityClass ¶
func (c *IsAbstractConstraint) GetEntityClass() string
type NamespaceResolver ¶
type PropertyConstraint ¶
type PropertyConstraint struct {
Constraint
}
func (*PropertyConstraint) GetConstrainedEntityClass ¶
func (c *PropertyConstraint) GetConstrainedEntityClass() (string, error)
func (*PropertyConstraint) GetConstrainedPropertyClass ¶
func (c *PropertyConstraint) GetConstrainedPropertyClass() (string, error)
func (*PropertyConstraint) GetDataType ¶
func (c *PropertyConstraint) GetDataType() string
func (*PropertyConstraint) GetIsQueryable ¶
func (c *PropertyConstraint) GetIsQueryable() bool
func (*PropertyConstraint) GetIsUnique ¶
func (c *PropertyConstraint) GetIsUnique() bool
func (*PropertyConstraint) GetMaxAllowedOccurrences ¶
func (c *PropertyConstraint) GetMaxAllowedOccurrences() int
func (*PropertyConstraint) GetMinAllowedOccurrences ¶
func (c *PropertyConstraint) GetMinAllowedOccurrences() int
func (*PropertyConstraint) GetSortable ¶
func (c *PropertyConstraint) GetSortable() string
type PropertyValueConstraint ¶
type PropertyValueConstraint struct {
}
type QueryConstraint ¶
type QueryConstraint struct {
Constraint
}
type ReferenceConstraint ¶
type ReferenceConstraint struct {
Constraint
}
func (*ReferenceConstraint) GetAllowedReferencedClass ¶
func (aReferenceConstraint *ReferenceConstraint) GetAllowedReferencedClass() (string, error)
func (*ReferenceConstraint) GetConstrainedEntityClass ¶
func (aReferenceConstraint *ReferenceConstraint) GetConstrainedEntityClass() (string, error)
func (*ReferenceConstraint) GetConstrainedPropertyClass ¶
func (aReferenceConstraint *ReferenceConstraint) GetConstrainedPropertyClass() (string, error)
func (*ReferenceConstraint) GetInverseConstrainedPropertyClass ¶
func (aReferenceConstraint *ReferenceConstraint) GetInverseConstrainedPropertyClass() (string, error)
func (*ReferenceConstraint) GetMaxAllowedOccurrences ¶
func (aReferenceConstraint *ReferenceConstraint) GetMaxAllowedOccurrences() int
func (*ReferenceConstraint) GetMinAllowedOccurrences ¶
func (aReferenceConstraint *ReferenceConstraint) GetMinAllowedOccurrences() int
type RemoteDataProvider ¶
type RemoteDataProvider struct {
// contains filtered or unexported fields
}
func NewRemoteDataProvider ¶
func NewRemoteDataProvider(client *datahub.Client) (*RemoteDataProvider, error)
func (*RemoteDataProvider) GetDatasetEntities ¶
func (r *RemoteDataProvider) GetDatasetEntities(name string) (datahub.EntityIterator, error)
type Schema ¶
type Schema struct {
EntityCollection *egdm.EntityCollection
EntityClasses []*EntityClass
Constraints []any
BaseURI string
Description string
}
func NewSchema ¶
func NewSchema(entities *egdm.EntityCollection) *Schema
func NewSchemaFromYaml ¶
func (*Schema) GetConstraintsForEntityClass ¶
func (*Schema) GetEntityClassById ¶
func (aSchema *Schema) GetEntityClassById(entityClassIdentifier string) *EntityClass
func (*Schema) GetEntityClassClassHierarchy ¶
func (*Schema) GetOutgoingInverseConstraintsForEntityClass ¶
func (aSchema *Schema) GetOutgoingInverseConstraintsForEntityClass(entityClassIdentifier string, inherited bool) []any
Get any reference constraints that are inverse and thus outgoing for the specific entityClassIdentifer
func (*Schema) IsAbstract ¶
func (aSchema *Schema) IsAbstract(entityClass *EntityClass) bool
type SchemaValidator ¶
type SchemaValidator interface {
ValidateEntity(schema *Schema, entity *egdm.Entity) (ok bool, exceptions []*ConstraintViolation, err error)
ValidateDataset(schema *Schema, datasetName string) (ok bool, exceptions []*ConstraintViolation, err error)
ValidateSchema(schema *Schema) (ok bool, exceptions []*ConstraintViolation, err error)
ValidateEntityCollection(schema *Schema, entityCollection *egdm.EntityCollection) (ok bool, exceptions []*ConstraintViolation, err error)
}
type Validator ¶
type Validator struct {
// contains filtered or unexported fields
}
func NewValidator ¶
func NewValidator() *Validator
func (*Validator) CheckConstraint ¶
func (v *Validator) CheckConstraint(schema *Schema, constraint any, entity *egdm.Entity) (bool, *ConstraintViolation, error)
CheckConstraint checks if the given constraint is violated for the given entity. Returns false if the constraint is ok and true and a constraint violation struct if not. Error is returned if something went wrong while checking the constraint.
func (*Validator) CheckEntityIsAbstractConstraint ¶
func (v *Validator) CheckEntityIsAbstractConstraint(schema *Schema, entity *egdm.Entity, constraint *IsAbstractConstraint) (bool, *ConstraintViolation, error)
func (*Validator) CheckExistenceAndTypeOfReferencedEntity ¶
func (*Validator) CheckGlobalIsAbstractConstraint ¶
func (v *Validator) CheckGlobalIsAbstractConstraint(constraint *IsAbstractConstraint) (bool, *ConstraintViolation, error)
func (*Validator) CheckInverseReferenceConstraint ¶
func (v *Validator) CheckInverseReferenceConstraint(entity *egdm.Entity, constraint *InverseReferenceConstraint) (bool, *ConstraintViolation, error)
func (*Validator) CheckPropertyConstraint ¶
func (v *Validator) CheckPropertyConstraint(entity *egdm.Entity, constraint *PropertyConstraint) (valid bool, violation *ConstraintViolation, err error)
func (*Validator) CheckReferenceConstraint ¶
func (v *Validator) CheckReferenceConstraint(entity *egdm.Entity, constraint *ReferenceConstraint) (bool, *ConstraintViolation, error)
func (*Validator) ValidateDataset ¶
func (v *Validator) ValidateDataset(schema *Schema, datasetName string) (ok bool, exceptions []*ConstraintViolation, err error)
ValidateDataset validates the given schema against the data in the named dataset
func (*Validator) ValidateEntity ¶
func (*Validator) ValidateEntityCollection ¶
func (v *Validator) ValidateEntityCollection(schema *Schema, entityCollection *egdm.EntityCollection) (ok bool, exceptions []*ConstraintViolation, err error)
ValidateEntityCollection validates the given entity collection against the given schema
func (*Validator) ValidateSchema ¶
func (v *Validator) ValidateSchema(schema *Schema) (ok bool, exceptions []*ConstraintViolation, err error)
ValidateSchema validates the given schema against data accessible to this validator
func (*Validator) WithDataProvider ¶
func (v *Validator) WithDataProvider(provider DataProvider) *Validator
func (*Validator) WithSettings ¶
func (v *Validator) WithSettings(settings *ValidatorSettings) *Validator
type ValidatorSettings ¶
type ValidatorSettings struct {
// StrictValidation will cause the validator to fail if an entity has properties or references that are not defined in the schema
StrictValidation bool
// ValidateRelated enables validation of referenced entities, specifically that they exist and are of the correct type
ValidateRelated bool
// datasetsContext defines the set of datasets that are in play when checking referenced entities
DatasetsContext []string
}
type ViolationType ¶
type ViolationType int
const ( MinPropertyOccurrenceNotMet ViolationType = iota MaxPropertyOccurrenceExceeded MinReferenceOccurrenceNotMet MaxReferenceOccurrenceExceeded ReferenceNotFound ReferenceTypeMismatch AbstractEntityClassViolation )
Click to show internal directories.
Click to hide internal directories.