public ManchesterTriageProtocolConfigVo getTriageProtocol(ManchesterTriageProtocolConfigLiteVo selectedTriageProtocol) { if (selectedTriageProtocol == null || selectedTriageProtocol.getID_ManchesterTriageProtocolConfiguration() == null) { throw new CodingRuntimeException("Cannot get ManchesterTriageProtocolConfigVo on null Id "); } DomainFactory factory = getDomainFactory(); StringBuffer hql = new StringBuffer(); hql.append(" select protocol from ManchesterTriageProtocolConfiguration as protocol where protocol.id = :protocolID"); List<?> list = factory.find(hql.toString(), new String[] { "protocolID" }, new Object[] { selectedTriageProtocol.getID_ManchesterTriageProtocolConfiguration() }); if (list != null && list.size() > 0) return ManchesterTriageProtocolConfigVoAssembler.createManchesterTriageProtocolConfigVoCollectionFromManchesterTriageProtocolConfiguration(list).get(0); return null; }
public ManchesterTriageProtocolConfigVo saveTriage(ManchesterTriageProtocolConfigVo triageProtocol) throws StaleObjectException, UniqueKeyViolationException { if (triageProtocol == null) throw new CodingRuntimeException("Cannot save null TriageProtocol"); if (!triageProtocol.isValidated()) throw new DomainRuntimeException("triageProtocolVo Not Validated."); DomainFactory factory = getDomainFactory(); triageProtocol.setProtocolName(triageProtocol.getProtocolName().trim()); ManchesterTriageProtocolConfigVo savedProtocol = null; ManchesterTriageProtocolConfiguration domProtocol = ManchesterTriageProtocolConfigVoAssembler.extractManchesterTriageProtocolConfiguration(factory, triageProtocol); if (triageProtocol.getTaxonomyMapIsNotNull()) { boolean found = false; StringBuilder errors = new StringBuilder(); for (int i = 0; i < triageProtocol.getTaxonomyMap().size(); i++) { TaxonomyMap code = triageProtocol.getTaxonomyMap().get(i); ManchesterTriageProtocolConfiguration triageRole = getDiscriminatorRoleByTaxonomy(code.getTaxonomyCode(), code.getTaxonomyName()); if (triageRole != null && !triageRole.getId().equals(triageProtocol.getID_ManchesterTriageProtocolConfiguration())) { found = true; errors.append("\nProtocol '" + triageRole.getProtocolName() + "' already has mapped :"); errors.append(" External Code Type '" + code.getTaxonomyName() + "' and code '" + code.getTaxonomyCode() + "'"); } } if (found) throw new UniqueKeyViolationException(errors.toString()); } factory.save(domProtocol); savedProtocol = ManchesterTriageProtocolConfigVoAssembler.create(domProtocol); return savedProtocol; }