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.
I18N-1318 - Add 'Introduced By' field to show the source URL that cre…
…ated a text unit (#189) * GH link for text unit information * Add configuration * Add regex matching for filtering branches that introduced TU * Add all Introduced In strings * Add table to track branch source URLS and text unit introduced branch * Refactoring * Add index to tables and log errors if saving fails * Add index and foreign keys to entities, fix push error due to empty branch mapping * Changes to SQL schema * Added default branch source url with repo override * Removed unused variable and prepare for rebase
- Loading branch information
1 parent
afe235c
commit 3748ffe
Showing
29 changed files
with
355 additions
and
4 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
webapp/src/main/java/com/box/l10n/mojito/entity/BranchSource.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,39 @@ | ||
package com.box.l10n.mojito.entity; | ||
|
||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.ForeignKey; | ||
import jakarta.persistence.Index; | ||
import jakarta.persistence.JoinColumn; | ||
import jakarta.persistence.ManyToOne; | ||
import jakarta.persistence.Table; | ||
|
||
@Entity | ||
@Table( | ||
name = "branch_source", | ||
indexes = {@Index(name = "I__BRANCH_SOURCE__BRANCH_ID", columnList = "branch_id")}) | ||
public class BranchSource extends BaseEntity { | ||
|
||
@ManyToOne | ||
@JoinColumn(name = "branch_id", foreignKey = @ForeignKey(name = "FK__BRANCH_SOURCE__BRANCH_ID")) | ||
private Branch branch; | ||
|
||
@Column(name = "url") | ||
private String url; | ||
|
||
public Branch getBranch() { | ||
return branch; | ||
} | ||
|
||
public void setBranch(Branch branch) { | ||
this.branch = branch; | ||
} | ||
|
||
public String getUrl() { | ||
return url; | ||
} | ||
|
||
public void setUrl(String url) { | ||
this.url = url; | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
webapp/src/main/java/com/box/l10n/mojito/entity/TMTextUnitToBranch.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,44 @@ | ||
package com.box.l10n.mojito.entity; | ||
|
||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.ForeignKey; | ||
import jakarta.persistence.Index; | ||
import jakarta.persistence.JoinColumn; | ||
import jakarta.persistence.ManyToOne; | ||
import jakarta.persistence.Table; | ||
|
||
@Entity | ||
@Table( | ||
name = "tm_text_unit_to_branch", | ||
indexes = { | ||
@Index(name = "I__TEXT_UNIT_TO_BRANCH__TEXT_UNIT_ID", columnList = "tm_text_unit_id") | ||
}) | ||
public class TMTextUnitToBranch extends BaseEntity { | ||
@ManyToOne | ||
@JoinColumn( | ||
name = "tm_text_unit_id", | ||
foreignKey = @ForeignKey(name = "FK__TM_TEXT_UNIT_TO_BRANCH__TM_TEXT_UNIT_ID")) | ||
private TMTextUnit tmTextUnit; | ||
|
||
@ManyToOne | ||
@JoinColumn( | ||
name = "branch_id", | ||
foreignKey = @ForeignKey(name = "FK__TM_TEXT_UNIT_TO_BRANCH__BRANCH_ID")) | ||
private Branch branch; | ||
|
||
public TMTextUnit getTmTextUnit() { | ||
return tmTextUnit; | ||
} | ||
|
||
public void setTmTextUnit(TMTextUnit tmTextUnit) { | ||
this.tmTextUnit = tmTextUnit; | ||
} | ||
|
||
public Branch getBranch() { | ||
return branch; | ||
} | ||
|
||
public void setBranch(Branch branch) { | ||
this.branch = branch; | ||
} | ||
} |
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
14 changes: 14 additions & 0 deletions
14
webapp/src/main/java/com/box/l10n/mojito/service/branch/BranchSource.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,14 @@ | ||
package com.box.l10n.mojito.service.branch; | ||
|
||
public class BranchSource { | ||
|
||
String url; | ||
|
||
public String getUrl() { | ||
return url; | ||
} | ||
|
||
public void setUrl(String url) { | ||
this.url = url; | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
webapp/src/main/java/com/box/l10n/mojito/service/branch/BranchSourceConfig.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,39 @@ | ||
package com.box.l10n.mojito.service.branch; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
@ConfigurationProperties("l10n.branch-sources") | ||
public class BranchSourceConfig { | ||
|
||
String url; | ||
String notFound = "-"; | ||
Map<String, BranchSource> repoOverride = new HashMap<>(); | ||
|
||
public String getUrl() { | ||
return url; | ||
} | ||
|
||
public void setUrl(String url) { | ||
this.url = url; | ||
} | ||
|
||
public String getNotFound() { | ||
return notFound; | ||
} | ||
|
||
public void setNotFound(String notFound) { | ||
this.notFound = notFound; | ||
} | ||
|
||
public Map<String, BranchSource> getRepoOverride() { | ||
return repoOverride; | ||
} | ||
|
||
public void setRepoOverride(Map<String, BranchSource> repoOverride) { | ||
this.repoOverride = repoOverride; | ||
} | ||
} |
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
16 changes: 16 additions & 0 deletions
16
webapp/src/main/java/com/box/l10n/mojito/service/tm/BranchSourceRepository.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,16 @@ | ||
package com.box.l10n.mojito.service.tm; | ||
|
||
import com.box.l10n.mojito.entity.BranchSource; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
|
||
public interface BranchSourceRepository extends JpaRepository<BranchSource, Long> { | ||
@Query( | ||
value = | ||
"SELECT bs.*" | ||
+ " FROM branch_source bs" | ||
+ " JOIN tm_text_unit_to_branch tutb ON tutb.branch_id = bs.branch_id" | ||
+ " WHERE tutb.tm_text_unit_id = :textUnitId", | ||
nativeQuery = true) | ||
BranchSource findByTextUnitId(Long textUnitId); | ||
} |
6 changes: 6 additions & 0 deletions
6
webapp/src/main/java/com/box/l10n/mojito/service/tm/TMTextUnitToBranchRepository.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,6 @@ | ||
package com.box.l10n.mojito.service.tm; | ||
|
||
import com.box.l10n.mojito.entity.TMTextUnitToBranch; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface TMTextUnitToBranchRepository extends JpaRepository<TMTextUnitToBranch, Long> {} |
25 changes: 25 additions & 0 deletions
25
webapp/src/main/resources/db/migration/V72__Add_branch_source.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,25 @@ | ||
CREATE TABLE tm_text_unit_to_branch( | ||
id BIGINT AUTO_INCREMENT PRIMARY KEY, | ||
tm_text_unit_id BIGINT NOT NULL, | ||
branch_id BIGINT NOT NULL | ||
); | ||
|
||
ALTER TABLE tm_text_unit_to_branch | ||
ADD CONSTRAINT FK__TM_TEXT_UNIT_TO_BRANCH__TM_TEXT_UNIT_ID FOREIGN KEY (tm_text_unit_id) REFERENCES tm_text_unit(id); | ||
|
||
ALTER TABLE tm_text_unit_to_branch | ||
ADD CONSTRAINT FK__TM_TEXT_UNIT_TO_BRANCH__BRANCH_ID FOREIGN KEY (branch_id) REFERENCES branch(id); | ||
|
||
create index I__TEXT_UNIT_TO_BRANCH__TEXT_UNIT_ID on tm_text_unit_to_branch (tm_text_unit_id); | ||
|
||
CREATE TABLE branch_source( | ||
id BIGINT AUTO_INCREMENT PRIMARY KEY, | ||
branch_id BIGINT NOT NULL, | ||
url VARCHAR(255) NOT NULL | ||
); | ||
|
||
ALTER TABLE branch_source | ||
ADD CONSTRAINT FK__BRANCH_SOURCE__BRANCH_ID FOREIGN KEY (branch_id) REFERENCES branch(id); | ||
|
||
create index I__BRANCH_SOURCE__BRANCH_ID on branch_source (branch_id); | ||
|
Oops, something went wrong.