Skip to content

Commit

Permalink
remove trailing whitespace, ref #274
Browse files Browse the repository at this point in the history
i didn't touch the migrations, though
  • Loading branch information
karyon committed Apr 24, 2014
1 parent efe3e81 commit 9519182
Show file tree
Hide file tree
Showing 76 changed files with 779 additions and 779 deletions.
8 changes: 4 additions & 4 deletions Anonymization/src/de/myhpi/evap/anonymizer/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ public class Main {
public static void main(String[] args) throws IOException, ClassNotFoundException, SQLException {
Properties properties = new Properties();
properties.load(new FileReader(args[0]));

Connection connection = connectToDB(properties);

UserSubstitution.substitute(properties, connection);
CourseShuffling.shuffle(properties, connection);
CommentSubstitution.substitute(properties, connection);

connection.close();
}

private static Connection connectToDB(Properties properties) throws ClassNotFoundException, SQLException {
Class.forName("org.postgresql.Driver");
String db_url = properties.getProperty("db_url");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ public class Comment {
private int id;
private String reviewed_answer;
private String original_answer;

public Comment(int id, String reviewed_answer, String original_answer) {
this.id = id;
this.reviewed_answer = reviewed_answer;
this.original_answer = original_answer;
}

public int getId() {
return id;
}

public String getReviewed_answer() {
return reviewed_answer;
}

public String getOriginal_answer() {
return original_answer;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ public class CommentSubstitution {
public static void substitute(Properties properties, Connection connection)
throws IOException, SQLException {
System.out.println("Substituting comments");

String[] loremIpsum = getLoremIpsum(properties);

String table = properties.getProperty("db_comment_table");
List<Comment> comments = readCommentsFromDB(table, connection);

substituteComments(loremIpsum, comments, table, connection);

System.out.println("Comments substituted");
}

private static List<Comment> readCommentsFromDB(String table, Connection connection)
throws SQLException {
List<Comment> comments = new ArrayList<Comment>();
Expand All @@ -48,20 +48,20 @@ private static String[] getLoremIpsum(Properties properties)
String loremIpsumRaw = FileHelper.readLinesFromFile(loremIpsumFile).get(0);
return loremIpsumRaw.split(" ");
}

private static void substituteComments(String[] loremIpsum,
List<Comment> comments, String table, Connection connection)
throws SQLException {
PreparedStatement preparedStatement = connection.prepareStatement(
"UPDATE " + table + " " +
"SET reviewed_answer = ?, original_answer = ? " +
"WHERE id = ?");

for (Comment comment : comments) {
int id = comment.getId();
String reviewed_answer = comment.getReviewed_answer();
String original_answer = comment.getOriginal_answer();

preparedStatement.setInt(3, id);
preparedStatement.setString(1, getLoremIpsumSubstitution(loremIpsum, reviewed_answer));
preparedStatement.setString(2, getLoremIpsumSubstitution(loremIpsum, original_answer));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ public Course(int id, String name_de, String name_en) {
this.name_de = name_de;
this.name_en = name_en;
}

public int getId() {
return id;
}

public String getName_de() {
return name_de;
}

public String getName_en() {
return name_en;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ public class CourseShuffling {
public static void shuffle(Properties properties, Connection connection)
throws SQLException, IOException {
System.out.println("Shuffling courses");

String table = properties.getProperty("db_course_table");

List<Course> courses = readCoursesFromDB(table, connection);
List<Course> shuffledCourses = new ArrayList<Course>(courses);
Collections.shuffle(shuffledCourses);

String outputFile = properties.getProperty("output_courses");
substituteCourses(courses, shuffledCourses, table, outputFile, connection);

System.out.println("Courses shuffled, results written to " + outputFile);
}

Expand All @@ -52,9 +52,9 @@ private static void substituteCourses(List<Course> courses,
"UPDATE " + table + " " +
"SET name_de = ?, name_en = ? " +
"WHERE id = ?");

StringBuffer changes = new StringBuffer();

for (int i=0; i<courses.size(); i++) {
Course original = courses.get(i);
Course substitute = shuffledCourses.get(i);
Expand All @@ -67,7 +67,7 @@ private static void substituteCourses(List<Course> courses,
preparedStatement.setString(2, substitute.getName_en());
preparedStatement.executeUpdate();
}

FileHelper.writeToFile(changes.toString(), outputFile);
}
}
16 changes: 8 additions & 8 deletions Anonymization/src/de/myhpi/evap/anonymizer/users/Person.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,29 @@ public class Person {
private String firstname;
private String lastname;
private String username;

public Person(String firstname, String lastname) {
this.firstname = firstname;
this.lastname = lastname;
this.username = firstname.toLowerCase() + "." + lastname.toLowerCase();
}

public String getFirstname() {
return firstname;
}

public String getLastname() {
return lastname;
}

public String getUsername() {
return username;
}

public String getUsernameExternal() {
return username + ".ext";
}

public String getHPIStudentEmail() {
return username + "@student.hpi.uni-potsdam.de";
}
Expand All @@ -38,15 +38,15 @@ public String getHPIStaffEmail() {
public String getExternalEmail() {
return username + "@myhpi.de";
}

@Override
public boolean equals(Object other) {
if (other instanceof Person) {
return username.equals(((Person) other).getUsername());
}
return false;
}

@Override
public int hashCode() {
return username.hashCode()*3+1;
Expand Down
8 changes: 4 additions & 4 deletions Anonymization/src/de/myhpi/evap/anonymizer/users/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@
public class User {
private String username;
private String email;

public User(String username, String email) {
this.username = username;
this.email = email;
}

public String getUsername() {
return username;
}

public boolean isHPIStudent() {
return email.contains("@student.hpi.uni-potsdam.de");
}

public boolean isHPIStaff() {
return email.contains("@hpi.uni-potsdam.de");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,23 @@

public class UserSubstitution {
public static final int NUMBER_OF_PERSONS = 2000;

public static void substitute(Properties properties, Connection connection)
throws IOException, SQLException {
System.out.println("Substituting users");

String firstnamesFile = properties.getProperty("input_first_names");
String lastnamesFile = properties.getProperty("input_last_names");
String ignoreFile = properties.getProperty("input_ignores");
String outputFile = properties.getProperty("output_users");
String table = properties.getProperty("db_user_table");

List<Person> persons = createPersons(firstnamesFile, lastnamesFile);
List<User> users = readUsersFromDB(table, connection);
List<String> ignores = FileHelper.readLinesFromFile(ignoreFile);

substituteUsers(users, persons, ignores, table, connection, outputFile);

System.out.println("Users substituted, results written to " + outputFile);
}

Expand All @@ -40,7 +40,7 @@ private static List<Person> createPersons(String firstnamesFile,
List<String> firstnames = FileHelper.readLinesFromFile(firstnamesFile);
List<String> lastnames = FileHelper.readLinesFromFile(lastnamesFile);
List<Person> persons = new ArrayList<Person>(NUMBER_OF_PERSONS);

Random random = new Random(System.currentTimeMillis());
while (persons.size() < NUMBER_OF_PERSONS) {
int firstnameI = random.nextInt(firstnames.size());
Expand All @@ -56,7 +56,7 @@ private static List<Person> createPersons(String firstnamesFile,
private static List<User> readUsersFromDB(String table, Connection connection)
throws SQLException {
List<User> users = new ArrayList<User>();

Statement statement = connection.createStatement();
statement.execute("SELECT username, email FROM " + table);
ResultSet resultSet = statement.getResultSet();
Expand All @@ -67,7 +67,7 @@ private static List<User> readUsersFromDB(String table, Connection connection)
users.add(new User(username, email));
}
}

return users;
}

Expand All @@ -79,9 +79,9 @@ private static void substituteUsers(List<User> users, List<Person> persons,
"UPDATE " + table + " " +
"SET username = ?, first_name = ?, last_name = ?, email = ? " +
"WHERE username = ?");

StringBuffer changes = new StringBuffer();

for (int i=0; i < users.size(); i++) {
User user = users.get(i);
if (!ignores.contains(user.getUsername().toLowerCase())) {
Expand All @@ -108,7 +108,7 @@ private static void substituteUsers(List<User> users, List<Person> persons,
preparedStatement.executeUpdate();
}
}

FileHelper.writeToFile(changes.toString(), outputFile);
}
}
26 changes: 13 additions & 13 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@
What is EvaP?
-------------

EvaP (a successor to the infamous EvaJ) is a course evaluation system used
EvaP (a successor to the infamous EvaJ) is a course evaluation system used
internally at Hasso Plattner Institute.

For the documentation, please look into the *docs* subdirectory or the generated
For the documentation, please look into the *docs* subdirectory or the generated
documentation at ReadTheDocs: https://evap.readthedocs.org.

Installation
------------

EvaP is a plain Django application leveraging South for database migrations. In order to start hacking away,
EvaP is a plain Django application leveraging South for database migrations. In order to start hacking away,

(1) simply install the requirements::

pip install -r requirements.txt

(2) go into the evap folder::

cd evap
Expand All @@ -33,11 +33,11 @@ EvaP is a plain Django application leveraging South for database migrations. In
(4) create yourself some users::

python manage.py create_user -p

(5) start the development server::

python evap/manage.py runserver

(6) and open your browser::

http://localhost:8000/
Expand Down Expand Up @@ -68,14 +68,14 @@ Contributors to EvaP
License
-------

The software is licensed under the MIT license. The source code includes other
components in whole or in part; namely jQuery, jQuery UI, jQuery UI Multiselect
The software is licensed under the MIT license. The source code includes other
components in whole or in part; namely jQuery, jQuery UI, jQuery UI Multiselect
and jQuery Formset. These components are used under the MIT resp. BSD licenses.
It also uses symbols of the Silk icon set from famfamfam.com, which is licensed
It also uses symbols of the Silk icon set from famfamfam.com, which is licensed
under a Creative Commons Attribution 2.5 License.

The source repository may include logos, names or other trademarks of the
Hasso Plattner Institute or other entities; potential usage restrictions for
The source repository may include logos, names or other trademarks of the
Hasso Plattner Institute or other entities; potential usage restrictions for
these elements still apply and are not touched by the software license.

::
Expand All @@ -89,10 +89,10 @@ these elements still apply and are not touched by the software license.
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Expand Down
2 changes: 1 addition & 1 deletion deployment/modules/evap/manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
provider => shell,
command => 'python manage.py syncdb --noinput --migrate',
cwd => '/vagrant'
} -> exec { 'django-collectstatic':
} -> exec { 'django-collectstatic':
provider => shell,
command => 'python manage.py collectstatic --noinput',
cwd => '/vagrant'
Expand Down
Loading

0 comments on commit 9519182

Please sign in to comment.