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

Not able to generate code for GoogleDigitalBuildings RDF file and latest OLGA SDK #28

Open
navneet79 opened this issue May 28, 2021 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@navneet79
Copy link

navneet79 commented May 28, 2021

Compilation fails for Java code generated using the OLGA SDK

Steps to reproduce the behavior:
Download the digital_buildings rdf file from the digital buildings repo.
ZIP the OLGA Repo Master branch.
install the CORE and CLI packages,

java -jar OLGA-Cli/target/OLGA-Cli-0.0.6-with-dependencies.jar --code java --library rdf4j --name DigitalBuildings --path digital_buildings.rdf

I get the following error
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project digitalbuildings-RDF4J: Compilation failure: Compilation failure:
[ERROR] /E:/OLGA-master/OLGA-master/OLGA/OLGA/generated/digitalbuildings-RDF4J-java/src/main/java/digitalbuildings/rdf/model/Ahu_bspc_dx4sc_econm_efss_efvsc_oafmc_sfss_sfvsc_sspc.java:[64,17] method addUsesOptionalsEconomizer_mode(digitalbuildings.rdf.model.IEconomizer_mode) is already defined in class digitalbuildings.rdf.model.Ahu_bspc_dx4sc_econm_efss_efvsc_oafmc_sfss_sfvsc_sspc

This comes for a lot of classes
Please Help

@charbull charbull added the bug Something isn't working label Jul 2, 2021
@charbull
Copy link
Collaborator

charbull commented Jul 2, 2021

@radissoa can you please take a look?
@navneet79 I saw this bug and generated the code here: https://github.com/charbull/OLGA-GeneratedCode-DigitalBuildingsOntology/blob/master/README.md

Please take a look until it is fixed.
Thank you

@navneet79
Copy link
Author

Thanks @charbull

@radissoa
Copy link
Collaborator

radissoa commented Jul 6, 2021

I can take a look at it, I'll come back to you soon.

@radissoa
Copy link
Collaborator

radissoa commented Jul 7, 2021

So i had a look at it, it is hard to reproduce the exact error @navneet79 mentioned because there are so many others.
Although my feeling is that all or nearly all errors are due to the fact that the digital buildings ontology implements multiple inheritance, for example :

  <owl:Class rdf:about="http://www.google.com/digitalbuildings/0.0.1/hvac#Ahu_bspc_chwsc_econ_efss4x_efvsc4x_fdpm_hwsc_sfss2x_sfvsc2x_sspc">
    <rdfs:subClassOf rdf:resource="http://www.google.com/digitalbuildings/0.0.1/hvac#Ahu"/>
    <rdfs:label>Ahu_bspc_chwsc_econ_efss4x_efvsc4x_fdpm_hwsc_sfss2x_sfvsc2x_sspc</rdfs:label>
    <rdfs:subClassOf rdf:resource="http://www.google.com/digitalbuildings/0.0.1/hvac#Sfvsc2x"/>
    <rdfs:subClassOf rdf:resource="http://www.google.com/digitalbuildings/0.0.1/hvac#Hwsc"/>
    <rdfs:subClassOf rdf:resource="http://www.google.com/digitalbuildings/0.0.1/hvac#Chwsc"/>
    <rdfs:subClassOf rdf:resource="http://www.google.com/digitalbuildings/0.0.1/hvac#Efvsc4x"/>
    <rdfs:comment>Multi-zone AHU.</rdfs:comment>
    <rdfs:subClassOf rdf:resource="http://www.google.com/digitalbuildings/0.0.1/hvac#Sspc"/>
    <rdfs:subClassOf rdf:resource="http://www.google.com/digitalbuildings/0.0.1/hvac#Bspc"/>
    <rdfs:subClassOf rdf:resource="http://www.google.com/digitalbuildings/0.0.1/hvac#Efss4x"/>
    <rdfs:subClassOf rdf:resource="http://www.google.com/digitalbuildings/0.0.1/hvac#Econ"/>
    <rdfs:subClassOf rdf:resource="http://www.google.com/digitalbuildings/0.0.1/hvac#Sfss2x"/>
    <rdfs:subClassOf rdf:resource="http://www.google.com/digitalbuildings/0.0.1/hvac#Fdpm"/>
  </owl:Class>

This puts us in a tricky spot because in the generated code, we use both class and interface hierarchy and a class can only extend one class but an interface can extend multiple interfaces. Hence, there is a disparity between the two hierarchies and some methods are not implemented by certain classes, there is also the case that a method with the same name is declared in two interfaces, generating a conflict, because the same property applies to two of superclasses in the ontology.

Looking briefly at the code, it seems that OLGA was planned for simpler class hierarchies, and we need to review the design to accept more complex ones.

What is your opinion @charbull ?

@charbull
Copy link
Collaborator

charbull commented Jul 7, 2021

@radissoa thank you for taking a look,
I thought we handled this already here:

public interface ${interfaceName}<#if motherClassList??><#if motherClassList?has_content> extends <#list motherClassList as SuperZClassCurrentElementOfList><#if SuperZClassCurrentElementOfList.getzClassName() == "Resource" && preserveNameSpaceOfOntology==true>${SuperZClassCurrentElementOfList.getPackageName()?lower_case}.I${SuperZClassCurrentElementOfList.getzClassName()}<#else>I${SuperZClassCurrentElementOfList.getzClassName()}</#if><#sep>, </#list><#else> extends IRI</#if></#if>{

and here:

Where we pick the best one to extend maybe the bug is here? we do support multi-inheritance already, probably the code has a bug there?

What do you think?

@radissoa
Copy link
Collaborator

radissoa commented Jul 8, 2021

You are right we do support multi inheritance, and yes the bug might there. I will have to start the debugger to get a clearer idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants