logs update

This commit is contained in:
mr 2024-08-02 14:07:43 +02:00
parent e23756eba6
commit fa52c71e93
11 changed files with 51 additions and 47 deletions

View File

@ -101,8 +101,8 @@ func ToValueOperator(operator Operator, value interface{}) interface{} {
}
type Filters struct {
And map[string]Filter `json:"and"`
Or map[string]Filter `json:"or"`
And map[string][]Filter `json:"and"`
Or map[string][]Filter `json:"or"`
}
type Filter struct {

View File

@ -267,13 +267,17 @@ func (m *MongoDB) Search(filters *dbs.Filters, collection_name string) (*mongo.C
f := bson.D{}
if filters != nil {
for k, filter := range filters.Or {
orList = append(orList, dbs.StringToOperator(filter.Operator).ToMongoOperator(k, filter.Value))
for _, ff := range filter {
orList = append(orList, dbs.StringToOperator(ff.Operator).ToMongoOperator(k, ff.Value))
}
}
if len(orList) > 0 {
f = bson.D{{"$or", orList}}
}
for k, filter := range filters.And {
f = append(f, dbs.StringToOperator(filter.Operator).ToMongoEOperator(k, filter.Value))
for _, ff := range filter {
f = append(f, dbs.StringToOperator(ff.Operator).ToMongoEOperator(k, ff.Value))
}
}
}

View File

@ -58,8 +58,8 @@ func (wfa *ResourceModelMongoAccessor) Search(filters *dbs.Filters, search strin
objs := []utils.ShallowDBObject{}
if (filters == nil || len(filters.And) == 0 || len(filters.Or) == 0) && search != "" {
filters = &dbs.Filters{
Or: map[string]dbs.Filter{
"resource_type": {Operator: dbs.LIKE.String(), Value: search},
Or: map[string][]dbs.Filter{
"resource_type": []dbs.Filter{{Operator: dbs.LIKE.String(), Value: search}},
},
}
}

View File

@ -75,12 +75,12 @@ func (wfa *dataMongoAccessor) Search(filters *dbs.Filters, search string) ([]uti
objs := []utils.ShallowDBObject{}
if (filters == nil || len(filters.And) == 0 || len(filters.Or) == 0) && search != "" {
filters = &dbs.Filters{
Or: map[string]dbs.Filter{
"abstractresource.abstractobject.name": {Operator: dbs.LIKE.String(), Value: search},
"abstractresource.short_description": {Operator: dbs.LIKE.String(), Value: search},
"abstractresource.description": {Operator: dbs.LIKE.String(), Value: search},
"abstractresource.owner": {Operator: dbs.LIKE.String(), Value: search},
"abstractresource.source_url": {Operator: dbs.LIKE.String(), Value: search},
Or: map[string][]dbs.Filter{
"abstractresource.abstractobject.name": {{Operator: dbs.LIKE.String(), Value: search}},
"abstractresource.short_description": {{Operator: dbs.LIKE.String(), Value: search}},
"abstractresource.description": {{Operator: dbs.LIKE.String(), Value: search}},
"abstractresource.owner": {{Operator: dbs.LIKE.String(), Value: search}},
"abstractresource.source_url": {{Operator: dbs.LIKE.String(), Value: search}},
},
}
}

View File

@ -77,12 +77,12 @@ func (wfa *datacenterMongoAccessor) Search(filters *dbs.Filters, search string)
objs := []utils.ShallowDBObject{}
if (filters == nil || len(filters.And) == 0 || len(filters.Or) == 0) && search != "" {
filters = &dbs.Filters{
Or: map[string]dbs.Filter{
"abstractresource.abstractobject.name": {Operator: dbs.LIKE.String(), Value: search},
"abstractresource.short_description": {Operator: dbs.LIKE.String(), Value: search},
"abstractresource.description": {Operator: dbs.LIKE.String(), Value: search},
"abstractresource.owner": {Operator: dbs.LIKE.String(), Value: search},
"abstractresource.source_url": {Operator: dbs.LIKE.String(), Value: search},
Or: map[string][]dbs.Filter{
"abstractresource.abstractobject.name": {{Operator: dbs.LIKE.String(), Value: search}},
"abstractresource.short_description": {{Operator: dbs.LIKE.String(), Value: search}},
"abstractresource.description": {{Operator: dbs.LIKE.String(), Value: search}},
"abstractresource.owner": {{Operator: dbs.LIKE.String(), Value: search}},
"abstractresource.source_url": {{Operator: dbs.LIKE.String(), Value: search}},
},
}
}

View File

@ -78,12 +78,12 @@ func (wfa *processingMongoAccessor) Search(filters *dbs.Filters, search string)
objs := []utils.ShallowDBObject{}
if (filters == nil || len(filters.And) == 0 || len(filters.Or) == 0) && search != "" {
filters = &dbs.Filters{
Or: map[string]dbs.Filter{
"abstractresource.abstractobject.name": {Operator: dbs.LIKE.String(), Value: search},
"abstractresource.short_description": {Operator: dbs.LIKE.String(), Value: search},
"abstractresource.description": {Operator: dbs.LIKE.String(), Value: search},
"abstractresource.owner": {Operator: dbs.LIKE.String(), Value: search},
"abstractresource.source_url": {Operator: dbs.LIKE.String(), Value: search},
Or: map[string][]dbs.Filter{
"abstractresource.abstractobject.name": {{Operator: dbs.LIKE.String(), Value: search}},
"abstractresource.short_description": {{Operator: dbs.LIKE.String(), Value: search}},
"abstractresource.description": {{Operator: dbs.LIKE.String(), Value: search}},
"abstractresource.owner": {{Operator: dbs.LIKE.String(), Value: search}},
"abstractresource.source_url": {{Operator: dbs.LIKE.String(), Value: search}},
},
}
}

View File

@ -78,12 +78,12 @@ func (wfa *storageMongoAccessor) Search(filters *dbs.Filters, search string) ([]
objs := []utils.ShallowDBObject{}
if (filters == nil || len(filters.And) == 0 || len(filters.Or) == 0) && search != "" {
filters = &dbs.Filters{
Or: map[string]dbs.Filter{
"abstractresource.abstractobject.name": {Operator: dbs.LIKE.String(), Value: search},
"abstractresource.short_description": {Operator: dbs.LIKE.String(), Value: search},
"abstractresource.description": {Operator: dbs.LIKE.String(), Value: search},
"abstractresource.owner": {Operator: dbs.LIKE.String(), Value: search},
"abstractresource.source_url": {Operator: dbs.LIKE.String(), Value: search},
Or: map[string][]dbs.Filter{
"abstractresource.abstractobject.name": {{Operator: dbs.LIKE.String(), Value: search}},
"abstractresource.short_description": {{Operator: dbs.LIKE.String(), Value: search}},
"abstractresource.description": {{Operator: dbs.LIKE.String(), Value: search}},
"abstractresource.owner": {{Operator: dbs.LIKE.String(), Value: search}},
"abstractresource.source_url": {{Operator: dbs.LIKE.String(), Value: search}},
},
}
}

View File

@ -82,12 +82,12 @@ func (wfa *workflowResourceMongoAccessor) Search(filters *dbs.Filters, search st
objs := []utils.ShallowDBObject{}
if (filters == nil || len(filters.And) == 0 || len(filters.Or) == 0) && search != "" {
filters = &dbs.Filters{
Or: map[string]dbs.Filter{
"abstractresource.abstractobject.name": {Operator: dbs.LIKE.String(), Value: search},
"abstractresource.short_description": {Operator: dbs.LIKE.String(), Value: search},
"abstractresource.description": {Operator: dbs.LIKE.String(), Value: search},
"abstractresource.owner": {Operator: dbs.LIKE.String(), Value: search},
"abstractresource.source_url": {Operator: dbs.LIKE.String(), Value: search},
Or: map[string][]dbs.Filter{
"abstractresource.abstractobject.name": {{Operator: dbs.LIKE.String(), Value: search}},
"abstractresource.short_description": {{Operator: dbs.LIKE.String(), Value: search}},
"abstractresource.description": {{Operator: dbs.LIKE.String(), Value: search}},
"abstractresource.owner": {{Operator: dbs.LIKE.String(), Value: search}},
"abstractresource.source_url": {{Operator: dbs.LIKE.String(), Value: search}},
},
}
}

View File

@ -47,15 +47,15 @@ func (dma *AbstractAccessor) SetLogger(t DataType) {
func (wfa *AbstractAccessor) GenericStoreOne(data DBObject, accessor Accessor) (DBObject, int, error) {
data.GenerateID()
f := dbs.Filters{
Or: map[string]dbs.Filter{
"abstractresource.abstractobject.name": {
Or: map[string][]dbs.Filter{
"abstractresource.abstractobject.name": {{
Operator: dbs.LIKE.String(),
Value: data.GetName(),
},
"abstractobject.name": {
}},
"abstractobject.name": {{
Operator: dbs.LIKE.String(),
Value: data.GetName(),
},
}},
},
}
if cursor, _, _ := accessor.Search(&f, ""); len(cursor) > 0 {

View File

@ -101,8 +101,8 @@ func (wfa *workflowMongoAccessor) CopyOne(data utils.DBObject) (utils.DBObject,
func (wfa *workflowMongoAccessor) execute(workflow *Workflow) {
accessor := (&workspace.Workspace{}).GetAccessor()
filters := &dbs.Filters{
Or: map[string]dbs.Filter{
"abstractobject.name": {dbs.LIKE.String(), workflow.Name + "_workspace"},
Or: map[string][]dbs.Filter{
"abstractobject.name": {{dbs.LIKE.String(), workflow.Name + "_workspace"}},
},
}
resource, _, err := accessor.Search(filters, "")
@ -166,8 +166,8 @@ func (wfa *workflowMongoAccessor) Search(filters *dbs.Filters, search string) ([
objs := []utils.ShallowDBObject{}
if (filters == nil || len(filters.And) == 0 || len(filters.Or) == 0) && search != "" {
filters = &dbs.Filters{
Or: map[string]dbs.Filter{
"abstractobject.name": {Operator: dbs.LIKE.String(), Value: search},
Or: map[string][]dbs.Filter{
"abstractobject.name": {{Operator: dbs.LIKE.String(), Value: search}},
},
}
}

View File

@ -140,8 +140,8 @@ func (wfa *workspaceMongoAccessor) Search(filters *dbs.Filters, search string) (
objs := []utils.ShallowDBObject{}
if (filters == nil || len(filters.And) == 0 || len(filters.Or) == 0) && search != "" {
filters = &dbs.Filters{
Or: map[string]dbs.Filter{
"abstractobject.name": {Operator: dbs.LIKE.String(), Value: search},
Or: map[string][]dbs.Filter{
"abstractobject.name": {{Operator: dbs.LIKE.String(), Value: search}},
},
}
}