Skip to content

Commit

Permalink
feat: Create BPN VC while creating wallet, test case modification, fi…
Browse files Browse the repository at this point in the history
…lter support added in get all wallet and get all credential API
  • Loading branch information
nitin-vavdiya committed May 30, 2023
1 parent 8861877 commit 928c501
Show file tree
Hide file tree
Showing 18 changed files with 162 additions and 73 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.smartsensesolutions.java.commons.specification.SpecificationUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springdoc.core.properties.SwaggerUiConfigProperties;
Expand Down Expand Up @@ -58,6 +59,11 @@ public ObjectMapper objectMapper() {
return objectMapper;
}

@Bean
public SpecificationUtil specificationUtil() {
return new SpecificationUtil<>();
}

@Override
public void addViewControllers(ViewControllerRegistry registry) {
String redirectUri = properties.getPath();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.eclipse.tractusx.managedidentitywallets.dto.IssueMembershipCredentialRequest;
import org.eclipse.tractusx.managedidentitywallets.service.CredentialService;
import org.eclipse.tractusx.ssi.lib.model.verifiable.credential.VerifiableCredential;
import org.springframework.data.domain.Page;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
Expand Down Expand Up @@ -60,8 +61,14 @@ public class CredentialController {
*/
@Operation(description = "Permission: **view_wallets** OR **view_wallet** (The BPN of holderIdentifier must equal BPN of caller)\n\n Search verifiable credentials with filter criteria", summary = "Query Verifiable Credentials")
@GetMapping(path = RestURI.CREDENTIALS, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Credential>> getCredentials(@RequestParam(required = false) String holderIdentifier, @RequestParam(required = false) String id, @RequestParam(required = false) String issuerIdentifier, @RequestParam(required = false) List<String> type) {
return ResponseEntity.status(HttpStatus.OK).body(service.getCredentials(holderIdentifier, id, issuerIdentifier, type));
public ResponseEntity<Page<Credential>> getCredentials(@RequestParam(required = false) String holderIdentifier, @RequestParam(required = false) String id,
@RequestParam(required = false) String issuerIdentifier,
@RequestParam(required = false) List<String> type,
@RequestParam(required = false, defaultValue = "0") int pageNumber,
@RequestParam(required = false, defaultValue = Integer.MAX_VALUE + "") int size,
@RequestParam(required = false, defaultValue = "createdAt") String sortColumn,
@RequestParam(required = false, defaultValue = "desc") String sortTpe) {
return ResponseEntity.status(HttpStatus.OK).body(service.getCredentials(holderIdentifier, id, issuerIdentifier, type, pageNumber, size, sortColumn, sortTpe));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@
import org.eclipse.tractusx.managedidentitywallets.dao.entity.Wallet;
import org.eclipse.tractusx.managedidentitywallets.dto.CreateWalletRequest;
import org.eclipse.tractusx.managedidentitywallets.service.WalletService;
import org.springframework.data.domain.Page;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
Expand Down Expand Up @@ -129,7 +129,10 @@ public ResponseEntity<Wallet> getWalletByIdentifier(@PathVariable(name = "identi
*/
@Operation(summary = "List of wallets", description = "Permission: **view_wallets** \n\n Retrieve list of registered wallets")
@GetMapping(path = RestURI.WALLETS, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Wallet>> getWallets() {
return ResponseEntity.status(HttpStatus.OK).body(service.getWallets());
public ResponseEntity<Page<Wallet>> getWallets(@RequestParam(required = false, defaultValue = "0") int pageNumber,
@RequestParam(required = false, defaultValue = Integer.MAX_VALUE + "") int size,
@RequestParam(required = false, defaultValue = "createdAt") String sortColumn,
@RequestParam(required = false, defaultValue = "desc") String sortTpe) {
return ResponseEntity.status(HttpStatus.OK).body(service.getWallets(pageNumber, size, sortColumn, sortTpe));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class Credential extends BaseEntity {
public class Credential extends MIWBaseEntity {


@Id
Expand All @@ -47,10 +47,10 @@ public class Credential extends BaseEntity {
private Long id;

@Column(nullable = false)
private Long holder;
private String holderDid;

@Column(nullable = false)
private Long issuer;
private String issuerDid;

@Column(nullable = false)
private String type;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
package org.eclipse.tractusx.managedidentitywallets.dao.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.smartsensesolutions.java.commons.base.entity.BaseEntity;
import jakarta.persistence.Column;
import jakarta.persistence.MappedSuperclass;
import jakarta.persistence.Temporal;
Expand All @@ -43,7 +44,7 @@
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class BaseEntity {
public class MIWBaseEntity implements BaseEntity {

@JsonIgnore
@CreationTimestamp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class Wallet extends BaseEntity {
public class Wallet extends MIWBaseEntity {

@Id
@JsonIgnore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class WalletKey extends BaseEntity{
public class WalletKey extends MIWBaseEntity {

@Id
@JsonIgnore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@

package org.eclipse.tractusx.managedidentitywallets.dao.repository;

import com.smartsensesolutions.java.commons.base.repository.BaseRepository;
import org.eclipse.tractusx.managedidentitywallets.dao.entity.Credential;
import org.eclipse.tractusx.ssi.lib.model.verifiable.credential.VerifiableCredential;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

Expand All @@ -32,39 +32,39 @@
/**
* The interface Credential repository.
*/
public interface CredentialRepository extends JpaRepository<Credential, Long> {
public interface CredentialRepository extends BaseRepository<Credential, Long> {
/**
* Gets by holder.
* Gets by holder did.
*
* @param id the id
* @return the by holder
* @param holderDid the holder did
* @return the by holder did
*/
List<Credential> getByHolder(Long id);
List<Credential> getByHolderDid(String holderDid);

/**
* Gets credentials by holder.
*
* @param holder the holder
* @param holderDid the holder did
* @return the credentials by holder
*/
@Query("select data from Credential where holder=:holder")
List<VerifiableCredential> getCredentialsByHolder(@Param("holder") Long holder);
@Query("select data from Credential where holderDid=:holderDid")
List<VerifiableCredential> getCredentialsByHolder(@Param("holderDid") String holderDid);

/**
* Gets by holder and type.
* Gets by holder did and type.
*
* @param holderWalletId the holder wallet id
* @param type the type
* @return the by holder and type
* @param holderDid the holder did
* @param type the type
* @return the by holder did and type
*/
Credential getByHolderAndType(Long holderWalletId, String type);
Credential getByHolderDidAndType(String holderDid, String type);

/**
* Exists by holder and type boolean.
* Exists by holder did and type boolean.
*
* @param holderWalletId the holder wallet id
* @param type the type
* @param holderDid the holder did
* @param type the type
* @return the boolean
*/
boolean existsByHolderAndType(Long holderWalletId, String type);
boolean existsByHolderDidAndType(String holderDid, String type);
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@

package org.eclipse.tractusx.managedidentitywallets.dao.repository;

import com.smartsensesolutions.java.commons.base.repository.BaseRepository;
import org.eclipse.tractusx.managedidentitywallets.dao.entity.WalletKey;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

/**
* The interface Wallet key repository.
*/
@Repository
public interface WalletKeyRepository extends JpaRepository<WalletKey, Long> {
public interface WalletKeyRepository extends BaseRepository<WalletKey, Long> {
/**
* Gets by wallet id.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@

package org.eclipse.tractusx.managedidentitywallets.dao.repository;

import com.smartsensesolutions.java.commons.base.repository.BaseRepository;
import org.eclipse.tractusx.managedidentitywallets.dao.entity.Wallet;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

/**
* The interface Wallet repository.
*/
@Repository
public interface WalletRepository extends JpaRepository<Wallet, Long> {
public interface WalletRepository extends BaseRepository<Wallet, Long> {

/**
* Gets by bpn.
Expand Down
Loading

0 comments on commit 928c501

Please sign in to comment.