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; }
private String getAncestorId(YStructure structure, String level) { YAncestor ancestor = structure.getAncestor(level); return ancestor == null ? null : ancestor.getIdentity(); }
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; }
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; }
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; }
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; }
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("", ""); }
if (changeElementLevel(repository, secVolume.getIdentity())) { secVolume.setLevel(HierarchyWithLevelIds.EXT_LEVEL_JOURNAL_ISSUE); saveDocumentWithElement(repository, document, element);
return ViewConstants.REDIRECT_MAIN_PAGE; final String id = ancestor.getIdentity(); final String url = "/resource/" + id + "/tab/jContent/facet"; StringBuilder field = new StringBuilder();
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; }
String ancestorId = yAnc.getIdentity(); YElement ancestorElement = null; try {
private void createAllAncestorsInHierarchy(final String hierarchyId, final YElement element, final List<YElement> ancestors, Set<String> visitedElements) { visitedElements.add(element.getId()); final YStructure structure = element.getStructure(hierarchyId); if (structure == null) { return; } final YAncestor ancestor = getFirstNotVisitedAncestor(structure, visitedElements); if (ancestor != null) { try { final String ancestorExtId = ancestor.getIdentity(); final YElement ancestorElement = dataSourcesFactory.getYSourceFactory().getYSource() .getElementById(ancestorExtId); if (ancestorElement == null) { log.error("doesn't find source for ancestor; elementId = " + element.getId()); return; } if (notInLevelToSkip(ancestor)) { ancestors.add(ancestorElement); } createAllAncestorsInHierarchy(hierarchyId, ancestorElement, ancestors, visitedElements); } catch (final ModelDataSourceException e) { log.error(e.toString()); } } return; }
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; }
YElement ancElement = fetchElement(repository, yAncestor.getIdentity()); YStructure structure = ancElement.getStructure(HierarchyWithLevelIds.EXT_HIERARCHY_JOURNAL); String ancLevel = structure.getCurrent().getLevel();
@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; }
final YAncestor parent = yStructure.getParent(); if (ancestorList.isEmpty()) { final ElementAncestors<YElement> parentWithAncestors = getElementWithAncestors(parent.getIdentity ()); final Ancestors parentAncestors = parentWithAncestors.getAncestors();
private void updateCommonFromAncestor(PublicationDownload download, YAncestor ancestor) { download.setDoi(getId(ancestor, IdSchemaIds.EXT_SCHEME_DOI)); download.setIssn(getId(ancestor, IdSchemaIds.EXT_SCHEME_ISSN)); download.setEissn(getId(ancestor, IdSchemaIds.EXT_SCHEME_EISSN)); download.setBwmetaId(ancestor.getIdentity()); download.setName(ancestor.getDefaultName().getText()); }
final YAncestor parent = yStructure.getParent(); final ElementAncestors<YElement> parentWithAncestors = getElementWithAncestors(parent.getIdentity()); final Ancestors parentAncestors = parentWithAncestors.getAncestors(); List<Ancestor> ancestorList = parentAncestors.getAncestorsOfHierarchy(YConstants.EXT_HIERARCHY_JOURNAL);