func (r *GormWorkItemLinkRepository) ValidateCorrectSourceAndTargetType(ctx context.Context, sourceID, targetID uint64, linkTypeID uuid.UUID) error {
	linkType, err := r.workItemLinkTypeRepo.LoadTypeFromDBByID(ctx, linkTypeID)
	if err != nil {
		return errs.WithStack(err)
	}
	// Fetch the source work item
	source, err := r.workItemRepo.LoadFromDB(ctx, strconv.FormatUint(sourceID, 10))
	if err != nil {
		return errs.WithStack(err)
	}
	// Fetch the target work item
	target, err := r.workItemRepo.LoadFromDB(ctx, strconv.FormatUint(targetID, 10))
	if err != nil {
		return errs.WithStack(err)
	}
	// Fetch the concrete work item types of the target and the source.
	sourceWorkItemType, err := r.workItemTypeRepo.LoadTypeFromDB(ctx, source.Type)
	if err != nil {
		return errs.WithStack(err)
	}
	targetWorkItemType, err := r.workItemTypeRepo.LoadTypeFromDB(ctx, target.Type)
	if err != nil {
		return errs.WithStack(err)
	}
	// Check type paths
	if !sourceWorkItemType.IsTypeOrSubtypeOf(linkType.SourceTypeID) {
		return errors.NewBadParameterError("source work item type", source.Type)
	}
	if !targetWorkItemType.IsTypeOrSubtypeOf(linkType.TargetTypeID) {
		return errors.NewBadParameterError("target work item type", target.Type)
	}
	return nil
}
// ValidateCorrectSourceAndTargetType returns an error if the Path of
// the source WIT as defined by the work item link type is not part of
// the actual source's WIT; the same applies for the target.
ValidateCorrectSourceAndTargetType returns an error if the Path of
the source WIT as defined by the work item link type is not part of
the actual source's WIT; the same applies for the target.
// ValidateCorrectSourceAndTargetType returns an error if the Path of // the source WIT as defined by the work item link type is not part of // the actual source ' s WIT ; the same applies for the target .
func (r *GormWorkItemLinkRepository) ValidateCorrectSourceAndTargetType(ctx context.Context, sourceID, targetID uint64, linkTypeID uuid.UUID) error {
	linkType, err := r.workItemLinkTypeRepo.LoadTypeFromDBByID(ctx, linkTypeID)
	if err != nil {
		return errs.WithStack(err)
	}
	source, err := r.workItemRepo.LoadFromDB(ctx, strconv.FormatUint(sourceID, 10))
	if err != nil {
		return errs.WithStack(err)
	}
	target, err := r.workItemRepo.LoadFromDB(ctx, strconv.FormatUint(targetID, 10))
	if err != nil {
		return errs.WithStack(err)
	}
	sourceWorkItemType, err := r.workItemTypeRepo.LoadTypeFromDB(ctx, source.Type)
	if err != nil {
		return errs.WithStack(err)
	}
	targetWorkItemType, err := r.workItemTypeRepo.LoadTypeFromDB(ctx, target.Type)
	if err != nil {
		return errs.WithStack(err)
	}
	if !sourceWorkItemType.IsTypeOrSubtypeOf(linkType.SourceTypeID) {
		return errors.NewBadParameterError("source work item type", source.Type)
	}
	if !targetWorkItemType.IsTypeOrSubtypeOf(linkType.TargetTypeID) {
		return errors.NewBadParameterError("target work item type", target.Type)
	}
	return nil
}
func ( r * GormWorkItemLinkRepository ) ValidateCorrectSourceAndTargetType ( ctx context . Context , sourceID , targetID uint64 , linkTypeID uuid . UUID ) error { linkType , err := r . workItemLinkTypeRepo . LoadTypeFromDBByID ( ctx , linkTypeID ) if err != nil { return errs . WithStack ( err ) } source , err := r . workItemRepo . LoadFromDB ( ctx , strconv . FormatUint ( sourceID , 10 ) ) if err != nil { return errs . WithStack ( err ) } target , err := r . workItemRepo . LoadFromDB ( ctx , strconv . FormatUint ( targetID , 10 ) ) if err != nil { return errs . WithStack ( err ) } sourceWorkItemType , err := r . workItemTypeRepo . LoadTypeFromDB ( ctx , source . Type ) if err != nil { return errs . WithStack ( err ) } targetWorkItemType , err := r . workItemTypeRepo . LoadTypeFromDB ( ctx , target . Type ) if err != nil { return errs . WithStack ( err ) } if ! sourceWorkItemType . IsTypeOrSubtypeOf ( linkType . SourceTypeID ) { return errors . NewBadParameterError ( " " , source . Type ) } if ! targetWorkItemType . IsTypeOrSubtypeOf ( linkType . TargetTypeID ) { return errors . NewBadParameterError ( " " , target . Type ) } return nil }
ValidateCorrectSourceAndTargetType returns an error if the Path of
the source WIT as defined by the work item link type is not part of
the actual source's WIT; the same applies for the target.
ValidateCorrectSourceAndTargetType returns an error if the Path of the source WIT as defined by the work item link type is not part of the actual source ' s WIT ; the same applies for the target .
// Fetch the source work item // Fetch the target work item // Fetch the concrete work item types of the target and the source. // Check type paths