Changeset 1017 for trunk/src


Ignore:
Timestamp:
10/25/11 09:56:18 (13 years ago)
Author:
lgiessmann
Message:

gdl-frontend: Widgets: implemented the tmcl:item-identifier-constraint semantics for generating content entered in GdlVisibleObject?

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlVisibleObject.java ΒΆ

    r1016 r1017  
    24512451       
    24522452        // handles the getContent call for item identifiers
    2453         private void getItemIdentifierContent(ArrayList<Pair<Object, TopicMapsTypes>> contents, boolean validate, Topic carier, int selectedValueIndex) throws InvalidGdlSchemaException, InvalidContentException, ExecutionException{
     2453        private void getItemIdentifierContent(ArrayList<Pair<Object, TopicMapsTypes>> contents, boolean validate, Construct carier, int selectedValueIndex) throws InvalidGdlSchemaException, InvalidContentException, ExecutionException{
     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
     2456                // get type
     2457                Topic constrainedTopicType = TmHelper.getConstrainedTopicType(this.getConstraint());
     2458
     2459                int typeIdx = -1;
     2460                JsArray<Topic> types = null;
     2461                if((carier instanceof Topic)){
     2462                        types = ((Topic)carier).getTypes();
     2463                        if(types.length() != 0){
     2464                                for(typeIdx = 0; typeIdx != types.length(); ++typeIdx) if(types.get(typeIdx).equals(constrainedTopicType)) break;
     2465                        }
     2466                }
     2467
    24542468                JsArray<Locator> identifiers = null;
    2455                
    2456                
    2457                
     2469                ArrayList<Locator> filteredIdentifiers = null;
     2470                if((carier instanceof Topic) && types != null && typeIdx != types.length()){
     2471                        identifiers = ((Topic)carier).getItemIdentifiers();
     2472                        filteredIdentifiers = this.filterLocators(TmHelper.getRegExp(this.getConstraint()), identifiers);
     2473                       
     2474                        Locator changedIdentifier = null;
     2475                        if(validate) this.validateLiteralValue(this.getSelectedValues().get(selectedValueIndex));
     2476                       
     2477                        if(filteredIdentifiers.size() > selectedValueIndex){
     2478                                changedIdentifier = filteredIdentifiers.get(selectedValueIndex);
     2479                                ((Topic)carier).removeItemIdentifier(changedIdentifier);
     2480                        }
     2481                       
     2482                        changedIdentifier = ((Topic)carier).getTopicMap().createLocator(this.getSelectedValues().get(selectedValueIndex));
     2483                        ((Topic)carier).addItemIdentifier(changedIdentifier);
     2484                        contents.add(new Pair<Object, TopicMapsTypes>(changedIdentifier, TopicMapsTypes.Locator));
     2485                } else {                       
     2486                        // search for the topic type
     2487                        Reifiable ref = null;
     2488
     2489                        // search for the characteristics type
     2490                        if(carier instanceof Topic){
     2491                                JsArray<Name> names = ((Topic)carier).getNames(constrainedTopicType);
     2492                                if(names.length() != 0){
     2493                                        ref = names.get(0);
     2494                                } else {
     2495                                        JsArray<Occurrence> occs = ((Topic)carier).getOccurrences(constrainedTopicType);
     2496                                        if(occs.length() != 0) ref = occs.get(0);
     2497                                }
     2498                        } else if(carier instanceof Association){
     2499                                JsArray<Role> roles = ((Association)carier).getRoles(constrainedTopicType);
     2500                                if(roles.length() != 0) ref = roles.get(0);
     2501                        }
     2502                        if(ref == null) return;
     2503                       
     2504                        // search for item-identifiers of the found topic type or characteristics
     2505                        identifiers = ((ReifiableStub)ref).getItemIdentifiers();
     2506                        filteredIdentifiers = this.filterLocators(TmHelper.getRegExp(this.getConstraint()), identifiers);
     2507                       
     2508                        Locator changedIdentifier = null;
     2509                        if(validate) this.validateLiteralValue(this.getSelectedValues().get(selectedValueIndex));
     2510                       
     2511                        if(filteredIdentifiers.size() > selectedValueIndex){
     2512                                changedIdentifier = filteredIdentifiers.get(selectedValueIndex);
     2513                                ((ReifiableStub)carier).removeItemIdentifier(changedIdentifier);
     2514                        }
     2515                       
     2516                        changedIdentifier = ((ReifiableStub)carier).getTopicMap().createLocator(this.getSelectedValues().get(selectedValueIndex));
     2517                        ((ReifiableStub)carier).addItemIdentifier(changedIdentifier);
     2518                        contents.add(new Pair<Object, TopicMapsTypes>(changedIdentifier, TopicMapsTypes.Locator));
     2519                }
    24582520        }
    24592521       
Note: See TracChangeset for help on using the changeset viewer.