Skip to content

Commit

Permalink
DASH-353, DASH-354 Fix for the missing assignment
Browse files Browse the repository at this point in the history
  • Loading branch information
pushyamig committed Feb 26, 2016
1 parent 79f62dc commit 750fde4
Show file tree
Hide file tree
Showing 10 changed files with 116 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

import org.sakaiproject.dash.entity.DashboardEntityInfo;
import org.sakaiproject.dash.listener.EventProcessor;
import org.sakaiproject.dash.model.AvailabilityCheck;
import org.sakaiproject.dash.model.CalendarItem;
import org.sakaiproject.dash.model.CalendarLink;
import org.sakaiproject.dash.model.Context;
Expand Down Expand Up @@ -427,6 +428,17 @@ public void reviseRepeatingCalendarItemsLabelKey(String entityReference,
* @param scheduledTime
*/
public void scheduleAvailabilityCheck(String entityReference, String entityTypeId, Date scheduledTime);

/**
* If an entity uses some form of scheduled release, this method is called to
* update the scheduled-release time.
*/
public void updateScheduleAvailabilityCheck(String entityReference, String entityTypeId, Date scheduledTime);

/**
* checks if an entity is scheduled for release has entry in the database table or not
*/
public boolean isScheduleAvailabilityCheckMade(String entityReference, String entityTypeId, Date scheduledTime);

/**
* @param newHorizon
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,17 @@ public interface DashboardDao {
*/
public boolean addAvailabilityCheck(AvailabilityCheck availabilityCheck);

/**
* If an entity uses some form of scheduled release, this method is called to
* update the scheduled-release time
*/
public boolean updateAvailabilityCheck(AvailabilityCheck availabilityCheck);

/**
* checks if an entity is scheduled for release has entry in the database table or not
*/
public boolean isScheduleAvailabilityCheckMade(String entityReference);

/**
* @param calendarItem
* @return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,22 @@ public boolean addAvailabilityCheck(AvailabilityCheck availabilityCheck) {
return false;
}
}

@Override
public boolean updateAvailabilityCheck(AvailabilityCheck availabilityCheck) {
if(log.isDebugEnabled()) {
log.debug("updateAvailabilityCheck( " + availabilityCheck.toString() + ")");
}
try {
getJdbcTemplate().update(getStatement("update.AvailabilityCheck"),
new Object[]{availabilityCheck.getScheduledTime(),availabilityCheck.getEntityReference()}
);
return true;
} catch (DataAccessException ex) {
log.warn("updateAvailabilityCheck: Error executing query: " + ex.getClass() + ":" + ex.getMessage());
return false;
}
}

/* (non-Javadoc)
* @see org.sakaiproject.dash.dao.DashboardDao#addCalendarItem(org.sakaiproject.dash.model.CalendarItem)
Expand Down Expand Up @@ -846,6 +862,22 @@ public List<AvailabilityCheck> getAvailabilityChecksBeforeTime(Date time) {
return new ArrayList<AvailabilityCheck>();
}
}
public boolean isScheduleAvailabilityCheckMade(String entityReference){
if (log.isDebugEnabled()) {
log.debug("isScheduleAvailabilityCheckMade");
}
String sql = getStatement("select.AvailabilityChecks.entry");
Object[] params = new Object[] { entityReference };
try {
List<AvailabilityCheck> ac = (List<AvailabilityCheck>) getJdbcTemplate().query(sql, params,
new AvailabilityCheckMapper());
return !ac.isEmpty();
} catch (DataAccessException ex) {
log.warn("isScheduleAvailabilityCheckMade: Error executing query: " + ex.getClass() + ":" + ex.getMessage());
return false;
}

}

/* (non-Javadoc)
* @see org.sakaiproject.dash.dao.DashboardDao#getRepeatingCalendarItem(java.lang.String, java.lang.String)
Expand Down Expand Up @@ -2391,4 +2423,6 @@ private HashMap<String, Set<String>> getDashboardContextUserMap(String sqlName)

return dashboardUserMap;
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -645,14 +645,22 @@ public void processEvent(Event event) {
// add NewsItem and calendar items
nItem = dashboardLogic.createNewsItem(assn.getTitle(), event.getEventTime(), "assignment.added", assnReference, context, sourceType, null);
}

// if assignment is available
if(! dashboardLogic.isAvailable(assnReference, IDENTIFIER))
{
// remove all news and calendar links
dashboardLogic.removeNewsLinks(assnReference);
dashboardLogic.removeCalendarLinks(assnReference);
// assignment is not open yet, schedule for check later
dashboardLogic.scheduleAvailabilityCheck(assnReference, IDENTIFIER, new Date(assn.getOpenTime().getTime()));
// assignment is not open yet, check if the schedule check is made already , if yes then update the new open time else schedule for check later
if (dashboardLogic.isScheduleAvailabilityCheckMade(assnReference, IDENTIFIER,
new Date(assn.getOpenTime().getTime()))) {
dashboardLogic.updateScheduleAvailabilityCheck(assnReference, IDENTIFIER,
new Date(assn.getOpenTime().getTime()));
} else {
dashboardLogic.scheduleAvailabilityCheck(assnReference, IDENTIFIER,
new Date(assn.getOpenTime().getTime()));
}

}
else
{
Expand Down Expand Up @@ -786,6 +794,7 @@ private void createUpdateAssigmentCalendarItem(Context context,
{

dashboardLogic.reviseCalendarItemTime(assnReference, calendarItemLabel, null, calendarItemTime);
dashboardLogic.updateScheduleAvailabilityCheck(assnReference, IDENTIFIER, assignmentOpenDate);
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1287,6 +1287,16 @@ public void scheduleAvailabilityCheck(String entityReference,
this.dashboardLogic.scheduleAvailabilityCheck(entityReference, entityTypeId, scheduledTime);
}

@Override
public void updateScheduleAvailabilityCheck(String entityReference, String entityTypeId, Date scheduledTime) {
this.dashboardLogic.updateScheduleAvailabilityCheck(entityReference, entityTypeId, scheduledTime);
}

@Override
public boolean isScheduleAvailabilityCheckMade(String entityReference, String entityTypeId, Date scheduledTime) {
return this.dashboardLogic.isScheduleAvailabilityCheckMade(entityReference, entityTypeId, scheduledTime);
}

/*
* (non-Javadoc)
* @see org.sakaiproject.dash.logic.DashboardLogic#setRepeatingEventHorizon(java.util.Date)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1116,6 +1116,18 @@ public void scheduleAvailabilityCheck(String entityReference, String entityTypeI
// boolean added =
dao.addAvailabilityCheck(availabilityCheck);
}

@Override
public void updateScheduleAvailabilityCheck(String entityReference, String entityTypeId, Date scheduledTime) {
AvailabilityCheck availabilityCheck = new AvailabilityCheck(entityReference, entityTypeId, scheduledTime);
dao.updateAvailabilityCheck(availabilityCheck);

}

@Override
public boolean isScheduleAvailabilityCheckMade(String entityReference, String entityTypeId, Date scheduledTime) {
return dao.isScheduleAvailabilityCheckMade(entityReference);
}

/* (non-Javadoc)
* @see org.sakaiproject.dash.logic.DashboardLogic#setRepeatingEventHorizon(java.util.Date)
Expand Down
6 changes: 5 additions & 1 deletion dashboard/impl/src/resources/hsqldb.properties
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ delete.AvailabilityChecks.by.entityReference = delete from dash_availability_che

delete.CalendarItem.by.id = delete from dash_calendar_item where id=?

delete.CalendarItems.no.links = delete from dash_calendar_item item where not exists (select * from dash_calendar_link link where item.id=link.item_id)
delete.CalendarItems.no.links = delete from dash_calendar_item item where not exists (select * from dash_calendar_link link where item.id=link.item_id) and item.entity_ref not in (select entity_ref from dash_availability_check)

delete.CalendarLink.by.personId.itemId = delete from dash_calendar_link where person_id=? and item_id=?

Expand Down Expand Up @@ -159,6 +159,8 @@ insert.SourceType = insert into dash_sourcetype (id, identifier) values (NULL, ?

select.AvailabilityChecks.before.date = select * from dash_availability_check where scheduled_time < ?

select.AvailabilityChecks.entry = select * from dash_availability_check where entity_ref = ?

select.CalendarItem.by.entityReference.calendarTimeLabelKey = select ci.id as ci_id, ci.calendar_time as ci_calendar_time, \
ci.calendar_time_label_key as ci_calendar_time_label_key, ci.title as ci_title, ci.entity_ref as ci_entity_ref, \
ci.subtype as ci_subtype, ci.sequence_num as ci_sequence_num, \
Expand Down Expand Up @@ -663,6 +665,8 @@ update.RepeatingEventsTime.entityReference = update dash_repeating_event set fir

update.RepeatingEventsTitle.entityReference = update dash_repeating_event set title=? where entity_ref=?

update.AvailabilityCheck = update dash_availability_check set scheduled_time = ? where entity_ref = ?

create.TaskLock.table = create table dash_task_lock \
( id BIGINT GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1) PRIMARY KEY, \
task varchar(255) not null, server_id varchar(255) not null, claim_time timestamp(6), \
Expand Down
6 changes: 5 additions & 1 deletion dashboard/impl/src/resources/mysql.properties
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ delete.AvailabilityChecks.by.entityReference = delete from dash_availability_che

delete.CalendarItem.by.id = delete from dash_calendar_item where id=?

delete.CalendarItems.no.links = delete item from dash_calendar_item item left join dash_calendar_link link on item.id=link.item_id where link.id is null;
delete.CalendarItems.no.links = delete item from dash_calendar_item item left join dash_calendar_link link on item.id=link.item_id where link.id is null and item.entity_ref not in (select entity_ref from dash_availability_check)

delete.CalendarLink.by.personId.itemId = delete from dash_calendar_link where person_id=? and item_id=?

Expand Down Expand Up @@ -158,6 +158,8 @@ insert.SourceType = insert into dash_sourcetype (identifier) values (?)

select.AvailabilityChecks.before.date = select * from dash_availability_check where scheduled_time < ?

select.AvailabilityChecks.entry = select * from dash_availability_check where entity_ref = ?

select.CalendarItem.by.entityReference.calendarTimeLabelKey = select ci.id as ci_id, ci.calendar_time as ci_calendar_time, \
ci.calendar_time_label_key as ci_calendar_time_label_key, ci.title as ci_title, ci.entity_ref as ci_entity_ref, \
ci.subtype as ci_subtype, ci.sequence_num as ci_sequence_num, \
Expand Down Expand Up @@ -671,6 +673,8 @@ update.RepeatingEventsTime.entityReference = update dash_repeating_event set fir

update.RepeatingEventsTitle.entityReference = update dash_repeating_event set title=? where entity_ref=?

update.AvailabilityCheck = update dash_availability_check set scheduled_time = ? where entity_ref = ?

create.TaskLock.table = create table dash_task_lock \
( id bigint not null auto_increment, \
task varchar(255) not null, server_id varchar(255) not null, claim_time datetime, \
Expand Down
6 changes: 5 additions & 1 deletion dashboard/impl/src/resources/oracle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ delete.AvailabilityChecks.by.entityReference = delete from dash_availability_che

delete.CalendarItem.by.id = delete from dash_calendar_item where id=?

delete.CalendarItems.no.links = delete from dash_calendar_item item where not exists (select * from dash_calendar_link link where item.id=link.item_id)
delete.CalendarItems.no.links = delete from dash_calendar_item item where not exists (select * from dash_calendar_link link where item.id=link.item_id) and item.entity_ref not in (select entity_ref from dash_availability_check)

delete.CalendarLink.by.personId.itemId = delete from dash_calendar_link where person_id=? and item_id=?

Expand Down Expand Up @@ -172,6 +172,8 @@ insert.SourceType = insert into dash_sourcetype ( id, identifier) values (dash_s

select.AvailabilityChecks.before.date = select * from dash_availability_check where scheduled_time < ?

select.AvailabilityChecks.entry = select * from dash_availability_check where entity_ref = ?

select.CalendarItem.by.entityReference.calendarTimeLabelKey = select ci.id as ci_id, ci.calendar_time as ci_calendar_time, \
ci.calendar_time_label_key as ci_calendar_time_label_key, ci.title as ci_title, ci.entity_ref as ci_entity_ref, \
ci.subtype as ci_subtype, ci.sequence_num as ci_sequence_num, \
Expand Down Expand Up @@ -678,6 +680,8 @@ update.RepeatingEventsTime.entityReference = update dash_repeating_event set fir

update.RepeatingEventsTitle.entityReference = update dash_repeating_event set title=? where entity_ref=?

update.AvailabilityCheck = update dash_availability_check set scheduled_time = ? where entity_ref = ?

create.TaskLock.table = create table dash_task_lock \
( id number not null primary key, \
task varchar2(255) not null, server_id varchar2(255) not null, claim_time timestamp(9), \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -932,4 +932,14 @@ public HashMap<String, Set<String>> getDashboardCalendarContextUserMap()
// TODO Auto-generated method stub
return new HashMap<String, Set<String>>();
}

@Override
public boolean updateAvailabilityCheck(AvailabilityCheck availabilityCheck) {
return false;
}

@Override
public boolean isScheduleAvailabilityCheckMade(String entityReference) {
return false;
}
}

0 comments on commit 750fde4

Please sign in to comment.