@Override protected boolean enhanceMetadata(MatchResult result, YElement metadata) { metadata.addAttribute("ArticleID", result.group(1)); return true; } }
private void updatePartType(org.jdom.Element jElement, YElement yElement) { String partType = jElement.getAttributeValue("book-part-type"); if (partType != null) { yElement.addAttribute(NlmToYConstants.AT_NLM_BOOKPART_TYPE, partType); } } }
@Override protected boolean enhanceMetadata(MatchResult result, YElement metadata) { int first = Integer.parseInt(result.group(1)); int last = Integer.parseInt(result.group(2)); if (first <= last) { metadata.addAttribute("pages", first + "-" + last); return true; } else { return false; } }
@Override protected boolean enhanceMetadata(MatchResult result, YElement metadata) { int first = Integer.parseInt(result.group(1)); int last = Integer.parseInt(result.group(2)); if (first <= last) { metadata.addAttribute("pages", first + "-" + last); return true; } else { return false; } }
@Override protected boolean enhanceMetadata(BxZone zone, YElement metadata) { Matcher matcher = PATTERN.matcher(zone.toText()); boolean ret = false; while (matcher.find()) { String email = matcher.group().replaceFirst("[;\\.,]$", ""); metadata.addAttribute("email", email); ret = true; } return ret; }
private void prepareAttributes(Video video, YElement yElement) { yElement.addAttribute(SOURCE_YOUTUBE_VIDEO_ID, video.getId()); }
/** * Modifies input {@code element} {@code YElement} if {@code enrichedYElement} {@code YElement} * is enriched. The {@code YTagList} with {@code TagTypes.TG_KEYWORD}. * The {@code maxKeywords} is used to estimate {@code YTagList} {@code YTagList#getValues()} amount. * @param element, will be updated with classification. * @param enrichedYElement, should has classification. * @return {@code true} if meta data was modify * {@code false} otherwise. */ protected boolean modifyIfNeeded(YElement element, final YElement enrichedYElement) { if ( ! enrichedYElement.getTagLists(TG_SONCA_KEYWORDS).isEmpty()) { prepareKeywords(enrichedYElement, TG_SONCA_KEYWORDS, element, TagTypes.TG_KEYWORD); element.addAttribute(AT_CLASSIFICATION_OECD_BY, "Sonca"); return true; } return false; }
/** * Extracts <la> field from ZBL record. * * @param src * @param yelement */ private void updateArticleLA(ZentralBlattRecord src, YElement yelement) { if (src.hasField("la")) { String laText = src.getField("la").trim(); YAttribute attribute = new YAttribute(YConstants.AT_ZBL_LANG_DESCRIPTION, laText); yelement.addAttribute(attribute); } }
/** * Modifies input {@code element} {@code YElement} if {@code enrichedYElement} {@code YElement} * is enriched. The {@code YAttribute} is setup with {@code key} {@code AT_CLASSIFICATION_OECD_BY} * and {@code value} {@code "Sonca"}. * @param element, will be updated with classification. * @param enrichedYElement, should has classification. * @return {@code true} if meta data is modified * {@code false} otherwise. */ protected boolean modifyIfNeeded(YElement element, final YElement enrichedYElement) { if (hasClassification(enrichedYElement, SONCA_OECD_CLASSIFICATION_ID)) { changeCategoryRef(enrichedYElement, SONCA_OECD_CLASSIFICATION_ID, element, OECD_CLASSIFICATION); element.addAttribute(AT_CLASSIFICATION_OECD_BY, "Sonca"); return true; } return false; }
private void updateJournalZblFingerprint(org.jdom.Element jmeta, YElement journal) { // Try to update journal with zbl fingerprint try { org.jdom.Element jtitles = JDOMHelper.getChild(jmeta, "journal-title-group"); String journalAbbrev = JDOMHelper.getChildTextTrim(jtitles, "abbrev-journal-title"); String abrevType = JDOMHelper.getChild(jtitles, "abbrev-journal-title").getAttribute("abbrev-type").getValue().trim(); if ("short-title".equals(abrevType)) { journal.addAttribute(ZentrallBlatSpecificAttributeTypes.AT_ZBL_JOURNAL_FINGERPRINT, journalAbbrev); } } catch (Exception e) { } }
private void updateElementConference(org.jdom.Element jElement, YElement yElement) { Element conf = JDOMHelper.optDescendant(jElement, "conference"); if (conf != null) { Element confName = JDOMHelper.optDescendant(conf, "conf-name"); Element confDate = JDOMHelper.optDescendant(conf, "conf-date"); Element confNum = JDOMHelper.optDescendant(conf, "conf-num"); Element confLoc = JDOMHelper.optDescendant(conf, "conf-loc"); List<Element> confAcronyms = JDOMHelper.optChildren(conf, "conf-acronym"); if (confName != null) { yElement.addAttribute(NlmToYConstants.AT_CONF_NAME, JDOMHelper.textOfElement(confName)); } if (confDate != null) { yElement.addAttribute(NlmToYConstants.AT_CONF_DATE, JDOMHelper.textOfElement(confDate)); } if (confNum != null) { yElement.addAttribute(NlmToYConstants.AT_CONF_NUM, JDOMHelper.textOfElement(confNum)); } if (confLoc != null) { yElement.addAttribute(NlmToYConstants.AT_CONF_NUM, JDOMHelper.textOfElement(confLoc)); } for (Element confAcronym : confAcronyms) { yElement.addAttribute(NlmToYConstants.AT_CONF_ACRONYM, JDOMHelper.textOfElement(confAcronym)); } } }
private YElement prepareYElement(String id, Properties prop) { YElement yElement = new YElement(); yElement.setId(id); if (!prop.getProperty("title").isEmpty()) { yElement.addName(new YName(prepareProperty("title", prop))); } yElement.addDescription(new YDescription(YLanguage.Undetermined, prepareProperty("description", prop), DescriptionTypes.DS_SUMMARY)); if (!prop.getProperty("key-words").isEmpty()) { List<String> tags = new ArrayList<String>(Arrays.asList(prepareProperty("key-words", prop).split(","))); yElement.addTagList(new YTagList().setType(TagTypes.TG_KEYWORD).setValues(tags)); } if (!prop.getProperty("supplier").isEmpty()) { yElement.addAttribute("copyright-holder", prepareProperty("supplier", prop)); } if (!prop.getProperty("duration").isEmpty()) { yElement.addAttribute("duration", prepareProperty("duration", prop)); } yElement.addLanguage(YLanguage.Undetermined); return yElement; }
public void updateElementIds(org.jdom.Element ameta, YElement article, String idElementName) { List<org.jdom.Element> aids = JDOMHelper.getChildren(ameta, idElementName); for (org.jdom.Element aid : aids) { if ("eudml-id".equalsIgnoreCase(aid.getAttributeValue("pub-id-type"))) { article.addId(new YId(IdSchemaIds.EXT_SCHEMA_EUDML, aid.getTextTrim())); } else if ("doi".equalsIgnoreCase(aid.getAttributeValue("pub-id-type"))) { article.addId(new YId(IdSchemaIds.EXT_SCHEME_DOI, aid.getTextTrim())); } else if ("cedram-id".equalsIgnoreCase(aid.getAttributeValue("pub-id-type"))) { article.addId(new YId(IdSchemaIds.EXT_SCHEME_CEDRAM, aid.getTextTrim())); } else if ("gdz-id".equalsIgnoreCase(aid.getAttributeValue("pub-id-type"))) { article.addId(new YId("bwmeta1.id-class." + aid.getAttributeValue("pub-id-type"), aid.getTextTrim())); } else if ("dmlcz-id".equalsIgnoreCase(aid.getAttributeValue("pub-id-type"))) { article.addId(new YId("bwmeta1.id-class." + aid.getAttributeValue("pub-id-type"), aid.getTextTrim())); } else { article.addAttribute("bwmeta1.id-class." + aid.getAttributeValue("pub-id-type"), aid.getTextTrim()); } } }
private void updateJournalAids(org.jdom.Element jmeta, YElement journal) { List<org.jdom.Element> aids = JDOMHelper.getChildren(jmeta, "journal-id"); for (org.jdom.Element aid : aids) { String journalIdType = aid.getAttributeValue("journal-id-type"); String idVal = aid.getTextNormalize(); if ("eudml-id".equalsIgnoreCase(journalIdType)) { journal.addId(new YId(IdSchemaIds.EXT_SCHEMA_EUDML, idVal)); } else if ("doi".equalsIgnoreCase(journalIdType)) { journal.addId(new YId(IdSchemaIds.EXT_SCHEME_DOI, idVal)); } else if ("issn".equalsIgnoreCase(journalIdType)) { journal.addId(new YId(IdSchemaIds.EXT_SCHEME_ISSN, idVal)); } else if ("pubmed".equalsIgnoreCase(journalIdType)) { journal.addId(new YId(IdSchemaIds.EXT_SCHEME_PMID, idVal)); } else if ("cedram-id".equalsIgnoreCase(journalIdType)) { journal.addId(new YId(IdSchemaIds.EXT_SCHEME_CEDRAM, idVal)); }else { journal.addAttribute( journalIdType, idVal); } } } //?? do we need this?
private void updateReferencesFromMetadata(final CatalogInformationEnhancedObject<YExportable> result) throws CatalogException, TransformationException { final YExportable exportable = result.getObject(); if (exportable instanceof YElement) { final YElement element = (YElement) exportable; final IExportable iMetadata = dataSourcesFactory.getMetadataModelDataSource() .getMetadataModelExportable(id); final DocMetadata metadata = iMetadata instanceof DocMetadata ? (DocMetadata) iMetadata : null; if (metadata != null) { final List<DocReference> references = metadata.getReferences(); if (references != null && !references.isEmpty()) { final List<YRelation> relationsFromMetadata = toYRelations(references); element.setRelations(relationsFromMetadata); if (metadata.isTaggedWith(C_BIBREF_GEN)) { element.addAttribute(YConstants.AT_BIB_GEN, Boolean.TRUE.toString()); } } } } }
public static boolean sanitizeCategoryRefs(YElement article) { if (article == null || article.getCategoryRefs().isEmpty()) return false; boolean warning = false; List<YCategoryRef> cleanRefs = new ArrayList<YCategoryRef>(); for (YCategoryRef ref : article.getCategoryRefs()) { if (ref == null || ref.getCode() == null || ref.getCode().trim().isEmpty()) continue; ref.setCode(ref.getCode().trim()); List<YCategoryRef> refs = sanitizeCategoryRef(ref); warning = warning || isChanged(ref, refs); cleanRefs.addAll(refs); } article.setCategoryRefs(cleanRefs); if (!warning) return false; YAttribute attr = article.getOneAttribute(Warnings.WARNINGS); if (attr == null) { attr = new YAttribute(Warnings.WARNINGS, (String) null); article.addAttribute(attr); } if (attr.getOneAttribute(Warnings.WARNINGS_CHECK_CATEGORY_REFS) == null) attr.addAttribute(Warnings.WARNINGS_CHECK_CATEGORY_REFS, ""); return true; }
issue.addId(new YId(IdSchemaIds.EXT_SCHEME_CEDRAM, aid.getText())); ///TODO sprawdzic, gdzie to jest uzywane i we wszstkich tych miejscach trzeba to zmienic } else { issue.addAttribute(new YAttribute(aid.getAttributeValue("pub-id-type"), aid.getText()));
private boolean addMetadataIfNeeded(HarvestingResult harvestingResult, YElement element) { boolean metadataModified = false; if (shouldAbstractBeAdded(harvestingResult, element)) { Node htmlNode = new Node(BaseYModelUtils.XHTML_NAMESPACE, BaseYModelUtils.HTML_TAG); htmlNode.addPart(new Leaf(StringUtils.trim(harvestingResult.getDesciption()))); YRichText richText = new YRichText(Arrays.asList(htmlNode)); YDescription newAbstract = new YDescription(YLanguage.Undetermined, richText, DescriptionTypes.DS_ABSTRACT); element.addDescription(newAbstract); metadataModified = true; } if (shouldImpactFactorBeAdded(harvestingResult, element)) { element.addAttribute(new YAttribute(YModelUtils.IMPACT_FACTOR, harvestingResult.getImpactFactor().toEngineeringString())); metadataModified = true; } if (shouldFrequencyBeAdded(harvestingResult, element)) { element.addAttribute(new YAttribute(YModelUtils.FREQUENCY, harvestingResult.getFrequency())); metadataModified = true; } List<YCategoryRef> refs = element.getCategoryRefs(); if (shouldCategoryRefsBeAdded(harvestingResult, refs)) { refs.addAll(harvestingResult.getCategories()); metadataModified = true; } if (shouldTitlesBeAdded(harvestingResult, element)) { metadataModified |= addTitleHistory(harvestingResult.getOtherTitles(), element); } return metadataModified; }
yJournal.addAttribute(attribute); ancestor.addAttribute(attribute); updated = true;
element.addAttribute(CommonAttributeTypes.AT_CONTACT_LOCATION, eventMetadata.getConferenceLocation()); element.addAttribute(CommonAttributeTypes.AT_SEQUENCE_NUMBER, eventMetadata.getConferenceNumber()); element.addAttribute(CommonAttributeTypes.AT_ORG_NAME, sponsor); element.addAttribute(CommonAttributeTypes.AT_ORG_DIVISION, eventMetadata.getConferenceTheme());