Skip to content

Commit

Permalink
Merge pull request #35 from catenax-ng/feat/DCMFOSS-113
Browse files Browse the repository at this point in the history
Feat/dcmfoss 113
  • Loading branch information
Diogo12246 authored Jan 29, 2024
2 parents e887213 + b815721 commit faff8f6
Show file tree
Hide file tree
Showing 8 changed files with 650 additions and 183 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ target/
.idea/*

demand-capacity-mgmt-backend/.mvn/wrapper/maven-wrapper.jar
.env
keycloak/generate-secret.sh
keycloak/init-db.sql
keycloak/realm-export.json
Expand Down
7 changes: 7 additions & 0 deletions demand-capacity-mgmt-backend/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
BASE_URL=
API_KEY=

TOKEN_ENDPOINT=
CLIENT_ID=
CLIENT_SECRET=
GRANT_TYPE=
6 changes: 6 additions & 0 deletions demand-capacity-mgmt-backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@

</properties>
<dependencies>
<dependency>
<groupId>io.github.cdimascio</groupId>
<artifactId>java-dotenv</artifactId>
<version>5.2.2</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

import eclipse.tractusx.demand_capacity_mgmt_specification.api.DemandCategoryApi;
import eclipse.tractusx.demand_capacity_mgmt_specification.model.DemandCategoryResponse;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import java.util.List;
import lombok.AllArgsConstructor;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.services.DemandCategoryService;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.controllers;

import eclipse.tractusx.demand_capacity_mgmt_specification.api.EdcApi;
import eclipse.tractusx.demand_capacity_mgmt_specification.model.*;
import java.util.List;
import lombok.AllArgsConstructor;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.services.EDCService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

@RestController
@AllArgsConstructor
public class EDCController implements EdcApi {

private final EDCService edcService;

@Override
public ResponseEntity<List<Asset>> createAssetRequest(QuerySpec querySpec) throws Exception {
return ResponseEntity.ok(edcService.createAssetRequest(querySpec));
}

@Override
public ResponseEntity<IdResponse> createContract(ContractDefinitionInput contractDefinitionInput) throws Exception {
return ResponseEntity.ok(edcService.createContractDef(contractDefinitionInput).block());
}

@Override
public ResponseEntity<List<ContractDefinitionOutput>> createContractRequest(QuerySpec querySpec) throws Exception {
return ResponseEntity.ok(edcService.createContractDefRequest(querySpec));
}

@Override
public ResponseEntity<IdResponse> createPolicy(PolicyDefinitionInput policyDefinitionInput) throws Exception {
return ResponseEntity.ok(edcService.createPolicy(policyDefinitionInput).block());
}

@Override
public ResponseEntity<List<PolicyDefinitionOutput>> createPolicyRequest(QuerySpec querySpec) throws Exception {
return ResponseEntity.ok(edcService.createPolicyRequest(querySpec));
}

@Override
public ResponseEntity<Void> deleteAssetById(String assetId) throws Exception {
return ResponseEntity.ok(edcService.deleteAsset(assetId));
}

@Override
public ResponseEntity<Void> deleteContractById(String contractId) throws Exception {
return ResponseEntity.ok(edcService.deleteContractDef(contractId));
}

@Override
public ResponseEntity<Void> deletePolicyById(String policyId) throws Exception {
return ResponseEntity.ok(edcService.deletePolicy(policyId));
}

@Override
public ResponseEntity<AccessTokenResponse> getAccessToken() throws Exception {
return ResponseEntity.ok(edcService.getAccessToken().block());
}

@Override
public ResponseEntity<Asset> getAssetById(String assetId) throws Exception {
return ResponseEntity.ok(edcService.getAsset(assetId));
}

@Override
public ResponseEntity<ContractDefinitionOutput> getContractById(String contractId) throws Exception {
return ResponseEntity.ok(edcService.getContractDef(contractId));
}

@Override
public ResponseEntity<PolicyDefinitionOutput> getPolicyById(String policyId) throws Exception {
return ResponseEntity.ok(edcService.getPolicy(policyId));
}

@Override
public ResponseEntity<IdResponse> registerAsset(AssetEntryNewDto assetInput) throws Exception {
return ResponseEntity.ok(edcService.createAsset(assetInput).block());
}
}
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
package org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.services;

import eclipse.tractusx.demand_capacity_mgmt_specification.model.*;
import java.util.List;
import javax.xml.catalog.Catalog;
import org.springframework.http.ResponseEntity;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

public interface EDCService {
Mono<IdResponse> createAsset(AssetInput dto);
Mono<IdResponse> createAsset(AssetEntryNewDto dto);

Flux<AssetOutput> createAssetRequest(QuerySpec dto);
List<Asset> createAssetRequest(QuerySpec dto);

Mono<AssetOutput> getAsset(String assetId);
Asset getAsset(String assetId);

Mono<Void> deleteAsset(String assetId);
Void deleteAsset(String assetId);

Mono<IdResponse> createPolicy(PolicyDefinitionInput dto);

Flux<PolicyDefinitionOutput> createPolicyRequest(QuerySpec dto);
List<PolicyDefinitionOutput> createPolicyRequest(QuerySpec dto);

Mono<PolicyDefinitionOutput> getPolicy(String policyId);
PolicyDefinitionOutput getPolicy(String policyId);

Mono<Void> deletePolicy(String policyId);
Void deletePolicy(String policyId);

Mono<IdResponse> createContractDef(ContractDefinitionInput dto);

Flux<ContractDefinitionOutput> createContractDefRequest(QuerySpec dto);
List<ContractDefinitionOutput> createContractDefRequest(QuerySpec dto);

Mono<ContractDefinitionOutput> getContractDef(String contractDefId);
ContractDefinitionOutput getContractDef(String contractDefId);

Mono<Void> deleteContractDef(String contractDefId);
Void deleteContractDef(String contractDefId);

Mono<Catalog> createCatalogRequest(CatalogRequest dto);

Expand All @@ -45,6 +45,8 @@ public interface EDCService {

Mono<IdResponse> createEDR(NegotiateEdrRequest dto);

Mono<AccessTokenResponse> getAccessToken();

Mono<DataAddress> getEDR(String edrId);

Mono<Void> deleteEDR(String edrId);
Expand Down
Loading

0 comments on commit faff8f6

Please sign in to comment.