From 37c3a43ea88f9218bbd4c860e4bc03acdc345287 Mon Sep 17 00:00:00 2001
From: srosse <none@none>
Date: Thu, 9 Feb 2012 15:56:56 +0100
Subject: [PATCH] FXOLAT-437: small refactoring

---
 .../java/org/olat/core/CoreSpringFactory.java |  2 +-
 .../assessment/AssessmentMainController.java  | 39 +++++++++++--------
 .../_content/efficiencystatement.html         |  4 +-
 .../org/olat/group/context/BGContextImpl.java | 19 ++++++++-
 4 files changed, 45 insertions(+), 19 deletions(-)

diff --git a/src/main/java/org/olat/core/CoreSpringFactory.java b/src/main/java/org/olat/core/CoreSpringFactory.java
index fad4c582d29..9eeed6c4224 100644
--- a/src/main/java/org/olat/core/CoreSpringFactory.java
+++ b/src/main/java/org/olat/core/CoreSpringFactory.java
@@ -121,7 +121,7 @@ public class CoreSpringFactory implements ServletContextAware, BeanFactoryAware
 		if (m.size() == 1)  {
 			return m.values().iterator().next();
 		}
-		throw new OLATRuntimeException("found more than one bean for: "+ interfaceClass +". Calling this method should only find one bean!", null);
+		throw new OLATRuntimeException("found " + m.size() + " bean for: "+ interfaceClass +". Calling this method should only find one bean!", null);
 	}
 
 	/**
diff --git a/src/main/java/org/olat/course/assessment/AssessmentMainController.java b/src/main/java/org/olat/course/assessment/AssessmentMainController.java
index 7cdab881e4f..b51be9f1c32 100644
--- a/src/main/java/org/olat/course/assessment/AssessmentMainController.java
+++ b/src/main/java/org/olat/course/assessment/AssessmentMainController.java
@@ -427,18 +427,7 @@ AssessmentMainController(UserRequest ureq, WindowControl wControl, OLATResourcea
 					}
 					// init edit controller for this identity and this course node 
 					// or use identity assessment overview if no course node is defined
-					if (this.currentCourseNode == null) {
-						UserCourseEnvironment chooseUserCourseEnv = assessedIdentityWrapper.getUserCourseEnvironment();		
-						removeAsListenerAndDispose(identityAssessmentController);
-						identityAssessmentController = new IdentityAssessmentEditController(getWindowControl(),ureq, chooseUserCourseEnv, course, true);
-						listenTo(identityAssessmentController);
-						setContent(identityAssessmentController.getInitialComponent());
-					} else {
-						removeAsListenerAndDispose(assessmentEditController);
-						assessmentEditController = new AssessmentEditController(ureq, getWindowControl(),course, currentCourseNode, assessedIdentityWrapper);
-						listenTo(assessmentEditController);
-						main.setContent(assessmentEditController.getInitialComponent());
-					}
+					initIdentityEditController(ureq, course);
 				}
 			} else if (event.equals(TableController.EVENT_FILTER_SELECTED)) {
 				ShortName filter = userListCtr.getActiveFilter();
@@ -644,6 +633,27 @@ AssessmentMainController(UserRequest ureq, WindowControl wControl, OLATResourcea
 		}
 	}
 	
+	/**
+	 * Init edit controller for this identity and this course node or use identity assessment
+	 * overview if no course node is defined. (Rely on the instance variable currentCourseNode
+	 * and assessedIdentityWrapper)
+	 * @param ureq
+	 * @param course
+	 */
+	private void initIdentityEditController(UserRequest ureq, ICourse course) {
+		if (currentCourseNode == null) {
+			UserCourseEnvironment chooseUserCourseEnv = assessedIdentityWrapper.getUserCourseEnvironment();
+			removeAsListenerAndDispose(identityAssessmentController);
+			identityAssessmentController = new IdentityAssessmentEditController(getWindowControl(),ureq, chooseUserCourseEnv, course, true);
+			listenTo(identityAssessmentController);
+			setContent(identityAssessmentController.getInitialComponent());
+		} else {
+			removeAsListenerAndDispose(assessmentEditController);
+			assessmentEditController = new AssessmentEditController(ureq, getWindowControl(),course, currentCourseNode, assessedIdentityWrapper);
+			listenTo(assessmentEditController);
+			main.setContent(assessmentEditController.getInitialComponent());
+		}
+	}
 
 	/**
 	 * Initialize the group list table according to the users access rights
@@ -1231,10 +1241,7 @@ AssessmentMainController(UserRequest ureq, WindowControl wControl, OLATResourcea
 				}
 				
 				if(assessedIdentityWrapper != null) {
-					removeAsListenerAndDispose(assessmentEditController);
-					assessmentEditController = new AssessmentEditController(ureq, getWindowControl(), course, currentCourseNode, assessedIdentityWrapper);
-					listenTo(assessmentEditController);
-					main.setContent(assessmentEditController.getInitialComponent());
+					initIdentityEditController(ureq, course);
 				}
 			}
 		}
diff --git a/src/main/java/org/olat/course/assessment/_content/efficiencystatement.html b/src/main/java/org/olat/course/assessment/_content/efficiencystatement.html
index 0bacb080681..c3f88f0cdba 100644
--- a/src/main/java/org/olat/course/assessment/_content/efficiencystatement.html
+++ b/src/main/java/org/olat/course/assessment/_content/efficiencystatement.html
@@ -10,7 +10,9 @@ Ext.onReady(function(){
 #end
 
 <div class="o_efficiencystatement">
-	$r.render("collectArtefactLink")
+	#if($r.available("collectArtefactLink"))
+		$r.render("collectArtefactLink")
+	#end
 	<h3 class="b_with_small_icon_left o_efficiencystatement_icon">$r.translate("efficiencystatement.title")</h3>
 	
 	<table class="b_table">
diff --git a/src/main/java/org/olat/group/context/BGContextImpl.java b/src/main/java/org/olat/group/context/BGContextImpl.java
index 4f84f5cb9ba..20889e3ca6a 100644
--- a/src/main/java/org/olat/group/context/BGContextImpl.java
+++ b/src/main/java/org/olat/group/context/BGContextImpl.java
@@ -156,4 +156,21 @@ public class BGContextImpl extends PersistentObject implements BGContext {
 	public void setDefaultContext(boolean defaultContext) {
 		this.defaultContext = defaultContext;
 	}
-}
\ No newline at end of file
+	
+	@Override
+	public int hashCode() {
+		return getKey() == null ? 836785 : getKey().hashCode();
+	}
+	
+	@Override
+	public boolean equals(Object obj) {
+		if(this == obj) {
+			return true;
+		}
+		if(obj instanceof BGContext) {
+			BGContext ctx = (BGContext)obj;
+			return equalsByPersistableKey(ctx);
+		}
+		return false;
+	}
+}
-- 
GitLab