Package ca.carleton.gcrc.couch.app.impl

Examples of ca.carleton.gcrc.couch.app.impl.UpdateSpecifier


   
    // Check if doc exists in database
    JSONObject currentTargetDoc = null;
    boolean creationRequired = false;
    boolean modified = false;
    UpdateSpecifier updateSpecifier = null;
    try {
      if( false == couchDb.documentExists(docId) ) {
        creationRequired = true;
        updateSpecifier = UpdateSpecifier.computeUpdateSpecifier(sourceDoc, dd, null, schedule);
       
      } else {
        // Get document from database
        currentTargetDoc = couchDb.getDocument(docId);
       
        // Check if the document in database was modified
        modified = DocumentManifest.hasDocumentBeenModified(currentTargetDoc);
       
        // Figure out the differences between the source document and
        // the target document
        updateSpecifier = UpdateSpecifier.computeUpdateSpecifier(sourceDoc, dd, currentTargetDoc, schedule);
      }
    } catch(Exception e) {
      throw new Exception("Unable to access current document", e);
    }
   
    // Upload, if required
    if( creationRequired ) {
      listener.updatingDocument(Phase.BEFORE, sourceDoc);
      updateDocument(sourceDoc, dd, null, updateSpecifier);
      listener.updatingDocument(Phase.AFTER, sourceDoc);

    } else if( schedule == Schedule.UPDATE_FORCED ) {
      // Forced update always take place
      listener.updatingDocument(Phase.BEFORE, sourceDoc);
      updateDocument(sourceDoc, dd, currentTargetDoc, updateSpecifier);
      listener.updatingDocument(Phase.AFTER, sourceDoc);

    } else if( false == updateSpecifier.isUpdateRequired() ) {
      // Document on database is same as the one requested. No
      // update required
      listener.documentSkippedBecauseUnchanged(sourceDoc);
     
    } else if( modified && schedule == Schedule.UPDATE_UNLESS_MODIFIED ) {
View Full Code Here


   
    // Check if doc exists in database
    JSONObject currentTargetDoc = null;
    boolean creationRequired = false;
    boolean modified = false;
    UpdateSpecifier updateSpecifier = null;
    try {
      if( false == couchDb.documentExists(docId) ) {
        creationRequired = true;
        updateSpecifier = UpdateSpecifier.computeUpdateSpecifier(sourceDoc, dd, null, schedule);
       
      } else {
        // Get document from database
        currentTargetDoc = couchDb.getDocument(docId);
       
        // Check if the document in database was modified
        modified = DocumentManifest.hasDocumentBeenModified(currentTargetDoc);
       
        // Figure out the differences between the source document and
        // the target document
        updateSpecifier = UpdateSpecifier.computeUpdateSpecifier(sourceDoc, dd, currentTargetDoc, schedule);
      }
    } catch(Exception e) {
      throw new Exception("Unable to access current document", e);
    }
   
    // Upload, if required
    if( creationRequired ) {
      listener.updatingDocument(Phase.BEFORE, sourceDoc);
      updateDocument(sourceDoc, dd, null, updateSpecifier);
      listener.updatingDocument(Phase.AFTER, sourceDoc);

    } else if( schedule == Schedule.UPDATE_FORCED ) {
      // Forced update always take place
      listener.updatingDocument(Phase.BEFORE, sourceDoc);
      updateDocument(sourceDoc, dd, currentTargetDoc, updateSpecifier);
      listener.updatingDocument(Phase.AFTER, sourceDoc);

    } else if( false == updateSpecifier.isUpdateRequired() ) {
      // Document on database is same as the one requested. No
      // update required
      listener.documentSkippedBecauseUnchanged(sourceDoc);
     
    } else if( modified && schedule == Schedule.UPDATE_UNLESS_MODIFIED ) {
View Full Code Here

   
    // Check if doc exists in database
    JSONObject currentTargetDoc = null;
    boolean creationRequired = false;
    boolean modified = false;
    UpdateSpecifier updateSpecifier = null;
    try {
      if( false == couchDb.documentExists(docId) ) {
        creationRequired = true;
        updateSpecifier = UpdateSpecifier.computeUpdateSpecifier(sourceDoc, dd, null, schedule);
       
      } else {
        // Get document from database
        currentTargetDoc = couchDb.getDocument(docId);
       
        // Check if the document in database was modified
        modified = DocumentManifest.hasDocumentBeenModified(currentTargetDoc);
       
        // Figure out the differences between the source document and
        // the target document
        updateSpecifier = UpdateSpecifier.computeUpdateSpecifier(sourceDoc, dd, currentTargetDoc, schedule);
      }
    } catch(Exception e) {
      throw new Exception("Unable to access current document", e);
    }
   
    // Upload, if required
    if( creationRequired ) {
      logger.debug(sourceDoc.getId()+" creation required");
     
      listener.updatingDocument(Phase.BEFORE, sourceDoc);
      updateDocument(sourceDoc, dd, null, updateSpecifier);
      listener.updatingDocument(Phase.AFTER, sourceDoc);

    } else if( schedule == Schedule.UPDATE_FORCED ) {
      logger.debug(sourceDoc.getId()+" forced update");

      // Forced update always take place
      listener.updatingDocument(Phase.BEFORE, sourceDoc);
      updateDocument(sourceDoc, dd, currentTargetDoc, updateSpecifier);
      listener.updatingDocument(Phase.AFTER, sourceDoc);

    } else if( false == updateSpecifier.isUpdateRequired() ) {
      logger.debug(sourceDoc.getId()+" update not required");

      // Document on database is same as the one requested. No
      // update required
      listener.documentSkippedBecauseUnchanged(sourceDoc);
View Full Code Here

TOP

Related Classes of ca.carleton.gcrc.couch.app.impl.UpdateSpecifier

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.