[isidorus-cvs] r812 - in branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets: base button view
lgiessmann at common-lisp.net
lgiessmann at common-lisp.net
Tue Aug 30 12:45:14 UTC 2011
Author: lgiessmann
Date: Tue Aug 30 05:45:13 2011
New Revision: 812
Log:
gdl-frontend: Widgets: implemented the production of gdl:Hidden-Value instances when they are set to a gdlt:Role-Player instance
Modified:
branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlHiddenValue.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/button/GdlCommitButton.java
branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/view/GdlAssociationView.java
branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/view/GdlTopicView.java
Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlHiddenValue.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlHiddenValue.java Tue Aug 30 05:43:56 2011 (r811)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlHiddenValue.java Tue Aug 30 05:45:13 2011 (r812)
@@ -1,9 +1,11 @@
package us.isidor.gdl.anaToMia.Widgets.base;
+
import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Topic;
import us.isidor.gdl.anaToMia.Widgets.environment.ExecutionException;
import us.isidor.gdl.anaToMia.Widgets.environment.InvalidGdlSchemaException;
+
public class GdlHiddenValue {
protected Topic constraintTopic = null;
protected boolean constraintTopicSet = false;
@@ -14,15 +16,19 @@
protected Topic defaultLiteralValueTopic = null;
protected boolean defaultLiteralValueTopicSet = false;
protected Topic tmRepresentative = null;
+ protected boolean rawTmValuesSet = false;
+ protected Topic rawTmValue = null;
+ protected GdlVisibleObject owner = null;
@SuppressWarnings("unused")
private GdlHiddenValue(){}
- public GdlHiddenValue(Topic tmRepresentative) throws ExecutionException{
- if(tmRepresentative == null) throw new ExecutionException("tmRepresentative must no be null");
+ public GdlHiddenValue(Topic tmRepresentative, GdlVisibleObject owner) throws ExecutionException{
+ if(tmRepresentative == null || owner == null) throw new ExecutionException("tmRepresentative and owner must not be null");
this.tmRepresentative = tmRepresentative;
+ this.owner = owner;
}
@@ -90,4 +96,16 @@
else if(this.getDefaultLiteralValue() != null) return this.getDefaultLiteralValue();
else return this.getDefaultTmValue();
}
+
+
+ //returns the actual values represetned by the tmValues
+ public Topic getRawTmValue() throws InvalidGdlSchemaException{
+ if(this.rawTmValuesSet){
+ return this.rawTmValue;
+ } else {
+ this.rawTmValuesSet = true;
+ this.rawTmValue = TmHelper.getRawTmValueForHiddenValue(this.tmRepresentative, this.owner);
+ return this.rawTmValue;
+ }
+ }
}
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 Tue Aug 30 05:43:56 2011 (r811)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TmHelper.java Tue Aug 30 05:45:13 2011 (r812)
@@ -1425,4 +1425,25 @@
throw new ExecutionException("no topic found for the representation string: " + representation);
}
+
+
+ // Returns the actual default tm value for the corresponding hidden-value topic
+ public static Topic getRawTmValueForHiddenValue(Topic hiddenValue, GdlVisibleObject elem) throws InvalidGdlSchemaException{
+ ArrayList<Topic> result = new ArrayList<Topic>();
+ if(hiddenValue == null) return null;
+
+ Topic defaultTmValue = getDefaultTmValueOfHiddenValue(hiddenValue);
+ if(defaultTmValue != null){
+ result = getValuesForTmValue(defaultTmValue);
+ }else if(getDefaultLiteralValueOfHiddenValue(hiddenValue) != null){
+ return null;
+ } else {
+ if(elem == null) return null;
+ else result.add(getNearestTopic(elem));
+ }
+
+ if(result.size() > 1) throw new InvalidGdlSchemaException("the hidden value " + getAnyIdOfTopic(hiddenValue) + " represents more than one particular value: " + result.size());
+ else if(result.size() == 1) return result.get(0);
+ else return null;
+ }
}
Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/button/GdlCommitButton.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/button/GdlCommitButton.java Tue Aug 30 05:43:56 2011 (r811)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/button/GdlCommitButton.java Tue Aug 30 05:45:13 2011 (r812)
@@ -37,8 +37,8 @@
@Override
public void onClick(ClickEvent event) {
try{
- this.owner.getGdlParent().getContent(null);
-
+ Window.alert(" >> " + this.owner.getGdlParent().getContent(null).size());
+
// TODO: implement
}catch(Exception e){
e.printStackTrace();
Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/view/GdlAssociationView.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/view/GdlAssociationView.java Tue Aug 30 05:43:56 2011 (r811)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/view/GdlAssociationView.java Tue Aug 30 05:45:13 2011 (r812)
@@ -2,6 +2,7 @@
import java.util.ArrayList;
import com.google.gwt.core.client.JsArray;
+import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;
@@ -12,6 +13,7 @@
import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.TopicMap;
import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.TopicMapsTypes;
import us.isidor.gdl.anaToMia.Widgets.base.ButtonableObject;
+import us.isidor.gdl.anaToMia.Widgets.base.GdlHiddenValue;
import us.isidor.gdl.anaToMia.Widgets.base.GdlVisibleObject;
import us.isidor.gdl.anaToMia.Widgets.base.PSIs;
import us.isidor.gdl.anaToMia.Widgets.base.TmHelper;
@@ -197,7 +199,29 @@
}
}
- // TODO: process hidden values
+ // process hidden values
+ for (Topic hd : this.getHiddenValues()) {
+ GdlHiddenValue hdv = new GdlHiddenValue(hd, this);
+ if(TmHelper.isInstanceOf(hdv.getConstraint(), PSIs.GDL.TopicType.gdlRolePlayer)){
+ if(!TmHelper.isInstanceOf(hdv.getRootConstraint(), PSIs.TMCL.tmclTopicRoleConstraint)) throw new InvalidGdlSchemaException("the constraint " + TmHelper.getAnyIdOfTopic(hdv.getConstraint()) + " must be bound to an instance of " + PSIs.TMCL.tmclTopicRoleConstraint + ", but is: " + TmHelper.getAnyIdOfTopic(hdv.getRootConstraint()));
+ for (Pair<Construct, TopicMapsTypes> pair : result) {
+ if(pair.getSecond().equals(TopicMapsTypes.Association)){
+ Association assoc = (Association)pair.getFirst();
+ Topic player = hdv.getRawTmValue();
+ if(player == null) throw new InvalidGdlSchemaException("the hidden value " + TmHelper.getAnyIdOfTopic(hd) + " must be bound to exactly one topic, but is unbound");
+ assoc.createRole(TmHelper.getConstrainedRoleAndPlayerTypeOfConstraint(hdv.getRootConstraint()).getFirst(), player);
+ }
+ }
+ }
+
+ // TODO: implement
+ // reifier => topic-role
+ // item-identifeir => topic-role
+ // type => association-role
+ // reifier => association-role
+ // item-identifier => association-role
+ // scope => assocition-role
+ }
return result;
}
Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/view/GdlTopicView.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/view/GdlTopicView.java Tue Aug 30 05:43:56 2011 (r811)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/view/GdlTopicView.java Tue Aug 30 05:45:13 2011 (r812)
@@ -91,7 +91,20 @@
}
}
- // TODO: process hidden values
+ for (@SuppressWarnings("unused") Topic hd : this.getHiddenValues()) {
+ // TODO: process hidden values
+ // subject-identifier
+ // subject-locator
+ // item-identifier
+ // topic-name
+ // variant-name
+ // topic-occurrence
+ // type => topic-name
+ // type => topic-occurrence
+ // datatype => topic-occurrence
+ // scope => topic-name
+ // scope => topic-occurrence
+ }
return result;
}
More information about the Isidorus-cvs
mailing list