@Override
public void createEntity(ActionMessages errors, EditLoadForm form, Hashtable<String, Object> attributes, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
UserVO activeUser = (UserVO) request.getSession().getAttribute(Globals.USER_KEY);
JobVO job = new JobVO();
job.setStatus(JobVO.Status.PLANNED);
job.setPriority(JobVO.Priority.MEDIUM);
job.setAccessUser(EntityAccess.Access.WRITE_SYSTEM);
job.setOwnerUser(activeUser.getId());
job.setAccessGroup(EntityAccess.Access.NONE);
job.setOwnerGroup(activeUser.getProfile().getDefaultUsergroup().getId());
job.setAccessGlobal(EntityAccess.Access.WRITE_SYSTEM);
if(Panel.getPanelStack(request).peek() instanceof EditPanel) {
EditPanel lastPanel = (EditPanel)Panel.getPanelStack(request).peek();
if(lastPanel.getEntity() instanceof CompanyVO) {
if (log.isDebugEnabled())
log.debug("contact for company");
CompanyVO company = (CompanyVO) lastPanel.getEntity();
job.setReferencedCompany(company);
} else if(lastPanel.getEntity() instanceof PersonVO) {
if (log.isDebugEnabled())
log.debug("contact for person");
PersonVO person = (PersonVO)lastPanel.getEntity();
job.setReferencedPerson(person);
job.setReferencedCompany(person.getCompany());
} else {
log.warn("unknown entity found in panel: "+lastPanel);
}
}
job.setAssignedUser(activeUser);
attributes.put("job", job);
}