Author: lgiessmann Date: Thu Jul 28 03:31:02 2011 New Revision: 688
Log: gdl-frontend: Widgets: implemented the static method TmHelper.getValueConstraintOfValueGroup(Topic valueGroup) that can be used by all visible elements to retrieve the bound tmcl or gdl contraint instance to their gdl:Value-Group instance
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/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/base/GdlPsis.java ============================================================================== --- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlPsis.java Thu Jul 28 02:23:24 2011 (r687) +++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlPsis.java Thu Jul 28 03:31:02 2011 (r688) @@ -17,6 +17,7 @@ // some psis of the TMCL public class TMCL { public final static String topictype = "http://psi.topicmaps.org/tmcl/topic-type"; + public final static String constraint = "http://psi.topicmaps.org/tmcl/constraint"; }
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 02:23:24 2011 (r687) +++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/IGdlHasValueGroup.java Thu Jul 28 03:31:02 2011 (r688) @@ -12,6 +12,13 @@ // returns the constraint that is bound to the value group topic public Topic getConstraint() throws InvalidGdlSchemaException; + + // returns the constraint that is at the root position, e.g. + // a value-group is bound to gdl:Type and the gdl:Type is bound + // to a tmcl:name-constraint. in this case the gdl:Type is specified + // as the constraint and tmcl:name-constraint is set as the + // root constraint + public Topic getRootConstraint() throws InvalidGdlSchemaException; // returns all topics that are set as default values for this value group public ArrayList<Topic> getDefaultTmValues() throws InvalidGdlSchemaException;
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 02:23:24 2011 (r687) +++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TmHelper.java Thu Jul 28 03:31:02 2011 (r688) @@ -610,4 +610,27 @@ else if(valueGroups.size() == 0) return null; else throw new InvalidGdlSchemaException("the topic " + getAnyIdOfTopic(visibleElement) + " must be bound none or once to a value group, but is: " + valueGroups.size()); } + + + // returns the direct constraint a value group is bound to + public static Topic getConstraintOfValueGroup(Topic valueGroup) throws InvalidGdlSchemaException{ + if(valueGroup == null) return null; + + TopicMap tm = valueGroup.getTopicMap(); + Topic valueGroupRoleType = getTopicByPsi(GdlPsis.RoleType.gdlValueGroup, tm); + Topic descriptorType = getTopicByPsi(GdlPsis.TopicType.gdlDescriptor, tm); + Topic tmBindingAssocType = getTopicByPsi(GdlPsis.AssociationType.gdlTmBinding, tm); + Topic tmclConstraintType = getTopicByPsi(GdlPsis.TMCL.constraint, tm); + Topic tmConstructRoleType = getTopicByPsi(GdlPsis.RoleType.gdlTmConstruct, tm); + ArrayList<Topic> tmclConstraints = getOtherPlayerOfBinaryAssociation(valueGroup, valueGroupRoleType, tmBindingAssocType, null, tmclConstraintType, tmConstructRoleType); + + ArrayList<Topic> gdlConstraints = getOtherPlayerOfBinaryAssociation(valueGroup, valueGroupRoleType, tmBindingAssocType, null, descriptorType, tmConstructRoleType); + + if(tmclConstraints.size() > 1 || gdlConstraints.size() > 1 || (tmclConstraints.size() == 1 && gdlConstraints.size() == 1)) + throw new InvalidGdlSchemaException("the topic " + getAnyIdOfTopic(valueGroup) + " can be bound only to one constraint, but is " + (tmclConstraints.size() + gdlConstraints.size())); + + if(tmclConstraints.size() == 1) return tmclConstraints.get(0); + else if (gdlConstraints.size() == 1) return gdlConstraints.get(0); + else 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 02:23:24 2011 (r687) +++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/text/GdlText.java Thu Jul 28 03:31:02 2011 (r688) @@ -820,6 +820,13 @@
@Override public Topic getConstraint() throws InvalidGdlSchemaException { + Topic valueGroup = this.getValueGroup(); + return valueGroup == null ? null : TmHelper.getConstraintOfValueGroup(valueGroup); + } + + + @Override + public Topic getRootConstraint() throws InvalidGdlSchemaException { // TODO Auto-generated method stub return null; }
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 02:23:24 2011 (r687) +++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/war/gdl_widgets/test.gdl.jtm Thu Jul 28 03:31:02 2011 (r688) @@ -30,6 +30,7 @@ {"subject_identifiers":["[gdl:Visible-Object]"]}, {"subject_identifiers":["[gdl:Value-Group]"]}, {"subject_identifiers":["[gdl:Text-Object]"]}, + {"subject_identifiers":["[gdl:Type]"]}, {"subject_identifiers":["[gdl:Position]"]}, {"subject_identifiers":["[gdl:position]"], "instance_of":["si:[tmcl:association-type]"]}, {"subject_identifiers":["[doc:value-group-person-name]"], "instance_of":["si:[gdl:Value-Group]"]}, @@ -67,6 +68,7 @@ {"subject_identifiers":["[gdl:Title]"]}, {"subject_identifiers":["[gdl:Reference]"]}, {"subject_identifiers":["[gdl:List]"]}, + {"subject_identifiers":["[doc:person-name-type-constraint]"], "instance_of":["si:[gdl:Type]"]}, {"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"}]}, {"subject_identifiers":["[doc:unit-1-check-box]"], "instance_of":["si:[gdl:Check-Box]"], "occurrences":[{"type":"si:[gdl:id]", "value":"unit_1_check_box_id"},{"type":"si:[gdl:content-orientation]", "value":"vertical"}, {"type":"si:[gdl:background-color]", "value": "lime"}, {"type":"si:[gdl:margin]", "value":"30pt"}, {"type":"si:[gdl:font-size]", "value":"8pt"}]}, {"subject_identifiers":["[doc:unit-1-action-button]"], "instance_of":["si:[gdl:Action-Button]"], "occurrences":[{"type":"si:[gdl:id]","value":"unit_1_action_button"}]}, @@ -170,6 +172,7 @@ {"type":"si:[tmdm:supertype-subtype]", "roles":[{"type":"si:[tmdm:supertype]", "player":"si:[gdl:Action-Button]"},{"type":"si:[tmdm:subtype]", "player":"si:[gdl:Delete-Button]"}]}, {"type":"si:[tmdm:supertype-subtype]", "roles":[{"type":"si:[tmdm:supertype]", "player":"si:[gdl:Action-Button]"},{"type":"si:[tmdm:subtype]", "player":"si:[gdl:Create-Button]"}]}, {"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:[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]"}]}, @@ -219,5 +222,6 @@ {"type":"si:[gdl:button-position]", "roles":[{"type":"si:[gdl:nth-element]", "player":"si:[doc:nth-elem-crt-btn]"},{"type":"si:[gdl:action-button]", "player":"si:[doc:unit-1-text-create-button]"}]}, {"type":"si:[gdl:button-position]", "roles":[{"type":"si:[gdl:nth-element]", "player":"si:[doc:nth-elem-del-btn]"},{"type":"si:[gdl:action-button]", "player":"si:[doc:unit-1-text-delete-button]"}]}, {"type":"si:[gdl:contains]", "roles":[{"type":"si:[gdl:container]", "player":"si:[doc:unit-1-reference]"},{"type":"si:[gdl:containee]", "player":"si:[doc:info-1]"}]}, - {"type":"si:[gdl:view-binding]", "roles":[{"type":"si:[gdl:value-group]", "player":"si:[doc:value-group-person-name]"},{"type":"si:[gdl:descriptor]", "player":"si:[doc:text-1]"}]} + {"type":"si:[gdl:view-binding]", "roles":[{"type":"si:[gdl:value-group]", "player":"si:[doc:value-group-person-name]"},{"type":"si:[gdl:descriptor]", "player":"si:[doc:text-1]"}]}, + {"type":"si:[gdl:tm-binding]", "roles":[{"type":"si:[gdl:value-group]", "player":"si:[doc:value-group-person-name]"},{"type":"si:[gdl:tm-construct]", "player":"si:[doc:person-name-type-constraint]"}]} ]} \ No newline at end of file