Package com.knowgate.addrbook

Examples of com.knowgate.addrbook.Fellow


    return iPct;
  }

  public boolean load (JDCConnection oConn, String sWorkArea, String sId) throws SQLException {
    ACLUser  oUser = new ACLUser();
    Fellow   oFellw = new Fellow();
    Contact  oCont = new Contact();
    Company  oComp = new Company();
    Supplier oSupl = new Supplier();
    boolean bFound;
   
  PreparedStatement oStmt = oConn.prepareStatement("SELECT "+DB.pg_lookup+" FROM "+DB.k_duties_lookup+" WHERE "+DB.gu_owner+"=? AND "+DB.id_section+"='nm_resource' AND "+DB.vl_lookup+"=?",
                                                   ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
  oStmt.setString(1, sWorkArea);
  oStmt.setString(2, sId);
  ResultSet oRSet = oStmt.executeQuery();
  bFound = oRSet.next();
  if (bFound) iPg = oRSet.getInt(1);
  oRSet.close();
  oStmt.close();

  if (bFound) {
      sVl = sId;

      if (oFellw.load(oConn, sId)) {
      sFullName = (oFellw.getStringNull(DB.tx_name,"")+" "+oFellw.getStringNull(DB.tx_surname,"")).trim();
      sEmail = oUser.getStringNull(DB.tx_email,"");
      sPhone = oUser.getStringNull(DB.work_phone,"");
      } else if (oUser.load(oConn, sId)) {
      sFullName = (oUser.getStringNull(DB.nm_user,"")+" "+oUser.getStringNull(DB.tx_surname1,"")+" "+oUser.getStringNull(DB.tx_surname2,"")).trim();
      sEmail = oUser.getStringNull(DB.tx_main_email,"");
View Full Code Here


    throws java.io.IOException, ServletException
    {
    boolean bFound;
    Class oDriver;
    Connection oConn = null;
    Fellow oFlw = new Fellow();
    String sPKFld, sPKVal, vCard, sNick = null;

     if (DebugFile.trace) {
       DebugFile.writeln("Begin HttpVCardServlet.doGet");
       DebugFile.incIdent();
     }

    try {
      oDriver = Class.forName(jdbcDriverClassName);
    }
    catch (ClassNotFoundException ignore) {
      oDriver = null;
      if (DebugFile.trace) DebugFile.writeln("Class.forName(" + jdbcDriverClassName + ") : " + ignore.getMessage());
      response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Database driver not found");
    }

    if (null==oDriver) return;

    ServletOutputStream oOut = response.getOutputStream();

    try {
      if (DebugFile.trace) DebugFile.writeln("DriverManager.getConnection(" + jdbcURL + ",...)");

      oConn = DriverManager.getConnection(jdbcURL,dbUserName,dbUserPassword);

      sPKFld = (request.getParameter("pk_field")!=null ? request.getParameter("pk_field") : "null");
      sPKVal = (request.getParameter("pk_value")!=null ? request.getParameter("pk_value") : "null");

      if (DebugFile.trace) DebugFile.writeln("pk_field = " + sPKFld);

      if (sPKFld.equalsIgnoreCase("gu_fellow")) {
        bFound = oFlw.load(oConn, new Object[]{sPKVal});

        if (!oFlw.isNull("tx_nickname"))
          sNick = oFlw.getString("tx_nickname");
        else
          sNick = sPKVal;
      }
      else
        bFound = false;

      if (bFound) {

        if (DebugFile.trace) {
          DebugFile.writeln("response.setContentType(\"application/directory\")");
          DebugFile.writeln("response.setHeader(\"Content-Disposition\", \"attachment; filename=\"" + sNick + ".vcf\"");
        }

        // Send some basic http headers to support binary d/l.
        response.setContentType("application/directory");
        response.setHeader("Content-Disposition", "attachment; filename=\"" + sNick + ".vcf\"");

        oOut.print(oFlw.vCard(oConn));

        oOut.flush();
      } // fi (bFound)

      if (!bFound) {
View Full Code Here

                        oBuf.append("<privacy>0</privacy>");
                      else
                        oBuf.append("<privacy>"+String.valueOf(oMeet.getShort(DB.bo_private))+"</privacy>");
                      oBuf.append("<title>"+oMeet.getStringNull(DB.tx_meeting,"")+"</title>");
                      oBuf.append("<description>"+oMeet.getStringNull(DB.de_meeting,"")+"</description>");             
            Fellow oOrg = new Fellow(oCon, oMeet.getString(DB.gu_fellow));
                      oBuf.append("<organizer>");
                      oBuf.append("<id>"+oOrg.getStringNull(DB.id_ref,"")+"</id>");
                      oBuf.append("<gu>"+oOrg.getString(DB.gu_fellow)+"</gu>");
                      oBuf.append("<name>"+oOrg.getStringNull(DB.tx_name,"")+"</name>");
                      oBuf.append("<surname>"+oOrg.getStringNull(DB.tx_surname,"")+"</surname>");
                      oBuf.append("<email>"+oOrg.getStringNull(DB.tx_email,"")+"</email>");
                      oBuf.append("<timezone>"+oOrg.getStringNull(DB.tx_timezone,"")+"</timezone>");
                      oBuf.append("</organizer>");
                DBSubset oRomm = new DBSubset(DB.k_rooms+" r,"+DB.k_x_meeting_room+" m","r."+DB.tp_room+",r."+DB.nm_room+",r."+DB.tx_comments,
                                "r."+DB.gu_workarea+"=? AND m."+DB.gu_meeting+"=? AND r."+DB.nm_room+"=m."+DB.nm_room, 10);
              int nRomm = oRomm.load(oCon, new Object[]{sWrkA, oMeet.getString(DB.gu_meeting)});
                      oBuf.append("<rooms count=\""+String.valueOf(nRomm)+"\">");
                      for (int r=0; r<nRomm; r++) {
                        oBuf.append("<room type=\""+oRomm.getStringNull(0,r,"")+"\"><name>"+oRomm.getStringNull(1,r,"")+"</name><comments>"+oRomm.getStringNull(2,r,"")+"</comments></room>");
                      } // next
                      oBuf.append("</rooms>");
                      DBSubset oFlws = new DBSubset(DB.k_fellows +" f,"+DB.k_x_meeting_fellow +" x",
                                          "f." + DB.gu_fellow + ",f." + DB.id_ref + ",f." + DB.tx_name + ",f." + DB.tx_surname + ",f." + DB.tx_email + ",f." + DB.tx_timezone,
                                      "f."+DB.tx_email+" IS NOT NULL AND f."+DB.gu_fellow+"=x."+DB.gu_fellow+" AND x."+DB.gu_meeting+"=?", 10);
                      DBSubset oCnts = new DBSubset(DB.k_member_address+" c,"+DB.k_x_meeting_contact+" x",
                                          "c." + DB.gu_contact + ",c." + DB.id_ref + ",c." + DB.tx_name + ",c." + DB.tx_surname + ",c." + DB.tx_email + ",'+00:00' AS " + DB.tx_timezone,
                                      "c."+DB.tx_email+" IS NOT NULL AND c."+DB.gu_contact+"=x."+DB.gu_contact+" AND x."+DB.gu_meeting+"=?", 10);
                      oFlws.load(oCon, new Object[]{oMeet.getString(DB.gu_meeting)});
                      oCnts.load(oCon, new Object[]{oMeet.getString(DB.gu_meeting)});
                      oFlws.union(oCnts);
                      oBuf.append("<attendants count=\""+String.valueOf(oFlws.getRowCount())+"\">");
                      for (int f=0; f<oFlws.getRowCount(); f++) {
                        oBuf.append("<attendant>");
                        oBuf.append("<id>"+oFlws.getStringNull(1,f,"")+"</id>");
                        oBuf.append("<gu>"+oFlws.getString(0,f)+"</gu>");
                        oBuf.append("<name>"+oFlws.getStringNull(2,f,"")+"</name>");
                        oBuf.append("<surname>"+oFlws.getStringNull(3,f,"")+"</surname>");
                        oBuf.append("<email>"+oFlws.getStringNull(4,f,"")+"</email>");
                        oBuf.append("<timezone>"+oFlws.getStringNull(5,f,"")+"</timezone>");
                        oBuf.append("</attendant>");
                      }
                      oBuf.append("</attendants>");
            oBuf.append("</meeting></meetings></calendarresponse>");
          } else {
                      oBuf.append("<calendarresponse command=\"getMeeting\" code=\"0\"><error></error><value>false</value><meetings/></calendarresponse>");
          }
                  oRst.close();
                  oStm.close();
                  oCon.close("HttpCalendarServlet.getmeeting");
                response.setContentType("text/xml");
                response.setCharacterEncoding("UTF-8");
                response.getWriter().print(oBuf.toString());
            } catch (SQLException sqle) {
                  try { if (oCon!=null) if (!oCon.isClosed()) oCon.close("HttpCalendarServlet.getmeeting"); } catch (Exception ignore) { }
                  response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, sqle.getMessage());
            return;
                }
          }
        } else if (sCmd.equalsIgnoreCase("storeMeeting")) {
          if (null==sMeet) {
                response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Parameter meeting is required");
          } else if (null==request.getParameter("title")) {
                response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Parameter title is required");
          } else {
            String[] aRooms = null;
          String sRooms = request.getParameter("rooms");
          if (sRooms!=null) if (sRooms.length()>0) aRooms = Gadgets.split(sRooms,',');
            try {
              oCon = oDbb.getConnection("HttpCalendarServlet.storemeeting",false);
          if (null!=aRooms) {
            boolean bExists;
            short iAvailable = 0;
            PreparedStatement oAct = oCon.prepareStatement("SELECT "+DB.bo_available+" FROM "+DB.k_rooms+" WHERE "+DB.gu_workarea+"=? AND "+DB.nm_room+"=?");
            for (int v=0; v<aRooms.length; v++) {
              oAct.setString (1,sWrkA);
              oAct.setString (2, aRooms[v]);
              ResultSet oRct = oAct.executeQuery();
              bExists = oRct.next();
              if (bExists) iAvailable = oRct.getShort(1);
              oRct.close();
              if (!bExists) {
                      oAct.close();
                      oCon.close("HttpCalendarServlet.storemeeting");
                        oBuf.append("<calendarresponse command=\"storeMeeting\" code=\"-100\"><error>Room "+aRooms[v]+" was not found at WorkArea "+sWrkA+"</error><value>false</value><meetings count=\"0\"></meetings></calendarresponse>");
                    response.setContentType("text/xml");
                    response.setCharacterEncoding("UTF-8");
                    response.getWriter().print(oBuf.toString());
                return;
              } else if (0==iAvailable) {
                      oAct.close();
                      oCon.close("HttpCalendarServlet.storemeeting");
                        oBuf.append("<calendarresponse command=\"storeMeeting\" code=\"-101\"><error>Room "+aRooms[v]+" is not available for booking</error><value>false</value><meetings count=\"0\"></meetings></calendarresponse>");
                    response.setContentType("text/xml");
                    response.setCharacterEncoding("UTF-8");
                    response.getWriter().print(oBuf.toString());
                return;
              }
            } // next
            oAct.close();
          } // fi
          oCon.setAutoCommit(false);
          Meeting oMeet = new Meeting();
          PreparedStatement oStm = oCon.prepareStatement("SELECT "+DB.gu_meeting+" FROM "+DB.k_meetings+" WHERE "+DB.gu_workarea+"=? AND ("+DB.gu_meeting+"=? OR "+DB.id_icalendar+"=?)", ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
          oStm.setString(1, sWrkA);
          oStm.setString(2, sMeet);
          oStm.setString(3, sMeet);
          ResultSet oRst = oStm.executeQuery();         
          if (oRst.next()) {
            oMeet.load(oCon, oRst.getString(1));
                    oRst.close();
                    oStm.close();
                      if (null!=sDtStart) oMeet.replace(DB.dt_start, oFmt.parse(sDtStart));
                      if (null!=sDtEnd) oMeet.replace(DB.dt_end, oFmt.parse(sDtEnd));           
            if (null!=sDtStart && null!=sDtEnd)
              if (oFmt.parse(sDtStart).getTime()>oFmt.parse(sDtEnd).getTime())
                throw new IllegalArgumentException("Start date must be prior to end date");
            if (null!=request.getParameter("type"))
              oMeet.replace(DB.tp_meeting, request.getParameter("type"));
            if (null!=request.getParameter("privacy"))
              oMeet.replace(DB.bo_private, Short.parseShort(request.getParameter("privacy")));
            oMeet.replace(DB.tx_meeting, Gadgets.left(request.getParameter("title"),100));
            if (null!=request.getParameter("description"))
              oMeet.replace(DB.de_meeting, Gadgets.left(request.getParameter("description"),1000));           
            oMeet.store(oCon);
          } else {
                    oRst.close();
                    oStm.close();
                    oMeet.put(DB.gu_meeting, Gadgets.generateUUID());
                    oMeet.put(DB.id_icalendar, sMeet);
                    oMeet.put(DB.id_domain, DBCommand.queryInt(oCon, "SELECT "+DB.id_domain+" FROM "+DB.k_workareas+" WHERE "+DB.gu_workarea+"='"+sWrkA+"'"));
                    oMeet.put(DB.gu_workarea, sWrkA);
                    oMeet.put(DB.gu_fellow, sUid);
                    oMeet.put(DB.gu_writer, sUid);
                      oMeet.put(DB.dt_start, oFmt.parse(sDtStart));
                      oMeet.put(DB.dt_end, oFmt.parse(sDtEnd));
            if (null!=request.getParameter("type"))
              oMeet.put(DB.tp_meeting, request.getParameter("type"));
            if (null!=request.getParameter("privacy"))
              oMeet.put(DB.bo_private, Short.parseShort(request.getParameter("privacy")));
            oMeet.put(DB.tx_meeting, Gadgets.left(request.getParameter("title"),100));
            if (null!=request.getParameter("description"))
              oMeet.put(DB.de_meeting, Gadgets.left(request.getParameter("description"),1000));
            oMeet.store(oCon);
          }

          oMeet.clearRooms(oCon);
          if (aRooms!=null) {
            PreparedStatement oPrm = oCon.prepareStatement("INSERT INTO "+DB.k_x_meeting_room+" ("+DB.gu_meeting+","+DB.nm_room+","+DB.dt_start+","+DB.dt_end+") VALUES (?,?,?,?)");
            for (int a=0; a<aRooms.length; a++) {
              oPrm.setString(1, oMeet.getString(DB.gu_meeting));
              oPrm.setString(2, aRooms[a]);
              oPrm.setTimestamp(3, new Timestamp(oMeet.getDate(DB.dt_start).getTime()));
              oPrm.setTimestamp(4, new Timestamp(oMeet.getDate(DB.dt_end).getTime()));
              oPrm.executeUpdate();
            } // next
            oPrm.close();
          } // fi

          oMeet.clearAttendants(oCon);
          boolean bSelf = false;
          String sAttendants = request.getParameter("attendants");
          if (sAttendants!=null) {
            if (sAttendants.length()>0) {
              String sGuFellow;
              String[] aAttendants = Gadgets.split(sAttendants,',');
              PreparedStatement oAtd = oCon.prepareStatement("SELECT * FROM "+DB.k_fellows+" WHERE "+DB.gu_workarea+"=? AND ("+DB.gu_fellow+"=? OR "+DB.tx_email+"=?)");
              for (int a=0; a<aAttendants.length; a++) {
                oAtd.setString(1, oMeet.getString(DB.gu_workarea));
                oAtd.setString(2, aAttendants[a]);
                oAtd.setString(3, aAttendants[a]);
                ResultSet oRtd = oAtd.executeQuery();
                if (oRtd.next())
                  sGuFellow = oRtd.getString(1);
                else
                  sGuFellow = null;
                oRtd.close();
                if (sGuFellow!=null) oMeet.addAttendant(oCon, sGuFellow);
              bSelf = sUid.equals(sGuFellow);
              } // next
              if (!bSelf) oMeet.addAttendant(oCon, sUid);             
              oAtd.close();
            } // fi
          } // fi
         
          oCon.commit();

                    oBuf.append("<calendarresponse command=\"storeMeeting\" code=\"0\"><error></error><value>true</value><meetings count=\"1\"><meeting type=\""+oMeet.getStringNull(DB.tp_meeting,"")+"\">");
                    oBuf.append("<id>"+oMeet.getStringNull(DB.id_icalendar,"")+"</id>");
                    oBuf.append("<gu>"+oMeet.getString(DB.gu_meeting)+"</gu>");
                    oBuf.append("<startdate>"+oXmt.format(oMeet.getDate(DB.dt_start)).replace(' ','T')+"</startdate>");
                    oBuf.append("<enddate>"+oXmt.format(oMeet.getDate(DB.dt_end)).replace(' ','T')+"</enddate>");
                    if (oMeet.isNull(DB.bo_private))
                      oBuf.append("<privacy>0</privacy>");
                    else
                      oBuf.append("<privacy>"+String.valueOf(oMeet.getShort(DB.bo_private))+"</privacy>");
                    oBuf.append("<title>"+oMeet.getStringNull(DB.tx_meeting,"")+"</title>");
                    oBuf.append("<description>"+oMeet.getStringNull(DB.de_meeting,"")+"</description>");
          Fellow oOrg = new Fellow(oCon, oMeet.getString(DB.gu_fellow));
                    oBuf.append("<organizer>");
                    oBuf.append("<id>"+oOrg.getStringNull(DB.id_ref,"")+"</id>");
                    oBuf.append("<gu>"+oOrg.getString(DB.gu_fellow)+"</gu>");
                    oBuf.append("<name>"+oOrg.getStringNull(DB.tx_name,"")+"</name>");
                    oBuf.append("<surname>"+oOrg.getStringNull(DB.tx_surname,"")+"</surname>");
                    oBuf.append("<email>"+oOrg.getStringNull(DB.tx_email,"")+"</email>");
                    oBuf.append("<timezone>"+oOrg.getStringNull(DB.tx_timezone,"")+"</timezone>");
                    oBuf.append("</organizer>");
              DBSubset oRomm = new DBSubset(DB.k_rooms+" r,"+DB.k_x_meeting_room+" m","r."+DB.tp_room+",r."+DB.nm_room+",r."+DB.tx_comments,
                                "r."+DB.gu_workarea+"=? AND m."+DB.gu_meeting+"=? AND r."+DB.nm_room+"=m."+DB.nm_room, 10);
            int nRomm = oRomm.load(oCon, new Object[]{sWrkA, oMeet.getString(DB.gu_meeting)});
                    oBuf.append("<rooms count=\""+String.valueOf(nRomm)+"\">");                 
View Full Code Here

TOP

Related Classes of com.knowgate.addrbook.Fellow

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.