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


Java Assignment.getSortOrder方法代码示例

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


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

示例1: addAssignment

import org.sakaiproject.service.gradebook.shared.Assignment; //导入方法依赖的package包/类
/**
 * Add a new assignment definition to the gradebook
 *
 * @param assignment
 * @return id of the newly created assignment or null if there were any errors
 */
public Long addAssignment(final Assignment assignment) {

	final Gradebook gradebook = getGradebook();

	if (gradebook != null) {
		final String gradebookId = gradebook.getUid();

		final Long assignmentId = this.gradebookService.addAssignment(gradebookId, assignment);

		// Force the assignment to sit at the end of the list
		if (assignment.getSortOrder() == null) {
			final List<Assignment> allAssignments = this.gradebookService.getAssignments(gradebookId);
			int nextSortOrder = allAssignments.size();
			for (final Assignment anotherAssignment : allAssignments) {
				if (anotherAssignment.getSortOrder() != null && anotherAssignment.getSortOrder() >= nextSortOrder) {
					nextSortOrder = anotherAssignment.getSortOrder() + 1;
				}
			}
			updateAssignmentOrder(assignmentId, nextSortOrder);
		}

		// also update the categorized order
		updateAssignmentCategorizedOrder(gradebook.getUid(), assignment.getCategoryId(), assignmentId,
				Integer.MAX_VALUE);

		return assignmentId;

		// TODO wrap this so we can catch any runtime exceptions
	}
	return null;
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:38,代码来源:GradebookNgBusinessService.java

示例2: getAssignmentSortOrder

import org.sakaiproject.service.gradebook.shared.Assignment; //导入方法依赖的package包/类
/**
 * Get the sort order of an assignment. If the assignment has a sort order, use that. Otherwise we determine the order of the assignment
 * in the list of assignments
 *
 * This means that we can always determine the most current sort order for an assignment, even if the list has never been sorted.
 *
 *
 * @param assignmentId
 * @return sort order if set, or calculated, or -1 if cannot determine at all.
 */
public int getAssignmentSortOrder(final long assignmentId) {
	final String siteId = getCurrentSiteId();
	final Gradebook gradebook = getGradebook(siteId);

	if (gradebook != null) {
		final Assignment assignment = this.gradebookService.getAssignment(gradebook.getUid(), assignmentId);

		// if the assignment has a sort order, return that
		if (assignment.getSortOrder() != null) {
			return assignment.getSortOrder();
		}

		// otherwise we need to determine the assignment sort order within
		// the list of assignments
		final List<Assignment> assignments = this.getGradebookAssignments(siteId);

		for (int i = 0; i < assignments.size(); i++) {
			final Assignment a = assignments.get(i);
			if (assignmentId == a.getId() && a.getSortOrder() != null) {
				return a.getSortOrder();
			}
		}
	}

	return -1;
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:37,代码来源:GradebookNgBusinessService.java

示例3: addAssignment

import org.sakaiproject.service.gradebook.shared.Assignment; //导入方法依赖的package包/类
/**
   * Add a new assignment definition to the gradebook
   * @param assignment
* @return id of the newly created assignment or null if there were any errors
   */
  public Long addAssignment(Assignment assignment) {

  	Gradebook gradebook = getGradebook();
      
  	if(gradebook != null) {
          String gradebookId = gradebook.getUid();

          Long assignmentId = this.gradebookService.addAssignment(gradebookId, assignment);

          // Force the assignment to sit at the end of the list
          if (assignment.getSortOrder() == null) {
              List<Assignment> allAssignments = this.gradebookService.getAssignments(gradebookId);
              int nextSortOrder = allAssignments.size();
              for (Assignment anotherAssignment : allAssignments) {
                  if (anotherAssignment.getSortOrder() != null && anotherAssignment.getSortOrder() >= nextSortOrder) {
                      nextSortOrder = anotherAssignment.getSortOrder() + 1;
                  }
              }
              updateAssignmentOrder(assignmentId, nextSortOrder);
          }

          // also update the categorized order
          syncCatagorizedAssignmentOrder(getCurrentSiteId(), assignment);

          return assignmentId;
          
          //TODO wrap this so we can catch any runtime exceptions
      }
return null;
  }
 
开发者ID:steveswinsburg,项目名称:gradebookNG,代码行数:36,代码来源:GradebookNgBusinessService.java

示例4: getAssignmentSortOrder

import org.sakaiproject.service.gradebook.shared.Assignment; //导入方法依赖的package包/类
/**
 * Get the sort order of an assignment. If the assignment has a sort order, use that.
 * Otherwise we determine the order of the assignment in the list of assignments
 * 
 * This means that we can always determine the most current sort order for an assignment, even if the list has never been sorted.
 * 
 * 
 * @param assignmentId
 * @return sort order if set, or calculated, or -1 if cannot determine at all.
 */
public int getAssignmentSortOrder(long assignmentId) {
 String siteId = this.getCurrentSiteId();
 Gradebook gradebook = getGradebook(siteId);
     	 
 if(gradebook != null) {
	 Assignment assignment = gradebookService.getAssignment(gradebook.getUid(), assignmentId);
	 
	 //if the assignment has a sort order, return that
	 if(assignment.getSortOrder() != null) {
		 return assignment.getSortOrder();
	 }
	 
	 //otherwise we need to determine the assignment sort order within the list of assignments
	 List<Assignment> assignments = this.getGradebookAssignments(siteId);
	
	 
	 for(int i=0; i<assignments.size(); i++) {
		 Assignment a = assignments.get(i);
		 if(assignmentId == a.getId()) {
			 return a.getSortOrder();
		 }
	 }
 }
 
 return -1;
}
 
开发者ID:steveswinsburg,项目名称:gradebookNG,代码行数:37,代码来源:GradebookNgBusinessService.java


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