Author: kono
Date: 2011-12-13 17:44:19 -0800 (Tue, 13 Dec 2011)
New Revision: 27786
Modified:
core3/impl/trunk/datasource-biogrid-impl/src/main/java/org/cytoscape/datasource/biogrid/internal/BiogridDataLoader.java
Log:
Added method to skip unnecessary local data update.
Modified:
core3/impl/trunk/datasource-biogrid-impl/src/main/java/org/cytoscape/datasource/biogrid/internal/BiogridDataLoader.java
===================================================================
---
core3/impl/trunk/datasource-biogrid-impl/src/main/java/org/cytoscape/datasource/biogrid/internal/BiogridDataLoader.java
2011-12-14 01:27:58 UTC (rev 27785)
+++
core3/impl/trunk/datasource-biogrid-impl/src/main/java/org/cytoscape/datasource/biogrid/internal/BiogridDataLoader.java
2011-12-14 01:44:19 UTC (rev 27786)
@@ -6,6 +6,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
+import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
import java.util.HashSet;
@@ -14,6 +15,8 @@
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
+import javax.swing.filechooser.FileSystemView;
+
import org.cytoscape.datasource.DataSource;
import org.cytoscape.datasource.DefaultDataSource;
import org.cytoscape.io.DataCategory;
@@ -56,6 +59,29 @@
if (localFile.exists() == false)
localFile.mkdir();
}
+
+ /**
+ * Check local file is available or not.
+ *
+ * @return true if files are already exists.
+ */
+ private boolean isExist() {
+ if(localFile.isDirectory()) {
+ final String[] fileNames = localFile.list();
+ if(fileNames == null || fileNames.length == 0)
+ return false;
+ else {
+ for(String fileName: fileNames) {
+ if(fileName.contains("mitab"))
+ return true;
+ }
+ }
+ } else {
+ throw new IllegalStateException("given location is not
a directory.");
+ }
+
+ return false;
+ }
/**
@@ -64,6 +90,12 @@
* @throws IOException
*/
void extract() throws IOException {
+
+ if(isExist()) {
+ processExistingFiles();
+ return;
+ }
+
ZipInputStream zis = new ZipInputStream(source.openStream());
try {
@@ -94,8 +126,22 @@
zis = null;
}
}
+
+ private void processExistingFiles() throws IOException {
+ // Just need to create from existing files.
+ final File[] dataFiles = localFile.listFiles();
+ for (File file : dataFiles) {
+ final String[] data = createName(file.getName());
+ final DataSource ds = new DefaultDataSource(data[0],
data[1], data[2], DataCategory.NETWORK, file.toURI()
+ .toURL());
+ sources.add(ds);
+ }
+ return;
+ }
+
+
private void processOneEntry(File outFile, InputStream is) throws
IOException {
outFile.createNewFile();
FileWriter outWriter = new FileWriter(outFile);
--
You received this message because you are subscribed to the Google Groups
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/cytoscape-cvs?hl=en.