Skip to content

Commit 0924bc9

Browse files
committed
add query for getting project ids
1 parent 7ccce73 commit 0924bc9

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

src/main/java/com/topcoder/onlinereview/component/project/management/ProjectManager.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ public Project[] searchProjects(Filter filter) throws PersistenceException {
5959
}
6060
}
6161

62+
public long[] searchProjectsForIds(String query) throws PersistenceException {
63+
return this.persistence.searchProjectsForIds(query);
64+
}
65+
6266
public Project[] getAllProjects(Long userId, ProjectStatus status, int page, int perPage, long categoryId,
6367
boolean my, boolean hasManagerRole) throws PersistenceException {
6468
return persistence.getAllProjects(userId, status, page, perPage, categoryId, my, hasManagerRole);

src/main/java/com/topcoder/onlinereview/component/project/management/ProjectPersistence.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2590,6 +2590,27 @@ public Project[] getAllProjects(
25902590
return projects;
25912591
}
25922592

2593+
/**
2594+
* Gets projects ids.
2595+
*
2596+
* @return the id array
2597+
*/
2598+
public long[] searchProjectsForIds(String query) {
2599+
try {
2600+
List<Map<String, Object>> result = executeSql(jdbcTemplate, query);
2601+
// create the PrizeType array.
2602+
long[] projectIds = new long[result.size()];
2603+
2604+
for (int i = 0; i < result.size(); ++i) {
2605+
Map<String, Object> row = result.get(i);
2606+
projectIds[i] = getLong(row, "project_id");
2607+
}
2608+
return projectIds;
2609+
} catch (Exception e) {
2610+
throw new PersistenceException("error occurs when trying to get ids.");
2611+
}
2612+
}
2613+
25932614
private Project[] getProjectsList(String query, List<Object> args, ProjectStatus status)
25942615
throws PersistenceException {
25952616
// find projects in the table.

0 commit comments

Comments
 (0)