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.
Short circuit on Smartling pull if no changes to translated files
- Loading branch information
Showing
8 changed files
with
233 additions
and
21 deletions.
There are no files selected for viewing
65 changes: 65 additions & 0 deletions
65
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,65 @@ | ||
package com.box.l10n.mojito.entity; | ||
|
||
import java.io.Serializable; | ||
import javax.persistence.Column; | ||
import javax.persistence.EmbeddedId; | ||
import javax.persistence.Entity; | ||
import javax.persistence.Index; | ||
import javax.persistence.Table; | ||
import org.hibernate.envers.Audited; | ||
import org.hibernate.envers.RelationTargetAuditMode; | ||
|
||
/** Entity that stores the checksum of a translated file downloaded via a third party sync. */ | ||
@Entity | ||
@Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED) | ||
@Table( | ||
name = "third_party_sync_file_checksum", | ||
indexes = { | ||
@Index( | ||
name = "UK__THIRD_PARTY_FILE_CHECKSUM__REPOSITORY_ID__FILE_NAME", | ||
columnList = "repository_id, file_name", | ||
unique = true), | ||
}) | ||
public class ThirdPartyFileChecksum implements Serializable { | ||
|
||
@EmbeddedId private ThirdPartyFileChecksumId thirdPartyFileChecksumId; | ||
|
||
@Column(name = "checksum") | ||
private String checksum; | ||
|
||
public ThirdPartyFileChecksum() {} | ||
|
||
public ThirdPartyFileChecksum( | ||
ThirdPartyFileChecksumId thirdPartyFileChecksumId, String checksum) { | ||
this.thirdPartyFileChecksumId = thirdPartyFileChecksumId; | ||
this.checksum = checksum; | ||
} | ||
|
||
public ThirdPartyFileChecksumId getThirdPartyFileChecksumId() { | ||
return thirdPartyFileChecksumId; | ||
} | ||
|
||
public void setThirdPartyFileChecksumId(ThirdPartyFileChecksumId thirdPartyFileChecksumId) { | ||
this.thirdPartyFileChecksumId = thirdPartyFileChecksumId; | ||
} | ||
|
||
public String getChecksum() { | ||
return checksum; | ||
} | ||
|
||
public void setChecksum(String checksum) { | ||
this.checksum = checksum; | ||
} | ||
|
||
public Locale getLocale() { | ||
return thirdPartyFileChecksumId.getLocale(); | ||
} | ||
|
||
public Repository getRepository() { | ||
return thirdPartyFileChecksumId.getRepository(); | ||
} | ||
|
||
public String getFileName() { | ||
return thirdPartyFileChecksumId.getFileName(); | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
webapp/src/main/java/com/box/l10n/mojito/entity/ThirdPartyFileChecksumId.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,59 @@ | ||
package com.box.l10n.mojito.entity; | ||
|
||
import java.io.Serializable; | ||
import javax.persistence.Column; | ||
import javax.persistence.Embeddable; | ||
import javax.persistence.ForeignKey; | ||
import javax.persistence.JoinColumn; | ||
import javax.persistence.ManyToOne; | ||
|
||
@Embeddable | ||
public class ThirdPartyFileChecksumId implements Serializable { | ||
|
||
@ManyToOne(optional = false) | ||
@JoinColumn( | ||
name = "repository_id", | ||
foreignKey = @ForeignKey(name = "FK__THIRD_PARTY_CHECKSUM__REPO__ID")) | ||
private Repository repository; | ||
|
||
@Column(name = "file_name") | ||
private String fileName; | ||
|
||
@ManyToOne(optional = false) | ||
@JoinColumn( | ||
name = "locale_id", | ||
foreignKey = @ForeignKey(name = "FK__THIRD_PARTY_CHECKSUM__LOCALE__ID")) | ||
private Locale locale; | ||
|
||
public ThirdPartyFileChecksumId() {} | ||
|
||
public ThirdPartyFileChecksumId(Repository repository, Locale locale, String fileName) { | ||
this.repository = repository; | ||
this.locale = locale; | ||
this.fileName = fileName; | ||
} | ||
|
||
public Locale getLocale() { | ||
return locale; | ||
} | ||
|
||
public void setLocale(Locale locale) { | ||
this.locale = locale; | ||
} | ||
|
||
public Repository getRepository() { | ||
return repository; | ||
} | ||
|
||
public void setRepository(Repository repository) { | ||
this.repository = repository; | ||
} | ||
|
||
public String getFileName() { | ||
return fileName; | ||
} | ||
|
||
public void setFileName(String fileName) { | ||
this.fileName = fileName; | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...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,15 @@ | ||
package com.box.l10n.mojito.service.thirdparty; | ||
|
||
import com.box.l10n.mojito.entity.ThirdPartyFileChecksum; | ||
import com.box.l10n.mojito.entity.ThirdPartyFileChecksumId; | ||
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, ThirdPartyFileChecksumId> { | ||
|
||
Optional<ThirdPartyFileChecksum> findByThirdPartyFileChecksumId( | ||
ThirdPartyFileChecksumId thirdPartyFileChecksumId); | ||
} |
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
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
3 changes: 3 additions & 0 deletions
3
webapp/src/main/resources/db/migration/V64__third_party_sync_file_checksum.sql
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,3 @@ | ||
create table third_party_sync_file_checksum (repository_id bigint not null, locale_id bigint not null, checksum char(32) not null, file_name varchar(255) not null); | ||
alter table third_party_sync_file_checksum add constraint FK__THIRD_PARTY_CHECKSUM__REPO__ID foreign key (repository_id) references repository (id); | ||
alter table third_party_sync_file_checksum add constraint FK__THIRD_PARTY_CHECKSUM__LOCALE__ID foreign key (locale_id) references locale (id); |
Oops, something went wrong.