Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into Demo_branch
Browse files Browse the repository at this point in the history
  • Loading branch information
OSousa117 committed Oct 17, 2023
2 parents 89344c3 + f3833ea commit 44e42d6
Show file tree
Hide file tree
Showing 19 changed files with 190 additions and 62 deletions.
122 changes: 118 additions & 4 deletions INSTALL.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,123 @@
Prerequisites:
- Have helm installed on your machine
- Ensure you have both Helm and Kind installed.

Installing Helm:

Helm is the package manager for Kubernetes. You can get helm from here: https://github.com/helm/helm/releases

-------------------------------------------------------------------------------

Installing Kind:

Kind stands for "Kubernetes in Docker". It's used for running local Kubernetes clusters using Docker containers as nodes. And you can get it from here: https://kind.sigs.k8s.io/docs/user/quick-start/

Now that you have Helm and Kind installed, let's create a cluster, this way we can run the helms charts.

For that we run the following command on a terminal:

kind create cluster --name {NAME_OF_CLUSTER}

And then you can see your cluster by entering:

kind get clusters

-------------------------------------------------------------------------------

Now that you saw your cluster follow the steps below to install the DCM application.

You can get helm from here: https://github.com/helm/helm/releases

To install the images we need to run this command on the root folder:

```helm install dcm ./charts/demand-capacity-management ```
helm install dcm ./charts/demand-capacity-management


Now that you have the application running let's work on the MIW.

-------------------------------------------------------------------------------

For that we will need a version of MIW running that you can now open a terminal and paste:

git clone https://github.com/eclipse-tractusx/managed-identity-wallet

On your IDE open the MIW project and open charts/values

You need to change:

- authorityWallet.bpn: BPN of your company

Here in this file there is also other options that you can play with such as requests.requests.


And then on the terminal:

cd managed-identity-wallet/charts/managed-identity-wallet
helm dependency build
helm install miw .

Wait a little bit for the pod to be up and running after that run:

kubectl port-forward {POD_NAME} 9000:8080

To see the pod's name open a new terminal and enter:

kubectl get pods -A

To see in which port he is running enter:

kubectl get services

Now if you go to http://localhost:9000 you can see that your MIW instance is running.

-------------------------------------------------------------------------------

Now for the EDC we will need an instance of keycloak running, and for that you can run the following command on the terminal:

docker run -p 8080:8080 -e KEYCLOAK_ADMIN={choose} -e KEYCLOAK_ADMIN_PASSWORD={choose} quay.io/keycloak/keycloak:22.0.4 start-dev

And then go to http://localhost:8080 and then Administration Console, and log with the user and password that you choose on previous command.
After that, click on master on the left side, and choose Create Realm -> Browse -> {your_computer_path}\managed-identity-wallet\dev-assets\docker-environment\keycloak\miw_test_realm_local.json -> create

Now that you have your realm created, go to Realm settings on the bottom left, and then on Endpoints open: OpenID Endpoint Configuration, you will need this for later, for ssi.oauth.tokenurl.

-------------------------------------------------------------------------------

Still for the edc go to https://centralidp.int.demo.catena-x.net/auth/realms/CX-Central/protocol/openid-connect/auth?client_id=Cl2-CX-Portal&redirect_uri=https%3A%2F%2Fportal.int.demo.catena-x.net%2Ftechuserdetails%2Fa76bf67a-ffd4-4647-8699-070312cef9b6&state=3ebf0332-fba4-4bbb-b89b-567f385e9820&response_mode=fragment&response_type=code&scope=openid&nonce=6a02c519-b57e-4c40-9d0d-744d5b4c7ea4&code_challenge=7QetODkKyomOr3skQhicyt1-WtPb-nD1-NaQL08Vz5g&code_challenge_method=S256
Search for your portal company and login.

And now we need to create a user for the edc.

Click on the user icon, on the top right -> User Management -> Technical User Management -> Create Technical User

Choose the Username, the Description, select Identity Wallet Management and then Click Confirm. And you have your user for MIW created!.

-------------------------------------------------------------------------------

We are almost ready to run the EDC.

for that open a terminal and enter:

git clone https://github.com/eclipse-tractusx/tractusx-edc

On your IDE open the EDC project and open charts/tractusx-connector-memory/values

You need to change:

- participant.id: BPN of your company
- ssi.miw.url: http://localhost:9000
- ssi.miw.authorityId: BPN of your company
- ssi.oauth.tokenurl: OpenID Endpoint Configuration link
- ssi.oauth.client.id: id of your MIW user
- secretAlias: "client-secret" #The alias under which the client secret is stored in the vault.

then on the terminal:

cd charts/tractusx-connector-memory
helm repo add tractusx-edc https://eclipse-tractusx.github.io/charts/dev
helm install edc . --set vault.secrets="client-secret:$YOUR_CLIENT_SECRET"

Now just wait a little bit, and you have your instance of EDC up and Running






Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import eclipse.tractusx.demand_capacity_mgmt_specification.model.MaterialDemandResponse;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import java.util.List;
import java.util.List;

import jakarta.servlet.http.HttpServletRequest;
import lombok.AllArgsConstructor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

import eclipse.tractusx.demand_capacity_mgmt_specification.api.WeekBasedCapacityGroupApi;
import eclipse.tractusx.demand_capacity_mgmt_specification.model.*;
import eclipse.tractusx.demand_capacity_mgmt_specification.model.WeekBasedCapacityGroupDtoRequest;
import eclipse.tractusx.demand_capacity_mgmt_specification.model.WeekBasedCapacityGroupDtoResponse;
import eclipse.tractusx.demand_capacity_mgmt_specification.model.WeekBasedCapacityGroupRequest;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,10 @@

import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
import io.micrometer.core.lang.Nullable;
import jakarta.persistence.*;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import java.util.List;
import java.util.List;
import java.util.UUID;
import java.util.UUID;
import lombok.*;
import lombok.AllArgsConstructor;
import lombok.Builder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import lombok.NoArgsConstructor;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.entities.converters.WeekBasedCapacityGroupConverter;
import org.hibernate.annotations.ColumnTransformer;
import org.hibernate.annotations.GenericGenerator;

@Entity
@Table(name = "week_based_capacity")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import lombok.NoArgsConstructor;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.entities.converters.WeekBasedMaterialConverter;
import org.hibernate.annotations.ColumnTransformer;
import org.hibernate.annotations.GenericGenerator;

@Entity
@Table(name = "week_based_material_demand")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,16 @@
import java.util.UUID;
import java.util.concurrent.atomic.AtomicBoolean;
import lombok.RequiredArgsConstructor;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import lombok.extern.slf4j.Slf4j;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.entities.*;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.entities.*;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.entities.enums.EventObjectType;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.entities.enums.EventType;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.entities.enums.FavoriteType;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.exceptions.type.NotFoundException;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.repositories.*;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.services.*;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.utils.DataConverterUtil;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.services.CapacityGroupService;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.services.CompanyService;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.utils.UUIDUtil;
import org.springframework.stereotype.Service;

Expand All @@ -59,9 +57,7 @@ public class CapacityGroupServiceImpl implements CapacityGroupService {
private final CapacityGroupRepository capacityGroupRepository;
private final StatusesRepository statusesRepository;
private final DemandSeriesRepository demandSeriesRepository;

private final UserRepository userRepository;

private final LoggingHistoryService loggingHistoryService;
private final FavoriteService favoriteService;
private static List<CapacityGroupEntity> oldCapacityGroups;
Expand All @@ -80,7 +76,6 @@ public CapacityGroupResponse createCapacityGroup(CapacityGroupRequest capacityGr
linkedCapacityGroupMaterialDemandRepository.save(entity);
}
oldCapacityGroups = capacityGroupRepository.findAll();
//TODO: update the link Status here
updateStatus(userID);
return convertCapacityGroupDto(capacityGroupEntity);
}
Expand Down Expand Up @@ -127,6 +122,7 @@ private void postLogs(String capacityGroupId) {
loggingHistoryService.createLog(loggingHistoryRequest);
}


@Override
public void linkCapacityGroupToMaterialDemand(LinkCGDSRequest linkCGDSRequest,String userID) {
oldCapacityGroups = capacityGroupRepository.findAll();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ public class DemandServiceImpl implements DemandService {
private final CapacityGroupRepository capacityGroupRepository;
private final LinkedCapacityGroupMaterialDemandRepository linkedCapacityGroupMaterialDemandRepository;


@Override
public MaterialDemandResponse createDemand(MaterialDemandRequest materialDemandRequest,String userID) {
validateMaterialDemandRequestFields(materialDemandRequest);
Expand Down Expand Up @@ -144,6 +143,11 @@ public List<MaterialDemandResponse> getAllDemandsByProjectId() {
return demandEntityList.stream().map(this::convertDemandResponseDto).toList();
}

@Override
public MaterialDemandEntity getDemandEntityById(String demandId) {
return null;
}

@Override
public MaterialDemandResponse getDemandById(String demandId) {
MaterialDemandEntity demand = getDemandEntity(demandId);
Expand All @@ -166,11 +170,6 @@ private List<MaterialDemandEntity> getAllDemands() {
return materialDemandRepository.findAll();
}

@Override
public MaterialDemandEntity getDemandEntityById(String demandId) {
return getDemandEntity(demandId);
}

@Override
public void deleteDemandById(String demandId) {
MaterialDemandEntity demand = getDemandEntity(demandId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ private FavoriteResponse convertFavoriteResponse(FavoriteEntity request) {
FavoriteResponse response = new FavoriteResponse();
response.setFavoriteId(request.getId().toString());
response.setfType(request.getType().name());
response.setfTypeId(request.getFavoriteTypeId().toString());
return response;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,12 @@ private LoggingHistoryEntity convertDtoToEntity(LoggingHistoryRequest loggingHis
loggingHistoryEntity.setMaterialDemandId(UUID.fromString(loggingHistoryRequest.getMaterialDemandId()));
}
if (null != capacityGroupID && !capacityGroupID.isEmpty()) {

if (loggingHistoryRequest.getMaterialDemandId() != null) {
loggingHistoryEntity.setMaterialDemandId(UUID.fromString(loggingHistoryRequest.getMaterialDemandId()));
}

if (loggingHistoryRequest.getCapacityGroupId() != null) {
loggingHistoryEntity.setCapacityGroupId(UUID.fromString(loggingHistoryRequest.getCapacityGroupId()));
}

Expand All @@ -126,6 +132,8 @@ private LoggingHistoryEntity convertDtoToEntity(LoggingHistoryRequest loggingHis
loggingHistoryEntity.setDescription(loggingHistoryRequest.getEventDescription());
loggingHistoryEntity.setIsFavorited(loggingHistoryRequest.getIsFavorited());


}
return loggingHistoryEntity;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ private void postLogs(String weekBasedCapacityGroupId) {
loggingHistoryRequest.setMaterialDemandId(weekBasedCapacityGroupId);
loggingHistoryRequest.setIsFavorited(false);
loggingHistoryRequest.setEventDescription("WEEKLY_BASED_CAPACITY_GROUP Created");
//TODO: Add Event
loggingHistoryRequest.setEventType(EventType.GENERAL_EVENT.toString());
loggingHistoryService.createLog(loggingHistoryRequest);
}
Expand Down Expand Up @@ -173,28 +172,9 @@ public void createWeekBasedCapacityGroupRequestFromEntity(CapacityGroupEntity ca
WeekBasedCapacityGroupRequest basedCapacityGroupRequest = new WeekBasedCapacityGroupRequest();

basedCapacityGroupRequest.setCapacityGroupId(capacityGroupEntity.getId().toString());
// basedCapacityGroupRequest.setUnityOfMeasure(capacityGroupEntity.getUnitMeasure().getCodeValue());
basedCapacityGroupRequest.setCustomer(capacityGroupEntity.getCustomer().getBpn());
// basedCapacityGroupRequest.setCustomer(capacityGroupEntity.getCustomerId().getBpn());
basedCapacityGroupRequest.setSupplier(capacityGroupEntity.getSupplier().getBpn());
basedCapacityGroupRequest.setName(capacityGroupEntity.getCapacityGroupName());
// basedCapacityGroupRequest.setChangedAt(capacityGroupEntity.getChangedAt().toString());
// basedCapacityGroupRequest.setSupplierLocations(capacityGroupEntity.getSupplierLocation());

// List<LinkedDemandSeriesRequest> linkedDemandSeries = capacityGroupEntity
// .getLinkedDemandSeries()
// .stream()
// .map(WeekBasedCapacityGroupServiceImpl::getLinkedDemandSeries)
// .toList();
// basedCapacityGroupRequest.setLinkedDemandSeries(linkedDemandSeries);
//
// List<CapacitiesDto> capacitiesDtos = capacityGroupEntity
// .getCapacityTimeSeries()
// .stream()
// .map(WeekBasedCapacityGroupServiceImpl::getCapacitiesDto)
// .toList();
//
// basedCapacityGroupRequest.setCapacities(capacitiesDtos);
updateStatus();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public class WeekBasedMaterialServiceImpl implements WeekBasedMaterialService {
private final LinkDemandService linkDemandService;

private final StatusesRepository statusesRepository;
private final LoggingHistoryService loggingHistoryService;
private List<WeekBasedMaterialDemandResponseDto> oldWeekBasedMaterialDemands;
private List<WeekBasedMaterialDemandResponseDto> newWeekBasedMaterialDemands;

Expand All @@ -62,8 +63,6 @@ public class WeekBasedMaterialServiceImpl implements WeekBasedMaterialService {

private final DemandService demandService;

private final LoggingHistoryService loggingHistoryService;

@Override
public void createWeekBasedMaterial(List<WeekBasedMaterialDemandRequestDto> weekBasedMaterialDemandRequestDtoList) {
oldWeekBasedMaterialDemands =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ spring:
user: ${DCM_DATASOURCE_USER:dcm}
password: ${DCM_DATASOURCE_PASS:dcm}
schemas: migrations
locations: classpath:db/migration
locations: classpath:db/migration/postgresql

management:
security:
Expand Down
6 changes: 6 additions & 0 deletions demand-capacity-mgmt-frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,25 @@
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"@types/jest": "^29.5.2",
"@types/js-cookie": "^3.0.4",
"@types/node": "^20.3.1",
"@types/react": "^18.2.13",
"@types/react-dom": "^18.2.6",
"axios": "^1.4.0",
"bootstrap": "^5.3.2",
"date-fns": "^2.30.0",
"http-proxy-middleware": "^2.0.6",
"js-cookie": "^3.0.5",
"jwt-decode": "^3.1.2",
"moment": "^2.29.4",
"moment-weekday-calc": "^1.1.4",
"prop-types": "^15.8.1",
"qs": "^6.11.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-icons": "^4.10.1",
"react-native": "^0.72.4",
"react-oauth2-auth-code-flow": "^1.0.2",
"react-router-dom": "^6.14.2",
"react-scripts": "^5.0.1",
"react-select": "4.3.1",
Expand Down Expand Up @@ -65,6 +70,7 @@
"devDependencies": {
"@babel/plugin-transform-flow-strip-types": "^7.22.5",
"@babel/template": "^7.22.5",
"@types/keycloak-js": "^3.4.1",
"@types/react-datepicker": "^4.11.2",
"@types/react-native": "^0.72.2",
"@types/react-select": "^4.0.18",
Expand Down
Loading

0 comments on commit 44e42d6

Please sign in to comment.