From 67b714b37149795d10290cfb7a024711b6596884 Mon Sep 17 00:00:00 2001 From: nikopol Date: Thu, 15 Oct 2020 08:41:19 +0300 Subject: [PATCH] Fix access for GetIndexById method --- data/dummies.json | 2 +- data/dummies_map.json | 2 +- data/dummies_ref.json | 2 +- persistence/IdentifiableMemoryPersistence.go | 10 +++++----- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/data/dummies.json b/data/dummies.json index 3ab08e3..7ce9528 100644 --- a/data/dummies.json +++ b/data/dummies.json @@ -1 +1 @@ -[{"id":"2a54e89e0ffd4bd997342a8c65e6b51d","key":"Key 2","content":"Content 2"}] \ No newline at end of file +[{"id":"ac75860734b24807bb233ce3a8415bb9","key":"Key 2","content":"Content 2"}] \ No newline at end of file diff --git a/data/dummies_map.json b/data/dummies_map.json index 257d55f..03a596d 100644 --- a/data/dummies_map.json +++ b/data/dummies_map.json @@ -1 +1 @@ -[{"Content":"Content 2","Id":"d6ff41c6d2634829872165894f55ea99","Key":"Key 2"}] \ No newline at end of file +[{"Content":"Content 2","Id":"12084d944f63450ab8cf508bc3efe1e6","Key":"Key 2"}] \ No newline at end of file diff --git a/data/dummies_ref.json b/data/dummies_ref.json index f6a0a57..4f47d82 100644 --- a/data/dummies_ref.json +++ b/data/dummies_ref.json @@ -1 +1 @@ -[{"id":"6e936dbe3bc04494955f05e2f7d70234","key":"Key 2","content":"Content 2"}] \ No newline at end of file +[{"id":"ba8503c7dab64695b9e4fcadae0c2804","key":"Key 2","content":"Content 2"}] \ No newline at end of file diff --git a/persistence/IdentifiableMemoryPersistence.go b/persistence/IdentifiableMemoryPersistence.go index fe7d87f..0836f30 100644 --- a/persistence/IdentifiableMemoryPersistence.go +++ b/persistence/IdentifiableMemoryPersistence.go @@ -160,7 +160,7 @@ func (c *IdentifiableMemoryPersistence) GetOneById(correlationId string, id inte // Get index by "Id" field // return index number -func (c *IdentifiableMemoryPersistence) getIndexById(id interface{}) int { +func (c *IdentifiableMemoryPersistence) GetIndexById(id interface{}) int { var index int = -1 for i, v := range c.Items { vId := GetObjectId(v) @@ -213,7 +213,7 @@ func (c *IdentifiableMemoryPersistence) Set(correlationId string, item interface GenerateObjectId(&newItem) id := GetObjectId(item) - index := c.getIndexById(id) + index := c.GetIndexById(id) if index < 0 { c.Items = append(c.Items, newItem) } else { @@ -241,7 +241,7 @@ func (c *IdentifiableMemoryPersistence) Update(correlationId string, item interf c.Lock.Lock() id := GetObjectId(item) - index := c.getIndexById(id) + index := c.GetIndexById(id) if index < 0 { c.Logger.Trace(correlationId, "Item %s was not found", id) return nil, nil @@ -271,7 +271,7 @@ func (c *IdentifiableMemoryPersistence) Update(correlationId string, item interf func (c *IdentifiableMemoryPersistence) UpdatePartially(correlationId string, id interface{}, data *cdata.AnyValueMap) (result interface{}, err error) { c.Lock.Lock() - index := c.getIndexById(id) + index := c.GetIndexById(id) if index < 0 { c.Logger.Trace(correlationId, "Item %s was not found", id) return nil, nil @@ -311,7 +311,7 @@ func (c *IdentifiableMemoryPersistence) UpdatePartially(correlationId string, id func (c *IdentifiableMemoryPersistence) DeleteById(correlationId string, id interface{}) (result interface{}, err error) { c.Lock.Lock() - index := c.getIndexById(id) + index := c.GetIndexById(id) if index < 0 { c.Logger.Trace(correlationId, "Item %s was not found", id) return nil, nil