Skip to content

Commit

Permalink
feat: connector and contractoffer models and stores (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
tmberthold authored May 11, 2023
1 parent 26b2965 commit 303c9f2
Show file tree
Hide file tree
Showing 5 changed files with 154 additions and 0 deletions.
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;
}
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;
}
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
}
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);
}
}
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);
}
}

0 comments on commit 303c9f2

Please sign in to comment.