Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recent changes #148

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
8772892
Created RecentChangesFetcher
mardam May 29, 2015
8a37efb
add first implementation of getRecentChanges(); returns a set of Strings
mardam Jun 2, 2015
85e7724
first jUnit-Test with MockObject added
mardam Jun 2, 2015
f37e9cb
add parseTime() and corresponding test
mardam Jun 2, 2015
a673fdf
add parseAuthor and corresponding test
mardam Jun 2, 2015
85a57eb
change datatype of testfile
mardam Jun 3, 2015
24c8e7c
replace Scanner in parsing of RSS feed by BufferedReader
mardam Jun 3, 2015
0cff4a1
remove unnecessary public visabilites
mardam Jun 5, 2015
4e5506c
Edit time parsing to fix positions in line
mardam Jun 5, 2015
d95069e
Edit parsing of author to a fix beginning
mardam Jun 5, 2015
858ade7
created class RecentChange
mardam Jun 7, 2015
c4c32d3
Fix for testParseDate()
mardam Jun 7, 2015
7198237
Put RecentChange to own file and removed as inner class from
mardam Jun 7, 2015
a244f0f
add Constructor to RecentChange
mardam Jun 7, 2015
78ff331
added RecentChangesTest
mardam Jun 7, 2015
5538726
add test for Comparable-interface of RecentChange
mardam Jun 7, 2015
b22ca40
expand test for equal RecentChange
mardam Jun 7, 2015
250a451
correct style guide
mardam Jun 10, 2015
c8ced9e
fix of API URL
mardam Jun 11, 2015
fd6fa61
add buildUrl
mardam Jun 11, 2015
2fb42cf
Overload getRecentChanges
mardam Jun 11, 2015
27aafc8
Edit URL to HTPPS since WebResourceFetcher does not support http
mardam Jul 16, 2015
a7cae7a
Merge remote-tracking branch 'origin/master' into recent_changes
mardam Sep 21, 2015
d5d0761
Adapt RecentChangesFetcher to ApiConnector
mardam Sep 21, 2015
6621906
Fix URI Format
monkey2000 Sep 26, 2015
8c6010f
Merge pull request #209 from monkey2000/recent_changes
mkroetzsch Sep 30, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
* #L%
*/

import java.net.URLEncoder;
import java.io.UnsupportedEncodingException;
import org.openrdf.model.Value;
import org.wikidata.wdtk.datamodel.interfaces.DatatypeIdValue;
import org.wikidata.wdtk.datamodel.interfaces.PropertyIdValue;
Expand Down Expand Up @@ -81,8 +83,12 @@ public Value getRdfValue(StringValue value,
* @return URL of the page
*/
static String getCommonsUrl(String pageName) {
return "http://commons.wikimedia.org/wiki/File:"
+ pageName.replace(' ', '_');
try {
return "http://commons.wikimedia.org/wiki/File:"
+ URLEncoder.encode(pageName.replace(' ', '_'), "UTF-8");
} catch(UnsupportedEncodingException uee) {
logger.error("This machine does not support UTF-8 encoding");
return null;
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
package org.wikidata.wdtk.wikibaseapi;

/*
* #%L
* Wikidata Toolkit Wikibase API
* %%
* Copyright (C) 2014 - 2015 Wikidata Toolkit Developers
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/


import java.util.Date;

/**
* Simple class for saving recent changes
*
* @author Markus Damm
*
*/

class RecentChange implements Comparable<RecentChange> {

/**
* author of the recent change
*/
private String author;

/**
* property that was recently changed
*/
private String propertyName;

/**
* date and time of the recent change
*/
private Date date;

/**
* Constructor
*
* @param propertyName
* name of the changed property
* @param date
* date of the recent change
* @param author
* name of the author of the recent change
*/
RecentChange(String propertyName, Date date, String author) {
this.propertyName = propertyName;
this.date = date;
this.author = author;
}

/**
* Returns the author of the recent change
*
* @return name (if user is registered) or the ip adress (if user is
* unregistered) of the author of the recent change
*/
String getAuthor() {
return author;
}

/**
* Returns the name of the changed property
*
* @return name of the recently changed property
*/
String getPropertyName() {
return propertyName;
}

/**
* Returns the date of the recent change
*
* @return date of the recent change
*/
Date getDate() {
return date;
}

@Override
public boolean equals(Object other) {
if (other instanceof RecentChange) {
RecentChange o = (RecentChange) other;
if (this.propertyName.equals(o.propertyName)
&& (this.date.equals(o.date))
&& (this.author.equals(o.author))) {
return true;
}
}
return false;
}

@Override
public int compareTo(RecentChange other) {
if (this.date.after(other.date)) {
return 1;
}
if (this.date.before(other.date)) {
return -1;
}
return 0;
}
}
Loading