id stringlengths 36 36 | text stringlengths 1 1.25M |
|---|---|
91fa3a14-6f2b-423f-9c44-93da779b9bea | @Transactional
public void add(Category category) {
// TODO Auto-generated method stub
session.getCurrentSession().save(category);
} |
77d1eaf7-96a0-44bc-bda7-a01265ba6a91 | @Transactional
public void edit(Category category) {
// TODO Auto-generated method stub
session.getCurrentSession().update(category);
} |
66decb6d-2a98-4aa5-9652-b1686c84f22d | @Transactional
public void delete(int categoryId) {
// TODO Auto-generated method stub
session.getCurrentSession().delete(getCategory(categoryId));
} |
cfec66e3-aa08-4b6c-9bc6-3aaec22acb55 | @Transactional
public Category getCategory(int categoryId) {
// TODO Auto-generated method stub
return (Category)session.getCurrentSession().get(Category.class, categoryId);
} |
b1a4c14c-f999-484d-9dc7-6ce2c7ca13a6 | @Transactional
public List getAllCategory() {
// TODO Auto-generated method stub
return session.getCurrentSession().createQuery("from Category").list();
} |
dc4226e2-94ca-4ac6-9da4-d9a10fdd23f5 | @Transactional
public void add(Project project) {
// TODO Auto-generated method stub
session.getCurrentSession().save(project);
} |
0bf8ddad-880d-4834-991a-bdb007e107c0 | @Transactional
public void edit(Project project) {
// TODO Auto-generated method stub
session.getCurrentSession().update(project);
} |
bb5583b3-a4e8-4dd1-8108-161c89c88e01 | @Transactional
public void delete(int projectId) {
// TODO Auto-generated method stub
session.getCurrentSession().delete(getProject(projectId));
} |
3df0be6c-c1c2-4338-a4bb-a0062cd78485 | @Transactional
public Project getProject(int projectId) {
// TODO Auto-generated method stub
return (Project)session.getCurrentSession().get(Project.class, projectId);
} |
c214913e-f153-4b4d-85dc-959ed7b0815a | @Transactional
public List getAllProject() {
// TODO Auto-generated method stub
return session.getCurrentSession().createQuery("from Project").list();
} |
42ad713e-7475-4447-ae45-c8d42354963d | @Transactional
public void add(Location location) {
// TODO Auto-generated method stub
session.getCurrentSession().save(location);
} |
1bbd5c41-fee9-4289-beda-0b3ec2478086 | @Transactional
public void edit(Location location) {
// TODO Auto-generated method stub
session.getCurrentSession().update(location);
} |
98052bbe-fccc-40c5-86f6-6a76eceba178 | @Transactional
public void delete(int locationId) {
// TODO Auto-generated method stub
session.getCurrentSession().delete(getLocation(locationId));
} |
0349fcbc-849c-466f-b04f-7da2cae50b52 | @Transactional
public Location getLocation(int locationId) {
// TODO Auto-generated method stub
return (Location)session.getCurrentSession().get(Location.class, locationId);
} |
65323346-5295-4788-b235-c0d0a29e0044 | @Transactional
public List getAllLocation() {
// TODO Auto-generated method stub
return session.getCurrentSession().createQuery("from Location").list();
} |
7902083e-f2a7-4955-9482-bc859d8be880 | @RequestMapping("/")
public String setupForm(Map<String, Object> map)
{
User user = new User();
map.put("user",user);
map.put("userList",userDao.getAllUser());
map.put("locationList", locationDao.getAllLocation());
map.put("categoryList", categoryDao.getAllCategory());
map.put("projectList", projectDao.getAllProject() );
map.put("createdProjectList", userDao.getUser(1).getCreatedProject() );
map.put("fundProjectList", projectDao.getProject(2).getFunds() );
map.put("commentProjectList", projectDao.getProject(2).getComments() );
return "user";
} |
e12b6a7c-95f6-4ae9-bbbd-92226e73d7a1 | @RequestMapping(value="/user.do", method=RequestMethod.POST)
public String doActions(@ModelAttribute User user, BindingResult result, @RequestParam String action, Map<String, Object> map) {
User userResult = new User();
switch(action.toLowerCase()) {
case "add":
userDao.add(user);
userResult = user;
break;
case "edit":
userDao.edit(user);
userResult = user;
break;
case "delete":
userDao.delete(user.getUserId());
userResult = user;
break;
case "search":
User searchedUser = userDao.getUser(user.getUserId());
userResult = searchedUser!=null ? searchedUser : new User() ;
break;
}
map.put("user",userResult);
map.put("userList",userDao.getAllUser());
return setupForm(map);
} |
0849eaff-26df-4150-9d37-58a201b3b328 | @Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
HttpServletRequest req = (HttpServletRequest) request;
HttpSession session = req.getSession();
String paginaSolicitada = req.getRequestURI();
if (session.getAttribute("logado") != null || paginaSolicitada.contains("login.xhtml") || paginaSolicitada.contains("cadastroUsuario.xhtml") ) {
chain.doFilter(request, response);
} else {
HttpServletResponse res = (HttpServletResponse) response;
res.sendRedirect(req.getContextPath()+"/login.xhtml");
}
} |
25f6dc51-fcd1-433a-be4d-0d06e3d5b011 | @Override
public void init(FilterConfig filterConfig) throws ServletException {
fc = filterConfig;
} |
cd49bb7c-4aa7-4a8c-8f99-faca05835944 | @Override
public void destroy() {
} |
dcdec0ba-ed9d-40a2-9edd-0da37d03b2fd | public Usuario buscarUsuario(Usuario usuario); |
ec6055d4-b2c0-4996-b70d-1186ff957af1 | public List<Usuario> listarUsuarios(); |
e644bb51-19f0-41a2-9be5-a8c5c18ad7e2 | public void inserir(Usuario usuario); |
a304dad9-39dd-428d-922a-0d4d1d9780e7 | public Connection getConexao() throws NamingException, SQLException{
String conexao = "jdbc/sistemaru";
DataSource ds = null;
try {
InitialContext ctx = new InitialContext();
ds = (DataSource) ctx.lookup(conexao);
} catch (NamingException ex) {
Logger.getLogger(ConexaoDAO.class.getName()).log(Level.SEVERE, null, ex);
}
return ds.getConnection();
} |
6f96a0f6-ab75-4930-9822-a1e888c0895d | public void inserir(Usuario usuario){
ConexaoDAO conexaoDAO = new ConexaoDAO();
//Estabelecendo conex�o com o banco
Connection con = null;
try{
// Criando o PreparedStatement para envio da senten�a insert SQL
con = conexaoDAO.getConexao();
PreparedStatement pstm = con.prepareStatement("INSERT INTO USUARIO(LOGIN, SENHA) VALUES(?,?)");
// Populando os parametros da sentenca SQL
pstm.setString(1, usuario.getLogin());
pstm.setString(2, usuario.getSenha());
//Executando o PreparedStatement
pstm.executeUpdate();
System.out.println("Usuario inserido com sucesso!");
}
catch(Exception e){
e.printStackTrace();
}
finally{
try {
con.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
} |
80140554-5cc5-4aea-8e09-b57e1d9da0c9 | public List<Usuario> listarUsuarios(){
ConexaoDAO conexaoDAO = new ConexaoDAO();
//Estabelecendo conex�o com o banco
ResultSet resultado = null;
List<Usuario> usuarios = null;
try{
// Criando o PreparedStatement para envio da senten�a insert SQL
Connection con = conexaoDAO.getConexao();
usuarios = new ArrayList<Usuario>();
String sqlConsulta = "SELECT * FROM USUARIO";
PreparedStatement pstm = con.prepareStatement(sqlConsulta);
resultado = pstm.executeQuery();
while(resultado.next()){
Usuario usuario = new Usuario();
usuario.setLogin(resultado.getString("LOGIN"));
usuario.setSenha(resultado.getString("SENHA"));
usuarios.add(usuario);
}
}
catch(Exception e){
e.printStackTrace();
}
finally{
}
return usuarios;
} |
75b24022-c576-49f6-a9aa-a22103f3edb3 | public Usuario buscarUsuario(Usuario usuario){
Usuario objUsuario = null;
ConexaoDAO conexaoDAO = new ConexaoDAO();
Connection con = null;
try{
String sqlConsulta= "SELECT * FROM USUARIO WHERE LOGIN = ?";
con = conexaoDAO.getConexao();
PreparedStatement pstm = con.prepareStatement(sqlConsulta);
pstm.setString(1, usuario.getLogin());
ResultSet rs = pstm.executeQuery();
if(rs.next()){
//populando o objeto
objUsuario = new Usuario();
objUsuario.setLogin(rs.getString("LOGIN"));
objUsuario.setSenha(rs.getString("SENHA"));
}
}
catch(Exception e){
e.printStackTrace();
}
finally{
try {
con.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return objUsuario;
} |
dcb29e7e-af22-4f4a-83ac-c365acf1a1c0 | public String getLogin() {
return login;
} |
8758c0ce-2be9-4204-8270-1d98b1d8b99d | public void setLogin(String login) {
this.login = login;
} |
b03d9c3a-fba1-4b50-8af3-19d7b9063bc0 | public LoginBean() {
} |
3952234c-393a-4f4f-8f59-0b20c60924c8 | public Usuario getUsuario() {
if (usuario == null) {
usuario = new Usuario();
}
return usuario;
} |
82e4b7c7-9225-473b-83e4-18d3a43bc152 | public void setUsuario(Usuario usuario) {
this.usuario = usuario;
} |
c21b4b46-6fa9-4616-b731-1d7472b9237e | public String checkLogin() throws Exception {
if (getUsuario() != null) {
Usuario usuarioRegistrado = usuarioDAO.buscarUsuario(getUsuario());
if (usuarioRegistrado != null && usuarioRegistrado.getSenha().equals(getUsuario().getSenha())) {
HttpSession session = (HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(false);
session.setAttribute("logado", true);
return "/index";
}
}
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("Login ou senha inexistente"));
return "";
} |
0a969f18-5342-460f-97a8-8b555cdb6219 | public String cadastrarUsuario() throws Exception {
List<Usuario> usuarios = usuarioDAO.listarUsuarios();
for (Usuario usuario : usuarios) {
System.out.print("teste " + usuario.getLogin() + " - " + usuario.getSenha());
}
if (getUsuario() != null) {
usuarioDAO.inserir(getUsuario());
}
return "/login";
} |
df8a9dbc-ec0d-440d-b5a8-af1f92813fa0 | public String doLogout() {
FacesContext facesContext = FacesContext.getCurrentInstance();
HttpSession httpSession = (HttpSession) facesContext.getExternalContext().getSession(false);
httpSession.invalidate();
return "/login?faces-redirect=true";
} |
9a67dffa-6c72-4aa5-975b-0bded9a7efa5 | public Usuario() {
} |
12094676-7cc0-4b03-a2b7-7a46cf7a2f6f | public String getLogin() {
return login;
} |
5852f1aa-bc2b-428b-a90e-a9a0d7950501 | public void setLogin(String login) {
this.login = login;
} |
9a1ebf78-1090-4bec-9fae-ec4fcd9ee74d | public String getSenha() {
return senha;
} |
f9e90113-7a80-4b7a-975c-4243a5f08698 | public void setSenha(String senha) {
this.senha = senha;
} |
b7fe3e3b-1a07-406e-a096-cdb9be368367 | public int getId() {
return id;
} |
75e38b93-a38e-42f9-9031-a3d580502d0f | public void setId(int id) {
this.id = id;
} |
19c39e85-3c0f-433a-ab8b-85772b43f5d5 | public String getaParty() {
return aParty;
} |
62de6a1b-eb3d-43a0-8c58-9d7168a60bb4 | public void setaParty(String aParty) {
this.aParty = aParty;
} |
64727478-c1cf-4da1-ab91-8110c7cf75c2 | public double getAmount() {
return amount;
} |
05cf482b-81ce-4a8e-af5e-781a3e009555 | public void setAmount(double amount) {
this.amount = amount;
} |
e13e1bab-cbec-4c46-8dc4-e11164cf6662 | public int getStat() {
return stat;
} |
207ddd3e-8891-4dd8-87f4-1e61de53952c | public void setStat(int stat) {
this.stat = stat;
} |
f927fe09-5611-4ff8-804f-b53cd7ffd4df | public int getChargeType() {
return chargeType;
} |
2bddb697-3818-4fb5-bb65-45bbb7dbe0a0 | public void setChargeType(int chargeType) {
this.chargeType = chargeType;
} |
a9f4c7e2-8508-4fcd-8718-0f09297ced5a | public Date getCreated() {
return created;
} |
aaa133e3-3acb-4929-acd5-500b2d5bbf3f | public void setCreated(Date created) {
this.created = created;
} |
9df421b3-5fd2-40ae-97aa-d06e43243516 | public Date getUpdated() {
return updated;
} |
2b3d21e9-c788-4aa7-b917-64996ef7ec91 | public void setUpdated(Date updated) {
this.updated = updated;
} |
c2c04a25-08df-4e4b-b429-694c6d9439ab | public int getRetryCount() {
return retryCount;
} |
634db956-ec1a-4261-9b73-640ffb6510b8 | public void setRetryCount(int retryCount) {
this.retryCount = retryCount;
} |
0a832824-41fe-4e26-9baf-66c8fa70e8c0 | public int getSubscriberType() {
return subscriberType;
} |
6f5fe9b4-ad3a-4d91-9618-1261fb61651e | public void setSubscriberType(int subscriberType) {
this.subscriberType = subscriberType;
} |
a2881635-8e27-4d02-b45d-3df8c47d3f43 | public String getReferenceId() {
return referenceId;
} |
1fbe0d2f-12de-4da2-a554-0d594e571a15 | public void setReferenceId(String referenceId) {
this.referenceId = referenceId;
} |
b96bfb81-61b5-400e-ba90-772954d11103 | public String getErrorCode() {
return errorCode;
} |
5e099b25-a51f-4e37-92fa-796b96882ce0 | public void setErrorCode(String errorCode) {
this.errorCode = errorCode;
} |
48816cc6-ee2e-499f-8e19-49b374e3574a | @Override
public String toString() {
return "RenewalEntry [id=" + id + ", aParty=" + aParty + ", amount="
+ amount + ", stat=" + stat + ", chargeType=" + chargeType
+ ", created=" + created + ", updated=" + updated
+ ", retryCount=" + retryCount + ", subscriberType="
+ subscriberType + ", referenceId=" + referenceId
+ ", errorCode=" + errorCode + "]";
} |
084f6b23-0c03-40f1-8f7c-f6c54c214baf | public String getaParty() {
return aParty;
} |
1d37e580-b6d0-42ea-bb72-dcb073a75972 | public void setaParty(String aParty) {
this.aParty = aParty;
} |
e611463d-814c-442f-8386-28609c6d34cf | public int getInActiveDays() {
return inActiveDays;
} |
0aa382d4-f8f4-4385-8337-76826efdc33b | public void setInActiveDays(int inActiveDays) {
this.inActiveDays = inActiveDays;
} |
5e74d44b-52ff-4c71-bc82-6de23f1671b5 | public String getExpiry() {
return expiry;
} |
6c405bb9-7977-4faf-9324-a615236e9eab | public void setExpiry(String expiry) {
this.expiry = expiry;
} |
af7f0671-2d0c-455e-a610-577ce7e88085 | public static int getInt(String key, int defaultValue) {
Preferences prefs = Preferences.userNodeForPackage(mim.notifier.NotifierDaemon.class);
return prefs.getInt(key, defaultValue);
} |
f4cef755-f386-43ed-9fac-3fe5649c3361 | public static void setInt(String key, int value) {
Preferences prefs = Preferences.userNodeForPackage(mim.notifier.NotifierDaemon.class);
prefs.putInt(key, value);
} |
68b99cfe-f112-45d5-9ab6-6bc1505a9509 | public static boolean getBoolean(String key, boolean defaultValue) {
Preferences prefs = Preferences.userNodeForPackage(mim.notifier.NotifierDaemon.class);
return prefs.getBoolean(key, defaultValue);
} |
1f8f2f49-45e6-4e18-b179-a6fcd87b3251 | public static void setBoolean(String key, boolean value) {
Preferences prefs = Preferences.userNodeForPackage(mim.notifier.NotifierDaemon.class);
prefs.putBoolean(key, value);
} |
154e338b-e5ea-4830-bec5-b7fb0d38b82b | public void addEntry(String msisdn) {
log.info(msisdn);
} |
e854da0f-9cb8-4156-9db3-406f1a28a136 | public static String generateReferenceId() {
//int min = 4097; // hex equivalant 1001
//int max = 65534; // hex equivalant fffe
Random r = new Random();
//int decRand = r.nextInt(max - min + 1) + min;
//String hexRand = Integer.toHexString(decRand);
DateFormat dateFormat = new SimpleDateFormat("ddMMyyHHmmss");
Calendar cal = Calendar.getInstance();
String dateStr = dateFormat.format(cal.getTime());
String refID = dateStr + r.nextInt(9999);
return refID;
} |
c0c90b4e-8958-4049-b366-68ac80686e17 | public void addEntry(String msisdn) {
log.info(msisdn);
} |
723bb2a8-34c5-42b9-8a28-bc467466aa57 | public DatabaseConnection() {
log = Logger.getLogger(getClass().getName());
} |
5ea9d8de-fb65-4fc2-baf4-92191838767f | protected abstract void readConfig(); |
1638f6ff-aa30-43e9-9b08-4d35a5a1faf3 | public Connection getConnection() {
if(!isConnected()) {
connect();
}
return connection;
} |
65bcbd20-8e1d-4c1e-91a2-fbdb37f7a56b | public boolean isConnected() {
try {
return (connection != null) && !connection.isClosed();
} catch (SQLException e) {
log.warn("DatabaseConnection: Connection check failed: " + e.getMessage(), e);
return false;
}
} |
7fafc988-cc3d-44c3-85e5-76219a19e20c | public synchronized boolean connect() {
if(!isConnected()) {
try {
readConfig();
Class.forName("com.mysql.jdbc.Driver");
String url = "jdbc:mysql://" + this.dbUrl + ":" + this.dbPort + "/" + this.dbName + "?useServerPrepStmts=false&rewriteBatchedStatements=true&user=" + this.dbUsername
+ "&password=" + this.dbPassword;
log.info("DatabaseConnection: Connecting to " + url);
connection = DriverManager.getConnection(url);
} catch (SQLException e) {
log.error("DatabaseConnection: Connection failed: " + e.getMessage(), e);
return false;
} catch (ClassNotFoundException e) {
log.error("DatabaseConnection: Driver nod found: " + e.getMessage(), e);
return false;
}
} else {
log.info("DatabaseConnection: already connected");
}
return true;
} |
65890f17-1207-419a-a13a-720e4e24a2c7 | public synchronized void close() {
if(isConnected()) {
try {
connection.close();
} catch (SQLException e) {
log.error("DatabaseConnection: Connection closure failed: " + e.getMessage(), e);
e.printStackTrace();
}
}
} |
bf8d59dc-2b58-4f64-8abb-db9fda285a7f | public ChargingHistoryDAO() {
db = HistoryDatabaseConnection.getInstance();
} |
a910fbc9-59c0-4ab5-ae42-1888de9533b6 | public void resetEligibleRenewals(String month) {
CallableStatement stmt = null;
try {
stmt = this.db.getConnection().prepareCall("{ call resetEligibleRenewals(?, ?) }");
stmt.setString("month", month);
stmt.executeUpdate();
} catch (SQLException e) {
log.error("resetEligibleRenewals failed: " + e.getMessage(), e);
} finally {
try {
if (stmt != null) stmt.close();
} catch (SQLException ex) {
log.error("failed to close db resources: " + ex.getMessage(), ex);
}
}
} |
2c097aeb-e353-4523-a171-e6f92786bdcd | public void updateBatch(List<RenewalEntry> entries, String month) {
StringBuilder sb = new StringBuilder();
//String strSqlUpdateSuccess = "UPDATE charge_process SET stat = 2 WHERE a_party IN(" + sb.substring(0, sb.length() - 1) + ")";
//String strSqlInsertSuccess = "INSERT IGNORE INTO charge_" + month + "(a_party, amount, stat, charge_type, " +
// "created, updated, retry_count, sub_type, ref_id, error_code) SELECT a_party, amount, 2, charge_type, created, NOW(), retry_count, " +
// "sub_type, ref_id, error_code FROM charge_process WHERE a_party IN(" + sb.substring(0, sb.length() - 1) + ")";
//
//String strSqlInsert = "INSERT INTO charge_" + month + "(a_party, amount, stat, charge_type, " +
// "created, updated, retry_count, sub_type, ref_id, error_code) VALUES('%s', %f, %d, %d, NOW(), NOW(), %d, %d, '%s', '%s');";
String strSqlUpdate = "UPDATE charge_process SET retry_count = %d, ref_id = '%s', updated = NOW(), error_code = '%s', stat = %d WHERE id = %d";
Statement stmt = null;
int[] rowUpdates = null;
boolean autoCommit = true;
try {
autoCommit = this.db.getConnection().getAutoCommit();
this.db.getConnection().setAutoCommit(false);
stmt = this.db.getConnection().createStatement();
long startTime = System.currentTimeMillis();
for(RenewalEntry entry : entries) {
if(entry.getStat() == 2) {
sb.append("'");
sb.append(entry.getaParty());
sb.append("',");
}
strSqlUpdate = "UPDATE charge_process SET retry_count = " + ((entry.getStat() != 2) ? entry.getRetryCount() + 1 : entry.getRetryCount()) +
", ref_id = '" + entry.getReferenceId() + "', updated = NOW(), error_code = '" + entry.getErrorCode() + "', " +
"stat = " + entry.getStat() + " WHERE id = " + entry.getId();
if(log.isDebugEnabled())
log.debug("Adding query to batch: " + strSqlUpdate);
stmt.addBatch(strSqlUpdate);
}
rowUpdates = stmt.executeBatch();
updateSuccessRenewals(month, sb.substring(0, sb.length() - 1));
this.db.getConnection().commit();
this.db.getConnection().setAutoCommit(autoCommit);
long stopTime = System.currentTimeMillis();
long elapsedTime = stopTime - startTime;
if(log.isDebugEnabled())
log.debug("Batch sql execution completed in (msec)" + elapsedTime);
} catch (SQLException e) {
log.error("getEligibleRenewal failed: " + e.getMessage(), e);
} finally {
try {
if (stmt != null) stmt.close();
} catch (SQLException ex) {
log.error("failed to close db resources: " + ex.getMessage(), ex);
}
if(rowUpdates != null && rowUpdates.length > 0)
log.info("Total records executed: " + rowUpdates[0]);
}
} |
afe05212-cbf6-4058-9d33-5cb1b9574666 | public void updateSuccessRenewals(String month, String aPartyNumbers) {
CallableStatement stmt = null;
try {
stmt = this.db.getConnection().prepareCall("{ call updateSuccessRenewals(?, ?) }");
stmt.setString("month", month);
stmt.setString("a_partyNumbers", aPartyNumbers);
int rowsAffected = stmt.executeUpdate();
log.info("updateSuccessRenewals() -> Affected rows: " + rowsAffected);
} catch (SQLException e) {
log.error("updateSuccessRenewals failed: " + e.getMessage(), e);
} finally {
try {
if (stmt != null) stmt.close();
} catch (SQLException ex) {
log.error("failed to close db resources: " + ex.getMessage(), ex);
}
}
} |
62e3dba4-18b8-40ac-987d-e6b0f35f51ab | public List<RenewalEntry> getEligibleRenewal(double chargeAmount, int chargeType) {
List<RenewalEntry> listRenewals = new ArrayList<RenewalEntry>();
CallableStatement stmt = null;
ResultSet rs = null;
RenewalEntry entry = null;
try {
stmt = this.db.getConnection().prepareCall("{ call populateAndFetchEligibleRenewals(?, ?) }");
stmt.setDouble("chargingAmount", chargeAmount);
stmt.setInt("chargeType", chargeType);
rs = stmt.executeQuery();
while(rs.next()) {
entry = new RenewalEntry();
entry.setId(rs.getInt("id"));
entry.setaParty(rs.getString("a_party"));
entry.setAmount(rs.getDouble("amount"));
entry.setStat(rs.getInt("stat"));
entry.setChargeType(rs.getInt("charge_type"));
entry.setCreated(rs.getDate("created"));
entry.setUpdated(rs.getDate("updated"));
entry.setRetryCount(rs.getInt("retry_count"));
entry.setSubscriberType(rs.getInt("sub_type"));
entry.setReferenceId(rs.getString("ref_id"));
entry.setErrorCode(rs.getString("error_code"));
listRenewals.add(entry);
}
} catch (SQLException e) {
log.error("getEligibleRenewal failed: " + e.getMessage(), e);
} finally {
try {
if(rs != null) rs.close();
if (stmt != null) stmt.close();
} catch (SQLException ex) {
log.error("failed to close db resources: " + ex.getMessage(), ex);
}
log.info("Total renewl records fetch for processing: " + listRenewals.size());
}
return listRenewals;
} |
08c98965-073b-4393-909b-aad3d75ed6d0 | public List<Subscriber> getInActiveSubscribers() {
List<Subscriber> listSubscriber = new ArrayList<Subscriber>();
CallableStatement stmt = null;
ResultSet rs = null;
Subscriber subscriber = null;
try {
stmt = this.db.getConnection().prepareCall("{ call fetchInActiveSubscribers() }");
rs = stmt.executeQuery();
while(rs.next()) {
subscriber = new Subscriber();
subscriber.setaParty(rs.getString("a_party"));
subscriber.setInActiveDays(rs.getInt("in_active_days"));
subscriber.setExpiry(rs.getString("expiry"));
listSubscriber.add(subscriber);
}
} catch (SQLException e) {
log.error("getInActiveSubscribers failed: " + e.getMessage(), e);
} finally {
try {
if(rs != null) rs.close();
if (stmt != null) stmt.close();
} catch (SQLException ex) {
log.error("failed to close db resources: " + ex.getMessage(), ex);
}
}
return listSubscriber;
} |
71b37aa5-512a-4c51-aae4-edb57bb08bf4 | public Map<String, String> getNotifyCommands() {
Map<String, String> commandsMapping = new HashMap<String, String>();
CallableStatement stmt = null;
ResultSet rs = null;
try {
stmt = this.db.getConnection().prepareCall("{ call getNotifyCommands() }");
rs = stmt.executeQuery();
while(rs.next()) {
commandsMapping.put(rs.getString("Command"), rs.getString("Xml"));
}
} catch (Exception e) {
log.error("getNotifyCommands failed: " + e.getMessage(), e);
} finally {
try {
if(rs != null) rs.close();
if (stmt != null) stmt.close();
} catch (SQLException ex) {
log.error("failed to close db resources: " + ex.getMessage(), ex);
}
}
return commandsMapping;
} |
96fbf1cb-22a3-43cb-9315-1522fd6aaaf5 | public HistoryDatabaseConnection() {
log = Logger.getLogger(getClass().getName());
} |
430a9368-cefd-49a3-85f5-27d7b56310ea | @Override
protected void readConfig() {
log.info("Initializing HistoryDatabaseConnection");
ResourceBundle myResources = ResourceBundle.getBundle("notify");
dbUsername = myResources.getString("db.history.user");
dbPassword = myResources.getString("db.history.password");
dbUrl = myResources.getString("db.history.url");
dbPort = myResources.getString("db.history.port");
dbName = myResources.getString("db.history.name");
} |
504b69f7-6644-473e-8979-5ce7401e150b | public synchronized static HistoryDatabaseConnection getInstance() {
if(instance == null) {
instance = new HistoryDatabaseConnection();
}
return instance;
} |
32b235fc-1163-4d4f-b202-fc11f656b240 | public SubscriberDatabaseConnection() {
log = Logger.getLogger(getClass().getName());
} |
076a875b-f444-4d1f-9aa3-489eb5b2d169 | @Override
protected void readConfig() {
log.info("Initializing SubscriberDatabaseConnection");
ResourceBundle myResources = ResourceBundle.getBundle("notify");
dbUsername = myResources.getString("db.mim.user");
dbPassword = myResources.getString("db.mim.password");
dbUrl = myResources.getString("db.mim.url");
dbPort = myResources.getString("db.mim.port");
dbName = myResources.getString("db.mim.name");
} |
3042e496-e706-48a3-915d-9a9598afea4a | public synchronized static SubscriberDatabaseConnection getInstance() {
if(instance == null) {
instance = new SubscriberDatabaseConnection();
}
return instance;
} |
c2fe6181-cbef-4d29-8d77-60a937892254 | public void execute(JobExecutionContext context) {
log.info("Executing NotifyInActiveSubscriberTask... ");
client = new Client();
//Map<String, String> xmlCommands = chargingDao.getNotifyCommands();
List<Subscriber> listSubscribers = chargingDao.getInActiveSubscribers();
String xmlRequest = "";
for(Subscriber s : listSubscribers) {
if(s.getInActiveDays() < 7) {
new UsersNotUsedLogger().addEntry(s.getaParty());
//xmlRequest = xmlCommands.get("NOTIFY IN ACTIVE SUBSCRIBER");
//if(xmlRequest != null) {
// xmlRequest = xmlRequest.replace("&1", s.getExpiry());
//}
} else {
new UsersNotChargedLogger().addEntry(s.getaParty());
//xmlRequest = xmlCommands.get("AUTO UNSUB");
//if(xmlRequest != null) {
// xmlRequest = xmlRequest.replace("&1", "7");
//}
}
//if(xmlRequest != null) {
//xmlRequest = xmlRequest.replace("#DestAddr#", "6060");
//xmlRequest = xmlRequest.replace("#SrcAddr#", s.getaParty());
//String refId = Util.generateReferenceId();
//xmlRequest = xmlRequest.replace("#GwMsgId#", refId);
//client.sendRequest(xmlRequest, refId);
//}
}
} |
abeb1d2b-add3-4e24-8866-c70080a59c71 | public Client() {
client = new TcpClient();
} |
7cae137a-ac8f-47de-af99-af4ea712c759 | public void sendRequest(String request, String referenceId) {
RequestResult r = client.sendRequest(provGwIP, provGwPort, 30, 30, request, referenceId);
log.debug("ProvGw response: " + r.responseString);
} |
ceec951c-1ed6-4b82-9821-a472d9d9653c | protected void readConfig() {
log.info("Initializing NotifierDaemon ...");
ResourceBundle myResources = ResourceBundle.getBundle("notify");
cycleStart = Integer.parseInt(myResources.getString("notify.start_hour"));
Client.provGwIP = myResources.getString("provgw.ip");
Client.provGwPort = Integer.parseInt(myResources.getString("provgw.port"));
} |
35164470-db89-486c-907f-3bf6b2f4093f | public void startDaemon() throws SchedulerException {
readConfig();
JobDetail jobNotify = JobBuilder.newJob(NotifyInActiveSubscriberTask.class)
.withIdentity("notifyInActive", "group1")
.build();
Trigger dailyNotifyTrigger = TriggerBuilder
.newTrigger()
.withIdentity("notifyTrigger", "group1")
.withSchedule(CronScheduleBuilder.cronSchedule("0 0 " + cycleStart + " * * ?"))
.startNow()
.build();
Scheduler scheduler = new StdSchedulerFactory().getScheduler();
scheduler.start();
scheduler.scheduleJob(jobNotify, dailyNotifyTrigger);
scheduler.triggerJob(jobNotify.getKey());
log.info("NotifierDaemon has started...");
log.info("NotifyInActiveDeamon will next execute on: " + dailyNotifyTrigger.getNextFireTime());
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.