[isidorus-cvs] r820 - branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base

lgiessmann at common-lisp.net lgiessmann at common-lisp.net
Fri Sep 2 09:59:11 UTC 2011


Author: lgiessmann
Date: Fri Sep  2 02:59:10 2011
New Revision: 820

Log:
gdl-frontend: Widgets: excluded the validation of literal-values of topic-names and topic-occurrences to a separate function

Modified:
   branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlVisibleObject.java

Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlVisibleObject.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlVisibleObject.java	Fri Sep  2 02:47:08 2011	(r819)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlVisibleObject.java	Fri Sep  2 02:59:10 2011	(r820)
@@ -2214,6 +2214,27 @@
 	public abstract ArrayList<String> getSelectedValues();
 	
 	
+	// validates names, occurrences and identifiers for tha passed value
+	private void validateLiteralValue(String selectedValue) throws InvalidContentException, InvalidGdlSchemaException{
+		ArrayList<Pattern> validLiteralValues = new ArrayList<Pattern>();
+		for (String literal : this.getLiterals()) validLiteralValues.add(new Pattern(literal));
+		if(validLiteralValues.size() == 0) validLiteralValues.add(new Pattern(this.getLiteralValueForConstraint()));	
+		int i = 0;
+		for( ; i != validLiteralValues.size(); ++i) if(validLiteralValues.get(i).matches(selectedValue)) break;
+		
+		if(TmHelper.isInstanceOf(this.getRootConstraint(), PSIs.TMCL.tmclTopicNameConstraint)){
+			if(i == validLiteralValues.size()) throw new InvalidContentException("the user data " + selectedValue + " for the topic-name " + TmHelper.getAnyIdOfTopic(TmHelper.getConstrainedStatement(this.getConstraint())) + " does not satisfy any of the constraints: " + Utils.arrayToString(validLiteralValues));
+		} else if(TmHelper.isInstanceOf(this.getRootConstraint(), PSIs.TMCL.tmclTopicOccurrenceConstraint)){
+			if(i == validLiteralValues.size()) throw new InvalidContentException("the user data " + selectedValue + " for the topic-occurrence " + TmHelper.getAnyIdOfTopic(TmHelper.getConstrainedStatement(this.getConstraint())) + " does not satisfy any of the constraints: " + Utils.arrayToString(validLiteralValues));
+		} else if(TmHelper.isInstanceOf(this.getRootConstraint(), PSIs.TMCL.tmclSubjectIdentifierConstraint)){
+			
+		} else if(TmHelper.isInstanceOf(this.getRootConstraint(), PSIs.TMCL.tmclSubjectLocatorConstraint)){
+			
+		} else if(TmHelper.isInstanceOf(this.getRootConstraint(), PSIs.TMCL.tmclItemIdentifierConstraint)){
+			
+		}
+	}
+	
 	// returns the actual data that is hold by this instance
 	public ArrayList<Pair<Construct, TopicMapsTypes>> getContent(Construct carrier, boolean validate) throws InvalidGdlSchemaException, ExecutionException, InvalidContentException {
 		ArrayList<Pair<Construct, TopicMapsTypes>> result = new ArrayList<Pair<Construct,TopicMapsTypes>>();
@@ -2222,10 +2243,6 @@
 		if(carrier == null) localCarrier = TmHelper.getNearestTopicOrAssociation(this);
 		
 		//TODO: finalise
-		ArrayList<Pattern> validLiteralValues = new ArrayList<Pattern>();
-		for (String literal : this.getLiterals()) validLiteralValues.add(new Pattern(literal));
-		if(validLiteralValues.size() == 0) validLiteralValues.add(new Pattern(this.getLiteralValueForConstraint()));		
-		
 		for (int idx = 0; idx != this.getSelectedValues().size(); ++idx){
 			if(TmHelper.isInstanceOf(this.getConstraint(), PSIs.TMCL.tmclItemIdentifierConstraint)){
 				
@@ -2233,18 +2250,14 @@
 				
 			} else if (TmHelper.isInstanceOf(this.getRootConstraint(), PSIs.TMCL.tmclSubjectLocatorConstraint)){
 				
-			} else if (TmHelper.isInstanceOf(this.getRootConstraint(), PSIs.TMCL.tmclTopicNameConstraint)){
+			} else if (TmHelper.isInstanceOf(this.getRootConstraint(), PSIs.TMCL.tmclTopicNameConstraint)){				
 				if(!(localCarrier instanceof Topic)) throw new ExecutionException("the constraint " + TmHelper.getAnyIdOfTopic(this.getRootConstraint()) + " must be bound to a Topic, but is: " + localCarrier.getClass());
 				Topic nameType = TmHelper.getConstrainedStatement(this.getConstraint());
 				JsArray<Name> names = ((Topic)localCarrier).getNames(nameType);				
 				
 				Name changedName = null;
 				if(this.getRootConstraint().equals(this.getConstraint())){
-					if(validate){
-						int i = 0;
-						for( ; i != validLiteralValues.size(); ++i) if(validLiteralValues.get(i).matches(this.getSelectedValues().get(idx))) break;
-						if(i == validLiteralValues.size()) throw new InvalidContentException("the user data " + this.getSelectedValues().get(idx) + " for the topic-name " + TmHelper.getAnyIdOfTopic(TmHelper.getConstrainedStatement(this.getConstraint())) + " does not satisfy any of the constraints: " + Utils.arrayToString(validLiteralValues));
-					}
+					if(validate) this.validateLiteralValue(this.getSelectedValues().get(idx)); 
 					
 					if(names.length() > idx){
 						changedName = names.get(idx);
@@ -2264,11 +2277,7 @@
 				
 				Occurrence changedOccurrence = null;
 				if(this.getRootConstraint().equals(this.getConstraint())){
-					if(validate){
-						int i = 0;
-						for( ; i != validLiteralValues.size(); ++i) if(validLiteralValues.get(i).matches(this.getSelectedValues().get(idx))) break;
-						if(i == validLiteralValues.size()) throw new InvalidContentException("the user data " + this.getSelectedValues().get(idx) + " for the topic-occurrence " + TmHelper.getAnyIdOfTopic(TmHelper.getConstrainedStatement(this.getConstraint())) + " does not satisfy any of the constraints: " + Utils.arrayToString(validLiteralValues));
-					}
+					if(validate) this.validateLiteralValue(this.getSelectedValues().get(idx)); 
 					
 					if(occurrences.length() > idx){
 						changedOccurrence = occurrences.get(idx);




More information about the Isidorus-cvs mailing list