public DiscriminatorConfigVo getDiscriminatorConfig(DiscriminatorConfigVo discriminatorConfig) { DomainFactory factory = getDomainFactory(); if (discriminatorConfig == null || !discriminatorConfig.getID_DiscriminatorConfigIsNotNull()) { throw new CodingRuntimeException("Cannot get DiscriminatorConfig on null Id "); } StringBuffer hql = new StringBuffer(); hql.append(" select Discriminator from DiscriminatorConfig as Discriminator where Discriminator.id = :discriminatorID"); List<?> list = factory.find(hql.toString(), new String[] { "discriminatorID" }, new Object[] { discriminatorConfig.getID_DiscriminatorConfig() }); if (list != null && list.size() > 0) return DiscriminatorConfigVoAssembler.createDiscriminatorConfigVoCollectionFromDiscriminatorConfig(list).get(0); return null; }
public DiscriminatorConfigVoCollection listDiscriminators(String filter) { List<?> resultsList; try { resultsList = listItemInfo(filter); } catch (DomainInterfaceException e) { return null; } if (resultsList.size() > 0) { return DiscriminatorConfigVoAssembler.createDiscriminatorConfigVoCollectionFromDiscriminatorConfig(resultsList); } return null; }
public DiscriminatorConfigVoCollection listDiscriminators(String filter, Boolean activeOnly, DiscriminatorConfigRefVo discriminatorRef) //wdev-15985 { List<?> resultsList; try { resultsList = listItemInfo(filter, activeOnly.booleanValue()); } catch (DomainInterfaceException e) { return null; } if (resultsList.size() > 0) { return DiscriminatorConfigVoAssembler.createDiscriminatorConfigVoCollectionFromDiscriminatorConfig(resultsList); } else //wdev-15985 { if( discriminatorRef != null ) { DomainFactory factory = getDomainFactory(); StringBuffer hql = new StringBuffer(); hql.append(" select Discriminator from DiscriminatorConfig as Discriminator where Discriminator.id = :discriminatorID"); List<?> list = factory.find(hql.toString(), new String[] { "discriminatorID" }, new Object[] { discriminatorRef.getID_DiscriminatorConfig() }); if ( list != null && list.size() > 0) { DiscriminatorConfigVoCollection temp = DiscriminatorConfigVoAssembler.createDiscriminatorConfigVoCollectionFromDiscriminatorConfig(list); return temp; } } } return null; }
public DiscriminatorConfigVo saveDiscriminatorConfig(DiscriminatorConfigVo discriminatorConfig) throws UniqueKeyViolationException, StaleObjectException, DomainInterfaceException { if (discriminatorConfig == null) throw new CodingRuntimeException("Cannot save null DiscriminatorConfig"); if (!discriminatorConfig.isValidated()) throw new DomainRuntimeException("discriminatorConfigVo Not Validated."); DomainFactory factory = getDomainFactory(); discriminatorConfig.setDiscriminatorName(discriminatorConfig.getDiscriminatorName().trim()); DiscriminatorConfigVo savedDiscriminator = null; DiscriminatorConfig domDiscriminator = DiscriminatorConfigVoAssembler.extractDiscriminatorConfig(factory, discriminatorConfig); if ((discriminatorConfig.getKeywords() == null || discriminatorConfig.getKeywords().size() == 0) && domDiscriminator.getDiscriminatorName() != null) domDiscriminator.setKeywords(Keywords.setupKeyWords((List<?>) domDiscriminator.getKeywords(), domDiscriminator.getDiscriminatorName())); if (domDiscriminator.getKeywords().size() <= 0) throw new DomainInterfaceException("No keywords were created. Please amend Discriminator name."); if (discriminatorConfig.getTaxonomyMapIsNotNull()) { boolean found = false; StringBuilder errors = new StringBuilder(); for (int i = 0; i < discriminatorConfig.getTaxonomyMap().size(); i++) { TaxonomyMap code = discriminatorConfig.getTaxonomyMap().get(i); DiscriminatorConfig discriminatorRole = getDiscriminatorRoleByTaxonomy(code.getTaxonomyCode(), code.getTaxonomyName()); if (discriminatorRole != null && !discriminatorRole.getId().equals(discriminatorConfig.getID_DiscriminatorConfig())) { found = true; errors.append("\nDiscriminator '" + discriminatorRole.getDiscriminatorName() + "' already has mapped :"); errors.append(" External Code Type '" + code.getTaxonomyName() + "' and code '" + code.getTaxonomyCode() + "'"); } } if (found) throw new UniqueKeyViolationException(errors.toString()); } factory.save(domDiscriminator); savedDiscriminator = DiscriminatorConfigVoAssembler.create(domDiscriminator); return savedDiscriminator; }