Skip to content

Commit

Permalink
Issue #723 - test for cluster name exists
Browse files Browse the repository at this point in the history
  • Loading branch information
FrankSylvia committed Mar 1, 2023
1 parent 13d44f6 commit 1e431ec
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 10 deletions.
7 changes: 6 additions & 1 deletion resources/teacherTools/teacherToolsMain.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,12 @@ catch (Exception e) {
var toYear = t_schoolYear;
var fromYear = toYear-1;
myHTML += '<div class="pull-right">&nbsp;&nbsp;' + labelYear + ':' + fromYear + '-' + toYear + '</div>';
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") %>';
Expand Down
30 changes: 29 additions & 1 deletion src/edu/umass/ckc/wo/db/DbClass.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}


Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
3 changes: 2 additions & 1 deletion web/WEB-INF/classes/MathSpring.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion web/WEB-INF/classes/MathSpring_es.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion webProduction/WEB-INF/classes/MathSpring.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion webProduction/WEB-INF/classes/MathSpring_es.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion webTest/WEB-INF/classes/MathSpring.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion webTest/WEB-INF/classes/MathSpring_es.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1e431ec

Please sign in to comment.