Ignore:
Timestamp:
2013-01-11T18:35:45+13:00 (11 years ago)
Author:
davidb
Message:

Write out a frameID metadata value to an item's corresponding archives doc.xml file.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • other-projects/GlamED/trunk/src/org/honours/greenstone/CollectionContentEditor.java

    r26588 r26698  
    2727        List<Item> items = _collectionItem.getFrame().getItems();
    2828        boolean noChange = true;
     29        ArchiveFileReader afr = new ArchiveFileReader(_collectionItem.getDocXML());
    2930       
    3031        for(Item item : items){
     
    3334                if(item.isAnnotation()){
    3435                    //TODO: Deal with annotation items correctly.
     36                   
    3537                }else{
    3638                   
    3739                    Text text = (Text)item;
    38                    
    39                     ArchiveFileReader afe = new ArchiveFileReader(_collectionItem.getDocXML());
    40                    
     40
    4141                    if(text.getData() != null)
    4242                    if(text.getData().size() > 0){
    43                         String elemText = afe.obtainElementText(text.getData().get(0));
     43                        String elemText = afr.obtainElementText(text.getData().get(0));
    4444                   
    4545                        if(!elemText.equals(null)){
     
    5353                    if(!noChange)
    5454                        _archiveFileEditor.editArchiveDocFile(text);
     55
    5556                }
    5657            }else if(item instanceof Picture){
     
    5859            }
    5960        }
     61       
     62        noChange = writeFrameID(afr,noChange);
    6063       
    6164        //addNotes();
     
    6568    }
    6669
     70    /**
     71     * Method for adding/editing the framID metadata value
     72     * @param afr
     73     * @param noChange
     74     */
     75    private boolean writeFrameID(ArchiveFileReader afr, boolean noChange){
     76       
     77        //Write code to write frame number.
     78        String frameID = afr.obtainElementText("frameID");
     79        String currentFrameID = Integer.toString(_collectionItem.getFrame().getNumber());
     80        Text frameIDtext = null;
     81               
     82        if(frameID == null){
     83            //create a new frameID element
     84            frameIDtext = new Text(currentFrameID);
     85            frameIDtext.setData("frameID");
     86                   
     87        }else{
     88            //check if frameID is the same as the current frame name/number.
     89            if(!frameID.equals(currentFrameID)){
     90           
     91                frameIDtext = new Text(currentFrameID);
     92                frameIDtext.setData("frameID");
     93                   
     94            }
     95                   
     96        }
     97               
     98        if(frameIDtext != null){
     99            _archiveFileEditor.editArchiveDocFile(frameIDtext);
     100            noChange = false;
     101        }
     102       
     103        return noChange;
     104    }
     105
     106    /**
     107     * Method to output any notes associated with an item to the
     108     * doc.xml file.
     109     */
    67110    private void addNotes() {
    68111        //Add notes to docXML file.
Note: See TracChangeset for help on using the changeset viewer.