Package org.photovault.dbhelper

Examples of org.photovault.dbhelper.ODMGXAWrapper


     */
    public static PhotoInfo create(UUID uuid) {
        PhotoInfo photo = new PhotoInfo();
        photo.uuid = uuid;
       
        ODMGXAWrapper txw = new ODMGXAWrapper();
        Database db = ODMG.getODMGDatabase();       
        db.makePersistent( photo );
        txw.lock( photo, Transaction.WRITE );
        txw.commit();
        return photo;
    }
View Full Code Here


    */
    protected void removeSubfolder( PhotoFolder subfolder ) {
  if ( subfolder == null ) {
      return;
  }
  ODMGXAWrapper txw = new ODMGXAWrapper();
  txw.lock( this, Transaction.WRITE );
        txw.lock( subfolder, Transaction.WRITE );
  subfolders.remove( subfolder );
  modified();
  // Inform all parents & their that the structure has changed
  subfolderStructureChanged( this );
  txw.commit();
    }
View Full Code Here

            throw new java.lang.Error( "Unknown subclass of VolumeBase: "
                    + vol.getClass().getName() );
        }
       
        // Create the image
        ODMGXAWrapper txw = new ODMGXAWrapper();
        PhotoInfo photo = PhotoInfo.create();
        txw.lock( photo, Transaction.WRITE );
        photo.addInstance( vol, instanceFile, ImageInstance.INSTANCE_TYPE_ORIGINAL );
        photo.setCropBounds( new Rectangle2D.Float( 0.0F, 0.0F, 1.0F, 1.0F ) );
        photo.updateFromOriginalFile();
        txw.commit();
        return photo;
    }
View Full Code Here

    public PhotoFolder getParentFolder() {
  return parent;
    }

    public void setParentFolder( PhotoFolder newParent ) {
  ODMGXAWrapper txw = new ODMGXAWrapper();
  txw.lock( this, Transaction.WRITE );
  // If the parent is already set, remove the folder from its subfolders
  if ( parent != null ) {
      parent.removeSubfolder( this );
  }
  this.parent = newParent;
  if ( parent != null ) {
      parent.addSubfolder( this );
  }
  modified();
  txw.commit();
    }
View Full Code Here

       @param parent Parent folder of the new folder
       @throws IllegalArgumentException if name is longer than @see NAME_LENGTH
    */
    public static PhotoFolder create( String name, PhotoFolder parent ) {
       
        ODMGXAWrapper txw = new ODMGXAWrapper();
        PhotoFolder folder = new PhotoFolder();
        try {
            folder.setName( name );
            folder.uuid = UUID.randomUUID();
            folder.setParentFolder( parent );
            txw.lock( folder, Transaction.WRITE );
        } catch (IllegalArgumentException e ) {
            throw e;
        } finally {
            txw.commit();
        }
        return folder;
    }
View Full Code Here

        }
        return uuid;
    }   
   
    public void setUUID( UUID uuid ) {
        ODMGXAWrapper txw = new ODMGXAWrapper();
  txw.lock( this, Transaction.WRITE );
  this.uuid = uuid;
  modified();
  txw.commit();
    }
View Full Code Here

       Creates & returns a new persistent PhotoFolder object
       @param uuid UUID for the created folder
       @param parent Parent folder of the new folder
    */
    public static PhotoFolder create(UUID uuid, PhotoFolder parent) {
        ODMGXAWrapper txw = new ODMGXAWrapper();
        PhotoFolder folder = new PhotoFolder();
        try {
            folder.uuid = uuid;
            folder.name = "";
            folder.setParentFolder( parent );
            txw.lock( folder, Transaction.WRITE );
        } catch (IllegalArgumentException e ) {
            throw e;
        } finally {
            txw.commit();
        }
        return folder;
    }   
View Full Code Here

     Reads field values from original file EXIF values
     @return true if successfull, false otherwise
     */
   
    public boolean updateFromOriginalFile() {
        ODMGXAWrapper txw = new ODMGXAWrapper();
        ImageInstance instance = null;
        for ( int n = 0; n < instances.size(); n++ ) {
            ImageInstance candidate = (ImageInstance) instances.get( n );
            if ( candidate.getInstanceType() == ImageInstance.INSTANCE_TYPE_ORIGINAL ) {
                instance = candidate;
                File f = instance.getImageFile();
                boolean success = false;
                if ( f != null ) {
                    String suffix = "";
                    int suffixStart = f.getName().lastIndexOf( "." );
                    if ( suffixStart >= 0 &&  suffixStart < f.getName().length() -1 ) {
                        suffix = f.getName().substring( suffixStart+1 );
                    }
                    Iterator readers = ImageIO.getImageReadersBySuffix( suffix );
                    if ( readers.hasNext() ) {
                        updateFromFileMetadata( f );
                        success = true;
                    } else {
                        success = updateFromRawFileMetadata( f );
                    }
                    txw.commit();
                    return success;
                }
            }
        }
        txw.commit();
        return false;
    }
View Full Code Here

       Returns the root folder for the PhotoFolder hierarchy, i.e. the folder with id 1.
    */
    public static PhotoFolder getRoot() {
        PhotoFolder rootFolder = PhotoFolder.rootFolder;
        if ( rootFolder == null ) {
            ODMGXAWrapper txw = new ODMGXAWrapper();
            Implementation odmg = ODMG.getODMGImplementation();
 
            List folders = null;
            boolean mustCommit = false;
            try {
                OQLQuery query = odmg.newOQLQuery();
                query.create( "select folders from " + PhotoFolder.class.getName() + " where folderId = 1" );               
                folders = (List) query.execute();
            } catch ( Exception e ) {
                Throwable rootCause = e;
                while ( rootCause.getCause() != null ) {
                    rootCause = rootCause.getCause();
                }
                log.error( rootCause.getMessage() );
                txw.abort();
                return null;
            }
            rootFolder = (PhotoFolder) folders.get( 0 );
            PhotoFolder.rootFolder = rootFolder;
            // If a new transaction was created, commit it
            txw.commit();
        }
  return rootFolder;
    }
View Full Code Here

     @param uuid UUID for t6he folder to retrieve
     @return The given folder or <code>null</code> if not found    
     */
    public static PhotoFolder getFolderByUUID(UUID uuid) {
        PhotoFolder f = null;
        ODMGXAWrapper txw = new ODMGXAWrapper();
        Implementation odmg = ODMG.getODMGImplementation();
       
        List folders = null;
        boolean mustCommit = false;
        try {
            OQLQuery query = odmg.newOQLQuery();
            query.create( "select folders from " + PhotoFolder.class.getName()
                        + " where uuid = \"" + uuid.toString() + "\"" );
            folders = (List) query.execute();
        } catch ( Exception e ) {
            txw.abort();
            return null;
        }
        if ( folders.size() > 0 ) {
            f = (PhotoFolder) folders.get( 0 );
        }
        // If a new transaction was created, commit it
        txw.commit();
        return f;
    }
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.