@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((yLanguage == null) ? 0 : yLanguage.getBibliographicCode().hashCode()); return result; }
@Override public LanguageData getLocalizedLanguage(YLanguage language, Locale locale) { String longDesc = languageDictionary.getLongDescription(language.getBibliographicCode(), locale); return new LanguageData(language, language.getBibliographicCode(), longDesc); }
/** * Creates Language with specified single parameters * * @param id * identification * @param name * Displayed name */ public LanguageData(YLanguage yLanguage) { super(yLanguage.getBibliographicCode(), yLanguage.getName()); this.yLanguage = yLanguage; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; LanguageData other = (LanguageData) obj; if (!yLanguage.getBibliographicCode().equals(other.yLanguage.getBibliographicCode()) || !yLanguage.getName().equals(other.yLanguage.getName())) return false; return true; }
@Override public String getTranslation(String languageId, Locale locale, DictionaryDataTypes type) { final String code = YLanguage.byCode(languageId, YLanguage.Undetermined).getBibliographicCode(); if (StringUtils.isNotEmpty(code)) { return languageDictionary.getLongDescription(code, locale); } return languageId; }
public String extractLanguageCode(YLanguage yLanguage){ String code = yLanguage.getShortCode(); if(code.isEmpty()) code = yLanguage.getTerminologyCode(); if(code.isEmpty()) code = yLanguage.getBibliographicCode(); if(code.isEmpty()) code = yLanguage.getName(); return code; }
@RequestMapping(value = KEY_WORD_SUGGESTION, method = RequestMethod.GET) public @ResponseBody Map<String, List<String>> keyWordSuggestion(HttpServletRequest request) { Map<String, List<String>> allKeywords = new HashMap<String, List<String>>(); try { for (YLanguage lang : metadataGenerator.getSupportedLanguages()) { String desc = ServletRequestUtils.getStringParameter(request, "desc_" + lang.getBibliographicCode(), StringUtils.EMPTY);; String title = ServletRequestUtils.getStringParameter(request, "title_" + lang.getBibliographicCode(), StringUtils.EMPTY);; if (StringUtils.isNotBlank(desc) || StringUtils.isNotBlank(title)) { String text = buildKeywordBaseText(title, desc); List<String> keywords = metadataGenerator.generateKeywords(lang, text); allKeywords.put(lang.getBibliographicCode(), keywords); } } } catch (Exception e) { logger.warn("Exception while generating keywords", e); } return allKeywords; }
public YLanguage byCodeName(String code, YLanguage fallback) { if (code == null || code.isEmpty()) return fallback; code = code.toLowerCase(Locale.ENGLISH); for (YLanguage lang : YLanguage.values()) { if (code.equals(lang.getShortCode())) return lang; if (code.equals(lang.getBibliographicCode())) return lang; if (code.equals(lang.getTerminologyCode())) return lang; if (isInArrayIgnoreCase(lang.getNames(), code)) return lang; } return fallback; }
protected void cleanKeywords(ResourceData resource) { List<KeywordsData> result = new ArrayList<KeywordsData>(); for (KeywordsData data : resource.getKeywords()) { if (data.getLanguage() != null && !YLanguage.NoLinguisticContent.getBibliographicCode().equals(data.getLanguage().getId())) { result.add(data); } } resource.setKeywords(result); }
protected void cleanDescriptions(ResourceData resource) { List<LocalizedData<String>> result = new ArrayList<LocalizedData<String>>(); for (LocalizedData<String> data : resource.getDescriptions()) { if (data.getLanguage() != null && !YLanguage.NoLinguisticContent.getBibliographicCode().equals(data.getLanguage().getId())) { result.add(data); } } resource.setDescriptions(result); }
private LanguageData makeLanguageData(final YLanguage yLanguage, final Locale locale) { final String longDesc = languageDictionary.getLongDescription(yLanguage.getBibliographicCode(), locale); return new LanguageData(yLanguage, yLanguage.getShortCode(), longDesc); }
@Override public void buildReferenceData(RequestWrapper requestWrapper, Model model, Locale locale) { LinkedHashSet<LanguageData> preferredLanguages = new LinkedHashSet<LanguageData>( languageService.getPreferedLanguagesBibliographicFormat(locale)); List<AdvancedFormFieldCondition> conditions = StringUtils.isEmpty(requestWrapper.getSearchQuery()) ? buildInitialConditions() : buildSearchConditions(requestWrapper.getSearchQuery()); preferredLanguages.addAll(fetchAdditionalLanguagesFromConditions(conditions, locale)); model.addAttribute("advancedQuery", conditions); model.addAttribute("datasets", datasetDictionary.listDataSets()); model.addAttribute("levels", levelDictionary.listAvailableLevels()); model.addAttribute("allLanguages", languageService.getAllLanguagesBibliographicFormat(locale)); model.addAttribute("defaultSelectedLanguage", YLanguage.byCode(locale.getLanguage(), YLanguage.Polish) .getBibliographicCode()); model.addAttribute("languages", preferredLanguages); }
/** * Iterates over titles and removes elements without language definition or * with {@link YLanguage#NoLinguisticContent} language * * @param resource */ protected void cleanTitles(ResourceData resource) { List<LocalizedData<String>> result = new ArrayList<LocalizedData<String>>(); for (LocalizedData<String> data : resource.getTitles()) { if (data.getLanguage() != null && !YLanguage.NoLinguisticContent.getBibliographicCode().equals(data.getLanguage().getId())) { result.add(data); } } resource.setTitles(result); }
private YLanguage extractYLanguage(Attribute langAttribute) { if (langAttribute == null) { return null; } String langStr = langAttribute.getValue(); if (langStr == null) { return null; } langStr = langStr.trim(); for (YLanguage lang : YLanguage.values()) { if (lang.getBibliographicCode().equals(langStr) || lang.getShortCode().equals(langStr) || lang.getTerminologyCode().equals(langStr)) { return lang; } for (String langName : lang.getNames()) { if (langName != null && langName.equals(langStr)) { return lang; } } } return null; }
private KeywordsData makeLocalizedKeywordsData(final YTagList yTagList, final YLanguage yLanguage, Locale locale) { if (yTagList.getType().equals(TG_KEYWORD)) { List<String> tags = new ArrayList<String>(); for (YRichText richTag : yTagList.getRichValues()) { tags.add(richTag.toText().replaceAll(YModelUtils.LF_CR, YModelUtils.CR)); } String longDesc = languageDictionary.getLongDescription(yLanguage.getBibliographicCode(), locale); LanguageData data = new LanguageData(yLanguage, yLanguage.getShortCode(), longDesc); return new KeywordsData(data).setStringData(tags); } return null; }
@Override public Set<DBUserProfileCustomProperty> apply(LanguageData input) { DBUserProfileCustomProperty property = new DBUserProfileCustomProperty(); setLanguage(property, input.getyLanguage().getBibliographicCode()); setCustomValue(property, input.getId()); setName(property, input.getName()); return Sets.newHashSet(property); }
@Override public Set<DBUserProfileCustomProperty> apply(CoverableValue<KeywordsData> input) { Set<DBUserProfileCustomProperty> properties = Sets.newHashSet(); KeywordsData keywordsData = input.getValue(); String level = input.getLevel(); if (keywordsData == null || keywordsData.getLanguage() == null) { return properties; } String language = keywordsData.getLanguage().getyLanguage().getBibliographicCode(); Integer position = 0; if(keywordsData.getData() == null || keywordsData.getData().isEmpty()){ DBUserProfileCustomProperty property = new DBUserProfileCustomProperty(); property.setSupplementaryKey(position.toString()); setLevel(property, level); setLanguage(property, language); properties.add(property); return properties; }else { for (String data : keywordsData.getStringData()) { DBUserProfileCustomProperty property = new DBUserProfileCustomProperty(); property.setSupplementaryKey(position.toString()); setLevel(property, level); setLanguage(property, language); setValue(property, data); properties.add(property); position++; } } return properties; }
protected ElementCollection convert(CollectionData data) { ElementCollection collection = new ElementCollection(); collection.setId(data.getId()); collection.setDescription(data.getDescription()); collection.setName(data.getName()); collection.setVisibility(data.getVisibility()); collection.setType(data.getType().getTypeName()); collection.setCreationTimestamp(data.getCreationTimestamp()); collection.setModifyTimestamp(data.getModifyTimestamp()); collection.setDisciplines(new HashSet<String>(Arrays.asList(data.getDisciplines()))); for (KeywordsData kd : data.getKeywords()) { if (StringUtils.isNotBlank(kd.getContentString())) { collection.getKeywords().add(new KeywordSet(kd.getLanguage().getyLanguage().getBibliographicCode(),kd.getStringData())); } } for (CollectionUserData contributor : data.getUsers()) { if(StringUtils.isNotBlank(contributor.getUserId())){ collection.getAssignedUsers().add(new CollectionUser(contributor.getUserId(), contributor.getRole())); } } return collection; }
bibEntry.setField(BibEntry.FIELD_LANGUAGE, yElement.getOneLanguage().getBibliographicCode());