forked from box/mojito
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce 'delta-pull' option to the third party sync command (#10)
Introduce a delta-pull option to the third party sync command, when enabled text unit imports will only occur for batches that contain updates. The implementation stores the checksum of a translated file pulled from a third party provider for a locale, on a subsequent sync compare the checksum of the current file with the stored checksum. If checksums match no changes have occurred and we will exit processing early for that locale.
- Loading branch information
Showing
11 changed files
with
607 additions
and
47 deletions.
There are no files selected for viewing
81 changes: 81 additions & 0 deletions
81
webapp/src/main/java/com/box/l10n/mojito/entity/ThirdPartyFileChecksum.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package com.box.l10n.mojito.entity; | ||
|
||
import javax.persistence.Column; | ||
import javax.persistence.Entity; | ||
import javax.persistence.ForeignKey; | ||
import javax.persistence.Index; | ||
import javax.persistence.JoinColumn; | ||
import javax.persistence.ManyToOne; | ||
import javax.persistence.Table; | ||
|
||
/** Entity that stores the checksum of a translated file downloaded via a third party sync. */ | ||
@Entity | ||
@Table( | ||
name = "third_party_sync_file_checksum", | ||
indexes = { | ||
@Index( | ||
name = "I__TPS_FILE_CHECKSUM__REPO_ID__LOCALE_ID__FILE_NAME", | ||
columnList = "repository_id, locale_id, file_name", | ||
unique = true), | ||
}) | ||
public class ThirdPartyFileChecksum extends AuditableEntity { | ||
|
||
@ManyToOne(optional = false) | ||
@JoinColumn( | ||
name = "repository_id", | ||
foreignKey = @ForeignKey(name = "FK__TPS_FILE_CHECKSUM__REPO__ID")) | ||
private Repository repository; | ||
|
||
@Column(name = "file_name") | ||
private String fileName; | ||
|
||
@ManyToOne(optional = false) | ||
@JoinColumn( | ||
name = "locale_id", | ||
foreignKey = @ForeignKey(name = "FK__TPS_FILE_CHECKSUM__LOCALE__ID")) | ||
private Locale locale; | ||
|
||
@Column(name = "md5") | ||
private String md5; | ||
|
||
public ThirdPartyFileChecksum() {} | ||
|
||
public ThirdPartyFileChecksum(Repository repository, String fileName, Locale locale, String md5) { | ||
this.repository = repository; | ||
this.fileName = fileName; | ||
this.locale = locale; | ||
this.md5 = md5; | ||
} | ||
|
||
public String getMd5() { | ||
return md5; | ||
} | ||
|
||
public void setMd5(String checksum) { | ||
this.md5 = checksum; | ||
} | ||
|
||
public Locale getLocale() { | ||
return locale; | ||
} | ||
|
||
public Repository getRepository() { | ||
return repository; | ||
} | ||
|
||
public String getFileName() { | ||
return fileName; | ||
} | ||
|
||
public void setLocale(Locale locale) { | ||
this.locale = locale; | ||
} | ||
|
||
public void setRepository(Repository repository) { | ||
this.repository = repository; | ||
} | ||
|
||
public void setFileName(String fileName) { | ||
this.fileName = fileName; | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...rc/main/java/com/box/l10n/mojito/service/thirdparty/ThirdPartyFileChecksumRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.box.l10n.mojito.service.thirdparty; | ||
|
||
import com.box.l10n.mojito.entity.Locale; | ||
import com.box.l10n.mojito.entity.Repository; | ||
import com.box.l10n.mojito.entity.ThirdPartyFileChecksum; | ||
import java.util.Optional; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.rest.core.annotation.RepositoryRestResource; | ||
|
||
@RepositoryRestResource(exported = false) | ||
public interface ThirdPartyFileChecksumRepository | ||
extends JpaRepository<ThirdPartyFileChecksum, Long> { | ||
|
||
Optional<ThirdPartyFileChecksum> findById(Long thirdPartyFileChecksumId); | ||
|
||
Optional<ThirdPartyFileChecksum> findByRepositoryAndFileNameAndLocale( | ||
Repository repository, String fileName, Locale locale); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.