private YAttribute extractEmailAttributes(PersonInfoViewObject personViewObject) { final String email = personViewObject.getEmail(); if(StringUtils.isNotBlank(email)) return new YAttribute(AttributeConstants.CONTACT_EMAIL, email); else return null; }
protected void addNotNullAttribute(AbstractA<?> element, String key, String value) { if (value == null) return; element.addAttribute(new YAttribute(key, value)); }
private void addDocumentTypeAttribute(String typeShortName, List<YAttribute> yAttributes) { DocumentType type = DocumentType.getTypeByShortName(typeShortName); yAttributes.add(new YAttribute(CS.DOCUMENT_TYPE, type.getShortName())); }
/** * Creates an attribute given its key and value. If the key or value is empty * or null, does not create an attribute but returns null. * * @param key attribute name * @param value attribute text value * @return created attribute, or null if either parameter was empty or null */ public YAttribute attribute(String key, String value) { if (empty(key) || empty(value)) return null; return new YAttribute(key, value); }
public static void updateYRelationWithZblNames(YRelation relye, YElement zblye) { for (YName n : zblye.getNames()) { YAttribute ya = new YAttribute(YConstants.AT_ENHANCED_FROM_ZBL_NAME, ""); ya.addAttribute(new YAttribute(YConstants.AT_ENHANCED_FROM_ZBL_LANGUAGE, n.getLanguage().getName())); ya.addAttribute(new YAttribute(YConstants.AT_ENHANCED_FROM_ZBL_TYPE, n.getType())); ya.addAttribute(new YAttribute(YConstants.AT_ENHANCED_FROM_ZBL_VALUE, n.getText())); relye.addAttribute(ya); } }
public static void updateYRelationWithZblTags(YRelation relye, YElement zblye) { for (YTagList tl : zblye.getTagLists()) { YAttribute ya = new YAttribute(YConstants.AT_ENHANCED_FROM_ZBL_TAG, ""); ya.addAttribute(new YAttribute(YConstants.AT_ENHANCED_FROM_ZBL_TYPE, tl.getType())); ya.addAttribute(new YAttribute(YConstants.AT_ENHANCED_FROM_ZBL_LANGUAGE, tl.getLanguage().getName())); for (String t : tl.getValues()) { ya.addAttribute(new YAttribute(YConstants.AT_ENHANCED_FROM_ZBL_VALUE, t)); } relye.addAttribute(ya); } }
public static void updateYRelationWithZblIds(YRelation relye, YElement zblye) { YAttribute ya = new YAttribute(YConstants.TG_CATEGORY, ""); for (YId i : zblye.getIds()) { if (i.getScheme().equals(YConstants.EXT_SCHEME_ISSN)) { ya.addAttribute(new YAttribute(YConstants.EXT_SCHEME_ISSN, i.getValue())); } else if (i.getScheme().equals(YConstants.EXT_SCHEME_ISBN)) { ya.addAttribute(new YAttribute(YConstants.EXT_SCHEME_ISBN, i.getValue())); } else if (i.getScheme().equals(YConstants.EXT_SCHEME_ZBL)) { ya.addAttribute(new YAttribute(YConstants.EXT_SCHEME_ZBL, i.getValue())); } else if (i.getScheme().equals(YConstants.EXT_SCHEME_ZBL)) { ya.addAttribute(new YAttribute(YConstants.EXT_SCHEME_ZBL, i.getValue())); } } relye.addAttribute(ya); }
/** * 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); } }
public static void updateYRelationWithZblClassificationCodes(YRelation relye, YElement zblye) { YAttribute ya; ya = new YAttribute(YConstants.TG_CATEGORY, ""); for (YCategoryRef r : zblye.getCategoryRefs()) { ya.addAttribute(new YAttribute(r.getClassification(), r.getCode())); } relye.addAttribute(ya); }
public YRelation parse(String text) { Node n = parser.parse(text); if (n == null) return null; if (!"citation".equals(n.getName())) throw new IllegalStateException("Unexpected node name"); YRelation yr = new YRelation(); yr.addAttribute(new YAttribute(YConstants.AT_REFERENCE_TEXT,text)); processReference(n, yr); return yr; }
private List<YAttribute> processAttributes(String key, Object value) { List<YAttribute> attributes = new ArrayList<>(); if(value instanceof String){ YAttribute attribute = new YAttribute(); attribute.setValue(value.toString()); attribute.setKey(key); attributes.add(attribute); } else if(value instanceof List){ for(Object object:((BasicDBList) value)){ attributes.addAll(processAttributes(key, object)); } } else if(value instanceof DBObject) { YAttribute attribute = getConverter().read(YAttribute.class, (DBObject) value); attribute.setKey(key); attributes.add(attribute); } return attributes; }
private static YAttribute extractOneReferenceTextAttributeScNode(YAttribute ya) { if(! ll.contains(ya.getKey())) return ya; for(Part p:ya.getRichValue().toParts()){ if(p instanceof Node){ if("sc".equals(((Node)p).getTag())) return new YAttribute(ya.getKey(),new YRichText(((Node)p).getParts().get(0).toString())); }else if(p instanceof Leaf) return new YAttribute(ya.getKey(),new YRichText(((Leaf)p).toPlainText())); } return ya; }
private static YAttribute extractOneReferenceTextAttributeScNode(YAttribute ya) { if(! ll.contains(ya.getKey())) return ya; for(Part p:ya.getRichValue().toParts()){ if(p instanceof Node){ if("sc".equals(((Node)p).getTag())) return new YAttribute(ya.getKey(),new YRichText(((Node)p).getParts().get(0).toString())); }else if(p instanceof Leaf) // if(p.toPlainText()!=null && !p.toPlainText().matches("[\\s]+")) return new YAttribute(ya.getKey(),new YRichText(((Leaf)p).toPlainText())); } return ya; } }
@Override public DataResponse apply(YElement input) { ZipFile zipFile = processorState.getZipFile(); ZipEntry lastEntry = processorState.getLastZipEntry(); YAttribute attribute = new YAttribute(CommonExtractorContstants.SOURCE_ATTRIBUTE, zipFile.getName() + "/" + lastEntry.getName()); input.getAttributes().add(attribute); DataResponse dataResponse = new DataResponse(input, dataResponseQualityComparator); for (YContentFile file : createIterable(input.getContents())) { String id = file.getId(); String fileName = file.getLocations().get(0); ZipEntry entry = zipFile.getEntry(fileName); if (entry != null) { dataResponse.addContent(id, new ZipEntryResource(zipFile.getName(), entry)); } } if(insertSource){ dataResponse.addContent(CommonExtractorContstants.SOURCE_ATTRIBUTE, new ZipEntryResource(zipFile.getName(), lastEntry)); } return dataResponse; }
@SuppressWarnings("deprecation") public static void updateYRelationWithZblContributor(YRelation relye, YContributor c) { YAttribute ya = null; if (c.getOneName("canonical") != null) ya = new YAttribute(YConstants.AT_REFERENCE_PARSED_AUTHOR, c.getOneName("canonical").getText().toString()); if (c.getAttributes(YConstants.AT_ZBL_AUTHOR_FINGERPRINT).size() > 0) ya.addAttribute(YConstants.AT_ZBL_AUTHOR_FINGERPRINT, c.getAttributes(YConstants.AT_ZBL_AUTHOR_FINGERPRINT) .get(0).getValue()); if (c.getOneName("forenames") != null) ya.addAttribute(YConstants.AT_REFERENCE_PARSED_AUTHOR_FORENAMES, c.getOneName("forenames").getText() .toString()); ya.addAttribute(YConstants.AT_REFERENCE_PARSED_AUTHOR_SURNAME, c.getOneName("surname").getText().toString()); relye.addAttribute(ya); }
soData.jrnlFingerprint); attribute = new YAttribute(YConstants.AT_ZBL_JOURNAL_FINGERPRINT, seData.jrnlFingerprint); } else if (soFingerprint) { attribute = new YAttribute(YConstants.AT_ZBL_JOURNAL_FINGERPRINT, soData.jrnlFingerprint); } else { // seFingerprint attribute = new YAttribute(YConstants.AT_ZBL_JOURNAL_FINGERPRINT, seData.jrnlFingerprint);
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; }
String fingerprint = ai[i].trim(); if (fingerprint.length() > 1) { // e.g. "-" is filtered YAttribute attribute = new YAttribute(YConstants.AT_ZBL_AUTHOR_FINGERPRINT, fingerprint); ycontributor.addAttribute(attribute); updated = 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; }