119 Date before = new Date(); |
119 Date before = new Date(); |
120 log("Time before recording to db: " + before); |
120 log("Time before recording to db: " + before); |
121 for (MetaDataInput metadataInput : metadataList) { |
121 for (MetaDataInput metadataInput : metadataList) { |
122 boolean removed = false; |
122 boolean removed = false; |
123 String logPath = null; |
123 String logPath = null; |
|
124 String currentLogPath = null; |
124 Iterator<Metadata.LogEntry> inputIterator = metadataInput.iterator(); |
125 Iterator<Metadata.LogEntry> inputIterator = metadataInput.iterator(); |
125 while (inputIterator.hasNext()) { |
126 while (inputIterator.hasNext()) { |
|
127 //Todo: better way of log handling, with metadatainput |
|
128 // metadata initialization for each logfile within |
|
129 //metadatainput itself would be better. this is temporary. |
126 Metadata.LogEntry logEntry = inputIterator.next(); |
130 Metadata.LogEntry logEntry = inputIterator.next(); |
127 if (!removed) { |
131 logPath = logEntry.getLogPath(); |
128 logPath = logEntry.getLogPath(); |
132 if (currentLogPath == null) { |
|
133 currentLogPath = logPath; |
|
134 removed = false; |
|
135 } else if (!currentLogPath.equals(logPath)) { |
|
136 finalizeForLogPath(currentLogPath, metadataInput, ormDB); |
|
137 currentLogPath = logPath; |
|
138 removed = false; |
|
139 } |
|
140 if (!removed ) { |
|
141 log.debug("processing for log: " + logPath); |
129 ormDB.removeEntries(logPath); |
142 ormDB.removeEntries(logPath); |
130 removed = true; |
143 removed = true; |
131 } |
144 } |
132 //initializes the metadata if none exists |
145 //initializes the metadata if none exists |
133 ormDB.addLogEntry(logEntry); |
146 ormDB.addLogEntry(logEntry); |
134 } |
147 } |
135 if (logPath != null && metadataInput instanceof CustomMetaDataProvider) { |
148 finalizeForLogPath(currentLogPath, metadataInput, ormDB); |
136 CustomMetaDataProvider provider = (CustomMetaDataProvider)metadataInput; |
|
137 provider.provide(ormDB, logPath); |
|
138 } |
|
139 if (logPath != null) { |
|
140 ormDB.finalizeMetadata(logPath); |
|
141 } |
|
142 } |
149 } |
143 Date after = new Date(); |
150 Date after = new Date(); |
144 log("Time after recording to db: " + after); |
151 log("Time after recording to db: " + after); |
145 log("Elapsed time: " + (after.getTime() - before.getTime()) + " ms"); |
152 log("Elapsed time: " + (after.getTime() - before.getTime()) + " ms"); |
146 log.debug("Successfully writen to DB"); |
153 log.debug("Successfully writen to DB"); |