Examples of PhotoInfo


Examples of org.photovault.imginfo.PhotoInfo

        Iterator iter = photos.iterator();
        writer.write( getIndent() + "<photos>" );
        writer.newLine();
        indent += 2;
        while ( iter.hasNext() ) {
            PhotoInfo p = ( PhotoInfo ) iter.next();
            writePhoto( p );
        }
        indent -= 2;
        writer.write( getIndent() + "</photos>" );
        writer.newLine();
View Full Code Here

Examples of org.photovault.imginfo.PhotoInfo

            // No action, there just were no matching instances in database
        }
        if ( oldInstance != null ) {
            // There is an existing instance, check whether the data matches
            if ( oldInstance.doConsistencyCheck() ) {
                PhotoInfo photo = null;
                try {
                    photo = PhotoInfo.retrievePhotoInfo(oldInstance.getPhotoUid());
                } catch (PhotoNotFoundException ex) {
                    ex.printStackTrace();
                }
                return photo;
            } else {
                PhotoInfo photo = null;
                try {
                    photo = PhotoInfo.retrievePhotoInfo(oldInstance.getPhotoUid());
                } catch (PhotoNotFoundException ex) {
                    ex.printStackTrace();
                }
                Vector instances = photo.getInstances();
                int instNum = instances.indexOf( oldInstance );
                if ( instNum >= 0 ) {
                    photo.removeInstance( instNum );
                }
            }
        }
       
       
        // Check whether this is really an image file
       
        ODMGXAWrapper txw = new ODMGXAWrapper();
        ImageInstance instance = null;
        try {
            instance = ImageInstance.create( volume, f );
        } catch ( Exception e ) {
            currentEvent.setResult( ExtVolIndexerEvent.RESULT_ERROR );
            return null;
        }
        if ( instance == null ) {
            currentEvent.setResult( ExtVolIndexerEvent.RESULT_NOT_IMAGE );
            /*
             ImageInstance already aborts transaction if reading image file
             was unsuccessfull.
             */
            return null;
        }
        byte[] hash = instance.getHash();
       
        // Check whether there is already an image instance with the same hash
        PhotoInfo matchingPhotos[] = PhotoInfo.retrieveByOrigHash( hash );
        PhotoInfo photo = null;
        if ( matchingPhotos != null && matchingPhotos.length > 0 ) {
            // If yes then get the PhotoInfo and add this file as an instance with
            // the same type as the one with same hash. If only PhotoInfo with no
            // instances add as original for that
            photo = matchingPhotos[0];
            photo.addInstance( instance );
            currentEvent.setResult( ExtVolIndexerEvent.RESULT_NEW_INSTANCE );
            newInstanceCount++;
        } else {
            photo = PhotoInfo.create();
            photo.addInstance( instance );
            photo.updateFromOriginalFile();
            txw.flush();
            // Create a thumbnail for this photo
            photo.getThumbnail();
            currentEvent.setResult( ExtVolIndexerEvent.RESULT_NEW_PHOTO );
            newInstanceCount++;
            newPhotoCount++;
        }
        currentEvent.setPhoto( photo );
View Full Code Here

Examples of org.photovault.imginfo.PhotoInfo

                indexDirectory( f, subfolder, subdirStart, subdirEnd );
                percentComplete = c.getProgress();
            } else {
                if ( f.canRead() ) {
                    currentEvent = new ExtVolIndexerEvent( this );
                    PhotoInfo p = indexFile( f );
                    if ( p != null ) {
                        if ( photoInstanceCounts.containsKey( p ) ) {
                            // The photo is already in this folder
                            int refCount = ((Integer)photoInstanceCounts.get( p ) ).intValue();
                            photoInstanceCounts.remove( p );
                            photoInstanceCounts.put( p, new Integer( refCount+1 ));
                        } else {
                            // The photo is not yet in this folder
                            folder.addPhoto( p );
                            photoInstanceCounts.put( p, new Integer( 1 ));
                        }
                    }
                    nFile++;
                    c.setProcessedFiles( nFile );
                    percentComplete = c.getProgress();
                    notifyListeners( currentEvent );
                }
            }
        }
       
        /*
         Check if some of the photos that were in folder before were not found in
         this directory
         */
        Iterator iter = photoInstanceCounts.keySet().iterator();
        while ( iter.hasNext() ) {
            PhotoInfo p = (PhotoInfo ) iter.next();
            int refCount = ((Integer)photoInstanceCounts.get( p )).intValue();
            if ( refCount == 0 ) {
                folder.removePhoto( p );
            }
        }
View Full Code Here

Examples of org.photovault.imginfo.PhotoInfo

        }       

        // Now go through all the photos with stray instances
        Iterator photoIter = result.iterator();
        while ( photoIter.hasNext() ) {
            PhotoInfo p = (PhotoInfo) photoIter.next();
            Vector instances = p.getInstances();
            for ( int i = instances.size()-1; i >= 0; i-- ) {
                ImageInstance inst = (ImageInstance) instances.get( i );
                Date checkTime = inst.getCheckTime();
                if ( inst.getVolume() == volume
                        && (checkTime == null || checkTime.before( startTime )) ) {
                    p.removeInstance( i );
                }
            }
        }
        txw.commit();
    }
View Full Code Here

Examples of org.photovault.imginfo.PhotoInfo

          }
      }
      log.debug( "Done!" );

      // Inform the view that the thumbnail is now created
      final PhotoInfo lastPhoto = photo;
      photo = null;
      SwingUtilities.invokeLater( new Runnable() {
        public void run() {
            log.debug( "drawing new thumbnail for " + lastPhoto.getUid() );
            view.thumbnailCreated( lastPhoto );
                                }
                        });
        }
    } catch ( InterruptedException e ) {
View Full Code Here

Examples of org.photovault.imginfo.PhotoInfo

        // Create top folder for indexed files
        topFolder = PhotoFolder.create( "ExtVolTest", PhotoFolder.getRoot() );
       
        // Remove the test files from database if they are already there
        hash1 = ImageInstance.calcHash( testfile1 );
        PhotoInfo photos1[] = PhotoInfo.retrieveByOrigHash( hash1 );
        if ( photos1 != null ) {
            for ( int n = 0; n < photos1.length; n++ ) {
                photos1[n].delete();
            }
        }
        hash2 = ImageInstance.calcHash( testfile2);
        PhotoInfo photos2[] = PhotoInfo.retrieveByOrigHash( hash2 );
        if ( photos2 != null ) {
            for ( int n = 0; n < photos2.length; n++ ) {
                photos2[n].delete();
            }
        }
        hash3 = ImageInstance.calcHash( testfile3);
        PhotoInfo photos3[] = PhotoInfo.retrieveByOrigHash( hash3 );
        if ( photos3 != null ) {
            for ( int n = 0; n < photos3.length; n++ ) {
                photos3[n].delete();
            }
        }
View Full Code Here

Examples of org.photovault.imginfo.PhotoInfo

    public void tearDown() {
        FileUtils.deleteTree( extVolDir );
        topFolder.delete();

        PhotoInfo photos1[] = PhotoInfo.retrieveByOrigHash( hash1 );
        if ( photos1 != null ) {
            for ( int n = 0; n < photos1.length; n++ ) {
                photos1[n].delete();
            }
        }
        PhotoInfo photos2[] = PhotoInfo.retrieveByOrigHash( hash2 );
        if ( photos2 != null ) {
            for ( int n = 0; n < photos2.length; n++ ) {
                photos2[n].delete();
            }
        }
        PhotoInfo photos3[] = PhotoInfo.retrieveByOrigHash( hash3 );
        if ( photos3 != null ) {
            for ( int n = 0; n < photos3.length; n++ ) {
                photos3[n].delete();
            }
        }       
View Full Code Here

Examples of org.photovault.imginfo.PhotoInfo

        if ( ODMG.getODMGImplementation().currentTransaction() != null ) {
            fail( "Still in transaction" );
        }
        assertNotNull( "photos1 = null", photos1 );
        assertEquals( "Only 1 photo per picture should be found", 1, photos1.length );
        PhotoInfo p1 = photos1[0];
        assertEquals( "2 instances should be found in photo 1", 2, p1.getNumInstances() );
        PhotoInfo[] photos2 = PhotoInfo.retrieveByOrigHash( hash2 );
        if ( ODMG.getODMGImplementation().currentTransaction() != null ) {
            fail( "Still in transaction" );
        }
        assertEquals( "1 photo per picture should be found", 1, photos2.length );
        PhotoInfo p2 = photos2[0];
        assertEquals( "3 instances should be found in photo 2", 3, p2.getNumInstances() );

        // Check that both instances of p2 can be found
        boolean found[] = {false, false};
        File files[] = {photo2inst1, photo2inst2};
        for ( n = 0; n < p2.getNumInstances(); n++ ) {
            ImageInstance i = p2.getInstance( n );
            for ( int m = 0; m < found.length; m++ ) {
                if ( files[m].equals( i.getImageFile() ) ) {
                    found[m] = true;
                }
            }
        }
        for ( n = 0; n < found.length; n++ ) {
            assertTrue( "Photo " + n + " not found", found[n] );
        }
       
        if ( ODMG.getODMGImplementation().currentTransaction() != null ) {
            fail( "Still in transaction" );
        }
        // Check that the folders have the correct photos
        PhotoInfo[] photosInTopFolder = { p1, p2 };
        assertFolderHasPhotos( topFolder, photosInTopFolder );

        PhotoFolder subFolder = topFolder.getSubfolder( 0 );
        assertEquals( "Subfolder name not correct", "test", subFolder.getName() );
        PhotoInfo[] photosInSubFolder = { p2 };
        assertFolderHasPhotos( subFolder, photosInSubFolder );  
       
        // Check that the listener was called correctly
        assertEquals( "Wrong photo count in listener", 2, l.photoCount );
        assertEquals( "Wrong photo count in indexer statistics", 2, indexer.getNewPhotoCount() );
        assertEquals( "Wrong instance count in listener", 3, l.instanceCount );
        assertEquals( "Wrong instance count in indexer statistics", 3, indexer.getNewInstanceCount() );
       
        assertEquals( "Indexing complete 100%", 100, indexer.getPercentComplete() );
        assertNotNull( "StartTime still null", indexer.getStartTime() );

        if ( ODMG.getODMGImplementation().currentTransaction() != null ) {
            fail( "Still in transaction" );
        }
           
        // Next, let's make some modifications to the external volume
        try {
            // New file
            File testfile3 = new File( "testfiles", "test3.jpg" );
            File f3 = new File( extVolDir, "test3.jpg");
            FileUtils.copyFile( testfile3, f3 );
           
            // Replace the test1 file with test3
            File f1 = new File ( extVolDir, "test1.jpg" );
            FileUtils.copyFile( testfile3, f1 );
           
            // Remove 1 copy of test2
            File f2 = new File( extVolDir, "test2.jpg" );
            f2.delete();
        } catch (IOException ex) {
            fail( "IOException while altering external volume: " + ex.getMessage() );
        }
       
        indexer = new ExtVolIndexer( v );
        indexer.setTopFolder( topFolder );
        l = new TestListener();
        indexer.addIndexerListener( l );
   
        assertEquals( "Indexing not started -> completeness must be 0",
                0, indexer.getPercentComplete() );
        assertNull( "StartTime must be null before starting", indexer.getStartTime() );
        indexer.run();

        // Check that the folders have the correct photos

        PhotoInfo[] photos3 = PhotoInfo.retrieveByOrigHash( hash3 );
        assertEquals( "1 photo per picture should be found", 1, photos3.length );
        PhotoInfo p3 = photos3[0];       
        PhotoInfo photosInTopFolder2[] = { p3 };
        assertFolderHasPhotos( topFolder, photosInTopFolder2 );
        assertEquals( "More than 1 subfolder in topFolder", 1, topFolder.getSubfolderCount() );
        subFolder = topFolder.getSubfolder( 0 );
        assertEquals( "Subfolder name not correct", "test", subFolder.getName() );
        PhotoInfo[] photosInSubFolder2 = { p2 };
View Full Code Here

Examples of org.photovault.imginfo.PhotoInfo

        for ( int n = 0; n < photos.length; n++ ) {
            found[n] = false;
        }
        int numPhotosInFolder = folder.getPhotoCount();
        for ( int i = 0; i < numPhotosInFolder; i++ ) {
            PhotoInfo p = folder.getPhoto( i );
            for ( int n = 0; n < photos.length; n++ ) {
                if ( p == photos[n] ) {
                    found[n] = true;
                }
            }
View Full Code Here

Examples of org.photovault.imginfo.PhotoInfo

      org.apache.log4j.lf5.DefaultLF5Configurator.configure();
  } catch ( Exception e ) {}
  log.info( "Starting application" );

  // Parse the arguments
  PhotoInfo photo = null;
  log.debug( "Number of args" + args.length );
  log.debug( args.toString() );
  if ( args.length == 2 ) {
      if ( args[0].equals( "-f" ) ) {
    File f = new File( args[1] );
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.