Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add basic browser rendering for all pages and page types

  • Loading branch information...
commit 4b8b20759d35fb8e3333950614a6a688bb4e37dc 1 parent f63fc3b
@mikecafarella mikecafarella authored
View
51 src/java/com/cloudera/recordbreaker/analyzer/FSAnalyzer.java
@@ -303,7 +303,6 @@ protected Long job(SQLiteConnection db) throws SQLiteException {
* <code>getSchemaSummaries</code> returns an instance of SchemaSummary
* for each unique schema in the database.
*/
- //static String schemaInfoQuery = "SELECT Schemas.schemaid, schemalabel, schemadescriptor, Files.fid, fname FROM Schemas, Files, TypeGuesses WHERE TypeGuesses.fid = Files.fid AND TypeGuesses.schemaid = Schemas.schemaid";
static String schemaInfoQuery = "SELECT schemaid FROM Schemas";
public List<SchemaSummary> getSchemaSummaries() {
return dbQueue.execute(new SQLiteJob<List<SchemaSummary>>() {
@@ -325,6 +324,56 @@ protected Long job(SQLiteConnection db) throws SQLiteException {
}}).complete();
}
+ /**
+ * <code>getFileSummaries</code> returns an instance of FileSummary
+ * for each unique schema in the database.
+ */
+ static String fileInfoQuery = "SELECT fid FROM Files";
+ public List<FileSummary> getFileSummaries() {
+ return dbQueue.execute(new SQLiteJob<List<FileSummary>>() {
+ protected List<FileSummary> job(SQLiteConnection db) throws SQLiteException {
+ List<FileSummary> output = new ArrayList<FileSummary>();
+ SQLiteStatement stmt = db.prepare(fileInfoQuery);
+
+ try {
+ while (stmt.step()) {
+ long fid = stmt.columnLong(0);
+ output.add(new FileSummary(FSAnalyzer.this, fid));
+ }
+ } catch (SQLiteException se) {
+ se.printStackTrace();
+ } finally {
+ stmt.dispose();
+ }
+ return output;
+ }}).complete();
+ }
+
+ /**
+ * <code>getTypeSummaries</code> returns an instance of TypeSummary
+ * for each unique type in the database.
+ */
+ static String typeInfoQuery = "SELECT typeid FROM Types";
+ public List<TypeSummary> getTypeSummaries() {
+ return dbQueue.execute(new SQLiteJob<List<TypeSummary>>() {
+ protected List<TypeSummary> job(SQLiteConnection db) throws SQLiteException {
+ List<TypeSummary> output = new ArrayList<TypeSummary>();
+ SQLiteStatement stmt = db.prepare(typeInfoQuery);
+
+ try {
+ while (stmt.step()) {
+ long typeid = stmt.columnLong(0);
+ output.add(new TypeSummary(FSAnalyzer.this, typeid));
+ }
+ } catch (SQLiteException se) {
+ se.printStackTrace();
+ } finally {
+ stmt.dispose();
+ }
+ return output;
+ }}).complete();
+ }
+
///////////////////////////////////////////
// ACCESSORS FOR INDIVIDUAL OBJECTS
///////////////////////////////////////////
View
3  src/java/com/cloudera/recordbreaker/analyzer/SchemaSummary.java
@@ -38,6 +38,9 @@ public SchemaSummary(FSAnalyzer analyzer, long schemaId) {
this.schemaId = schemaId;
this.hasData = false;
}
+ public long getSchemaId() {
+ return schemaId;
+ }
void getData() {
this.ssd = analyzer.getSchemaSummaryData(this.schemaId);
this.hasData = true;
View
3  src/java/com/cloudera/recordbreaker/analyzer/TypeSummary.java
@@ -34,6 +34,9 @@ public TypeSummary(FSAnalyzer analyzer, long typeid) {
this.typeid = typeid;
this.hasData = false;
}
+ public long getTypeId() {
+ return typeid;
+ }
void getData() {
this.tsd = analyzer.getTypeSummaryData(this.typeid);
this.hasData = true;
View
33 src/java/com/cloudera/recordbreaker/fisheye/FilePage.java
@@ -15,10 +15,17 @@
package com.cloudera.recordbreaker.fisheye;
import com.cloudera.recordbreaker.analyzer.FileSummary;
+import com.cloudera.recordbreaker.analyzer.TypeSummary;
+import com.cloudera.recordbreaker.analyzer.SchemaSummary;
+import com.cloudera.recordbreaker.analyzer.TypeGuessSummary;
+
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.markup.html.link.ExternalLink;
import org.apache.wicket.request.mapper.parameter.PageParameters;
+import java.util.List;
+
/**
* Wicket Page class that describes a specific File
*
@@ -35,14 +42,23 @@ public FilePage(PageParameters params) {
if (fidStr != null) {
try {
FileSummary fs = new FileSummary(FishEye.analyzer, Long.parseLong(fidStr));
- if (fs != null) {
- add(new Label("filetitle", fs.getFname()));
- add(new Label("filesubtitle", "in " + fs.getPath()));
- add(new Label("owner", fs.getOwner()));
- add(new Label("size", "" + fs.getSize()));
- add(new Label("lastmodified", fs.getLastModified()));
- return;
- }
+ add(new Label("filetitle", fs.getFname()));
+ add(new Label("filesubtitle", "in " + fs.getPath()));
+ add(new Label("owner", fs.getOwner()));
+ add(new Label("size", "" + fs.getSize()));
+ add(new Label("lastmodified", fs.getLastModified()));
+ add(new Label("crawledon", fs.getCrawl().getLastExamined()));
+
+ List<TypeGuessSummary> tgses = fs.getTypeGuesses();
+ TypeGuessSummary tgs = tgses.get(0);
+ TypeSummary ts = tgs.getTypeSummary();
+ SchemaSummary ss = tgs.getSchemaSummary();
+
+ String typeUrl = urlFor(FiletypePage.class, new PageParameters("typeid=" + ts.getTypeId())).toString();
+ String schemaUrl = urlFor(SchemaPage.class, new PageParameters("schemaid=" + ss.getSchemaId())).toString();
+ add(new ExternalLink("typelink", typeUrl, ts.getLabel()));
+ add(new ExternalLink("schemalink", schemaUrl, "Schema"));
+ return;
} catch (NumberFormatException nfe) {
}
}
@@ -51,5 +67,6 @@ public FilePage(PageParameters params) {
add(new Label("owner", ""));
add(new Label("size", ""));
add(new Label("lastmodified", ""));
+ add(new Label("crawledon", ""));
}
}
View
37 src/java/com/cloudera/recordbreaker/fisheye/FilesPage.java
@@ -13,14 +13,49 @@
* License.
*/
package com.cloudera.recordbreaker.fisheye;
+
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.markup.html.list.ListView;
+import org.apache.wicket.markup.html.list.ListItem;
+import org.apache.wicket.markup.html.link.ExternalLink;
+import org.apache.wicket.request.mapper.parameter.PageParameters;
+
+import java.util.List;
+
+import com.cloudera.recordbreaker.analyzer.TypeSummary;
+import com.cloudera.recordbreaker.analyzer.FileSummary;
+import com.cloudera.recordbreaker.analyzer.SchemaSummary;
+import com.cloudera.recordbreaker.analyzer.TypeGuessSummary;
/**
* The <code>FilesPage</code> renders information about all known files.
*/
public class FilesPage extends WebPage {
public FilesPage() {
- add(new Label("numFisheyeFiles", "10"));
+ List<FileSummary> list = FishEye.analyzer.getFileSummaries();
+ ListView<FileSummary> listview = new ListView<FileSummary>("listview", list) {
+ protected void populateItem(ListItem<FileSummary> item) {
+ FileSummary fs = item.getModelObject();
+
+ // Fields are: 'filelink', 'sizelabel', 'typelink', and 'schemalink'
+ String fileUrl = urlFor(FilePage.class, new PageParameters("fid=" + fs.getFid())).toString();
+ item.add(new ExternalLink("filelink", fileUrl, fs.getFname()));
+
+ item.add(new Label("sizelabel", "" + fs.getSize()));
+
+ List<TypeGuessSummary> tgs = fs.getTypeGuesses();
+ TypeSummary ts = tgs.get(0).getTypeSummary();
+ SchemaSummary ss = tgs.get(0).getSchemaSummary();
+
+ String typeUrl = urlFor(FiletypePage.class, new PageParameters("typeid=" + ts.getTypeId())).toString();
+ item.add(new ExternalLink("typelink", typeUrl, ts.getLabel()));
+
+ String schemaUrl = urlFor(SchemaPage.class, new PageParameters("schemaid=" + ss.getSchemaId())).toString();
+ item.add(new ExternalLink("schemalink", schemaUrl, "Schema"));
+ }
+ };
+ add(listview);
+ add(new Label("numFisheyeFiles", "" + list.size()));
}
}
View
42 src/java/com/cloudera/recordbreaker/fisheye/FiletypePage.java
@@ -14,8 +14,19 @@
*/
package com.cloudera.recordbreaker.fisheye;
+import com.cloudera.recordbreaker.analyzer.TypeSummary;
+import com.cloudera.recordbreaker.analyzer.FileSummary;
+import com.cloudera.recordbreaker.analyzer.SchemaSummary;
+import com.cloudera.recordbreaker.analyzer.TypeGuessSummary;
+
import org.apache.wicket.markup.html.WebPage;
+import org.apache.wicket.markup.html.list.ListView;
+import org.apache.wicket.markup.html.list.ListItem;
+import org.apache.wicket.markup.html.link.ExternalLink;
import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.request.mapper.parameter.PageParameters;
+
+import java.util.List;
/**
* Wicket Page class that describes a specific file type
@@ -28,4 +39,35 @@
public class FiletypePage extends WebPage {
public FiletypePage() {
}
+ public FiletypePage(PageParameters params) {
+ String filetypeStr = params.get("typeid").toString();
+ if (filetypeStr != null) {
+ try {
+ // Metadata for type
+ TypeSummary ts = new TypeSummary(FishEye.analyzer, Long.parseLong(filetypeStr));
+ add(new Label("typetitle", ts.getLabel()));
+ List<TypeGuessSummary> tgses = ts.getTypeGuesses();
+
+ // Files that have this type
+ ListView<TypeGuessSummary> observationList = new ListView<TypeGuessSummary>("observations", tgses) {
+ protected void populateItem(ListItem<TypeGuessSummary> item) {
+ TypeGuessSummary tgs = item.getModelObject();
+ FileSummary fs = tgs.getFileSummary();
+ SchemaSummary ss = tgs.getSchemaSummary();
+
+ String fileUrl = urlFor(FilePage.class, new PageParameters("fid=" + fs.getFid())).toString();
+ item.add(new ExternalLink("filelink", fileUrl, fs.getFname()));
+
+ String schemaUrl = urlFor(SchemaPage.class, new PageParameters("schemaid=" + ss.getSchemaId())).toString();
+ item.add(new ExternalLink("schemalink", schemaUrl, "Schema"));
+ }
+ };
+ add(observationList);
+
+ return;
+ } catch (NumberFormatException nfe) {
+ }
+ }
+ add(new Label("typetitle", ""));
+ }
}
View
20 src/java/com/cloudera/recordbreaker/fisheye/FiletypesPage.java
@@ -14,14 +14,32 @@
*/
package com.cloudera.recordbreaker.fisheye;
+import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.wicket.markup.html.WebPage;
+import org.apache.wicket.markup.html.list.ListView;
+import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.markup.html.link.ExternalLink;
+
+import java.util.List;
+
+import com.cloudera.recordbreaker.analyzer.TypeSummary;
/**
* The <code>SchemasPage</code> renders information about all known filetypes
*/
public class FiletypesPage extends WebPage {
public FiletypesPage() {
- add(new Label("numFisheyeFiletypes", "3"));
+ List<TypeSummary> list = FishEye.analyzer.getTypeSummaries();
+ ListView<TypeSummary> listview = new ListView<TypeSummary>("listview", list) {
+ protected void populateItem(ListItem<TypeSummary> item) {
+ TypeSummary ts = item.getModelObject();
+
+ String typeUrl = urlFor(FiletypePage.class, new PageParameters("typeid=" + ts.getTypeId())).toString();
+ item.add(new ExternalLink("typelabel", typeUrl, ts.getLabel()));
+ }
+ };
+ add(listview);
+ add(new Label("numFisheyeTypes", "" + list.size()));
}
}
View
2  src/java/com/cloudera/recordbreaker/fisheye/FishEye.java
@@ -54,8 +54,6 @@ public FishEye(int port, File htmlRoot, File schemaDir, File fisheyeDir) throws
this.schemaDir = schemaDir;
this.fisheyeDir = fisheyeDir;
FishEye.analyzer = new FSAnalyzer(fisheyeDir, schemaDir);
- System.err.println("Schema summary list: " + analyzer.getSchemaSummaries().size());
- System.err.println("Schema summary list: " + analyzer.getSchemaSummaries().size());
}
public void run() throws Exception {
View
7 src/java/com/cloudera/recordbreaker/fisheye/FishEyeWebApplication.java
@@ -6,11 +6,9 @@
import org.apache.wicket.util.resource.locator.ResourceStreamLocator;
import org.apache.wicket.util.resource.IResourceStream;
-
/**
* The <code>FishEyeWebApplication</code> class sets up some config information
* for the Web app. It doesn't do a ton of interesting things.
- *
*/
public class FishEyeWebApplication extends WebApplication {
public FishEyeWebApplication() {
@@ -34,11 +32,8 @@ private String trimFolders(String path) {
public void init() {
super.init();
IResourceSettings resourceSettings = getResourceSettings();
- String htmlDir = this.getClass().getClassLoader().getResource("Overview.html").toExternalForm();
- resourceSettings.addResourceFolder(htmlDir);
resourceSettings.setResourceStreamLocator(new PathStripperLocator());
- mountPage("/Overview", Overview.class);
mountPage("/About", AboutPage.class);
mountPage("/Files", FilesPage.class);
@@ -54,6 +49,6 @@ public void init() {
@Override
public Class<? extends Page> getHomePage() {
- return Overview.class;
+ return FilesPage.class;
}
}
View
10 src/java/com/cloudera/recordbreaker/fisheye/Overview.java
@@ -1,10 +0,0 @@
-package com.cloudera.recordbreaker.fisheye;
-
-import org.apache.wicket.markup.html.WebPage;
-import org.apache.wicket.markup.html.basic.Label;
-
-public class Overview extends WebPage {
- public Overview() {
- add(new Label("numFisheyeFiles", "10"));
- }
-}
View
17 src/web/FilePage.html
@@ -37,10 +37,10 @@
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
- <a class="brand" href="/Overview">Cloudera Fisheye</a>
+ <a class="brand" href="/">Cloudera Fisheye</a>
<div class="nav-collapse">
<ul class="nav">
- <li><a href="/Overview">Home</a></li>
+ <li><a href="/">Home</a></li>
<li><a href="About">About</a></li>
</ul>
</div><!--/.nav-collapse -->
@@ -53,7 +53,6 @@
<div class="span2">
<div class="well sidebar-nav">
<ul class="nav nav-list">
- <li class="nav-header"><a href="/Overview">Overview</a></li>
<li class="nav-header"><a href="/Files">Files</a></li>
<!--<li><a href="path?targetpath=asdasd">asdasd</a></li>
<li><a href="path?targetpath=blimfark">blimfark</a></li>
@@ -91,6 +90,18 @@
<td>last modified</td>
<td><span wicket:id="lastmodified" /></td>
</tr>
+ <tr>
+ <td>crawled on</td>
+ <td><span wicket:id="crawledon" /></td>
+ </tr>
+ <tr>
+ <td>type</td>
+ <td><a href="#" wicket:id="typelink"></a></td>
+ </tr>
+ <tr>
+ <td>schema</td>
+ <td><a href="#" wicket:id="schemalink"></a></td>
+ </tr>
</tbody>
</table>
View
21 src/web/FilesPage.html
@@ -37,10 +37,10 @@
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
- <a class="brand" href="/Overview">Cloudera Fisheye</a>
+ <a class="brand" href="/">Cloudera Fisheye</a>
<div class="nav-collapse">
<ul class="nav">
- <li><a href="/Overview">Home</a></li>
+ <li><a href="/">Home</a></li>
<li><a href="About">About</a></li>
</ul>
</div><!--/.nav-collapse -->
@@ -53,7 +53,6 @@
<div class="span2">
<div class="well sidebar-nav">
<ul class="nav nav-list">
- <li class="nav-header"><a href="/Overview">Overview</a></li>
<li class="nav-header active"><a href="/Files">Files</a></li>
<!--<li><a href="path?targetpath=asdasd">asdasd</a></li>
<li><a href="path?targetpath=blimfark">blimfark</a></li>
@@ -75,6 +74,22 @@
<h1>Files</h1>
<p>Fisheye is currently staring at <span wicket:id="numFisheyeFiles"></span> files.</p>
+ <table class="table table-striped table-bordered table-condensed">
+ <thead>
+ <tr>
+ <th>file</th>
+ <th>size</th>
+ <th>type</th>
+ <th>schema</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr wicket:id="listview">
+ <td><a href="#" wicket:id="filelink"></a></td><td><span wicket:id="sizelabel"/></td><td><a href="#" wicket:id="typelink"/></td><td><a href="#" wicket:id="schemalink"/></td>
+ </tr>
+ </tbody>
+ </table>
+
</div> <!-- /container -->
</div>
</div>
View
22 src/web/Overview.html → src/web/FiletypePage.html
@@ -37,10 +37,10 @@
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
- <a class="brand" href="/Overview">Cloudera Fisheye</a>
+ <a class="brand" href="/">Cloudera Fisheye</a>
<div class="nav-collapse">
<ul class="nav">
- <li class="active"><a href="/Overview">Home</a></li>
+ <li><a href="/">Home</a></li>
<li><a href="About">About</a></li>
</ul>
</div><!--/.nav-collapse -->
@@ -53,7 +53,6 @@
<div class="span2">
<div class="well sidebar-nav">
<ul class="nav nav-list">
- <li class="nav-header active"><a href="/Overview">Overview</a></li>
<li class="nav-header"><a href="/Files">Files</a></li>
<!--<li><a href="path?targetpath=asdasd">asdasd</a></li>
<li><a href="path?targetpath=blimfark">blimfark</a></li>
@@ -72,9 +71,22 @@
</div>
<div class="span10">
<div class="container">
- <h1>Overview</h1>
- <p>Fisheye is currently staring at <span wicket:id="numFisheyeFiles"></span> files.</p>
+ <h1>Type: <span wicket:id="typetitle"/></h1>
+ Files with this type:
+ <table class="table table-striped table-bordered table-condensed">
+ <thead>
+ <tr>
+ <th>File</th>
+ <th>Schema</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr wicket:id="observations">
+ <td><a href="#" wicket:id="filelink"></a></td><td><a href="#" wicket:id="schemalink"></a></td>
+ </tr>
+ </tbody>
+ </table>
</div> <!-- /container -->
</div>
</div>
View
19 src/web/FiletypesPage.html
@@ -37,10 +37,10 @@
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
- <a class="brand" href="/Overview">Cloudera Fisheye</a>
+ <a class="brand" href="/">Cloudera Fisheye</a>
<div class="nav-collapse">
<ul class="nav">
- <li><a href="/Overview">Home</a></li>
+ <li><a href="/">Home</a></li>
<li><a href="About">About</a></li>
</ul>
</div><!--/.nav-collapse -->
@@ -53,7 +53,6 @@
<div class="span2">
<div class="well sidebar-nav">
<ul class="nav nav-list">
- <li class="nav-header"><a href="/Overview">Overview</a></li>
<li class="nav-header"><a href="/Files">Files</a></li>
<!--<li><a href="path?targetpath=asdasd">asdasd</a></li>
<li><a href="path?targetpath=blimfark">blimfark</a></li>
@@ -73,7 +72,19 @@
<div class="span10">
<div class="container">
<h1>Filetypes</h1>
- <p>Fisheye is currently gazing at <span wicket:id="numFisheyeFiletypes"></span> filetypes.</p>
+ <p>Fisheye is currently gazing, unblinking, at <span wicket:id="numFisheyeTypes"></span> file types.</p>
+ <table class="table table-striped table-bordered table-condensed">
+ <thead>
+ <tr>
+ <th>Type</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr wicket:id="listview">
+ <td><a href="#" wicket:id="typelabel"></a></td>
+ </tr>
+ </tbody>
+ </table>
</div> <!-- /container -->
</div>
View
5 src/web/SchemaPage.html
@@ -37,10 +37,10 @@
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
- <a class="brand" href="/Overview">Cloudera Fisheye</a>
+ <a class="brand" href="/">Cloudera Fisheye</a>
<div class="nav-collapse">
<ul class="nav">
- <li><a href="/Overview">Home</a></li>
+ <li><a href="/">Home</a></li>
<li><a href="About">About</a></li>
</ul>
</div><!--/.nav-collapse -->
@@ -53,7 +53,6 @@
<div class="span2">
<div class="well sidebar-nav">
<ul class="nav nav-list">
- <li class="nav-header"><a href="/Overview">Overview</a></li>
<li class="nav-header"><a href="/Files">Files</a></li>
<!--<li><a href="path?targetpath=asdasd">asdasd</a></li>
<li><a href="path?targetpath=blimfark">blimfark</a></li>
View
5 src/web/SchemasPage.html
@@ -37,10 +37,10 @@
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
- <a class="brand" href="/Overview">Cloudera Fisheye</a>
+ <a class="brand" href="/">Cloudera Fisheye</a>
<div class="nav-collapse">
<ul class="nav">
- <li><a href="/Overview">Home</a></li>
+ <li><a href="/">Home</a></li>
<li><a href="About">About</a></li>
</ul>
</div><!--/.nav-collapse -->
@@ -53,7 +53,6 @@
<div class="span2">
<div class="well sidebar-nav">
<ul class="nav nav-list">
- <li class="nav-header"><a href="/Overview">Overview</a></li>
<li class="nav-header"><a href="/Files">Files</a></li>
<!--<li><a href="path?targetpath=asdasd">asdasd</a></li>
<li><a href="path?targetpath=blimfark">blimfark</a></li>
View
5 src/web/SettingsPage.html
@@ -37,10 +37,10 @@
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
- <a class="brand" href="/Overview">Cloudera Fisheye</a>
+ <a class="brand" href="/">Cloudera Fisheye</a>
<div class="nav-collapse">
<ul class="nav">
- <li><a href="/Overview">Home</a></li>
+ <li><a href="/">Home</a></li>
<li><a href="About">About</a></li>
</ul>
</div><!--/.nav-collapse -->
@@ -53,7 +53,6 @@
<div class="span2">
<div class="well sidebar-nav">
<ul class="nav nav-list">
- <li class="nav-header"><a href="/Overview">Overview</a></li>
<li class="nav-header"><a href="/Files">Files</a></li>
<!--<li><a href="path?targetpath=asdasd">asdasd</a></li>
<li><a href="path?targetpath=blimfark">blimfark</a></li>
Please sign in to comment.
Something went wrong with that request. Please try again.