385
385
* <p>
386
386
* Version 1.8.2 (TOPCODER - SUPPORT GROUPS CONCEPT FOR CHALLENGES):
387
387
* <ul>
388
- * <li>Added {@link #CREATE_PROJECT_GROUP_SQL}</li>
389
- * <li>Added {@link #DELETE_PROJECT_GROUP_SQL}</li>
390
388
* <li>Added {@link #QUERY_ALL_PROJECT_GROUP_SQL}</li>
391
389
* <li>Added {@link #QUERY_ALL_PROJECT_GROUP_COLUMN_TYPES}</li>
392
- * <li>Added {@link #QUERY_PROJECT_GROUP_SQL}</li>
393
- * <li>Added {@link #QUERY_PROJECT_GROUP_COLUMN_TYPES}</li>
394
- * <li>Added {@link #QUERY_PROJECT_GROUP_IDS_SQL}</li>
395
- * <li>Updated {@link #createProject(Long, Project, String, Connection)}</li>
396
- * <li>Updated {@link #getProjects(long[], Connection)} add groups</li>
397
- * <li>Updated {@link #updateProject(Project, String, String, Connection)}</li>
398
- * <li>Added {@link #updateProjectGroups(Long, List<ProjectGroup>, String, Connection)} to update challenge groups</li>
399
390
* <li>Added {@link #getAllProjectGroups()} get all groups</li>
400
- * <li>Added {@link #createProjectGroup(Long, List, String, Connection)}to add groups of challenge</li>
401
- * <li>Added {@link #getProjectGroupIdsForProject(Long, Connection)} get groupg ids of challenge</li>
402
- * <li>Added {@link #deleteProjectGroup(Long, List, Connection)} to delete groups</li>
403
391
* </ul>
404
392
*
405
393
* @author tuenm, urtks, bendlund, fuyun, flytoj2ee, tangzx, GreatKevin, frozenfx, freegod, bugbuka, Veve, GreatKevin, TCSCODER
@@ -2464,28 +2452,12 @@ public abstract class AbstractInformixProjectPersistence implements ProjectPersi
2464
2452
private static final String UPDATE_CHECKPOINT_FEEDBACK_SQL = "UPDATE comp_milestone_feedback "
2465
2453
+ "SET feedback = ? WHERE project_id = " ;
2466
2454
2467
- /**
2468
- * Sql statement for adding challenge group
2469
- * @since 1.8.2
2470
- */
2471
- private static final String CREATE_PROJECT_GROUP_SQL = "INSERT INTO project_group_xref "
2472
- + "(project_id, project_group_id,"
2473
- + "create_user, create_date, modify_user, modify_date) "
2474
- + "VALUES (?, ?, ?, CURRENT, ?, CURRENT)" ;
2475
-
2476
- /**
2477
- * Sql statement for deleting challenge group
2478
- * @since 1.8.2
2479
- */
2480
- private static final String DELETE_PROJECT_GROUP_SQL = "DELETE FROM project_group_xref "
2481
- + "WHERE project_id = ? AND project_group_id IN " ;
2482
-
2483
2455
/**
2484
2456
* Sql statement for fetching all of challenge groups
2485
2457
* @since 1.8.2
2486
2458
*/
2487
- private static final String QUERY_ALL_PROJECT_GROUP_SQL = "SELECT project_group_id, name " +
2488
- " FROM project_group_lu " ;
2459
+ private static final String QUERY_ALL_PROJECT_GROUP_SQL = "SELECT group_id, description " +
2460
+ " FROM security_groups where challenge_group_ind=1 " ;
2489
2461
2490
2462
/**
2491
2463
* Return type of {@link #QUERY_ALL_PROJECT_GROUP_SQL}
@@ -2494,30 +2466,6 @@ public abstract class AbstractInformixProjectPersistence implements ProjectPersi
2494
2466
private static final DataType [] QUERY_ALL_PROJECT_GROUP_COLUMN_TYPES = new DataType [] {
2495
2467
Helper .LONG_TYPE , Helper .STRING_TYPE };
2496
2468
2497
- /**
2498
- * Sql statement for fetching challenge groups of a challenge
2499
- * @since 1.8.2
2500
- */
2501
- private static final String QUERY_PROJECT_GROUP_SQL =
2502
- "SELECT pg.project_id, pg.project_group_id, plu.name \n " +
2503
- "FROM project_group_xref pg \n " +
2504
- "INNER JOIN project_group_lu plu \n " +
2505
- "ON pg.project_group_id = plu.project_group_id WHERE pg.project_id IN" ;
2506
-
2507
- /**
2508
- * Return type of {@link #QUERY_PROJECT_GROUP_SQL}
2509
- * @since 1.8.2
2510
- */
2511
- private static final DataType [] QUERY_PROJECT_GROUP_COLUMN_TYPES = new DataType [] {
2512
- Helper .LONG_TYPE , Helper .LONG_TYPE , Helper .STRING_TYPE };
2513
-
2514
- /**
2515
- * Sql statement for fetching group id of challenge group
2516
- * @since 1.8.2
2517
- */
2518
- private static final String QUERY_PROJECT_GROUP_IDS_SQL = "SELECT "
2519
- + "project_group_id FROM project_group_xref WHERE project_id = ?" ;
2520
-
2521
2469
/**
2522
2470
* <p>
2523
2471
* The factory instance used to create connection to the database. It is
@@ -5425,9 +5373,6 @@ private void createProject(Long projectId, Project project,
5425
5373
5426
5374
// create the project platforms
5427
5375
createProjectPlatforms (projectId , project .getPlatforms (), operator , conn );
5428
-
5429
- //create challenge group
5430
- createProjectGroup (projectId , project .getGroups (), operator , conn );
5431
5376
}
5432
5377
5433
5378
/**
@@ -5586,9 +5531,6 @@ private void updateProject(Project project, String reason, String operator,
5586
5531
5587
5532
// update the project platforms
5588
5533
updateProjectPlatforms (projectId , project .getPlatforms (), operator , conn );
5589
-
5590
- //update group
5591
- updateProjectGroups (projectId , project .getGroups (), operator , conn );
5592
5534
}
5593
5535
5594
5536
/**
@@ -5937,14 +5879,7 @@ private Project[] getProjects(long ids[], Connection conn)
5937
5879
5938
5880
project .getPlatforms ().add (new ProjectPlatform ((Long ) row [1 ], (String ) row [2 ]));
5939
5881
}
5940
- //get challenge group
5941
- rows = Helper .doQuery (conn , QUERY_PROJECT_GROUP_SQL + idList , new Object []{},
5942
- QUERY_PROJECT_GROUP_COLUMN_TYPES );
5943
- for (int i = 0 ; i < rows .length ; ++i ) {
5944
- Object [] row = rows [i ];
5945
- Project project = (Project ) projectMap .get (row [0 ]);
5946
- project .getGroups ().add (new ProjectGroup ((Long ) row [1 ], (String ) row [2 ]));
5947
- }
5882
+
5948
5883
return projects ;
5949
5884
}
5950
5885
/**
@@ -10080,58 +10015,6 @@ private List<CopilotContestExtraInfo> getCopilotContestExtraInfos(long projectId
10080
10015
}
10081
10016
}
10082
10017
10083
- /**
10084
- * <p>
10085
- * Update groups of the challenge
10086
- * </p>
10087
- *
10088
- * @param projectId project Id
10089
- * @param groups list of challenge groups
10090
- * @param operator user id who execute this
10091
- * @param conn connection
10092
- * @throws PersistenceException if database related exception occur
10093
- * @since 1.8.2
10094
- */
10095
- private void updateProjectGroups (Long projectId , List <ProjectGroup > groups , String operator , Connection conn )
10096
- throws PersistenceException {
10097
-
10098
- if (groups == null ) {
10099
- groups = new ArrayList <ProjectGroup >();
10100
- }
10101
-
10102
- // get old platform ids from database
10103
- Set <Long > oldGroupIds = getProjectGroupIdsForProject (projectId , conn );
10104
-
10105
- // create a list to contain the platforms to insert
10106
- List <ProjectGroup > groupsToAdd = new ArrayList <ProjectGroup >();
10107
-
10108
- // create a list to contain the platforms to remove
10109
- List <Long > groupsToDelete = new ArrayList <Long >();
10110
-
10111
- Set <Long > newGroupIds = new HashSet <Long >();
10112
-
10113
- for (ProjectGroup p : groups ) {
10114
- if (!oldGroupIds .contains (p .getId ())) {
10115
- // the existing does not contain, to add
10116
- groupsToAdd .add (p );
10117
- }
10118
- newGroupIds .add (p .getId ());
10119
- }
10120
-
10121
- for (Long oldGId : oldGroupIds ) {
10122
- if (!newGroupIds .contains (oldGId )) {
10123
- // the old platform is not in the new platform, to remove
10124
- groupsToDelete .add (oldGId );
10125
- }
10126
- }
10127
-
10128
- // create the new platforms
10129
- createProjectGroup (projectId , groupsToAdd , operator , conn );
10130
-
10131
- // delete the old platforms
10132
- deleteProjectGroup (projectId , groupsToDelete , conn );
10133
- }
10134
-
10135
10018
/**
10136
10019
* <p>
10137
10020
* Get all groups
@@ -10172,116 +10055,4 @@ public ProjectGroup[] getAllProjectGroups() throws PersistenceException {
10172
10055
throw e ;
10173
10056
}
10174
10057
}
10175
-
10176
- /**
10177
- * <p>
10178
- * Add groups to a challenge
10179
- * </p>
10180
- *
10181
- * @param projectId project Id
10182
- * @param groups list of ProjectGroup of the challenge
10183
- * @param operator user whos execute this
10184
- * @param conn connection
10185
- * @throws PersistenceException if any database exception occur
10186
- * @since 1.8.2
10187
- */
10188
- private void createProjectGroup (Long projectId , List <ProjectGroup > groups , String operator , Connection conn )
10189
- throws PersistenceException {
10190
-
10191
- getLogger ().log (Level .INFO , new LogMessage (projectId , operator ,
10192
- "insert record into project_group_xref with project id" + projectId ));
10193
-
10194
- if (groups == null || groups .size () == 0 ) {
10195
- return ;
10196
- }
10197
-
10198
- PreparedStatement preparedStatement = null ;
10199
-
10200
- try {
10201
- // prepare the statement.
10202
- preparedStatement = conn
10203
- .prepareStatement (CREATE_PROJECT_GROUP_SQL );
10204
-
10205
- // enumerator each project platform
10206
- for (ProjectGroup group : groups ) {
10207
- System .out .println ("DDD create: " + group .getId ());
10208
- Object [] queryArgs = new Object []{projectId , group .getId (),
10209
- operator , operator };
10210
- Helper .doDMLQuery (preparedStatement , queryArgs );
10211
- }
10212
-
10213
- } catch (SQLException e ) {
10214
- throw new PersistenceException (
10215
- "Unable to create prepared statement ["
10216
- + CREATE_PROJECT_GROUP_SQL + "]." , e );
10217
- } finally {
10218
- Helper .closeStatement (preparedStatement );
10219
- }
10220
- }
10221
-
10222
- /**
10223
- * <p>
10224
- * Get ids of groups of the challenge
10225
- * </p>
10226
- *
10227
- * @param projectId project ID
10228
- * @param conn connection
10229
- * @return list of ids of groups
10230
- * @throws PersistenceException if any database related exception occur
10231
- * @sincec 1.8.2
10232
- */
10233
- private Set <Long > getProjectGroupIdsForProject (Long projectId , Connection conn ) throws PersistenceException {
10234
- Set <Long > groupIds = new HashSet <Long >();
10235
-
10236
- // find projects in the table.
10237
- Object [][] rows = Helper .doQuery (conn , QUERY_PROJECT_GROUP_IDS_SQL ,
10238
- new Object []{projectId }, new DataType [] {Helper .LONG_TYPE });
10239
-
10240
- // enumerator each row
10241
- for (int i = 0 ; i < rows .length ; ++i ) {
10242
- Object [] row = rows [i ];
10243
-
10244
- // add the id to the map
10245
- groupIds .add ((Long ) row [0 ]);
10246
- }
10247
-
10248
- return groupIds ;
10249
- }
10250
-
10251
- /**
10252
- * <p>
10253
- * Delete groups from challenge
10254
- * </p>
10255
- *
10256
- * @param projectId project Id
10257
- * @param groupIds list ids of groups to delete
10258
- * @param conn connection
10259
- * @throws PersistenceException if any database related exception occur
10260
- * @since 1.8.2
10261
- */
10262
- private void deleteProjectGroup (Long projectId , List <Long > groupIds , Connection conn )
10263
- throws PersistenceException {
10264
-
10265
- if (groupIds != null && !groupIds .isEmpty ()) {
10266
-
10267
- // build the id list string
10268
- StringBuffer idListBuffer = new StringBuffer ();
10269
- idListBuffer .append ('(' );
10270
- int idx = 0 ;
10271
- for (Long pid : groupIds ) {
10272
- if (idx ++ != 0 ) {
10273
- idListBuffer .append (',' );
10274
- }
10275
- idListBuffer .append (pid );
10276
- }
10277
- idListBuffer .append (')' );
10278
-
10279
- getLogger ().log (Level .INFO , new LogMessage (projectId , null ,
10280
- "delete records from project_group_xref with projectId:" + projectId ));
10281
-
10282
- // delete the project platforms whose id is in the set
10283
- Helper .doDMLQuery (conn , DELETE_PROJECT_GROUP_SQL
10284
- + idListBuffer .toString (), new Object [] {projectId });
10285
- }
10286
- }
10287
10058
}
0 commit comments