Author: solomax
Date: Mon Jun 25 06:51:25 2012
New Revision: 1353401

URL: http://svn.apache.org/viewvc?rev=1353401&view=rev
Log:
OPENMEETINGS-333 is fixed

Modified:
    
incubator/openmeetings/trunk/singlewebapp/WebContent/src/modules/lzcalendar/compontents/lzViewCalendarEvent.lzx
    
incubator/openmeetings/trunk/singlewebapp/src/org/openmeetings/app/data/calendar/beans/AppointmentDTO.java
    
incubator/openmeetings/trunk/singlewebapp/src/org/openmeetings/app/data/calendar/daos/AppointmentDaoImpl.java
    
incubator/openmeetings/trunk/singlewebapp/src/org/openmeetings/app/persistence/beans/calendar/Appointment.java

Modified: 
incubator/openmeetings/trunk/singlewebapp/WebContent/src/modules/lzcalendar/compontents/lzViewCalendarEvent.lzx
URL: 
http://svn.apache.org/viewvc/incubator/openmeetings/trunk/singlewebapp/WebContent/src/modules/lzcalendar/compontents/lzViewCalendarEvent.lzx?rev=1353401&r1=1353400&r2=1353401&view=diff
==============================================================================
--- 
incubator/openmeetings/trunk/singlewebapp/WebContent/src/modules/lzcalendar/compontents/lzViewCalendarEvent.lzx
 (original)
+++ 
incubator/openmeetings/trunk/singlewebapp/WebContent/src/modules/lzcalendar/compontents/lzViewCalendarEvent.lzx
 Mon Jun 25 06:51:25 2012
@@ -54,6 +54,13 @@
                this.eventDS.setAttribute("data", this.dataElement.childNodes);
                
                this.appointmentId = 
this.eventDS.getPointer().xpathQuery('appointmentId/text()');
+               
+                   if ($debug) Debug.write("organizerId ", 
this.eventDS.getPointer().xpathQuery('organizerId/text()'));
+                   if ($debug) Debug.write("currentUser: ", canvas.user_id);
+               if (canvas.user_id != 
Number(this.eventDS.getPointer().xpathQuery('organizerId/text()'))) {
+                       this._content.deleteBtn.setAttribute('visible', false); 
+                       this._content.editBtn.setAttribute('visible', false); 
+               }
                    
                    if ($debug) Debug.write("this.eventDS ",this.eventDS);
                    if ($debug) Debug.write("this.appointmentId 
",this.appointmentId);
@@ -162,7 +169,7 @@
                        </handler>
                </simpleLabelButton>
                        
-                       <simpleLabelButton labelid="814" width="100" x="5" 
y="$once{ parent.height-24 }" >
+                       <simpleLabelButton name="deleteBtn" labelid="814" 
width="100" x="5" y="$once{ parent.height-24 }" >
                        <handler name="onclick">
                                //check if event is from other user
                                new lz.confirmationSingle(parent.parent,{
@@ -182,7 +189,7 @@
                        </method>
                </simpleLabelButton>
                
-                   <simpleLabelButton labelid="1446" width="110" x="$once{ 
parent.width-115 }" 
+                   <simpleLabelButton name="editBtn" labelid="1446" 
width="110" x="$once{ parent.width-115 }" 
                           y="$once{ parent.height-24 }" 
                           onclick="this.parent.close();">
                        <handler name="onclick">

Modified: 
incubator/openmeetings/trunk/singlewebapp/src/org/openmeetings/app/data/calendar/beans/AppointmentDTO.java
URL: 
http://svn.apache.org/viewvc/incubator/openmeetings/trunk/singlewebapp/src/org/openmeetings/app/data/calendar/beans/AppointmentDTO.java?rev=1353401&r1=1353400&r2=1353401&view=diff
==============================================================================
--- 
incubator/openmeetings/trunk/singlewebapp/src/org/openmeetings/app/data/calendar/beans/AppointmentDTO.java
 (original)
+++ 
incubator/openmeetings/trunk/singlewebapp/src/org/openmeetings/app/data/calendar/beans/AppointmentDTO.java
 Mon Jun 25 06:51:25 2012
@@ -40,6 +40,7 @@ public class AppointmentDTO {
        private Calendar end;
        private Boolean isPasswordProtected;
        private List<MeetingMemberDTO> meetingMember = new 
ArrayList<MeetingMemberDTO>();
+       private Long organizerId;
 
        public AppointmentDTO(Appointment appointment, TimeZone timezone) {
                appointmentId = appointment.getAppointmentId();
@@ -58,6 +59,7 @@ public class AppointmentDTO {
                start = appointment.appointmentStartAsCalendar(timezone);
                end = appointment.appointmentEndAsCalendar(timezone);
                isPasswordProtected = appointment.getIsPasswordProtected();
+               organizerId = appointment.getUserId().getUser_id();
                for (MeetingMember meetingMemberItem : 
appointment.getMeetingMember()) {
                        meetingMember.add(new 
MeetingMemberDTO(meetingMemberItem));
                }
@@ -159,4 +161,12 @@ public class AppointmentDTO {
                this.roomTypeId = roomTypeId;
        }
 
+       public Long getOrganizerId() {
+               return organizerId;
+       }
+
+       public void setOrganizerId(Long organizerId) {
+               this.organizerId = organizerId;
+       }
+
 }

Modified: 
incubator/openmeetings/trunk/singlewebapp/src/org/openmeetings/app/data/calendar/daos/AppointmentDaoImpl.java
URL: 
http://svn.apache.org/viewvc/incubator/openmeetings/trunk/singlewebapp/src/org/openmeetings/app/data/calendar/daos/AppointmentDaoImpl.java?rev=1353401&r1=1353400&r2=1353401&view=diff
==============================================================================
--- 
incubator/openmeetings/trunk/singlewebapp/src/org/openmeetings/app/data/calendar/daos/AppointmentDaoImpl.java
 (original)
+++ 
incubator/openmeetings/trunk/singlewebapp/src/org/openmeetings/app/data/calendar/daos/AppointmentDaoImpl.java
 Mon Jun 25 06:51:25 2012
@@ -19,6 +19,7 @@
 package org.openmeetings.app.data.calendar.daos;
 
 import java.sql.Timestamp;
+import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.Date;
 import java.util.List;
@@ -719,29 +720,22 @@ public class AppointmentDaoImpl {
                        
                        log.debug("Start " + calstart.getTime() + " End " + 
calend.getTime());
 
-                       String hql = "select a from Appointment a "
-                                       + "WHERE a.deleted <> :deleted  "
-                                       + "AND "
-                                       + "( "
-                                       + "(a.appointmentStarttime BETWEEN 
:starttime AND :endtime) "
-                                       + "OR "
-                                       + "(a.appointmentEndtime BETWEEN 
:starttime AND :endtime) "
-                                       + "OR "
-                                       + "(a.appointmentStarttime < :starttime 
AND a.appointmentEndtime > :endtime) "
-                                       + ") " + "AND " + "( " + 
"a.userId.user_id = :userId "
-                                       + ")";
-
-                       // "AND (a.terminstatus != 4 AND a.terminstatus != 5)";
-
-                       TypedQuery<Appointment> query = em.createQuery(hql,
-                                       Appointment.class);
+                       TypedQuery<Appointment> query = 
em.createNamedQuery("appointmentsInRange", Appointment.class);
                        query.setParameter("deleted", "true");
                        query.setParameter("starttime", calstart.getTime());
                        query.setParameter("endtime", calend.getTime());
                        query.setParameter("userId", userId);
-
-                       List<Appointment> listAppoints = query.getResultList();
-
+                       
+                       List<Appointment> listAppoints = new 
ArrayList<Appointment>(query.getResultList()); 
+                       TypedQuery<Appointment> q1 = 
em.createNamedQuery("joinedAppointmentsInRange", Appointment.class);
+                       q1.setParameter("starttime", calstart.getTime());
+                       q1.setParameter("endtime", calend.getTime());
+                       q1.setParameter("userId", userId);
+                       for (Appointment a : q1.getResultList()) {
+                               a.setIsConnectedEvent(true); //TODO need to be 
reviewed
+                               listAppoints.add(a);
+                       }
+                       
                        for (Appointment appointment : listAppoints) {
                                log.debug("" + appointment);
 

Modified: 
incubator/openmeetings/trunk/singlewebapp/src/org/openmeetings/app/persistence/beans/calendar/Appointment.java
URL: 
http://svn.apache.org/viewvc/incubator/openmeetings/trunk/singlewebapp/src/org/openmeetings/app/persistence/beans/calendar/Appointment.java?rev=1353401&r1=1353400&r2=1353401&view=diff
==============================================================================
--- 
incubator/openmeetings/trunk/singlewebapp/src/org/openmeetings/app/persistence/beans/calendar/Appointment.java
 (original)
+++ 
incubator/openmeetings/trunk/singlewebapp/src/org/openmeetings/app/persistence/beans/calendar/Appointment.java
 Mon Jun 25 06:51:25 2012
@@ -33,6 +33,8 @@ import javax.persistence.Id;
 import javax.persistence.JoinColumn;
 import javax.persistence.Lob;
 import javax.persistence.ManyToOne;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
 import javax.persistence.Table;
 import javax.persistence.Transient;
 
@@ -41,6 +43,29 @@ import org.openmeetings.app.persistence.
 
 @Entity
 @Table(name = "appointments")
+@NamedQueries({
+    @NamedQuery(name="appointmentsInRange",
+               query="SELECT a FROM Appointment a "
+                       + "WHERE a.deleted <> :deleted "
+                       + "     AND ( "
+                       + "             (a.appointmentStarttime BETWEEN 
:starttime AND :endtime) "
+                       + "             OR (a.appointmentEndtime BETWEEN 
:starttime AND :endtime) "
+                       + "             OR (a.appointmentStarttime < :starttime 
AND a.appointmentEndtime > :endtime) "
+                       + "     )"
+                       + "     AND a.userId.user_id = :userId"
+       )
+    , @NamedQuery(name="joinedAppointmentsInRange",
+       query="SELECT a FROM MeetingMember mm, IN(mm.appointment) a "
+                       + "WHERE mm.deleted <> true AND mm.invitor <> true AND 
mm.userid.user_id = :userId "
+                       + "     AND a.appointmentId NOT IN (SELECT 
a.appointmentId FROM Appointment a WHERE a.userId.user_id = :userId)"
+                       + "     AND mm.isConnectedEvent <> true " //TODO 
review: isConnectedEvent is set for the MeetingMember if event is created from 
"Private Messages", it is weird
+                       + "     AND ( "
+                       + "             (a.appointmentStarttime BETWEEN 
:starttime AND :endtime) "
+                       + "             OR (a.appointmentEndtime BETWEEN 
:starttime AND :endtime) "
+                       + "             OR (a.appointmentStarttime < :starttime 
AND a.appointmentEndtime > :endtime) "
+                       + "     )"
+       )
+})
 public class Appointment implements Serializable {
 
        private static final long serialVersionUID = 2016808778885761525L;


Reply via email to