use of com.liferay.tasks.model.TasksEntry in project liferay-ide by liferay.
the class TasksEntryLocalServiceImpl method updateTasksEntry.
public TasksEntry updateTasksEntry(long tasksEntryId, String title, int priority, long assigneeUserId, long resolverUserId, int dueDateMonth, int dueDateDay, int dueDateYear, int dueDateHour, int dueDateMinute, boolean addDueDate, int status, ServiceContext serviceContext) throws PortalException, SystemException {
// Tasks entry
Date now = new Date();
TasksEntry tasksEntry = tasksEntryPersistence.findByPrimaryKey(tasksEntryId);
User user = UserLocalServiceUtil.getUserById(tasksEntry.getUserId());
validate(title);
Date dueDate = null;
if (addDueDate) {
dueDate = PortalUtil.getDate(dueDateMonth, dueDateDay, dueDateYear, dueDateHour, dueDateMinute, user.getTimeZone(), TasksEntryDueDateException.class);
}
long oldAssigneeUserId = tasksEntry.getAssigneeUserId();
int oldStatus = tasksEntry.getStatus();
tasksEntry.setModifiedDate(now);
tasksEntry.setTitle(title);
tasksEntry.setPriority(priority);
tasksEntry.setAssigneeUserId(assigneeUserId);
tasksEntry.setDueDate(dueDate);
if (status == TasksEntryConstants.STATUS_RESOLVED) {
tasksEntry.setResolverUserId(resolverUserId);
tasksEntry.setFinishDate(now);
} else {
tasksEntry.setResolverUserId(0);
tasksEntry.setFinishDate(null);
}
tasksEntry.setStatus(status);
tasksEntryPersistence.update(tasksEntry);
// Asset
updateAsset(tasksEntry.getUserId(), tasksEntry, serviceContext.getAssetCategoryIds(), serviceContext.getAssetTagNames());
// Social
addSocialActivity(status, tasksEntry, serviceContext);
// Notifications
sendNotificationEvent(tasksEntry, oldStatus, oldAssigneeUserId, serviceContext);
return tasksEntry;
}
use of com.liferay.tasks.model.TasksEntry in project liferay-ide by liferay.
the class TasksEntryLocalServiceImpl method addSocialActivity.
protected void addSocialActivity(int status, TasksEntry tasksEntry, ServiceContext serviceContext) throws PortalException, SystemException {
int activity = TasksActivityKeys.UPDATE_ENTRY;
if (status == TasksEntryConstants.STATUS_REOPENED) {
activity = TasksActivityKeys.REOPEN_ENTRY;
} else if (status == TasksEntryConstants.STATUS_RESOLVED) {
activity = TasksActivityKeys.RESOLVE_ENTRY;
}
JSONObject extraDataJSONObject = JSONFactoryUtil.createJSONObject();
extraDataJSONObject.put("title", tasksEntry.getTitle());
SocialActivityLocalServiceUtil.addActivity(serviceContext.getUserId(), tasksEntry.getGroupId(), TasksEntry.class.getName(), tasksEntry.getTasksEntryId(), activity, extraDataJSONObject.toString(), tasksEntry.getAssigneeUserId());
}
use of com.liferay.tasks.model.TasksEntry in project liferay-ide by liferay.
the class TasksEntryLocalServiceImpl method addTasksEntry.
public TasksEntry addTasksEntry(long userId, String title, int priority, long assigneeUserId, int dueDateMonth, int dueDateDay, int dueDateYear, int dueDateHour, int dueDateMinute, boolean addDueDate, ServiceContext serviceContext) throws PortalException, SystemException {
// Tasks entry
User user = UserLocalServiceUtil.getUserById(userId);
long groupId = serviceContext.getScopeGroupId();
Date now = new Date();
validate(title);
Date dueDate = null;
if (addDueDate) {
dueDate = PortalUtil.getDate(dueDateMonth, dueDateDay, dueDateYear, dueDateHour, dueDateMinute, user.getTimeZone(), TasksEntryDueDateException.class);
}
long tasksEntryId = CounterLocalServiceUtil.increment();
TasksEntry tasksEntry = tasksEntryPersistence.create(tasksEntryId);
tasksEntry.setGroupId(groupId);
tasksEntry.setCompanyId(user.getCompanyId());
tasksEntry.setUserId(user.getUserId());
tasksEntry.setUserName(user.getFullName());
tasksEntry.setCreateDate(now);
tasksEntry.setModifiedDate(now);
tasksEntry.setTitle(title);
tasksEntry.setPriority(priority);
tasksEntry.setAssigneeUserId(assigneeUserId);
tasksEntry.setDueDate(dueDate);
tasksEntry.setStatus(TasksEntryConstants.STATUS_OPEN);
tasksEntryPersistence.update(tasksEntry);
// Resources
resourceLocalService.addModelResources(tasksEntry, serviceContext);
// Asset
updateAsset(userId, tasksEntry, serviceContext.getAssetCategoryIds(), serviceContext.getAssetTagNames());
// Social
JSONObject extraDataJSONObject = JSONFactoryUtil.createJSONObject();
extraDataJSONObject.put("title", tasksEntry.getTitle());
SocialActivityLocalServiceUtil.addActivity(userId, groupId, TasksEntry.class.getName(), tasksEntryId, TasksActivityKeys.ADD_ENTRY, extraDataJSONObject.toString(), assigneeUserId);
// Notifications
sendNotificationEvent(tasksEntry, TasksEntryConstants.STATUS_ALL, assigneeUserId, serviceContext);
return tasksEntry;
}
use of com.liferay.tasks.model.TasksEntry in project liferay-ide by liferay.
the class TasksEntryLocalServiceImpl method updateTasksEntryStatus.
public TasksEntry updateTasksEntryStatus(long tasksEntryId, long resolverUserId, int status, ServiceContext serviceContext) throws PortalException, SystemException {
// Tasks entry
Date now = new Date();
TasksEntry tasksEntry = tasksEntryPersistence.findByPrimaryKey(tasksEntryId);
tasksEntry.setModifiedDate(now);
if (status == TasksEntryConstants.STATUS_RESOLVED) {
tasksEntry.setResolverUserId(resolverUserId);
tasksEntry.setFinishDate(now);
} else {
tasksEntry.setResolverUserId(0);
tasksEntry.setFinishDate(null);
}
int oldStatus = tasksEntry.getStatus();
tasksEntry.setStatus(status);
tasksEntryPersistence.update(tasksEntry);
// Social
addSocialActivity(status, tasksEntry, serviceContext);
// Notifications
sendNotificationEvent(tasksEntry, oldStatus, tasksEntry.getAssigneeUserId(), serviceContext);
return tasksEntry;
}
Aggregations