func ConvertLinkToModel(appLink app.WorkItemLinkSingle) (*link.WorkItemLink, error) {
	modelLink := link.WorkItemLink{}
	attrs := appLink.Data.Attributes
	rel := appLink.Data.Relationships
	var err error
	if appLink.Data.ID != nil {
		modelLink.ID = *appLink.Data.ID
	}

	if attrs != nil && attrs.Version != nil {
		modelLink.Version = *attrs.Version
	}

	if rel != nil && rel.LinkType != nil && rel.LinkType.Data != nil {
		modelLink.LinkTypeID = rel.LinkType.Data.ID
	}

	if rel != nil && rel.Source != nil && rel.Source.Data != nil {
		d := rel.Source.Data
		// The the work item id MUST NOT be empty
		if d.ID == "" {
			return nil, errors.NewBadParameterError("data.relationships.source.data.id", d.ID)
		}
		if modelLink.SourceID, err = strconv.ParseUint(d.ID, 10, 64); err != nil {
			return nil, errors.NewBadParameterError("data.relationships.source.data.id", d.ID)
		}
	}

	if rel != nil && rel.Target != nil && rel.Target.Data != nil {
		d := rel.Target.Data
		// If the the target type is not nil, it MUST be "workitems"
		// The the work item id MUST NOT be empty
		if d.ID == "" {
			return nil, errors.NewBadParameterError("data.relationships.target.data.id", d.ID)
		}
		if modelLink.TargetID, err = strconv.ParseUint(d.ID, 10, 64); err != nil {
			return nil, errors.NewBadParameterError("data.relationships.target.data.id", d.ID)
		}
	}

	return &modelLink, nil
}
// ConvertLinkToModel converts the incoming app representation of a work item link to the model layout.
// Values are only overwrriten if they are set in "in", otherwise the values in "out" remain.
// NOTE: Only the LinkTypeID, SourceID, and TargetID fields will be set.
//       You need to preload the elements after calling this function.
ConvertLinkToModel converts the incoming app representation of a work item link to the model layout.
Values are only overwrriten if they are set in "in", otherwise the values in "out" remain.
NOTE: Only the LinkTypeID, SourceID, and TargetID fields will be set.
You need to preload the elements after calling this function.
// ConvertLinkToModel converts the incoming app representation of a work item link to the model layout . // Values are only overwrriten if they are set in " in " otherwise the values in " out " remain . // NOTE : Only the LinkTypeID SourceID and TargetID fields will be set . // You need to preload the elements after calling this function .
func ConvertLinkToModel(appLink app.WorkItemLinkSingle) (*link.WorkItemLink, error) {
	modelLink := link.WorkItemLink{}
	attrs := appLink.Data.Attributes
	rel := appLink.Data.Relationships
	var err error
	if appLink.Data.ID != nil {
		modelLink.ID = *appLink.Data.ID
	}
	if attrs != nil && attrs.Version != nil {
		modelLink.Version = *attrs.Version
	}
	if rel != nil && rel.LinkType != nil && rel.LinkType.Data != nil {
		modelLink.LinkTypeID = rel.LinkType.Data.ID
	}
	if rel != nil && rel.Source != nil && rel.Source.Data != nil {
		d := rel.Source.Data
		if d.ID == "" {
			return nil, errors.NewBadParameterError("data.relationships.source.data.id", d.ID)
		}
		if modelLink.SourceID, err = strconv.ParseUint(d.ID, 10, 64); err != nil {
			return nil, errors.NewBadParameterError("data.relationships.source.data.id", d.ID)
		}
	}
	if rel != nil && rel.Target != nil && rel.Target.Data != nil {
		d := rel.Target.Data
		if d.ID == "" {
			return nil, errors.NewBadParameterError("data.relationships.target.data.id", d.ID)
		}
		if modelLink.TargetID, err = strconv.ParseUint(d.ID, 10, 64); err != nil {
			return nil, errors.NewBadParameterError("data.relationships.target.data.id", d.ID)
		}
	}
	return &modelLink, nil
}
func ConvertLinkToModel ( appLink app . WorkItemLinkSingle ) ( * link . WorkItemLink , error ) { modelLink := link . WorkItemLink { } attrs := appLink . Data . Attributes rel := appLink . Data . Relationships var err error if appLink . Data . ID != nil { modelLink . ID = * appLink . Data . ID } if attrs != nil && attrs . Version != nil { modelLink . Version = * attrs . Version } if rel != nil && rel . LinkType != nil && rel . LinkType . Data != nil { modelLink . LinkTypeID = rel . LinkType . Data . ID } if rel != nil && rel . Source != nil && rel . Source . Data != nil { d := rel . Source . Data if d . ID == " " { return nil , errors . NewBadParameterError ( " " , d . ID ) } if modelLink . SourceID , err = strconv . ParseUint ( d . ID , 10 , 64 ) ; err != nil { return nil , errors . NewBadParameterError ( " " , d . ID ) } } if rel != nil && rel . Target != nil && rel . Target . Data != nil { d := rel . Target . Data if d . ID == " " { return nil , errors . NewBadParameterError ( " " , d . ID ) } if modelLink . TargetID , err = strconv . ParseUint ( d . ID , 10 , 64 ) ; err != nil { return nil , errors . NewBadParameterError ( " " , d . ID ) } } return & modelLink , nil }
ConvertLinkToModel converts the incoming app representation of a work item link to the model layout.
ConvertLinkToModel converts the incoming app representation of a work item link to the model layout .
// The the work item id MUST NOT be empty // If the the target type is not nil, it MUST be "workitems" // The the work item id MUST NOT be empty