Author: lgiessmann Date: Tue Oct 25 02:03:42 2011 New Revision: 1015
Log: gdl-frontend: Widgets: implemented the tmcl:subject-identifier-constraint and tmcl:subject-locator-constraint semantics for generating content entered in GdlVisibleObject
Modified: trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlPanel.java trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlVisibleObject.java trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TestClass.java trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TmHelper.java trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/environment/ICommitCallback.java trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/environment/IDeleteCallback.java trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/isidorus/CommitCallback.java trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/isidorus/DeleteCallback.java trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/view/GdlAssociationView.java trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/view/GdlTopicView.java
Modified: trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlPanel.java ============================================================================== --- trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlPanel.java Thu Oct 20 02:23:09 2011 (r1014) +++ trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlPanel.java Tue Oct 25 02:03:42 2011 (r1015) @@ -2,7 +2,6 @@
import java.util.ArrayList; import us.isidor.gdl.anaToMia.TopicMaps.TmEngineModel.TmEngine; -import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Construct; import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.TopicMap; import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.TopicMapsTypes; import us.isidor.gdl.anaToMia.Widgets.environment.ExecutionException; @@ -210,8 +209,8 @@ if(this.commitCallback == null){ throw new ExecutionException("No CommitCallback was set yet"); } - ArrayList<Pair<Construct, TopicMapsTypes>> data = new ArrayList<Pair<Construct,TopicMapsTypes>>(); - data.add(new Pair<Construct, TopicMapsTypes>(this.requestedSchemaTm, TopicMapsTypes.TopicMap)); + ArrayList<Pair<Object, TopicMapsTypes>> data = new ArrayList<Pair<Object,TopicMapsTypes>>(); + data.add(new Pair<Object, TopicMapsTypes>(this.requestedSchemaTm, TopicMapsTypes.TopicMap)); this.commitCallback.commitTmConstruct(data, null, this.tmEngine); }catch(Exception e){ for (IOnErrorCallback handler : localOnErrorContainer) { @@ -253,8 +252,8 @@ if(this.deleteCallback == null) throw new ExecutionException("No DeleteCallback was set yet"); - ArrayList<Pair<Construct, TopicMapsTypes>> data = new ArrayList<Pair<Construct,TopicMapsTypes>>(); - data.add(new Pair<Construct, TopicMapsTypes>(this.requestedSchemaTm, TopicMapsTypes.TopicMap)); + ArrayList<Pair<Object, TopicMapsTypes>> data = new ArrayList<Pair<Object,TopicMapsTypes>>(); + data.add(new Pair<Object, TopicMapsTypes>(this.requestedSchemaTm, TopicMapsTypes.TopicMap)); this.deleteCallback.deleteTmConstruct(data, this.getTmEngine(), null); }catch(Exception e){ for (IOnErrorCallback handler : localOnErrorContainer) @@ -265,7 +264,7 @@ // this method is responsible for generating a Topic Map fo the user's // data by using the view's getContent method. - public ArrayList<Pair<Construct, TopicMapsTypes>> getContent(boolean validate) throws Exception { + public ArrayList<Pair<Object, TopicMapsTypes>> getContent(boolean validate) throws Exception { try{ return this.view.getContent(null, validate); }catch(Exception e){
Modified: trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlVisibleObject.java ============================================================================== --- trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlVisibleObject.java Thu Oct 20 02:23:09 2011 (r1014) +++ trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlVisibleObject.java Tue Oct 25 02:03:42 2011 (r1015) @@ -4,6 +4,7 @@ import java.util.ArrayList; import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Association; import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Construct; +import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Locator; import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Name; import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Occurrence; import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Reifiable; @@ -2333,24 +2334,23 @@ public abstract ArrayList<String> getSelectedValues();
- // validates names, occurrences and identifiers for tha passed value + // validates names, occurrences and identifiers for the 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)){ + if(TmHelper.isInstanceOf(this.getRootConstraint(), PSIs.TMCL.tmclSubjectIdentifierConstraint) || TmHelper.isInstanceOf(this.getRootConstraint(), PSIs.TMCL.tmclSubjectLocatorConstraint) || TmHelper.isInstanceOf(this.getRootConstraint(), PSIs.TMCL.tmclItemIdentifierConstraint)){ + Pattern pattern = new Pattern(TmHelper.getRegExp(this.getConstraint())); + if(!pattern.matches(selectedValue)) throw new InvalidContentException("The value "" + selectedValue + "" does not satisfy the constraint " + TmHelper.getAnyIdOfTopic(this.getConstraint()) + " with the regular expression: " + TmHelper.getRegExp(this.getConstraint())); + } else { + 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)); + } } }
@@ -2380,10 +2380,58 @@ } }
+ + // returns all locators contained in the passed locators array, which match the + // passed regular expression value + private ArrayList<Locator> filterLocators(String pattern, JsArray<Locator> locators){ + ArrayList<Locator> result = new ArrayList<Locator>(); + if(locators == null || locators.length() == 0) return result; + Pattern patternObject = new Pattern(pattern == null ? ".*" : pattern); + + for(int i = 0; i != locators.length(); ++i){ + if(patternObject.matches(locators.get(i).getReference())) result.add(locators.get(i)); + } + + return result; + } + + + // handles the getContetn call for subject identifiers and subject locators + private void getTopicIdentifierContent(ArrayList<Pair<Object, TopicMapsTypes>> contents, boolean validate, Topic carier, int selectedValueIndex) throws InvalidGdlSchemaException, InvalidContentException, ExecutionException{ + JsArray<Locator> identifiers = null; + + ArrayList<Locator> filteredIdentifiers = null; + boolean isPsiConstraint = false; + if(TmHelper.isInstanceOf(this.getConstraint(), PSIs.TMCL.tmclSubjectIdentifierConstraint)){ + isPsiConstraint = true; + identifiers = carier.getSubjectIdentifiers(); + filteredIdentifiers = this.filterLocators(TmHelper.getRegExp(this.getConstraint()), identifiers); + } else if(TmHelper.isInstanceOf(this.getConstraint(), PSIs.TMCL.tmclSubjectLocatorConstraint)){ + identifiers = carier.getSubjectLocators(); + filteredIdentifiers = this.filterLocators(TmHelper.getRegExp(this.getConstraint()), identifiers); + } else { + throw new ExecutionException("Only the constraints " + PSIs.TMCL.tmclSubjectIdentifierConstraint + " and " + PSIs.TMCL.tmclSubjectLocatorConstraint + " are supported by the function getTopicIdentifierContent"); + } + + Locator changedIdentifier = null; + if(validate) this.validateLiteralValue(this.getSelectedValues().get(selectedValueIndex)); + + if(filteredIdentifiers.size() > selectedValueIndex){ + changedIdentifier = filteredIdentifiers.get(selectedValueIndex); + if(isPsiConstraint) carier.removeSubjectIdentifier(changedIdentifier); + else carier.removeSubjectLocator(changedIdentifier); + } + + changedIdentifier = carier.getTopicMap().createLocator(this.getSelectedValues().get(selectedValueIndex)); + if(isPsiConstraint) carier.addSubjectIdentifier(changedIdentifier); + else carier.addSubjectLocator(changedIdentifier); + contents.add(new Pair<Object, TopicMapsTypes>(changedIdentifier, TopicMapsTypes.Locator)); + } +
// 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>>(); + public ArrayList<Pair<Object, TopicMapsTypes>> getContent(Construct carrier, boolean validate) throws InvalidGdlSchemaException, ExecutionException, InvalidContentException { + ArrayList<Pair<Object, TopicMapsTypes>> result = new ArrayList<Pair<Object,TopicMapsTypes>>(); if(this.getRootConstraint() == null) return result; Construct localCarrier = carrier; if(carrier == null) localCarrier = TmHelper.getNearestTopicOrAssociation(this); @@ -2392,10 +2440,12 @@ if(TmHelper.isInstanceOf(this.getConstraint(), PSIs.TMCL.tmclItemIdentifierConstraint)){ // TODO: implement } else if (TmHelper.isInstanceOf(this.getConstraint(), PSIs.TMCL.tmclSubjectIdentifierConstraint)){ - // TODO: implement + if(!(localCarrier instanceof Topic)) throw new ExecutionException("the constraint " + TmHelper.getAnyIdOfTopic(this.getConstraint()) + " must be bound to a Topic, but is: " + localCarrier.getClass()); + this.getTopicIdentifierContent(result, validate, (Topic)localCarrier, idx); } else if (TmHelper.isInstanceOf(this.getConstraint(), PSIs.TMCL.tmclSubjectLocatorConstraint)){ - // TODO: implement - } else if (TmHelper.isInstanceOf(this.getConstraint(), PSIs.TMCL.tmclTopicNameConstraint)){ + if(!(localCarrier instanceof Topic)) throw new ExecutionException("the constraint " + TmHelper.getAnyIdOfTopic(this.getConstraint()) + " must be bound to a Topic, but is: " + localCarrier.getClass()); + this.getTopicIdentifierContent(result, validate, (Topic)localCarrier, idx); + } else if (TmHelper.isInstanceOf(this.getConstraint(), PSIs.TMCL.tmclTopicNameConstraint)){ if(!(localCarrier instanceof Topic)) throw new ExecutionException("the constraint " + TmHelper.getAnyIdOfTopic(this.getConstraint()) + " must be bound to a Topic, but is: " + localCarrier.getClass()); Topic nameType = TmHelper.getConstrainedStatement(this.getConstraint()); JsArray<Name> names = ((Topic)localCarrier).getNames(nameType); @@ -2409,8 +2459,7 @@ }else { changedName = ((Topic)localCarrier).createName(this.getSelectedValues().get(idx), nameType, null); } - - result.add(new Pair<Construct, TopicMapsTypes>(changedName, TopicMapsTypes.Name)); + result.add(new Pair<Object, TopicMapsTypes>(changedName, TopicMapsTypes.Name)); } else if (TmHelper.isInstanceOf(this.getConstraint(), PSIs.TMCL.tmclVariantNameConstraint)){ // TODO: implement } else if (TmHelper.isInstanceOf(this.getConstraint(), PSIs.TMCL.tmclScopeConstraint)){ @@ -2442,7 +2491,7 @@ changedOccurrence = ((Topic)localCarrier).createOccurrence(occurrenceType, this.getSelectedValues().get(idx), null, null); }
- result.add(new Pair<Construct, TopicMapsTypes>(changedOccurrence, TopicMapsTypes.Occurrence)); + result.add(new Pair<Object, TopicMapsTypes>(changedOccurrence, TopicMapsTypes.Occurrence)); } else if (TmHelper.isInstanceOf(this.getConstraint(), PSIs.GDL.TopicType.gdlRolePlayer)){ if(!(localCarrier instanceof Association)) throw new ExecutionException("the constraint " + TmHelper.getAnyIdOfTopic(this.getConstraint()) + " must be bound to an Association, but is: " + localCarrier.getClass()); if(!TmHelper.isInstanceOf(this.getRootConstraint(), PSIs.TMCL.tmclTopicRoleConstraint))throw new InvalidGdlSchemaException("the constraint " + TmHelper.getAnyIdOfTopic(this.getConstraint()) + " must be bound to a root constraint of the type " + PSIs.TMCL.tmclTopicRoleConstraint + ", but is: " + TmHelper.getAnyIdOfTopic(this.getRootConstraint())); @@ -2465,7 +2514,7 @@ } else { changedRole = ((Association)localCarrier).createRole(roleType, player); } - result.add(new Pair<Construct, TopicMapsTypes>(changedRole, TopicMapsTypes.Role)); + result.add(new Pair<Object, TopicMapsTypes>(changedRole, TopicMapsTypes.Role)); } else { throw new InvalidGdlSchemaException("the constraint " + TmHelper.getAnyIdOfTopic(this.getConstraint()) + " is not supported"); }
Modified: trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TestClass.java ============================================================================== --- trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TestClass.java Thu Oct 20 02:23:09 2011 (r1014) +++ trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TestClass.java Tue Oct 25 02:03:42 2011 (r1015) @@ -2,8 +2,8 @@
import us.isidor.gdl.anaToMia.TmEngine.jtmsBasedEngine.JtmsTmEngine; import us.isidor.gdl.anaToMia.TopicMaps.TmEngineModel.TmEngine; -import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Construct; import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.TopicMapsTypes; +import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Locator; import us.isidor.gdl.anaToMia.Widgets.environment.ICommitCallback; import us.isidor.gdl.anaToMia.Widgets.environment.IDeleteCallback; import us.isidor.gdl.anaToMia.Widgets.environment.Pair; @@ -56,13 +56,21 @@ gdlPanel.setLoadSchemaCallback(new TestLoadSchemaCallback()); gdlPanel.setCommitCallback(new ICommitCallback() { @Override - public void commitTmConstruct(ArrayList<Pair<Construct, TopicMapsTypes>> constructs, String buttonId, TmEngine tmEngine) { - Window.alert("not implemented yet :-("); + public void commitTmConstruct(ArrayList<Pair<Object, TopicMapsTypes>> constructs, String buttonId, TmEngine tmEngine) { + for (Pair<Object, TopicMapsTypes> construct : constructs) { + if(construct.getSecond().equals(TopicMapsTypes.Topic)){ + Window.alert("Topic!!!"); + } else if(construct.getSecond().equals(TopicMapsTypes.Locator)){ + Window.alert(((Locator)construct.getFirst()).getReference() + " >> " + construct.getSecond()); + } else { + Window.alert(construct.getFirst() + " >> " + construct.getSecond()); + } + } } }); gdlPanel.setDeleteCallback(new IDeleteCallback() { @Override - public void deleteTmConstruct(ArrayList<Pair<Construct, TopicMapsTypes>> constructs, TmEngine tmEngine, String buttonId) { + public void deleteTmConstruct(ArrayList<Pair<Object, TopicMapsTypes>> constructs, TmEngine tmEngine, String buttonId) { Window.alert("not implemented yet :-("); } });
Modified: trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TmHelper.java ============================================================================== --- trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TmHelper.java Thu Oct 20 02:23:09 2011 (r1014) +++ trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TmHelper.java Tue Oct 25 02:03:42 2011 (r1015) @@ -1210,7 +1210,7 @@ ArrayList<Topic> occurrenceTypes = getOtherPlayerOfBinaryAssociation(constraint, constraintRoleType, constrainedStatementAssocType, null, occurrenceType, constrainedRoleType); ArrayList<Topic> nameOrOccurrenceTypes = Utils.union(nameTypes, occurrenceTypes); - if(nameOrOccurrenceTypes.size() == 0){ + if(nameOrOccurrenceTypes.size() == 0){ return result; } else if(nameOrOccurrenceTypes.size() > 1){ throw new InvalidGdlSchemaException("the topic " + getAnyIdOfTopic(constraint) + " must be bound maximum once to a topic via a " + PSIs.TMCL.tmclConstrainedStatement + ", but is: " + nameOrOccurrenceTypes.size()); @@ -1368,7 +1368,7 @@ }
- // returns an integer representing the tmcl:card-min value + // returns an integer representing the tmcl:card-min value of the passed constraint public static int getCardMin(Topic constraint) throws InvalidGdlSchemaException { if(constraint == null) return 0; Occurrence occ = getSingleOccurrence(constraint, getTopicByPsi(PSIs.TMCL.tmclCardMin, constraint.getTopicMap())); @@ -1384,8 +1384,20 @@ } - // returns an integer representing the tmcl:card-max value or -1 - // if infinite + // returns a string representing the tmcl:regexp value of the passed constraint + public static String getRegExp(Topic constraint) throws InvalidGdlSchemaException { + if(constraint == null) return ".*"; + Occurrence occ = getSingleOccurrence(constraint, getTopicByPsi(PSIs.TMCL.tmclRegexp, constraint.getTopicMap())); + if(occ == null){ + return ".*"; + } else { + return occ.getValue(); + } + } + + + // returns an integer representing the tmcl:card-max value of the + // passed constraint or -1 if infinite public static int getCardMax(Topic constraint) throws InvalidGdlSchemaException { if(constraint == null) return 0; Occurrence occ = getSingleOccurrence(constraint, getTopicByPsi(PSIs.TMCL.tmclCardMax, constraint.getTopicMap()));
Modified: trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/environment/ICommitCallback.java ============================================================================== --- trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/environment/ICommitCallback.java Thu Oct 20 02:23:09 2011 (r1014) +++ trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/environment/ICommitCallback.java Tue Oct 25 02:03:42 2011 (r1015) @@ -3,11 +3,10 @@ import java.util.ArrayList;
import us.isidor.gdl.anaToMia.TopicMaps.TmEngineModel.TmEngine; -import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Construct; import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.TopicMapsTypes;
public interface ICommitCallback { - public void commitTmConstruct(ArrayList<Pair<Construct, TopicMapsTypes>> constructs, String buttonId, TmEngine tmEngine); + public void commitTmConstruct(ArrayList<Pair<Object, TopicMapsTypes>> constructs, String buttonId, TmEngine tmEngine); }
Modified: trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/environment/IDeleteCallback.java ============================================================================== --- trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/environment/IDeleteCallback.java Thu Oct 20 02:23:09 2011 (r1014) +++ trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/environment/IDeleteCallback.java Tue Oct 25 02:03:42 2011 (r1015) @@ -2,10 +2,9 @@
import java.util.ArrayList; import us.isidor.gdl.anaToMia.TopicMaps.TmEngineModel.TmEngine; -import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Construct; import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.TopicMapsTypes;
public interface IDeleteCallback { - public void deleteTmConstruct(ArrayList<Pair<Construct, TopicMapsTypes>> constructs, TmEngine tmEngine, String buttonId); + public void deleteTmConstruct(ArrayList<Pair<Object, TopicMapsTypes>> constructs, TmEngine tmEngine, String buttonId); }
Modified: trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/isidorus/CommitCallback.java ============================================================================== --- trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/isidorus/CommitCallback.java Thu Oct 20 02:23:09 2011 (r1014) +++ trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/isidorus/CommitCallback.java Tue Oct 25 02:03:42 2011 (r1015) @@ -22,7 +22,6 @@ import us.isidor.gdl.anaToMia.TopicMaps.TmEngineModel.ExporterException; import us.isidor.gdl.anaToMia.TopicMaps.TmEngineModel.TmEngine; import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Association; -import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Construct; import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Locator; import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Name; import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Occurrence; @@ -49,7 +48,7 @@ @Override - public void commitTmConstruct(ArrayList<Pair<Construct, TopicMapsTypes>> constructs, String buttonId, TmEngine tmEngine) { + public void commitTmConstruct(ArrayList<Pair<Object, TopicMapsTypes>> constructs, String buttonId, TmEngine tmEngine) { try{ if("creator_hash_object_commit_button_id".equals(buttonId)){ if(this.gdlWebPage != null) this.gdlWebPage.createLoadScreenPanel("Committing Data", "committing the currently created Hash-Object topic to " + this.COMMIT_REQUEST_URL); @@ -78,12 +77,12 @@ } - private void commitCreatedEnvironment(ArrayList<Pair<Construct, TopicMapsTypes>> constructs, TmEngine tmEngine) throws ExporterException { + private void commitCreatedEnvironment(ArrayList<Pair<Object, TopicMapsTypes>> constructs, TmEngine tmEngine) throws ExporterException { final String carrierPsi = PSIs.GDL.gdl + "environment_default_creator_topic_view_id"; ArrayList<Topic> topics = new ArrayList<Topic>(); ArrayList<TopicMap> topicMaps = new ArrayList<TopicMap>(); - for (Pair<Construct, TopicMapsTypes> construct : constructs) { + for (Pair<Object, TopicMapsTypes> construct : constructs) { if(construct.getSecond().equals(TopicMapsTypes.Topic)) topics.add((Topic)construct.getFirst()); else if(construct.getSecond().equals(TopicMapsTypes.TopicMap)) topicMaps.add((TopicMap)construct.getFirst()); else throw new ExporterException("unexpected construct types: " + construct.getSecond()+ ", only Topic and Association are allowed"); @@ -134,13 +133,13 @@ } - private void commitCreatedHashObject(ArrayList<Pair<Construct, TopicMapsTypes>> constructs, TmEngine tmEngine, boolean edited) throws ExporterException{ + private void commitCreatedHashObject(ArrayList<Pair<Object, TopicMapsTypes>> constructs, TmEngine tmEngine, boolean edited) throws ExporterException{ final String carrierPsi = PSIs.GDL.gdl + "hash_object_default_creator_topic_view_id"; ArrayList<Topic> topics = new ArrayList<Topic>(); ArrayList<Association> associations = new ArrayList<Association>(); ArrayList<TopicMap> topicMaps = new ArrayList<TopicMap>(); - for (Pair<Construct, TopicMapsTypes> construct : constructs) { + for (Pair<Object, TopicMapsTypes> construct : constructs) { if(construct.getSecond().equals(TopicMapsTypes.Association)) associations.add((Association)construct.getFirst()); else if(construct.getSecond().equals(TopicMapsTypes.Topic)) topics.add((Topic)construct.getFirst()); else if(construct.getSecond().equals(TopicMapsTypes.TopicMap)) topicMaps.add((TopicMap)construct.getFirst());
Modified: trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/isidorus/DeleteCallback.java ============================================================================== --- trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/isidorus/DeleteCallback.java Thu Oct 20 02:23:09 2011 (r1014) +++ trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/isidorus/DeleteCallback.java Tue Oct 25 02:03:42 2011 (r1015) @@ -18,7 +18,6 @@ import com.google.gwt.user.client.Window; import us.isidor.gdl.anaToMia.TopicMaps.TmEngineModel.ExporterException; import us.isidor.gdl.anaToMia.TopicMaps.TmEngineModel.TmEngine; -import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Construct; import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Topic; import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.TopicMapsTypes; import us.isidor.gdl.anaToMia.Widgets.base.TmHelper; @@ -52,7 +51,7 @@
@Override - public void deleteTmConstruct(ArrayList<Pair<Construct, TopicMapsTypes>> constructs, TmEngine tmEngine, String buttonId) { + public void deleteTmConstruct(ArrayList<Pair<Object, TopicMapsTypes>> constructs, TmEngine tmEngine, String buttonId) { if(buttonId != null){ Element elem = DOM.getElementById(buttonId); ButtonElement btnElem = (ButtonElement)elem; @@ -62,8 +61,8 @@ }
- private void deleteTopic(ArrayList<Pair<Construct, TopicMapsTypes>> constructs, TmEngine tmEngine){ - for (Pair<Construct, TopicMapsTypes> pair : constructs) { + private void deleteTopic(ArrayList<Pair<Object, TopicMapsTypes>> constructs, TmEngine tmEngine){ + for (Pair<Object, TopicMapsTypes> pair : constructs) { if(pair.getSecond().equals(TopicMapsTypes.Topic)){ Topic top = (Topic)pair.getFirst();
Modified: trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/view/GdlAssociationView.java ============================================================================== --- trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/view/GdlAssociationView.java Thu Oct 20 02:23:09 2011 (r1014) +++ trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/view/GdlAssociationView.java Tue Oct 25 02:03:42 2011 (r1015) @@ -185,13 +185,13 @@
@Override - public ArrayList<Pair<Construct, TopicMapsTypes>> getContent(Construct carrier, boolean validate) throws InvalidGdlSchemaException, ExecutionException, InvalidContentException{ - ArrayList<Pair<Construct, TopicMapsTypes>> result = new ArrayList<Pair<Construct,TopicMapsTypes>>(); + public ArrayList<Pair<Object, TopicMapsTypes>> getContent(Construct carrier, boolean validate) throws InvalidGdlSchemaException, ExecutionException, InvalidContentException{ + ArrayList<Pair<Object, TopicMapsTypes>> result = new ArrayList<Pair<Object,TopicMapsTypes>>(); for (Widget ctrl : this.subElements) { if(ctrl instanceof ButtonableObject){ if(((ButtonableObject)ctrl).getMainObject() instanceof AssociationItem){ - for (Pair<Construct, TopicMapsTypes> pair : ((AssociationItem)((ButtonableObject)ctrl).getMainObject()).getContent(null, validate)) { + for (Pair<Object, TopicMapsTypes> pair : ((AssociationItem)((ButtonableObject)ctrl).getMainObject()).getContent(null, validate)) { result.add(pair); } } @@ -207,7 +207,7 @@ 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) { + for (Pair<Object, TopicMapsTypes> pair : result) { if(pair.getSecond().equals(TopicMapsTypes.Association)){ Association assoc = (Association)pair.getFirst(); JsArray<Role> roles = assoc.getRoles(roleType); @@ -276,8 +276,8 @@ @Override - public ArrayList<Pair<Construct, TopicMapsTypes>> getContent(Construct carrier, boolean validate) throws InvalidGdlSchemaException, ExecutionException, InvalidContentException { - ArrayList<Pair<Construct, TopicMapsTypes>> result = new ArrayList<Pair<Construct,TopicMapsTypes>>(); + public ArrayList<Pair<Object, TopicMapsTypes>> getContent(Construct carrier, boolean validate) throws InvalidGdlSchemaException, ExecutionException, InvalidContentException { + ArrayList<Pair<Object, TopicMapsTypes>> result = new ArrayList<Pair<Object,TopicMapsTypes>>(); Association localCarrier = this.getRepresentedAssociation(); @@ -286,7 +286,7 @@ ((GdlVisibleObject)ctrl).getContent(localCarrier, validate); } } - result.add(new Pair<Construct, TopicMapsTypes>(localCarrier, TopicMapsTypes.Association)); + result.add(new Pair<Object, TopicMapsTypes>(localCarrier, TopicMapsTypes.Association)); return result; }
Modified: trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/view/GdlTopicView.java ============================================================================== --- trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/view/GdlTopicView.java Thu Oct 20 02:23:09 2011 (r1014) +++ trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/view/GdlTopicView.java Tue Oct 25 02:03:42 2011 (r1015) @@ -88,14 +88,14 @@ // returns true if the construct that is contained in the first member of pair // is also indirectly contained in the container - private boolean indirectlyContained(Pair<Construct, TopicMapsTypes> pair, ArrayList<Pair<Construct, TopicMapsTypes>> container){ + private boolean indirectlyContained(Pair<Object, TopicMapsTypes> pair, ArrayList<Pair<Object, TopicMapsTypes>> container){ if(pair == null) return true; if(container == null) return false; TopicMapsTypes newType = pair.getSecond(); if(newType.equals(TopicMapsTypes.Name)){ Name name = (Name)pair.getFirst(); - for (Pair<Construct, TopicMapsTypes> item : container) { + for (Pair<Object, TopicMapsTypes> item : container) { if(item.getSecond().equals(TopicMapsTypes.Topic)){ JsArray<Name> names = ((Topic)item.getFirst()).getNames(); if(Utils.contains(names, name)) return true; @@ -103,14 +103,14 @@ } } else if (newType.equals(TopicMapsTypes.Variant)){ Variant variant = (Variant)pair.getFirst(); - for (Pair<Construct, TopicMapsTypes> item : container) { + for (Pair<Object, TopicMapsTypes> item : container) { if(item.getSecond().equals(TopicMapsTypes.Name)){ JsArray<Variant> variants = ((Name)item.getFirst()).getVariants(); if(Utils.contains(variants, variant)) return true; } } - for (Pair<Construct, TopicMapsTypes> item : container) { + for (Pair<Object, TopicMapsTypes> item : container) { if(item.getSecond().equals(TopicMapsTypes.Topic)){ JsArray<Name> names = ((Topic)item.getFirst()).getNames(); for(int i = 0; i != names.length(); ++i){ @@ -121,7 +121,7 @@ } } else if (newType.equals(TopicMapsTypes.Occurrence)){ Occurrence occurrence = (Occurrence)pair.getFirst(); - for (Pair<Construct, TopicMapsTypes> item : container) { + for (Pair<Object, TopicMapsTypes> item : container) { if(item.getSecond().equals(TopicMapsTypes.Topic)){ JsArray<Occurrence> occurrences = ((Topic)item.getFirst()).getOccurrences(); if(Utils.contains(occurrences, occurrence)) return true; @@ -129,7 +129,7 @@ } } else if (newType.equals(TopicMapsTypes.Role)){ Role role = (Role)pair.getFirst(); - for (Pair<Construct, TopicMapsTypes> item : container) { + for (Pair<Object, TopicMapsTypes> item : container) { if(item.getSecond().equals(TopicMapsTypes.Association)){ JsArray<Role> roles = ((Association)item.getFirst()).getRoles(); if(Utils.contains(roles, role)) return true; @@ -143,18 +143,18 @@ @SuppressWarnings("unchecked") @Override - public ArrayList<Pair<Construct, TopicMapsTypes>> getContent(Construct carrier, boolean validate) throws InvalidGdlSchemaException, ExecutionException, InvalidContentException { - ArrayList<Pair<Construct, TopicMapsTypes>> result = new ArrayList<Pair<Construct,TopicMapsTypes>>(); + public ArrayList<Pair<Object, TopicMapsTypes>> getContent(Construct carrier, boolean validate) throws InvalidGdlSchemaException, ExecutionException, InvalidContentException { + ArrayList<Pair<Object, TopicMapsTypes>> result = new ArrayList<Pair<Object,TopicMapsTypes>>(); Topic localCarrier = this.getRepresentedTopic(); for (Widget ctrl : this.subElements) { int i = 0; for( ; i != result.size(); ++i) if(result.get(i).getFirst().equals(localCarrier)) break; - if(i == result.size()) result.add(new Pair<Construct, TopicMapsTypes>(localCarrier, TopicMapsTypes.Topic)); + if(i == result.size()) result.add(new Pair<Object, TopicMapsTypes>(localCarrier, TopicMapsTypes.Topic)); if(ctrl instanceof GdlVisibleObject){ - for (Pair<Construct, TopicMapsTypes> pair : ((GdlVisibleObject)ctrl).getContent(localCarrier, validate)) { + for (Pair<Object, TopicMapsTypes> pair : ((GdlVisibleObject)ctrl).getContent(localCarrier, validate)) { if((this.receivedData != null || (ctrl instanceof GdlView)) && !this.indirectlyContained(pair, result))result.add(pair); } } @@ -177,7 +177,7 @@ if(i == occurrences.length()){ Occurrence occ = top.createOccurrence(occurrenceType, value, (JsArray<Topic>)JsArray.createArray()); - Pair<Construct, TopicMapsTypes> newItem = new Pair<Construct, TopicMapsTypes>(occ, TopicMapsTypes.Occurrence); + Pair<Object, TopicMapsTypes> newItem = new Pair<Object, TopicMapsTypes>(occ, TopicMapsTypes.Occurrence); if(!this.indirectlyContained(newItem, result)) result.add(newItem); } }