Package org.photovault.dbhelper

Examples of org.photovault.dbhelper.ODMGXAWrapper


     Check that the e crop bounds are defined in consistent manner. This is needed
     since in old installations the max parameters can be larger than min ones.
     */
   
    private void checkCropBounds() {
        ODMGXAWrapper txw = new ODMGXAWrapper();
        if ( cropMaxX - cropMinX <= 0) {
            txw.lock( this, Transaction.WRITE );
            cropMaxX = 1.0 - cropMinX;
        }
        if ( cropMaxY - cropMinY <= 0) {
            txw.lock( this, Transaction.WRITE );
            cropMaxY = 1.0 - cropMinY;
        }
        txw.commit();
    }
View Full Code Here


   
    /**
     Get the preferred crop bounds of the original image
     */
    public Rectangle2D getCropBounds() {
        ODMGXAWrapper txw = new ODMGXAWrapper();
        txw.lock( this, Transaction.READ );
        checkCropBounds();
        txw.commit();
        return new Rectangle2D.Double( cropMinX, cropMinY,
                cropMaxX-cropMinX, cropMaxY-cropMinY );       
    }
View Full Code Here

    /**
     Set the preferred cropping operation
     @param cropBounds New crop bounds
     */
    public void setCropBounds( Rectangle2D cropBounds ) {
        ODMGXAWrapper txw = new ODMGXAWrapper();
        txw.lock( this, Transaction.WRITE );
        cropMinX = cropBounds.getMinX();
        cropMinY = cropBounds.getMinY();
        cropMaxX = cropBounds.getMaxX();
        cropMaxY = cropBounds.getMaxY();
        txw.commit();
    }
View Full Code Here

     Set the raw conversion settings for this photo
     @param s The new raw conversion settings used to create this instance.
     The method makes a clone of the object.    
     */
    public void setRawSettings( RawConversionSettings s ) {
        ODMGXAWrapper txw = new ODMGXAWrapper();
        txw.lock( this, Transaction.WRITE );
        RawConversionSettings settings = null;
        if ( s != null ) {
            settings = s.clone();
            txw.lock( settings, Transaction.WRITE );
        }
        if ( rawSettings != null ) {
            Database db = ODMG.getODMGDatabase();
            db.deletePersistent( rawSettings );
        }
        rawSettings = settings;       
        txw.commit();
    }
View Full Code Here

     Get the current raw conversion settings.
     @return Current settings or <code>null</code> if instance was not created
     from a raw image.    
     */
    public RawConversionSettings getRawSettings() {
        ODMGXAWrapper txw = new ODMGXAWrapper();
        txw.lock( this, Transaction.READ );
        txw.commit();
        return rawSettings;
    }
View Full Code Here

    /**
     Set the color channel mapping from original to this instance
     @param cm the new color channel mapping
     */
    public void setColorChannelMapping( ChannelMapOperation cm ) {
        ODMGXAWrapper txw = new ODMGXAWrapper();
        txw.lock( this, Transaction.WRITE );
        channelMap = cm;
        txw.commit();
    }
View Full Code Here

    /**
     Get color channel mapping from original to this instance.
     @return The current color channel mapping
     */
    public ChannelMapOperation getColorChannelMapping() {
        ODMGXAWrapper txw = new ODMGXAWrapper();
        txw.lock( this, Transaction.READ );
        txw.commit();
        return channelMap;
    }
View Full Code Here

     Sets the photo UID of this instance. THis should only be called by
     PhotoInfo.addInstance()
     @param uid UID of the photo
     */
    protected void setPhotoUid(int uid) {
  ODMGXAWrapper txw = new ODMGXAWrapper();
  txw.lock( this, Transaction.WRITE );
  photoUid = uid;
  txw.commit();
       
    }
View Full Code Here

        }
       
       
        // 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 );
        txw.commit();
        log.debug( "exit: indexFile " + f.getAbsolutePath() );
        return photo;
    }
View Full Code Here

        Criteria cutoffDateCrit = new Criteria();
        cutoffDateCrit.addLessThan( "instances.checkTime", startTime );
        dateCrit.addOrCriteria( cutoffDateCrit );
        crit.addAndCriteria( dateCrit );
       
        ODMGXAWrapper txw = new ODMGXAWrapper();
  Implementation odmg = ODMG.getODMGImplementation();
  Transaction tx = odmg.currentTransaction();
        Collection result = null;
  try {
      PersistenceBroker broker = ((HasBroker) tx).getBroker();
      QueryByCriteria q = new QueryByCriteria( PhotoInfo.class, crit );
      result = broker.getCollectionByQuery( q );
        } catch ( Exception e ) {
            e.printStackTrace();
        }       

        // 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

TOP

Related Classes of org.photovault.dbhelper.ODMGXAWrapper

Copyright © 2018 www.massapicom. 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.