1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.coa.dataaccess.impl;
17
18 import org.apache.ojb.broker.metadata.MetadataManager;
19 import org.kuali.ole.coa.businessobject.Organization;
20 import org.kuali.ole.coa.businessobject.PriorYearOrganization;
21 import org.kuali.ole.coa.dataaccess.PriorYearOrganizationDao;
22 import org.kuali.rice.core.framework.persistence.jdbc.dao.PlatformAwareDaoBaseJdbc;
23
24
25
26
27 public class PriorYearOrganizationDaoJdbc extends PlatformAwareDaoBaseJdbc implements PriorYearOrganizationDao {
28
29
30 private static final String OBJ_ID = "OBJ_ID";
31
32
33
34
35
36
37
38 public int purgePriorYearOrganizations() {
39 String priorYrOrgTableName = MetadataManager.getInstance().getGlobalRepository().getDescriptorFor(PriorYearOrganization.class).getFullTableName();
40
41
42 int count = getSimpleJdbcTemplate().queryForInt("SELECT COUNT(" + OBJ_ID + ") from " + priorYrOrgTableName);
43
44
45 getSimpleJdbcTemplate().update("DELETE from " + priorYrOrgTableName);
46
47 return count;
48 }
49
50
51
52
53
54
55
56 public int copyCurrentOrganizationsToPriorYearTable() {
57 String priorYrOrgTableName = MetadataManager.getInstance().getGlobalRepository().getDescriptorFor(PriorYearOrganization.class).getFullTableName();
58 String orgTableName = MetadataManager.getInstance().getGlobalRepository().getDescriptorFor(Organization.class).getFullTableName();
59
60
61 getSimpleJdbcTemplate().update("INSERT into " + priorYrOrgTableName + " SELECT * from " + orgTableName);
62
63
64 return getSimpleJdbcTemplate().queryForInt("SELECT COUNT(" + OBJ_ID + ") from " + priorYrOrgTableName);
65 }
66
67 }