コード例 #1
0
 public void buildDiscoverySave(Capsule capsule, CapsuleContract.SyncStateAction syncAction) {
   // Make sure there is a sync ID
   if (capsule.getSyncId() <= 0) {
     throw new InvalidParameterException("The Capsule does not have a sync ID");
   }
   // Determine the best IDs for the Capsule
   CapsuleOperations.Capsules.determineBestId(this.mResolver, this, capsule);
   CapsuleOperations.Discoveries.determineBestId(this.mResolver, this, (CapsuleDiscovery) capsule);
   // Build INSERT/UPDATE operations depending on if the Capsule and Discovery already exist
   if (capsule.getId() > 0) {
     // Capsule UPDATE
     this.buildCapsuleUpdate(capsule, /* withYield */ true);
     // Check if the Discovery exists
     if (((CapsuleDiscovery) capsule).getDiscoveryId() > 0) {
       // Discovery UPDATE
       this.buildDiscoveryUpdate((CapsuleDiscovery) capsule, /* withYield */ false, syncAction);
     } else {
       // Discovery INSERT
       this.buildDiscoveryInsert((CapsuleDiscovery) capsule, /* withYield */ false, syncAction);
     }
   } else {
     // Capsule INSERT
     this.buildCapsuleInsert(capsule, /* withYield */ true);
     // Check if the Discovery exists
     if (((CapsuleDiscovery) capsule).getDiscoveryId() > 0) {
       // Discovery UPDATE
       this.buildDiscoveryUpdate(
           (CapsuleDiscovery) capsule, /* withYield */
           false,
           this.getLastOperationIndex(),
           syncAction);
     } else {
       // Discovery INSERT
       this.buildDiscoveryInsert(
           (CapsuleDiscovery) capsule, /* withYield */
           false,
           this.getLastOperationIndex(),
           syncAction);
     }
   }
 }
コード例 #2
0
 public void buildOwnershipSave(Capsule capsule, CapsuleContract.SyncStateAction syncAction) {
   // Determine the best IDs for the Capsule
   CapsuleOperations.Capsules.determineBestId(this.mResolver, this, capsule);
   CapsuleOperations.Ownerships.determineBestId(this.mResolver, this, (CapsuleOwnership) capsule);
   // Build the INSERT/UPDATE operations depending on if the Capsule and Ownership exist
   if (capsule.getId() > 0) {
     // Capsule UPDATE
     this.buildCapsuleUpdate(capsule, /* withYield */ true);
     // Check if the Ownership exists
     if (((CapsuleOwnership) capsule).getOwnershipId() > 0) {
       // Ownership UPDATE
       this.buildOwnershipUpdate((CapsuleOwnership) capsule, /* withYield */ false, syncAction);
     } else {
       // Ownership INSERT
       this.buildOwnershipInsert((CapsuleOwnership) capsule, /* withYield */ false, syncAction);
     }
   } else {
     // Capsule INSERT
     this.buildCapsuleInsert(capsule, /* withYield */ true);
     // Check if the Ownership exists
     if (((CapsuleOwnership) capsule).getOwnershipId() > 0) {
       // Ownership UPDATE
       this.buildOwnershipUpdate(
           (CapsuleOwnership) capsule, /* withYield */
           false,
           this.getLastOperationIndex(),
           syncAction);
     } else {
       // Ownership INSERT
       this.buildOwnershipInsert(
           (CapsuleOwnership) capsule, /* withYield */
           false,
           this.getLastOperationIndex(),
           syncAction);
     }
   }
 }