@Override public boolean hasChapteredContent(YElement element) { if (element.getContents() != null) { return hasChapteredContent(element.getContents()); } return false; }
@Override public boolean isContentAvailable(YElement yElement) { String mainLevel = fetchCurrentStructureLevel(yElement); if (yElement.getContents() != null && !yElement.getContents().isEmpty()) { return checkContentAvailable(yElement.getContents(), mainLevel); } return false; }
public void convertContentLocations(YExportable entity) { if (!(entity instanceof YElement)) { return; } YElement element = (YElement) entity; for (YContentEntry<?> entry : element.getContents()) { convertContentLocations(entry); } }
private boolean checkIfContentPresent(final YElement yElement, final String fileId) { for (YContentEntry<?> content : yElement.getContents()) { if (content instanceof YContentFile) { if (StringUtils.equals(((YContentFile) content).getId(), fileId)) { return true; } } } return false; }
private void prepareCover(YElement element, String location, String mimeType, String fileId) { List<String> locations = new ArrayList<String>(); locations.add(fileId); locations.add(location); YContentFile newCover = new YContentFile(fileId, FileTypes.FT_COVER, mimeType, locations); element.getContents().add(newCover); }
public static void processYContents(YElement element, Predicate<YContentEntry<?>> shouldDeletePredicate) { if (element == null) { return; } processYContents(element.getContents(), shouldDeletePredicate); }
@Override public List<ContentEntryData> translateContentList(YElement element, Locale locale) { final String mainLevel = yModelPropertyExtractor.fetchCurrentStructureLevel(element); if (element.getContents() != null) { return translateContent(element.getContents(), locale, mainLevel); } else { return new ArrayList<ContentEntryData>(); } }
public void convertContentLocations(YExportable entity) { if (!(entity instanceof YElement)) { return; } YElement element = (YElement) entity; for (YContentEntry<?> entry : element.getContents()) { convertContentLocations(entry); } }
private Map<String, YContentFile> scanForFulltextFiles(YElement yElement, String... fileFormats) { Set<String> formats = Sets.newHashSet(fileFormats); return scanForFulltextFiles(yElement.getContents(), formats); }
@Override public List<ContentChapterData> translateContentChapters(YElement element, Locale locale) { final String mainLevel = yModelPropertyExtractor.fetchCurrentStructureLevel(element); if (element.getContents() != null) { return transformChaptersContent(findChapters(element.getContents(), locale), locale, mainLevel); } else { return new ArrayList<ContentChapterData>(); } }
/** * For Pionier video stream we must put stream url instead of video id in youtube case. * @param model, {@code COMP_VIDEO_PLAYER} and {@code COMP_VIDEO_FORMAT} will be put. * @param yElement, {@code YElement.getContents()} is used for model fill up. */ public void prepareVideoAttributes(Model model, YElement yElement) { final String videoId = prepareVideoId(yElement.getContents()); final String videoFormat = prepareVideoFormat(yElement.getContents()); if ("pionierFormat".equals(videoFormat)) { model.addAttribute(COMP_VIDEO_PLAYER, preparePionierStreamUrl(videoId)); } else { model.addAttribute(COMP_VIDEO_PLAYER, videoId); } model.addAttribute(COMP_VIDEO_FORMAT, videoFormat); }
protected void fillFormats(YElement yElement, List<YExportable> referedElements, Map<String, List<StringWithAttributes>> ret) { // format element for (YContentEntry<?> yContentEntry : yElement.getContents()) { if (yContentEntry.isFile()) { if (!ret.containsKey(E_FORMAT)) { ret.put(E_FORMAT, new ArrayList<StringWithAttributes>()); } ret.get(E_FORMAT).add(new StringWithAttributes(((YContentFile) yContentEntry).getFormat())); } } }
protected String resolveCoverUrl(YElement element) { for (YContentEntry e : element.getContents()) { if (e.isFile()) { YContentFile cFile = (YContentFile) e; String location = cFile.getLocations().get(0); if (location != null && ((cFile.getType() != null && cFile.getType().equals("cover") || anyContentAsCover))) { return "download/" + location.replace("yar://", ""); } } } return null; }
private boolean isLicensedContent(ElementMetadata elementMetadata, String contentPath) { YElement yElement = (YElement) elementMetadata.getContent(); for (YContentEntry<?> entry : yElement.getContents()) { if (entry.isFile()) { YContentFile contentFile = (YContentFile) entry; if (contentFile.getLocations().contains(contentPath) && notLicensedContentTypes != null && notLicensedContentTypes.contains(contentFile.getType())) { return false; } } } return true; }
@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); List<YContentEntry> contents = article.getContents(); String fullTextLocation = findLocationOfContentLink(contents, YConstants.FT_FULL_TEXT); if (fullTextLocation != null && fullTextLocation.length() > 0) { return YElementsParsingToolbox.removeEmptyValues(fullTextLocation); } return YElementsParsingToolbox.removeEmptyValues(findLocationOfContentLink(contents, YConstants.FT_PLAIN_TEXT)); }
public static List<FilteredContentEntry<?>> fetchPlainTextContentEntries(YElement element) { ContentBrowser contentBrowser = new ContentBrowser(); HasFilesContentFilter filter = new PlainTextContentFilter(); return contentBrowser.filter(element.getContents(), filter); }
protected void fillFormats(HtmlMetaHeaders metadata, YElement yElement) { for (YContentEntry<?> yContentEntry : yElement.getContents()) { if (yContentEntry.isFile()) { YContentFile yContentFile = (YContentFile) yContentEntry; metadata.addMetadataName(DC_NAMESPACE + SEPARATOR + DublinCoreStrings.E_FORMAT, yContentFile.getFormat()); } } }
public static boolean hasPlainTextContentEntries(YElement element) { ContentBrowser contentBrowser = new ContentBrowser(); HasFilesContentFilter filter = new PlainTextContentFilter(); contentBrowser.filter(element.getContents(), filter); return filter.hasFiles(); }
@Override public void parseMetadata(YElement element, PublicationMeta pm, YLanguage defaultLanguage, List<YElement> ancestors) { if (pm.getLinkGroup() != null) { pm.getXmlLang(); for (Link link : pm.getLinkGroup().getLink()) { switch (link.getType()) { case "toTypesetVersion": element.getContents().add(getContentFile(link)); continue; default: LOGGER.info("Unknown link type: " + link.getType()); } } } }
@SuppressWarnings("rawtypes") public Mets transform(YElement yElement) { List<YContentEntry> contents = yElement.getContents(); Mets mets = new Mets(); FileSec fileSec = new FileSec(); mets.setFileSec(fileSec); FileGrp mainFileGroup = new FileGrp(); mainFileGroup.setID("main"); extractContents(yElement.getId(), contents, mainFileGroup); fileSec.getFileGrps().add(mainFileGroup); mets.setID(yElement.getId()); String label = prepareLabel(yElement); mets.setLABEL(label); addDCMetadata(mets.getDmdSecs(), yElement); addBwmeta(mets.getDmdSecs(), yElement); return mets; }