Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
262 changes: 209 additions & 53 deletions README.md

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions api/rest/src/test/resources/extraction/test-db-extraction-1.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,18 @@
"typeHints": ["CarbonFootprint", "CO2Footprint", "CarbonEmission"]
}
}
},
"aasOntology": {
"fields": {
"productName": {
"semanticId": "0173-1#02-AAW338",
"idShortPath": ["Nameplate", "ManufacturerProductDesignation"],
"preferLanguage": "en"
},
"carbonFootprint": {
"semanticId": "0173-1#02-ABG855",
"idShortPath": ["CarbonFootprint", "ProductCarbonFootprints", "ProductCarbonFootprint00", "PcfCO2eq"]
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,14 @@
"typeHints": ["Product","ProductData","DPP","DPPData","Model","ModelData"]
}
}
},
"aasOntology": {
"fields": {
"productName": {
"semanticId": "0173-1#02-AAW338",
"idShortPath": ["Nameplate", "ManufacturerProductDesignation"],
"preferLanguage": "en"
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -106,5 +106,26 @@
"typeHints": ["Height","QuantitativeValue"]
}
}
},
"aasOntology": {
"fields": {
"productName": {
"semanticId": "0173-1#02-AAW338",
"idShortPath": ["Nameplate", "ManufacturerProductDesignation"],
"preferLanguage": "en"
},
"weight": {
"semanticId": "0173-1#02-AAB419",
"idShortPath": ["TechnicalData", "TechnicalProperties", "NetWeight"]
},
"carbonFootprint": {
"semanticId": "0173-1#02-ABG855",
"idShortPath": ["CarbonFootprint", "ProductCarbonFootprints", "ProductCarbonFootprint00", "PcfCO2eq"]
},
"height": {
"semanticId": "0173-1#02-AAB419",
"idShortPath": ["TechnicalData", "TechnicalProperties", "NetHeight"]
}
}
}
}
38 changes: 38 additions & 0 deletions core/src/main/java/it/extrared/extractor/config/AasOntology.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package it.extrared.extractor.config;

import it.extrared.extractor.config.field.AasFieldSpec;
import java.util.Map;
import java.util.Objects;

/**
* Configuration to extract values from Asset Administration Shell (AAS) JSON documents. Supports
* both idShort path navigation and semanticId-based matching.
*/
public class AasOntology {

private Map<String, AasFieldSpec> fields;

public Map<String, AasFieldSpec> getFields() {
return fields;
}

public void setFields(Map<String, AasFieldSpec> fields) {
this.fields = fields;
}

@Override
public boolean equals(Object o) {
if (o == null || getClass() != o.getClass()) return false;
return Objects.equals(fields, ((AasOntology) o).fields);
}

@Override
public int hashCode() {
return Objects.hashCode(fields);
}

@Override
public String toString() {
return "AasOntology{fields=" + fields + '}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package it.extrared.extractor.config;

import it.extrared.extractor.config.field.AasFieldSpec;
import it.extrared.extractor.config.field.FieldType;
import it.extrared.extractor.config.field.SearchField;
import it.extrared.extractor.exceptions.InvalidExtractionConfigException;
Expand All @@ -39,6 +40,8 @@ public class ExtractionConfiguration {

private UnknownOntology unknownOntology;

private AasOntology aasOntology;

/**
* @return the Known Ontology configuration.
*/
Expand Down Expand Up @@ -126,6 +129,7 @@ public void validate() {
KnownOntology knownOntology = getKnownOntology();
UnknownOntology unknownOntology = getUnknownOntology();
NoOntology noOntology = getNoOntology();
AasOntology aasOntology = getAasOntology();
if (knownOntology == null)
throw new InvalidExtractionConfigException(
"Known Ontology configuration must be provided.");
Expand All @@ -135,11 +139,15 @@ public void validate() {
if (unknownOntology == null)
throw new InvalidExtractionConfigException(
"Unknown Ontology configuration must be provided.");
if (aasOntology == null)
throw new InvalidExtractionConfigException(
"AAS Ontology configuration must be provided.");

checkSpecFieldNames(KnownOntology.class, knownOntology.getFields().keySet(), targetTypes);
checkSpecFieldNames(
UnknownOntology.class, unknownOntology.getFields().keySet(), targetTypes);
checkSpecFieldNames(NoOntology.class, noOntology.getFields().keySet(), targetTypes);
checkSpecFieldNames(AasFieldSpec.class, aasOntology.getFields().keySet(), targetTypes);
}

private void checkSpecFieldNames(
Expand All @@ -151,19 +159,12 @@ private void checkSpecFieldNames(
.formatted(subConfigType.getSimpleName(), k));
}

@Override
public boolean equals(Object o) {
if (o == null || getClass() != o.getClass()) return false;
ExtractionConfiguration that = (ExtractionConfiguration) o;
return Objects.equals(searchFields, that.searchFields)
&& Objects.equals(knownOntology, that.knownOntology)
&& Objects.equals(noOntology, that.noOntology)
&& Objects.equals(unknownOntology, that.unknownOntology);
public AasOntology getAasOntology() {
return aasOntology;
}

@Override
public int hashCode() {
return Objects.hash(searchFields, knownOntology, noOntology, unknownOntology);
public void setAasOntology(AasOntology aasOntology) {
this.aasOntology = aasOntology;
}

@Override
Expand All @@ -177,6 +178,24 @@ public String toString() {
+ noOntology
+ ", unknownOntology="
+ unknownOntology
+ ", assOntology="
+ aasOntology
+ '}';
}

@Override
public boolean equals(Object o) {
if (o == null || getClass() != o.getClass()) return false;
ExtractionConfiguration that = (ExtractionConfiguration) o;
return Objects.equals(searchFields, that.searchFields)
&& Objects.equals(knownOntology, that.knownOntology)
&& Objects.equals(noOntology, that.noOntology)
&& Objects.equals(unknownOntology, that.unknownOntology)
&& Objects.equals(aasOntology, that.aasOntology);
}

@Override
public int hashCode() {
return Objects.hash(searchFields, knownOntology, noOntology, unknownOntology, aasOntology);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package it.extrared.extractor.config.field;

import java.util.List;
import java.util.Objects;

/**
* Field specification for AAS JSON extraction.
*
* <p>Supports two complementary matching strategies:
*
* <ul>
* <li><b>semanticId</b>: matches against {@code semanticId.keys[].value} — more precise,
* ontology-stable across different AAS producers.
* <li><b>idShortPath</b>: dot-navigates the submodelElement tree by {@code idShort} — useful when
* semanticId is absent or non-standard.
* </ul>
*
* When both are configured, semanticId match takes priority. For {@code MultiLanguageProperty},
* {@code preferLanguage} drives value selection (default "en").
*/
public class AasFieldSpec {

/**
* Ordered list of idShort segments to navigate: e.g. ["Nameplate", "ManufacturerName"]. May be
* null if semanticId matching is sufficient.
*/
private List<String> idShortPath;

/**
* The semantic ID value to match against {@code semanticId.keys[].value}. May be null if
* idShortPath matching is sufficient.
*/
private String semanticId;

/** Preferred language tag for {@code MultiLanguageProperty} values. Defaults to "en". */
private String preferLanguage = "en";

public List<String> getIdShortPath() {
return idShortPath;
}

public void setIdShortPath(List<String> idShortPath) {
this.idShortPath = idShortPath;
}

public String getSemanticId() {
return semanticId;
}

public void setSemanticId(String semanticId) {
this.semanticId = semanticId;
}

public String getPreferLanguage() {
return preferLanguage;
}

public void setPreferLanguage(String preferLanguage) {
this.preferLanguage = preferLanguage;
}

@Override
public boolean equals(Object o) {
if (o == null || getClass() != o.getClass()) return false;
AasFieldSpec that = (AasFieldSpec) o;
return Objects.equals(idShortPath, that.idShortPath)
&& Objects.equals(semanticId, that.semanticId)
&& Objects.equals(preferLanguage, that.preferLanguage);
}

@Override
public int hashCode() {
return Objects.hash(idShortPath, semanticId, preferLanguage);
}
}
Loading
Loading