From 1e431ec6808cfaed2b470e625ada9adb06f41423 Mon Sep 17 00:00:00 2001 From: fsylvia Date: Wed, 1 Mar 2023 08:56:36 -0800 Subject: [PATCH] Issue #723 - test for cluster name exists --- resources/teacherTools/teacherToolsMain.jsp | 7 ++++- src/edu/umass/ckc/wo/db/DbClass.java | 30 ++++++++++++++++++- .../impl/TTCreateClassAssistServiceImpl.java | 10 +++++-- web/WEB-INF/classes/MathSpring.properties | 3 +- web/WEB-INF/classes/MathSpring_es.properties | 3 +- .../WEB-INF/classes/MathSpring.properties | 3 +- .../WEB-INF/classes/MathSpring_es.properties | 3 +- webTest/WEB-INF/classes/MathSpring.properties | 3 +- .../WEB-INF/classes/MathSpring_es.properties | 3 +- 9 files changed, 55 insertions(+), 10 deletions(-) diff --git a/resources/teacherTools/teacherToolsMain.jsp b/resources/teacherTools/teacherToolsMain.jsp index 1570aa54..298999bc 100644 --- a/resources/teacherTools/teacherToolsMain.jsp +++ b/resources/teacherTools/teacherToolsMain.jsp @@ -366,7 +366,12 @@ catch (Exception e) { var toYear = t_schoolYear; var fromYear = toYear-1; myHTML += '
  ' + labelYear + ':' + fromYear + '-' + toYear + '
'; - labelClassCode = '<%= rb.getString("class_code") %>'; + if (t_hasClusters) { + labelClassCode = '<%= rb.getString("master_code") %>'; + } + else { + labelClassCode = '<%= rb.getString("class_code") %>'; + } } else { labelClassCode = '<%= rb.getString("cluster_code") %>'; diff --git a/src/edu/umass/ckc/wo/db/DbClass.java b/src/edu/umass/ckc/wo/db/DbClass.java index 933572d1..161ce4e2 100644 --- a/src/edu/umass/ckc/wo/db/DbClass.java +++ b/src/edu/umass/ckc/wo/db/DbClass.java @@ -2056,7 +2056,35 @@ public static String getStringClassesInCluster(Connection conn, String classId) rs.close(); } } - + + public static final boolean isClassNameInUse(Connection conn, String newName) { + boolean result = true; + + ResultSet rs=null; + PreparedStatement stmt=null; + try { + String q = "select name from class where name = ?"; + stmt = conn.prepareStatement(q); + stmt.setString(1,newName); + rs = stmt.executeQuery(); + if (rs.next()) { + result = true; + } + else { + result = false; + } + if (stmt != null) + stmt.close(); + if (rs != null) + rs.close(); + } + catch(SQLException e) { + System.out.println(e.getMessage()); + } + + + return result; + } } \ No newline at end of file diff --git a/src/edu/umass/ckc/wo/ttmain/ttservice/classservice/impl/TTCreateClassAssistServiceImpl.java b/src/edu/umass/ckc/wo/ttmain/ttservice/classservice/impl/TTCreateClassAssistServiceImpl.java index ff5070ff..53081419 100644 --- a/src/edu/umass/ckc/wo/ttmain/ttservice/classservice/impl/TTCreateClassAssistServiceImpl.java +++ b/src/edu/umass/ckc/wo/ttmain/ttservice/classservice/impl/TTCreateClassAssistServiceImpl.java @@ -154,8 +154,14 @@ public boolean editClass(CreateClassForm createForm, String tid, int classId) th public Integer cloneExistingClass(Integer classId, CreateClassForm createForm) throws TTCustomException { int result = 0; - try { - ClassInfo ciPrev = DbClass.getClass(connection.getConnection(), classId); + try { + + boolean inUse = DbClass.isClassNameInUse(connection.getConnection(), createForm.getClassName()); + if (inUse) { + throw new TTCustomException(ErrorCodeMessageConstants.ERROR_WHILE_CLONNING_EXISTING_CLASS); + } + + ClassInfo ciPrev = DbClass.getClass(connection.getConnection(), classId); createForm.setClassGrade(ciPrev.getGrade()); int newClassId = ClassCloner.cloneClass(connection.getConnection(),classId,createForm.getClassName(),createForm.getGradeSection(),createForm.getClassLanguage(),createForm.getColor()); diff --git a/web/WEB-INF/classes/MathSpring.properties b/web/WEB-INF/classes/MathSpring.properties index 47c62681..8f1bc51c 100644 --- a/web/WEB-INF/classes/MathSpring.properties +++ b/web/WEB-INF/classes/MathSpring.properties @@ -880,7 +880,8 @@ violet=violet yellow=yellow home_page_for_cluster=Home Page for Cluster cluster_name=Cluster name -cluster_code=Cluster Code +cluster_code=Cluster code +master_code=Master code clusters=Clusters create_class_cluster=Create Class Cluster select_a_destination=Select a destination diff --git a/web/WEB-INF/classes/MathSpring_es.properties b/web/WEB-INF/classes/MathSpring_es.properties index fd4376ad..78010bb6 100644 --- a/web/WEB-INF/classes/MathSpring_es.properties +++ b/web/WEB-INF/classes/MathSpring_es.properties @@ -880,7 +880,8 @@ violet=Violeta yellow=amarillo home_page_for_cluster=Página de inicio del clúster cluster_name=El nombre de clúster -cluster_code=código de clúster +cluster_code=Código de clúster +master_code=Código principal clusters=Los clústeres create_class_cluster=Crear clúster de clase select_a_destination=Seleccione un destino diff --git a/webProduction/WEB-INF/classes/MathSpring.properties b/webProduction/WEB-INF/classes/MathSpring.properties index 47c62681..8f1bc51c 100644 --- a/webProduction/WEB-INF/classes/MathSpring.properties +++ b/webProduction/WEB-INF/classes/MathSpring.properties @@ -880,7 +880,8 @@ violet=violet yellow=yellow home_page_for_cluster=Home Page for Cluster cluster_name=Cluster name -cluster_code=Cluster Code +cluster_code=Cluster code +master_code=Master code clusters=Clusters create_class_cluster=Create Class Cluster select_a_destination=Select a destination diff --git a/webProduction/WEB-INF/classes/MathSpring_es.properties b/webProduction/WEB-INF/classes/MathSpring_es.properties index fd4376ad..78010bb6 100644 --- a/webProduction/WEB-INF/classes/MathSpring_es.properties +++ b/webProduction/WEB-INF/classes/MathSpring_es.properties @@ -880,7 +880,8 @@ violet=Violeta yellow=amarillo home_page_for_cluster=Página de inicio del clúster cluster_name=El nombre de clúster -cluster_code=código de clúster +cluster_code=Código de clúster +master_code=Código principal clusters=Los clústeres create_class_cluster=Crear clúster de clase select_a_destination=Seleccione un destino diff --git a/webTest/WEB-INF/classes/MathSpring.properties b/webTest/WEB-INF/classes/MathSpring.properties index 47c62681..8f1bc51c 100644 --- a/webTest/WEB-INF/classes/MathSpring.properties +++ b/webTest/WEB-INF/classes/MathSpring.properties @@ -880,7 +880,8 @@ violet=violet yellow=yellow home_page_for_cluster=Home Page for Cluster cluster_name=Cluster name -cluster_code=Cluster Code +cluster_code=Cluster code +master_code=Master code clusters=Clusters create_class_cluster=Create Class Cluster select_a_destination=Select a destination diff --git a/webTest/WEB-INF/classes/MathSpring_es.properties b/webTest/WEB-INF/classes/MathSpring_es.properties index fd4376ad..78010bb6 100644 --- a/webTest/WEB-INF/classes/MathSpring_es.properties +++ b/webTest/WEB-INF/classes/MathSpring_es.properties @@ -880,7 +880,8 @@ violet=Violeta yellow=amarillo home_page_for_cluster=Página de inicio del clúster cluster_name=El nombre de clúster -cluster_code=código de clúster +cluster_code=Código de clúster +master_code=Código principal clusters=Los clústeres create_class_cluster=Crear clúster de clase select_a_destination=Seleccione un destino