Skip to content
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

Provide OID domains per layers #68

Merged
merged 6 commits into from
Nov 8, 2023
Merged

Provide OID domains per layers #68

merged 6 commits into from
Nov 8, 2023

Conversation

signedav
Copy link
Member

@signedav signedav commented Nov 3, 2023

This PR provides the OID domain (type) over the Layer object.

This is the approach the Plugin using the Generator and not calling a db_connector function directly. The reason is, to have the information about the relevance of a layer, alias (that will be used in the project later) etc. and we can set the default_expression directly.

How I imagine it to work:

image

It's reloaded on changing the strategy - and the generator is persisted for further project generation:

0. getting the Generator

generator = Generator(
    self.configuration.tool,
    uri,
    self.configuration.inheritance,
    self.configuration.dbschema,
    mgmt_uri=mgmt_uri,
    consider_basket_handling=True,
    optimize_strategy=self.optimize_combo.currentData(),
)

and on changing the strategy in the GUI:

generator.optimize_strategy = self.optimize_combo.currentData()

and getting the list of layers...

1. getting a list of the layers visible in the project (according to relevance and strategy) not concerning the system tables

available_layers = generator.layers()
# maybe make it more readable and less single linish
layers_of_interest = [
    l for l in available_layers if (l.is_relevant or self.optimize_combo.currentData() != optimize_strategy.HIDE) and l.name not in self.BASKET_TABLES
]

2. Getting the oid type (and the other info)

for layer in layers_of_interest:
      oid_entry['oid_domain']=layer.oid_domain

3. Set the default_expressions

layer.t_ili_tid_field.default_value_expression = "'ch_baker'||ilicounter(000000000,999999999)"

Limitations

If a CLASS is designed in a TOPIC (with ANYOID) and it's extended in multiple other TOPICS with different OID definitions, we cannot say what should be the default value. This is a known limitation or maybe we find a solution for it.

@signedav signedav changed the title OID (TID) Generation Provide OID domains per layers Nov 6, 2023
@signedav
Copy link
Member Author

signedav commented Nov 6, 2023

The changes on the class are not that big, in fact only a nice provide of the oid_domain (the type) and the t_ili_tid field (oid field). Then some tests and in the end kind of a proof of concept...

@signedav signedav marked this pull request as ready for review November 6, 2023 08:28
@@ -341,6 +341,20 @@ def real_id(self):
else:
return None

@property
def oid_domain(self):
t_ili_tid_field = self.t_ili_tid_field
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
t_ili_tid_field = self.t_ili_tid_field
t_ili_tid_field = self.t_ili_tid_field()

Missing parentheses?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah no its a property...

@signedav
Copy link
Member Author

signedav commented Nov 8, 2023

Thanks @domi4484 I think here you would have already the basics for the GUI implementation. Maybe you will find some more requirements to it during implementation. I'll make a release of the library.

@signedav signedav merged commit dc192f5 into main Nov 8, 2023
4 checks passed
@signedav signedav deleted the oid_madness branch November 8, 2023 07:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants