// Path: src/java/is/idega/idegaweb/egov/company/EgovCompanyConstants.java
// public class EgovCompanyConstants {
// 
// 	private EgovCompanyConstants() {}
// 
// 	public static final String IW_BUNDLE_IDENTIFIER = "is.idega.idegaweb.egov.company";
// 
// 	public static final String COMPANY_SUPER_ADMIN_ROLE = "company_super_admin";
// 	public static final String COMPANY_ADMIN_ROLE = "company_admin";
// 	public static final String COMPANY_EMPLOYEE_ROLE = "company_staff";
// 
// 	public static final List<String> ALL_COMPANY_ROLES = Collections.unmodifiableList(Arrays.asList(
// 			StandardRoles.ROLE_KEY_COMPANY,
// 			COMPANY_SUPER_ADMIN_ROLE,
// 			COMPANY_ADMIN_ROLE,
// 			COMPANY_EMPLOYEE_ROLE
// 	));
// 
// 	public static final String GROUP_TYPE_COMPANY_ADMINS = "iw_company_admins_group";
// 	public static final String GROUP_TYPE_COMPANY_STAFF = "iw_company_staff_group";
// 	public static final List<String> ALL_COMPANY_TYPES = Collections.unmodifiableList(Arrays.asList(
// 			CompanyConstants.GROUP_TYPE_COMPANY,
// 			GROUP_TYPE_COMPANY_ADMINS,
// 			GROUP_TYPE_COMPANY_STAFF
// 	));
// 
// 	public static final String CASE_CODE_KEY = "COMPORT";
// 
// 	public static final String CONTENT_CODE_REQUEST_INFORMATION = "prm_company_code_request_information";
// 
// 	public static final Integer APPLICATION_TYPE_APPROVED = 0;
// 	public static final Integer APPLICATION_TYPE_REJECTED = 1;
// 	public static final Integer APPLICATION_TYPE_UNHANDLED = 2;
// 
// 	public static final String USER_LOGIN_METADATA = "userLoginEnabledMetaDataForCompanyPortal";
// 
// 	public static final String COMPANY_PORTAL_ROOT_GROUP = "Company Portal";
// 	public static final String COMPANY_ADMINS_GROUP_IN_COMPANY_PORTAL = "Company Admins";
// 	public static final String COMPANY_SUPER_ADMINS_GROUP_IN_COMPANY_PORTAL = "Company Super Admins";
// 
// 	public static final String COMPANY_PORTAL_HOME_PAGE_APPLICATION_PROPERTY = "companyPortalHomePage";
// 	public static final String COMPANY_STAFF_HOME_PAGE_APPLICATION_PROPERTY = "companyStaffHomePage";
// 
// 	public static final String COMPANY_PORTAL_CURRENT_COMPANY_ATTRIBUTE = "companyPortalCurrentCompanyId";
// 
// 	public static final String COMPANY_PERSONAL_ID_METADATA = "COMPANY_PERSONAL_ID";
// }


import is.idega.idegaweb.egov.company.EgovCompanyConstants;
import java.rmi.RemoteException;
import java.util.Collection;
import java.util.List;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
import com.idega.business.IBOLookup;
import com.idega.business.IBOLookupException;
import com.idega.core.builder.data.ICPage;
import com.idega.presentation.IWContext;
import com.idega.user.business.UserBusiness;
import com.idega.user.business.UserCompanyBusiness;
import com.idega.user.data.Group;
import com.idega.user.data.User;
import com.idega.util.ListUtil;
import com.idega.util.expression.ELUtil;
package is.idega.idegaweb.egov.company.business;





@Scope("singleton")
@Service(UserCompanyBusiness.SPRING_BEAN_IDENTIFIER)
public class UserCompanyBusinessBean implements UserCompanyBusiness {

	public void setPreferedCompanyForCurrentUser(String companyId) throws RemoteException {
		IWContext iwc = IWContext.getCurrentInstance();
		getUserBusiness(iwc).setPreferedCompany(companyId, iwc.getCurrentUser());
	}

	public Group getPreferedCompanyForUser(IWContext iwc, User user) throws RemoteException {
		return getUserBusiness(iwc).getPreferedCompany(user);
	}

	protected CompanyApplicationBusiness getCompanyApplicationBusiness(IWContext iwc) throws IBOLookupException {
		return (CompanyApplicationBusiness) IBOLookup.getServiceInstance(iwc, CompanyApplicationBusiness.class);
	}

	protected UserBusiness getUserBusiness(IWContext iwc) throws IBOLookupException {
		return (UserBusiness) IBOLookup.getServiceInstance(iwc, UserBusiness.class);
	}

	public Collection<Group> getUsersCompanies(IWContext iwc, User user) throws RemoteException {
		CompanyPortalBusiness companyPortalBusiness = ELUtil.getInstance().getBean(CompanyPortalBusiness.SPRING_BEAN_IDENTIFIER);
		return companyPortalBusiness.getAllUserCompanies(user);
	}

	public String getCurrentCompanyAttributeId() {
// Path: src/java/is/idega/idegaweb/egov/company/EgovCompanyConstants.java
// public class EgovCompanyConstants {
// 
// 	private EgovCompanyConstants() {}
// 
// 	public static final String IW_BUNDLE_IDENTIFIER = "is.idega.idegaweb.egov.company";
// 
// 	public static final String COMPANY_SUPER_ADMIN_ROLE = "company_super_admin";
// 	public static final String COMPANY_ADMIN_ROLE = "company_admin";
// 	public static final String COMPANY_EMPLOYEE_ROLE = "company_staff";
// 
// 	public static final List<String> ALL_COMPANY_ROLES = Collections.unmodifiableList(Arrays.asList(
// 			StandardRoles.ROLE_KEY_COMPANY,
// 			COMPANY_SUPER_ADMIN_ROLE,
// 			COMPANY_ADMIN_ROLE,
// 			COMPANY_EMPLOYEE_ROLE
// 	));
// 
// 	public static final String GROUP_TYPE_COMPANY_ADMINS = "iw_company_admins_group";
// 	public static final String GROUP_TYPE_COMPANY_STAFF = "iw_company_staff_group";
// 	public static final List<String> ALL_COMPANY_TYPES = Collections.unmodifiableList(Arrays.asList(
// 			CompanyConstants.GROUP_TYPE_COMPANY,
// 			GROUP_TYPE_COMPANY_ADMINS,
// 			GROUP_TYPE_COMPANY_STAFF
// 	));
// 
// 	public static final String CASE_CODE_KEY = "COMPORT";
// 
// 	public static final String CONTENT_CODE_REQUEST_INFORMATION = "prm_company_code_request_information";
// 
// 	public static final Integer APPLICATION_TYPE_APPROVED = 0;
// 	public static final Integer APPLICATION_TYPE_REJECTED = 1;
// 	public static final Integer APPLICATION_TYPE_UNHANDLED = 2;
// 
// 	public static final String USER_LOGIN_METADATA = "userLoginEnabledMetaDataForCompanyPortal";
// 
// 	public static final String COMPANY_PORTAL_ROOT_GROUP = "Company Portal";
// 	public static final String COMPANY_ADMINS_GROUP_IN_COMPANY_PORTAL = "Company Admins";
// 	public static final String COMPANY_SUPER_ADMINS_GROUP_IN_COMPANY_PORTAL = "Company Super Admins";
// 
// 	public static final String COMPANY_PORTAL_HOME_PAGE_APPLICATION_PROPERTY = "companyPortalHomePage";
// 	public static final String COMPANY_STAFF_HOME_PAGE_APPLICATION_PROPERTY = "companyStaffHomePage";
// 
// 	public static final String COMPANY_PORTAL_CURRENT_COMPANY_ATTRIBUTE = "companyPortalCurrentCompanyId";
// 
// 	public static final String COMPANY_PERSONAL_ID_METADATA = "COMPANY_PERSONAL_ID";
// }


// Path: src/java/is/idega/idegaweb/egov/company/business/UserCompanyBusinessBean.java
import is.idega.idegaweb.egov.company.EgovCompanyConstants;
import java.rmi.RemoteException;
import java.util.Collection;
import java.util.List;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
import com.idega.business.IBOLookup;
import com.idega.business.IBOLookupException;
import com.idega.core.builder.data.ICPage;
import com.idega.presentation.IWContext;
import com.idega.user.business.UserBusiness;
import com.idega.user.business.UserCompanyBusiness;
import com.idega.user.data.Group;
import com.idega.user.data.User;
import com.idega.util.ListUtil;
import com.idega.util.expression.ELUtil;

package is.idega.idegaweb.egov.company.business;





@Scope("singleton")
@Service(UserCompanyBusiness.SPRING_BEAN_IDENTIFIER)
public class UserCompanyBusinessBean implements UserCompanyBusiness {

	public void setPreferedCompanyForCurrentUser(String companyId) throws RemoteException {
		IWContext iwc = IWContext.getCurrentInstance();
		getUserBusiness(iwc).setPreferedCompany(companyId, iwc.getCurrentUser());
	}

	public Group getPreferedCompanyForUser(IWContext iwc, User user) throws RemoteException {
		return getUserBusiness(iwc).getPreferedCompany(user);
	}

	protected CompanyApplicationBusiness getCompanyApplicationBusiness(IWContext iwc) throws IBOLookupException {
		return (CompanyApplicationBusiness) IBOLookup.getServiceInstance(iwc, CompanyApplicationBusiness.class);
	}

	protected UserBusiness getUserBusiness(IWContext iwc) throws IBOLookupException {
		return (UserBusiness) IBOLookup.getServiceInstance(iwc, UserBusiness.class);
	}

	public Collection<Group> getUsersCompanies(IWContext iwc, User user) throws RemoteException {
		CompanyPortalBusiness companyPortalBusiness = ELUtil.getInstance().getBean(CompanyPortalBusiness.SPRING_BEAN_IDENTIFIER);
		return companyPortalBusiness.getAllUserCompanies(user);
	}

	public String getCurrentCompanyAttributeId() {
		return EgovCompanyConstants.COMPANY_PORTAL_CURRENT_COMPANY_ATTRIBUTE;