Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'master' of github.com:aidGer/aidGer

  • Loading branch information...
commit e418633b77cc3f1d90852cb5e2ec06b31bdb0695 2 parents 85a9a3d + b7d5cbf
Philipp Gildein rmbl authored
11 src/de/aidger/model/models/Activity.java
View
@@ -176,10 +176,8 @@ public boolean validate() {
* @return The activities related to the assistant or null if none were
* found
*/
- @SuppressWarnings("unchecked")
public List<Activity> getActivities(Assistant assistant) {
- //TODO: Implement
- return null;
+ return all().filter("Hilfskraft_ID", assistant.getId()).fetch();
}
/**
@@ -189,10 +187,8 @@ public boolean validate() {
* The course for which all activities should be returned
* @return The activities related to the course or null if none were found
*/
- @SuppressWarnings("unchecked")
public List<Activity> getActivities(Course course) {
- //TODO: Implement
- return null;
+ return all().filter("Veranstaltung_ID", course.getId()).fetch();
}
/**
@@ -205,8 +201,7 @@ public boolean validate() {
* @return All activities that occured during that date range
*/
public List<Activity> getActivities(Date from, Date to) {
- //TODO: Implement
- return null;
+ return all().filter("Datum >", from).filter("Datum < to", to).fetch();
}
/**
21 src/de/aidger/model/models/Contract.java
View
@@ -22,6 +22,7 @@
import static de.aidger.utils.Translation._;
import java.sql.Date;
+import java.util.ArrayList;
import java.util.List;
import siena.Table;
@@ -48,7 +49,7 @@
/**
* The date the contract was completed.
*/
- @Column("DatumEnde")
+ @Column("DatumAbschluss")
private Date completionDate;
/**
@@ -178,8 +179,17 @@ public boolean validateOnRemove() {
* @return List of contracts
*/
public List<Contract> getContracts(Date start, Date end) {
- //TODO: Implement
- return null;
+ List<Contract> contracts = all().filter("DatumAnfang >=", start).filter("DatumAnfang <=", end).fetch();
+ for(Contract contract : all().filter("DatumEnde >=", start).filter("DatumEnde <=", end).fetch())
+ if(!contracts.contains(contract))
+ contracts.add(contract);
+ for(Contract contract : all().filter("DatumAbschluss >=", start).filter("DatumAbschluss <=", end).fetch())
+ if(!contracts.contains(contract))
+ contracts.add(contract);
+ for(Contract contract : all().filter("DatumBestaetigung >=", start).filter("DatumBestaetigung <=", end).fetch())
+ if(!contracts.contains(contract))
+ contracts.add(contract);
+ return contracts;
}
/**
@@ -189,9 +199,8 @@ public boolean validateOnRemove() {
* The assistant to search for
* @return List of contracts
*/
- public List<Contract> getContracts(Assistant assi) {
- //TODO: Implement
- return null;
+ public List<Contract> getContracts(Assistant assistant) {
+ return all().filter("Hilfskraft_ID", assistant.getId()).fetch();
}
/**
1  src/de/aidger/model/models/CostUnit.java
View
@@ -29,7 +29,6 @@
* @author aidGer Team
*/
//TODO: Rewrite! Uses XML instead of DB
-@SuppressWarnings("unchecked")
public class CostUnit extends AbstractModel<CostUnit> {
/**
* The cost unit that is a 8 digit number.
26 src/de/aidger/model/models/Course.java
View
@@ -21,6 +21,7 @@
import static de.aidger.utils.Translation._;
+import java.util.ArrayList;
import java.util.List;
import siena.Table;
@@ -221,8 +222,7 @@ public boolean validateOnRemove() {
* @return A list of courses
*/
public List<Course> getCourses(FinancialCategory category) {
- //TODO: Implement
- return null;
+ return all().filter("Finanzkategorie_ID", category.getId()).fetch();
}
/**
@@ -233,8 +233,7 @@ public boolean validateOnRemove() {
* @return List of courses
*/
public List<Course> getCoursesBySemester(String semester) {
- //TODO: Implement
- return null;
+ return all().filter("Semester", semester).fetch();
}
/**
@@ -245,8 +244,7 @@ public boolean validateOnRemove() {
* @return List of courses
*/
public List<Course> getCoursesByGroup(String group) {
- //TODO: Implement
- return null;
+ return all().filter("Gruppe", group).fetch();
}
/**
@@ -255,8 +253,12 @@ public boolean validateOnRemove() {
* @return List of semesters
*/
public List<String> getDistinctSemesters() {
- //TODO: Implement
- return null;
+ List<Course> courses = all().order("Semester").fetch();
+ List<String> semesters = new ArrayList<String>();
+ for(Course course : courses)
+ if(!semesters.contains(course.getSemester()))
+ semesters.add(course.getSemester());
+ return semesters;
}
/**
@@ -265,8 +267,12 @@ public boolean validateOnRemove() {
* @return List of groups
*/
public List<String> getDistinctGroups() {
- //TODO: Implement
- return null;
+ List<Course> courses = all().order("Gruppe").fetch();
+ List<String> groups = new ArrayList<String>();
+ for(Course course : courses)
+ if(!groups.contains(course.getGroup()))
+ groups.add(course.getGroup());
+ return groups;
}
/**
37 src/de/aidger/model/models/Employment.java
View
@@ -22,6 +22,8 @@
import static de.aidger.utils.Translation._;
import java.sql.Date;
+import java.util.ArrayList;
+import java.util.Calendar;
import java.util.List;
import siena.Table;
@@ -198,8 +200,15 @@ public boolean validate() {
* @return The employments during the given time
*/
public List<Employment> getEmployments(Date start, Date end) {
- //TODO: Implement
- return null;
+ Calendar cal = Calendar.getInstance();
+ cal.setTime(start);
+ short startYear = (short) cal.get(Calendar.YEAR);
+ byte startMonth = (byte) cal.get(Calendar.MONTH);
+
+ cal.setTime(end);
+ short endYear = (short) cal.get(Calendar.YEAR);
+ byte endMonth = (byte) cal.get(Calendar.MONTH);
+ return getEmployments(startYear, startMonth, endYear, endMonth);
}
/**
@@ -217,8 +226,8 @@ public boolean validate() {
*/
public List<Employment> getEmployments(short startYear, byte startMonth,
short endYear, byte endMonth) {
- //TODO: Implement
- return null;
+ return all().filter("Monat >=", startMonth).filter("Monat <=", endMonth)
+ .filter("Jahr >=", startYear).filter("Jahr <=", endYear).fetch();
}
/**
@@ -229,8 +238,7 @@ public boolean validate() {
* @return The employments with the given contract
*/
public List<Employment> getEmployments(Contract contract) {
- //TODO: Implement
- return null;
+ return all().filter("Vertrag_ID", contract.getId()).fetch();
}
/**
@@ -241,8 +249,7 @@ public boolean validate() {
* @return The employments of the given assistant
*/
public List<Employment> getEmployments(Assistant assistant) {
- //TODO: Implement
- return null;
+ return all().filter("Hilfskraft_ID", assistant.getId()).fetch();
}
/**
@@ -253,8 +260,7 @@ public boolean validate() {
* @return The employments for the given course
*/
public List<Employment> getEmployments(Course course) {
- //TODO: Implement
- return null;
+ return all().filter("Veranstaltung_ID", course.getId()).fetch();
}
/**
@@ -265,8 +271,7 @@ public boolean validate() {
* @return The employments in the given semester
*/
public List<Employment> getEmployments(String semester) {
- //TODO: Implement
- return null;
+ return all().filter("Semester", semester).fetch();
}
/**
@@ -275,8 +280,12 @@ public boolean validate() {
* @return A list of distinct cost units
*/
public List<Integer> getDistinctCostUnits() {
- //TODO: Implement
- return null;
+ List<Employment> employments = all().order("Kostenstelle").fetch();
+ List<Integer> costUnits = new ArrayList<Integer>();
+ for(Employment employment : employments)
+ if(!costUnits.contains(employment.getCostUnit()))
+ costUnits.add(employment.getCostUnit());
+ return costUnits;
}
/**
Please sign in to comment.
Something went wrong with that request. Please try again.