Author: lgiessmann Date: Thu Jul 28 08:22:27 2011 New Revision: 691
Log: gdl-frontend: Widgets: implemented the method TmHelper.getDefaultTmValue() that returns the topic that represents the tm-default-value; extended the test.gdl.jtm file
Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/TODO.txt branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlPsis.java branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/IGdlHasValueGroup.java branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TmHelper.java branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/text/GdlText.java branches/gdl-frontend/src/anaToMia/GDL_Widgets/war/gdl_widgets/test.gdl.jtm
Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/TODO.txt ============================================================================== --- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/TODO.txt Thu Jul 28 06:35:52 2011 (r690) +++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/TODO.txt Thu Jul 28 08:22:27 2011 (r691) @@ -1,3 +1,4 @@ +* peson-name-constraint: create a person topic type, bind the person-name to this topic type, set the default-tm-value * Implement all IHasValueGroup to: * GdlText * GdlInfo
Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlPsis.java ============================================================================== --- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlPsis.java Thu Jul 28 06:35:52 2011 (r690) +++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlPsis.java Thu Jul 28 08:22:27 2011 (r691) @@ -189,6 +189,7 @@ public final static String gdlTmBinding = gdl + "tm-binding"; public final static String gdlViewBinding = gdl + "view-binding"; public final static String gdlTopicViewBinding = gdl + "topic-view-binding"; + public final static String gdlValueBinding = gdl + "value-binding"; } @@ -205,6 +206,7 @@ public final static String gdlValueGroup = gdl + "value-group"; public final static String gdlTmValue = gdl + "tm-value"; public final static String gdlActionButton = gdl + "action-button"; + public final static String gdlValue = gdl + "value"; }
Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/IGdlHasValueGroup.java ============================================================================== --- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/IGdlHasValueGroup.java Thu Jul 28 06:35:52 2011 (r690) +++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/IGdlHasValueGroup.java Thu Jul 28 08:22:27 2011 (r691) @@ -31,7 +31,9 @@ // i.e. is is one value of getDefaultTmValue(), getDefaultLiteralValue() public Topic getDefaultValue() throws InvalidGdlSchemaException; - // returns all possible topics that can be used as values for this value group + // returns all possible topics that can be used as values for this value group, + // i.e. if no tm-values are bound to this value-group, all possible values are + // generated by examining the tmcl:constraint public ArrayList<Topic> getTmValues() throws InvalidGdlSchemaException; // returns all possible literals that can be used as values for this value group
Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TmHelper.java ============================================================================== --- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TmHelper.java Thu Jul 28 06:35:52 2011 (r690) +++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TmHelper.java Thu Jul 28 08:22:27 2011 (r691) @@ -665,4 +665,35 @@ else throw new InvalidGdlSchemaException("the value group " + getAnyIdOfTopic(valueGroup) + " must be bound to exaclty on root constraint of the type " + GdlPsis.TMCL.constraint + " but is unbound"); } } + + + // returns the topic that represent the default tm value for the passed value group + public static Topic getDefaultTmValue(Topic valueGroup) throws InvalidGdlSchemaException { + if(valueGroup == null) return null; + + TopicMap tm = valueGroup.getTopicMap(); + Topic valueBindingAssocTopic = getTopicByPsi(GdlPsis.AssociationType.gdlValueBinding, tm); + Topic valueGroupRoleType = getTopicByPsi(GdlPsis.RoleType.gdlValueGroup, tm); + Topic valueRoleType = getTopicByPsi(GdlPsis.RoleType.gdlValue, tm); + Topic defaultTmValueType = getTopicByPsi(GdlPsis.TopicType.gdlDefaultTmValue, tm); + + ArrayList<Topic> defaultTmValues = getOtherPlayerOfBinaryAssociation(valueGroup, valueGroupRoleType, valueBindingAssocTopic, null, defaultTmValueType, valueRoleType); + + if(defaultTmValues.size() == 1) return defaultTmValues.get(0); + else if(defaultTmValues.size() == 0) return null; + else throw new InvalidGdlSchemaException("the topic " + getAnyIdOfTopic(valueGroup) + " must be bound none or once to a DefaultTmValue, but is: " + defaultTmValues.size()); + } + + + public static Topic getDefaultLiteralValue(Topic valueGroup) throws InvalidGdlSchemaException{ + // TODO: implement + return null; + } + + + public static ArrayList<Topic> getTmValue(Topic valueGroup) throws InvalidGdlSchemaException { + // TODO: implement + // TODO: if no tm-values are set, examine the tmcl constraint + return null; + } }
Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/text/GdlText.java ============================================================================== --- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/text/GdlText.java Thu Jul 28 06:35:52 2011 (r690) +++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/text/GdlText.java Thu Jul 28 08:22:27 2011 (r691) @@ -43,6 +43,8 @@ protected boolean constraintTopicSet = false; protected Topic rootConstraintTopic = null; protected boolean rootConstraintTopicSet = false; + protected Topic defaultTmValueTopic = null; + protected boolean defaultTmValueTopicSet = false; // some constructors protected GdlText() throws InvalidGdlSchemaException, ExecutionException { @@ -55,6 +57,8 @@ // TODO: create a text element for each TM-elem this.createNewTextArea().setText("Text"); // TODO: remove only for debugging this.setNthButtons(); + + Window.alert(TmHelper.getAnyIdOfTopic(this.tmRepresentative) + " >> " + TmHelper.getAnyIdOfTopic(this.getDefaultTmValue())); // TODO: remove } @@ -817,29 +821,34 @@
@Override public Topic getValueGroup() throws InvalidGdlSchemaException { - if(!this.valueGroupTopicSet) this.valueGroupTopic = TmHelper.getValueGroupOf(this.tmRepresentative); - return this.valueGroupTopic; + if(this.valueGroupTopicSet){ + return this.valueGroupTopic; + } else { + this.valueGroupTopic = TmHelper.getValueGroupOf(this.tmRepresentative); + this.valueGroupTopicSet = true; + return this.valueGroupTopic; + } }
@Override public Topic getConstraint() throws InvalidGdlSchemaException { - Topic valueGroup = this.getValueGroup(); - if(valueGroup != null) this.constraintTopic = TmHelper.getConstraintOfValueGroup(valueGroup); - this.constraintTopicSet = true; - return this.constraintTopic; + if(this.constraintTopicSet){ + return this.constraintTopic; + } else { + this.constraintTopic = TmHelper.getConstraintOfValueGroup(this.getValueGroup()); + this.constraintTopicSet = true; + return this.constraintTopic; + } } @Override public Topic getRootConstraint() throws InvalidGdlSchemaException { - Topic valueGroup = this.getValueGroup(); - this.rootConstraintTopicSet = true; - if(valueGroup == null) { - this.rootConstraintTopicSet = true; - return null; + if(this.rootConstraintTopicSet){ + return this.rootConstraintTopic; } else { - this.rootConstraintTopic = TmHelper.getRootConstraintOfValueGroup(valueGroup, this.getConstraint()); + this.rootConstraintTopic = TmHelper.getRootConstraintOfValueGroup(this.getValueGroup(), this.getConstraint()); this.rootConstraintTopicSet = true; return this.rootConstraintTopic; } @@ -848,8 +857,13 @@
@Override public Topic getDefaultTmValue() throws InvalidGdlSchemaException { - // TODO Auto-generated method stub - return null; + if(this.defaultTmValueTopicSet){ + return this.defaultTmValueTopic; + } else { + this.defaultTmValueTopic = TmHelper.getDefaultTmValue(this.getValueGroup()); + this.defaultTmValueTopicSet = true; + return this.defaultTmValueTopic; + } }
@@ -862,7 +876,9 @@ @Override public Topic getDefaultValue() throws InvalidGdlSchemaException { - return this.getDefaultLiteralValue() == null ? this.getDefaultTmValue() : this.getDefaultLiteralValue(); + if(this.getDefaultLiteralValue() != null && this.getDefaultTmValue() != null) throw new InvalidGdlSchemaException("the topic " + TmHelper.getAnyIdOfTopic(this.getValueGroup()) + " must be bound to maximal one " + GdlPsis.TopicType.gdlDefaultValue + ", but is: 2"); + else if(this.getDefaultLiteralValue() != null) return this.getDefaultLiteralValue(); + else return this.getDefaultTmValue(); }
Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/war/gdl_widgets/test.gdl.jtm ============================================================================== --- branches/gdl-frontend/src/anaToMia/GDL_Widgets/war/gdl_widgets/test.gdl.jtm Thu Jul 28 06:35:52 2011 (r690) +++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/war/gdl_widgets/test.gdl.jtm Thu Jul 28 08:22:27 2011 (r691) @@ -30,6 +30,11 @@ {"subject_identifiers":["[tmcl:card-min]"], "instance_of":["si:[tmcl:occurrence-type]"]}, {"subject_identifiers":["[doc:test-schema]"], "instance_of":["si:[gdl:Schema]"], "names":[{"value": "Test GDL Schema", "type":"si:[gdl:schema-name]"}]}, {"subject_identifiers":["[gdl:Visible-Object]"]}, + {"subject_identifiers":["[doc:person-name]"], "instance_of":["si:[tmcl:name-type]"]}, + {"subject_identifiers":["[doc:poet-name]"]}, + {"subject_identifiers":["[doc:musician-name]"]}, + {"subject_identifiers":["[doc:director-name]"]}, + {"subject_identifiers":["[gdl:Visible-Object]"]}, {"subject_identifiers":["[tmcl:constraint]"], "instance_of":["si:[tmcl:topic-type]"]}, {"subject_identifiers":["[tmcl:topic-name-constraint]"], "instance_of":["si:[tmcl:topic-type]"]}, {"subject_identifiers":["[gdl:Value-Group]"]}, @@ -63,6 +68,21 @@ {"subject_identifiers":["[gdl:Button]"]}, {"subject_identifiers":["[gdl:Action-Button]"]}, {"subject_identifiers":["[gdl:Input-Button]"]}, + {"subject_identifiers":["[gdl:Value]"]}, + {"subject_identifiers":["[gdl:Default-Value]"]}, + {"subject_identifiers":["[gdl:Input-Button]"]}, + {"subject_identifiers":["[gdl:Literal-Value]"]}, + {"subject_identifiers":["[gdl:TM-Value]"]}, + {"subject_identifiers":["[gdl:TM-Type-Value]"]}, + {"subject_identifiers":["[gdl:TM-Single-Type-Value]"]}, + {"subject_identifiers":["[gdl:TM-Multiple-Type-Value]"]}, + {"subject_identifiers":["[gdl:TM-Instance-Value"]}, + {"subject_identifiers":["[gdl:Default-Literal-Value]"]}, + {"subject_identifiers":["[gdl:Default-TM-Value]"]}, + {"subject_identifiers":["[gdl:Default-TM-Type-Value]"]}, + {"subject_identifiers":["[gdl:Default-TM-Single-Type-Value]"]}, + {"subject_identifiers":["[gdl:Default-TM-Multiple-Type-Value]"]}, + {"subject_identifiers":["[gdl:Default-TM-Instance-Value]"]}, {"subject_identifiers":["[gdl:Delete-Button]"]}, {"subject_identifiers":["[gdl:Create-Button]"]}, {"subject_identifiers":["[gdl:Radio-Button]"]}, @@ -72,6 +92,7 @@ {"subject_identifiers":["[gdl:Title]"]}, {"subject_identifiers":["[gdl:Reference]"]}, {"subject_identifiers":["[gdl:List]"]}, + {"subject_identifiers":["[doc:default-tm-value-person-name-type-constraint]"], "instance_of":["si:[gdl:Default-TM-Instance-Value]"]}, {"subject_identifiers":["[doc:person-name-type-constraint]"], "instance_of":["si:[gdl:Type]"]}, {"subject_identifiers":["[doc:person-name-constraint]"], "instance_of":["si:[tmcl:topic-name-constraint]"], "occurrences":[{"type":"si:[tmcl:card-min]", "value":"1"}, {"type":"si:[tmcl:card-max]", "value":"1"}]}, {"subject_identifiers":["[doc:unit-1-radio-button]"], "instance_of":["si:[gdl:Radio-Button]"], "occurrences":[{"type":"si:[gdl:id]", "value":"unit_1_radio_button_id"},{"type":"si:[gdl:content-orientation]", "value":"horizontal"}, {"type":"si:[gdl:background-color]", "value": "lime"}, {"type":"si:[gdl:margin-left]", "value":"15pt"}, {"type":"si:[gdl:font-size]", "value":"8pt"}]}, @@ -98,7 +119,6 @@ {"subject_identifiers":["[doc:pos-of-unit-1-text]"], "instance_of":["si:[gdl:Position]"]}, {"subject_identifiers":["[doc:reference-1]"], "instance_of":["si:[gdl:Reference]"], "occurrences":[{"type":"si:[gdl:id]", "value":"reference_1_id", "datatype":"[xsd:ID]"}, {"type":"si:[gdl:margin-left]", "value":"200px"}, {"type":"si:[gdl:background-color]", "value":"yellow"}]}, {"subject_identifiers":["[doc:list-box-1]"], "instance_of":["si:[gdl:List-Box]"], "occurrences":[{"type":"si:[gdl:id]", "value":"list_box_1_id", "datatype":"[xsd:ID]"}]}, - {"subject_identifiers":["[gdl:Value]"], "instance_of":["si:[tmcl:topic-type]"]}, {"subject_identifiers":["[doc:pos-of-title-1]"], "instance_of":["si:[gdl:Position]"]}, {"subject_identifiers":["[doc:pos-of-text-1]"], "instance_of":["si:[gdl:Position]"], "occurrences":[{"type":"si:[gdl:position-style]", "value":"relative"}, {"type":"si:[gdl:top]", "value":"40px"}, {"type":"si:[gdl:left]", "value": "5%"}]}, {"subject_identifiers":["[doc:pos-of-reference-1]"], "instance_of":["si:[gdl:Position]"], "occurrences":[{"type":"si:[gdl:position-style]", "value":"static"}]}, @@ -111,7 +131,6 @@ {"subject_identifiers":["[gdl:bottom]"], "instance_of":["si:[tmcl:occurrence-type]"]}, {"subject_identifiers":["[gdl:left]"], "instance_of":["si:[tmcl:occurrence-type]"]}, {"subject_identifiers":["[gdl:content-orientation]"], "instance_of":["si:[tmcl:occurrence-type]"]}, - {"subject_identifiers":["[gdl:TM-Value]"]}, {"subject_identifiers":["[gdl:Unit]"]}, {"subject_identifiers":["[gdl:Nth-Element]"]}, {"subject_identifiers":["[gdl:nth-value]"], "instance_of":["si:[tmcl:occurrence-type]"]}, @@ -157,6 +176,18 @@ {"type":"si:[tmdm:supertype-subtype]", "roles":[{"type":"si:[tmdm:supertype]", "player":"si:[gdl:Default-Topic-View]"},{"type":"si:[tmdm:subtype]", "player":"si:[gdl:Default-Editor-Topic-View]"}]}, {"type":"si:[tmdm:supertype-subtype]", "roles":[{"type":"si:[tmdm:supertype]", "player":"si:[gdl:Special-Topic-View]"},{"type":"si:[tmdm:subtype]", "player":"si:[gdl:Special-Creator-Topic-View]"}]}, {"type":"si:[tmdm:supertype-subtype]", "roles":[{"type":"si:[tmdm:supertype]", "player":"si:[gdl:Value]"},{"type":"si:[tmdm:subtype]", "player":"si:[gdl:TM-Value]"}]}, + {"type":"si:[tmdm:supertype-subtype]", "roles":[{"type":"si:[tmdm:supertype]", "player":"si:[gdl:Value]"},{"type":"si:[tmdm:subtype]", "player":"si:[gdl:Literal-Value]"}]}, + {"type":"si:[tmdm:supertype-subtype]", "roles":[{"type":"si:[tmdm:supertype]", "player":"si:[gdl:Value]"},{"type":"si:[tmdm:subtype]", "player":"si:[gdl:Default-Value]"}]}, + {"type":"si:[tmdm:supertype-subtype]", "roles":[{"type":"si:[tmdm:supertype]", "player":"si:[gdl:TM-Value]"},{"type":"si:[tmdm:subtype]", "player":"si:[gdl:TM-Type-Value]"}]}, + {"type":"si:[tmdm:supertype-subtype]", "roles":[{"type":"si:[tmdm:supertype]", "player":"si:[gdl:TM-Value]"},{"type":"si:[tmdm:subtype]", "player":"si:[gdl:TM-Single-Type-Value]"}]}, + {"type":"si:[tmdm:supertype-subtype]", "roles":[{"type":"si:[tmdm:supertype]", "player":"si:[gdl:TM-Value]"},{"type":"si:[tmdm:subtype]", "player":"si:[gdl:TM-Multiple-Type-Value]"}]}, + {"type":"si:[tmdm:supertype-subtype]", "roles":[{"type":"si:[tmdm:supertype]", "player":"si:[gdl:TM-Value]"},{"type":"si:[tmdm:subtype]", "player":"si:[gdl:TM-Instance-Value]"}]}, + {"type":"si:[tmdm:supertype-subtype]", "roles":[{"type":"si:[tmdm:supertype]", "player":"si:[gdl:Default-TM-Value]"},{"type":"si:[tmdm:subtype]", "player":"si:[gdl:TM-Value]"}]}, + {"type":"si:[tmdm:supertype-subtype]", "roles":[{"type":"si:[tmdm:supertype]", "player":"si:[gdl:Default-TM-Value]"},{"type":"si:[tmdm:subtype]", "player":"si:[gdl:Default-Value]"}]}, + {"type":"si:[tmdm:supertype-subtype]", "roles":[{"type":"si:[tmdm:supertype]", "player":"si:[gdl:Default-Literal-Value]"},{"type":"si:[tmdm:subtype]", "player":"si:[gdl:Default-Value]"}]}, + {"type":"si:[tmdm:supertype-subtype]", "roles":[{"type":"si:[tmdm:supertype]", "player":"si:[gdl:Default-TM-Type-Value]"},{"type":"si:[tmdm:subtype]", "player":"si:[gdl:Default-TM-Type-Value]"}]}, + {"type":"si:[tmdm:supertype-subtype]", "roles":[{"type":"si:[tmdm:supertype]", "player":"si:[gdl:Default-TM-Type-Value]"},{"type":"si:[tmdm:subtype]", "player":"si:[gdl:Default-TM-Single-Type-Value]"}]}, + {"type":"si:[tmdm:supertype-subtype]", "roles":[{"type":"si:[tmdm:supertype]", "player":"si:[gdl:Default-TM-Type-Value]"},{"type":"si:[tmdm:subtype]", "player":"si:[gdl:Default-TM-Multiple-Type-Value]"}]}, {"type":"si:[tmdm:supertype-subtype]", "roles":[{"type":"si:[tmdm:supertype]", "player":"si:[gdl:TM-Value]"},{"type":"si:[tmdm:subtype]", "player":"si:[gdl:TM-Instance-Value]"}]}, {"type":"si:[tmdm:supertype-subtype]", "roles":[{"type":"si:[tmdm:supertype]", "player":"si:[gdl:TM-Value]"},{"type":"si:[tmdm:subtype]", "player":"si:[gdl:TM-Multiple-Type-Value]"}]}, {"type":"si:[tmdm:supertype-subtype]", "roles":[{"type":"si:[tmdm:supertype]", "player":"si:[gdl:Visible-Object]"},{"type":"si:[tmdm:subtype]", "player":"si:[gdl:Text-Object]"}]}, @@ -179,6 +210,9 @@ {"type":"si:[tmdm:supertype-subtype]", "roles":[{"type":"si:[tmdm:supertype]", "player":"si:[gdl:Descriptor]"},{"type":"si:[tmdm:subtype]", "player":"si:[gdl:Value-Group]"}]}, {"type":"si:[tmdm:supertype-subtype]", "roles":[{"type":"si:[tmdm:supertype]", "player":"si:[gdl:Descriptor]"},{"type":"si:[tmdm:subtype]", "player":"si:[gdl:Type]"}]}, {"type":"si:[tmdm:supertype-subtype]", "roles":[{"type":"si:[tmdm:supertype]", "player":"si:[tmcl:constraint]"},{"type":"si:[tmdm:subtype]", "player":"si:[tmcl:topic-name-constraint]"}]}, + {"type":"si:[tmdm:supertype-subtype]", "roles":[{"type":"si:[tmdm:supertype]", "player":"si:[doc:person-name]"},{"type":"si:[tmdm:subtype]", "player":"si:[doc:musician-name]"}]}, + {"type":"si:[tmdm:supertype-subtype]", "roles":[{"type":"si:[tmdm:supertype]", "player":"si:[doc:person-name]"},{"type":"si:[tmdm:subtype]", "player":"si:[doc:poet-name]"}]}, + {"type":"si:[tmdm:supertype-subtype]", "roles":[{"type":"si:[tmdm:supertype]", "player":"si:[doc:person-name]"},{"type":"si:[tmdm:subtype]", "player":"si:[doc:director-name]"}]}, {"type":"si:[gdl:contains]", "roles":[{"type":"si:[gdl:container]", "player":"si:[doc:test-schema]"},{"type":"si:[gdl:containee]", "player":"si:[doc:default-creator-topic-view-1]"}]}, {"type":"si:[gdl:contains]", "roles":[{"type":"si:[gdl:container]", "player":"si:[doc:test-schema]"},{"type":"si:[gdl:containee]", "player":"si:[doc:default-creator-topic-view-2]"}]}, {"type":"si:[gdl:contains]", "roles":[{"type":"si:[gdl:container]", "player":"si:[doc:test-schema]"},{"type":"si:[gdl:containee]", "player":"si:[doc:default-editor-topic-view]"}]},