// Path: src/java/se/idega/idegaweb/commune/school/presentation/CentralPlacementEditorConstants.java
// public class CentralPlacementEditorConstants {
// 
// 	public static final String KP = "central_placement_editor.";
// 	public static final String FORM_NAME = CommuneCareConstants.CENTRAL_PLACEMENT_EDITOR_FORM_NAME;
// 	public static final String KEY_PLACEMENT_PARAGRAPH_LABEL = KP + "placement_paragraph_label";
// 	public static final String KEY_SCHOOL_YEAR = KP + "school_year";
// 	public static final String KEY_SCHOOL_GROUP = KP + "school_group";
// 	public static final String KEY_STUDY_PATH = KP + "study_path";
// 	public static final String KEY_LANGUAGE = KP + "language";
// 	public static final String KEY_NATIVE_LANGUAGE = KP + "native_language";
// 
// }


import java.rmi.RemoteException;
import java.sql.Timestamp;
import java.util.Collection;
import java.util.Iterator;
import javax.ejb.FinderException;
import javax.transaction.SystemException;
import javax.transaction.UserTransaction;
import se.idega.idegaweb.commune.business.CommuneUserBusiness;
import se.idega.idegaweb.commune.care.business.CareBusiness;
import se.idega.idegaweb.commune.care.resource.data.ResourceClassMember;
import se.idega.idegaweb.commune.care.resource.data.ResourceClassMemberHome;
import se.idega.idegaweb.commune.school.presentation.CentralPlacementEditorConstants;
import com.idega.block.school.business.SchoolBusiness;
import com.idega.block.school.data.SchoolCategory;
import com.idega.block.school.data.SchoolCategoryHome;
import com.idega.block.school.data.SchoolClassMember;
import com.idega.block.school.data.SchoolClassMemberHome;
import com.idega.block.school.data.SchoolSeason;
import com.idega.block.school.data.SchoolStudyPath;
import com.idega.block.school.data.SchoolStudyPathHome;
import com.idega.block.school.data.SchoolYear;
import com.idega.business.IBOLookup;
import com.idega.business.IBOServiceBean;
import com.idega.data.IDOLookup;
import com.idega.idegaweb.IWResourceBundle;
import com.idega.presentation.IWContext;
import com.idega.user.business.UserBusiness;
import com.idega.user.data.User;
import com.idega.util.IWTimestamp;
	
	public SchoolSeason getCurrentSeason() {
		SchoolSeason season = null;
		
		try {
			season = getCareBusiness().getSchoolSeasonHome().findSeasonByDate(getSchoolBusiness().getCategoryElementarySchool(), new IWTimestamp().getDate());
		} catch (Exception e) {}
		
		if (season == null) {
			try {
				season = getCareBusiness().getCurrentSeason();
			} catch (Exception e1) {
				e1.printStackTrace();
			} 
		}
		
		return season;
	}
	
	public String getPlacementString(SchoolClassMember placement, User user, IWResourceBundle iwrb) {
		// Placement
		StringBuffer buf = new StringBuffer("");
		try {
			// add school name
			buf.append(placement.getSchoolClass().getSchool().getName());						
		} catch (Exception e) {}
		try {
			// school year
			SchoolYear theYear = placement.getSchoolYear();
			if (theYear != null) {
// Path: src/java/se/idega/idegaweb/commune/school/presentation/CentralPlacementEditorConstants.java
// public class CentralPlacementEditorConstants {
// 
// 	public static final String KP = "central_placement_editor.";
// 	public static final String FORM_NAME = CommuneCareConstants.CENTRAL_PLACEMENT_EDITOR_FORM_NAME;
// 	public static final String KEY_PLACEMENT_PARAGRAPH_LABEL = KP + "placement_paragraph_label";
// 	public static final String KEY_SCHOOL_YEAR = KP + "school_year";
// 	public static final String KEY_SCHOOL_GROUP = KP + "school_group";
// 	public static final String KEY_STUDY_PATH = KP + "study_path";
// 	public static final String KEY_LANGUAGE = KP + "language";
// 	public static final String KEY_NATIVE_LANGUAGE = KP + "native_language";
// 
// }


// Path: src/java/se/idega/idegaweb/commune/school/business/CentralPlacementBusinessBean.java
import java.rmi.RemoteException;
import java.sql.Timestamp;
import java.util.Collection;
import java.util.Iterator;
import javax.ejb.FinderException;
import javax.transaction.SystemException;
import javax.transaction.UserTransaction;
import se.idega.idegaweb.commune.business.CommuneUserBusiness;
import se.idega.idegaweb.commune.care.business.CareBusiness;
import se.idega.idegaweb.commune.care.resource.data.ResourceClassMember;
import se.idega.idegaweb.commune.care.resource.data.ResourceClassMemberHome;
import se.idega.idegaweb.commune.school.presentation.CentralPlacementEditorConstants;
import com.idega.block.school.business.SchoolBusiness;
import com.idega.block.school.data.SchoolCategory;
import com.idega.block.school.data.SchoolCategoryHome;
import com.idega.block.school.data.SchoolClassMember;
import com.idega.block.school.data.SchoolClassMemberHome;
import com.idega.block.school.data.SchoolSeason;
import com.idega.block.school.data.SchoolStudyPath;
import com.idega.block.school.data.SchoolStudyPathHome;
import com.idega.block.school.data.SchoolYear;
import com.idega.business.IBOLookup;
import com.idega.business.IBOServiceBean;
import com.idega.data.IDOLookup;
import com.idega.idegaweb.IWResourceBundle;
import com.idega.presentation.IWContext;
import com.idega.user.business.UserBusiness;
import com.idega.user.data.User;
import com.idega.util.IWTimestamp;

	
	public SchoolSeason getCurrentSeason() {
		SchoolSeason season = null;
		
		try {
			season = getCareBusiness().getSchoolSeasonHome().findSeasonByDate(getSchoolBusiness().getCategoryElementarySchool(), new IWTimestamp().getDate());
		} catch (Exception e) {}
		
		if (season == null) {
			try {
				season = getCareBusiness().getCurrentSeason();
			} catch (Exception e1) {
				e1.printStackTrace();
			} 
		}
		
		return season;
	}
	
	public String getPlacementString(SchoolClassMember placement, User user, IWResourceBundle iwrb) {
		// Placement
		StringBuffer buf = new StringBuffer("");
		try {
			// add school name
			buf.append(placement.getSchoolClass().getSchool().getName());						
		} catch (Exception e) {}
		try {
			// school year
			SchoolYear theYear = placement.getSchoolYear();
			if (theYear != null) {
				buf.append(", " + iwrb.getLocalizedString(CentralPlacementEditorConstants.KEY_SCHOOL_YEAR, "school year") + " "