entityrelationship

package
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 16, 2019 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// ErrERNotFound must be used to indicate that entity relationship for provided id is not found in the system
	ErrERNotFound = errors.Error("entity relationship not found in the system database.")

	// ErrERInvalidIdentifier must be used to indicate different identifier
	ErrERInvalidIdentifier = errors.Error("entity relationship contains different entity identifier")

	// ErrERNoToken must be used to indicate missing tokens
	ErrERNoToken = errors.Error("entity relationship contains no access token")

	// ErrNotEntityRelationship must be used if an expected entityRelationship model is not a entityRelationship
	ErrNotEntityRelationship = errors.Error("model not entity relationship")
)
View Source
const (
	// BootstrappedEntityRelationshipService maps to the service for entity relationships
	BootstrappedEntityRelationshipService string = "BootstrappedEntityRelationshipService"
)

Variables

This section is empty.

Functions

func CreateValidator

func CreateValidator(factory identity.Factory) documents.ValidatorGroup

CreateValidator returns a validator group that should be run before creating the entity and persisting it to DB

func UpdateValidator

func UpdateValidator(factory identity.Factory) documents.ValidatorGroup

UpdateValidator returns a validator group that should be run before updating the entity

Types

type Bootstrapper

type Bootstrapper struct{}

Bootstrapper implements bootstrap.Bootstrapper.

func (Bootstrapper) Bootstrap

func (Bootstrapper) Bootstrap(ctx map[string]interface{}) error

Bootstrap sets the required storage and registers

type EntityRelationship

type EntityRelationship struct {
	*documents.CoreDocument

	// owner of the relationship
	OwnerIdentity *identity.DID
	// Entity identifier
	EntityIdentifier []byte
	// identity which will be granted access
	TargetIdentity *identity.DID
}

EntityRelationship implements the documents.Model and keeps track of entity-relationship related fields and state.

func (*EntityRelationship) AddNFT

func (e *EntityRelationship) AddNFT(grantReadAccess bool, registry common.Address, tokenID []byte) error

AddNFT is not implemented for EntityRelationship

func (*EntityRelationship) CalculateDataRoot

func (e *EntityRelationship) CalculateDataRoot() ([]byte, error)

CalculateDataRoot calculates the data root.

func (*EntityRelationship) CalculateDocumentRoot

func (e *EntityRelationship) CalculateDocumentRoot() ([]byte, error)

CalculateDocumentRoot calculates the document root.

func (*EntityRelationship) CalculateSigningRoot

func (e *EntityRelationship) CalculateSigningRoot() ([]byte, error)

CalculateSigningRoot calculates the signing root of the document.

func (*EntityRelationship) CollaboratorCanUpdate

func (e *EntityRelationship) CollaboratorCanUpdate(updated documents.Model, identity identity.DID) error

CollaboratorCanUpdate checks that the identity attempting to update the document is the identity which owns the document.

func (*EntityRelationship) CreateNFTProofs

func (e *EntityRelationship) CreateNFTProofs(
	account identity.DID,
	registry common.Address,
	tokenID []byte,
	nftUniqueProof, readAccessProof bool) (proofs []*proofspb.Proof, err error)

CreateNFTProofs is not implemented for EntityRelationship.

func (*EntityRelationship) CreateProofs

func (e *EntityRelationship) CreateProofs(fields []string) (proofs []*proofspb.Proof, err error)

CreateProofs generates proofs for given fields.

func (*EntityRelationship) DocumentRootTree

func (e *EntityRelationship) DocumentRootTree() (tree *proofs.DocumentTree, err error)

DocumentRootTree creates and returns the document root tree.

func (*EntityRelationship) DocumentType

func (*EntityRelationship) DocumentType() string

DocumentType returns the entity relationship document type.

func (*EntityRelationship) FromJSON

func (e *EntityRelationship) FromJSON(jsonData []byte) error

FromJSON unmarshals the json bytes into EntityRelationship

func (*EntityRelationship) InitEntityRelationshipInput

func (e *EntityRelationship) InitEntityRelationshipInput(ctx context.Context, entityID string, data *entitypb2.RelationshipData) error

InitEntityRelationshipInput initialize the model based on the received parameters from the rest api call

func (*EntityRelationship) JSON

func (e *EntityRelationship) JSON() ([]byte, error)

JSON marshals EntityRelationship into a json bytes

func (*EntityRelationship) PackCoreDocument

func (e *EntityRelationship) PackCoreDocument() (cd coredocumentpb.CoreDocument, err error)

PackCoreDocument packs the EntityRelationship into a CoreDocument.

func (*EntityRelationship) PrepareNewVersion

func (e *EntityRelationship) PrepareNewVersion(old documents.Model, data *entitypb2.RelationshipData, collaborators []string) error

PrepareNewVersion prepares new version from the old entity.

func (*EntityRelationship) Type

func (e *EntityRelationship) Type() reflect.Type

Type gives the EntityRelationship type.

func (*EntityRelationship) UnpackCoreDocument

func (e *EntityRelationship) UnpackCoreDocument(cd coredocumentpb.CoreDocument) error

UnpackCoreDocument unpacks the core document into an EntityRelationship.

type Service

type Service interface {
	documents.Service

	// DeriveFromCreatePayload derives Entity Relationship from RelationshipPayload
	DeriveFromCreatePayload(ctx context.Context, payload *entitypb.RelationshipPayload) (documents.Model, error)

	// DeriveFromUpdatePayload derives a revoked entity relationship model from RelationshipPayload
	DeriveFromUpdatePayload(ctx context.Context, payload *entitypb.RelationshipPayload) (documents.Model, error)

	// DeriveEntityRelationshipData returns the entity relationship data as client data
	DeriveEntityRelationshipData(relationship documents.Model) (*entitypb.RelationshipData, error)

	// DeriveEntityRelationshipResponse returns the entity relationship model in our standard client format
	DeriveEntityRelationshipResponse(relationship documents.Model) (*entitypb.RelationshipResponse, error)

	// GetEntityRelationships returns a list of the latest versions of the relevant entity relationship based on an entity id
	GetEntityRelationships(ctx context.Context, entityID []byte) ([]documents.Model, error)
}

Service defines specific functions for entity

func DefaultService

func DefaultService(
	srv documents.Service,
	repo repository,
	queueSrv queue.TaskQueuer,
	jobManager jobs.Manager,
	factory identity.Factory,
) Service

DefaultService returns the default implementation of the service.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL