Skip to content

Commit

Permalink
Adjusted all models except for financial categories to siena. (refs #323
Browse files Browse the repository at this point in the history
)
  • Loading branch information
Philly committed May 18, 2012
1 parent b5da959 commit db01bcd
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 39 deletions.
11 changes: 3 additions & 8 deletions src/de/aidger/model/models/Activity.java
Expand Up @@ -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();
}

/**
Expand All @@ -189,10 +187,8 @@ public List<Activity> getActivities(Assistant assistant) {
* 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();
}

/**
Expand All @@ -205,8 +201,7 @@ public List<Activity> getActivities(Course course) {
* @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();
}

/**
Expand Down
21 changes: 15 additions & 6 deletions src/de/aidger/model/models/Contract.java
Expand Up @@ -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;
Expand All @@ -48,7 +49,7 @@ public class Contract extends AbstractModel<Contract> {
/**
* The date the contract was completed.
*/
@Column("DatumEnde")
@Column("DatumAbschluss")
private Date completionDate;

/**
Expand Down Expand Up @@ -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;
}

/**
Expand All @@ -189,9 +199,8 @@ public List<Contract> getContracts(Date start, Date end) {
* 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();
}

/**
Expand Down
1 change: 0 additions & 1 deletion src/de/aidger/model/models/CostUnit.java
Expand Up @@ -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.
Expand Down
26 changes: 16 additions & 10 deletions src/de/aidger/model/models/Course.java
Expand Up @@ -21,6 +21,7 @@

import static de.aidger.utils.Translation._;

import java.util.ArrayList;
import java.util.List;

import siena.Table;
Expand Down Expand Up @@ -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();
}

/**
Expand All @@ -233,8 +233,7 @@ public List<Course> getCourses(FinancialCategory category) {
* @return List of courses
*/
public List<Course> getCoursesBySemester(String semester) {
//TODO: Implement
return null;
return all().filter("Semester", semester).fetch();
}

/**
Expand All @@ -245,8 +244,7 @@ public List<Course> getCoursesBySemester(String semester) {
* @return List of courses
*/
public List<Course> getCoursesByGroup(String group) {
//TODO: Implement
return null;
return all().filter("Gruppe", group).fetch();
}

/**
Expand All @@ -255,8 +253,12 @@ public List<Course> getCoursesByGroup(String group) {
* @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;
}

/**
Expand All @@ -265,8 +267,12 @@ public List<String> getDistinctSemesters() {
* @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;
}

/**
Expand Down
37 changes: 23 additions & 14 deletions src/de/aidger/model/models/Employment.java
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}

/**
Expand All @@ -217,8 +226,8 @@ public List<Employment> getEmployments(Date start, Date end) {
*/
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();
}

/**
Expand All @@ -229,8 +238,7 @@ public List<Employment> getEmployments(short startYear, byte startMonth,
* @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();
}

/**
Expand All @@ -241,8 +249,7 @@ public List<Employment> getEmployments(Contract contract) {
* @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();
}

/**
Expand All @@ -253,8 +260,7 @@ public List<Employment> getEmployments(Assistant assistant) {
* @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();
}

/**
Expand All @@ -265,8 +271,7 @@ public List<Employment> getEmployments(Course course) {
* @return The employments in the given semester
*/
public List<Employment> getEmployments(String semester) {
//TODO: Implement
return null;
return all().filter("Semester", semester).fetch();
}

/**
Expand All @@ -275,8 +280,12 @@ public List<Employment> getEmployments(String semester) {
* @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;
}

/**
Expand Down

0 comments on commit db01bcd

Please sign in to comment.