/** * Gets a description spec representing the <code>description</code> in the dialect specified by * the <code>dialectNid</code>. * * @param description the description to represent * @param dialectNid specifying the dialect of the description spec * @param viewCoordinate specifying which version of the description to use * @return the generated description spec for the specified dialect * @throws UnsupportedDialectOrLanguage indicates an unsupported dialect or language * @throws IOException signals that an I/O exception has occurred */ public static DescriptionSpec getDescriptionSpecForDialect( DescriptionVersionBI<?> description, int dialectNid, ViewCoordinate viewCoordinate) throws UnsupportedDialectOrLanguage, IOException { try { lazyInit(dialectNid); String variantText = makeTextForDialect(description.getText(), dialectNid); UUID descUuid = UuidT5Generator.getDescUuid( description.getText(), AppContext.getService(TerminologyStoreDI.class) .getConcept(dialectNid) .getPrimordialUuid(), AppContext.getService(TerminologyStoreDI.class) .getConcept(description.getConceptNid()) .getPrimordialUuid()); DescriptionSpec ds = new DescriptionSpec( new UUID[] {descUuid}, SpecFactory.get( AppContext.getService(TerminologyStoreDI.class) .getConcept(description.getConceptNid()), viewCoordinate), SpecFactory.get( AppContext.getService(TerminologyStoreDI.class) .getConcept(description.getTypeNid()), viewCoordinate), variantText); ds.setLangText(description.getLang()); return ds; } catch (NoSuchAlgorithmException ex) { throw new IOException(ex); } catch (UnsupportedEncodingException ex) { throw new IOException(ex); } }
/** * Checks if the enclosing concept of the given <code>description</code> is has any descriptions * in the specified dialect, <code>dialectNid</code>. Uses the given <code>viewCoordinate</code> * to determine which version of the descriptions to use. * * @param description the description containing the text to check * @param dialectNid the dialect nid specifying the desired dialect * @param viewCoordinate the view coordinate specifying which version of the description to use * @return <code>true</code>, if no description is found in the specified dialect * @throws IOException signals that an I/O exception has occurred * @throws ContradictionException if more than one version is found for the given view coordinate * @throws UnsupportedDialectOrLanguage indicates an unsupported dialect or language */ public static boolean isMissingDescForDialect( DescriptionVersionBI<?> description, int dialectNid, ViewCoordinate viewCoordinate) throws IOException, ContradictionException, UnsupportedDialectOrLanguage { lazyInit(dialectNid); if (!description.getLang().equals("en")) { return false; } if (isTextForDialect(description.getText(), dialectNid)) { return false; } String dialectText = makeTextForDialect(description.getText(), dialectNid); ConceptVersionBI concept = AppContext.getService(TerminologyStoreDI.class) .getConceptVersion(viewCoordinate, description.getConceptNid()); for (DescriptionVersionBI<?> d : concept.getDescriptionsActive()) { if (d.getText().toLowerCase().equals(dialectText.toLowerCase())) { return false; } } return true; }