Changeset 8013
- Timestamp:
- 2004-08-20T13:14:21+12:00 (20 years ago)
- Location:
- trunk/gli/src/org/greenstone/gatherer/metadata
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/metadata/DocXMLFileManager.java
r7978 r8013 35 35 static public void loadDocXMLFiles(File directory) 36 36 { 37 // Make sure the directory (archives) exists 38 if (directory.exists() == false) { 39 return; 40 } 41 37 42 // Look recursively at each subfile of the directory for doc.xml files 38 43 File[] directory_files = directory.listFiles(); -
trunk/gli/src/org/greenstone/gatherer/metadata/MetadataAuditTableModel.java
r7978 r8013 8 8 import javax.swing.table.*; 9 9 import org.greenstone.gatherer.Configuration; 10 import org.greenstone.gatherer.Dictionary;11 10 import org.greenstone.gatherer.Gatherer; 12 11 import org.greenstone.gatherer.file.FileNode; … … 18 17 /** The FileNodes this model is built for */ 19 18 private FileNode[] file_nodes = null; 20 private ArrayList metadata_values = null; 19 /** The list of MetadataElements in the table (columns) */ 20 private ArrayList metadata_elements = new ArrayList(); 21 /** The list of MetadataAuditTableEntries in the table (rows) */ 22 private ArrayList metadata_audit_table_entries = new ArrayList(); 21 23 22 24 … … 24 26 public int getColumnCount() 25 27 { 26 return 1; // !!! TO DO28 return metadata_elements.size(); 27 29 } 28 30 29 31 30 / / /** Retrieves the name of the specified column. */31 //public String getColumnName(int col)32 //{33 // return COLUMN_NAMES[col];34 //}32 /** Retrieves the name of the specified column. */ 33 public String getColumnName(int col) 34 { 35 return metadata_elements.get(col).toString(); 36 } 35 37 36 38 37 // /* Called to retrieve the MetadataValueTableEntry at a certain row. Usually caused by the user selecting a row in the table. It is synchronized so that the model doesn't up and change while we're trying to retrieve the indicated element. */ 38 // public synchronized MetadataValueTableEntry getMetadataValueTableEntry(int row) 39 // { 40 // if (row >= 0 && row < metadata_value_table_entries.size()) { 41 // return (MetadataValueTableEntry) metadata_value_table_entries.get(row); 42 // } 43 44 // return null; 45 // } 46 47 48 /** Returns the number of rows in this table. */ 39 /** Returns the number of rows in this table. */ 49 40 public int getRowCount() 50 41 { 51 return metadata_ values.size();42 return metadata_audit_table_entries.size(); 52 43 } 53 44 … … 57 48 { 58 49 // Check values are reasonable 59 if (row < 0 || row >= metadata_ values.size() || col < 0 || col >= getColumnCount()) {50 if (row < 0 || row >= metadata_audit_table_entries.size() || col < 0 || col >= metadata_elements.size()) { 60 51 return null; 61 52 } 62 53 63 return null; 54 MetadataAuditTableEntry metadata_audit_table_entry = (MetadataAuditTableEntry) metadata_audit_table_entries.get(row); 55 return metadata_audit_table_entry.getMetadataValueTreeNode(col); 64 56 } 65 57 … … 67 59 public void rebuild(FileNode[] file_nodes) 68 60 { 69 metadata_values.clear(); 61 metadata_elements = MetadataSetManager.getEveryMetadataSetElement(); 62 metadata_audit_table_entries.clear(); 70 63 71 64 this.file_nodes = file_nodes; 65 if (file_nodes != null && file_nodes.length > 0) { 66 // Create model builder 67 MetadataAuditTableModelBuilder builder = new MetadataAuditTableModelBuilder(); 68 builder.run(); 69 } 72 70 } 73 71 74 72 75 // public void rebuild(FileNode[] file_nodes) 76 // { 77 // metadata_value_table_entries.clear(); 73 private class MetadataAuditTableModelBuilder 74 { 75 public void run() 76 { 77 // Build a list of MetadataAuditTableEntries that represent the metadata asssigned to the selected files 78 System.err.println("Building MetadataAuditTableModel..."); 78 79 79 // if (!Gatherer.c_man.ready()) { 80 // Gatherer.println("Not ready!"); 81 // return;82 // } 80 // Process each of the selected files in turn 81 for (int i = 0; i < file_nodes.length; i++) { 82 File current_file = file_nodes[i].getFile(); 83 System.err.println(" File: " + current_file); 83 84 84 // this.file_nodes = file_nodes; 85 // if (file_nodes != null && file_nodes.length > 0) { 86 // // Create model builder 87 // MetadataValueTableModelBuilder builder = new MetadataValueTableModelBuilder(); 88 // builder.run(); 89 // } 90 // } 85 // Get the metadata assigned to this file 86 ArrayList current_file_metadata = MetadataXMLFileManager.getMetadataAssignedToFile(current_file); 87 88 // Get the extracted metadata for this file, if desired 89 if (Gatherer.config.get("general.view_extracted_metadata", Configuration.COLLECTION_SPECIFIC) == true) { 90 current_file_metadata.addAll(DocXMLFileManager.getMetadataExtractedFromFile(current_file)); 91 } 92 93 MetadataAuditTableEntry metadata_audit_table_entry = new MetadataAuditTableEntry(current_file, current_file_metadata); 94 metadata_audit_table_entries.add(metadata_audit_table_entry); 95 } 96 } 97 } 91 98 92 99 93 // private class MetadataValueTableModelBuilder 94 // { 95 // public void run() 96 // { 97 // // Build a list of MetadataValueTableEntries that represent the metadata asssigned to the selected files 98 // boolean hid_extracted_metadata = false; 99 // boolean has_inherited_metadata = false; 100 // ArrayList metadata_elements_seen = new ArrayList(); 101 102 // // Process each of the selected files in turn 103 // for (int i = 0; i < file_nodes.length; i++) { 104 // File current_file = file_nodes[i].getFile(); 105 106 // // Get the metadata assigned to this file 107 // ArrayList assigned_metadata = MetadataXMLFileManager.getMetadataAssignedToFile(current_file); 108 // for (int j = 0; j < assigned_metadata.size(); j++) { 109 // MetadataValue metadata_value = (MetadataValue) assigned_metadata.get(j); 110 // MetadataElement metadata_element = metadata_value.getMetadataElement(); 111 112 // // Note if there is inherited (folder-level) metadata in the table 113 // has_inherited_metadata = has_inherited_metadata || metadata_value.isInheritedMetadata(); 114 115 // // Insert this metadata value into the table, unless it already exists (in which case increment its count) 116 // insertMetadataValueIntoTable(metadata_value); 117 118 // // Remember we have seen this metadata element 119 // if (metadata_elements_seen.contains(metadata_element) == false) { 120 // metadata_elements_seen.add(metadata_element); 121 // } 122 // } 123 124 // // Get the extracted metadata for this file, if desired 125 // if (Gatherer.config.get("general.view_extracted_metadata", Configuration.COLLECTION_SPECIFIC) == true) { 126 // ArrayList extracted_metadata = DocXMLFileManager.getMetadataExtractedFromFile(current_file); 127 // for (int k = 0; k < extracted_metadata.size(); k++) { 128 // MetadataValue metadata_value = (MetadataValue) extracted_metadata.get(k); 129 130 // // Insert this metadata value into the table, unless it already exists (in which case increment its count) 131 // insertMetadataValueIntoTable(metadata_value); 132 // } 133 // } 134 // } 135 136 // // Make sure each non-extracted metadata element appears in the table (even if blank) 137 // ArrayList every_metadata_set_element = MetadataSetManager.getEveryMetadataSetElement(); 138 // for (int i = 0; i < every_metadata_set_element.size(); i++) { 139 // MetadataElement metadata_element = (MetadataElement) every_metadata_set_element.get(i); 140 141 // // If we haven't seen this metadata element and it isn't extracted, add it now 142 // if (!metadata_elements_seen.contains(metadata_element) && !metadata_element.isExtractedMetadata()) { 143 // MetadataValueTableEntry metadata_value_table_entry = new MetadataValueTableEntry(metadata_element, new MetadataValueTreeNode("")); 144 145 // // Blank metadata is common to all selected files (otherwise it wouldn't be blank!) 146 // metadata_value_table_entry.setOccurrences(file_nodes.length); 147 148 // // Add it to the table 149 // insertMetadataValueIntoTable(metadata_value_table_entry); 150 // } 151 // } 152 153 // // If extracted metadata was hidden, display the warning 154 // if (hid_extracted_metadata) { 155 // showExtractedMetadataWarning(); 156 // } 157 158 // // If there is inherited metadata, display the warning 159 // if (has_inherited_metadata) { 160 // showInheritedMetadataWarning(); 161 // } 162 // } 100 /** This class represents one (file, metadata) pair */ 101 private class MetadataAuditTableEntry 102 { 103 private File file = null; 104 private MetadataValue[] metadata_values = null; 163 105 164 106 165 // /** Alphabetically inserts the new metadata value into the table */ 166 // private void insertMetadataValueIntoTable(MetadataValue metadata_value) 167 // { 168 // for (int i = 0; i < metadata_value_table_entries.size(); i++) { 169 // MetadataValueTableEntry current_metadata_value_table_entry = (MetadataValueTableEntry) metadata_value_table_entries.get(i); 170 // int c = current_metadata_value_table_entry.compareTo(metadata_value); 107 public MetadataAuditTableEntry(File file, ArrayList metadata_values_list) 108 { 109 this.file = file; 171 110 172 // // Insert value before existing entry 173 // if (c > 0) { 174 // metadata_value_table_entries.add(i, new MetadataValueTableEntry(metadata_value)); 175 // fireTableRowsInserted(i, i); 176 // return; 177 // } 111 metadata_values = new MetadataValue[metadata_elements.size()]; 112 for (int i = 0; i < metadata_values_list.size(); i++) { 113 MetadataValue metadata_value = (MetadataValue) metadata_values_list.get(i); 114 MetadataElement metadata_element = metadata_value.getMetadataElement(); 178 115 179 // // Entry already exists (increment existing count) 180 // if (c == 0) { 181 // current_metadata_value_table_entry.anotherOccurrence(); 182 // return; 183 // } 184 // } 116 // Find the right column to put the value in 117 for (int j = 0; j < metadata_elements.size(); j++) { 118 if (metadata_element.equals(metadata_elements.get(j))) { 119 metadata_values[j] = metadata_value; 120 break; 121 } 122 } 123 } 124 } 185 125 186 // // Must go at the end of the table 187 // metadata_value_table_entries.add(new MetadataValueTableEntry(metadata_value)); 188 // fireTableRowsInserted(metadata_value_table_entries.size() - 1, metadata_value_table_entries.size() - 1); 189 // } 126 127 public MetadataValueTreeNode getMetadataValueTreeNode(int col) 128 { 129 if (metadata_values[col] == null) { 130 return null; 131 } 132 133 return metadata_values[col].getMetadataValueTreeNode(); 134 } 135 } 190 136 } -
trunk/gli/src/org/greenstone/gatherer/metadata/MetadataValueTableModel.java
r7978 r8013 22 22 private ArrayList metadata_value_table_entries = new ArrayList(); 23 23 24 static final private String[] COLUMN_NAMES = { "", Dictionary.get("Metadata.Element"), Dictionary.get("Metadata.Value")};24 static final private String[] COLUMN_NAMES = { "", Dictionary.get("Metadata.Element"), Dictionary.get("Metadata.Value") }; 25 25 26 26 -
trunk/gli/src/org/greenstone/gatherer/metadata/MetadataXMLFileManager.java
r7978 r8013 92 92 static public void loadMetadataXMLFiles(File directory) 93 93 { 94 // Make sure the directory (import) exists 95 if (directory.exists() == false) { 96 return; 97 } 98 94 99 // Look recursively at each subfile of the directory for metadata.xml files 95 100 File[] directory_files = directory.listFiles();
Note:
See TracChangeset
for help on using the changeset viewer.