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

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

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

YStructure.getAncestors介绍

暂无

代码示例

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

private YAncestor getFirstNotVisitedAncestor(YStructure structure, Set<String> visitedElements) {
  final List<YAncestor> ancestors = structure.getAncestors();
  for (int ancestorIndex = ancestors.size() - 1; ancestorIndex >= 0; ancestorIndex--) {
    final YAncestor currentAncestor = ancestors.get(ancestorIndex);
    if (!visitedElements.contains(currentAncestor.getIdentity())) {
      return currentAncestor;
    }
  }
  return null;
}

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

private String findDoubledLevel(YElement element) {
  YStructure structure = element.getStructure(HierarchyWithLevelIds.EXT_HIERARCHY_JOURNAL);
  if (structure == null) {
    return null;
  }
  
  List<YAncestor> ancestors = structure.getAncestors();
  
  Set<String> existingLevels = new HashSet<String>();
  
  for (YAncestor yAncestor : ancestors) {
    String level = yAncestor.getLevel();
    if (level != null) {
      if (existingLevels.contains(level)) {
        return level;
      } else {
        existingLevels.add(level);
      }
    }
  }
  return null;
}

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

private Map<String, YDate> extractDatesFromHierarchy(final List<YStructure> structures) {
  Map<String, YDate> dates = new HashMap<>();
  for (final YStructure structure : structures) {
    for (final YAncestor ancestor : structure.getAncestors()) {
      dates.putAll(processYDates(ancestor.getDates()));
      if (HierarchyWithLevelIds.EXT_LEVEL_JOURNAL_YEAR.equals(ancestor.getLevel())) {
        dates.put("hierarchy", getDateFromYear(ancestor));
      }
    }
  }
  return dates;
}

代码示例来源:origin: pl.edu.icm.yadda.repowebeditor/repository-web-editor-core

private YAncestor setNonIssueAncestorsAndGetExisitingIssue(String issueId, YStructure journal) {
  YAncestor existingIssue = null;
  List<YAncestor> nonIssueAncestors = new ArrayList<>();
  for(YAncestor ancestor : journal.getAncestors()) {
    boolean isNotIssue = !ancestor.getLevel().equals(YConstants.EXT_LEVEL_JOURNAL_ISSUE);
    boolean isCurrentIssue = ancestor.getIdentity().equals(issueId);
    if(isNotIssue) {
      nonIssueAncestors.add(ancestor);
    } else if(isCurrentIssue) {
      existingIssue = ancestor;
    } else {
      // ignore/remove non current issues
    }
  }
  journal.setAncestors(nonIssueAncestors);
  return existingIssue;
}

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

public static Map<String, IdentifiersData> collectIdentifiers(YElement element) {
  Map<String, IdentifiersData> data = new HashMap<>();
  for (YStructure structure : element.getStructures()) {
    for (YAncestor ancestor : structure.getAncestors()) {
      if(SUPPORTRED_LEVELS.contains(ancestor.getLevel())){
        data.putAll(collectObjectIdentifiers(ancestor, ancestor.getLevel()));
      }
    }
  }
  data.putAll(collectObjectIdentifiers(element, StringUtils.EMPTY));
  return data;
}

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

private ThumbnailRef findThumbnailPathInAncestors(YElement element) {
  List<YStructure> yStructures = element.getStructures();
  for (YStructure yStructure : yStructures) {
    List<YAncestor> ancestors = Lists.reverse(yStructure.getAncestors());
    for (YAncestor yAncestor : ancestors) {
      ThumbnailRef thumbnailPath = findThumbnailPath(yAncestor, yAncestor.getIdentity());
      if (thumbnailPath != null) {
        return thumbnailPath;
      }
    }
  }
  return null;
}

代码示例来源:origin: pl.edu.icm.synat/synat-importer-direct

@Override
public YStructure build(PublicationMeta meta, List<YElement> ancestors) {
  if (isAlreadyBuilt(meta, ancestors)) {
    return null;
  }
  YStructure structure = new YStructure(getSupportedHierarchyId());
  YElement directAncestor = null;
  if (!ancestors.isEmpty()) {
    directAncestor = ancestors.get(ancestors.size() - 1);
    YStructure parentStructure = directAncestor.getStructure(getSupportedHierarchyId());
    structure.getAncestors().addAll(parentStructure.getAncestors());
    YAncestor ancestor = new YAncestor(structure.getHierarchy());
    ancestor.setLevel(getLevel(directAncestor));
    AncestorsManagement.copyDataToAncestor(directAncestor, ancestor);
    structure.getAncestors().add(ancestor);
  }
  structure.setCurrent(getCurrent(meta, directAncestor));
  return structure;
}

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

private static void replaceJournalNameField(final YElement yElement, final String[] values) {
  if (values != null && values.length > 0) {
  }
  final YStructure structure = yElement.getStructure(YConstants.EXT_HIERARCHY_JOURNAL);
  if (structure != null) {
    for (final YAncestor ancestor : structure.getAncestors()) {
      final String level = ancestor.getLevel();
      if (YConstants.EXT_LEVEL_JOURNAL_JOURNAL.equals(level)) {
        final String firstJournalName = values[0];
        ancestor.addName(new YName(null, firstJournalName, Y_TYPE_HIGHLIGHTED));
      }
    }
  }
}

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

for (YAncestor actAnc : actYStruct.getAncestors()) {
    String level = actAnc.getLevel();
    actAncMap.put(level, actAnc);
  for (YAncestor expAnc : expYStruct.getAncestors()) {
    String level = expAnc.getLevel();
    if (actAncMap.containsKey(level)) {
  for (YAncestor yanc : expYStruct.getAncestors()) {
    String level = yanc.getLevel();
    result.append(level, ResultStatus.FAILED, 1);
for (YAncestor yanc : actStructMap.get(hierarchy).getAncestors()) {
  String level = yanc.getLevel();
  result.append(level, ResultStatus.REDUNDANT, 1);

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

public List<String> getBasicIds(YElement elem) {
  ArrayList<String> ret = new ArrayList<String>();
  for (YAffiliation aff: elem.getAffiliations()) {
    if (aff.getIdentity()!=null && !aff.getIdentity().isEmpty()){
      ret.add(aff.getIdentity());
    }
  }
  for (YContributor cont : elem.getContributors()) {
    if (!cont.getIdentity().isEmpty()) {
      ret.add(cont.getIdentity());
    }
  }
  for (YStructure struct : elem.getStructures()) {
    for (YAncestor anc : struct.getAncestors()) {
      if (!anc.getIdentity().isEmpty()) {
        ret.add(anc.getIdentity());
      }
    }
  }
  return ret;
}

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

protected YStructure buildStructureFromParent(YElement parent, String hierarchy, String currentLevel) {
  YStructure structure = new YStructure(hierarchy);
  YCurrent current = new YCurrent(currentLevel);
  structure.setCurrent(current);
  if (parent != null) {
    YStructure parentStructure = parent.getStructure(hierarchy);
    structure.getAncestors().addAll(parentStructure.getAncestors());
    YAncestor ancestor = new YAncestor(parentStructure.getCurrent().getLevel(), parent.getId());
    ancestor.getNames().addAll(parent.getNames());
    ancestor.getIds().addAll(parent.getIds());
    structure.addAncestor(ancestor);
  }
  return structure;
}

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

private void tryToFixVolumes(DocumentRepository repository,
    Document document, YElement element) {
  List<YAncestor> ancestors = element.getStructure(HierarchyWithLevelIds.EXT_HIERARCHY_JOURNAL).getAncestors();
  YAncestor firstVolume = null;
  YAncestor secVolume = null;

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

@Override
public YElement process(Book book, YElement parent, CrossrefIdGenerator generator) {
  BookSeriesMetadata bookSeriesMetadata = book.getBookSeriesMetadata();
  String id = generator.generateBookVolumeId(parent.getId(), bookSeriesMetadata.getVolume());
  YElement element = new YElement();
  element.setId(id);
  element.addName(new YName(bookSeriesMetadata.getVolume()));
  YStructure structure = new YStructure(HierarchyWithLevelIds.EXT_HIERARCHY_BOOK);
  YCurrent current = new YCurrent(HierarchyWithLevelIds.EXT_LEVEL_BOOK_VOLUME);
  structure.setCurrent(current);
  structure.getAncestors().addAll(parent.getStructure(HierarchyWithLevelIds.EXT_HIERARCHY_BOOK).getAncestors());
  element.addStructure(structure);
  return element;
}

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

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;
}

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

List<YAncestor> ancestors = element.getStructure(HierarchyWithLevelIds.EXT_HIERARCHY_JOURNAL).getAncestors();

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

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;
}

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

/**
 * Creates an element in the hierarchy.
 *
 * @param level hierarchy for the element
 * @param level level for the element in the hierarchy
 * @param name name to use as the canonical name of the element
 * @param parent parent for the element in the hierarchy
 * @param id eudml id
 * @return the created element
 */
public YElement element(String hierarchy, String level, YName name, YElement parent, String id) {
  YStructure ps = parent==null ? null : parent.getStructure(hierarchy);
  YStructure struct = new YStructure(hierarchy).setCurrent(new YCurrent(level));
  List<String> issns = parent==null ? null : parent.getIds(IdSchemaIds.EXT_SCHEME_ISSN);
  String issn = (issns==null || issns.isEmpty()) ? null : issns.get(0);
  if (ps != null) {
    YAncestor ancestor = new YAncestor(ps.getCurrent().getLevel(), parent.getId()).addName(parent.getDefaultName());
    if (StringUtils.isNotEmpty(issn)) {
      ancestor.addId(new YId(IdSchemaIds.EXT_SCHEME_ISSN, issn));
    }
    struct.setAncestors(ps.getAncestors()).addAncestor(ancestor);
  }
  return new YElement(id).addName(name).addStructure(struct);
}

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

YStructure tmpStruct = new YStructure(HierarchyWithLevelIds.EXT_HIERARCHY_JOURNAL);
tmpStruct.setCurrent(new YCurrent(HierarchyWithLevelIds.EXT_LEVEL_JOURNAL_YEAR));
for (YAncestor a : struct.getAncestors()) {
  tmpStruct.addAncestor(a);
YStructure tmpStruct = new YStructure(HierarchyWithLevelIds.EXT_HIERARCHY_JOURNAL);
tmpStruct.setCurrent(new YCurrent(HierarchyWithLevelIds.EXT_LEVEL_JOURNAL_VOLUME));
for (YAncestor a : struct.getAncestors()) {
  tmpStruct.addAncestor(a);
YStructure tmpStruct = new YStructure(HierarchyWithLevelIds.EXT_HIERARCHY_JOURNAL);
tmpStruct.setCurrent(new YCurrent(HierarchyWithLevelIds.EXT_LEVEL_JOURNAL_ISSUE));
for (YAncestor a : struct.getAncestors()) {
  tmpStruct.addAncestor(a);

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

ancestor.addId(yISSN);
struct.setAncestors(ps.getAncestors()).addAncestor(ancestor);

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

/**
 * Creates an element in the hierarchy specified by the <code>hierarchy</code> property.
 *
 * @param level level for the element in the hierarchy
 * @param name name to use as the canonical name of the element
 * @param parent parent for the element in the hierarchy
 * @return the created element
 */
public YElement element(String level, YName name, YElement parent) {
  YStructure ps = parent.getStructure(getHierarchy());
  YStructure struct = new YStructure(getHierarchy()).setCurrent(new YCurrent(level));
  if (ps != null)
    struct
      .setAncestors(ps.getAncestors())
      .addAncestor(
        new YAncestor(ps.getCurrent().getLevel(), parent.getId())
          .addName(parent.getDefaultName()));

  return new YElement(
      generateId(EXT_PREFIX_ELEMENT, parent, name))
    .addName(name)
    .addStructure(struct);
}

相关文章