Skip to content

Commit

Permalink
Retrieve correct data from dataset struct.
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Swärd committed Nov 26, 2024
1 parent 1fd0587 commit faefbf2
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 10 deletions.
12 changes: 10 additions & 2 deletions dsp/catalog_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,14 @@ func (ch *dspHandlers) datasetRequestHandler(w http.ResponseWriter, req *http.Re
}

func processProviderDataset(pds *providerv1alpha1.Dataset, service shared.DataService) shared.Dataset {
var checksum *shared.Checksum
cs := pds.GetChecksum()
if cs != nil {
checksum = &shared.Checksum{
Algorithm: cs.GetAlgorithm(),
Value: cs.GetValue(),
}
}
ds := shared.Dataset{
Resource: shared.Resource{
ID: shared.IDToURN(pds.GetId()),
Expand All @@ -152,14 +160,14 @@ func processProviderDataset(pds *providerv1alpha1.Dataset, service shared.DataSe
ByteSize: int(pds.GetByteSize()),
CompressFormat: pds.GetCompressFormat(),
PackageFormat: pds.GetPackageFormat(),
Checksum: nil,
Checksum: checksum,
}},
}

for _, desc := range pds.GetDescription() {
ds.Distribution[0].Description = append(ds.Distribution[0].Description, shared.Multilanguage{
Value: desc.GetValue(),
Language: desc.GetValue(),
Language: desc.GetLanguage(),
})
}

Expand Down
32 changes: 24 additions & 8 deletions dsp/control/control.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,13 +330,6 @@ func processCatalogue(cat []shared.Dataset) []*dspv1alpha1.Dataset {
}

func processDataset(dsp shared.Dataset) *dspv1alpha1.Dataset {
desc := make([]*dspv1alpha1.Multilingual, len(dsp.Description))
for i, v := range dsp.Description {
desc[i] = &dspv1alpha1.Multilingual{
Value: v.Value,
Language: v.Language,
}
}
issued, err := time.Parse(time.RFC3339, dsp.Issued)
if err != nil {
issued = time.Unix(0, 0).UTC()
Expand All @@ -346,8 +339,28 @@ func processDataset(dsp shared.Dataset) *dspv1alpha1.Dataset {
modified = time.Unix(0, 0).UTC()
}
a := ""
mediaType := ""
var desc []*dspv1alpha1.Multilingual
var size int64
var checksum *dspv1alpha1.Checksum
if len(dsp.Distribution) > 0 {
a = dsp.Distribution[0].Format
d := dsp.Distribution[0]
desc = make([]*dspv1alpha1.Multilingual, len(d.Description))
for i, v := range d.Description {
desc[i] = &dspv1alpha1.Multilingual{
Value: v.Value,
Language: v.Language,
}
}
a = d.Format
mediaType = d.MediaType
size = int64(d.ByteSize)
if d.Checksum != nil {
checksum = &dspv1alpha1.Checksum{
Algorithm: d.Checksum.Algorithm,
Value: d.Checksum.Value,
}
}
}
return &dspv1alpha1.Dataset{
Id: strings.TrimPrefix(dsp.ID, "urn:uuid:%s"),
Expand All @@ -359,6 +372,9 @@ func processDataset(dsp shared.Dataset) *dspv1alpha1.Dataset {
Issued: timestamppb.New(issued),
Modified: timestamppb.New(modified),
Metadata: map[string]string{},
MediaType: mediaType,
ByteSize: size,
Checksum: checksum,
}
}

Expand Down

0 comments on commit faefbf2

Please sign in to comment.