Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP:Linked Project Calendar #27

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,10 @@ public void onPageRequest(final PageRequest request) {
calendars.put(calendarId++, getOrgUnit().getId());
calendars.put(calendarId, getOrgUnit().getCalendarId());
calendarId = calendarId + 3;
java.util.Iterator<OrgUnitDTO> iter = getOrgUnit().getChildrenOrgUnits().iterator();
while (iter.hasNext()) {
calendars.put(calendarId++, getOrgUnit().getChildrenOrgUnits().iterator().next().getId());
calendars.put(calendarId, getOrgUnit().getChildrenOrgUnits().iterator().next().getCalendarId());
iter.next();

for(final OrgUnitDTO child : getOrgUnit().getChildrenOrgUnits()) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Raphcal Changed to for loop as suggested.

calendars.put(calendarId++, child.getId());
calendars.put(calendarId, child.getCalendarId());
calendarId = calendarId + 3;
}
calendarPresenter.reload(calendars);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ public Calendar getCalendar(CalendarIdentifier identifier,EntityManager em) {
sb.append(format.format(point.getExpectedDate()));
sb.append(')');
}

event.setDescription(sb.toString());
event.setDescription(sb.toString() + calendarIdentifier.getProjectId());

// Adding the event to the event map
final Date key = event.getKey();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ public Calendar getCalendar(CalendarIdentifier identifier,EntityManager em) {
sb.append(format.format(reminder.getExpectedDate()));
sb.append(')');
}

event.setDescription(sb.toString());
event.setDescription(sb.toString() + calendarIdentifier.getProjectId());

// Adding the event to the event map
final Date key = event.getKey();
Expand Down
10 changes: 7 additions & 3 deletions src/main/java/org/sigmah/shared/dto/calendar/CalendarType.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ private Color(final int colorCode) {
this.colorCode = colorCode;
}
}

/**
* Returns the given {@code type} corresponding {@link CalendarIdentifier} instance for the given {@code id}.
*
Expand All @@ -86,7 +86,10 @@ private Color(final int colorCode) {
* The calendar id.
* @return The {@link CalendarIdentifier} instance.
*/
static int projectId;
public static CalendarIdentifier getIdentifier(final CalendarType type, final Integer id) {



if (type == null) {
throw new IllegalArgumentException("Invalid calendar type.");
Expand All @@ -95,18 +98,19 @@ public static CalendarIdentifier getIdentifier(final CalendarType type, final In
switch (type) {

case Activity:
projectId = id;
return new ActivityCalendarIdentifier(id, I18N.CONSTANTS.logFrameActivities(), I18N.CONSTANTS.logFrameActivitiesCode());

case Personal:
return new PersonalCalendarIdentifier(id);

case MonitoredPoint:
return new MonitoredPointCalendarIdentifier(id, I18N.CONSTANTS.monitoredPoints(), I18N.CONSTANTS.monitoredPointClosed(),
I18N.CONSTANTS.monitoredPointExpectedDate(), DateUtils.DATE_SHORT.getPattern());
I18N.CONSTANTS.monitoredPointExpectedDate(), DateUtils.DATE_SHORT.getPattern() , projectId);

case Reminder:
return new ReminderCalendarIdentifier(id, I18N.CONSTANTS.reminderPoints(), I18N.CONSTANTS.monitoredPointClosed(),
I18N.CONSTANTS.monitoredPointExpectedDate(), DateUtils.DATE_SHORT.getPattern());
I18N.CONSTANTS.monitoredPointExpectedDate(), DateUtils.DATE_SHORT.getPattern(),projectId);

default:
throw new IllegalArgumentException("Invalid calendar type.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,19 @@ public class MonitoredPointCalendarIdentifier implements CalendarIdentifier {
private String completedEventString;
private String expectedDateString;
private String dateFormat;
private int projectId;

public MonitoredPointCalendarIdentifier() {
// Serialization.
}

public MonitoredPointCalendarIdentifier(int monitoredListId, String calendarName, String completedEventString, String expectedDateString, String dateFormat) {
public MonitoredPointCalendarIdentifier(int monitoredListId, String calendarName, String completedEventString, String expectedDateString, String dateFormat, int projectId) {
this.monitoredListId = monitoredListId;
this.calendarName = calendarName;
this.completedEventString = completedEventString;
this.expectedDateString = expectedDateString;
this.dateFormat = dateFormat;
this.projectId = projectId;
}

public int getMonitoredListId() {
Expand Down Expand Up @@ -90,6 +92,16 @@ public void setDateFormat(String dateFormat) {
this.dateFormat = dateFormat;
}

public int getProjectId() {
return projectId;
}

public void setProjectId(int projectId) {
this.projectId = projectId;
}



/**
* {@inheritDoc}
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,19 @@ public class ReminderCalendarIdentifier implements CalendarIdentifier {
private String completedEventString;
private String expectedDateString;
private String dateFormat;
private int projectId;

public ReminderCalendarIdentifier() {
// Serialization.
}

public ReminderCalendarIdentifier(int reminderListId, String calendarName, String completedEventString, String expectedDateString, String dateFormat) {
public ReminderCalendarIdentifier(int reminderListId, String calendarName, String completedEventString, String expectedDateString, String dateFormat, int projectId) {
this.reminderListId = reminderListId;
this.calendarName = calendarName;
this.completedEventString = completedEventString;
this.expectedDateString = expectedDateString;
this.dateFormat = dateFormat;
this.projectId = projectId;
}

public int getReminderListId() {
Expand Down Expand Up @@ -90,6 +92,16 @@ public void setDateFormat(String dateFormat) {
this.dateFormat = dateFormat;
}

public int getProjectId() {
return projectId;
}

public void setProjectId(int projectId) {
this.projectId = projectId;
}



/**
* {@inheritDoc}
*/
Expand Down