[isidorus-cvs] r771 - in branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets: base view

lgiessmann at common-lisp.net lgiessmann at common-lisp.net
Mon Aug 22 14:26:38 UTC 2011


Author: lgiessmann
Date: Mon Aug 22 07:26:37 2011
New Revision: 771

Log:
gdl-frontend: Widgets: implemented some helpers to comsume associations by GdlAssociationView instances

Modified:
   branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/PSIs.java
   branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TestClass.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/base/Utils.java
   branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/view/GdlAssociationView.java

Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/PSIs.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/PSIs.java	Mon Aug 22 06:51:31 2011	(r770)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/PSIs.java	Mon Aug 22 07:26:37 2011	(r771)
@@ -21,7 +21,7 @@
 		public final static String tmclNameType = tmcl + "name-type";
 		public final static String tmclOccurrenceType = tmcl + "occurrence-type";
 		public final static String tmclAssociationType = tmcl + "association-type";
-		public final static String tmclRoleType = "tmcl" + "role-type";
+		public final static String tmclRoleType = tmcl + "role-type";
 		public final static String tmclConstraint = tmcl + "constraint";
 		public final static String tmclConstrained = tmcl + "constrained";
 		public final static String tmclConstrainedStatement = tmcl + "constrained-statement";
@@ -45,6 +45,7 @@
 		public final static String tmclItemIdentifierConstraint = tmcl + "item-identifier-constraint";
 		public final static String tmclConstrainedTopicType = tmcl + "constrained-topic-type";
 		public final static String tmclConstrainedRole = tmcl + "constrained-role";
+		public final static String tmclRoleCombinationConstraint = tmcl + "role-combination-constraint";
 	}
 	
 	

Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TestClass.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TestClass.java	Mon Aug 22 06:51:31 2011	(r770)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TestClass.java	Mon Aug 22 07:26:37 2011	(r771)
@@ -27,22 +27,22 @@
 			mainPanel.setBorderWidth(1);
 			mainPanel.setPixelSize(1000, 600);
 			
-			ArrayList<Pair<String, TopicIdentifierTypes>> requestedTopicsToCreate = new ArrayList<Pair<String,TopicIdentifierTypes>>();
-			requestedTopicsToCreate.add(new Pair<String, TopicIdentifierTypes>("http://textgrid.org/serviceregistry/model/types/Hash-Object", TopicIdentifierTypes.SubjectIdentifier));
+			//ArrayList<Pair<String, TopicIdentifierTypes>> requestedTopicsToCreate = new ArrayList<Pair<String,TopicIdentifierTypes>>();
+			//requestedTopicsToCreate.add(new Pair<String, TopicIdentifierTypes>("http://textgrid.org/serviceregistry/model/types/Hash-Object", TopicIdentifierTypes.SubjectIdentifier));
 			//requestedTopicsToCreate.add(new Pair<String, TopicIdentifierTypes>("http://textgrid.org/serviceregistry/model/types/Environment", TopicIdentifierTypes.SubjectIdentifier));
 			//requestedTopicsToCreate.add(new Pair<String, TopicIdentifierTypes>("http://psi.test.org/gdl-test/Poet", TopicIdentifierTypes.SubjectIdentifier));
 			//requestedTopicsToCreate.add(new Pair<String, TopicIdentifierTypes>("http://psi.test.org/gdl-test/Musician", TopicIdentifierTypes.SubjectIdentifier));
 			
 			//Pair<String, TopicIdentifierTypes> requestedTopicToEdit = new Pair<String, TopicIdentifierTypes>("http://textgrid.org/serviceregistry/model/types/test-env", TopicIdentifierTypes.SubjectIdentifier);
 			//Pair<String, TopicIdentifierTypes> requestedTopicToEdit = new Pair<String, TopicIdentifierTypes>("http://textgrid.org/serviceregistry/model/types/test-hash", TopicIdentifierTypes.SubjectIdentifier);
-			//Pair<String, TopicIdentifierTypes> requestedTopicToEdit = new Pair<String, TopicIdentifierTypes>("http://textgrid.org/serviceregistry/test-hash-2", TopicIdentifierTypes.SubjectIdentifier);
+			Pair<String, TopicIdentifierTypes> requestedTopicToEdit = new Pair<String, TopicIdentifierTypes>("http://textgrid.org/serviceregistry/test-hash-2", TopicIdentifierTypes.SubjectIdentifier);
 			GdlPanel.addClickHandler("unit_1_text_create_button_id", new ClickHandler() {
 				@Override
 				public void onClick(ClickEvent event) {
 					Window.alert("you clicked " + ((Button)event.getSource()).getText());
 				}
 			});
-			gdlPanel = new GdlPanel(null, requestedTopicsToCreate);
+			gdlPanel = new GdlPanel(requestedTopicToEdit, null);
 			mainPanel.add(gdlPanel);
 			gdlPanel.setTmEngine(new JtmsTmEngine());
 			gdlPanel.setLoadSchemaCallback(new LoadSchemaCallback());

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	Mon Aug 22 06:51:31 2011	(r770)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TmHelper.java	Mon Aug 22 07:26:37 2011	(r771)
@@ -10,7 +10,6 @@
 import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.ScopedStub;
 import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Topic;
 import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.TopicMap;
-import us.isidor.gdl.anaToMia.Widgets.base.PSIs.TMDM;
 import us.isidor.gdl.anaToMia.Widgets.environment.ExecutionException;
 import us.isidor.gdl.anaToMia.Widgets.environment.InvalidGdlSchemaException;
 import us.isidor.gdl.anaToMia.Widgets.environment.Pair;
@@ -167,9 +166,9 @@
 		ArrayList<Topic> result = new ArrayList<Topic>();
 		if(top == null) return result;
 		TopicMap tm = top.getTopicMap();
-		Topic subtype = getTopicByPsi(TMDM.subtype, tm);
-		Topic supertype = getTopicByPsi(TMDM.supertype, tm);
-		Topic supertypeSubtype = getTopicByPsi(TMDM.supertypeSubtype, tm);
+		Topic subtype = getTopicByPsi(PSIs.TMDM.subtype, tm);
+		Topic supertype = getTopicByPsi(PSIs.TMDM.supertype, tm);
+		Topic supertypeSubtype = getTopicByPsi(PSIs.TMDM.supertypeSubtype, tm);
 		
 		if(subtype == null || supertype == null || supertypeSubtype == null) return result;
 		
@@ -633,6 +632,22 @@
 	}
 
 	
+	// returns the constrained role-types of the passed constraint
+	public static Topic getConstraintRolesOfConstraint(Topic topicRoleOrAssociationRoleConstraint) throws InvalidGdlSchemaException {
+		if(topicRoleOrAssociationRoleConstraint == null) return null;
+		
+		TopicMap tm = topicRoleOrAssociationRoleConstraint.getTopicMap();
+		Topic constraintRoleType = getTopicByPsi(PSIs.TMCL.tmclConstraint, tm);
+		Topic constrainedRoleAssocType = getTopicByPsi(PSIs.TMCL.tmclConstrainedRole, tm);
+		Topic constrainedRoleType = getTopicByPsi(PSIs.TMCL.tmclConstrained, tm);
+		Topic roleType = getTopicByPsi(PSIs.TMCL.tmclRoleType, tm);
+		ArrayList<Topic> result = getOtherPlayerOfBinaryAssociation(topicRoleOrAssociationRoleConstraint, constraintRoleType, constrainedRoleAssocType, null, roleType, constrainedRoleType);
+		
+		if(result.size() != 1) throw new InvalidGdlSchemaException("the topic " + getAnyIdOfTopic(topicRoleOrAssociationRoleConstraint) + " must be bound exactly once to a role-type via a " + PSIs.TMCL.tmclConstrainedRole + " association, but is bound: " + result.size());
+		else return result.get(0);
+	}
+	
+	
 	// returns the topic that plays the role of tmcl:constrained in an association
 	// of the type tmcl:constrained-statement that is bound to the passed topic
 	// constrinatTopic that plays the role of tmcl:constraint
@@ -649,13 +664,59 @@
 		ArrayList<Topic> constrainedNameTypes = getOtherPlayerOfBinaryAssociation(constraintTopic, constraintRoleType, constrainedStatementAssocType, null, nameType, constrainedRoleType);
 		ArrayList<Topic> constrainedOccurrenceTypes = getOtherPlayerOfBinaryAssociation(constraintTopic, constraintRoleType, constrainedStatementAssocType, null, occurrenceType, constrainedRoleType);
 		ArrayList<Topic> constrainedAssociationTypes = getOtherPlayerOfBinaryAssociation(constraintTopic, constraintRoleType, constrainedStatementAssocType, null, associationType, constrainedRoleType);
-		
-		ArrayList<Topic> constrainedStatements = Utils.merge(Utils.merge(constrainedNameTypes, constrainedOccurrenceTypes), constrainedAssociationTypes);
+		ArrayList<Topic> constrainedStatements = Utils.merge(Utils.merge(constrainedNameTypes, constrainedOccurrenceTypes), constrainedAssociationTypes); 
 		
 		if(constrainedStatements.size() != 1) throw new InvalidGdlSchemaException("the topic " + getAnyIdOfTopic(constraintTopic) + " must be bound exactly once to a statement topic via a " + PSIs.TMCL.tmclConstrainedStatement + " association, but is: " + constrainedStatements.size());
 		else return constrainedStatements.get(0);
 	}
 	
+	
+	// Returns the role-combination-constraints for the passed association-type
+	public static ArrayList<Topic> getRoleCombinationConstraints(Topic associationType){
+		if(associationType == null) return new ArrayList<Topic>();
+		
+		TopicMap tm = associationType.getTopicMap();
+		Topic constrainedRoleType = getTopicByPsi(PSIs.TMCL.tmclConstraint, tm);
+		Topic constrainedStatementAssocType = getTopicByPsi(PSIs.TMCL.tmclConstrainedStatement, tm);
+		Topic constraintRoleType = getTopicByPsi(PSIs.TMCL.tmclConstraint, tm);
+		Topic roleCombinationConstraintType = getTopicByPsi(PSIs.TMCL.tmclRoleCombinationConstraint, tm);
+		return getOtherPlayerOfBinaryAssociation(associationType, constrainedRoleType, constrainedStatementAssocType, null, roleCombinationConstraintType, constraintRoleType);
+	}
+	
+	
+	// Returns the tmcl:association-role-constraints that are bound to the passed topic, that is
+	// the Topic Maps representative of an gdl:association-view
+	public static ArrayList<Topic> getAssociationRoleConstraintsForView(Topic viewRepresentative) throws InvalidGdlSchemaException {
+		if(viewRepresentative == null) new ArrayList<Topic>();
+		
+		TopicMap tm = viewRepresentative.getTopicMap();
+		Topic descriptorRoleType = getTopicByPsi(PSIs.RoleType.gdlDescriptor, tm);
+		Topic associationViewBindingAssocType = getTopicByPsi(PSIs.AssociationType.gdlAssociationViewBinding, tm);
+		Topic tmConstructRoleType = getTopicByPsi(PSIs.RoleType.gdlTmConstruct, tm);
+		Topic associationRoleConstraintType = getTopicByPsi(PSIs.TMCL.tmclAssociationRoleConstraint, tm);
+		ArrayList<Topic> result = getOtherPlayerOfBinaryAssociation(viewRepresentative, descriptorRoleType, associationViewBindingAssocType, null, associationRoleConstraintType, tmConstructRoleType);
+				
+		if(result.size() == 0) throw new InvalidGdlSchemaException("the topic " + getAnyIdOfTopic(viewRepresentative) + " must be bound to at least one " + PSIs.TMCL.tmclAssociationRoleConstraint + ", but is unbound");
+		else return result;
+	}
+	
+	
+	// Returns the tmcl:topic-role-constraints that are bound to the passed topic, that is
+	// the Topic Maps representative of an gdl:association-view
+	public static ArrayList<Topic> getTopicRoleConstraintsForView(Topic viewRepresentative) throws InvalidGdlSchemaException {
+		if(viewRepresentative == null) new ArrayList<Topic>();
+		
+		TopicMap tm = viewRepresentative.getTopicMap();
+		Topic descriptorRoleType = getTopicByPsi(PSIs.RoleType.gdlDescriptor, tm);
+		Topic associationViewBindingAssocType = getTopicByPsi(PSIs.AssociationType.gdlAssociationViewBinding, tm);
+		Topic tmConstructRoleType = getTopicByPsi(PSIs.RoleType.gdlTmConstruct, tm);
+		Topic topicRoleConstraintType = getTopicByPsi(PSIs.TMCL.tmclTopicRoleConstraint, tm);
+		ArrayList<Topic> result = getOtherPlayerOfBinaryAssociation(viewRepresentative, descriptorRoleType, associationViewBindingAssocType, null, topicRoleConstraintType, tmConstructRoleType);
+				
+		if(result.size() == 0) throw new InvalidGdlSchemaException("the topic " + getAnyIdOfTopic(viewRepresentative) + " must be bound to at least one " + PSIs.TMCL.tmclTopicRoleConstraint + ", but is unbound");
+		else return result;
+	}
+	
 
 	// returns the root constraint of a gdl:Value-Group instance, i.e. a tmcl constraint.
 	// E.g. a value group may be bound to a gdl:Type constraint and this constraint may be bound
@@ -914,6 +975,35 @@
 	}
 	
 	
+	// Returns all tmcl:topic-role-constraint that the types of this topic
+	// are bound to
+	public static ArrayList<Topic> getTopicRoleConstraintsForTopicInstance(Topic topicInstance){
+		ArrayList<Topic> result = new ArrayList<Topic>();
+		if(topicInstance == null) return result;
+		
+		JsArray<Topic> topicTypes = topicInstance.getTypes();
+		for(int i = 0; i != topicTypes.length(); ++i){
+			ArrayList<Topic> resultForType = getTopicRoleConstraintsForTopicType(topicTypes.get(i));
+			result = Utils.merge(result, resultForType);
+		}
+		
+		return result;
+	}
+	
+	
+	// Returns all tmcl:topic-role-constraints the the passed topic is bound to
+	public static ArrayList<Topic> getTopicRoleConstraintsForTopicType(Topic topicType){
+		if(topicType == null) return new ArrayList<Topic>();
+		
+		TopicMap tm = topicType.getTopicMap();
+		Topic constrainedRoleType = getTopicByPsi(PSIs.TMCL.tmclConstrained, tm);
+		Topic constrainedTopicTypeAssocType = getTopicByPsi(PSIs.TMCL.tmclConstrainedTopicType, tm);
+		Topic constraintRoleType = getTopicByPsi(PSIs.TMCL.tmclConstraint, tm);
+		Topic topicRoleConstraintType = getTopicByPsi(PSIs.TMCL.tmclTopicRoleConstraint, tm);
+		return getOtherPlayerOfBinaryAssociation(topicType, constrainedRoleType, constrainedTopicTypeAssocType, null, topicRoleConstraintType, constraintRoleType);
+	}
+	
+	
 	// return the occurrence of the passed type, if the topic contains more than one such occurrences, 
 	// this function throws a InvalidgdlSchemaException 
 	public static Occurrence getSingleOccurrence(Topic topic, Topic occurrenceType) throws InvalidGdlSchemaException {

Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/Utils.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/Utils.java	Mon Aug 22 06:51:31 2011	(r770)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/Utils.java	Mon Aug 22 07:26:37 2011	(r771)
@@ -21,6 +21,17 @@
 			
 		return true;
 	}
+	
+	
+	// returns a list that contains a union of both lists
+	public static <T> ArrayList<T> union(ArrayList<T> fst, ArrayList<T> snd){
+		ArrayList<T> result = new ArrayList<T>();
+		if(fst == null || snd == null) return result;
+		
+		for (T t : fst)	if(snd.contains(t)) result.add(t);
+		
+		return result;
+	}
 
 	
 	// returns an ArrayList that is a merged ArrayList of fst and snd

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	Mon Aug 22 06:51:31 2011	(r770)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/view/GdlAssociationView.java	Mon Aug 22 07:26:37 2011	(r771)
@@ -2,40 +2,138 @@
 
 import java.util.ArrayList;
 
+import com.google.gwt.user.client.Window;
+
 import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Association;
 import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Topic;
+import us.isidor.gdl.anaToMia.Widgets.base.PSIs;
+import us.isidor.gdl.anaToMia.Widgets.base.TmHelper;
+import us.isidor.gdl.anaToMia.Widgets.base.Utils;
 import us.isidor.gdl.anaToMia.Widgets.environment.ExecutionException;
 import us.isidor.gdl.anaToMia.Widgets.environment.InvalidGdlSchemaException;
 
 
 public abstract class GdlAssociationView extends GdlView {
 	protected ArrayList<Association> associationsToRepresent = null;
+	private ArrayList<Topic> associationRoleConstraints = new ArrayList<Topic>();
+	private boolean associationRoleconstraintsSet = false;
+	private ArrayList<Topic> topicRoleConstraints = new ArrayList<Topic>();
+	private boolean topicRoleConstraintsSet = false;
+	private Topic associationType = null;
+	private boolean associationTypeSet = false;
+	private ArrayList<Topic> roleTypes = new ArrayList<Topic>();
+	private boolean roleTypesSet = false;
+	private ArrayList<Topic> roleCombinationConstraints = new ArrayList<Topic>();
+	private boolean roleCombinationConstraintsSet = false;
+	
 
 	public GdlAssociationView(Topic tmRepresentative, Topic receivedData) throws InvalidGdlSchemaException, ExecutionException {
-		super(tmRepresentative, null);
-		// TODO: set the associationsToRepresent array by using
-		//       the associations the passed topic is a player of
-		//       and the constraints that are bound to this element's
-		//       value-group instance
+		super(tmRepresentative, receivedData);
+		Window.alert("constraints: " +this.getRoleTypes().size() + " >> " + (this instanceof GdlEditorAssociationView));
+		
+		if(this instanceof GdlEditorAssociationView) this.associationsToRepresent = this.filterAssociations();
 	}
 	
 	
-	// return the association-type that this element is bound to through the
-	// set association-role- and topic-role- constraints
-	public Topic getAssociationType() throws InvalidGdlSchemaException {
-		// TODO: implement
-		return null;
+	// Return the association-role-constraints this view is bound to
+	public ArrayList<Topic> getAssociationRoleConstraints() throws InvalidGdlSchemaException {
+		if(this.associationRoleconstraintsSet){
+			return this.associationRoleConstraints;
+		} else {
+			this.associationRoleconstraintsSet = true;
+			this.associationRoleConstraints = TmHelper.getAssociationRoleConstraintsForView(this.tmRepresentative);
+			return this.associationRoleConstraints;
+		}
 	}
 	
 	
-	public ArrayList<Topic> getAssociationRoleConstraints(){
-		// TODO: implement
-		return null;
+	// Return the topic-role-constraints this view is bound to
+	public ArrayList<Topic> getTopicRoleConstraints() throws InvalidGdlSchemaException {
+		if(this.topicRoleConstraintsSet){
+			return this.topicRoleConstraints;
+		} else {
+			this.topicRoleConstraintsSet = true;
+			this.topicRoleConstraints = TmHelper.getTopicRoleConstraintsForView(this.tmRepresentative);
+			return this.topicRoleConstraints;
+		}
+	}
+	
+	
+	// Returns the role-combination-constraints of the association-
+	// type that is bound to this association-view via the bound
+	// constraints
+	public ArrayList<Topic> getRoleCombinationConstraints() throws InvalidGdlSchemaException {
+		if(this.roleCombinationConstraintsSet){
+			return this.roleCombinationConstraints;
+		} else {
+			this.roleCombinationConstraintsSet = true;
+			this.roleCombinationConstraints = TmHelper.getRoleCombinationConstraints(this.getAssociationType());
+			return this.roleCombinationConstraints;
+		}
 	}
 	
 	
-	public ArrayList<Topic> getTopicRoleConstraints(){
-		// TODO: implement
+	// returns the role-types that are valid to be used
+	// in associations of the type that is bound to this view
+	public ArrayList<Topic> getRoleTypes() throws InvalidGdlSchemaException {
+		if(this.roleTypesSet){
+			return this.roleTypes;
+		} else {
+			this.roleTypesSet = true;
+			ArrayList<Topic> roleTypesOfAssociationRoleConstraints = new ArrayList<Topic>();
+			for (Topic constraint : this.getAssociationRoleConstraints()){
+				Topic top = TmHelper.getConstraintRolesOfConstraint(constraint);
+				if(!roleTypesOfAssociationRoleConstraints.contains(top)) roleTypesOfAssociationRoleConstraints.add(top);
+			}
+			
+			ArrayList<Topic> roleTypesOfTopicRoleConstraints = new ArrayList<Topic>();
+			for (Topic constraint : this.getTopicRoleConstraints()){
+				Topic top = TmHelper.getConstraintRolesOfConstraint(constraint);
+				if(!roleTypesOfTopicRoleConstraints.contains(top)) roleTypesOfTopicRoleConstraints.add(top);
+			}
+			
+			return Utils.union(roleTypesOfAssociationRoleConstraints, roleTypesOfTopicRoleConstraints);
+		}
+	}
+	
+	
+	// returns the association type that is valid with respect to the
+	// topic- and the association-role-constraints that are bound to this view
+	public Topic getAssociationType() throws InvalidGdlSchemaException {
+		if(this.associationTypeSet){
+			return this.associationType;
+		} else {
+			this.associationTypeSet = true;
+			ArrayList<Topic> assocTypes = new ArrayList<Topic>();
+			for (Topic constraint : this.getAssociationRoleConstraints()){
+				Topic top = TmHelper.getConstrainedStatement(constraint);
+				if(!assocTypes.contains(top)) assocTypes.add(top);
+			}
+			
+			for (Topic constraint : this.getTopicRoleConstraints()){
+				Topic top = TmHelper.getConstrainedStatement(constraint);
+				if(!assocTypes.contains(top)) assocTypes.add(top);
+			}
+			
+			if(assocTypes.size() != 1){
+				String bindings = "[";
+				for (Topic topic : assocTypes)
+					bindings += TmHelper.getAnyIdOfTopic(topic) + ", ";
+				if(bindings.length() == 1) bindings = "[ ]";
+				else bindings = bindings.substring(0, bindings.length() - 2) + "]";
+				throw new InvalidGdlSchemaException("the association-view " + TmHelper.getAnyIdOfTopic(this.tmRepresentative) + " must be bound to topic-role-constraints and association-rle-constraints that own the same constrained-statement, but found the constrained-statements: " + bindings);
+			}
+			
+			this.associationType = assocTypes.get(0);
+			return this.associationType;
+		}
+	}
+	
+	
+	
+	public ArrayList<Association> filterAssociations(){
+		// TODO: implement => returns an array with associations that
+		//       must be represetned by this association view
 		return null;
 	}
 }




More information about the Isidorus-cvs mailing list