Package org.photovault.dbhelper

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;
  modified();
  txw.commit();
    }
View Full Code Here


     * Set the value of name.
     * @param v  Value to assign to name.
     */
    public void setName(String  v) {
  checkStringProperty( "Name", v, NAME_LENGTH );
        ODMGXAWrapper txw = new ODMGXAWrapper();
  txw.lock( this, Transaction.WRITE );
  this.name = v;
  modified();
  txw.commit();
    }
View Full Code Here

    /**
     * Set the value of description.
     * @param v  Value to assign to description.
     */
    public void setDescription(String  v) {
  ODMGXAWrapper txw = new ODMGXAWrapper();
  txw.lock( this, Transaction.WRITE );
  this.description = v;
  modified();
  txw.commit();
    }
View Full Code Here

        log.debug( "Fetching PhotoInfo with ID " + photoId );
        String oql = "select photos from " + PhotoInfo.class.getName() + " where uid=" + photoId;
        List photos = null;
       
        // Get transaction context
        ODMGXAWrapper txw = new ODMGXAWrapper();
        Implementation odmg = ODMG.getODMGImplementation();
       
        try {
            OQLQuery query = odmg.newOQLQuery();
            query.create( oql );
            photos = (List) query.execute();
            txw.commit();
        } catch (Exception e ) {
            log.warn( "Error fetching record: " + e.getMessage() );
            txw.abort();
            throw new PhotoNotFoundException();
        }
        if ( photos.size() == 0 ) {
            throw new PhotoNotFoundException();
        }
View Full Code Here

    */
    public void addPhoto( PhotoInfo photo ) {
  if ( photos == null ) {
      photos = new Vector();
  }
  ODMGXAWrapper txw = new ODMGXAWrapper();
  txw.lock( this, Transaction.WRITE );
  if ( !photos.contains( photo ) ) {
            txw.lock( photo, Transaction.WRITE );
      photo.addedToFolder( this );
      photos.add( photo );
      modified();
  }
  txw.commit();
    }
View Full Code Here

        log.debug( "Fetching PhotoInfo with UUID " + uuid );
        String oql = "select photos from " + PhotoInfo.class.getName() + " where uuid=\"" + uuid.toString() + "\"";
        List photos = null;
       
        // Get transaction context
        ODMGXAWrapper txw = new ODMGXAWrapper();
        Implementation odmg = ODMG.getODMGImplementation();
       
        try {
            OQLQuery query = odmg.newOQLQuery();
            query.create( oql );
            photos = (List) query.execute();
            txw.commit();
        } catch (Exception e ) {
            log.warn( "Error fetching record: " + e.getMessage() );
            txw.abort();
            throw new PhotoNotFoundException();
        }
        PhotoInfo photo = null;
        if ( photos.size() > 0 ) {
            if ( photos.size() > 1 ) {
View Full Code Here

    */
    public void removePhoto( PhotoInfo photo ) {
  if ( photos == null ) {
      return;
  }
  ODMGXAWrapper txw = new ODMGXAWrapper();
  txw.lock( this, Transaction.WRITE );
        txw.lock( photo, Transaction.WRITE );
  photo.removedFromFolder( this );
  photos.remove( photo );
  modified();
  txw.commit();
    }
View Full Code Here

     @param hash The hash code we are looking for
     @return An array of matching PhotoInfo objects or <code>null</code>
     if none found.
     */
    static public PhotoInfo[] retrieveByOrigHash(byte[] hash) {
        ODMGXAWrapper txw = new ODMGXAWrapper();
        Implementation odmg = ODMG.getODMGImplementation();
       
        Transaction tx = odmg.currentTransaction();
       
        PhotoInfo photos[] = null;
        try {
            PersistenceBroker broker = ((HasBroker) tx).getBroker();
           
            Criteria crit = new Criteria();
            crit.addEqualTo( "origInstanceHash", hash );
           
            QueryByCriteria q = new QueryByCriteria( PhotoInfo.class, crit );
            Collection result = broker.getCollectionByQuery( q );
            if ( result.size() > 0 ) {
                photos = (PhotoInfo[]) result.toArray( new PhotoInfo[result.size()] );
            }
            txw.commit();
        } catch ( Exception e ) {
            log.warn( "Error executing query: " + e.getMessage() );
            e.printStackTrace( System.out );
            txw.abort();
        }
        return photos; 
    }
View Full Code Here

    /**
       Adds a new subfolder to this folder. This method is called by setParentFolder().
    */
    protected void addSubfolder( PhotoFolder subfolder ) {
  ODMGXAWrapper txw = new ODMGXAWrapper();
  txw.lock( this, Transaction.WRITE );
  if ( subfolders == null ) {
      subfolders = new Vector();
  }
        // TODO: lock subfolder???
  subfolders.add( subfolder );
  modified();
  // Inform all parents & their that the structure has changed
  subfolderStructureChanged( this );
  txw.commit();
    }
View Full Code Here

     */
    public static PhotoInfo create() {
        PhotoInfo photo = new PhotoInfo();
        photo.uuid = UUID.randomUUID();
       
        ODMGXAWrapper txw = new ODMGXAWrapper();
        Database db = ODMG.getODMGDatabase();       
        db.makePersistent( photo );
        txw.lock( photo, Transaction.WRITE );
        txw.commit();
        return photo;
    }
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.