View S3FilesResource.java
public class S3FilesResource { | |
AmazonS3Client amazonS3Client; | |
// ... | |
@Path("/files") | |
public String listS3Files() { | |
StringBuilder html = new StringBuilder("<html><body>"); | |
List<S3ObjectSummary> files = this.amazonS3Client.listObjects("myBucket").getObjectSummaries(); |
View S3FilesResourceTest.java
public class S3FilesResourceTest { | |
@Test | |
public void listFilesButNotDirectoriesAsHtml() throws Exception { | |
S3FilesResource resource = new S3FilesResource(/* pass AWS credentials ... */); | |
String html = resource.listS3Files(); | |
assertThat(html) | |
.contains("<a href='/content?fileName=/dir/file1.txt'>/dir/file1.txt</a>") | |
.contains("<a href='/content?fileName=/dir/another.txt'>/dir/another.txt</a>") | |
.doesNotContain("/dir/</a>"); // directories should be excluded |
View S3Facade.java
public interface S3Facade { | |
List<S3File> listObjects(String bucketName); | |
} |
View S3FilesResourceTest.java
public class S3FilesResourceTest { | |
private static class FakeS3Facade implements S3Facade { | |
List<S3File> fileList; | |
public List<S3File> listObjects(String bucketName) { | |
return fileList; | |
} | |
} |
View A_Client.py
... | |
# The client code | |
@my.route('/cleanjson/<collection>/') | |
def getcleanjson(collection): | |
cleandata = Cleanjson() | |
cleandata.get_mongojson(str(collection), "?s={'_id': 1}") | |
cleandata.parse_json(cleandata.rawjson) | |
return cleandata.cleanjson |
View A_Client2.py
... | |
# The client code | |
@my.route('/cleanjson/<collection>/') | |
def getcleanjson(collection): | |
return Cleanjson().get_mongojson(str(collection), "?s={'_id': 1}", format=True) |
View LogEntry.java
public interface LogEntry { | |
Date getTimestamp(); | |
/** For dumping into a .tsv file to be imported into Hadoop */ | |
String toTabDelimitedString(); | |
String getSearchTerms(); | |
boolean hasSearchTerms(); | |
String[][] getColumns(); | |
String getKey(); | |
void mergeWith(LogEntry entry); | |
} |
View LogEntry2.java
public interface LogEntry { | |
// same as before | |
} |
View augmentSeriesWithPreviousValues.js
// compare two series and add the delta to the data for the current period | |
augmentSeriesWithPreviousValues:function (seriesData, previousSeriesData) { | |
var series = seriesData.series; | |
seriesData.previous = []; | |
var previousSeries = previousSeriesData.series; | |
... // checks, computing maxRows, maxColumns, previousCategories | |
// that maps category name to series index (id) | |
for (var seriesId = 0; seriesId < series.length; seriesId++) { |
View augmentSeriesWithPreviousValues2.js
// Set seriesData.previous to hold data series of the previous period | |
// so that we may compute deltas (e.g. +10%). | |
// We also ensure that all the series, previous and current, have the same | |
// number of data points, adding fake ones if necessary, so that the delta-computation | |
// code <tbd:add reference> doesn't blow up. There may be some data missing | |
// at the end of a period, for example because months have different numbers of days. | |
// The fake elements and also any other undefined values will default to [0,0], which | |
// should be OK with all (line,area,..) graphs and tables. | |
// E.x.: seriesData.series[0].data = [ [1,"12%"],[2,"22%"],..,[31,"18%"] ], | |
// the previous month had only 30 days so we add a fake element for day 31; |
OlderNewer