private TaxonomyMapCollection searchGpCodes(TaxonomyMap filter) throws ims.domain.exceptions.DomainInterfaceException { try{ ArrayList<String> names = new ArrayList<String>(); ArrayList<Object> values = new ArrayList<Object>(); StringBuffer taxonomyHql = new StringBuffer(" select distinct gp from Gp as gp left join gp.codeMappings as mappings" + " left join mappings.taxonomyName as tn where (tn.id = :taxonomyType and upper(mappings.taxonomyCode) like :taxonomyCode)"); //StringBuffer taxonomyHql = new StringBuffer(" select distinct g1_1 from Gp as g1_1 left join g1_1.codeMappings as t1_1 where (upper(t1_1.taxonomyCode) like :taxonomyCode and t1_1.taxonomyName = :taxonomyType)"); names.add("taxonomyType"); names.add("taxonomyCode"); values.add(TaxonomyType.NAT_GP_CODE.getId()); values.add("%"+filter.getDescription().toUpperCase()+"%"); List<?> find = getDomainFactory().find(taxonomyHql.toString(), names, values); GpVoCollection coll = GpVoAssembler.createGpVoCollectionFromGp(find); TaxonomyMapCollection coll_ret = new TaxonomyMapCollection(); if (coll != null && coll.size()>0) { for (int i = 0; i < coll.size(); i++) { GpVo vo= coll.get(i); TaxonomyMap tmGPCode = new TaxonomyMap(); tmGPCode.setTaxonomyName(TaxonomyType.NAT_GP_CODE); tmGPCode.setDescription(vo.getName().toString()); tmGPCode.setTaxonomyCode(vo.getCodeMappings().getMappingValue(TaxonomyType.NAT_GP_CODE)); coll_ret.add(tmGPCode); } } return coll_ret; } catch (DomainRuntimeException e) { throw new ims.domain.exceptions.DomainInterfaceException("Please contact your system administrator.\n\nError:\n" + e.getMessage()); } }
public GpVo saveGPRecord(GpVo vo) throws DomainInterfaceException, StaleObjectException, UniqueKeyViolationException { if (!vo.isValidated()) { throw new DomainRuntimeException("GpVo Vo has not been validated."); } DomainFactory factory = getDomainFactory(); Gp gpBo = GpVoAssembler.extractGp(factory, vo); factory.save(gpBo); return GpVoAssembler.create(gpBo); }
public GpVo getGPCode(String code) throws DomainInterfaceException { if(code == null || code.trim().length() == 0) return null; ArrayList names = new ArrayList(); ArrayList values = new ArrayList(); StringBuffer taxonomyHql = new StringBuffer(" select distinct gp from Gp gp join gp.codeMappings as mappings" + " where mappings.taxonomyName = :taxonomyType and mappings.taxonomyCode = :taxonomyCode"); names.add("taxonomyType"); names.add("taxonomyCode"); values.add(getDomLookup(TaxonomyType.NAT_GP_CODE)); values.add(code); GpVoCollection coll = GpVoAssembler.createGpVoCollectionFromGp(getDomainFactory().find(taxonomyHql.toString(), names, values)); if (coll != null && coll.size()>0) return coll.get(0); return null; }