Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore/add javadocs #26

Merged
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ private void createRequest() throws JsonProcessingException {
rfm = new ProductStockRequestForMaterial("OtherCU-MNR",
null, "OtherSU-MNR");
productStock.add(rfm);
request.setState(DT_RequestStateEnum.WORKING);
request.setState(DT_RequestStateEnum.Working);

request = productStockRequestService.createRequest(request);

Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -32,31 +32,28 @@ public enum DT_RequestStateEnum {
/**
* The consumer requested something.
*/
REQUESTED("Requested"),
Requested,

/**
* The provider receipt the request of the consumer.
* The supplier received the request of the consumer.
*/
RECEIPT("Received"),
Received,

/**
* The provider works on fulfilling the requested service or data.
* The supplier works on fulfilling the requested service or data.
*/
WORKING("Working"),
Working,

/**
* The provider fulfilled the service and sent the data to the consumer.
* The supplier fulfilled the service and sent the data to the consumer.
*/
COMPLETED("Completed"),
Completed,

/**
* An error occured between the start and completion of a request.
*/
ERROR("Error");
Error;


final public String STATUSTEXT;
private DT_RequestStateEnum(String statustext) {
this.STATUSTEXT = statustext;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,23 @@
*/
package org.eclipse.tractusx.puris.backend.common.edc.controller;

import com.fasterxml.jackson.databind.JsonNode;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.ExampleObject;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import lombok.extern.slf4j.Slf4j;
import org.eclipse.tractusx.puris.backend.common.edc.logic.dto.EDR_Dto;
import org.eclipse.tractusx.puris.backend.common.edc.logic.service.EndpointDataReferenceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import com.fasterxml.jackson.databind.JsonNode;
import lombok.extern.slf4j.Slf4j;

import java.util.UUID;

/**
* This class contains the endpoint for receiving the authCodes from
Expand All @@ -48,6 +56,25 @@ public class EndpointDataReferenceReceiver {
* @return
*/
@PostMapping("/edrendpoint")
@Operation(summary = "Endpoint for receiving the authCodes from the counterparty's dataplane",
requestBody = @io.swagger.v3.oas.annotations.parameters.RequestBody(
content = @Content(examples = {
@ExampleObject(name = "EDR Token",
value = "{\n" +
" \"id\" : \"6c2e5600-294a-488e-8ce1-2073806c1927\",\n" +
" \"endpoint\" : \"http://sokrates-dataplane:8181/api/public\",\n" +
" \"authKey\" : \"Authorization\",\n" +
" \"authCode\" : \"eyJhbGciOiJSUzI1NiJ9.eyJleHAiOjE2OTMyMTgzNzIsImRhZCI6Ik5YY2J1VktDOVFCTWY5eG9BQUFBQWN3RmE2blhIS1JEcllHTnZCeUNlbTdCNTBOVkVWd05vczdsNU1YM0lKL1pVK0NUU3NvcE02ZUVFbzloYmx5ak1aTlJYYnRnOUZpZ04vampRVmVlaDFWQk01RHA1RXUyN2VIbk5TNCt0VE9uMEZFZTVGVGNITjh6dWwwZG5VbW1nbCtsVERxODZhdHUwbjYxZVV5dXNzQ25pbTZDaWhOai9lRXZ0cUZydVhCbXNIWVQvSTNYN3JrYk1FeFZWRFhBOHNPVGFGeFVpTnl3YTI0cURpWkFnc0Nka1FDenBaSFVIWk16ZDQrNURKTTVkVkNDWnEyUHBnRDhuR09wVzVVTTJUYUlmNHdMOTFQbnhEdEQ2a1dWTCtNQUNGSE41S2RyVUt2a3pOeXAyRzVYcWJ2V29waEhhY0VLTTR4UTZDc2dkUHFoMGN6elNnbFZGdy9IWVl3ZDBXQVpCcnVSSTlUekY4WTJkMXBscW5zRFFwcWh1bUUz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n" +
" \"properties\" : {\n" +
" \"cid\" : \"product-stock-request-api:a050bf51-1ab1-4de4-834c-f5ce0a3030ea\"\n" +
" }\n" +
"}\n")
})
))
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Ok"),
@ApiResponse(responseCode = "400", description = "Received invalid message")
})
private ResponseEntity<String> authCodeReceivingEndpoint(@RequestBody JsonNode body) {
log.debug("Received edr data:\n" + body.toPrettyString());
String transferId = body.get("id").asText();
Expand All @@ -63,4 +90,4 @@ private ResponseEntity<String> authCodeReceivingEndpoint(@RequestBody JsonNode b
return ResponseEntity.status(200).build();
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,33 @@

import lombok.AllArgsConstructor;
import lombok.Getter;
import org.eclipse.tractusx.puris.backend.common.edc.logic.service.EndpointDataReferenceService;

/**
* An internal, immutable Dto class used by the {@link EndpointDataReferenceService}
* It contains an authKey, authCode and endpoint.
*/
@AllArgsConstructor
@Getter
public class EDR_Dto {

/**
* This defines the key, under which the
* authCode is to be sent to the data plane.
* For example: "Authorization"
*/
private final String authKey;

/**
* This is the secret key to be sent
* to the data plane.
*/
private final String authCode;

/**
* The address of the data plane that has
* to handle the consumer pull.
*/
private final String endpoint;

}
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ public JsonNode getCatalogFilteredByAssetPropertyObjectFilter(String idsUrl, Map
/**
* Orders your own EDC Connector Controlplane to negotiate a contract with
* the owner of the given connector address for an asset (specified by the
* assetId) under conditions as stated in the contract defintion with the
* assetId) under conditions as stated in the contract definition with the
* given contractDefinitionId
* @param connectorAddress
* @param contractDefinitionId
Expand Down Expand Up @@ -303,8 +303,8 @@ public String startTransfer(String transferId,
* Sends a request to the own EDC Connector Controlplane in order to receive
* the current status of the previously initiated transfer as specified by
* the parameter.
* @param transferId
* @return
* @param transferId the id of the transfer in question
* @return the response from your Controlplane
* @throws IOException
*/
public String getTransferState(String transferId) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public class EndpointDataReferenceService {
* Please note that any data will only be stored for a period of 5
* minutes.
* @param transferId
* @param authCode
* @param edr_Dto
eschrewe marked this conversation as resolved.
Show resolved Hide resolved
*/
public void save(String transferId, EDR_Dto edr_Dto) {
nonpersistantRepository.put(transferId, edr_Dto);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public JsonNode buildNegotiationRequestBody(String connectorAddress,
offerNode.put("assetId", assetId);
var policyNode = MAPPER.createObjectNode();
policyNode.put("uid", assetId);
policyNode.set("prohibiitons", MAPPER.createArrayNode());
policyNode.set("prohibitions", MAPPER.createArrayNode());
policyNode.set("obligations", MAPPER.createArrayNode());
var permissionArray = MAPPER.createArrayNode();
var permissionNode = MAPPER.createObjectNode();
Expand Down Expand Up @@ -185,7 +185,7 @@ public CreateAssetDto buildCreateAssetDtoForApi(DT_ApiMethodEnum method,
AssetPropertiesDto apiAssetPropertiesDto = new AssetPropertiesDto();
apiAssetPropertiesDto.setApiBusinessObject(DT_ApiBusinessObjectEnum.PRODUCT_STOCK.PROPERTIES_DESCRIPTION);
apiAssetPropertiesDto.setApiPurpose(method.PURPOSE);
apiAssetPropertiesDto.setContentType("appplication/json");
apiAssetPropertiesDto.setContentType("application/json");
apiAssetPropertiesDto.setId(variablesService.getApiAssetId(method));
apiAssetPropertiesDto.setName(method.NAME);
apiAssetPropertiesDto.setType(DT_AssetTypeEnum.api);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,37 @@
import java.util.Objects;
import java.util.Set;

/**
* <p>This class represents materials and products that are to be traded between
* partners that collaborate via the PURIS application. </p>
* <p>Whether a material is a product or a "material", is determined by the point of
* view. If the owner of the current instance of a PURIS application is selling a
* certain product to customers, the product flag must be set to "true" and the business
* logic will treat this material as a product if the circumstances require a differentiation
* between products and materials.</p>
* <p>If, on the other hand, the owner of the current instance of a PURIS application is buying
* a material from external partners, then the material-flag must be set to "true", in order to
* allow the business logic to handle this correctly.</p>
* <p>This approach allows for flexibility, especially in cases when the the owner of the current
* instance of a PURIS application is a trader who is buying a certain good from one partner just
* to sell it immediately to another partner. </p>
* <p>Each entity of this class is uniquely identified by the material number defined
* by the partner that runs an instance of the PURIS app.</p>
* <p>Example: A certain type of semiconductors is produced by partner A. He has labeled his
* product with the material number "SC-456.001". Partner B is buying this type of
* semiconductors from A. In his own ERP-System, he is referring to this semiconductor
* as "A-CHIP-0815".</p>
* <p>In partner A's PURIS app this material will be registered under the ownMaterialNumber
* "SC-456.001", while partner B will registered as "A-CHIP-0815". Let's further assume
* that Partner C now wants to buy this material from A as well. In his own domain, C names
* this material "XYZ-123". Therefore C will register the material under this ownMaterialNumber
* in his own PURIS app.</p>
* <p>When two partners are preparing to establish a business relationship in regard to a specific
* material, then each partner will create a {@link MaterialPartnerRelation}, where he
* designates the other partner as supplier or customer of this entity. He also must define,
* under which material number his partner refers to this material.</p>
eschrewe marked this conversation as resolved.
Show resolved Hide resolved
*
*/
@Entity
@Table(name = "material")
@Getter
Expand All @@ -55,11 +86,22 @@ public class Material {
*/
private boolean productFlag;

/**
* The unique material number defined by the owner of this
* PURIS instance for this material.
*/
@Id
private String ownMaterialNumber;

/**
* If there is a Catena-X material number defined
* for this material, this is stored here.
*/
private String materialNumberCx;

/**
* Informal name or description of the material.
*/
private String name;

@OneToMany(mappedBy = "material")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,22 @@
import java.util.Objects;
import java.util.UUID;

/**
* <p>This class represents a relation between an instance of the {@link Material} Entity
* and one instance of the {@link Partner} Entity. For each pair of Material and Partner
* Entities there exists at most one MaterialPartnerRelation. </p>
* <p>This class stores, under which identifier (material number) the Partner knows
* this Material, and whether this Partner is a supplier or a customer of the Material.</p>
*
*/
@Entity
@Getter
@Setter
@AllArgsConstructor
public class MaterialPartnerRelation {

@EmbeddedId
Key key;
private Key key;

private String partnerMaterialNumber;
private boolean partnerSuppliesMaterial;
Expand All @@ -44,12 +52,12 @@ public class MaterialPartnerRelation {
@ManyToOne
@MapsId("ownMaterialNumber")
@JoinColumn(name = "material_ownMaterialNumber")
Material material;
private Material material;

@ManyToOne
@MapsId("uuid")
@JoinColumn(name = "partner_uuid")
Partner partner;
private Partner partner;

public MaterialPartnerRelation() {
this.key = new Key();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ public class Partner {
/**
* The BPNL of the partner.
*/

private String bpnl;
@ElementCollection
/**
Expand Down
Loading
Loading