Changeset 1019 for trunk/src/anaToMia/GDL_Widgets
- Timestamp:
- 10/25/11 13:23:37 (14 years ago)
- Location:
- trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlVisibleObject.java ¶
r1018 r1019 2418 2418 2419 2419 // handles the getContent call for subject identifiers and subject locators 2420 private void getTopicIdentifierContent(ArrayList<Pair<Object, TopicMapsTypes>> contents, boolean validate, Topic car ier, int selectedValueIndex) throws InvalidGdlSchemaException, InvalidContentException, ExecutionException{2420 private void getTopicIdentifierContent(ArrayList<Pair<Object, TopicMapsTypes>> contents, boolean validate, Topic carrier, int selectedValueIndex) throws InvalidGdlSchemaException, InvalidContentException, ExecutionException{ 2421 2421 JsArray<Locator> identifiers = null; 2422 2422 … … 2425 2425 if(TmHelper.isInstanceOf(this.getConstraint(), PSIs.TMCL.tmclSubjectIdentifierConstraint)){ 2426 2426 isPsiConstraint = true; 2427 identifiers = car ier.getSubjectIdentifiers();2427 identifiers = carrier.getSubjectIdentifiers(); 2428 2428 filteredIdentifiers = this.filterLocators(TmHelper.getRegExp(this.getConstraint()), identifiers); 2429 2429 } else if(TmHelper.isInstanceOf(this.getConstraint(), PSIs.TMCL.tmclSubjectLocatorConstraint)){ 2430 identifiers = car ier.getSubjectLocators();2430 identifiers = carrier.getSubjectLocators(); 2431 2431 filteredIdentifiers = this.filterLocators(TmHelper.getRegExp(this.getConstraint()), identifiers); 2432 2432 } else { … … 2439 2439 if(filteredIdentifiers.size() > selectedValueIndex){ 2440 2440 changedIdentifier = filteredIdentifiers.get(selectedValueIndex); 2441 if(isPsiConstraint) car ier.removeSubjectIdentifier(changedIdentifier);2442 else car ier.removeSubjectLocator(changedIdentifier);2441 if(isPsiConstraint) carrier.removeSubjectIdentifier(changedIdentifier); 2442 else carrier.removeSubjectLocator(changedIdentifier); 2443 2443 } 2444 2444 2445 changedIdentifier = car ier.getTopicMap().createLocator(this.getSelectedValues().get(selectedValueIndex));2446 if(isPsiConstraint) car ier.addSubjectIdentifier(changedIdentifier);2447 else car ier.addSubjectLocator(changedIdentifier);2445 changedIdentifier = carrier.getTopicMap().createLocator(this.getSelectedValues().get(selectedValueIndex)); 2446 if(isPsiConstraint) carrier.addSubjectIdentifier(changedIdentifier); 2447 else carrier.addSubjectLocator(changedIdentifier); 2448 2448 contents.add(new Pair<Object, TopicMapsTypes>(changedIdentifier, TopicMapsTypes.Locator)); 2449 2449 } … … 2451 2451 2452 2452 // handles the getContent call for item identifiers 2453 private void getItemIdentifierContent(ArrayList<Pair<Object, TopicMapsTypes>> contents, boolean validate, Construct car ier, int selectedValueIndex) throws InvalidGdlSchemaException, InvalidContentException, ExecutionException{2453 private void getItemIdentifierContent(ArrayList<Pair<Object, TopicMapsTypes>> contents, boolean validate, Construct carrier, int selectedValueIndex) throws InvalidGdlSchemaException, InvalidContentException, ExecutionException{ 2454 2454 if(!(this.receivedData instanceof Reifiable) || !(this.receivedData instanceof Topic)) throw new ExecutionException("the constraint " + TmHelper.getAnyIdOfTopic(this.getConstraint()) + " must be bound to a Reifiable, but is: " + receivedData.getClass()); 2455 2455 … … 2459 2459 int typeIdx = -1; 2460 2460 JsArray<Topic> types = null; 2461 if((car ier instanceof Topic)){2462 types = ((Topic)car ier).getTypes();2461 if((carrier instanceof Topic)){ 2462 types = ((Topic)carrier).getTypes(); 2463 2463 if(types.length() != 0){ 2464 2464 for(typeIdx = 0; typeIdx != types.length(); ++typeIdx) if(types.get(typeIdx).equals(constrainedTopicType)) break; … … 2468 2468 JsArray<Locator> identifiers = null; 2469 2469 ArrayList<Locator> filteredIdentifiers = null; 2470 if((car ier instanceof Topic) && types != null && typeIdx != types.length()){2471 identifiers = ((Topic)car ier).getItemIdentifiers();2470 if((carrier instanceof Topic) && types != null && typeIdx != types.length()){ 2471 identifiers = ((Topic)carrier).getItemIdentifiers(); 2472 2472 filteredIdentifiers = this.filterLocators(TmHelper.getRegExp(this.getConstraint()), identifiers); 2473 2473 … … 2477 2477 if(filteredIdentifiers.size() > selectedValueIndex){ 2478 2478 changedIdentifier = filteredIdentifiers.get(selectedValueIndex); 2479 ((Topic)car ier).removeItemIdentifier(changedIdentifier);2479 ((Topic)carrier).removeItemIdentifier(changedIdentifier); 2480 2480 } 2481 2481 2482 changedIdentifier = ((Topic)car ier).getTopicMap().createLocator(this.getSelectedValues().get(selectedValueIndex));2483 ((Topic)car ier).addItemIdentifier(changedIdentifier);2482 changedIdentifier = ((Topic)carrier).getTopicMap().createLocator(this.getSelectedValues().get(selectedValueIndex)); 2483 ((Topic)carrier).addItemIdentifier(changedIdentifier); 2484 2484 contents.add(new Pair<Object, TopicMapsTypes>(changedIdentifier, TopicMapsTypes.Locator)); 2485 2485 } else { … … 2488 2488 2489 2489 // search for the characteristics type 2490 if(car ier instanceof Topic){2491 JsArray<Name> names = ((Topic)car ier).getNames(constrainedTopicType);2490 if(carrier instanceof Topic){ 2491 JsArray<Name> names = ((Topic)carrier).getNames(constrainedTopicType); 2492 2492 if(names.length() != 0){ 2493 2493 ref = names.get(0); 2494 2494 } else { 2495 JsArray<Occurrence> occs = ((Topic)car ier).getOccurrences(constrainedTopicType);2495 JsArray<Occurrence> occs = ((Topic)carrier).getOccurrences(constrainedTopicType); 2496 2496 if(occs.length() != 0) ref = occs.get(0); 2497 2497 } 2498 } else if(car ier instanceof Association){2499 JsArray<Role> roles = ((Association)car ier).getRoles(constrainedTopicType);2498 } else if(carrier instanceof Association){ 2499 JsArray<Role> roles = ((Association)carrier).getRoles(constrainedTopicType); 2500 2500 if(roles.length() != 0) ref = roles.get(0); 2501 2501 } … … 2511 2511 if(filteredIdentifiers.size() > selectedValueIndex){ 2512 2512 changedIdentifier = filteredIdentifiers.get(selectedValueIndex); 2513 ((ReifiableStub)car ier).removeItemIdentifier(changedIdentifier);2513 ((ReifiableStub)carrier).removeItemIdentifier(changedIdentifier); 2514 2514 } 2515 2515 2516 changedIdentifier = ((ReifiableStub)car ier).getTopicMap().createLocator(this.getSelectedValues().get(selectedValueIndex));2517 ((ReifiableStub)car ier).addItemIdentifier(changedIdentifier);2516 changedIdentifier = ((ReifiableStub)carrier).getTopicMap().createLocator(this.getSelectedValues().get(selectedValueIndex)); 2517 ((ReifiableStub)carrier).addItemIdentifier(changedIdentifier); 2518 2518 contents.add(new Pair<Object, TopicMapsTypes>(changedIdentifier, TopicMapsTypes.Locator)); 2519 2519 } … … 2521 2521 2522 2522 2523 // handles the getContent call for item identifiers of varian -names2524 private void getVariantIdentifierContent(ArrayList<Pair<Object, TopicMapsTypes>> contents, boolean validate, Topic car ier, int selectedValueIndex) throws InvalidGdlSchemaException, InvalidContentException, ExecutionException{2525 ArrayList<Variant> possibleVariants = TmHelper.getVariantsForConstraint(car ier, this.getRootConstraint());2523 // handles the getContent call for item identifiers of variant-names 2524 private void getVariantIdentifierContent(ArrayList<Pair<Object, TopicMapsTypes>> contents, boolean validate, Topic carrier, int selectedValueIndex) throws InvalidGdlSchemaException, InvalidContentException, ExecutionException{ 2525 ArrayList<Variant> possibleVariants = TmHelper.getVariantsForConstraint(carrier, this.getRootConstraint()); 2526 2526 if(possibleVariants.size() != 0){ 2527 2527 Variant variant = possibleVariants.get(0); … … 2546 2546 } 2547 2547 } 2548 2549 2550 // handles the getContent call for occurrence and name values 2551 private void getTopicCharacteristicContent(ArrayList<Pair<Object, TopicMapsTypes>> contents, boolean validate, Topic carrier, int selectedValueIndex) throws InvalidGdlSchemaException, InvalidContentException, ExecutionException{ 2552 Topic characteristicType = TmHelper.getConstrainedStatement(this.getConstraint()); 2548 2553 2554 boolean isOccConstraint = true; 2555 if(TmHelper.isInstanceOf(this.getConstraint(), PSIs.TMCL.tmclTopicOccurrenceConstraint)){ 2556 isOccConstraint = true; 2557 } else if(TmHelper.isInstanceOf(this.getConstraint(), PSIs.TMCL.tmclTopicNameConstraint)){ 2558 isOccConstraint = false; 2559 } else { 2560 throw new ExecutionException("the function getTopicCharacteristicContent can operate only on constraints of the type " + PSIs.TMCL.tmclTopicOccurrenceConstraint + " or " + PSIs.TMCL.tmclTopicNameConstraint + ", but is called with " + TmHelper.getAnyIdOfTopic(this.getConstraint())); 2561 } 2562 2563 JsArray<Name> names = null; 2564 JsArray<Occurrence> occurrences = null; 2565 if(isOccConstraint) occurrences = carrier.getOccurrences(characteristicType); 2566 else names = carrier.getNames(characteristicType); 2567 2568 2569 Construct changedConstruct = null; 2570 if(validate) this.validateLiteralValue(this.getSelectedValues().get(selectedValueIndex)); 2571 2572 if(isOccConstraint){ 2573 if(occurrences.length() > selectedValueIndex){ 2574 changedConstruct = occurrences.get(selectedValueIndex); 2575 ((Occurrence)changedConstruct).setValue(this.getSelectedValues().get(selectedValueIndex)); 2576 }else { 2577 changedConstruct = carrier.createOccurrence(characteristicType, this.getSelectedValues().get(selectedValueIndex), null); 2578 } 2579 } else { 2580 if(names.length() > selectedValueIndex){ 2581 changedConstruct = names.get(selectedValueIndex); 2582 ((Name)changedConstruct).setValue(this.getSelectedValues().get(selectedValueIndex)); 2583 }else { 2584 changedConstruct = carrier.createName(this.getSelectedValues().get(selectedValueIndex), characteristicType, null); 2585 } 2586 } 2587 contents.add(new Pair<Object, TopicMapsTypes>(changedConstruct, isOccConstraint ? TopicMapsTypes.Occurrence : TopicMapsTypes.Name)); 2588 } 2589 2549 2590 2550 2591 // returns the actual data that is hold by this instance … … 2567 2608 } else if (TmHelper.isInstanceOf(this.getConstraint(), PSIs.TMCL.tmclTopicNameConstraint)){ 2568 2609 if(!(localCarrier instanceof Topic)) throw new ExecutionException("the constraint " + TmHelper.getAnyIdOfTopic(this.getConstraint()) + " must be bound to a Topic, but is: " + localCarrier.getClass()); 2569 Topic nameType = TmHelper.getConstrainedStatement(this.getConstraint()); 2570 JsArray<Name> names = ((Topic)localCarrier).getNames(nameType); 2571 2572 Name changedName = null; 2573 if(validate) this.validateLiteralValue(this.getSelectedValues().get(idx)); 2574 2575 if(names.length() > idx){ 2576 changedName = names.get(idx); 2577 changedName.setValue(this.getSelectedValues().get(idx)); 2578 }else { 2579 changedName = ((Topic)localCarrier).createName(this.getSelectedValues().get(idx), nameType, null); 2580 } 2581 result.add(new Pair<Object, TopicMapsTypes>(changedName, TopicMapsTypes.Name)); 2610 this.getTopicCharacteristicContent(result, validate, (Topic)localCarrier, idx); 2582 2611 } else if (TmHelper.isInstanceOf(this.getConstraint(), PSIs.TMCL.tmclVariantNameConstraint)){ 2583 2612 // TODO: implement … … 2599 2628 } else if (TmHelper.isInstanceOf(this.getConstraint(), PSIs.TMCL.tmclTopicOccurrenceConstraint)){ 2600 2629 if(!(localCarrier instanceof Topic)) throw new ExecutionException("the constraint " + TmHelper.getAnyIdOfTopic(this.getConstraint()) + " must be bound to a Topic, but is: " + localCarrier.getClass()); 2601 Topic occurrenceType = TmHelper.getConstrainedStatement(this.getConstraint()); 2602 JsArray<Occurrence> occurrences = ((Topic)localCarrier).getOccurrences(occurrenceType); 2603 2604 Occurrence changedOccurrence = null; 2605 if(validate) this.validateLiteralValue(this.getSelectedValues().get(idx)); 2606 2607 if(occurrences.length() > idx){ 2608 changedOccurrence = occurrences.get(idx); 2609 changedOccurrence.setValue(this.getSelectedValues().get(idx)); 2610 }else { 2611 changedOccurrence = ((Topic)localCarrier).createOccurrence(occurrenceType, this.getSelectedValues().get(idx), null, null); 2612 } 2613 2614 result.add(new Pair<Object, TopicMapsTypes>(changedOccurrence, TopicMapsTypes.Occurrence)); 2630 this.getTopicCharacteristicContent(result, validate, (Topic)localCarrier, idx); 2615 2631 } else if (TmHelper.isInstanceOf(this.getConstraint(), PSIs.GDL.TopicType.gdlRolePlayer)){ 2616 2632 if(!(localCarrier instanceof Association)) throw new ExecutionException("the constraint " + TmHelper.getAnyIdOfTopic(this.getConstraint()) + " must be bound to an Association, but is: " + localCarrier.getClass()); -
TabularUnified trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TestClass.java ¶
r1015 r1019 3 3 import us.isidor.gdl.anaToMia.TmEngine.jtmsBasedEngine.JtmsTmEngine; 4 4 import us.isidor.gdl.anaToMia.TopicMaps.TmEngineModel.TmEngine; 5 import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Occurrence; 6 import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Name; 5 7 import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.TopicMapsTypes; 6 8 import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Locator; … … 63 65 } else if(construct.getSecond().equals(TopicMapsTypes.Locator)){ 64 66 Window.alert(((Locator)construct.getFirst()).getReference() + " >> " + construct.getSecond()); 67 } else if(construct.getSecond().equals(TopicMapsTypes.Occurrence)){ 68 Window.alert(((Occurrence)construct.getFirst()).getValue() + " >> " + construct.getSecond()); 69 } else if(construct.getSecond().equals(TopicMapsTypes.Name)){ 70 Window.alert(((Name)construct.getFirst()).getValue() + " >> " + construct.getSecond()); 65 71 } else { 66 72 Window.alert(construct.getFirst() + " >> " + construct.getSecond());
Note: See TracChangeset
for help on using the changeset viewer.