Skip to content

Commit

Permalink
Merge pull request #914 from opengisch/smart1optization
Browse files Browse the repository at this point in the history
Smart 1 project optimization
  • Loading branch information
signedav authored Jun 6, 2024
2 parents 80b45bd + 3cf8dbb commit 264c632
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 11 deletions.
61 changes: 53 additions & 8 deletions QgisModelBaker/gui/workflow_wizard/project_creation_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,7 @@ def __init__(self, parent, title):
self.existing_projecttopping_id = None
self.projecttopping_id = None

self.optimize_combo.clear()
self.optimize_combo.addItem(
self.tr("Hide unused base class layers"), OptimizeStrategy.HIDE
)
self.optimize_combo.addItem(
self.tr("Group unused base class layers"), OptimizeStrategy.GROUP
)
self.optimize_combo.addItem(self.tr("No optimization"), OptimizeStrategy.NONE)
self._update_optimize_combo()

self.create_project_button.clicked.connect(self._create_project)
self.is_complete = False
Expand Down Expand Up @@ -121,6 +114,10 @@ def restore_configuration(self, configuration):
self.configuration = configuration
self.db_connector = db_utils.get_db_connector(self.configuration)

# get inheritance
self.configuration.inheritance = self._inheritance()
self._update_optimize_combo()

# get existing topping
self.existing_topping_checkbox.setVisible(False)
self.existing_projecttopping_id = self._existing_projecttopping_id()
Expand All @@ -130,6 +127,7 @@ def restore_configuration(self, configuration):
self.existing_topping_checkbox.setChecked(True)
else:
self._use_existing(False)

self.workflow_wizard.busy(self, False)

def _use_existing(self, state):
Expand Down Expand Up @@ -195,6 +193,47 @@ def _enable_optimize_combo(self, state):
self.optimize_combo.setEnabled(state)
self.optimize_label.setEnabled(state)

def _update_optimize_combo(self):
index = self.optimize_combo.currentIndex()
self.optimize_combo.clear()
if self.configuration and self.configuration.inheritance == "smart2":
self.optimize_combo.addItem(
self.tr("Hide unused base class layers"), OptimizeStrategy.HIDE
)
self.optimize_combo.addItem(
self.tr("Group unused base class layers"), OptimizeStrategy.GROUP
)
self.optimize_combo.setToolTip(
self.tr(
"""
<html><head/><body>
<p><b>Hide unused base class layers:</b></p>
<p>- Base class layers with same named extensions will be <i>hidden</i> and and base class layers with multiple extensions as well. Except if the extension is in the same model, then it's will <i>not</i> be <i>hidden</i> but <i>renamed</i>.</p>
<p>- Relations of hidden layers will <i>not</i> be <i>created</i> and with them <i>no</i> widgets<br/></p>
<p><b>Group unused base class layers:</b></p>
<p>- Base class layers with same named extensions will be <i>collected in a group</i> and base class layers with multiple extensions as well. Except if the extension is in the same model, then it will <i>not</i> be <i>grouped</i> but <i>renamed</i>.</p>
<p>- Relations of grouped layers will be <i>created</i> but the widgets <i>not applied</i> to the form.</p>
</body></html>
"""
)
)
else:
self.optimize_combo.addItem(
self.tr("Hide unused base class types"), OptimizeStrategy.HIDE
)
self.optimize_combo.setToolTip(
self.tr(
"""
<html><head/><body>
<p><b>Hide unused base class types:</b></p>
<p>- Base class tables with same named extensions will be <i>hidden</i> in the <code>t_type</code> dropdown and and base class tables with multiple extensions as well. Except if the extension is in the same model, then it will <i>not</i> be <i>hidden</i>.</p>
</body></html>
"""
)
)
self.optimize_combo.addItem(self.tr("No optimization"), OptimizeStrategy.NONE)
self.optimize_combo.setCurrentIndex(index)

def _complete_completer(self):
if self.topping_line_edit.hasFocus() and self.topping_line_edit.completer():
if not self.topping_line_edit.text():
Expand Down Expand Up @@ -669,3 +708,9 @@ def _modelnames(self):
):
modelnames.append(name)
return modelnames

def _inheritance(self):
setting_records = self.db_connector.get_ili2db_settings()
for setting_record in setting_records:
if setting_record["tag"] == "ch.ehi.ili2db.inheritanceTrafo":
return setting_record["setting"]
8 changes: 6 additions & 2 deletions docs/docs/background_info/extended_models_optimization.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
If a model or topic contains extended classes, the inclusive base classes are implemented in the physical database. The users only want to see, what is relevant for them and mostly work on the most extended instance of the topics/classes. Model Baker detects the ***irrelevant*** tables and offers optimization strategies to the users on ***smart1intehritance*** implementations.
If a model or topic contains extended classes, the inclusive base classes are implemented in the physical database. The users only want to see, what is relevant for them and mostly work on the most extended instance of the topics/classes. Model Baker detects the ***irrelevant*** tables and offers optimization strategies.

In the [workflow wizard](../../user_guide/import_workflow/#optimize-qgis-project-if-extended) you can choose the optimization [strategy](../../background_info/extended_models_optimization/#strategies) and receive a nicely prepared layertree and forms.

Expand Down Expand Up @@ -36,7 +36,7 @@ What to do then? Well, you have always the option for the [NONE-strategy](../../

## Strategies

Let's check out the following examle model and it's implementation according to the strategies.
Let's check out the following example model and it's implementation according to the strategies on a database created with ***smart2intehritance***.

### Ortsplanung Example

Expand All @@ -57,6 +57,9 @@ Base class layers with extensions of the same name are **_hidden_** and base cla

Relations of hidden layers are **_not created_** and thus the widgets for them _**neither**_.

!!! Note
With ***smart1inheritance***, the extended `Gebaeude` classes would all be summarised in a layer with a `t_type`, which defines what type of extension it is. This strategy hides the irrelevant values for ‘t_type’.

#### Group strategy

Base class layers with extensions of the same name are ***grouped***, base class layers with multiple extensions ***also***. Unless the extension is in the same model, then it's ***not grouped*** but ***renamed***.
Expand All @@ -66,6 +69,7 @@ Base class layers with extensions of the same name are ***grouped***, base class
Relationships of grouped layers are ***created***, but widgets are ***not applied*** to the form.

#### None strategy

Independently from extended models (but pretty much connected to it), we eliminate ambiguous layer naming in general. This means:

- If layername is ambiuous append topic name as suffix.
Expand Down
3 changes: 3 additions & 0 deletions docs/docs/user_guide/import_workflow.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,9 @@ Choose your optimization strategy in the checkbox:

Relations of grouped layers will be *created* but the widgets are *not applied* to the form.

!!! Note
As well you can optimize projects created with *smart1inheritance*. There it only appends the relevant type-values to the `t_type` dropdown box in the form, when ***Hide unused base class types*** is selected. A "grouping" optimization does not make sense for *smart1inheritance*.

For more information about the optimization of extended models, see the [corresponding chapter](../../background_info/extended_models_optimization).

## 8. OID Values
Expand Down
2 changes: 1 addition & 1 deletion docs/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ plugins:
Basket and Dataset Handling: Dataset und Basket Handling
OID Generator: OID Generator
UsabILIty Hub: UsabILIty Hub
Overview: Übersicht
Overview: Overview
Model Baker Integration: Model Baker Integration
Technical Concept: Technisches Konzept
Optimized Projects for Extended Models: Optimierte Projekte für erweiterte
Expand Down

0 comments on commit 264c632

Please sign in to comment.