pl.edu.icm.model.bwmeta.y.YStructure.getAncestor()方法的使用及代码示例

x33g5p2x  于2022-02-05 转载在 其他  
字(15.7k)|赞(0)|评价(0)|浏览(123)

本文整理了Java中pl.edu.icm.model.bwmeta.y.YStructure.getAncestor()方法的一些代码示例,展示了YStructure.getAncestor()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YStructure.getAncestor()方法的具体详情如下:
包路径:pl.edu.icm.model.bwmeta.y.YStructure
类名称:YStructure
方法名:getAncestor

YStructure.getAncestor介绍

暂无

代码示例

代码示例来源:origin: pl.edu.icm.synat/synat-portal-core

private YAncestor getAncestor(YElement element, String hierarchy, String level) {
  YStructure structure = element.getStructure(hierarchy);
  if(structure == null){
    return null;
  }
  YAncestor ancestor = structure.getAncestor(level);
  return ancestor;
}

代码示例来源:origin: pl.edu.icm.bwmeta/bwmeta-2-foreign-transformers

private String getAncestorId(YStructure structure, String level) {
  YAncestor ancestor = structure.getAncestor(level);
  return ancestor == null ? null : ancestor.getIdentity();
}

代码示例来源:origin: pl.edu.icm.synat/synat-process-common

private void appendAncestorName(YStructure structure, Map<String, String> output, String level) {
  YAncestor ancestor = structure.getAncestor(level);
  if (ancestor != null && ancestor.getOneName()!=null ) {
    final String name = ancestor.getOneName().getText();
    if (StringUtils.isNotBlank(name)) {
      output.put(level, name);
    }
  }
}

代码示例来源:origin: pl.edu.icm.synat/synat-sdk-sample-services

private boolean isYearInYear(YElement element) {
    
  YStructure structure = element.getStructure(HierarchyWithLevelIds.EXT_HIERARCHY_JOURNAL);
  
  if (structure != null) {
    if (HierarchyWithLevelIds.EXT_LEVEL_JOURNAL_YEAR.equals(structure.getCurrent().getLevel())) {
      YAncestor ancestor = structure.getAncestor(HierarchyWithLevelIds.EXT_LEVEL_JOURNAL_YEAR);
      return ancestor != null;
    }
  }
  
  return false;
}

代码示例来源:origin: pl.edu.icm.synat/synat-portal-core

@Override
public List<PublisherData> preparePublisherData(final YElement yElement, final String role) {
  List<PublisherData> data = new LinkedList<>();
  BriefDataFactory bdf = new BriefDataFactory();
  for (YContributor ancestorContributor : yElement.getContributors()) {
    if (role.equals(ancestorContributor.getRole())) {
      data.add(bdf.createPublisherData(ancestorContributor));
    }
  }
  for (YStructure structure : yElement.getStructures()) {
    for (String level : Lists.reverse(Arrays.asList(StructureData.LEVELS_ALLOWED))) {
      if (structure.getAncestor(level) != null) {
        YAncestor publisher = structure.getAncestor(level);
        for (YContributor ancestorContributor : publisher.getContributors()) {
          if (role.equals(ancestorContributor.getRole())) {
            data.add(bdf.createPublisherData(ancestorContributor));
          }
        }
      }
    }
  }
  return data.stream().filter(element -> StringUtils.isNotBlank(element.getName())).collect(Collectors.toList());
}

代码示例来源:origin: pl.edu.icm.yadda/bwmeta-import

private String extracjIssnsFromArticle(List<YElement> yelements) {
  //System.out.println("[extracjIssnsFromArticle]");
  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 articles found in package of yelements!");
  }
  YElement article = articles.get(0);
  YStructure struct = article.getStructure(YConstants.EXT_HIERARCHY_JOURNAL);
  if (struct == null) {
    return null;
  }
  YAncestor ancest = struct.getAncestor(YConstants.EXT_LEVEL_JOURNAL_JOURNAL);
  if (ancest == null) {
    return null;
  }
  String issnsStr = extractIssnsStr(ancest.getIds());
  return issnsStr;
}

代码示例来源:origin: pl.edu.icm.yadda/bwmeta-import

private String extracjPublisherFromArticle(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 articles found in package of yelements!");
  }       
  YElement article = articles.get(0);
  
  YStructure struct = article.getStructure(YConstants.EXT_HIERARCHY_JOURNAL);
  if (struct == null) {
    return null;
  }
  YAncestor ancest = struct.getAncestor(YConstants.EXT_LEVEL_JOURNAL_PUBLISHER);
  if (ancest == null) {
    return null;
  }
  
  return YElementsParsingToolbox.removeEmptyValues(YElementsParsingToolbox.selectBestName(ancest.getNames()));
}

代码示例来源:origin: pl.edu.icm.synat/synat-portal-core

protected void fillVolumeAndIssue(HtmlMetaHeaders metadata, YStructure yJournalStructure) {
  YAncestor volumeAncestor = yJournalStructure.getAncestor(HierarchyWithLevelIds.EXT_LEVEL_JOURNAL_VOLUME);
  YAncestor issueAncestor = yJournalStructure.getAncestor(HierarchyWithLevelIds.EXT_LEVEL_JOURNAL_ISSUE);
  if (volumeAncestor != null && volumeAncestor.getOneName() != null) {
    metadata.addMetadataName(WP_ISSUE, volumeAncestor.getOneName().getText());
  }
  if (issueAncestor != null && issueAncestor.getOneName() != null) {
    metadata.addMetadataName(WP_VOLUME, issueAncestor.getOneName().getText());
  }
}

代码示例来源:origin: pl.edu.icm.synat/synat-portal-core

protected void fillJournalTitle(HtmlMetaHeaders metadata, YStructure yJournalStructure) {
  YAncestor journalAncestor = yJournalStructure.getAncestor(HierarchyWithLevelIds.EXT_LEVEL_JOURNAL_JOURNAL);
  if (journalAncestor != null && journalAncestor.getOneName() != null) {
    metadata.addMetadataName(WP_JOURNAL_TITLE, journalAncestor.getOneName().getText());
  }
}

代码示例来源:origin: pl.edu.icm.synat/synat-portal-core

private void fillBookTitle(HtmlMetaHeaders headers, YElement yElement) {
  YStructure booklStructure = yElement.getStructure(HierarchyWithLevelIds.EXT_HIERARCHY_BOOK);
  YAncestor bookAncestor = booklStructure.getAncestor(HierarchyWithLevelIds.EXT_LEVEL_BOOK_BOOK);
  if (bookAncestor != null) {
    headers.addMetadataName(WP_INBOOK_TITLE, bookAncestor.getOneName().getText());
  }
}

代码示例来源:origin: pl.edu.icm.yadda/bwmeta-import

YAncestor hier_journal_publisher = hier_journal.getAncestor(RepositoryStringConstants.HIERARCHY_JOURNAL_PUBLISHER);
if(hier_journal_publisher != null && hier_journal_publisher.getDefaultName()!=null){
  text.append("publisher:"+hier_journal_publisher.getDefaultName().getText()+YElementToZentralBlattConverter.SUGGESTED_MULTIVALUE_FIELD_SEPARATOR2);
YAncestor hier_journal_journal = hier_journal.getAncestor(RepositoryStringConstants.HIERARCHY_JOURNAL_JOURNAL);
if(hier_journal_journal != null && hier_journal_journal.getDefaultName()!=null){
  text.append("journal:"+hier_journal_journal.getDefaultName().getText()+YElementToZentralBlattConverter.SUGGESTED_MULTIVALUE_FIELD_SEPARATOR2);
YAncestor hier_journal_year = hier_journal.getAncestor(RepositoryStringConstants.HIERARCHY_JOURNAL_YEAR);
if(hier_journal_year != null && hier_journal_year.getDefaultName()!=null){
  text.append("journal_year:"+hier_journal_year.getDefaultName().getText()+YElementToZentralBlattConverter.SUGGESTED_MULTIVALUE_FIELD_SEPARATOR2);
YAncestor hier_journal_volume = hier_journal.getAncestor(RepositoryStringConstants.HIERARCHY_JOURNAL_VOLUME);
if(hier_journal_volume != null && hier_journal_volume.getDefaultName()!=null){
  text.append("journal_volume:"+hier_journal_volume.getDefaultName().getText()+YElementToZentralBlattConverter.SUGGESTED_MULTIVALUE_FIELD_SEPARATOR2);
YAncestor hier_journal_issue = hier_journal.getAncestor(RepositoryStringConstants.HIERARCHY_JOURNAL_ISSUE);
if(hier_journal_issue != null && hier_journal_issue.getDefaultName()!=null){
  text.append("journal_issue:"+hier_journal_issue.getDefaultName().getText()+YElementToZentralBlattConverter.SUGGESTED_MULTIVALUE_FIELD_SEPARATOR2);
YAncestor hier_journal_article = hier_journal.getAncestor(RepositoryStringConstants.HIERARCHY_JOURNAL_ARTICLE);
if(hier_journal_article != null && hier_journal_article.getPosition()!=null){
  if(hier_journal_article.getPosition().length()!=0)

代码示例来源:origin: pl.edu.icm.synat/synat-process-common

@Override
public boolean modify(YElement element) {
  if (element != null) {
    YStructure structure = element.getStructure(HierarchyWithLevelIds.EXT_HIERARCHY_JOURNAL);
    if (structure != null) {
      YAncestor journal = structure.getAncestor(HierarchyWithLevelIds.EXT_LEVEL_JOURNAL_JOURNAL);
      if (journal != null && StringUtils.isBlank(journal.getIdentity()) && journal.getOneName() != null ) {
        final String name = journal.getOneName().getText();
        final String journalId = resolveJournalId(name);
        if (journalId != null) {
          journal.setIdentity(journalId);
          Map<String,String> parameters = buildParameters(structure);
          Map<String,String> structureIds = indexSearchUtil.resolveStructureIds(journalId, parameters);
          if (MapUtils.isNotEmpty(structureIds)) {
            for (Map.Entry<String, String> entry : structureIds.entrySet()) {
              structure.getAncestor(entry.getKey()).setIdentity(entry.getValue());
            }
          }
          return true;
        }
      }
    }
  }
  return false;
}

代码示例来源:origin: pl.edu.icm.synat/synat-portal-core

public StructureData preparePublisher(YElement yElement) {
  for (YStructure structure : yElement.getStructures()) {
    YAncestor ancestor = structure.getAncestor(YaddaIdConstants.ID_LEVEL_JOURNAL_PUBLISHER);
    if (ancestor != null) {
      return new StructureData(ancestor.getIdentity(), YModelUtils.getDefaultName(ancestor));
    }
  }
  return new StructureData("", "");
}

代码示例来源:origin: pl.edu.icm.synat/synat-portal-core

final YAncestor ancestor = structure.getAncestor(HierarchyWithLevelIds.EXT_LEVEL_JOURNAL_JOURNAL);
if (ancestor == null) {
  logger.warn("No ancestor for element: " + yElement.getId());

代码示例来源:origin: pl.edu.icm.yadda/yadda-analysis-impl

YAncestor hier_journal_publisher = hier_journal.getAncestor(RepositoryStringConstants.HIERARCHY_JOURNAL_PUBLISHER);
if(hier_journal_publisher != null && hier_journal_publisher.getDefaultName()!=null){
  paos_doc.add(new PredicateAndObject(RelConstants.RL_PUBLISHER, hier_journal_publisher.getDefaultName().getText()));
YAncestor hier_journal_journal = hier_journal.getAncestor(RepositoryStringConstants.HIERARCHY_JOURNAL_JOURNAL);
if(hier_journal_journal != null && hier_journal_journal.getDefaultName()!=null){
  paos_doc.add(new PredicateAndObject(RelConstants.RL_JOURNAL, hier_journal_journal.getDefaultName().getText()));
YAncestor hier_journal_year = hier_journal.getAncestor(RepositoryStringConstants.HIERARCHY_JOURNAL_YEAR);
if(hier_journal_year != null && hier_journal_year.getDefaultName()!=null){
  paos_doc.add(new PredicateAndObject(RelConstants.RL_YEAR, hier_journal_year.getDefaultName().getText()));
YAncestor hier_journal_volume = hier_journal.getAncestor(RepositoryStringConstants.HIERARCHY_JOURNAL_VOLUME);
if(hier_journal_volume != null && hier_journal_volume.getDefaultName()!=null){
  paos_doc.add(new PredicateAndObject(RelConstants.RL_VOLUME, hier_journal_volume.getDefaultName().getText()));
YAncestor hier_journal_issue = hier_journal.getAncestor(RepositoryStringConstants.HIERARCHY_JOURNAL_ISSUE);
if(hier_journal_issue != null && hier_journal_issue.getDefaultName()!=null){
  paos_doc.add(new PredicateAndObject(RelConstants.RL_ISSUE, hier_journal_issue.getDefaultName().getText()));
YAncestor hier_journal_article = hier_journal.getAncestor(RepositoryStringConstants.HIERARCHY_JOURNAL_ARTICLE);
if(hier_journal_article != null && hier_journal_article.getPosition()!=null){
  if(hier_journal_article.getPosition().length()!=0) paos_doc.add(new PredicateAndObject(RelConstants.RL_PAGES, hier_journal_article.getPosition()));

代码示例来源:origin: pl.edu.icm.yadda/yadda-analysis-impl

YAncestor hier_journal_publisher = hier_journal.getAncestor(RepositoryStringConstants.HIERARCHY_JOURNAL_PUBLISHER);
if(hier_journal_publisher != null && hier_journal_publisher.getDefaultName()!=null){
  paos_doc.add(new PredicateAndObject(RelConstants.RL_PUBLISHER, hier_journal_publisher.getDefaultName().getText()));
YAncestor hier_journal_journal = hier_journal.getAncestor(RepositoryStringConstants.HIERARCHY_JOURNAL_JOURNAL);
if(hier_journal_journal != null && hier_journal_journal.getDefaultName()!=null){
  paos_doc.add(new PredicateAndObject(RelConstants.RL_JOURNAL, hier_journal_journal.getDefaultName().getText()));
YAncestor hier_journal_year = hier_journal.getAncestor(RepositoryStringConstants.HIERARCHY_JOURNAL_YEAR);
if(hier_journal_year != null && hier_journal_year.getDefaultName()!=null){
  paos_doc.add(new PredicateAndObject(RelConstants.RL_YEAR, hier_journal_year.getDefaultName().getText()));
YAncestor hier_journal_volume = hier_journal.getAncestor(RepositoryStringConstants.HIERARCHY_JOURNAL_VOLUME);
if(hier_journal_volume != null && hier_journal_volume.getDefaultName()!=null){
  paos_doc.add(new PredicateAndObject(RelConstants.RL_VOLUME, hier_journal_volume.getDefaultName().getText()));
YAncestor hier_journal_issue = hier_journal.getAncestor(RepositoryStringConstants.HIERARCHY_JOURNAL_ISSUE);
if(hier_journal_issue != null && hier_journal_issue.getDefaultName()!=null){
  paos_doc.add(new PredicateAndObject(RelConstants.RL_ISSUE, hier_journal_issue.getDefaultName().getText()));
YAncestor hier_journal_article = hier_journal.getAncestor(RepositoryStringConstants.HIERARCHY_JOURNAL_ARTICLE);
if(hier_journal_article != null && hier_journal_article.getPosition()!=null){
  if(hier_journal_article.getPosition().length()!=0) paos_doc.add(new PredicateAndObject(RelConstants.RL_PAGES, hier_journal_article.getPosition()));

代码示例来源:origin: pl.edu.icm.yadda/yaddaweb-lite-core

private String highlightedName(YElement element, ElementInfo elementInfo, InfoEntry entry) {
  String hlName = null;
  // try to get highlighted name
  YStructure struct = element.getStructure(elementInfo.getHierarchyId());
  if (struct != null) {
    YAncestor ancestor = struct.getAncestor(entry.getLevel());
    if (ancestor != null) {
      YName name = ancestor.getOneName(HighlightUtils.Y_TYPE_HIGHLIGHTED);
      if (!ancestor.getIdentity().equals(entry.getExtId())) {
        log.warn(
            "Different ancestor in YElement ({}) and infoService ({}). Highlight not performed.",
            ancestor.getIdentity(), entry.getExtId());
      } else if (name != null) {
        hlName = name.getText();
      }
    }
  }
  return hlName;
}

代码示例来源:origin: pl.edu.icm.synat/synat-portal-core

protected void fillIdentifiers(HtmlMetaHeaders metadata, YElement yElement) {
  YStructure yStructure = yElement.getStructure(YaddaIdConstants.ID_HIERARACHY_JOURNAL);
  if (yStructure != null) {
    YAncestor yAncestor = yStructure.getAncestor(YaddaIdConstants.ID_LEVEL_JOURNAL_JOURNAL);
    if (yAncestor != null) {
      for (YId journalYId : yAncestor.getIds()) {
        if (YaddaIdConstants.IDENTIFIER_CLASS_ISSN.equals(journalYId.getScheme())) {
          metadata.addMetadataName(DC_NAMESPACE + SEPARATOR + DublinCoreStrings.E_IDENTIFIER, "ISSN " + journalYId.getValue());
        }
      }
    }
  }
  for (YId yId : yElement.getIds()) {
    if (IdSchemaIds.EXT_SCHEME_DOI.equals(yId.getScheme())) {
      metadata.addMetadataName(DC_NAMESPACE + SEPARATOR + DublinCoreStrings.E_IDENTIFIER, "DOI " + yId.getValue());
    } else if (IdSchemaIds.EXT_SCHEME_ISBN.equals(yId.getScheme())) {
      metadata.addMetadataName(DC_NAMESPACE + SEPARATOR + DublinCoreStrings.E_IDENTIFIER, "ISBN " + yId.getValue());
    } else {
      metadata.addMetadataName(DC_NAMESPACE + SEPARATOR + DublinCoreStrings.E_IDENTIFIER, yId.getValue());
    }
  }
}

代码示例来源:origin: pl.edu.icm.synat/synat-portal-core

protected void fillPublicationDate(HtmlMetaHeaders metadata, YElement yElement) {
  for (YDate date : yElement.getDates()) {
    if (StringUtils.equals(DateTypes.DT_PUBLISHED, date.getType())) {
      String parsedDate = parseDate(date);
      if (parsedDate != null) {
        metadata.addMetadataName(WP_PUBLICATION_DATE, parseDate(date));
        return;
      }
    }
  }
  if (yElement.getStructure(HierarchyWithLevelIds.EXT_HIERARCHY_JOURNAL) != null) {
    YAncestor yAncestor = yElement.getStructure(HierarchyWithLevelIds.EXT_HIERARCHY_JOURNAL).getAncestor(HierarchyWithLevelIds.EXT_LEVEL_JOURNAL_YEAR);
    if (yAncestor != null && yAncestor.getOneName() != null) {
      metadata.addMetadataName(WP_PUBLICATION_DATE, yAncestor.getOneName().getText());
    }
  }
}

代码示例来源:origin: pl.edu.icm.yadda/yadda-content

final YAncestor journalAncestor = yStructure.getAncestor(YConstants.EXT_LEVEL_JOURNAL_JOURNAL);
if (journalAncestor != null) {
  final YName journalName = journalAncestor.getOneName(YConstants.NM_CANONICAL);
  docMetadata.setJournal(journalName == null ? null : journalName.getText());
final YAncestor volumeAncestor = yStructure.getAncestor(YConstants.EXT_LEVEL_JOURNAL_VOLUME);
if (volumeAncestor != null) {
  final YName volumeName = volumeAncestor.getOneName(YConstants.NM_CANONICAL);
  docMetadata.setVolume(volumeName == null ? null : volumeName.getText());
final YAncestor issueAncestor = yStructure.getAncestor(YConstants.EXT_LEVEL_JOURNAL_ISSUE);
if (issueAncestor != null) {
  final YName issueName = issueAncestor.getOneName(YConstants.NM_CANONICAL);

相关文章