possible error in ontology-parsing?

I have following ontology snippet:

ontology
    primary_language = <"en">
    term_definitions = <
        ["en"] = <
            items = <
                ["at0"]=<
                        description=<"person name, birthdate, address,
communications">
                        text=<"person name, birthdate, address,
communications">
                >

When I do
    archetype.getOntology().getLanguages()
or
    archetype.getOntology().getPrimaryLanguage()

I get Nullpointer-exceptions,

when I do
    archetype.getOntology().toString, I get

Bert,

I copy you in to a discussion Rong, Thomas and I had about this recently - see below.

Regards
Sebastian

Rong Chen wrote:

Hi,
According to the latest AOM specification, the method
ArchetypeOntology.getLanguages() is not there anymore. We need to
deprecate it in the next release.On the other hand, there is a method
called terminologies_available(), maybe we should also have
languages_available() in the specs and implementation code?

Rong,
you can leave it in the code if you want; the AOM doesn't stop you having extra methods. Terminologies_available() will probably go the same way. In the current AOM, the proper place to get languages_available is from ARCHETYPE (due to inheritance fom
AUTHORED_RESOURCE)

- thomas

Thanks, Sebastian, I appreciate this.

Please let me ask one question, because I work with results, I have to
as a programmer.

I understand that languages are out of order, now.
Does this mean, we cannot give meaning (=name-attribute) to a Locatable
now, because we cannot use the ArchetypeOntology interface to find that out?

Or is there an other way planned or already implemented to do this?

Thanks
Bert

Sebastian Garde schreef:

Bert,

I am not sure I understand what you need,
but you should be able to easily get the available languages:

HashSet<String> availableLanguages = new HashSet<String>();
List termDefinitionlist = ontology.getTermDefinitionsList();
for (int k = 0; k < termDefinitionlist.size(); k++) {
  OntologyDefinitions ontodefis = (OntologyDefinitions) termDefinitionlist.get(k);
  String termDefinitionLanguage = ontodefis.getLanguage();
  availableLanguages.add(termDefinitionLanguage);
}
    
This should give you all the available languages.
Rong may even consider to put this as a new indirect implementation for getLanguages() in the java ref imp - as Thomas said there can be additional methods and this one is certainly very handy to have

To be totally sure that you don't 'miss' a language somewhere else in the archetype (depending on what your needs are) you could also look in the description part and the constraint part in addition:

List li = anArchetype.getDescription().getDetails();
if (li != null) {
  for (int i = 0; i < li.size(); i++) {
    ResourceDescriptionItem languageGroup = (ResourceDescriptionItem) li.get(i);
    if (languageGroup.getLanguage() != null)
      language = languageGroup.getLanguage().getCodeString();
      availableLanguages.add(language);
  }
}
        
List constraintDefinitionList = ontology.getConstraintDefinitionsList();
for (int k = 0; k < constraintDefinitionList.size(); k++) {
  OntologyDefinitions constraintdefis = (OntologyDefinitions) constraintDefinitionList.get(k);
  String constraintLanguage = constraintdefis.getLanguage();
  availableLanguages.add(constraintLanguage);
}

Hope that helps
Sebastian

Hope that helps
Sebastian
  
Helps a lot, thanks Sebastian, I think I was too much seeinig it as a
problem which needed to be solverd somewhere else, instead of looking
for a solution mysel.

Thanks again

kind regards
Bert