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
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Set up JDK 8
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '8'
java-version: '21'
distribution: 'corretto'
cache: maven

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Set up Maven Central Repository
uses: actions/setup-java@v4
with:
java-version: '8'
java-version: '21'
distribution: 'corretto'
server-id: central
server-username: MAVEN_USERNAME
Expand Down
154 changes: 84 additions & 70 deletions dev_scripts/codegen/meta_model.py

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dev_scripts/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ classifiers = [
]
requires-python = ">=3.9"
dependencies = [
"aas-core-codegen@git+https://github.com/aas-core-works/aas-core-codegen@4c01ed64#egg=aas-core-codegen",
"aas-core-codegen@git+https://github.com/aas-core-works/aas-core-codegen@9db4f51",
"lxml",
"requests>=2.32.5",
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ public static void main(String[] args) {

MethodDeclaration constructMethod = null;
for (MethodDeclaration method : verificationCls.getMethods()) {
if (method.getName().toString().equals("constructMatchesRfc8089Path")) {
if (method.getName().toString().equals("constructMatchesRfc2396")) {
constructMethod = method;
break;
}
}

if (constructMethod == null) {
System.err.println(
"Could not find the method constructMatchesRfc8089Path in " + sourcePath
"Could not find the method constructMatchesRfc2396 in " + sourcePath
);
System.exit(1);
return;
Expand All @@ -73,7 +73,7 @@ public static void main(String[] args) {

if (!constructMethod.getBody().isPresent()) {
System.err.println(
"The constructMatchesRfc8089Path lacks the body in " + sourcePath
"The constructMatchesRfc2396 lacks the body in " + sourcePath
);
System.exit(1);
return;
Expand All @@ -94,22 +94,25 @@ public static void main(String[] args) {
if (expression instanceof VariableDeclarationExpr) {
VariableDeclarationExpr varDeclExpr = (VariableDeclarationExpr) expression;

if (expression.toString().equals("String pattern = \"^\" + fileUri + \"$\"")) {
if (expression.toString().equals(
"String uriReference = \"^(\" + absoluteuri + \"|\" + relativeuri + \")?(#\" + fragment + \")?$\"")) {
expectedPatternDecl = varDeclExpr.getVariable(0);
}
}
} else if (statement.isReturnStmt()) {
ReturnStmt returnStmt = (ReturnStmt) statement;

if (returnStmt.toString().equals("return Pattern.compile(pattern);")) {
if (returnStmt.toString().equals("return Pattern.compile(uriReference);")) {
expectedReturnStmt = returnStmt;
}
}
}

if (expectedPatternDecl == null) {
System.err.println(
"The constructMatchesRfc8089Path lacks the 'String pattern = \"^\" + fileUri + \"$\"' statement in "
"The constructMatchesRfc2396 lacks the "
+ "'String uriReference = \"^(\" + absoluteuri + \"|\" + relativeuri + \")?(#\" + fragment + \")?$\"' "
+ "statement in "
+ sourcePath
);
System.exit(1);
Expand All @@ -118,23 +121,25 @@ public static void main(String[] args) {

if (expectedReturnStmt == null) {
System.err.println(
"The constructMatchesRfc8089Path lacks the expected return statement " +
"'return Pattern.compile(pattern);' in " + sourcePath
"The constructMatchesRfc2396 lacks the expected return statement " +
"'return Pattern.compile(uriReference);' in " + sourcePath
);
System.exit(1);
return;
}

expectedPatternDecl.setInitializer("fileUri");
expectedPatternDecl.setInitializer(
"\"(\" + absoluteuri + \"|\" + relativeuri + \")?(#\" + fragment + \")?\""
);

expectedReturnStmt.setExpression(
StaticJavaParser.parseExpression("new RegExp(pattern).toAutomaton()")
StaticJavaParser.parseExpression("new RegExp(uriReference).toAutomaton()")
);

VariableDeclarator regexVariable = null;
for (FieldDeclaration field : verificationCls.getFields()) {
for (VariableDeclarator declarator : field.getVariables()) {
if (declarator.getNameAsString().equals("regexMatchesRfc8089Path")) {
if (declarator.getNameAsString().equals("regexMatchesRfc2396")) {
regexVariable = declarator;
break;
}
Expand All @@ -146,7 +151,7 @@ public static void main(String[] args) {

if (regexVariable == null) {
System.err.println(
"Could not find regexMatchesRfc8089Path field in " + sourcePath
"Could not find regexMatchesRfc2396 field in " + sourcePath
);
System.exit(1);
return;
Expand All @@ -155,15 +160,15 @@ public static void main(String[] args) {

MethodDeclaration matchesMethod = null;
for (MethodDeclaration method : verificationCls.getMethods()) {
if (method.getName().toString().equals("matchesRfc8089Path")) {
if (method.getName().toString().equals("matchesRfc2396")) {
matchesMethod = method;
break;
}
}

if (matchesMethod == null) {
System.err.println(
"Could not find the method matchesRfc8089Path in " + sourcePath
"Could not find the method matchesRfc2396 in " + sourcePath
);
System.exit(1);
return;
Expand All @@ -172,7 +177,7 @@ public static void main(String[] args) {
matchesMethod.setBody(
StaticJavaParser.parseBlock("""
{
return regexMatchesRfc8089Path.run(text);
return regexMatchesRfc2396.run(text);
}""")
);

Expand Down
81 changes: 46 additions & 35 deletions dev_scripts/semantic-patching/test-data/Verification.java
Original file line number Diff line number Diff line change
Expand Up @@ -157,48 +157,59 @@ public static Boolean matchesMimeType(String text) {
return regexMatchesMimeType.matcher(text).matches();
}

private static Pattern constructMatchesRfc8089Path() {
String h16 = "[0-9A-Fa-f]{1,4}";
String decOctet = "([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])";
String ipv4address = decOctet + "\\." + decOctet + "\\." + decOctet + "\\." + decOctet;
String ls32 = "(" + h16 + ":" + h16 + "|" + ipv4address + ")";
String ipv6address = "((" + h16 + ":){6}" + ls32 + "|::(" + h16 + ":){5}" + ls32 + "|(" + h16 + ")?::(" + h16 + ":){4}" + ls32 + "|((" + h16 + ":)?" + h16 + ")?::(" + h16 + ":){3}" + ls32 + "|((" + h16 + ":){2}" + h16 + ")?::(" + h16 + ":){2}" + ls32 + "|((" + h16 + ":){3}" + h16 + ")?::" + h16 + ":" + ls32 + "|((" + h16 + ":){4}" + h16 + ")?::" + ls32 + "|((" + h16 + ":){5}" + h16 + ")?::" + h16 + "|((" + h16 + ":){6}" + h16 + ")?::)";
String unreserved = "[a-zA-Z0-9\\-._~]";
String subDelims = "[!$&\'()*+,;=]";
String ipvfuture = "[vV][0-9A-Fa-f]+\\.(" + unreserved + "|" + subDelims + "|:)+";
String ipLiteral = "\\[(" + ipv6address + "|" + ipvfuture + ")\\]";
String pctEncoded = "%[0-9A-Fa-f][0-9A-Fa-f]";
String regName = "(" + unreserved + "|" + pctEncoded + "|" + subDelims + ")*";
String host = "(" + ipLiteral + "|" + ipv4address + "|" + regName + ")";
String fileAuth = "(localhost|" + host + ")";
String pchar = "(" + unreserved + "|" + pctEncoded + "|" + subDelims + "|[:@])";
String segmentNz = "(" + pchar + ")+";
String segment = "(" + pchar + ")*";
String pathAbsolute = "/(" + segmentNz + "(/" + segment + ")*)?";
String authPath = "(" + fileAuth + ")?" + pathAbsolute;
String localPath = pathAbsolute;
String fileHierPart = "(//" + authPath + "|" + localPath + ")";
String fileScheme = "file";
String fileUri = fileScheme + ":" + fileHierPart;
String pattern = "^" + fileUri + "$";

return Pattern.compile(pattern);
}

private static final Pattern regexMatchesRfc8089Path = constructMatchesRfc8089Path();
private static Pattern constructMatchesRfc2396() {
String alphanum = "[a-zA-Z0-9]";
String mark = "[-_.!~*\'()]";
String unreserved = "(" + alphanum + "|" + mark + ")";
String hex = "([0-9]|[aA]|[bB]|[cC]|[dD]|[eE]|[fF]|[aA]|[bB]|[cC]|[dD]|[eE]|[fF])";
String escaped = "%" + hex + hex;
String pchar = "(" + unreserved + "|" + escaped + "|[:@&=+$,])";
String param = "(" + pchar + ")*";
String segment = "(" + pchar + ")*(;" + param + ")*";
String pathSegments = segment + "(/" + segment + ")*";
String absPath = "/" + pathSegments;
String scheme = "[a-zA-Z][a-zA-Z0-9+\\-.]*";
String userinfo = "(" + unreserved + "|" + escaped + "|[;:&=+$,])*";
String domainlabel = "(" + alphanum + "|" + alphanum + "(" + alphanum + "|-)*" + alphanum + ")";
String toplabel = "([a-zA-Z]|[a-zA-Z](" + alphanum + "|-)*" + alphanum + ")";
String hostname = "(" + domainlabel + "\\.)*" + toplabel + "(\\.)?";
String ipv4address = "[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+";
String host = "(" + hostname + "|" + ipv4address + ")";
String port = "[0-9]*";
String hostport = host + "(:" + port + ")?";
String server = "((" + userinfo + "@)?" + hostport + ")?";
String regName = "(" + unreserved + "|" + escaped + "|[$,;:@&=+])+";
String authority = "(" + server + "|" + regName + ")";
String netPath = "//" + authority + "(" + absPath + ")?";
String reserved = "[;/?:@&=+$,]";
String uric = "(" + reserved + "|" + unreserved + "|" + escaped + ")";
String query = "(" + uric + ")*";
String hierPart = "(" + netPath + "|" + absPath + ")(\\?" + query + ")?";
String uricNoSlash = "(" + unreserved + "|" + escaped + "|[;?:@&=+$,])";
String opaquePart = uricNoSlash + "(" + uric + ")*";
String absoluteuri = scheme + ":(" + hierPart + "|" + opaquePart + ")";
String fragment = "(" + uric + ")*";
String relSegment = "(" + unreserved + "|" + escaped + "|[;@&=+$,])+";
String relPath = relSegment + "(" + absPath + ")?";
String relativeuri = "(" + netPath + "|" + absPath + "|" + relPath + ")(\\?" + query + ")?";
String uriReference = "^(" + absoluteuri + "|" + relativeuri + ")?(#" + fragment + ")?$";
return Pattern.compile(uriReference);
}

private static final Pattern regexMatchesRfc2396 = constructMatchesRfc2396();

/**
* Check that {@link text} is a path conforming to the pattern of RFC 8089.
* Check that {@link text} is a path conforming to the pattern of RFC 2396.
*
* <p>The definition has been taken from:
* https://datatracker.ietf.org/doc/html/rfc8089
* https://datatracker.ietf.org/doc/html/rfc2396
*
* @param textText to be checked
*
* @returns True if the {@link text} conforms to the pattern
*/
public static Boolean matchesRfc8089Path(String text) {
return regexMatchesRfc8089Path.matcher(text).matches();
public static Boolean matchesRfc2396(String text) {
return regexMatchesRfc2396.matcher(text).matches();
}

private static Pattern constructMatchesBcp47() {
Expand Down Expand Up @@ -9814,12 +9825,12 @@ public static Stream<Reporting.Error> verifyPathType (
"Identifier shall have a maximum length of 2000 characters.")));
}

if (!matchesRfc8089Path(that)) {
if (!matchesRfc2396(that)) {
errorStream = Stream.<Reporting.Error>concat(errorStream,
Stream.of(new Reporting.Error(
"Invariant violated:\n" +
"The value must represent a valid file URI scheme according " +
"to RFC 8089.")));
"to RFC 2396.")));
}

return errorStream;
Expand Down
7 changes: 3 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<maven.compiler.release>8</maven.compiler.release>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jackson.version>2.16.1</jackson.version>
<dk.brics.version>1.12-4</dk.brics.version>
<!--Note: For Java 8 we need the spotless plugin in version <= 2.30.0 -->
<spotless.maven.plugin.version>2.30.0</spotless.maven.plugin.version>
<spotless.maven.plugin.version>3.2.1</spotless.maven.plugin.version>
<javadoc.maven.plugin.version>3.6.3</javadoc.maven.plugin.version>
<!-- Disable gpg signing per default to allow mvn install and alike w/o gpg setup -->
<gpg.skip>true</gpg.skip>
Expand Down Expand Up @@ -96,8 +96,7 @@
<include>src/test/java/**/*.java</include>
</includes>
<googleJavaFormat>
<!--Note: JVM 8, is limited to google-java-format 1.7.-->
<version>1.7</version>
<version>1.17.0</version>
<style>GOOGLE</style>
</googleJavaFormat>
<importOrder/>
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/aas_core/aas3_0/types/impl/Blob.java
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,9 @@ public Iterable<IEmbeddedDataSpecification> overEmbeddedDataSpecificationsOrEmpt
return getEmbeddedDataSpecifications().orElseGet(Collections::emptyList);
}

/** @return the category or the default value if it has not been set. */
/**
* @return the category or the default value if it has not been set.
*/
public String categoryOrDefault() {
return category != null ? category : "VARIABLE";
}
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/aas_core/aas3_0/types/impl/Extension.java
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,9 @@ public Iterable<IReference> overRefersToOrEmpty() {
return getRefersTo().orElseGet(Collections::emptyList);
}

/** @return the value type {@link DataTypeDefXsd} or the default value if it has not been set. */
/**
* @return the value type {@link DataTypeDefXsd} or the default value if it has not been set.
*/
public DataTypeDefXsd valueTypeOrDefault() {
return valueType != null ? valueType : DataTypeDefXsd.STRING;
}
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/aas_core/aas3_0/types/impl/File.java
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,9 @@ public Iterable<IEmbeddedDataSpecification> overEmbeddedDataSpecificationsOrEmpt
return getEmbeddedDataSpecifications().orElseGet(Collections::emptyList);
}

/** @return the category or the default value if it has not been set. */
/**
* @return the category or the default value if it has not been set.
*/
public String categoryOrDefault() {
return category != null ? category : "VARIABLE";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,9 @@ public Iterable<ILangStringTextType> overValueOrEmpty() {
return getValue().orElseGet(Collections::emptyList);
}

/** @return the category or the default value if it has not been set. */
/**
* @return the category or the default value if it has not been set.
*/
public String categoryOrDefault() {
return category != null ? category : "VARIABLE";
}
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/aas_core/aas3_0/types/impl/Property.java
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,9 @@ public Iterable<IEmbeddedDataSpecification> overEmbeddedDataSpecificationsOrEmpt
return getEmbeddedDataSpecifications().orElseGet(Collections::emptyList);
}

/** @return the category or the default value if it has not been set. */
/**
* @return the category or the default value if it has not been set.
*/
public String categoryOrDefault() {
return category != null ? category : "VARIABLE";
}
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/aas_core/aas3_0/types/impl/Qualifier.java
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,9 @@ public Iterable<IReference> overSupplementalSemanticIdsOrEmpty() {
return getSupplementalSemanticIds().orElseGet(Collections::emptyList);
}

/** @return the {@link QualifierKind} or the default value if it has not been set. */
/**
* @return the {@link QualifierKind} or the default value if it has not been set.
*/
public QualifierKind kindOrDefault() {
return kind != null ? kind : QualifierKind.CONCEPT_QUALIFIER;
}
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/aas_core/aas3_0/types/impl/Range.java
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,9 @@ public Iterable<IEmbeddedDataSpecification> overEmbeddedDataSpecificationsOrEmpt
return getEmbeddedDataSpecifications().orElseGet(Collections::emptyList);
}

/** @return the category or the default value if it has not been set. */
/**
* @return the category or the default value if it has not been set.
*/
public String categoryOrDefault() {
return category != null ? category : "VARIABLE";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,9 @@ public Iterable<IEmbeddedDataSpecification> overEmbeddedDataSpecificationsOrEmpt
return getEmbeddedDataSpecifications().orElseGet(Collections::emptyList);
}

/** @return the category or the default value if it has not been set. */
/**
* @return the category or the default value if it has not been set.
*/
public String categoryOrDefault() {
return category != null ? category : "VARIABLE";
}
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/aas_core/aas3_0/types/impl/Submodel.java
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,9 @@ public Iterable<ISubmodelElement> overSubmodelElementsOrEmpty() {
return getSubmodelElements().orElseGet(Collections::emptyList);
}

/** @return the {@link ModellingKind} or the default value if it has not been set. */
/**
* @return the {@link ModellingKind} or the default value if it has not been set.
*/
public ModellingKind kindOrDefault() {
return kind != null ? kind : ModellingKind.INSTANCE;
}
Expand Down
Loading