textualize/core/Document/ProcessedText.go
Yehoshua Sandler c49f8e4d07
refact: generalized back end structs (#1)
* refact: generalized back end structs

* refact: fixed front end type, removed dead code

* removed test image folder

* refact: removed dead structs
2023-05-26 19:23:35 -05:00

50 lines
1.2 KiB
Go

package document
import "textualize/entities"
type ProcessedAreaCollection struct {
Areas []entities.ProcessedArea
}
var processedAreaCollectionInstnace *ProcessedAreaCollection
func GetProcessedAreaCollection() *ProcessedAreaCollection {
if processedAreaCollectionInstnace == nil {
processedAreaCollectionInstnace = &ProcessedAreaCollection{}
}
return processedAreaCollectionInstnace
}
func SetProcessedAreaCollection(collection ProcessedAreaCollection) {
processedAreaCollectionInstnace = &collection
}
func (collection *ProcessedAreaCollection) AddProcessedArea(area entities.ProcessedArea) {
collection.Areas = append(collection.Areas, area)
}
func (collection *ProcessedAreaCollection) GetAreasByDocumentId(id string) []*entities.ProcessedArea {
var foundAreas []*entities.ProcessedArea
for index, a := range collection.Areas {
if a.DocumentId == id {
foundAreas = append(foundAreas, &collection.Areas[index])
}
}
return foundAreas
}
func (collection *ProcessedAreaCollection) GetAreaById(areaId string) *entities.ProcessedArea {
var foundArea *entities.ProcessedArea
for index, a := range collection.Areas {
if a.Id == areaId {
foundArea = &collection.Areas[index]
break
}
}
return foundArea
}