Skip to content

Commit

Permalink
chore: re-use existing DataModelVersion (#554)
Browse files Browse the repository at this point in the history
  • Loading branch information
paullatzelsperger authored Feb 6, 2025
1 parent f0ebf46 commit e438299
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,18 +144,16 @@ This is deserialized to:

```java
public class CredentialDefinition {
public enum DataModelType {VCDM_1_1, VCDM_2_0}

private String credentialType;
private String schema;
private String format;
private long validity;

private DataModelType dataModel = DataModelType.VCDM_1_1;
private DataModelVersion dataModel = DataModelVersion.V_1_1;

private List<String> attestations = new ArrayList<>();
private List<CredentialRuleDefinition> rules = new ArrayList<>();
private List<MappingDefinition> mappings = new ArrayList<>();
private final List<MappingDefinition> mappings = new ArrayList<>();
}
```

Expand Down Expand Up @@ -343,7 +341,7 @@ public class IssuanceProcess {
SUBMITTED, APPROVED, DELIVERED, ERRORED
}

private State state = State.SUBMITTED;
private final State state = State.SUBMITTED;
private long stateTimestamp;
private int retries;
private int errorCode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
"version": "1.0.0-alpha",
"urlPath": "/v1alpha",
"lastUpdated": "2025-01-31T12:00:00Z",
"lastUpdated": "2025-02-06T12:00:00Z",
"maturity": null
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
"version": "1.0.0-alpha",
"urlPath": "/v1alpha",
"lastUpdated": "2025-02-03T10:00:00Z",
"lastUpdated": "2025-02-06T10:00:00Z",
"maturity": null
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import org.eclipse.edc.identityhub.spi.issuance.credentials.model.AttestationDefinition;
import org.junit.jupiter.api.Test;

import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

Expand Down Expand Up @@ -85,7 +87,7 @@ void verify_failFast() {

pipeline.registerFactory("testType1", sourceFactory);

var results = pipeline.evaluate(Set.of("a123", "a456"), new DefaultAttestationContext("123", emptyMap()));
var results = pipeline.evaluate(new LinkedHashSet<>(List.of("a123", "a456")), new DefaultAttestationContext("123", emptyMap()));
assertThat(results.failed()).isTrue();

verify(store).resolveDefinition("a123");
Expand Down
1 change: 1 addition & 0 deletions spi/issuance-credentials-spi/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ plugins {
dependencies {
api(libs.edc.spi.core)
api(libs.edc.spi.validator)
api(libs.edc.spi.vc)

testImplementation(libs.edc.lib.json)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

package org.eclipse.edc.identityhub.spi.issuance.credentials.model;

import org.eclipse.edc.iam.verifiablecredentials.spi.model.DataModelVersion;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
Expand All @@ -24,23 +26,23 @@
* Defines credential type that can be issued, its schema, and requirements for issuance.
*/
public class CredentialDefinition {
public enum DataModelType { VCDM_1_1, VCDM_2_0 }

private final List<String> attestations = new ArrayList<>();
private final List<CredentialRuleDefinition> rules = new ArrayList<>();
private final List<MappingDefinition> mappings = new ArrayList<>();
private String credentialType;
private String schema;
private long validity;
private DataModelVersion dataModel = DataModelVersion.V_1_1;

private DataModelType dataModel = DataModelType.VCDM_1_1;

private List<String> attestations = new ArrayList<>();
private List<CredentialRuleDefinition> rules = new ArrayList<>();
private List<MappingDefinition> mappings = new ArrayList<>();
private CredentialDefinition() {
}

public String getCredentialType() {
return credentialType;
}

public DataModelType getDataModel() {
public DataModelVersion getDataModel() {
return dataModel;
}

Expand All @@ -64,11 +66,12 @@ public List<MappingDefinition> getMappings() {
return mappings;
}

private CredentialDefinition() {
}

public static final class Builder {
private CredentialDefinition definition;
private final CredentialDefinition definition;

private Builder() {
definition = new CredentialDefinition();
}

public static Builder newInstance() {
return new Builder();
Expand All @@ -89,7 +92,7 @@ public Builder validity(long validity) {
return this;
}

public Builder dataModel(DataModelType dataModel) {
public Builder dataModel(DataModelVersion dataModel) {
this.definition.dataModel = dataModel;
return this;
}
Expand Down Expand Up @@ -130,10 +133,6 @@ public CredentialDefinition build() {
return definition;
}

private Builder() {
definition = new CredentialDefinition();
}

}

}

0 comments on commit e438299

Please sign in to comment.