当前位置: 首页>>代码示例>>Java>>正文


Java User.getUserId方法代码示例

本文整理汇总了Java中com.liferay.portal.model.User.getUserId方法的典型用法代码示例。如果您正苦于以下问题:Java User.getUserId方法的具体用法?Java User.getUserId怎么用?Java User.getUserId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.liferay.portal.model.User的用法示例。


在下文中一共展示了User.getUserId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: changeToShite

import com.liferay.portal.model.User; //导入方法依赖的package包/类
public void changeToShite(long workingUnitIdOld,long workingUnitId, User user) throws PortalException, SystemException{
	WorkingUnit work = WorkingUnitLocalServiceUtil.getWorkingUnit(workingUnitId);
	WorkingUnit workold = WorkingUnitLocalServiceUtil.getWorkingUnit(workingUnitIdOld);
	long userId = user.getUserId();
	//Group group = GroupLocalServiceUtil.getG(companyId, userId);
	List<Group> groups = user.getGroups();
	boolean f = false;
	for (int i = 0; i < groups.size(); i++){
		if (groups.get(i).getGroupId() == workold.getLocalSiteId() ){
			f = true;
			break;
		}
	}
	if (work.getLocalSiteId()  != workold.getLocalSiteId() || !f){
		if (workold.getLocalSiteId() != PortletKeys.LONG_DEFAULT && f) {
			GroupLocalServiceUtil.deleteUserGroup(userId,
					workold.getLocalSiteId());
		}
		if (work.getLocalSiteId() != PortletKeys.LONG_DEFAULT) {
			System.out.println(" changeToShite " + workingUnitId + "  "  + work.getLocalSiteId() + "  " + userId);
			GroupLocalServiceUtil.addUserGroup(userId,
					work.getLocalSiteId());
			System.out.println(" changeToShite " + workingUnitId + "  "  + work.getLocalSiteId() + "  " + userId);
		}
	}
}
 
开发者ID:openegovplatform,项目名称:OEPv2,代码行数:27,代码来源:EmpLoyeePortlet.java

示例2: updateUser

import com.liferay.portal.model.User; //导入方法依赖的package包/类
@JSONWebService
public void updateUser(String login, String firstName,String lastName,String email) throws PortalException, SystemException
{
	ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext();
	
		User user = UserLocalServiceUtil.getUserByScreenName(
				serviceContext.getCompanyId(), login);
		user.setFirstName(firstName);
		user.setLastName(lastName);
		user.setEmailAddress(email);
		List<UserGroup> userGroups = user.getUserGroups();
		long[] userArray = new long[] { user.getUserId() };
		if(PortalPermissionUtil.contains(
				getPermissionChecker(), ActionKeys.ADD_USER))
		{
			UserLocalServiceUtil.updateUser(user);
		}

}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:20,代码来源:CourseServiceImpl.java

示例3: countStartedOnlyStudents

import com.liferay.portal.model.User; //导入方法依赖的package包/类
public long countStartedOnlyStudents(long actId, long companyId, long courseGropupCreatedId, List<User> _students){
	Session session = null;
	try{
		LmsPrefs prefs = LmsPrefsLocalServiceUtil.fetchLmsPrefs(companyId);			
		long teacherRoleId=RoleLocalServiceUtil.getRole(prefs.getTeacherRole()).getRoleId();
		long editorRoleId=RoleLocalServiceUtil.getRole(prefs.getEditorRole()).getRoleId();
		
		String sql="SELECT * FROM lms_learningactivityresult r INNER JOIN users_groups ug ON r.userId = ug.userId AND ug.groupId ="+courseGropupCreatedId+
				" WHERE actId="+actId;
		
		// Se prepara el metodo para recibir un Listado de estudiantes especificos,, por ejemplo que pertenezcan a alguna organizacion. Sino, se trabaja con todos los estudiantes del curso.
		if(Validator.isNotNull(_students) && _students.size() > 0){
			sql += " AND r.userId in (-1";
			for(User user:_students){
				sql+=","+user.getUserId();
			}
			sql+=") ";
		}
		
		sql+=" AND r.userId not in ( SELECT userId FROM usergrouprole WHERE usergrouprole.groupId = " +courseGropupCreatedId+
			 " AND usergrouprole.roleId in ("+teacherRoleId+","+editorRoleId+"))";	
		
		session = openSession();			
		
		log.debug("sql: " + sql);			
		
		SQLQuery q = session.createSQLQuery(sql);
		return ((List<BigInteger>) q.list()).get(0).longValue();
		
	} catch (Exception e) {
       e.printStackTrace();
    } finally {
        closeSession(session);
    }

    return 0;
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:38,代码来源:LearningActivityResultFinderImpl.java

示例4: countFinishedOnlyStudents

import com.liferay.portal.model.User; //导入方法依赖的package包/类
public long countFinishedOnlyStudents(long actId, long companyId, long courseGropupCreatedId, List<User> _students){
	Session session = null;
	try{
		LmsPrefs prefs = LmsPrefsLocalServiceUtil.fetchLmsPrefs(companyId);			
		long teacherRoleId=RoleLocalServiceUtil.getRole(prefs.getTeacherRole()).getRoleId();
		long editorRoleId=RoleLocalServiceUtil.getRole(prefs.getEditorRole()).getRoleId();
		
		String sql="SELECT count(1) FROM lms_learningactivityresult r INNER JOIN users_groups ug ON r.userId = ug.userId AND ug.groupId ="+courseGropupCreatedId+
				" WHERE actId="+actId+" AND r.endDate IS NOT NULL ";
		
		// Se prepara el metodo para recibir un Listado de estudiantes especificos,, por ejemplo que pertenezcan a alguna organizacion. Sino, se trabaja con todos los estudiantes del curso.
		if(Validator.isNotNull(_students) && _students.size() > 0){
			sql += " AND r.userId in (-1";
			for(User user:_students){
				sql+=","+user.getUserId();
			}
			sql+=") ";
		}
		
		sql+=" AND r.userId not in ( SELECT userId FROM usergrouprole WHERE usergrouprole.groupId = " +courseGropupCreatedId+
			 " AND usergrouprole.roleId in ("+teacherRoleId+","+editorRoleId+"))";	
		
		session = openSession();			
		
		log.debug("sql: " + sql);			
		
		SQLQuery q = session.createSQLQuery(sql);
		
		return ((List<BigInteger>) q.list()).get(0).longValue();
		
	} catch (Exception e) {
       e.printStackTrace();
    } finally {
        closeSession(session);
    }

    return 0;
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:39,代码来源:LearningActivityResultFinderImpl.java

示例5: countStartedOnlyStudents

import com.liferay.portal.model.User; //导入方法依赖的package包/类
public long countStartedOnlyStudents(long actId, long companyId, long courseGropupCreatedId, List<User> _students){
	Session session = null;
	;
	try{
		LmsPrefs prefs = LmsPrefsLocalServiceUtil.fetchLmsPrefs(companyId);			
		long teacherRoleId=RoleLocalServiceUtil.getRole(prefs.getTeacherRole()).getRoleId();
		long editorRoleId=RoleLocalServiceUtil.getRole(prefs.getEditorRole()).getRoleId();
		
		String sql="SELECT count(1) FROM lms_learningactivityresult r INNER JOIN users_groups ug ON r.userId = ug.userId AND ug.groupId ="+courseGropupCreatedId+
				" WHERE actId="+actId;
		
		// Se prepara el metodo para recibir un Listado de estudiantes especificos,, por ejemplo que pertenezcan a alguna organizacion. Sino, se trabaja con todos los estudiantes del curso.
		if(Validator.isNotNull(_students) && _students.size() > 0){
			sql += " AND r.userId in (-1";
			for(User user:_students){
				sql+=","+user.getUserId();
			}
			sql+=") ";
		}
		
		sql+=" AND r.userId not in ( SELECT userId FROM usergrouprole WHERE usergrouprole.groupId = " +courseGropupCreatedId+
			 " AND usergrouprole.roleId in ("+teacherRoleId+","+editorRoleId+"))";	
		
		session = openSession();			
		
		log.debug("sql: " + sql);			
		
		SQLQuery q = session.createSQLQuery(sql);
		return ((List<BigInteger>) q.list()).get(0).longValue();
		
	} catch (Exception e) {
       e.printStackTrace();
    } finally {
        closeSession(session);
    }

    return 0;
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:39,代码来源:SurveyResultFinderImpl.java

示例6: createLearningActivityTry

import com.liferay.portal.model.User; //导入方法依赖的package包/类
@JSONWebService
public LearningActivityTry createLearningActivityTry(long actId,long userId) throws SystemException, PortalException
{
	User user=this.getUser();
	if(user.getUserId()==userId)
	{
	LearningActivityTry lat=learningActivityTryPersistence.create(counterLocalService.increment(
			LearningActivityTry.class.getName()));
	lat.setActId(actId);
	lat.setUserId(userId);
	java.util.Date today=new java.util.Date(System.currentTimeMillis());
	lat.setStartDate(today);
	learningActivityTryPersistence.update(lat, false);
	
	ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext();
	
	if(serviceContext!=null){
		courseResultLocalService.softInitializeByGroupIdAndUserId(serviceContext.getScopeGroupId(), serviceContext.getUserId());
	}
	
	//auditing
	if(serviceContext!=null){
		AuditingLogFactory.audit(serviceContext.getCompanyId(), serviceContext.getScopeGroupId(), LearningActivityTry.class.getName(), 
			actId, serviceContext.getUserId(), AuditConstants.ADD, null);
	}else{
		LearningActivity la = learningActivityPersistence.fetchByPrimaryKey(actId);
		if(la!=null){
			AuditingLogFactory.audit(la.getCompanyId(), la.getGroupId(), LearningActivityTry.class.getName(), 
					actId, la.getUserId(), AuditConstants.ADD, null);
		}
	}
	
	return lat;
	}
	return null;
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:37,代码来源:LearningActivityTryServiceImpl.java

示例7: initGlobals

import com.liferay.portal.model.User; //导入方法依赖的package包/类
public static void initGlobals() {
	try {
		// get default company
		Company company = CompanyLocalServiceUtil.getCompanyByWebId(PropsUtil.get(PropsKeys.COMPANY_DEFAULT_WEB_ID));
		// fallback
		if (company == null)
			company = CompanyLocalServiceUtil.getCompany(PortalUtil.getDefaultCompanyId());	
		
		globalCompanyId = company.getCompanyId();
		globalGroupId = company.getGroup().getGroupId();
		globalAdminId = company.getDefaultUser().getUserId(); 
		m_objLog.debug("Initial company is "+globalCompanyId+", group "+globalGroupId+", user "+globalAdminId);

		// get welcome page
		Layout layout = getLayout(globalGroupId, E_ContextPath.HOME.getPath());
		if (layout != null) {
			// correct values
			globalCompanyId = layout.getCompanyId();
			globalGroupId = layout.getGroupId();
			homeLayoutId = layout.getLayoutId();
			User admin = getDefaultAdmin(globalCompanyId);
			if (admin != null) {
				globalAdminId = admin.getUserId();
			} 
			m_objLog.debug("Corrected company is "+globalCompanyId+", group "+globalGroupId+", user "+globalAdminId);
		}
		
	} catch (Throwable t) {
		m_objLog.error(t);
	}
}
 
开发者ID:fraunhoferfokus,项目名称:particity,代码行数:32,代码来源:ParticityInitializer.java

示例8: triesPerUserOnlyStudents

import com.liferay.portal.model.User; //导入方法依赖的package包/类
public long triesPerUserOnlyStudents(long actId, long companyId, long courseGropupCreatedId, List<User> _students, long teamId) throws SystemException {
	Session session = null;
	try{
		LmsPrefs prefs = LmsPrefsLocalServiceUtil.fetchLmsPrefs(companyId);			
		long teacherRoleId=RoleLocalServiceUtil.getRole(prefs.getTeacherRole()).getRoleId();
		long editorRoleId=RoleLocalServiceUtil.getRole(prefs.getEditorRole()).getRoleId();
		
		String sql="SELECT count(1) FROM lms_learningactivitytry r " +
				" INNER JOIN users_groups ug ON r.userId = ug.userId " +
				" AND ug.groupId ="+courseGropupCreatedId;
		if(teamId>0){
			sql+=" INNER JOIN users_teams ut ON r.userId = ut.userId AND ut.teamId = "+teamId;
		}
		sql+= " WHERE actId="+actId;
		
		// Se prepara el metodo para recibir un Listado de estudiantes especificos,, por ejemplo que pertenezcan a alguna organizacion. Sino, se trabaja con todos los estudiantes del curso.
		if(Validator.isNotNull(_students) && _students.size() > 0){
			sql += " AND r.userId in (-1";
			for(User user:_students){
				sql+=","+user.getUserId();
			}
			sql+=") ";
		}
		
		sql+=" AND r.userId not in ( SELECT userId FROM usergrouprole WHERE usergrouprole.groupId = " +courseGropupCreatedId+
			 " AND usergrouprole.roleId in ("+teacherRoleId+","+editorRoleId+"))";	
		
		session = openSession();			
		
		log.debug("sql: " + sql);			
		
		SQLQuery q = session.createSQLQuery(sql);
		return ((List<BigInteger>) q.list()).get(0).longValue();
		
	} catch (Exception e) {
       e.printStackTrace();
    } finally {
        closeSession(session);
    }

    return 0;
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:43,代码来源:LearningActivityTryFinderImpl.java

示例9: countStartedOnlyStudents

import com.liferay.portal.model.User; //导入方法依赖的package包/类
public long countStartedOnlyStudents(long moduleId, long companyId, long groupId, List<User> _students, long teamId){
	Session session = null;
	try{
		LmsPrefs prefs = LmsPrefsLocalServiceUtil.fetchLmsPrefs(companyId);			
		long teacherRoleId=RoleLocalServiceUtil.getRole(prefs.getTeacherRole()).getRoleId();
		long editorRoleId=RoleLocalServiceUtil.getRole(prefs.getEditorRole()).getRoleId();
		
		String sql="SELECT count(1) FROM lms_moduleresult mr " +
				" INNER JOIN users_groups ug ON mr.userId = ug.userId " +
				" AND ug.groupId ="+groupId;
		if(teamId>0){
			sql+=" INNER JOIN users_teams ut ON mr.userId = ut.userId AND ut.teamId = "+teamId;
		}
		sql+=" WHERE moduleId="+moduleId;
		
		// Se prepara el metodo para recibir un Listado de estudiantes especificos,, por ejemplo que pertenezcan a alguna organizacion. Sino, se trabaja con todos los estudiantes del curso.
		if(Validator.isNotNull(_students) && _students.size() > 0){
			sql += " AND mr.userId in (-1";
			for(User user:_students){
				sql+=","+user.getUserId();
			}
			sql+=") ";
		}
		
		sql+=" AND mr.userId not in ( SELECT userId FROM usergrouprole WHERE usergrouprole.groupId = " +groupId+
			 " AND usergrouprole.roleId in ("+teacherRoleId+","+editorRoleId+"))";	
		
		session = openSession();			
		
		log.debug("sql: " + sql);			
		
		SQLQuery q = session.createSQLQuery(sql);
		return ((List<BigInteger>) q.list()).get(0).longValue();
		
	} catch (Exception e) {
       e.printStackTrace();
    } finally {
        closeSession(session);
    }

    return 0;
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:43,代码来源:ModuleResultFinderImpl.java

示例10: countFinishedOnlyStudents

import com.liferay.portal.model.User; //导入方法依赖的package包/类
public long countFinishedOnlyStudents(long moduleId, long companyId, long groupId, List<User> _students, long teamId){
	Session session = null;
	try{
		LmsPrefs prefs = LmsPrefsLocalServiceUtil.fetchLmsPrefs(companyId);			
		long teacherRoleId=RoleLocalServiceUtil.getRole(prefs.getTeacherRole()).getRoleId();
		long editorRoleId=RoleLocalServiceUtil.getRole(prefs.getEditorRole()).getRoleId();
		
		String sql="SELECT count(1) FROM lms_moduleresult mr " +
				" INNER JOIN users_groups ug ON mr.userId = ug.userId " +
				" AND ug.groupId ="+groupId;
		if(teamId>0){
			sql+=" INNER JOIN users_teams ut ON mr.userId = ut.userId AND ut.teamId = "+teamId;
		}
		sql+=" WHERE mr.moduleId ="+moduleId+" AND mr.passedDate IS NOT NULL ";
		
		// Se prepara el metodo para recibir un Listado de estudiantes especificos,, por ejemplo que pertenezcan a alguna organizacion. Sino, se trabaja con todos los estudiantes del curso.
		if(Validator.isNotNull(_students) && _students.size() > 0){
			sql += " AND mr.userId in (-1";
			for(User user:_students){
				sql+=","+user.getUserId();
			}
			sql+=") ";
		}
		
		sql+=" AND mr.userId not in ( SELECT userId FROM usergrouprole WHERE usergrouprole.groupId = " +groupId+
			 " AND usergrouprole.roleId in ("+teacherRoleId+","+editorRoleId+"))";	
		
		session = openSession();			
		
		log.debug("sql: " + sql);			
		
		SQLQuery q = session.createSQLQuery(sql);
		
		return ((List<BigInteger>) q.list()).get(0).longValue();
		
	} catch (Exception e) {
       e.printStackTrace();
    } finally {
        closeSession(session);
    }

    return 0;
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:44,代码来源:ModuleResultFinderImpl.java

示例11: countPassedOnlyStudents

import com.liferay.portal.model.User; //导入方法依赖的package包/类
public long countPassedOnlyStudents(long moduleId, long companyId, long groupId, List<User> _students, boolean passed, long teamId){
	Session session = null;
	try{
		LmsPrefs prefs = LmsPrefsLocalServiceUtil.fetchLmsPrefs(companyId);			
		long teacherRoleId=RoleLocalServiceUtil.getRole(prefs.getTeacherRole()).getRoleId();
		long editorRoleId=RoleLocalServiceUtil.getRole(prefs.getEditorRole()).getRoleId();
		
		String sql="SELECT count(1) FROM lms_moduleresult mr " +
				" INNER JOIN users_groups ug ON mr.userId = ug.userId " +
				" AND ug.groupId ="+groupId;
		if(teamId>0){
			sql+=" INNER JOIN users_teams ut ON mr.userId = ut.userId AND ut.teamId = "+teamId;
		}
		sql+=" WHERE mr.moduleId ="+moduleId+" AND mr.passed="+passed;
		
		// Se prepara el metodo para recibir un Listado de estudiantes especificos,, por ejemplo que pertenezcan a alguna organizacion. Sino, se trabaja con todos los estudiantes del curso.
		if(Validator.isNotNull(_students) && _students.size() > 0){
			sql += " AND mr.userId in (-1";
			for(User user:_students){
				sql+=","+user.getUserId();
			}
			sql+=") ";
		}
		sql+=" AND mr.userId not in ( SELECT userId FROM usergrouprole WHERE usergrouprole.groupId = " +groupId+
			 " AND usergrouprole.roleId in ("+teacherRoleId+","+editorRoleId+"))";	
		
		session = openSession();			
		
		log.debug("sql: " + sql);			
		
		SQLQuery q = session.createSQLQuery(sql);
		
		return ((List<BigInteger>) q.list()).get(0).longValue();
		
	} catch (Exception e) {
       e.printStackTrace();
    } finally {
        closeSession(session);
    }

    return 0;
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:43,代码来源:ModuleResultFinderImpl.java

示例12: countStartedOnlyStudents

import com.liferay.portal.model.User; //导入方法依赖的package包/类
public long countStartedOnlyStudents(long courseId, long companyId, long courseGropupCreatedId, List<User> _students, long teamId){
	Session session = null;
	try{
		LmsPrefs prefs = LmsPrefsLocalServiceUtil.fetchLmsPrefs(companyId);			
		long teacherRoleId=RoleLocalServiceUtil.getRole(prefs.getTeacherRole()).getRoleId();
		long editorRoleId=RoleLocalServiceUtil.getRole(prefs.getEditorRole()).getRoleId();
		
		String sql="SELECT count(1) " +
				"FROM lms_courseresult cr " +
				"INNER JOIN users_groups ug ON cr.userId = ug.userId " +
				"AND ug.groupId ="+courseGropupCreatedId;
		if(teamId>0){
			sql+=" INNER JOIN users_teams ut ON cr.userId = ut.userId AND ut.teamId = "+teamId;
		}
		sql+=" WHERE courseId="+courseId;
		
		// Se prepara el metodo para recibir un Listado de estudiantes especificos,, por ejemplo que pertenezcan a alguna organizacion. Sino, se trabaja con todos los estudiantes del curso.
		if(Validator.isNotNull(_students) && _students.size() > 0){
			sql += " AND cr.userId in (-1";
			for(User user:_students){
				sql+=","+user.getUserId();
			}
			sql+=") ";
		}
		
		sql+=" AND cr.userId not in ( SELECT userId FROM usergrouprole WHERE usergrouprole.groupId = " +courseGropupCreatedId+
			 " AND usergrouprole.roleId in ("+teacherRoleId+","+editorRoleId+"))";	
		
		session = openSession();			
		
		log.debug("sql: " + sql);			
		
		SQLQuery q = session.createSQLQuery(sql);
		return ((List<BigInteger>) q.list()).get(0).longValue();
		
	} catch (Exception e) {
       e.printStackTrace();
    } finally {
        closeSession(session);
    }

    return 0;
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:44,代码来源:CourseResultFinderImpl.java

示例13: countFinishedOnlyStudents

import com.liferay.portal.model.User; //导入方法依赖的package包/类
public long countFinishedOnlyStudents(long courseId, long companyId, long courseGropupCreatedId, List<User> _students, long teamId){
	Session session = null;
	try{
		LmsPrefs prefs = LmsPrefsLocalServiceUtil.fetchLmsPrefs(companyId);			
		long teacherRoleId=RoleLocalServiceUtil.getRole(prefs.getTeacherRole()).getRoleId();
		long editorRoleId=RoleLocalServiceUtil.getRole(prefs.getEditorRole()).getRoleId();
		
		String sql="SELECT count(1) " +
				" FROM lms_courseresult cr " +
				" INNER JOIN users_groups ug ON cr.userId = ug.userId " +
				" AND ug.groupId ="+courseGropupCreatedId;
		if(teamId>0){
			sql+=" INNER JOIN users_teams ut ON cr.userId = ut.userId AND ut.teamId = "+teamId;
		}
		sql+=" WHERE courseId="+courseId+" AND cr.passedDate IS NOT NULL ";
		
		// Se prepara el metodo para recibir un Listado de estudiantes especificos,, por ejemplo que pertenezcan a alguna organizacion. Sino, se trabaja con todos los estudiantes del curso.
		if(Validator.isNotNull(_students) && _students.size() > 0){
			sql += " AND cr.userId in (-1";
			for(User user:_students){
				sql+=","+user.getUserId();
			}
			sql+=") ";
		}
		
		sql+=" AND cr.userId not in ( SELECT userId FROM usergrouprole WHERE usergrouprole.groupId = " +courseGropupCreatedId+
			 " AND usergrouprole.roleId in ("+teacherRoleId+","+editorRoleId+"))";	
		
		session = openSession();			
		
		log.debug("sql: " + sql);			
		
		SQLQuery q = session.createSQLQuery(sql);
		
		return ((List<BigInteger>) q.list()).get(0).longValue();
		
	} catch (Exception e) {
       e.printStackTrace();
    } finally {
        closeSession(session);
    }

    return 0;
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:45,代码来源:CourseResultFinderImpl.java

示例14: countFinishedPassedOnlyStudents

import com.liferay.portal.model.User; //导入方法依赖的package包/类
public long countFinishedPassedOnlyStudents(long courseId, long companyId, long courseGropupCreatedId, List<User> _students, boolean passed, long teamId){
	Session session = null;
	try{
		LmsPrefs prefs = LmsPrefsLocalServiceUtil.fetchLmsPrefs(companyId);			
		long teacherRoleId=RoleLocalServiceUtil.getRole(prefs.getTeacherRole()).getRoleId();
		long editorRoleId=RoleLocalServiceUtil.getRole(prefs.getEditorRole()).getRoleId();
		
		String sql="SELECT count(1) " +
				" FROM lms_courseresult cr " +
				" INNER JOIN users_groups ug ON cr.userId = ug.userId " +
				" AND ug.groupId ="+courseGropupCreatedId;
		if(teamId>0){
			sql+=" INNER JOIN users_teams ut ON cr.userId = ut.userId AND ut.teamId = "+teamId;
		}
		sql+=" WHERE courseId="+courseId+" AND cr.passedDate IS NOT NULL AND cr.passed = "+passed;
		
		// Se prepara el metodo para recibir un Listado de estudiantes especificos,, por ejemplo que pertenezcan a alguna organizacion. Sino, se trabaja con todos los estudiantes del curso.
		if(Validator.isNotNull(_students) && _students.size() > 0){
			sql += " AND cr.userId in (-1";
			for(User user:_students){
				sql+=","+user.getUserId();
			}
			sql+=") ";
		}
		
		sql+=" AND cr.userId not in ( SELECT userId FROM usergrouprole WHERE usergrouprole.groupId = " +courseGropupCreatedId+
			 " AND usergrouprole.roleId in ("+teacherRoleId+","+editorRoleId+"))";	
		
		session = openSession();			
		
		log.debug("sql: " + sql);			
		
		SQLQuery q = session.createSQLQuery(sql);
		
		return ((List<BigInteger>) q.list()).get(0).longValue();
		
	} catch (Exception e) {
       e.printStackTrace();
    } finally {
        closeSession(session);
    }

    return 0;
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:45,代码来源:CourseResultFinderImpl.java

示例15: avgFinishedOnlyStudents

import com.liferay.portal.model.User; //导入方法依赖的package包/类
public double avgFinishedOnlyStudents(long courseId, long companyId, long courseGropupCreatedId, List<User> _students, boolean passed, long teamId){
	Session session = null;
	double result = 0;
	try{
		LmsPrefs prefs = LmsPrefsLocalServiceUtil.fetchLmsPrefs(companyId);			
		long teacherRoleId=RoleLocalServiceUtil.getRole(prefs.getTeacherRole()).getRoleId();
		long editorRoleId=RoleLocalServiceUtil.getRole(prefs.getEditorRole()).getRoleId();
		
		String sql="SELECT avg(cr.result) " +
				" FROM lms_courseresult cr " +
				" INNER JOIN users_groups ug ON cr.userId = ug.userId " +
				" AND ug.groupId ="+courseGropupCreatedId;
		if(teamId>0){
			sql+=" INNER JOIN users_teams ut ON cr.userId = ut.userId AND ut.teamId = "+teamId;
		}
		sql+=" WHERE courseId="+courseId+" AND cr.passedDate IS NOT NULL AND cr.passed =" + passed;
		
		// Se prepara el metodo para recibir un Listado de estudiantes especificos,, por ejemplo que pertenezcan a alguna organizacion. Sino, se trabaja con todos los estudiantes del curso.
		if(Validator.isNotNull(_students) && _students.size() > 0){
			sql += " AND cr.userId in (-1";
			for(User user:_students){
				sql+=","+user.getUserId();
			}
			sql+=") ";
		}
		
		sql+=" AND cr.userId not in ( SELECT userId FROM usergrouprole WHERE usergrouprole.groupId = " +courseGropupCreatedId+
			 " AND usergrouprole.roleId in ("+teacherRoleId+","+editorRoleId+"))";	
		
		session = openSession();			
		
		log.debug("sql: " + sql);			
		
		SQLQuery q = session.createSQLQuery(sql);
		if((q.list()).get(0)!=null){
			result = ((List<BigDecimal>) q.list()).get(0).doubleValue();
		}		
	} catch (Exception e) {
       e.printStackTrace();
    } finally {
        closeSession(session);
    }

    return result;
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:46,代码来源:CourseResultFinderImpl.java


注:本文中的com.liferay.portal.model.User.getUserId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。