protected void buildAndAttachProtocolCorrespondence( ProtocolBase protocol, byte[] data, String correspTypeCode) { ProtocolCorrespondence protocolCorrespondence = getNewProtocolCorrespondenceHook(); protocolCorrespondence.setProtocol(protocol); protocolCorrespondence.setProtocolId(protocol.getProtocolId()); protocolCorrespondence.setProtocolNumber(protocol.getProtocolNumber()); protocolCorrespondence.setSequenceNumber(protocol.getSequenceNumber()); protocolCorrespondence.setProtoCorrespTypeCode(correspTypeCode); ProtocolActionBase lastAction = protocol.getLastProtocolAction(); protocolCorrespondence.setProtocolAction(lastAction); protocolCorrespondence.setActionIdFk(lastAction.getProtocolActionId()); protocolCorrespondence.setCorrespondence(data); protocolCorrespondence.setActionId(lastAction.getActionId()); // What is Final flag used for? ANSWER: the final flag is used by the IRB admin to denote // correspondences // that are ready to be sent/published to the PI etc. protocolCorrespondence.setFinalFlag(false); protocolCorrespondence.setCreateUser(GlobalVariables.getUserSession().getPrincipalName()); protocolCorrespondence.setCreateTimestamp(dateTimeService.getCurrentTimestamp()); if (lastAction.getProtocolCorrespondences() == null) { List<ProtocolCorrespondence> correspondences = new ArrayList<ProtocolCorrespondence>(); correspondences.add(protocolCorrespondence); lastAction.setProtocolCorrespondences(correspondences); protocol.refreshReferenceObject("protocolSubmissions"); } else { lastAction.getProtocolCorrespondences().add(protocolCorrespondence); } getBusinessObjectService().save(protocolCorrespondence); getBusinessObjectService().save(protocol); }