Ignore:
Timestamp:
10/20/11 07:14:01 (14 years ago)
Author:
lgiessmann
Message:

gdl-frontend: Widgets: implemented the gdlt:Variant-Name-Scope semantics for retrieving data

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlVisibleObject.java

    r1010 r1011  
    19211921                        // get type
    19221922                        Topic constrainedTopicType = TmHelper.getConstrainedTopicType(this.getConstraint());
    1923                        
     1923
    19241924                        // search for the topic type
    19251925                        Reifiable ref = (Reifiable)this.receivedData;
    1926                        
     1926
    19271927                        // search for the characteristics type
    19281928                        if(this.receivedData instanceof Topic){
     
    19381938                                if(roles.length() != 0) ref = roles.get(0);
    19391939                        }
    1940                        
     1940
    19411941                        // search for item-identifiers of the found topic type or characteristics
    19421942                        Pattern rex = new Pattern(this.getLiteralValueForConstraint());
     
    19611961                } else if (TmHelper.isInstanceOf(this.getConstraint(), PSIs.TMCL.tmclReifierConstraint)){
    19621962                        Topic type = TmHelper.getConstrainedStatement(this.getConstraint());
    1963                        
     1963
    19641964                        Topic reifier = null;
    19651965                        if(this.receivedData instanceof Topic){
     
    19751975                                throw new ExecutionException("the constraint " + TmHelper.getAnyIdOfTopic(this.getConstraint()) + " must be bound to a topic or association, but is: " + this.receivedData.getClass());
    19761976                        }
    1977                        
     1977
    19781978                        String str = this.getTopicRepresentation(reifier, this.getDisplayByOfValueGroup(), this.getPreferredScopeOfValueGroup());
    19791979                        if(str == null) str = "";
     
    19811981                } else if (TmHelper.isInstanceOf(this.getConstraint(), PSIs.TMCL.tmclVariantNameConstraint)){
    19821982                        if(!(this.receivedData instanceof Topic)) throw new ExecutionException("the constraint " + TmHelper.getAnyIdOfTopic(this.getConstraint()) + " must be bound to a Topic, but is: " + receivedData.getClass());
    1983                        
     1983
    19841984                        Topic nameType = TmHelper.getConstrainedStatement(this.getRootConstraint());
    19851985                        JsArray<Name> names = ((Topic)this.receivedData).getNames(nameType);
    19861986                        Topic scope = TmHelper.getConstrainedScopeTopic(this.getRootConstraint());
    19871987                        JsArray<Variant> variants = names.get(0).getVariants();
    1988                        
    1989                         if(variants.get(0).getScope().length() != 0){
    1990                                 JsArray<Topic> scopes = variants.get(0).getScope();
    1991                                 int i = 0;
    1992                                 for( ; i != scopes.length(); ++i) if(scopes.get(i).equals(scope)) break;
    1993                                
    1994                                 if(i != scopes.length()){
    1995                                         for(i = 0; i != scopes.length(); ++i) this.addSubItem(this.getTopicRepresentation(scopes.get(i), this.getDisplayByOfValueGroup(), this.getPreferredScopeOfValueGroup()));
     1988
     1989                        for(int varIdx = 0; varIdx != variants.length(); ++varIdx){
     1990                                if(variants.get(varIdx).getScope().length() != 0){
     1991                                        JsArray<Topic> scopes = variants.get(varIdx).getScope();
     1992                                        int scopeIdx = 0;
     1993                                        for( ; scopeIdx != scopes.length(); ++scopeIdx) if(scopes.get(scopeIdx).equals(scope)) break;
     1994
     1995                                        if(scopeIdx != scopes.length()){
     1996                                                this.addSubItem(variants.get(varIdx).getValue());
     1997                                                break;
     1998                                        }
    19961999                                }
    19972000                        }
    19982001                } else if (TmHelper.isInstanceOf(this.getConstraint(), PSIs.TMCL.tmclScopeConstraint)){
    19992002                        Topic type = TmHelper.getConstrainedStatement(this.getConstraint());
    2000                        
     2003
    20012004                        JsArray<Topic> scope = null;
    20022005                        if(this.receivedData instanceof Topic){
     
    20122015                                throw new ExecutionException("the constraint " + TmHelper.getAnyIdOfTopic(this.getConstraint()) + " must be bound to a topic or association, but is: " + this.receivedData.getClass());
    20132016                        }
    2014                        
     2017
    20152018                        if(scope != null){
    20162019                                for(int i = 0; i != scope.length(); ++i) this.addSubItem(this.getTopicRepresentation(scope.get(i), this.getDisplayByOfValueGroup(), this.getPreferredScopeOfValueGroup()));
     
    20452048                                throw new ExecutionException("The topic " + TmHelper.getAnyIdOfTopic(this.getConstraint()) + " must be bound to the following root constraints: " + constraints);
    20462049                        }
    2047        
     2050
    20482051                        String str = this.getTopicRepresentation(type, this.getDisplayByOfValueGroup(), this.getPreferredScopeOfValueGroup());
    20492052                        if(str == null) str = "";
     
    20562059                        // TODO: implement: Variant-Name-Reifier
    20572060                } else if (TmHelper.isInstanceOf(this.getConstraint(), PSIs.GDL.TopicType.gdlVariantNameScope)){
    2058                         // TODO: implement: Variant-Name-Scope
     2061                        if(!(this.receivedData instanceof Topic)) throw new ExecutionException("the constraint " + TmHelper.getAnyIdOfTopic(this.getConstraint()) + " must be bound to a Topic, but is: " + receivedData.getClass());
     2062
     2063                        Topic nameType = TmHelper.getConstrainedStatement(this.getRootConstraint());
     2064                        JsArray<Name> names = ((Topic)this.receivedData).getNames(nameType);
     2065                        Topic scope = TmHelper.getConstrainedScopeTopic(this.getRootConstraint());
     2066                        JsArray<Variant> variants = names.get(0).getVariants();
     2067
     2068                        for(int varIdx = 0; varIdx != variants.length(); ++varIdx){
     2069                                if(variants.get(varIdx).getScope().length() != 0){
     2070                                        JsArray<Topic> scopes = variants.get(varIdx).getScope();
     2071                                        int scopeIdx = 0;
     2072                                        for( ; scopeIdx != scopes.length(); ++scopeIdx) if(scopes.get(scopeIdx).equals(scope)) break;
     2073
     2074                                        if(scopeIdx != scopes.length()){
     2075                                                for(int i = 0; i != scopes.length(); ++i) this.addSubItem(this.getTopicRepresentation(scopes.get(i), this.getDisplayByOfValueGroup(), this.getPreferredScopeOfValueGroup()));
     2076                                        }
     2077                                }
     2078                        }
    20592079                } else {
    20602080                        throw new InvalidGdlSchemaException("The constraint " + TmHelper.getAnyIdOfTopic(this.getConstraint()) + " is not suported to be bound to the value group instance " + TmHelper.getAnyIdOfTopic(this.getValueGroup()));
Note: See TracChangeset for help on using the changeset viewer.