public static String articlePosition(YElement element) { String position = null; YStructure anc = element.getStructure(YaddaIdConstants.ID_HIERARACHY_JOURNAL); if (anc != null) { YCurrent cAnc = anc.getCurrent(); if (cAnc != null && !StringUtils.isEmpty(cAnc.getPosition())) position = cAnc.getPosition(); } return position; }
@Deprecated private String getPosition(YElement element) { String position = null; for(YStructure structure : element.getStructures()) { YCurrent current = structure.getCurrent(); position = current.getPosition(); if(position != null) { break; } } return position; }
protected void fillJournalPages(HtmlMetaHeaders metadata, YStructure yJournalStructure) { YCurrent journalCurrent = yJournalStructure.getCurrent(); if (journalCurrent != null) { String position = journalCurrent.getPosition(); if (position.contains("-")) { metadata.addMetadataName(WP_FIRST_PAGE, position.substring(0, position.indexOf('-'))); if (position.indexOf('-') != position.length() - 1) { metadata.addMetadataName(WP_LAST_PAGE, position.substring(position.indexOf('-') + 1)); } } else if (StringUtils.isNotBlank(position)) { metadata.addMetadataName(WP_FIRST_PAGE, position); } } }
public String getPosition(YElement yElement){ YStructure structure = yElement.getStructure(YaddaIdConstants.ID_HIERARACHY_JOURNAL); YCurrent current = structure.getCurrent(); return current.getPosition(); }
@Override public String constructFieldValue(List<YElement> yelements) { List<YElement> articles = YElementsParsingToolbox.filterYElementsOfStructureLevel(yelements, YConstants.EXT_LEVEL_JOURNAL_ARTICLE); if (articles.size() == 0) { return null; } if (articles.size() > 1) { log.error("More than one article found in package of yelements!"); } YElement article = articles.get(0); YStructure structure = article.getStructure(YConstants.EXT_HIERARCHY_JOURNAL); if (structure == null) { return null; } YCurrent curr = structure.getCurrent(); if (curr == null) { return null; } return YElementsParsingToolbox.removeEmptyValues(curr.getPosition()); }
public static String pages(final YElement element) { final YCurrent current = yCurrentInJournalHierarchy(element); String result = current.getPosition(); if (StringUtils.isEmpty(result)) { // try to get it from description final String bibDesc = element.getOneAttributeSimpleValue("bibliographical.description"); if (StringUtils.isNotEmpty(bibDesc)) { final int[] position = PositionMatcher.match(bibDesc); if (position != null && position.length == 2) { if (position[0] == position[1]) { result = Integer.toString(position[0]); } else { result = position[0] + "-" + position[1]; } } else { final Pattern p = Pattern.compile("\\d"); final Matcher m = p.matcher(bibDesc); if (m.find()) { log.warn("Unable to extract pages from description ({}):{}", element.getId(), bibDesc); } } } } return result; }
private PositionExtractor getPosition(YElement element) { String position = null; List<YStructure> yStrictures = element.getStructures(); for(YStructure structure : yStrictures){ YCurrent current = structure.getCurrent(); position = current.getPosition(); if(position!=null){ break; } } return new PositionExtractor(position); }
@Override public void parseMetadata(YElement element, PublicationMeta pm, YLanguage defaultLanguage, List<YElement> ancestors) { String partNumber = element.getStructures().get(0).getCurrent().getPosition(); if(StringUtils.isNotBlank(partNumber)){ String id = ancestors.get(ancestors.size() - 1).getId() + "-p-" + partNumber; id = WileyUtils.processId(id); element.setId(id); } if (element.getNames().size() == 1) { YName name = YModelUtils.fetchDefaultName(element); if(StringUtils.equals(NameTypes.NM_ALTERNATIVE, name.getType()) && StringUtils.isNotBlank(partNumber)){ name.setText(BaseYModelUtils.buildRichText(name.getText() + StringUtils.SPACE + partNumber)); } name.setType(NameTypes.NM_CANONICAL); } }
private Map<String, AncestorData> extractHierarchy(YElement yElement) { Map<String, AncestorData> result = new HashMap<String, AncestorData>(); for (final String hierarhyId : YModelUtils.ALLOWED_HIERARCHY_ID) { YStructure yStructure = yElement.getStructure(hierarhyId); if (yStructure != null) { for (YAncestor ancestor : yStructure.getAncestors()) { if (ResourceDataConstants.MAP_ANCESTOR_TYPE_TO_LEVEL.containsValue(ancestor.getLevel())) { final YName ancestorName = ancestor.getOneName(); if (ancestorName != null) { result.put(ResourceDataConstants.MAP_ANCESTOR_TYPE_TO_LEVEL.inverse().get(ancestor.getLevel()), new AncestorData().setId(ancestor.getIdentity()).setName(ancestorName.getText())); } } } YCurrent current = yStructure.getCurrent(); if(current!=null && StringUtils.isNotBlank(current.getPosition())){ result.put(ResourceDataConstants.ANCESTOR_LEVEL_NAME_PAGES, new AncestorData().setName(current.getPosition())); } } } return result; }
if(ha != null && ha.getPosition()!=null){ if(ha.getPosition().length()!=0) text.append("journal_pages2:"+ha.getPosition());
private List<StructureData> prepareStructure(YElement yElement, String hierarchy, String[] levels, String... topLevelIds) { List<String> topLevels = Arrays.asList(topLevelIds); String topId = null; String topLevelId = null; List<StructureData> ancestors = new ArrayList<StructureData>(); final YStructure structure = yElement.getStructure(hierarchy); if (structure != null) { ListMultimap<String, YAncestor> mappedAncestors = getMappedAncestors(structure.getAncestors()); for (String level : levels) { final YAncestor ancestor = getAncestor(mappedAncestors, level); if (ancestor != null && ArrayUtils.contains(StructureData.LEVELS_ALLOWED, ancestor.getLevel())) { if (topLevels.contains(ancestor.getLevel())) { topId = ancestor.getIdentity(); topLevelId = ancestor.getLevel(); ancestors.add(new StructureData(ancestor.getIdentity(), YModelUtils.getDefaultName(ancestor), ancestor.getLevel(), topId, topLevelId)); } else { ancestors.add(new StructureData(ancestor.getIdentity(), IndexUtils.encodeNameValue(YModelUtils.getDefaultName(ancestor)), ancestor.getLevel(), topId, topLevelId)); } } } if (StringUtils.isNotBlank(structure.getCurrent().getPosition()) && ArrayUtils.contains(StructureData.ALLOWED_LEVELS_OF_CURRENT_POSITION, structure.getCurrent().getLevel())) { ancestors.add(new StructureData(null, structure.getCurrent().getPosition())); } } return ancestors; }
if(ha != null && ha.getPosition()!=null){ if(ha.getPosition().length()!=0) paos_doc.add(new PredicateAndObject(RelConstants.RL_PAGES, ha.getPosition()));
if(ha != null && ha.getPosition()!=null){ if(ha.getPosition().length()!=0) paos_doc.add(new PredicateAndObject(RelConstants.RL_PAGES, ha.getPosition()));
if(ha != null && ha.getPosition()!=null){ if(ha.getPosition().length()!=0) paos_doc.add(new PredicateAndObject(RelConstants.RL_PAGES, ha.getPosition()));
String pages = yElementJournalStructure.getCurrent().getPosition(); bibEntry.setField(BibEntry.FIELD_PAGES, pages);