market_communication

package
v0.5.0-alpha0 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateRandomDokumentennummer added in v0.0.31

func GenerateRandomDokumentennummer() string

GenerateRandomDokumentennummer returns a random BGM key

func GenerateRandomNachrichtenReferenznummer added in v0.0.31

func GenerateRandomNachrichtenReferenznummer() string

GenerateRandomNachrichtenReferenznummer returns a random UNH key

func GetAll added in v0.4.0

func GetAll[T any, Ptr interface {
	bo.BusinessObject
	*T
}](boneyComb *BOneyComb) []*T

GetAll filters a BOneyComb's Stammdaten for business objects of a specific type, given as type parameter T. T must be a non-pointer type, even if bo.BusinessObject is implemented only via pointer receivers (*T).

Example
package main

import (
	"fmt"

	"github.com/hochfrequenz/go-bo4e/bo"
	"github.com/hochfrequenz/go-bo4e/enum/botyp"
	"github.com/hochfrequenz/go-bo4e/market_communication"
)

func main() {
	boneyComb := &market_communication.BOneyComb{
		Stammdaten: []bo.BusinessObject{
			bo.NewBusinessObject(botyp.MARKTTEILNEHMER),
			bo.NewBusinessObject(botyp.MESSLOKATION),
			bo.NewBusinessObject(botyp.ZAEHLER),
			bo.NewBusinessObject(botyp.RECHNUNG),
			bo.NewBusinessObject(botyp.MESSLOKATION),
			bo.NewBusinessObject(botyp.LASTGANG),

			// Business objects created via bo.NewBusinessObject are pointers, but the concrete types implement
			// bo.BusinessObject via value receivers, so a slice of these objects may contain non-pointer values
			// as well. We include one of them here to show that these work as expected, too.
			bo.Marktteilnehmer{},
		},
	}

	var preisblattValues []*bo.Preisblatt = market_communication.GetAll[bo.Preisblatt](boneyComb)
	fmt.Printf("objects of type Preisblatt     : %d\n", len(preisblattValues))

	var marktteilnehmerValues []*bo.Marktteilnehmer = market_communication.GetAll[bo.Marktteilnehmer](boneyComb)
	fmt.Printf("objects of type Marktteilnehmer: %d\n", len(marktteilnehmerValues))

	var lastgangValues []*bo.Lastgang = market_communication.GetAll[bo.Lastgang](boneyComb)
	fmt.Printf("objects of type Lastgang       : %d\n", len(lastgangValues))

}
Output:

objects of type Preisblatt     : 0
objects of type Marktteilnehmer: 2
objects of type Lastgang       : 1

func GetSingle added in v0.4.0

func GetSingle[T any, Ptr interface {
	bo.BusinessObject
	*T
}](boneyComb *BOneyComb) (*T, error)

GetSingle searches BOneyComb's Stammdaten for the single business object of the specified type, given as type parameter T. T must be non-pointer type, even if bo.BusinessObject is implemented only via pointer receivers (*T). Returns an error if there is either no business object of that type or there is more than one.

Example
package main

import (
	"fmt"

	"github.com/hochfrequenz/go-bo4e/bo"
	"github.com/hochfrequenz/go-bo4e/enum/botyp"
	"github.com/hochfrequenz/go-bo4e/market_communication"
)

func main() {
	boneyComb := &market_communication.BOneyComb{
		Stammdaten: []bo.BusinessObject{
			bo.NewBusinessObject(botyp.MARKTTEILNEHMER),
			bo.NewBusinessObject(botyp.MESSLOKATION),
			bo.NewBusinessObject(botyp.ZAEHLER),
			bo.NewBusinessObject(botyp.RECHNUNG),
			bo.NewBusinessObject(botyp.MESSLOKATION),
			bo.NewBusinessObject(botyp.LASTGANG),

			// Business objects created via bo.NewBusinessObject are pointers, but the concrete types implement
			// bo.BusinessObject via value receivers, so a slice of these objects may contain non-pointer values
			// as well. We include one of them here to show that these work as expected, too.
			bo.Marktteilnehmer{},
		},
	}

	preisblatt, err := market_communication.GetSingle[bo.Preisblatt](boneyComb)
	if err != nil {
		fmt.Println("Preisblatt count is not 1")
	}
	if preisblatt != nil {
		fmt.Println("found a Preisblatt")
	}

	marktteilnehmer, err := market_communication.GetSingle[bo.Marktteilnehmer](boneyComb)
	if err != nil {
		fmt.Println("Marktteilnehmer count is not 1")
	}
	if marktteilnehmer != nil {
		fmt.Println("found a Marktteilnehmer")
	}

	lastgang, err := market_communication.GetSingle[bo.Lastgang](boneyComb)
	if err != nil {
		fmt.Println("Lastgang count is not 1")
	}
	if lastgang != nil {
		fmt.Println("found a Lastgang")
	}

}
Output:

Preisblatt count is not 1
Marktteilnehmer count is not 1
found a Lastgang

func PruefidentifikatorInTransaktionsdatenValidation added in v0.0.17

func PruefidentifikatorInTransaktionsdatenValidation(sl validator.StructLevel)

PruefidentifikatorInTransaktionsdatenValidation returns true iff a valid Pruefidentifikator (see GetPruefidentifikator) is present

Types

type BOneyComb

type BOneyComb struct {
	Stammdaten        bo.BusinessObjectSlice `json:"stammdaten" validate:"required"`        // Stammdaten is an array of business objects
	Transaktionsdaten map[string]string      `json:"transaktionsdaten" validate:"required"` // Transaktionsdaten are data relevant only in the context of this market communication message
	Links             map[string][]string    `json:"links"`                                 // Links describes relations between different BusinessObjects in Stammdaten
}

BOneyComb is a structure that is used when dealing with business objects that are embedded into market communication messages. The BOneyComb combines an array of business objects named "Stammdaten" with a key value dict of process data named "Transaktionsdaten"

func (*BOneyComb) ContainsAny added in v0.0.32

func (boneyComb *BOneyComb) ContainsAny(typ botyp.BOTyp) bool

ContainsAny returns true if any business object of the given type is present in BOneyComb.Stammdaten

func (*BOneyComb) GetAbsender

func (boneyComb *BOneyComb) GetAbsender() *bo.Marktteilnehmer

GetAbsender returns the sending bo.Marktteilnehmer if present in the Transaktionsdaten _and_ Stammdaten; nil otherwise

func (*BOneyComb) GetAbsenderCode

func (boneyComb *BOneyComb) GetAbsenderCode() *string

GetAbsenderCode returns the 13 digit ID of the sending Marktteilnehmer if present in the Transaktionsdaten; nil otherwise

func (*BOneyComb) GetAll added in v0.0.32

func (boneyComb *BOneyComb) GetAll(typ botyp.BOTyp) bo.BusinessObjectSlice

GetAll returns all business objects from BOneyComb.Stammdaten that have the given type

func (*BOneyComb) GetDokumentennummer

func (boneyComb *BOneyComb) GetDokumentennummer() *string

GetDokumentennummer returns the Dokumentennummer (BMG) from BOneyComb.Transaktionsdaten if it's present and nil otherwise

func (*BOneyComb) GetEmpfaenger

func (boneyComb *BOneyComb) GetEmpfaenger() *bo.Marktteilnehmer

GetEmpfaenger returns the receiving bo.Marktteilnehmer if present in the Transaktionsdaten _and_ Stammdaten; nil otherwise

func (*BOneyComb) GetEmpfaengerCode

func (boneyComb *BOneyComb) GetEmpfaengerCode() *string

GetEmpfaengerCode returns the 13 digit ID of the receiving Marktteilnehmer if present in both Transaktionsdaten; nil otherwise

func (*BOneyComb) GetMasterDataCount added in v0.0.30

func (boneyComb *BOneyComb) GetMasterDataCount(typ botyp.BOTyp) uint

GetMasterDataCount counts the objects of the given type in BOneyComb.Stammdaten

func (*BOneyComb) GetMasterDataCounts added in v0.0.30

func (boneyComb *BOneyComb) GetMasterDataCounts() map[botyp.BOTyp]uint

GetMasterDataCounts counts the different object types in BOneyComb.Stammdaten

func (*BOneyComb) GetNachrichtenReferenznummer added in v0.0.31

func (boneyComb *BOneyComb) GetNachrichtenReferenznummer() *string

GetNachrichtenReferenznummer returns the Dokumentennummer (UNH) from BOneyComb.Transaktionsdaten if it's present and nil otherwise

func (*BOneyComb) GetNachrichtendatum

func (boneyComb *BOneyComb) GetNachrichtendatum() (*time.Time, error)

GetNachrichtendatum checks if the message date is present in BOneyComb.Transaktionsdaten, returns its value if it is present and nil otherwise. Returns an error iff the parsing fails

func (*BOneyComb) GetPruefidentifikator added in v0.0.17

func (boneyComb *BOneyComb) GetPruefidentifikator() *string

GetPruefidentifikator returns the Pruefidentifikator from BOneyComb.Transaktionsdaten if it's present and nil otherwise

func (*BOneyComb) GetSingle added in v0.0.32

func (boneyComb *BOneyComb) GetSingle(typ botyp.BOTyp) (bo.BusinessObject, error)

GetSingle returns the single present business object of the given type if it is present in BOneyComb.Stammdaten. It returns an error if there is none or more than one

func (*BOneyComb) GetTransactionData

func (boneyComb *BOneyComb) GetTransactionData(key string) *string

GetTransactionData checks if the key is present in BOneyComb.Transaktionsdaten, returns its value if it is present and nil otherwise

func (*BOneyComb) GetTransaktionsdatenKeys added in v0.0.30

func (boneyComb *BOneyComb) GetTransaktionsdatenKeys() []string

GetTransaktionsdatenKeys returns a sorted array of keys used in the Transaktionsdaten This function is useful for unit testing purposes

func (*BOneyComb) SetAbsender added in v0.0.15

func (boneyComb *BOneyComb) SetAbsender(mt bo.Marktteilnehmer, useBo4eUri bool)

SetAbsender sets sending bo.Marktteilnehmer in both the Transaktionsdaten _and_ Stammdaten

func (*BOneyComb) SetAbsenderCode added in v0.0.15

func (boneyComb *BOneyComb) SetAbsenderCode(mpId string, useBo4eUri bool)

SetAbsenderCode sets the 13 digit ID of the sending Marktteilnehmer in the Transaktionsdaten

func (*BOneyComb) SetDokumentennummer added in v0.0.16

func (boneyComb *BOneyComb) SetDokumentennummer(dokumentnummer string)

SetDokumentennummer sets the Dokumentennummer (BGM) in the BOneyComb.Transaktionsdaten

func (*BOneyComb) SetEmpfaenger added in v0.0.15

func (boneyComb *BOneyComb) SetEmpfaenger(mt bo.Marktteilnehmer, useBo4eUri bool)

SetEmpfaenger sets receiving bo.Marktteilnehmer in both the Transaktionsdaten _and_ Stammdaten

func (*BOneyComb) SetEmpfaengerCode added in v0.0.15

func (boneyComb *BOneyComb) SetEmpfaengerCode(mpId string, useBo4eUri bool)

SetEmpfaengerCode sets the 13 digit ID of the receiving Marktteilnehmer in the Transaktionsdaten

func (*BOneyComb) SetNachrichtenReferenznummer added in v0.0.31

func (boneyComb *BOneyComb) SetNachrichtenReferenznummer(referenzNummer string)

SetNachrichtenReferenznummer sets the Reference Number (UNH) in the BOneyComb.Transaktionsdaten

func (*BOneyComb) SetNachrichtendatum added in v0.0.16

func (boneyComb *BOneyComb) SetNachrichtendatum(nachrichtendatum time.Time)

SetNachrichtendatum sets the nachrichtendatum in BOneyComb.Transaktionsdaten

func (*BOneyComb) SetPruefidentifikator added in v0.0.17

func (boneyComb *BOneyComb) SetPruefidentifikator(pruefi string)

SetPruefidentifikator sets the Pruefidentifikator in the BOneyComb.Transaktionsdaten

Jump to

Keyboard shortcuts

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