public ActionForward createParticipator( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws FenixServiceException { ResearchResult result = getResultFromRequest(request); ResultParticipationCreationBean bean = (ResultParticipationCreationBean) RenderUtils.getViewState("beanForExternalPerson").getMetaObject().getObject(); if (bean.getOrganization() != null) { ExternalContract contract = InsertExternalPerson.run( new InsertExternalPerson.ServiceArguments( bean.getParticipatorName(), bean.getOrganization())); bean.setParticipator(contract.getPerson().getPersonName()); createParticipation(bean); } else { request.setAttribute("createUnit", true); request.setAttribute("duringCreation", true); request.setAttribute("bean", bean); setResParticipationRequestAttributes(request, result, bean); RenderUtils.invalidateViewState(); return mapping.findForward("editParticipation"); } return prepareEdit(mapping, form, request, response); }
@Atomic public static ExternalContract run(ServiceArguments arguments) throws FenixServiceException { ExternalContract storedExternalContract = null; String personName = arguments.getPersonName(); Unit organization = arguments.getUnit(); storedExternalContract = ExternalContract.readByPersonNameAddressAndInstitutionID( personName, null, organization.getExternalId()); if (storedExternalContract != null) { throw new ExistingServiceException( "error.exception.commons.ExternalContract.existingExternalContract"); } Person externalPerson = Person.createExternalPerson( personName, Gender.MALE, null, null, null, null, null, String.valueOf(System.currentTimeMillis()), IDDocumentType.EXTERNAL); return new ExternalContract(externalPerson, organization, new YearMonthDay(), null); }
public void setExternalPerson(ExternalContract externalPerson) { if (externalPerson == null) { this.person = null; } else { setPerson(externalPerson.getPerson()); } }