2020-05-11 10:16:29 +00:00
|
|
|
package view
|
|
|
|
|
|
|
|
import (
|
|
|
|
proj_model "github.com/caos/zitadel/internal/project/model"
|
|
|
|
"github.com/caos/zitadel/internal/project/repository/view"
|
|
|
|
"github.com/caos/zitadel/internal/project/repository/view/model"
|
2020-06-25 06:01:13 +00:00
|
|
|
"github.com/caos/zitadel/internal/view/repository"
|
2020-05-11 10:16:29 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
applicationTable = "management.applications"
|
|
|
|
)
|
|
|
|
|
2020-08-13 06:28:18 +00:00
|
|
|
func (v *View) ApplicationByID(projectID, appID string) (*model.ApplicationView, error) {
|
|
|
|
return view.ApplicationByID(v.Db, applicationTable, projectID, appID)
|
2020-05-11 10:16:29 +00:00
|
|
|
}
|
|
|
|
|
2020-10-16 05:49:38 +00:00
|
|
|
func (v *View) ApplicationsByProjectID(projectID string) ([]*model.ApplicationView, error) {
|
|
|
|
return view.ApplicationsByProjectID(v.Db, applicationTable, projectID)
|
2020-08-05 16:32:25 +00:00
|
|
|
}
|
|
|
|
|
2020-07-30 12:37:55 +00:00
|
|
|
func (v *View) SearchApplications(request *proj_model.ApplicationSearchRequest) ([]*model.ApplicationView, uint64, error) {
|
2020-05-11 10:16:29 +00:00
|
|
|
return view.SearchApplications(v.Db, applicationTable, request)
|
|
|
|
}
|
|
|
|
|
2020-10-16 05:49:38 +00:00
|
|
|
func (v *View) PutApplication(app *model.ApplicationView) error {
|
|
|
|
err := view.PutApplication(v.Db, applicationTable, app)
|
2020-05-11 10:16:29 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2020-10-16 05:49:38 +00:00
|
|
|
return v.ProcessedApplicationSequence(app.Sequence)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (v *View) PutApplications(apps []*model.ApplicationView, sequence uint64) error {
|
|
|
|
err := view.PutApplications(v.Db, applicationTable, apps...)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return v.ProcessedApplicationSequence(sequence)
|
2020-05-11 10:16:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (v *View) DeleteApplication(appID string, eventSequence uint64) error {
|
|
|
|
err := view.DeleteApplication(v.Db, applicationTable, appID)
|
|
|
|
if err != nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return v.ProcessedApplicationSequence(eventSequence)
|
|
|
|
}
|
|
|
|
|
2020-10-16 05:49:38 +00:00
|
|
|
func (v *View) DeleteApplicationsByProjectID(projectID string) error {
|
|
|
|
return view.DeleteApplicationsByProjectID(v.Db, applicationTable, projectID)
|
2020-08-05 16:32:25 +00:00
|
|
|
}
|
|
|
|
|
2020-07-15 11:24:36 +00:00
|
|
|
func (v *View) GetLatestApplicationSequence() (*repository.CurrentSequence, error) {
|
2020-05-11 10:16:29 +00:00
|
|
|
return v.latestSequence(applicationTable)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (v *View) ProcessedApplicationSequence(eventSequence uint64) error {
|
|
|
|
return v.saveCurrentSequence(applicationTable, eventSequence)
|
|
|
|
}
|
|
|
|
|
2020-06-25 06:01:13 +00:00
|
|
|
func (v *View) GetLatestApplicationFailedEvent(sequence uint64) (*repository.FailedEvent, error) {
|
2020-05-11 10:16:29 +00:00
|
|
|
return v.latestFailedEvent(applicationTable, sequence)
|
|
|
|
}
|
|
|
|
|
2020-06-25 06:01:13 +00:00
|
|
|
func (v *View) ProcessedApplicationFailedEvent(failedEvent *repository.FailedEvent) error {
|
2020-05-11 10:16:29 +00:00
|
|
|
return v.saveFailedEvent(failedEvent)
|
|
|
|
}
|