Skip to content

Добавление новых объектов: Подписка на события и планы обмена #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@

# Dependency directories (remove the comment below to include it)
# vendor/
testdata/.metadata/
.idea/
1 change: 1 addition & 0 deletions .idea/mdclasses.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions EventSubscription.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package mdclasses

import "github.com/v8platform/mdclasses/encoding/xml"

type Source struct {
Types []string `xml:"types"`
}

type EventSubscription struct {
MDOBaseType
XMLName xml.Name `xml:"EventSubscription"`
Mdclass string `xml:"mdclass,attr"`
Uuid string `xml:"uuid,attr"`
Name string `xml:"name"`
Synonym ObjectKeyValueType `xml:"synonym"`
Source Source `xml:"source"`
Event string `xml:"event"`
Handler string `xml:"handler"`
}
38 changes: 38 additions & 0 deletions ExchangePlan.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package mdclasses

import "github.com/v8platform/mdclasses/encoding/xml"

type Content []struct {
MdObject string `xml:"mdObject"`
}

type ExchangePlan struct {
MDOBaseType
XMLName xml.Name `xml:"ExchangePlan"`
Xsi string `xml:"xsi,attr"`
Core string `xml:"core,attr"`
Mdclass string `xml:"mdclass,attr"`
Uuid string `xml:"uuid,attr"`
ThisNode string `xml:"thisNode,attr"`
ProducedTypes MDOProducedTypes `xml:"producedTypes"`
Name string `xml:"name"`
Synonym ObjectKeyValueType `xml:"synonym"`
UseStandardCommands string `xml:"useStandardCommands"`
InputByString []string `xml:"inputByString"`
FullTextSearchOnInputByString string `xml:"fullTextSearchOnInputByString"`
StandardAttributes []StandardAttribute `xml:"standardAttributes"`
CreateOnInput string `xml:"createOnInput"`
DataLockFields string `xml:"dataLockFields"`
DataLockControlMode string `xml:"dataLockControlMode"`
FullTextSearch string `xml:"fullTextSearch"`
ObjectPresentation ObjectKeyValueType `xml:"objectPresentation"`
ListPresentation ObjectKeyValueType `xml:"listPresentation"`
CodeLength string `xml:"codeLength"`
CodeAllowedLength string `xml:"codeAllowedLength"`
DescriptionLength string `xml:"descriptionLength"`
Content Content `xml:"content"`
DefaultPresentation string `xml:"defaultPresentation"`
EditType string `xml:"editType"`
ChoiceMode string `xml:"choiceMode"`
Attributes []Attribute `xml:"attributes"`
}
12 changes: 12 additions & 0 deletions commonTestMethods.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package mdclasses

import "testing"

func unpackTestConf(t *testing.T) Configuration {
got, err := UnpackConfiguration("tests/metadata/ssl/src")
if err != nil {
t.Errorf("UnpackConfiguration() error = %v", err)
return Configuration{}
}
return got
}
111 changes: 104 additions & 7 deletions configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ type Language struct {
type Configuration struct {
MDOBaseType

XMLName xml.Name `xml:"mdclass Configuration"`
XMLName xml.Name `xml:"mdclass Configuration"`
Synonym []ObjectKeyValueType `xml:"synonym"`
ContainedObjects []ContainedObject `xml:"containedObjects,allowempty"`
ContainedObjects []ContainedObject `xml:"containedObjects,allowempty"`
ConfigurationProperties

Languages []*Language `xml:"languages"`
Expand All @@ -45,12 +45,12 @@ type Configuration struct {
// FilterCriteria []MDOTypeRef `xml:"filterCriteria"`
CommonModules []*CommonModule `xml:"-"`
// CommonAttributes []MDOTypeRef `xml:"commonAttributes"`
// ExchangePlans []MDOTypeRef `xml:"exchangePlans"`
ExchangePlans []*ExchangePlan `xml:"-"`
// XDTOPackages []MDOTypeRef `xml:"xDTOPackages"`
// WebServices []MDOTypeRef `xml:"webServices"`
// HttpServices []MDOTypeRef `xml:"httpServices"`
// WsReferences []MDOTypeRef `xml:"wsReferences"`
// EventSubscriptions []MDOTypeRef `xml:"eventSubscriptions"`
EventSubscriptions []*EventSubscription `xml:"-"`
// ScheduledJobs []MDOTypeRef `xml:"scheduledJobs"`
// SettingsStorages []MDOTypeRef `xml:"settingsStorages"`
// FunctionalOptions []MDOTypeRef `xml:"functionalOptions"`
Expand Down Expand Up @@ -167,9 +167,6 @@ type ConfigurationChildObjects struct {
CalculationRegisters MDOTypeRefList `xml:"calculationRegisters"`
BusinessProcesses MDOTypeRefList `xml:"businessProcesses"`
Tasks MDOTypeRefList `xml:"tasks"`
WebService MDOTypeRefList `xml:"serviceService"`
WSReference MDOTypeRefList `xml:"wsReferenceReference"`
XDTOPackage MDOTypeRefList `xml:"xdtoPackage"`
}

const ConfigurationFile = "Configuration.mdo"
Expand Down Expand Up @@ -219,6 +216,16 @@ func (conf *Configuration) Unpack(cfg UnpackConfig) error {
return err
}

err = conf.ConfigurationChildObjects.ExchangePlans.Unpack(cfg, &conf.ExchangePlans)
if err != nil {
return err
}

err = conf.ConfigurationChildObjects.EventSubscriptions.Unpack(cfg, &conf.EventSubscriptions)
if err != nil {
return err
}

// for _, mdoTypeRef := range conf.ConfigurationChildObjects.Subsystems {
//
// subsystem := Subsystem{}
Expand Down Expand Up @@ -248,3 +255,93 @@ func (conf *Configuration) Unpack(cfg UnpackConfig) error {

return nil
}

// Возвращает раздел не распаковоанных объектов метаданных по имени типа
func (o ConfigurationChildObjects) GetChildByType(mdoType MDOType) *MDOTypeRefList {
switch mdoType {
case SUBSYSTEM:
return &o.Subsystems
case STYLE_ITEM:
return &o.StyleItems
case STYLE:
return &o.Styles
case COMMON_PICTURE:
return &o.CommonPictures
case SESSION_PARAMETER:
return &o.SessionParameters
case ROLE:
return &o.Roles
case COMMON_TEMPLATE:
return &o.CommonTemplates
case FILTER_CRITERION:
return &o.FilterCriteria
case COMMON_MODULE:
return &o.CommonModules
case COMMON_ATTRIBUTE:
return &o.CommonAttributes
case EXCHANGE_PLAN:
return &o.ExchangePlans
case XDTO_PACKAGE:
return &o.XDTOPackages
case WEB_SERVICE:
return &o.WebServices
case HTTP_SERVICE:
return &o.HttpServices
case WS_REFERENCE:
return &o.WsReferences
case EVENT_SUBSCRIPTION:
return &o.EventSubscriptions
case SCHEDULED_JOB:
return &o.ScheduledJobs
case SETTINGS_STORAGE:
return &o.SettingsStorages
case FUNCTIONAL_OPTION:
return &o.FunctionalOptions
case FUNCTIONAL_OPTIONS_PARAMETER:
return &o.FunctionalOptionsParameters
case DEFINED_TYPE:
return &o.DefinedTypes
case COMMON_COMMAND:
return &o.CommonCommands
case COMMAND_GROUP:
return &o.CommandGroups
case CONSTANT:
return &o.Constants
case COMMON_FORM:
return &o.CommonForms
case CATALOG:
return &o.Catalogs
case DOCUMENT:
return &o.Documents
case DOCUMENT_NUMERATOR:
return &o.DocumentNumerators
case SEQUENCE:
return &o.Sequences
case DOCUMENT_JOURNAL:
return &o.DocumentJournals
case ENUM:
return &o.Enums
case REPORT:
return &o.Reports
case DATA_PROCESSOR:
return &o.DataProcessors
case INFORMATION_REGISTER:
return &o.InformationRegisters
case ACCOUNTING_REGISTER:
return &o.AccountingRegisters
case ACCUMULATION_REGISTER:
return &o.AccumulationRegisters
case CHART_OF_CALCULATION_TYPES:
return &o.ChartsOfCalculationTypes
case CHART_OF_CHARACTERISTIC_TYPES:
return &o.ChartsOfCharacteristicTypes
case CALCULATION_REGISTER:
return &o.CalculationRegisters
case BUSINESS_PROCESS:
return &o.BusinessProcesses
case TASK:
return &o.Tasks
}
log.Warnf("Не найден раздел методанных %s", mdoType)
return nil
}
13 changes: 13 additions & 0 deletions configuration_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package mdclasses

import (
"github.com/stretchr/testify/require"
"testing"
)

func TestGetChildByTypeName(t *testing.T) {
got := unpackTestConf(t)
children := got.ConfigurationChildObjects
exchangePlan := children.GetChildByType(EVENT_SUBSCRIPTION)
require.True(t, exchangePlan != nil)
}
2 changes: 1 addition & 1 deletion mdclasses_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func TestUnpackConfiguration(t *testing.T) {
}
}

func Test(t *testing.T) {
func TestCompareFile(t *testing.T) {
tests := []struct {
name string
dir string
Expand Down
Loading