Skip to content

Commit bd10260

Browse files
committed
remove additionsl pathslice attribute, calculate it from sdcpb.path
1 parent 4385616 commit bd10260

File tree

2 files changed

+5
-40
lines changed

2 files changed

+5
-40
lines changed

pkg/tree/sharedEntryAttributes.go

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -609,41 +609,6 @@ func (s *sharedEntryAttributes) remainsToExist() bool {
609609
// getRegularDeletes performs deletion calculation on elements that have a schema attached.
610610
func (s *sharedEntryAttributes) getRegularDeletes(deletes []types.DeleteEntry, aggregate bool) ([]types.DeleteEntry, error) {
611611
var err error
612-
// if entry is a container type, check the keys, to be able to
613-
// issue a delte for the whole branch at once via keys
614-
// switch s.schema.GetSchema().(type) {
615-
// case *sdcpb.SchemaElem_Container:
616-
// // deletes for child elements (choice cases) that newly became inactive.
617-
// for _, v := range s.choicesResolvers {
618-
// // oldBestCaseName := v.getOldBestCaseName()
619-
// // newBestCaseName := v.getBestCaseName()
620-
// // // so if we have an old and a new best cases (not "") and the names are different,
621-
// // // all the old to the deletion list
622-
// // if oldBestCaseName != "" && newBestCaseName != "" && oldBestCaseName != newBestCaseName {
623-
// // // try fetching the case from the childs
624-
// // oldBestCaseEntry, exists := s.childs.GetEntry(oldBestCaseName)
625-
// // if exists {
626-
// // deletes = append(deletes, oldBestCaseEntry)
627-
// // } else {
628-
// // // it might be that the child is not loaded into the tree, but just considered from the treecontext cache for the choice/case resolution
629-
// // // if so, we create and return the DeleteEntryImpl struct
630-
// // path, err := s.SdcpbPath()
631-
// // if err != nil {
632-
// // return nil, err
633-
// // }
634-
// // deletes = append(deletes, types.NewDeleteEntryImpl(path, append(s.Path(), oldBestCaseName)))
635-
// // }
636-
// // }
637-
// path, err := s.SdcpbPath()
638-
// if err != nil {
639-
// return nil, err
640-
// }
641-
// deleteElements := v.GetDeletes()
642-
// for _, de := range deleteElements {
643-
// deletes = append(deletes, types.NewDeleteEntryImpl(path, append(s.Path(), de)))
644-
// }
645-
// }
646-
// }
647612

648613
if s.shouldDelete() && !s.IsRoot() && len(s.GetSchemaKeys()) == 0 {
649614
return append(deletes, s), nil
@@ -654,7 +619,8 @@ func (s *sharedEntryAttributes) getRegularDeletes(deletes []types.DeleteEntry, a
654619
if err != nil {
655620
return nil, err
656621
}
657-
deletes = append(deletes, types.NewDeleteEntryImpl(path, append(s.Path(), elem)))
622+
path.Elem = append(path.Elem, &sdcpb.PathElem{Name: elem})
623+
deletes = append(deletes, types.NewDeleteEntryImpl(path))
658624
}
659625

660626
for _, e := range s.childs.GetAll() {

pkg/tree/types/delete_entry.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package types
22

33
import (
4+
"github.com/sdcio/data-server/pkg/utils"
45
sdcpb "github.com/sdcio/sdc-protos/sdcpb"
56
)
67

@@ -12,21 +13,19 @@ type DeleteEntry interface {
1213
// DeleteEntryImpl is a crutch to flag oldbestcases if on a choice, the active case changed
1314
type DeleteEntryImpl struct {
1415
sdcpbPath *sdcpb.Path
15-
pathslice PathSlice
1616
}
1717

18-
func NewDeleteEntryImpl(sdcpbPath *sdcpb.Path, pathslice PathSlice) *DeleteEntryImpl {
18+
func NewDeleteEntryImpl(sdcpbPath *sdcpb.Path) *DeleteEntryImpl {
1919
return &DeleteEntryImpl{
2020
sdcpbPath: sdcpbPath,
21-
pathslice: pathslice,
2221
}
2322
}
2423

2524
func (d *DeleteEntryImpl) SdcpbPath() (*sdcpb.Path, error) {
2625
return d.sdcpbPath, nil
2726
}
2827
func (d *DeleteEntryImpl) Path() PathSlice {
29-
return d.pathslice
28+
return utils.ToStrings(d.sdcpbPath, false, false)
3029
}
3130

3231
type DeleteEntriesList []DeleteEntry

0 commit comments

Comments
 (0)