View Source SmeeView.PublicationPath (SmeeView v0.2.1)

This module can extracts the <mdrpi:Publication> elements in entity metadata as "aspect" structs, and then process and filter the results.

Aspects can be extracted with three functions:

  • Views, via view/3 are lists of aspects
  • Prisms, via prism/3 are maps of entity IDs to views
  • There is also view_one/3 which returns the first aspect found

Aspects can be extracted from Smee.Metadata structs, Smee.Entity structs, or lists of aspects, Metadata and Entity structs.

The other functions in this module are intended to be applied to collections of aspect structs - for working with individual aspects, please look at the appropriate Aspect module.

Summary

Functions

Removes any non-IdP aspects from a list (view) or map (prism)

Returns a map of Elixir.SmeeView.Aspects.Publication aspect structs extracted from the input data, with entity IDs as keys.

Removes any non-SP aspects from a list (view) or map (prism)

Returns a list of Elixir.SmeeView.Aspects.Publication aspect structs extracted from the input data.

Returns a single Elixir.SmeeView.Aspects.Publication aspect struct extracted from one record in the input data.

Functions

@spec idp_filter(aspects :: map() | list()) :: map() | list()

Removes any non-IdP aspects from a list (view) or map (prism)

PublicationPath.idp_filter(view)
# => []
Link to this function

prism(various, role \\ :all, options \\ [])

View Source
@spec prism(
  various :: Smee.Entity.t() | Smee.Metadata.t() | list(),
  role :: atom(),
  options :: keyword()
) :: map()

Returns a map of Elixir.SmeeView.Aspects.Publication aspect structs extracted from the input data, with entity IDs as keys.

Input data can be a Smee.Entity or Smee.Metadata struct, or a list containing Smee.Entity and/or Smee.Metadata structs. Only appropriate aspect records will be returned.

prism/3 is useful for extracting specific types of aspects from lists of entity records, or metadata. If you are only interested in one aspect from a single Smee.Entity struct then you should probably use view/3 instead.

The optional role parameter will optimize the results to only search for either :idp or :sp aspects. The default is :all.

PublicationPath.prism(entity)
# => %{"https://example.com/shibboleth" =>  [%Elixir.SmeeView.Aspects.Publication{}, %Elixir.SmeeView.Aspects.Publication{},]}
@spec sp_filter(aspects :: map() | list()) :: map() | list()

Removes any non-SP aspects from a list (view) or map (prism)

PublicationPath.sp_filter(view)
# => []
Link to this function

view(list, role \\ :all, options \\ [])

View Source
@spec view(
  list :: Smee.Entity.t() | Smee.Metadata.t() | list(),
  role :: atom(),
  options :: keyword()
) ::
  list()

Returns a list of Elixir.SmeeView.Aspects.Publication aspect structs extracted from the input data.

Input data can be a Smee.Entity or Smee.Metadata struct, or a list containing Smee.Entity, Smee.Metadata or any aspects. Only appropriate aspect records will be returned.

view/3 is useful for extracting specific types of aspects from one Entity, but because it has no entity ID information it's often not the best choice for handling Metadata. When extracting information from entire metadata it's often better to use prism/3 which returns the same data in a map, associated with each entity's ID.

The optional role parameter will optimize the results to only search for either :idp or :sp aspects. The default is :all.

PublicationPath.view(entity)
# => [%Elixir.SmeeView.Aspects.Publication{}, %Elixir.SmeeView.Aspects.Publication{}]
Link to this function

view_one(smee_data, role \\ :all, options \\ [])

View Source
@spec view_one(
  list :: Smee.Entity.t() | Smee.Metadata.t() | list(),
  role :: atom(),
  options :: keyword()
) :: SmeeView.Aspects.Publication.t() | nil

Returns a single Elixir.SmeeView.Aspects.Publication aspect struct extracted from one record in the input data.

Input data can be a Smee.Entity or Smee.Metadata struct, or a list containing Smee.Entity, Smee.Metadata or any aspects.

Only one entity will be processed and then only one aspect will be returned. If you pass one Entity struct as the input, it will be that entity (obviously). If you pass metadata structs or lists one entity will be chosen at random. The first suitable entity will be returned.

view_one/3 is intended for use with a single entity record and aspects like SmeeView.Aspect.Entity, SmeeView.Aspect.SP' orSmeeView.Aspect.Organization' but will work with any aspect.

The optional role parameter will optimize the results to only search for either :idp or :sp aspects. The default is :all.

PublicationPath.view_one(entity)
# => %Elixir.SmeeView.Aspects.Publication{}