Skip to content

Commit

Permalink
SAK-26331 Matthew B patch adding comments around loop
Browse files Browse the repository at this point in the history
git-svn-id: https://source.sakaiproject.org/svn/calendar/trunk@311243 66ffb92e-73f9-0310-93c1-f5514f145a0a
  • Loading branch information
ottenhoff committed Jul 29, 2014
1 parent 939d2be commit 765147f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,7 @@ public CalendarEvent addEvent(TimeRange range, String displayName,
{
// allocate a new unique event id
// String id = getUniqueId();
String id = getUniqueIdBasedOnFields(displayName, description, type, location);
String id = getUniqueIdBasedOnFields(displayName, description, type, location, m_id);

// create event
ExternalCalendarEvent edit = new ExternalCalendarEvent(m_context, m_id, id);
Expand Down Expand Up @@ -1044,10 +1044,15 @@ protected String getUniqueId()
}

protected String getUniqueIdBasedOnFields(String displayName, String description,
String type, String location)
String type, String location, String calendarId)
{
StringBuffer key = new StringBuffer();
key.append(displayName + description + type + location);
StringBuilder key = new StringBuilder();
key.append(displayName);
key.append(description);
key.append(type);
key.append(location);
key.append(calendarId);

String id = null;
int n = 0;
boolean unique = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3305,8 +3305,8 @@ protected void buildMonthContext(VelocityPortlet portlet,

protected Vector getNewEvents(int year, int month, int day, CalendarActionState state, RunData rundata, int time, int numberofcycles,Context context,CalendarEventVector CalendarEventVectorObj)
{
boolean firstTime = true;
Vector events = new Vector();
boolean firstTime = true; // Don't need to do complex checking the first time.
Vector events = new Vector(); // A vector of vectors, each of the vectors containing a range of previous events.

Time timeObj = TimeService.newTimeLocal(year,month,day,time,00,00,000);

Expand All @@ -3322,25 +3322,25 @@ protected Vector getNewEvents(int year, int month, int day, CalendarActionState

calEvent = CalendarEventVectorObj.getEvents(timeRangeObj);

Vector vectorObj = new Vector();
Vector vectorObj = new Vector(); // EventDisplay of calevent.
EventDisplayClass eventDisplayObj;
Vector newVectorObj = null;
Vector newVectorObj = null; // Ones we haven't see before?
boolean swapflag=true;
EventDisplayClass eventdisplayobj = null;

if (calEvent.hasNext())
if (calEvent.hasNext()) // While we still have more events in this range.
{
int i = 0;
int i = 0; // Size of vectorObj
while (calEvent.hasNext())
{
eventdisplayobj = new EventDisplayClass();
eventdisplayobj.setEvent((CalendarEvent)calEvent.next(),false,i);

vectorObj.add(i,eventdisplayobj);
vectorObj.add(i,eventdisplayobj); // Copy into vector, wrapping in EventDisplay
i++;
} // while

if(firstTime)
if(firstTime) // First range
{
events.add(range,vectorObj);
firstTime = false;
Expand All @@ -3350,44 +3350,45 @@ protected Vector getNewEvents(int year, int month, int day, CalendarActionState
while(swapflag == true)
{
swapflag=false;
for(int mm = 0; mm<events.size();mm++)
for(int mm = 0; mm<events.size();mm++) // Loop through all the previous ranges.
{
int eom, mv =0;
Vector evectorObj = (Vector)events.elementAt(mm);
if(evectorObj.isEmpty()==false)
//
Vector evectorObj = (Vector)events.elementAt(mm); // One vector range.
if(!evectorObj.isEmpty())
{
for(eom = 0; eom<evectorObj.size();eom++)
for(int eom = 0; eom<evectorObj.size();eom++) // loop through previous range.
{
if(!"".equals(evectorObj.elementAt(eom)))
{
// Event ID.
String eomId = (((EventDisplayClass)evectorObj.elementAt(eom)).getEvent()).getId();
newVectorObj = new Vector();
for(mv = 0; mv<vectorObj.size();mv++)
for(int mv = 0; mv<vectorObj.size();mv++) // Loop back through the current range.
{
if(!"".equals(vectorObj.elementAt(mv)))
{
String vectorId = (((EventDisplayClass)vectorObj.elementAt(mv)).getEvent()).getId();
if (vectorId.equals(eomId))
if (vectorId.equals(eomId)) // Exists in a previous range.
{
eventDisplayObj = (EventDisplayClass)vectorObj.elementAt(mv);
eventDisplayObj.setFlag(true);
if (mv != eom)
if (mv != eom) // index of current range,
{
swapflag = true;
vectorObj.removeElementAt(mv);
for(int x = 0 ; x<eom;x++)
{
if(vectorObj.isEmpty()==false)
if(!vectorObj.isEmpty())
{
newVectorObj.add(x,vectorObj.elementAt(0));
newVectorObj.add(x,vectorObj.elementAt(0)); // Copy data into new array.
vectorObj.removeElementAt(0);
}
else
{
newVectorObj.add(x,"");
}
}// for
newVectorObj.add(eom, eventDisplayObj);
newVectorObj.add(eom, eventDisplayObj); // Add the one that's out of position.
int neweom = eom;
neweom = neweom+1;

Expand Down

0 comments on commit 765147f

Please sign in to comment.