Search in sources :

Example 1 with MInterestArea

use of org.compiere.model.MInterestArea in project adempiere by adempiere.

the class WebInfo method getInterests.

//	getAssets
/**
	 * 	Get Interest Areas
	 *	@return interest areas of BPC
	 */
public ArrayList<MInterestArea> getInterests() {
    m_infoMessage = null;
    int AD_Client_ID = Env.getAD_Client_ID(m_ctx);
    //
    ArrayList<MInterestArea> list = new ArrayList<MInterestArea>();
    String sql = "SELECT * FROM R_InterestArea " + "WHERE IsActive='Y' AND IsSelfService='Y'" + " AND AD_Client_ID=? " + "ORDER BY Name";
    PreparedStatement pstmt = null;
    ResultSet rs = null;
    try {
        pstmt = DB.prepareStatement(sql, null);
        pstmt.setInt(1, AD_Client_ID);
        rs = pstmt.executeQuery();
        while (rs.next()) {
            MInterestArea ia = new MInterestArea(m_ctx, rs, null);
            ia.setSubscriptionInfo(getAD_User_ID());
            list.add(ia);
        }
    } catch (Exception e) {
        log.log(Level.SEVERE, sql, e);
    } finally {
        DB.close(rs, pstmt);
        rs = null;
        pstmt = null;
    }
    log.fine("#" + list.size());
    return list;
}
Also used : MInterestArea(org.compiere.model.MInterestArea) ArrayList(java.util.ArrayList) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement)

Example 2 with MInterestArea

use of org.compiere.model.MInterestArea in project adempiere by adempiere.

the class InfoServlet method processParameter.

//  doPost
/**************************************************************************
	 * 	Process Parameter and check them
	 * 	@param request request
	 *	@return true if processed
	 */
private boolean processParameter(HttpServletRequest request) {
    HttpSession session = request.getSession(true);
    session.removeAttribute(WebSessionCtx.HDR_MESSAGE);
    Properties ctx = JSPEnv.getCtx(request);
    //	mode = subscribe
    String mode = WebUtil.getParameter(request, "mode");
    if (mode == null)
        return false;
    boolean subscribe = !mode.startsWith("un");
    //	area = 101
    int R_InterestArea_ID = WebUtil.getParameterAsInt(request, "area");
    MInterestArea ia = MInterestArea.get(ctx, R_InterestArea_ID);
    //	contact = -1
    int AD_User_ID = WebUtil.getParameterAsInt(request, "contact");
    //
    log.fine("Subscribe=" + subscribe + ",R_InterestArea_ID=" + R_InterestArea_ID + ",AD_User_ID=" + AD_User_ID);
    if (R_InterestArea_ID == 0 || AD_User_ID == 0)
        return false;
    //
    MContactInterest ci = MContactInterest.get(ctx, R_InterestArea_ID, AD_User_ID, false, null);
    ci.subscribe(subscribe);
    boolean ok = ci.save();
    if (ok)
        log.fine("success");
    else
        log.log(Level.SEVERE, "subscribe failed");
    //	Lookup user if direct link
    WebUser wu = (WebUser) session.getAttribute(WebUser.NAME);
    if (wu == null) {
        wu = WebUser.get(ctx, AD_User_ID);
        session.setAttribute(WebUser.NAME, wu);
    }
    sendEMail(request, wu, ia.getName(), subscribe);
    return ok;
}
Also used : MContactInterest(org.compiere.model.MContactInterest) MInterestArea(org.compiere.model.MInterestArea) HttpSession(javax.servlet.http.HttpSession) WebUser(org.compiere.util.WebUser) Properties(java.util.Properties)

Aggregations

MInterestArea (org.compiere.model.MInterestArea)2 PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1 ArrayList (java.util.ArrayList)1 Properties (java.util.Properties)1 HttpSession (javax.servlet.http.HttpSession)1 MContactInterest (org.compiere.model.MContactInterest)1 WebUser (org.compiere.util.WebUser)1