Class: Mxrb::Model::Module
- Inherits:
-
Unit
- Object
- Unit
- Mxrb::Model::Module
show all
- Defined in:
- lib/mxrb/model/module.rb
Overview
$Type: Projects$Module
ContainmentName: "Modules"
Constant Summary
collapse
- INFRASTRUCTURE_DOCUMENT_ROUTES =
{
'ExportMappings$ExportMapping' => 'mappings/exports',
'ImportMappings$ImportMapping' => 'mappings/imports',
'JsonStructures$JsonStructure' => 'mappings/json_structures',
'MessageDefinitions$MessageDefinitionCollection' => 'mappings/message_definitions',
'MessageDefinitions$MessageDefinition2' => 'mappings/message_definitions',
'XmlSchemas$XmlSchema' => 'mappings/xml_schemas',
'Rest$PublishedRestService' => 'endpoints',
'WebServices$PublishedService' => 'endpoints',
'WebServices$PublishedWebService' => 'endpoints',
'ODataPublish$PublishedODataService' => 'endpoints',
'ODataPublish$PublishedODataService2' => 'endpoints',
'Rest$ConsumedRestService' => 'integrations',
'Rest$ConsumedODataService' => 'integrations',
'AppServices$ConsumedAppService' => 'integrations',
'ODataImport$ConsumedODataService' => 'integrations'
}.freeze
- MAPPING_DOCUMENT_TYPES =
INFRASTRUCTURE_DOCUMENT_ROUTES.keys.grep(
/Mappings|JsonStructures|MessageDefinitions|XmlSchemas/
).freeze
- APPLICATION_DOCUMENT_ROUTES =
{
'DataSets$DataSet' => 'queries/datasets',
'ScheduledEvents$ScheduledEvent' => 'jobs/scheduled_events'
}.freeze
- DOMAIN_DOCUMENT_ROUTES =
{
'DomainModels$ViewEntitySourceDocument' => 'oql_views',
'Enumerations$Enumeration' => 'enumerations',
'Constants$Constant' => 'constants'
}.freeze
- EDITABLE_DOCUMENT_TYPES =
(
INFRASTRUCTURE_DOCUMENT_ROUTES.keys + APPLICATION_DOCUMENT_ROUTES.keys +
DOMAIN_DOCUMENT_ROUTES.keys
).freeze
Instance Attribute Summary collapse
Attributes inherited from Unit
#bson_type, #container_id, #containment_name, #id, #mpr
Instance Method Summary
collapse
Methods inherited from Unit
#initialize, #save!
Instance Attribute Details
#app_store_guid ⇒ Object
Returns the value of attribute app_store_guid.
44
45
46
|
# File 'lib/mxrb/model/module.rb', line 44
def app_store_guid
@app_store_guid
end
|
#app_store_version ⇒ Object
Returns the value of attribute app_store_version.
44
45
46
|
# File 'lib/mxrb/model/module.rb', line 44
def app_store_version
@app_store_version
end
|
#export_level ⇒ Object
Returns the value of attribute export_level.
44
45
46
|
# File 'lib/mxrb/model/module.rb', line 44
def export_level
@export_level
end
|
#from_app_store ⇒ Object
Returns the value of attribute from_app_store.
44
45
46
|
# File 'lib/mxrb/model/module.rb', line 44
def from_app_store
@from_app_store
end
|
#name ⇒ Object
Returns the value of attribute name.
44
45
46
|
# File 'lib/mxrb/model/module.rb', line 44
def name
@name
end
|
#sort_index ⇒ Object
Returns the value of attribute sort_index.
44
45
46
|
# File 'lib/mxrb/model/module.rb', line 44
def sort_index
@sort_index
end
|
Instance Method Details
#application_documents ⇒ Object
129
130
131
|
# File 'lib/mxrb/model/module.rb', line 129
def application_documents
@application_documents ||= routed_documents(APPLICATION_DOCUMENT_ROUTES)
end
|
#associations ⇒ Object
77
|
# File 'lib/mxrb/model/module.rb', line 77
def associations = domain_model&.associations || []
|
#constants ⇒ Object
109
110
111
112
113
|
# File 'lib/mxrb/model/module.rb', line 109
def constants
@constants ||= document_units
.select { |u| u[:type] == "Constants$Constant" }
.map { unit_to_doc(_1) }
end
|
#decode(doc) ⇒ Object
47
48
49
50
51
52
53
54
|
# File 'lib/mxrb/model/module.rb', line 47
def decode(doc)
@name = doc["Name"]
@sort_index = doc["SortIndex"] || doc["NewSortIndex"]
@from_app_store = doc["FromAppStore"] == true
@app_store_guid = doc["AppStoreGuid"]
@app_store_version = doc["AppStoreVersion"]
@export_level = doc["ExportLevel"] || "Hidden"
end
|
#domain_documents ⇒ Object
133
134
135
|
# File 'lib/mxrb/model/module.rb', line 133
def domain_documents
@domain_documents ||= routed_documents(DOMAIN_DOCUMENT_ROUTES)
end
|
#domain_model ⇒ Object
── Children (resolved from Unit table by ContainerID) ────────────
69
70
71
72
73
74
|
# File 'lib/mxrb/model/module.rb', line 69
def domain_model
@domain_model ||= begin
raws = @mpr.units_by_containment("DomainModel").select { _1["ContainerID"] == @id }
raws.empty? ? nil : DomainModel.new(raws.first, @mpr)
end
end
|
#entities ⇒ Object
76
|
# File 'lib/mxrb/model/module.rb', line 76
def entities = domain_model&.entities || []
|
#enumerations ⇒ Object
103
104
105
106
107
|
# File 'lib/mxrb/model/module.rb', line 103
def enumerations
@enumerations ||= document_units
.select { |u| u[:type] == "Enumerations$Enumeration" }
.map { unit_to_doc(_1) }
end
|
#infrastructure_documents ⇒ Object
125
126
127
|
# File 'lib/mxrb/model/module.rb', line 125
def infrastructure_documents
@infrastructure_documents ||= routed_documents(INFRASTRUCTURE_DOCUMENT_ROUTES)
end
|
#inspect ⇒ Object
157
158
159
160
|
# File 'lib/mxrb/model/module.rb', line 157
def inspect
"#<Mxrb::Module name=#{@name.inspect} entities=#{entities.size} " \
"pages=#{pages.size} microflows=#{microflows.size}>"
end
|
#mapping_documents ⇒ Object
121
122
123
|
# File 'lib/mxrb/model/module.rb', line 121
def mapping_documents
infrastructure_documents.select { MAPPING_DOCUMENT_TYPES.include?(_1[:type]) }
end
|
97
98
99
100
101
|
# File 'lib/mxrb/model/module.rb', line 97
def
@menus ||= document_units
.select { |u| u[:type] == "Menus$MenuDocument" }
.map { Menu.new(_1[:raw], @mpr) }
end
|
#microflows ⇒ Object
85
86
87
88
89
|
# File 'lib/mxrb/model/module.rb', line 85
def microflows
@microflows ||= document_units
.select { |u| u[:type] == "Microflows$Microflow" }
.map { Microflow.new(_1[:raw], @mpr) }
end
|
#module_roles ⇒ Object
143
144
145
146
147
148
149
150
151
152
153
154
155
|
# File 'lib/mxrb/model/module.rb', line 143
def module_roles
@module_roles ||= begin
raw = @mpr.children_of(@id).find { _1["ContainmentName"] == "ModuleSecurity" }
if raw
doc = @mpr.parse_contents(raw)
parse_array(doc["ModuleRoles"]).map do |role|
{ name: role["Name"], description: role["Description"].to_s }
end
else
[]
end
end
end
|
#nanoflows ⇒ Object
91
92
93
94
95
|
# File 'lib/mxrb/model/module.rb', line 91
def nanoflows
@nanoflows ||= document_units
.select { |u| u[:type] == "Microflows$Nanoflow" }
.map { Microflow.new(_1[:raw], @mpr) }
end
|
#oql_view_documents ⇒ Object
137
138
139
140
141
|
# File 'lib/mxrb/model/module.rb', line 137
def oql_view_documents
@oql_view_documents ||= domain_documents.select do |document|
document[:type] == 'DomainModels$ViewEntitySourceDocument'
end
end
|
#pages ⇒ Object
79
80
81
82
83
|
# File 'lib/mxrb/model/module.rb', line 79
def pages
@pages ||= document_units
.select { |u| %w[Pages$Page Forms$Page].include?(u[:type]) }
.map { Page.new(_1[:raw], @mpr) }
end
|
#scheduled_events ⇒ Object
115
116
117
118
119
|
# File 'lib/mxrb/model/module.rb', line 115
def scheduled_events
@scheduled_events ||= document_units
.select { |u| u[:type] == "ScheduledEvents$ScheduledEvent" }
.map { unit_to_doc(_1) }
end
|
#to_bson ⇒ Object
56
57
58
59
60
61
62
63
64
65
|
# File 'lib/mxrb/model/module.rb', line 56
def to_bson
{
"$ID" => @id,
"$Type" => "Projects$Module",
"Name" => @name,
"SortIndex" => @sort_index || 0,
"FromAppStore" => @from_app_store || false,
"ExportLevel" => @export_level || "Hidden",
}
end
|