本文整理了Java中pl.edu.icm.model.bwmeta.y.YLanguage.byCode()
方法的一些代码示例,展示了YLanguage.byCode()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YLanguage.byCode()
方法的具体详情如下:
包路径:pl.edu.icm.model.bwmeta.y.YLanguage
类名称:YLanguage
方法名:byCode
暂无
代码示例来源:origin: pl.edu.icm.synat/synat-business-services-api
public LanguageData(String languageCode) {
this(YLanguage.byCode(languageCode, YLanguage.Undetermined));
}
代码示例来源:origin: pl.edu.icm.synat/synat-process-common
private static YLanguage detectLanguage(Set<YLanguage> possibleLanguages, Detector detector) throws LangDetectException {
for (Language language : detector.getProbabilities()) {
YLanguage lang = YLanguage.byCode(language.lang);
if (language.prob > MINIMUM_PROBABILITY) {
return lang;
}
if (language.prob > MINIMUM_PROBABILITY_FROM_SET && possibleLanguages.contains(lang)) {
return lang;
}
}
return YLanguage.Undetermined;
}
}
代码示例来源:origin: pl.edu.icm.bwmeta/bwmeta-2-foreign-transformers
/**
* Finds the effective xml:lang value of an element (that is either from
* attribute on the element or inherited from some ancestor) and converts it to
* a {@link YLanguage} value.
* <p>
* XXX: generally useful?, move to some commons?
*
* @param e the element to determine the language for, or null
* @return lang value, <code>Undetermined</code> if there is none or e is null
*/
private YLanguage getYLang(Element e) {
String l = null;
while (l == null && e != null) {
l = e.getAttributeValue("lang", Namespace.XML_NAMESPACE);
e = e.getParentElement();
}
return YLanguage.byCode(l, YLanguage.Undetermined);
}
代码示例来源:origin: pl.edu.icm.yadda/yadda-analysis-impl
/**
* Finds the effective xml:lang value of an element (that is either from
* attribute on the element or inherited from some ancestor) and converts it to
* a {@link YLanguage} value.
* <p>
* XXX: generally useful?, move to some commons?
*
* @param e the element to determine the language for, or null
* @return lang value, <code>Undetermined</code> if there is none or e is null
*/
private YLanguage getYLang(org.jdom.Element e) {
String l = null;
while (l == null && e != null) {
l = e.getAttributeValue("lang", Namespace.XML_NAMESPACE);
e = e.getParentElement();
}
return YLanguage.byCode(l, YLanguage.Undetermined);
}
代码示例来源:origin: pl.edu.icm.synat/synat-portal-core
@Override
public List<LanguageData> getPreferedLanguagesBibliographicFormat(Locale locale) {
List<LanguageData> bibliographicLanguageData = new ArrayList<LanguageData>();
for (String language : preferedLanguages) {
bibliographicLanguageData.add(getLocalizedLanguage(YLanguage.byCode(language), locale));
}
Collections.sort(bibliographicLanguageData, new LanguageComparator(locale));
return bibliographicLanguageData;
}
代码示例来源:origin: pl.edu.icm.synat/synat-portal-core
@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;
}
代码示例来源:origin: pl.edu.icm.synat/synat-portal-core
@Override
public List<LanguageData> getAllLanguagesBibliographicFormat(Locale locale) {
List<LanguageData> bibliographicLanguageData = new ArrayList<LanguageData>();
for (String language : languageDictionary.getLangsAvailable()) {
bibliographicLanguageData.add(getLocalizedLanguage(YLanguage.byCode(language), locale));
}
Collections.sort(bibliographicLanguageData, new LanguageComparator(locale));
return bibliographicLanguageData;
}
代码示例来源:origin: pl.edu.icm.synat/synat-portal-core
private Collection<LanguageData> fetchAdditionalLanguagesFromConditions(List<AdvancedFormFieldCondition> conditions,
Locale locale) {
LinkedHashSet<LanguageData> additionalLanguages = new LinkedHashSet<LanguageData>();
for (AdvancedFormFieldCondition condition : conditions) {
if (condition.getFieldName().equals("language")) {
YLanguage additionalPreferredYLanguage = YLanguage.byCode((String) condition.getValue());
if (additionalPreferredYLanguage != null) {
additionalLanguages.add(languageService.getLocalizedLanguage(additionalPreferredYLanguage, locale));
}
}
}
return additionalLanguages;
}
代码示例来源:origin: pl.edu.icm.yadda.repowebeditor/repository-web-editor-core
private YName createYName(String language, String text, String type) {
YLanguage ylanguage = YLanguage.byCode(language, YLanguage.English);
YRichText yTitleText = yRichTextExtractor.extractFrom(text);
return new YName(ylanguage, yTitleText, type);
}
代码示例来源:origin: pl.edu.icm.synat/synat-portal-core
@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);
}
代码示例来源:origin: pl.edu.icm.synat/synat-portal-core
@RequestMapping(value = "/user/edit/language", method = RequestMethod.POST)
public View langugeEditSubmitHandler(HttpServletRequest request, @RequestParam("locale") String language) {
UserProfile loggedUserProfile = userBusinessService.getCurrentUserProfile();
String referer = request.getHeader("Referer");
if (loggedUserProfile != null) {
YLanguage yLanguage = YLanguage.byCode(language);
if (yLanguage != null) {
loggedUserProfile.setLanguage(new LanguageData(yLanguage));
userManagementService.updateCurrentUserProfile(loggedUserProfile);
} else {
logger.debug("Couldn't resolve language with code {}", language);
}
}
if (StringUtils.isNotEmpty(referer)) {
return new RedirectView(referer, false, true, false);
}
return new RedirectView(ViewConstants.USER_DASHBOARD, true, true, false);
}
代码示例来源:origin: pl.edu.icm.yadda.repowebeditor/repository-web-editor-core
private YDescription toYAbstract(LocalizedString abstractValue) {
YLanguage language = YLanguage.byCode(abstractValue.getLang(), YLanguage.English);
YRichText yAbstractText = yRichTextExtractor.extractFrom(abstractValue.getText());
YDescription description = new YDescription(language, yAbstractText, YConstants.DS_ABSTRACT);
return description;
}
代码示例来源:origin: pl.edu.icm.synat/synat-importer-direct
@Override
public void parseMetadata(YElement element, ContentMeta cm, YLanguage defaultLanguage) {
Map<YLanguage, YTagList> tags = new HashMap<YLanguage, YTagList>();
for (KeywordGroup kwd : cm.getKeywordGroup()) {
YLanguage yLanguage = YLanguage.byCode(kwd.getXmlLang(), defaultLanguage);
YTagList list = getTaglist(yLanguage, tags);
for (Keyword k : kwd.getKeyword()) {
if (StringUtils.isNotBlank(k.getContent())) {
list.addValue(k.getContent().trim());
}
}
}
for(YTagList tagList: tags.values()){
element.addTagList(tagList);
}
}
代码示例来源:origin: pl.edu.icm.yadda.repowebeditor/repository-web-editor-core
public YTagList createYTagList(TagsInfoViewObject keyword) {
YLanguage language = YLanguage.byCode(keyword.getLang(), YLanguage.English);
YTagList tagList = new YTagList(language, YConstants.TG_KEYWORD);
tagList.setValues(keyword.getTags());
return tagList;
}
代码示例来源:origin: pl.edu.icm.bwmeta/bwmeta-2-foreign-transformers
@Override
public YElement process(Book book, YElement parent, CrossrefIdGenerator generator) {
BookSeriesMetadata bookSeriesMetadata = book.getBookSeriesMetadata();
YElement element = new YElement();
if (StringUtils.isNotBlank(bookSeriesMetadata.getLanguage())) {
element.addLanguage(YLanguage.byCode(bookSeriesMetadata.getLanguage()));
}
SeriesMetadata seriesMetadata = bookSeriesMetadata.getSeriesMetadata();
extractSeriesMetadata(parent, generator, element, seriesMetadata);
return element;
}
代码示例来源:origin: pl.edu.icm.synat/synat-importer-direct
public List<YElement> create(PublicationMeta meta, String hierarchyId, YLanguage defaultLanguage, List<YElement> ancestors) {
List<YElement> elements = new ArrayList<YElement>();
List<YElement> localAncestors = new ArrayList<>(ancestors);
StructureBuilder builder = this.getSynchronized(builders::get, this::registerBuilder, hierarchyId);
for (YStructure structure = builder.build(meta, localAncestors); structure != null; structure = builder.build(meta, localAncestors)) {
YElement element = new YElement();
element.addStructure(structure);
elements.add(element);
Collection<PublicationMetadataParser> parsers = this.<String, Collection<PublicationMetadataParser>> getSynchronized(mappedParsers::get,
this::registerParsers, structure.getCurrent().getLevel());
for (PublicationMetadataParser parser : parsers) {
YLanguage pmLanguage = YLanguage.byCode(meta.getXmlLang(), defaultLanguage);
parser.parseMetadata(element, meta, pmLanguage, localAncestors);
}
localAncestors.add(element);
}
return elements;
}
代码示例来源:origin: pl.edu.icm.synat/synat-portal-core
private PortalCollection toPortalCollection(Collection key) {
PortalCollection collection = new PortalCollection();
collection.setId(key.getId());
collection.setName(key.getName());
final Locale locale = LocaleContextHolder.getLocale();
YLanguage language = YLanguage.byCode(locale.getLanguage());
final String description;
switch(language){
case Polish: description = key.getDescription(); break;
default:
description = key.getDescriptionEn();
}
collection.setDescription(description);
return collection;
}
代码示例来源:origin: pl.edu.icm.synat/synat-portal-core
@Override
@Cacheable("datasetTranslationResult")
public String getTranslation(String dataSetId, Locale locale, DictionaryDataTypes type) {
try {
YElement element = dataSetDictionary.getYElement(dataSetId);
for (YName name : element.getNames()) {
if (name.getLanguage() != null && name.getLanguage().equals(YLanguage.byCode(locale.getISO3Language()))) {
return name.getText();
}
}
final String name = YModelUtils.getDefaultName(element);
if (StringUtils.isNotEmpty(name)) {
return name;
}
} catch (NotFoundException e) {
return dataSetId;
}
return dataSetId;
}
代码示例来源:origin: pl.edu.icm.bwmeta/bwmeta-2-foreign-transformers
protected YDescription convert(Abstract abs) {
YDescription description = new YDescription();
if (StringUtils.isNotBlank(abs.getLang())) {
description.setLanguage(YLanguage.byCode(abs.getLang()));
}
final List<Part> parts;
if (!abs.getPS().isEmpty()) {
parts = convertToParts(abs.getPS());
} else if (!abs.getSecs().isEmpty()) {
parts = convertToParts(abs.getSecs());
} else {
return null;
}
YRichText richText = new YRichText(parts);
description.setText(richText);
return description;
}
代码示例来源:origin: pl.edu.icm.bwmeta/bwmeta-2-foreign-transformers
@Override
public YElement process(Book book, YElement parent, CrossrefIdGenerator generator) {
BookSetMetadata bookSetMetadata = book.getBookSetMetadata();
YElement element = new YElement();
SetMetadata setMetadata = bookSetMetadata.getSetMetadata();
List<YName> setNames = convertTitles(setMetadata.getTitles());
element.getIds().addAll(convertIsbns(setMetadata.getIsbns()));
element.getNames().addAll(setNames);
String id = generator.generateBookSetId(element.getFirstIdOrNullIfAny(IdSchemaIds.EXT_SCHEME_ISBN), getDefaultName(element));
element.setId(id);
element.addStructure(buildStructureFromParent(parent, HierarchyWithLevelIds.EXT_HIERARCHY_BOOK, HierarchyWithLevelIds.EXT_LEVEL_BOOK_SERIES));
if (StringUtils.isNotBlank(bookSetMetadata.getLanguage())) {
element.addLanguage(YLanguage.byCode(bookSetMetadata.getLanguage()));
}
return element;
}
内容来源于网络,如有侵权,请联系作者删除!