MCPcopy Create free account
hub / github.com/pydio/cells / GetMetaEntityValuesMap

Method GetMetaEntityValuesMap

idm/meta/dao/sql/ev-sql.go:349–391  ·  view source on GitHub ↗

GetMetaEntityValuesMap retrieves a map of meta UUIDs to their linked entity values for a given list of meta UUIDs

(ctx context.Context, metaUuids []string)

Source from the content-addressed store, hash-verified

347
348// GetMetaEntityValuesMap retrieves a map of meta UUIDs to their linked entity values for a given list of meta UUIDs
349func (s *evSqlImpl) GetMetaEntityValuesMap(ctx context.Context, metaUuids []string) (map[string][]*idm.EntityValue, error) {
350 if len(metaUuids) == 0 {
351 return nil, nil
352 }
353
354 var relations []struct {
355 MetaUUID string
356 EVUuid string
357 EVLabel string
358 EVEntityUUID string
359 }
360
361 db := s.Session(ctx)
362 relTable := sql.TableNameFromModel(db, &MetaValuesRel{})
363 evTable := sql.TableNameFromModel(db, &EntityValues{})
364
365 relTable = sql.QuoteTo(db, relTable)
366 evTable = sql.QuoteTo(db, evTable)
367
368 tx := db.Model(&EntityValues{}).
369 Select(
370 fmt.Sprintf("%s.meta_uuid, %s.uuid as ev_uuid, %s.label as ev_label, %s.entity_uuid as ev_entity_uuid",
371 relTable, evTable, evTable, evTable)).
372 Joins(fmt.Sprintf("INNER JOIN %s ON %s.uuid = %s.e_value_uuid", relTable, evTable, relTable)).
373 Where(fmt.Sprintf("%s.meta_uuid IN ?", relTable), metaUuids).
374 Scan(&relations)
375
376 if tx.Error != nil {
377 return nil, evTagError(tx.Error)
378 }
379
380 result := make(map[string][]*idm.EntityValue)
381 for _, rel := range relations {
382 ev := &idm.EntityValue{
383 Uuid: rel.EVUuid,
384 Label: rel.EVLabel,
385 EntityUuid: rel.EVEntityUUID,
386 }
387 result[rel.MetaUUID] = append(result[rel.MetaUUID], ev)
388 }
389
390 return result, nil
391}

Callers 1

GetMetaEntityValuesMethod · 0.95

Calls 10

TableNameFromModelFunction · 0.92
QuoteToFunction · 0.92
evTagErrorFunction · 0.85
makeFunction · 0.85
SessionMethod · 0.65
ScanMethod · 0.65
WhereMethod · 0.65
SelectMethod · 0.65
JoinsMethod · 0.45
ModelMethod · 0.45

Tested by

no test coverage detected