Search in sources :

Example 1 with MCRTileJob

use of org.mycore.iview2.services.MCRTileJob in project mycore by MyCoRe-Org.

the class MCRIView2Commands method tileImage.

/**
 * Tiles this {@link MCRPath}
 */
public static void tileImage(MCRPath file) throws IOException {
    if (MCRIView2Tools.isFileSupported(file)) {
        MCRTileJob job = new MCRTileJob();
        job.setDerivate(file.getOwner());
        job.setPath(file.getOwnerRelativePath());
        MCRTilingQueue.getInstance().offer(job);
        LOGGER.info("Added to TilingQueue: {}", file);
        startMasterTilingThread();
    }
}
Also used : MCRTileJob(org.mycore.iview2.services.MCRTileJob)

Example 2 with MCRTileJob

use of org.mycore.iview2.services.MCRTileJob in project mycore by MyCoRe-Org.

the class MCRIView2Commands method tileImage.

/**
 * Tiles this image.
 * @param derivate derivate ID
 * @param absoluteImagePath absolute path to image file
 */
@MCRCommand(syntax = TILE_IMAGE_COMMAND_SYNTAX, help = "tiles a specific file identified by its derivate {0} and absolute path {1}", order = 70)
public static void tileImage(String derivate, String absoluteImagePath) {
    MCRTileJob job = new MCRTileJob();
    job.setDerivate(derivate);
    job.setPath(absoluteImagePath);
    MCRTilingQueue.getInstance().offer(job);
    startMasterTilingThread();
}
Also used : MCRTileJob(org.mycore.iview2.services.MCRTileJob) MCRCommand(org.mycore.frontend.cli.annotation.MCRCommand)

Example 3 with MCRTileJob

use of org.mycore.iview2.services.MCRTileJob in project mycore by MyCoRe-Org.

the class MCRIView2Commands method fixDeadEntries.

@MCRCommand(syntax = "fix dead tile jobs", help = "Deletes entries for files which dont exist anymore!")
public static void fixDeadEntries() {
    EntityManager em = MCREntityManagerProvider.getCurrentEntityManager();
    TypedQuery<MCRTileJob> allTileJobQuery = em.createNamedQuery("MCRTileJob.all", MCRTileJob.class);
    List<MCRTileJob> tiles = allTileJobQuery.getResultList();
    tiles.stream().filter(tj -> {
        MCRPath path = MCRPath.getPath(tj.getDerivate(), tj.getPath());
        return !Files.exists(path);
    }).peek(tj -> LOGGER.info("Delete TileJob {}:{}", tj.getDerivate(), tj.getPath())).forEach(em::remove);
}
Also used : MCRIView2Tools(org.mycore.iview2.services.MCRIView2Tools) Enumeration(java.util.Enumeration) TypedQuery(javax.persistence.TypedQuery) MCRException(org.mycore.common.MCRException) MessageFormat(java.text.MessageFormat) ArrayList(java.util.ArrayList) MCRRecursiveDeleter(org.mycore.datamodel.niofs.utils.MCRRecursiveDeleter) DirectoryStream(java.nio.file.DirectoryStream) JDOMException(org.jdom2.JDOMException) MCRImage(org.mycore.imagetiler.MCRImage) MCRTileJob(org.mycore.iview2.services.MCRTileJob) MCRXMLMetadataManager(org.mycore.datamodel.common.MCRXMLMetadataManager) MCRTiledPictureProps(org.mycore.imagetiler.MCRTiledPictureProps) ZipFile(java.util.zip.ZipFile) MCRCommandGroup(org.mycore.frontend.cli.annotation.MCRCommandGroup) Path(java.nio.file.Path) ZipEntry(java.util.zip.ZipEntry) SimpleFileVisitor(java.nio.file.SimpleFileVisitor) MCRMetadataManager(org.mycore.datamodel.metadata.MCRMetadataManager) MCRTilingQueue(org.mycore.iview2.services.MCRTilingQueue) ImageReader(javax.imageio.ImageReader) BufferedImage(java.awt.image.BufferedImage) Files(java.nio.file.Files) MCRAbstractCommands(org.mycore.frontend.cli.MCRAbstractCommands) MCRPath(org.mycore.datamodel.niofs.MCRPath) MCRImageTiler(org.mycore.iview2.services.MCRImageTiler) IOException(java.io.IOException) EntityManager(javax.persistence.EntityManager) FileSystem(java.nio.file.FileSystem) BasicFileAttributes(java.nio.file.attribute.BasicFileAttributes) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) TimeUnit(java.util.concurrent.TimeUnit) MCREntityManagerProvider(org.mycore.backend.jpa.MCREntityManagerProvider) FileVisitResult(java.nio.file.FileVisitResult) List(java.util.List) Logger(org.apache.logging.log4j.Logger) MCRCommand(org.mycore.frontend.cli.annotation.MCRCommand) MCRObjectID(org.mycore.datamodel.metadata.MCRObjectID) CRC32(java.util.zip.CRC32) LogManager(org.apache.logging.log4j.LogManager) InputStream(java.io.InputStream) EntityManager(javax.persistence.EntityManager) FileSystem(java.nio.file.FileSystem) MCRTileJob(org.mycore.iview2.services.MCRTileJob) MCRPath(org.mycore.datamodel.niofs.MCRPath) MCRCommand(org.mycore.frontend.cli.annotation.MCRCommand)

Example 4 with MCRTileJob

use of org.mycore.iview2.services.MCRTileJob in project mycore by MyCoRe-Org.

the class MCRMigrationCommands method fixMCR1717.

@MCRCommand(syntax = "fix MCR-1717", help = "Fixes wrong entries in tile job table (see MCR-1717 comments)")
public static void fixMCR1717() {
    EntityManager em = MCREntityManagerProvider.getCurrentEntityManager();
    TypedQuery<MCRTileJob> allTileJobQuery = em.createNamedQuery("MCRTileJob.all", MCRTileJob.class);
    List<MCRTileJob> tiles = allTileJobQuery.getResultList();
    tiles.stream().filter(tj -> !tj.getPath().startsWith("/")).peek(tj -> LOGGER.info("Fixing TileJob {}:{}", tj.getDerivate(), tj.getPath())).forEach(tj -> {
        String newPath = "/" + tj.getPath();
        tj.setPath(newPath);
    });
}
Also used : MCRObjectService(org.mycore.datamodel.metadata.MCRObjectService) Date(java.util.Date) URISyntaxException(java.net.URISyntaxException) MCRObjectStructure(org.mycore.datamodel.metadata.MCRObjectStructure) MCRDerivate(org.mycore.datamodel.metadata.MCRDerivate) MCRDNBURN(org.mycore.pi.urn.MCRDNBURN) Document(org.jdom2.Document) MCRPI(org.mycore.pi.backend.MCRPI) JDOMException(org.jdom2.JDOMException) MCRTileJob(org.mycore.iview2.services.MCRTileJob) CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) MCRXMLMetadataManager(org.mycore.datamodel.common.MCRXMLMetadataManager) Path(java.nio.file.Path) MCRMetadataManager(org.mycore.datamodel.metadata.MCRMetadataManager) CriteriaQuery(javax.persistence.criteria.CriteriaQuery) MCRLinkTableManager(org.mycore.datamodel.common.MCRLinkTableManager) MCRPath(org.mycore.datamodel.niofs.MCRPath) Collection(java.util.Collection) MCRPersistenceException(org.mycore.common.MCRPersistenceException) XPathExpression(org.jdom2.xpath.XPathExpression) MCREntityManagerProvider(org.mycore.backend.jpa.MCREntityManagerProvider) MCRVersionedMetadata(org.mycore.datamodel.ifs2.MCRVersionedMetadata) List(java.util.List) Stream(java.util.stream.Stream) Logger(org.apache.logging.log4j.Logger) MCRCommand(org.mycore.frontend.cli.annotation.MCRCommand) MCRObjectID(org.mycore.datamodel.metadata.MCRObjectID) SAXException(org.xml.sax.SAXException) Optional(java.util.Optional) MCRActiveLinkException(org.mycore.datamodel.common.MCRActiveLinkException) MCRDNBURNParser(org.mycore.pi.urn.MCRDNBURNParser) MCRMetaLinkID(org.mycore.datamodel.metadata.MCRMetaLinkID) Element(org.jdom2.Element) MCRBase(org.mycore.datamodel.metadata.MCRBase) MCRLINKHREF(org.mycore.backend.jpa.links.MCRLINKHREF) XPathFactory(org.jdom2.xpath.XPathFactory) MCRConstants(org.mycore.common.MCRConstants) TypedQuery(javax.persistence.TypedQuery) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) MCRLINKHREFPK_(org.mycore.backend.jpa.links.MCRLINKHREFPK_) MCRXMLFunctions(org.mycore.common.xml.MCRXMLFunctions) MCRMetaDerivateLink(org.mycore.datamodel.metadata.MCRMetaDerivateLink) MCRCommandGroup(org.mycore.frontend.cli.annotation.MCRCommandGroup) MCRAccessException(org.mycore.access.MCRAccessException) Root(javax.persistence.criteria.Root) MCRMetadataVersion(org.mycore.datamodel.ifs2.MCRMetadataVersion) Files(java.nio.file.Files) IOException(java.io.IOException) MCRLINKHREF_(org.mycore.backend.jpa.links.MCRLINKHREF_) EntityManager(javax.persistence.EntityManager) Paths(java.nio.file.Paths) EntityTransaction(javax.persistence.EntityTransaction) MCRSessionMgr(org.mycore.common.MCRSessionMgr) MCRObject(org.mycore.datamodel.metadata.MCRObject) LogManager(org.apache.logging.log4j.LogManager) Filters(org.jdom2.filter.Filters) EntityManager(javax.persistence.EntityManager) MCRTileJob(org.mycore.iview2.services.MCRTileJob) MCRCommand(org.mycore.frontend.cli.annotation.MCRCommand)

Aggregations

MCRTileJob (org.mycore.iview2.services.MCRTileJob)3 IOException (java.io.IOException)2 Files (java.nio.file.Files)2 Path (java.nio.file.Path)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 EntityManager (javax.persistence.EntityManager)2 TypedQuery (javax.persistence.TypedQuery)2 LogManager (org.apache.logging.log4j.LogManager)2 Logger (org.apache.logging.log4j.Logger)2 JDOMException (org.jdom2.JDOMException)2 MCREntityManagerProvider (org.mycore.backend.jpa.MCREntityManagerProvider)2 MCRXMLMetadataManager (org.mycore.datamodel.common.MCRXMLMetadataManager)2 MCRCommand (org.mycore.frontend.cli.annotation.MCRCommand)2 BufferedImage (java.awt.image.BufferedImage)1 InputStream (java.io.InputStream)1 URISyntaxException (java.net.URISyntaxException)1 DirectoryStream (java.nio.file.DirectoryStream)1 FileSystem (java.nio.file.FileSystem)1 FileVisitResult (java.nio.file.FileVisitResult)1