https://mvnrepository.com/artifact/org.apache.felix/org.apache.felix.webconsole/4.3.4
install http://central.maven.org/maven2/org/apache/felix/org.apache.felix.webconsole/4.3.4/org.apache.felix.webconsole-4.3.4.jar
http://localhost:8080/o/system/console
Username: admin password:admin
https://www.dropbox.com/s/7rp5r0mmtccrjy9/app-dev-extra.pdf?dl=0
@Reference(target = "(osgi.web.symbolicname=com.liferay.training.space.gradebook)")
private ServletContext _servletContext;
@Override
public PortletURL getURLAdd(
LiferayPortletRequest liferayPortletRequest,
LiferayPortletResponse liferayPortletResponse, long classTypeId) {
PortletURL portletURL = null;
portletURL = _portal.getControlPanelPortletURL(
liferayPortletRequest, getGroup(liferayPortletRequest),
GradebookPortletKeys.PORTLET_NAME, 0, 0, PortletRequest.RENDER_PHASE);
portletURL.setParameter("mvcRenderCommandName", "/gradebook/assignment/edit");
portletURL.setParameter("showback", Boolean.FALSE.toString());
return portletURL;
}
From gradebook-web/build.gradle
change version like below
compileOnly group: "com.liferay.portal", name: "com.liferay.portal.kernel", version: "2.6.0"
Modify the getURLEdit
@Override
public PortletURL getURLEdit(
LiferayPortletRequest liferayPortletRequest,
LiferayPortletResponse liferayPortletResponse)
throws Exception {
Group group = (Group)liferayPortletRequest.getAttribute(
WebKeys.ASSET_RENDERER_FACTORY_GROUP);
PortletURL portletURL = PortalUtil.getControlPanelPortletURL(
liferayPortletRequest, group,
GradebookPortletKeys.PORTLET_NAME, 0, 0, PortletRequest.RENDER_PHASE);
portletURL.setParameter("mvcRenderCommandName", "/gradebook/assignment/edit");
portletURL.setParameter(
"assignmentId", String.valueOf(_assignment.getAssignmentId()));
portletURL.setParameter("showback", Boolean.FALSE.toString());
return portletURL;
}
- Add blow to SubmissionLocalServiceImpl (run servicebuilder) and expose that to SubmissionServiceImpl (run servicebuilder)
public Submission addSubmission(long assignmentId, long studentId, int grade, String comment, ServiceContext serviceContext ) throws PortalException {
System.err.println("xxx");
long submissionId =
counterLocalService.increment(Submission.class.getName());
Assignment assignment = assignmentPersistence.findByPrimaryKey(assignmentId);
Submission submission = createSubmission(submissionId);
submission.setAssignmentId(assignmentId);
submission.setSubmissionId(submissionId);
submission.setCompanyId(assignment.getCompanyId());
submission.setGroupId(assignment.getGroupId());
submission.setStudentId(studentId);
submission.setCreateDate(new Date());
submission.setModifiedDate(new Date());
submission.setGrade(grade);
submission.setComment(comment);
return super.addSubmission(submission);
}
- Add Assignment:
Liferay.Service('/space.assignment/add-assignment', {
groupId: 20143,
userId: 31043,
title: { 'en_US': 'How to make birhday cake'},
description: 'Design most delicious and beautifull birthday cake. Serve that to who deserves it.',
dueDate: (new Date('2018-05-22')).getTime()
}, function(obj) {
console.log(obj);
});
- List Assignments
Liferay.Service('/space.assignment/get-assignments-by-group-id', {
groupId: 20143,
start: -1,
end: -1
},
function(obj) {
console.log(obj);
});
- Add submission
Liferay.Service(
'/space.submission/add-submission',
{
assignmentId: 301,
studentId: 31022 ,
grade: 5,
comment: 'Cheesecake with straberries and blueberries'
},
function(obj) {
console.log(obj);
}
);
- Combine these to one remote call.
Liferay.Service({'$assignment = /space.assignment/add-assignment':{
groupId: 20143,
userId: 31043,
title: { 'en_US': 'Please, make birhday cake'},
description: 'Design most delicious and beautifull birthday cake. Serve that to who deserves it.',
dueDate: (new Date('2018-05-22')).getTime(),
'$submission = /space.submission/add-submission': {
'@assignmentId': '$assignment.assignmentId',
studentId: 31022 ,
grade: 5,
comment: 'Cheesecake with straberries and blueberries'
}
}
},
function(obj) {
console.log(obj);
});
- Below is not working, but you can take it as also example.
Liferay.Service({
'$company[companyId] = /company/get-company-by-virtual-host' : {
virtualHost: 'localhost',
'$group[groupId] = /group/get-company-group': {
'@companyId': '$company.companyId',
'$student[userId] = /user/get-user-by-screen-name':{
'@companyId': '$company.companyId',
screenName: 'test',
'$assignment = /gradebook.assignment/add-assignment': {
'@groupId': '$group.groupId',
titleMap: { 'en_US': 'How to make birhday cake'},
description: 'Design most delicious and beautifull birthday cake. Serve that to who deserves it.',
dueDate: (new Date('2018-05-22')).getTime(),
'$submission = /gradebook.submission/add-submission': {
'@assignmentId': '$assignment.assignmentId',
'@studentId': '$student.userId',
submissionText: 'Cheesecake with straberries and blueberries'
}
}
}
}
}
}, function(obj) {
console.log(obj);
});
https://www.dropbox.com/s/gpcrlnte756bru6/Upgrading-to-DXP-v2.pdf?dl=0