-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: connector and contractoffer models and stores (#24)
- Loading branch information
1 parent
26b2965
commit 303c9f2
Showing
5 changed files
with
154 additions
and
0 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
...roker-server/src/main/java/de/sovity/edc/ext/brokerserver/dao/models/ConnectorRecord.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright (c) 2023 sovity GmbH | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Apache License, Version 2.0 which is available at | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* Contributors: | ||
* sovity GmbH - initial API and implementation | ||
* | ||
*/ | ||
|
||
package de.sovity.edc.ext.brokerserver.dao.models; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.Getter; | ||
import lombok.ToString; | ||
import lombok.experimental.FieldDefaults; | ||
|
||
import java.time.OffsetDateTime; | ||
|
||
@Getter | ||
@ToString | ||
@Builder(toBuilder = true) | ||
@EqualsAndHashCode(of = "id") | ||
@AllArgsConstructor(access = lombok.AccessLevel.PRIVATE) | ||
@FieldDefaults(makeFinal = true, level = lombok.AccessLevel.PRIVATE) | ||
public class ConnectorRecord { | ||
String id; | ||
String idsId; | ||
String title; | ||
String description; | ||
String endpoint; | ||
OffsetDateTime lastUpdate; | ||
OffsetDateTime offlineSince; | ||
OffsetDateTime createdAt; | ||
OnlineStatus onlineStatus; | ||
} |
18 changes: 18 additions & 0 deletions
18
...r-server/src/main/java/de/sovity/edc/ext/brokerserver/dao/models/ContractOfferRecord.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package de.sovity.edc.ext.brokerserver.dao.models; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.Getter; | ||
import lombok.ToString; | ||
import lombok.experimental.FieldDefaults; | ||
|
||
@Getter | ||
@ToString | ||
@Builder(toBuilder = true) | ||
@EqualsAndHashCode(of = "id") | ||
@AllArgsConstructor(access = lombok.AccessLevel.PRIVATE) | ||
@FieldDefaults(makeFinal = true, level = lombok.AccessLevel.PRIVATE) | ||
public class ContractOfferRecord { | ||
String id; | ||
} |
20 changes: 20 additions & 0 deletions
20
...s/broker-server/src/main/java/de/sovity/edc/ext/brokerserver/dao/models/OnlineStatus.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* Copyright (c) 2023 sovity GmbH | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Apache License, Version 2.0 which is available at | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* Contributors: | ||
* sovity GmbH - initial API and implementation | ||
* | ||
*/ | ||
|
||
package de.sovity.edc.ext.brokerserver.dao.models; | ||
|
||
public enum OnlineStatus { | ||
ONLINE, | ||
OFFLINE | ||
} |
37 changes: 37 additions & 0 deletions
37
...erver/src/main/java/de/sovity/edc/ext/brokerserver/dao/stores/InMemoryConnectorStore.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright (c) 2023 sovity GmbH | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Apache License, Version 2.0 which is available at | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* Contributors: | ||
* sovity GmbH - initial API and implementation | ||
* | ||
*/ | ||
|
||
package de.sovity.edc.ext.brokerserver.dao.stores; | ||
|
||
import de.sovity.edc.ext.brokerserver.dao.models.ConnectorRecord; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.stream.Stream; | ||
|
||
public class InMemoryConnectorStore { | ||
private final Map<String, ConnectorRecord> connectorsById = new HashMap<>(); | ||
|
||
public Stream<ConnectorRecord> findAll() { | ||
return connectorsById.values().stream(); | ||
} | ||
|
||
public ConnectorRecord findById(String connectorId) { | ||
return connectorsById.get(connectorId); | ||
} | ||
|
||
public ConnectorRecord save(ConnectorRecord connector) { | ||
return connectorsById.put(connector.getId(), connector); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
...r/src/main/java/de/sovity/edc/ext/brokerserver/dao/stores/InMemoryContractOfferStore.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright (c) 2023 sovity GmbH | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Apache License, Version 2.0 which is available at | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* Contributors: | ||
* sovity GmbH - initial API and implementation | ||
* | ||
*/ | ||
|
||
package de.sovity.edc.ext.brokerserver.dao.stores; | ||
|
||
import de.sovity.edc.ext.brokerserver.dao.models.ContractOfferRecord; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.stream.Stream; | ||
|
||
public class InMemoryContractOfferStore { | ||
private final Map<String, ContractOfferRecord> contractOffersById = new HashMap<>(); | ||
|
||
public Stream<ContractOfferRecord> findAll() { | ||
return contractOffersById.values().stream(); | ||
} | ||
|
||
public ContractOfferRecord findById(String contractOfferId) { | ||
return contractOffersById.get(contractOfferId); | ||
} | ||
|
||
public ContractOfferRecord save(ContractOfferRecord contractOffer) { | ||
return contractOffersById.put(contractOffer.getId(), contractOffer); | ||
} | ||
} |