Skip to content

Commit

Permalink
docs: add Javadoc for ConsumptionService
Browse files Browse the repository at this point in the history
  • Loading branch information
ronjaquensel committed Jul 21, 2023
1 parent 22add04 commit b36056e
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,34 @@

import java.util.Map;

/**
* Input for a consumption process.
*
* @author Ronja Quensel
*/
@AllArgsConstructor
@NoArgsConstructor
@Builder(toBuilder = true)
@Getter
public class ConsumptionInputDto {
/** ID of the provider. */
private String connectorId;

/** Address of the provider. */
private String connectorAddress;

/** ID of the offer which is the basis for the consumption request. */
private String offerId;

/** ID of the asset that is requested. */
private String assetId;

/** Policy used as the basis for the contract negotiation. */
private PolicyDto policy;

/**
* Destination where the data should be transferred. For reference, see
* {@link org.eclipse.edc.spi.types.domain.DataAddress}
*/
private Map<String, String> dataDestination;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,26 @@
import java.util.List;

/**
* DTO Class for ConsumerOutput
* DTO holding information about a consumption process.
*
* @author Steffen Biehs
* @author Steffen Biehs, Ronja Quensel
*/
@NoArgsConstructor
@AllArgsConstructor
@Getter
public class ConsumptionOutputDto {
/** ID of the process. */
private String id;

/** The input that was used to start this process. */
private ConsumptionInputDto input;

/** Collection of errors that may have occurred during this process. */
private List<String> errors;

/** Information about the contract negotiation associated with this process. */
private ContractNegotiationOutputDto contractNegotiation;

/** Information about the transfer process associated with this process. */
private TransferProcessOutputDto transferProcess;
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@
import static java.util.UUID.randomUUID;
import static org.eclipse.edc.spi.CoreConstants.EDC_NAMESPACE;

/**
* Service for managing consumption processes (= contract negotiation and subsequent data transfer).
*
* @author Ronja Quensel
*/
@RequiredArgsConstructor
@Slf4j
public class ConsumptionService {
Expand All @@ -48,6 +53,14 @@ public class ConsumptionService {
private final TypeTransformerRegistry transformerRegistry;
private final PolicyMappingService policyMappingService;

/**
* Starts a consumption process for the asset specified in the input. Validates the input and
* then triggers a contract negotiation with the specified provider. After the negotiation
* is finalized, the corresponding transfer will be started after a call-back.
*
* @param consumptionInputDto the input for the process.
* @return the process id.
*/
public String startConsumptionProcess(ConsumptionInputDto consumptionInputDto) {
//TODO generate ID
var id = "id";
Expand Down Expand Up @@ -86,6 +99,12 @@ public String startConsumptionProcess(ConsumptionInputDto consumptionInputDto) {
return id;
}

/**
* Method used for callback after the contract negotiation has been finalized. Will be called
* by a corresponding listener. Starts the transfer as defined in the original process input.
*
* @param contractNegotiation the finalized contract negotiation.
*/
public void negotiationConfirmed(ContractNegotiation contractNegotiation) {
var process = findByNegotiation(contractNegotiation);

Expand Down Expand Up @@ -116,6 +135,15 @@ public void negotiationConfirmed(ContractNegotiation contractNegotiation) {
}
}

/**
* Returns information about a consumption process. Retrieves the corresponding contract
* negotiation and transfer process, transforms them to an output format and returns them
* together with other persisted information about the consumption process like the original
* input.
*
* @param id the process id.
* @return information about the process.
*/
public ConsumptionOutputDto getConsumptionProcess(String id) {
var process = consumptionProcesses.get(id);
if (process == null) {
Expand Down

0 comments on commit b36056e

Please sign in to comment.