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

gdl-frontend: Widgets: implemented the gdlt:Variant-Identifiers-Scope and gdlt:Datatype semantics for retrieving data

Location:
trunk/src/anaToMia/GDL_Widgets
Files:
4 edited

Legend:

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

    r1011 r1012  
    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());
    19831983
    1984                         Topic nameType = TmHelper.getConstrainedStatement(this.getRootConstraint());
    1985                         JsArray<Name> names = ((Topic)this.receivedData).getNames(nameType);
    1986                         Topic scope = TmHelper.getConstrainedScopeTopic(this.getRootConstraint());
    1987                         JsArray<Variant> variants = names.get(0).getVariants();
    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                                         }
    1999                                 }
    2000                         }
     1984                        ArrayList<Variant> variants = TmHelper.getVariantsForConstraint((Topic)this.receivedData, this.getConstraint());
     1985                        if(variants.size() != 0) this.addSubItem(variants.get(0).getValue());
     1986                        else this.addSubItem("");
    20011987                } else if (TmHelper.isInstanceOf(this.getConstraint(), PSIs.TMCL.tmclScopeConstraint)){
    20021988                        Topic type = TmHelper.getConstrainedStatement(this.getConstraint());
     
    20532039                        this.addSubItem(str);
    20542040                } else if (TmHelper.isInstanceOf(this.getConstraint(), PSIs.GDL.TopicType.gdlDatatype)){
    2055                         // TODO: implement: Datatype
     2041                        if(!(this.receivedData instanceof Topic)) throw new ExecutionException("the constraint " + TmHelper.getAnyIdOfTopic(this.getConstraint()) + " must be bound to a Topic, but is: " + receivedData.getClass());
     2042
     2043                        if(TmHelper.isInstanceOf(this.getRootConstraint(), PSIs.TMCL.tmclVariantNameConstraint)){
     2044                                ArrayList<Variant> variants = TmHelper.getVariantsForConstraint((Topic)this.receivedData, this.getRootConstraint());
     2045                                if(variants.size() != 0){
     2046                                        this.addSubItem(variants.get(0).getDatatype().getReference());
     2047                                }
     2048                        } else if(TmHelper.isInstanceOf(this.getRootConstraint(), PSIs.TMCL.tmclOccurrenceConstraint)){
     2049                                Topic occType = TmHelper.getConstrainedStatement(this.getRootConstraint());
     2050                                JsArray<Occurrence> occs = ((Topic)this.receivedData).getOccurrences(occType);
     2051                                if(occs.length() != 0) this.addSubItem(occs.get(0).getDatatype().getReference());
     2052                        } else {
     2053                                throw new InvalidGdlSchemaException("the constraint " + TmHelper.getAnyIdOfTopic(this.getConstraint()) + " must be bound to a constraint of the type " + PSIs.TMCL.tmclVariantNameConstraint + " or " + PSIs.TMCL.tmclOccurrenceConstraint + ",  but is bound to: " + TmHelper.getAnyIdOfTopic(this.getRootConstraint()));
     2054                        }
    20562055                } else if (TmHelper.isInstanceOf(this.getConstraint(), PSIs.GDL.TopicType.gdlVariantNameIdentifiers)){
    2057                         // TODO: implement: Variant-Name-Identifiers
     2056                        if(!(this.receivedData instanceof Topic)) throw new ExecutionException("the constraint " + TmHelper.getAnyIdOfTopic(this.getConstraint()) + " must be bound to a Topic, but is: " + receivedData.getClass());
     2057                        if(!TmHelper.isInstanceOf(this.getRootConstraint(), PSIs.TMCL.tmclVariantNameConstraint)) throw new InvalidGdlSchemaException("the constraint " + TmHelper.getAnyIdOfTopic(this.getConstraint()) + " must be bound to a constraint of the type " + PSIs.TMCL.tmclVariantNameConstraint + ",  but is bound to: " + TmHelper.getAnyIdOfTopic(this.getRootConstraint()));
     2058                       
     2059                        ArrayList<Variant> variants = TmHelper.getVariantsForConstraint((Topic)this.receivedData, this.getRootConstraint());
     2060                        if(variants.size() != 0){
     2061                                for(int i = 0; i != variants.get(0).getItemIdentifiers().length(); ++i) this.addSubItem(variants.get(0).getItemIdentifiers().get(i).getReference());
     2062                        }
    20582063                } else if (TmHelper.isInstanceOf(this.getConstraint(), PSIs.GDL.TopicType.gdlVariantNameReifier)){
     2064                        if(!(this.receivedData instanceof Topic)) throw new ExecutionException("the constraint " + TmHelper.getAnyIdOfTopic(this.getConstraint()) + " must be bound to a Topic, but is: " + receivedData.getClass());
     2065                        if(!TmHelper.isInstanceOf(this.getRootConstraint(), PSIs.TMCL.tmclVariantNameConstraint)) throw new InvalidGdlSchemaException("the constraint " + TmHelper.getAnyIdOfTopic(this.getConstraint()) + " must be bound to a constraint of the type " + PSIs.TMCL.tmclVariantNameConstraint + ",  but is bound to: " + TmHelper.getAnyIdOfTopic(this.getRootConstraint()));
     2066                       
    20592067                        // TODO: implement: Variant-Name-Reifier
    20602068                } else if (TmHelper.isInstanceOf(this.getConstraint(), PSIs.GDL.TopicType.gdlVariantNameScope)){
    20612069                        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                                 }
     2070                        if(!TmHelper.isInstanceOf(this.getRootConstraint(), PSIs.TMCL.tmclVariantNameConstraint)) throw new InvalidGdlSchemaException("the constraint " + TmHelper.getAnyIdOfTopic(this.getConstraint()) + " must be bound to a constraint of the type " + PSIs.TMCL.tmclVariantNameConstraint + ",  but is bound to: " + TmHelper.getAnyIdOfTopic(this.getRootConstraint()));
     2071                       
     2072                        ArrayList<Variant> variants = TmHelper.getVariantsForConstraint((Topic)this.receivedData, this.getRootConstraint());
     2073                        if(variants.size() != 0){
     2074                                for(int i = 0; i != variants.get(0).getScope().length(); ++i) this.addSubItem(this.getTopicRepresentation(variants.get(0).getScope().get(i), this.getDisplayByOfValueGroup(), this.getPreferredScopeOfValueGroup()));
    20782075                        }
    20792076                } else {
  • TabularUnified trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/PSIs.java

    r1010 r1012  
    2222                public final static String tmclRoleType = tmcl + "role-type";
    2323                public final static String tmclConstraint = tmcl + "constraint";
     24                public final static String tmclOccurrenceConstraint = tmcl + "occurrence-constraint";
    2425                public final static String tmclConstrained = tmcl + "constrained";
    2526                public final static String tmclConstrainedStatement = tmcl + "constrained-statement";
  • TabularUnified trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TmHelper.java

    r1010 r1012  
    1313import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Topic;
    1414import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.TopicMap;
     15import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Variant;
    1516import us.isidor.gdl.anaToMia.Widgets.environment.ExecutionException;
    1617import us.isidor.gdl.anaToMia.Widgets.environment.InvalidGdlSchemaException;
     
    14991500                else return null;
    15001501        }
     1502
     1503       
     1504        // Returns all variants of a topic that satisfies the passed constraint.
     1505        public static ArrayList<Variant> getVariantsForConstraint(Topic owner, Topic constraint) throws InvalidGdlSchemaException {
     1506                ArrayList<Variant> result = new ArrayList<Variant>();
     1507                if(owner == null || constraint == null) return result;
     1508               
     1509                Topic nameType = TmHelper.getConstrainedStatement(constraint);
     1510                JsArray<Name> names = owner.getNames(nameType);
     1511                Topic scope = TmHelper.getConstrainedScopeTopic(constraint);
     1512
     1513                for(int nameIdx = 0; nameIdx != names.length(); ++nameIdx){
     1514                        JsArray<Variant> variants = names.get(nameIdx).getVariants();
     1515                        for(int varIdx = 0; varIdx != variants.length(); ++varIdx){
     1516                                if(variants.get(varIdx).getScope().length() != 0){
     1517                                        JsArray<Topic> scopes = variants.get(varIdx).getScope();
     1518                                        int scopeIdx = 0;
     1519                                        for( ; scopeIdx != scopes.length(); ++scopeIdx) if(scopes.get(scopeIdx).equals(scope)) break;
     1520
     1521                                        if(scopeIdx != scopes.length()) result.add(variants.get(varIdx));
     1522                                }
     1523                        }
     1524                }
     1525               
     1526                return result;
     1527        }
     1528
    15011529}
  • TabularUnified trunk/src/anaToMia/GDL_Widgets/war/gdl_widgets/Service_GDL_Schema.jtm

    r1010 r1012  
    223223           
    224224            {"subject_identifiers":["[gdlsrv:service-variant-name-iis-text]"], "instance_of":["si:[gdlt:Text]"], "occurrences":[{"type":"si:[gdl:id]", "value":"service_variant_name_ii_text_id"}, {"type":"si:[gdl:readonly]", "value":"false"}, {"type":"si:[gdl:width]", "value":"470px"},{"type":"si:[gdl:cursor]", "value":"text"}]},
    225             {"subject_identifiers":["[gdlsrv:service-variant-name-iis-text-position]"], "instance_of":["si:[gdlt:Position]"], "occurrences":[{"type":"si:[gdl:position-style]", "value":"absolute"}, {"type":"si:[gdl:top]", "value":"430px"}, {"type":"si:[gdl:left]", "value":"10px"}]},
     225            {"subject_identifiers":["[gdlsrv:service-variant-name-iis-text-position]"], "instance_of":["si:[gdlt:Position]"], "occurrences":[{"type":"si:[gdl:position-style]", "value":"absolute"}, {"type":"si:[gdl:top]", "value":"450px"}, {"type":"si:[gdl:left]", "value":"10px"}]},
    226226            {"subject_identifiers":["[gdlsrv:service-variant-name-iis-text-value-group]"], "instance_of":["si:[gdlt:Value-Group]"]},
    227227            {"subject_identifiers":["[model:service-variant-name-ii-constraint]"], "instance_of":["si:[gdlt:Variant-Name-Identifiers]"]},
    228228
    229229                        {"subject_identifiers":["[gdlsrv:service-variant-name-reifier-text]"], "instance_of":["si:[gdlt:Text]"], "occurrences":[{"type":"si:[gdl:id]", "value":"service_variant_name_reifier_text_id"}, {"type":"si:[gdl:readonly]", "value":"false"}, {"type":"si:[gdl:width]", "value":"470px"},{"type":"si:[gdl:cursor]", "value":"text"}]},
    230             {"subject_identifiers":["[gdlsrv:service-variant-name-reifier-text-position]"], "instance_of":["si:[gdlt:Position]"], "occurrences":[{"type":"si:[gdl:position-style]", "value":"absolute"}, {"type":"si:[gdl:top]", "value":"470px"}, {"type":"si:[gdl:left]", "value":"10px"}]},
     230            {"subject_identifiers":["[gdlsrv:service-variant-name-reifier-text-position]"], "instance_of":["si:[gdlt:Position]"], "occurrences":[{"type":"si:[gdl:position-style]", "value":"absolute"}, {"type":"si:[gdl:top]", "value":"490px"}, {"type":"si:[gdl:left]", "value":"10px"}]},
    231231            {"subject_identifiers":["[gdlsrv:service-variant-name-reifier-text-value-group]"], "instance_of":["si:[gdlt:Value-Group]"]},
    232232            {"subject_identifiers":["[model:service-variant-name-reifier-constraint]"], "instance_of":["si:[gdlt:Variant-Name-Reifier]"]},
Note: See TracChangeset for help on using the changeset viewer.