Examples of ODMGXAWrapper


Examples of org.photovault.dbhelper.ODMGXAWrapper

        if ( info == null ) {
            String oql = "select info from " + DbInfo.class.getName();
            List infos = null;
       
            // Get transaction context
            ODMGXAWrapper txw = new ODMGXAWrapper();
            Implementation odmg = ODMG.getODMGImplementation();
       
            try {
                OQLQuery query = odmg.newOQLQuery();
                query.create( oql );
                infos = (List) query.execute();
                txw.commit();
            } catch (Exception e ) {
                txw.abort();
            }
            if ( infos.size() > 0 ) {
                info = (DbInfo) infos.get(0);
            }
        }
View Full Code Here

Examples of org.photovault.dbhelper.ODMGXAWrapper

    /**
     Set the revision of database schema.
     @param version the version number.
     */
    public void setVersion( int version ) {
        ODMGXAWrapper txw = new ODMGXAWrapper();
        txw.lock( this, Transaction.WRITE );
        this.version = version;
        txw.commit();
    }
View Full Code Here

Examples of org.photovault.dbhelper.ODMGXAWrapper

     (e.g. if imgFile does not exist or is not of a recognized file type). In this case
     the method also aborts ongoing ODMG transaction.
     */
    public static ImageInstance create ( VolumeBase vol, File imgFile ) {
  log.debug( "Creating instance " + imgFile.getAbsolutePath() );
        ODMGXAWrapper txw = new ODMGXAWrapper();
        ImageInstance i = new ImageInstance();
  i.uuid = UUID.randomUUID();
  i.volume = vol;
  i.volumeId = vol.getName();
  i.imageFile = imgFile;
        i.fileSize = imgFile.length();
        i.mtime = imgFile.lastModified();
        i.fname = vol.mapFileToVolumeRelativeName( imgFile );
        txw.lock( i, Transaction.WRITE );
        // Read the rest of fields from the image file
  try {
      i.readImageFile();
  } catch (Exception e ) {
      txw.abort();
      log.warn( "Error opening image file: " + e.getMessage() );
      // The image does not exist, so it cannot be read!!!
      return null;
  }
        i.calcHash();
        i.checkTime = new java.util.Date();
        txw.commit();
        return i;
    }
View Full Code Here

Examples of org.photovault.dbhelper.ODMGXAWrapper

            PhotoInfo photo, int instanceType ) {

  log.debug( "Creating instance, volume = " + volume.getName() + " photo = " + photo.getUid()
       + " image file = " + imageFile.getName() );
  // Initialize transaction context
  ODMGXAWrapper txw = new ODMGXAWrapper();
 
  ImageInstance f = new ImageInstance();
  f.uuid = UUID.randomUUID();
        // Set up the primary key fields before locking the object
  f.volume = volume;
  f.volumeId = volume.getName();
  f.imageFile = imageFile;
        f.fileSize = imageFile.length();
        f.mtime = imageFile.lastModified();
        f.fname = volume.mapFileToVolumeRelativeName( imageFile );
        f.instanceType = instanceType;
  txw.lock( f, Transaction.WRITE );
  log.debug( "locked instance" );
 
  f.photoUid = photo.getUid();
  // Read the rest of fields from the image file
  try {
      f.readImageFile();
  } catch (Exception  e ) {
      txw.abort();
      log.warn( "Error opening image file: " + e.getMessage() );
      // The image does not exist, so it cannot be read!!!
      return null;
  }
        f.calcHash();
  f.checkTime = new java.util.Date();
        txw.commit();
  return f;
    }
View Full Code Here

Examples of org.photovault.dbhelper.ODMGXAWrapper

         them to some value. These values indicate that the instance is just a
         "placeholder" and no file is available.
         */
        i.volumeId = "##nonexistingfiles##";
        i.fname = uuid.toString();
  ODMGXAWrapper txw = new ODMGXAWrapper();
        Database db = ODMG.getODMGDatabase();       
        db.makePersistent( i );
        txw.commit();
        return i;
    }
View Full Code Here

Examples of org.photovault.dbhelper.ODMGXAWrapper

      + " where volumeId = \"" + volume.getName() + "\" and fname = \"" + fname + "\"";

  List instances = null;

  // Get transaction context
  ODMGXAWrapper txw = new ODMGXAWrapper();
  Implementation odmg = ODMG.getODMGImplementation();
  try {
      OQLQuery query = odmg.newOQLQuery();
      query.create( oql );
      instances = (List) query.execute();
      txw.commit();
  } catch ( Exception e ) {
      txw.abort();
      return null;
  }
       
  ImageInstance instance = null;
        if ( instances != null && instances.size() > 0 ) {
View Full Code Here

Examples of org.photovault.dbhelper.ODMGXAWrapper

        + " where instance_uuid = \"" + uuid.toString() + "\"";

  List instances = null;

  // Get transaction context
  ODMGXAWrapper txw = new ODMGXAWrapper();
  Implementation odmg = ODMG.getODMGImplementation();
  try {
      OQLQuery query = odmg.newOQLQuery();
      query.create( oql );
      instances = (List) query.execute();
      txw.commit();
  } catch ( Exception e ) {
      txw.abort();
      return null;
  }
       
  ImageInstance instance = null;
        if ( instances != null && instances.size() > 0 ) {
View Full Code Here

Examples of org.photovault.dbhelper.ODMGXAWrapper

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

Examples of org.photovault.dbhelper.ODMGXAWrapper

    /**
       Deletes the ImageInstance object from database.
     @deprecated Ise delete( boolean deleteFromExtVol ) instead.
    */
    public void delete() {
  ODMGXAWrapper txw = new ODMGXAWrapper();
  Database db = ODMG.getODMGDatabase()
  db.deletePersistent( this );
        // Delete the file unless it is stored in external volume
        if ( !(volume instanceof ExternalVolume) ) {
            if ( imageFile != null && !imageFile.delete() ) {
                log.error( "File " + imageFile.getAbsolutePath() + " could not be deleted" );
            }
        }
  txw.commit();
    }
View Full Code Here

Examples of org.photovault.dbhelper.ODMGXAWrapper

     on external volume.
     @return True if deletion was successful
     */
    public boolean delete( boolean deleteFromExtVol ) {
        boolean success = false;
  ODMGXAWrapper txw = new ODMGXAWrapper();
  Database db = ODMG.getODMGDatabase()
        if ( !(volume instanceof ExternalVolume) || deleteFromExtVol ) {
            if ( imageFile ==  null || imageFile.delete() ) {
          db.deletePersistent( this );
                success = true;
            }
        }
  txw.commit();
        return success;
    }
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.