-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: added dependencies and code to cater for entity objects * chore: test persistence * chore: removed unused DAO class * chore: fixed issues w/ validation and ovverriding rules in subclasses * chore: restored GitService
- Loading branch information
Showing
18 changed files
with
315 additions
and
118 deletions.
There are no files selected for viewing
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
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
36 changes: 36 additions & 0 deletions
36
common/src/main/java/org/cardanofoundation/tokenmetadata/registry/entity/TokenLogo.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,36 @@ | ||
package org.cardanofoundation.tokenmetadata.registry.entity; | ||
|
||
import jakarta.persistence.*; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
import org.cardanofoundation.tokenmetadata.registry.model.Mapping; | ||
import org.hibernate.annotations.JdbcTypeCode; | ||
import org.hibernate.type.SqlTypes; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.Objects; | ||
|
||
@Entity | ||
@Table(name = "logo") | ||
@Getter | ||
@Setter | ||
public class TokenLogo { | ||
|
||
@Id | ||
private String subject; | ||
|
||
private String logo; | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
TokenLogo tokenLogo = (TokenLogo) o; | ||
return Objects.equals(subject, tokenLogo.subject); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(subject); | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
common/src/main/java/org/cardanofoundation/tokenmetadata/registry/entity/TokenMetadata.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,56 @@ | ||
package org.cardanofoundation.tokenmetadata.registry.entity; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
import jakarta.persistence.*; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
import org.cardanofoundation.tokenmetadata.registry.model.Mapping; | ||
import org.hibernate.annotations.JdbcTypeCode; | ||
import org.hibernate.type.SqlTypes; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.Objects; | ||
|
||
@Entity | ||
@Table(name = "metadata") | ||
@Getter | ||
@Setter | ||
public class TokenMetadata { | ||
|
||
@Id | ||
private String subject; | ||
|
||
private String policy; | ||
|
||
private String name; | ||
|
||
private String ticker; | ||
|
||
private String url; | ||
|
||
private String description; | ||
|
||
private Long decimals; | ||
|
||
@Temporal(TemporalType.TIMESTAMP) | ||
private LocalDateTime updated; | ||
|
||
private String updatedBy; | ||
|
||
@JdbcTypeCode(SqlTypes.JSON) | ||
private Mapping properties; | ||
|
||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
TokenMetadata that = (TokenMetadata) o; | ||
return Objects.equals(subject, that.subject); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(subject); | ||
} | ||
} |
76 changes: 0 additions & 76 deletions
76
.../main/java/org/cardanofoundation/tokenmetadata/registry/persistence/TokenMetadataDao.java
This file was deleted.
Oops, something went wrong.
10 changes: 10 additions & 0 deletions
10
...ain/java/org/cardanofoundation/tokenmetadata/registry/repository/TokenLogoRepository.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,10 @@ | ||
package org.cardanofoundation.tokenmetadata.registry.repository; | ||
|
||
import org.cardanofoundation.tokenmetadata.registry.entity.TokenLogo; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
public interface TokenLogoRepository extends JpaRepository<TokenLogo, String> { | ||
|
||
} |
10 changes: 10 additions & 0 deletions
10
...java/org/cardanofoundation/tokenmetadata/registry/repository/TokenMetadataRepository.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,10 @@ | ||
package org.cardanofoundation.tokenmetadata.registry.repository; | ||
|
||
import org.cardanofoundation.tokenmetadata.registry.entity.TokenMetadata; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
public interface TokenMetadataRepository extends JpaRepository<TokenMetadata, String> { | ||
|
||
} |
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
46 changes: 46 additions & 0 deletions
46
common/src/main/java/org/cardanofoundation/tokenmetadata/registry/util/MappingsUtil.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,46 @@ | ||
package org.cardanofoundation.tokenmetadata.registry.util; | ||
|
||
import org.cardanofoundation.tokenmetadata.registry.entity.TokenLogo; | ||
import org.cardanofoundation.tokenmetadata.registry.entity.TokenMetadata; | ||
import org.cardanofoundation.tokenmetadata.registry.model.Item; | ||
import org.cardanofoundation.tokenmetadata.registry.model.Mapping; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.Optional; | ||
import java.util.function.Function; | ||
|
||
public class MappingsUtil { | ||
|
||
public static TokenMetadata toTokenMetadata(Mapping mapping, String updateBy, LocalDateTime updatedAt) { | ||
var tokenMetadata = new TokenMetadata(); | ||
tokenMetadata.setSubject(mapping.subject()); | ||
tokenMetadata.setPolicy(mapping.policy()); | ||
tokenMetadata.setName(getValue(mapping.name())); | ||
tokenMetadata.setTicker(getValue(mapping.ticker())); | ||
tokenMetadata.setUrl(getValue(mapping.url())); | ||
tokenMetadata.setDescription(getValue(mapping.description())); | ||
tokenMetadata.setDecimals(getValue(mapping.decimals(), Long::valueOf)); | ||
tokenMetadata.setUpdated(updatedAt); | ||
tokenMetadata.setUpdatedBy(updateBy); | ||
tokenMetadata.setProperties(mapping); | ||
return tokenMetadata; | ||
} | ||
|
||
public static TokenLogo toTokenLogo(Mapping mapping) { | ||
var tokenLogo = new TokenLogo(); | ||
tokenLogo.setSubject(mapping.subject()); | ||
tokenLogo.setLogo(getValue(mapping.logo())); | ||
return tokenLogo; | ||
} | ||
|
||
|
||
private static String getValue(Item item) { | ||
return getValue(item, Function.identity()); | ||
} | ||
|
||
private static <T> T getValue(Item item, Function<String, T> f) { | ||
return Optional.ofNullable(item).map(Item::value).map(f).orElse(null); | ||
} | ||
|
||
|
||
} |
Oops, something went wrong.